askui 0.20.8 → 0.20.10
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/cjs/core/ai-element/ai-element-collection.js.map +1 -0
- package/dist/cjs/core/ai-element/ai-element-error.js.map +1 -0
- package/dist/cjs/core/ai-element/ai-element.js.map +1 -0
- package/dist/cjs/core/annotation/annotation-writer.js.map +1 -0
- package/dist/cjs/core/annotation/annotation.js.map +1 -0
- package/dist/cjs/core/annotation/template.html +470 -10
- package/dist/cjs/core/inference-response/inference-response.js.map +1 -0
- package/dist/cjs/core/inference-response/invalid-model-type-error.js.map +1 -0
- package/dist/cjs/core/inference-response/model-type.d.ts +1 -1
- package/dist/cjs/core/inference-response/model-type.js.map +1 -0
- package/dist/cjs/core/model/annotation-result/annotation-interface.js.map +1 -0
- package/dist/cjs/core/model/annotation-result/boundary-box.js.map +1 -0
- package/dist/cjs/core/model/annotation-result/detected-element.js.map +1 -0
- package/dist/cjs/core/model/custom-element-json.js.map +1 -0
- package/dist/cjs/core/model/custom-element.d.ts +5 -5
- package/dist/cjs/core/model/custom-element.js +2 -2
- package/dist/cjs/core/model/custom-element.js.map +1 -0
- package/dist/cjs/core/reporting/default-step.js.map +1 -0
- package/dist/cjs/core/reporting/index.js +5 -1
- package/dist/cjs/core/reporting/index.js.map +1 -0
- package/dist/cjs/core/reporting/instruction.js.map +1 -0
- package/dist/cjs/core/reporting/reporter-config.js.map +1 -0
- package/dist/cjs/core/reporting/reporter.js.map +1 -0
- package/dist/cjs/core/reporting/snapshot-detail-level.d.ts +1 -1
- package/dist/cjs/core/reporting/snapshot-detail-level.js +1 -2
- package/dist/cjs/core/reporting/snapshot-detail-level.js.map +1 -0
- package/dist/cjs/core/reporting/snapshot.js.map +1 -0
- package/dist/cjs/core/reporting/step-reporter.js.map +1 -0
- package/dist/cjs/core/reporting/step-run.js.map +1 -0
- package/dist/cjs/core/reporting/step-status-end.d.ts +1 -1
- package/dist/cjs/core/reporting/step-status-end.js.map +1 -0
- package/dist/cjs/core/reporting/step-status.d.ts +1 -1
- package/dist/cjs/core/reporting/step-status.js.map +1 -0
- package/dist/cjs/core/reporting/step.js.map +1 -0
- package/dist/cjs/core/runner-protocol/index.js +5 -1
- package/dist/cjs/core/runner-protocol/index.js.map +1 -0
- package/dist/cjs/core/runner-protocol/request/capture-screenshot-request.js.map +1 -0
- package/dist/cjs/core/runner-protocol/request/control-request.js.map +1 -0
- package/dist/cjs/core/runner-protocol/request/get-server-process-pid.js.map +1 -0
- package/dist/cjs/core/runner-protocol/request/index.js.map +1 -0
- package/dist/cjs/core/runner-protocol/request/interactive-annotation-request.js.map +1 -0
- package/dist/cjs/core/runner-protocol/request/read-recording-request.js.map +1 -0
- package/dist/cjs/core/runner-protocol/request/runner-protocol-request.js.map +1 -0
- package/dist/cjs/core/runner-protocol/request/start-recording-request.js.map +1 -0
- package/dist/cjs/core/runner-protocol/request/stop-recording-request.js.map +1 -0
- package/dist/cjs/core/runner-protocol/response/index.js.map +1 -0
- package/dist/cjs/core/ui-control-commands/action.d.ts +1 -1
- package/dist/cjs/core/ui-control-commands/action.js.map +1 -0
- package/dist/cjs/core/ui-control-commands/control-command-code.js +1 -1
- package/dist/cjs/core/ui-control-commands/control-command-code.js.map +1 -0
- package/dist/cjs/core/ui-control-commands/control-command.js.map +1 -0
- package/dist/cjs/core/ui-control-commands/index.js.map +1 -0
- package/dist/cjs/core/ui-control-commands/input-event.js +1 -1
- package/dist/cjs/core/ui-control-commands/input-event.js.map +1 -0
- package/dist/cjs/execution/config-error.js.map +1 -0
- package/dist/cjs/execution/context.js.map +1 -0
- package/dist/cjs/execution/control-command-error.js.map +1 -0
- package/dist/cjs/execution/credentials-args.js.map +1 -0
- package/dist/cjs/execution/dsl.d.ts +6 -6
- package/dist/cjs/execution/dsl.js +1 -1
- package/dist/cjs/execution/dsl.js.map +1 -0
- package/dist/cjs/execution/execution-runtime.d.ts +3 -2
- package/dist/cjs/execution/execution-runtime.js +8 -7
- package/dist/cjs/execution/execution-runtime.js.map +1 -0
- package/dist/cjs/execution/index.d.ts +1 -0
- package/dist/cjs/execution/index.js +6 -1
- package/dist/cjs/execution/index.js.map +1 -0
- package/dist/cjs/execution/inference-client.js +8 -8
- package/dist/cjs/execution/inference-client.js.map +1 -0
- package/dist/cjs/execution/inference-response-error.js.map +1 -0
- package/dist/cjs/execution/is-image-required-interface.js.map +1 -0
- package/dist/cjs/execution/misc.js +1 -2
- package/dist/cjs/execution/misc.js.map +1 -0
- package/dist/cjs/execution/model-composition-branch.js.map +1 -0
- package/dist/cjs/execution/read-credentials.js +1 -2
- package/dist/cjs/execution/read-credentials.js.map +1 -0
- package/dist/cjs/execution/read-environment-credentials.js +1 -2
- package/dist/cjs/execution/read-environment-credentials.js.map +1 -0
- package/dist/cjs/execution/read-recording-response-stream-handler.js.map +1 -0
- package/dist/cjs/execution/repeat-error.js.map +1 -0
- package/dist/cjs/execution/retry-strategies/exponential-retry-strategy.d.ts +19 -0
- package/dist/cjs/execution/retry-strategies/exponential-retry-strategy.js +25 -0
- package/dist/cjs/execution/retry-strategies/fixed-retry-strategy.d.ts +19 -0
- package/dist/cjs/execution/retry-strategies/fixed-retry-strategy.js +25 -0
- package/dist/cjs/execution/retry-strategies/index.d.ts +4 -0
- package/dist/cjs/execution/retry-strategies/index.js +20 -0
- package/dist/cjs/execution/retry-strategies/linear-retry-strategy.d.ts +19 -0
- package/dist/cjs/execution/retry-strategies/linear-retry-strategy.js +25 -0
- package/dist/cjs/execution/retry-strategies/retry-strategy.d.ts +19 -0
- package/dist/cjs/execution/retry-strategies/retry-strategy.js +2 -0
- package/dist/cjs/execution/ui-control-client-dependency-builder.js +6 -5
- package/dist/cjs/execution/ui-control-client-dependency-builder.js.map +1 -0
- package/dist/cjs/execution/ui-control-client.d.ts +3 -3
- package/dist/cjs/execution/ui-control-client.js +21 -15
- package/dist/cjs/execution/ui-control-client.js.map +1 -0
- package/dist/cjs/execution/ui-controller-client-connection-state.js +1 -1
- package/dist/cjs/execution/ui-controller-client-connection-state.js.map +1 -0
- package/dist/cjs/execution/ui-controller-client-error.js.map +1 -0
- package/dist/cjs/execution/ui-controller-client-interface.d.ts +6 -0
- package/dist/cjs/execution/ui-controller-client-interface.js.map +1 -0
- package/dist/cjs/execution/ui-controller-client.js +2 -1
- package/dist/cjs/execution/ui-controller-client.js.map +1 -0
- package/dist/cjs/execution/ui-controller-not-connected-error.js.map +1 -0
- package/dist/cjs/lib/download-binaries.d.ts +0 -1
- package/dist/cjs/lib/download-binaries.js +3 -4
- package/dist/cjs/lib/download-binaries.js.map +1 -0
- package/dist/cjs/lib/index.js.map +1 -0
- package/dist/cjs/lib/interactive_cli/add-remove-script-package-json.js +2 -3
- package/dist/cjs/lib/interactive_cli/add-remove-script-package-json.js.map +1 -0
- package/dist/cjs/lib/interactive_cli/cli-options-interface.js.map +1 -0
- package/dist/cjs/lib/interactive_cli/cli.js +1 -2
- package/dist/cjs/lib/interactive_cli/cli.js.map +1 -0
- package/dist/cjs/lib/interactive_cli/create-example-project.js.map +1 -0
- package/dist/cjs/lib/interactive_cli/index.js.map +1 -0
- package/dist/cjs/lib/libfuse-error.js.map +1 -0
- package/dist/cjs/lib/logger.d.ts +1 -1
- package/dist/cjs/lib/logger.js.map +1 -0
- package/dist/cjs/lib/timeout-error.js.map +1 -0
- package/dist/cjs/lib/ui-controller-args.js +2 -3
- package/dist/cjs/lib/ui-controller-args.js.map +1 -0
- package/dist/cjs/lib/ui-controller-darwin.js.map +1 -0
- package/dist/cjs/lib/ui-controller-facade.js +4 -4
- package/dist/cjs/lib/ui-controller-facade.js.map +1 -0
- package/dist/cjs/lib/ui-controller-linux.js.map +1 -0
- package/dist/cjs/lib/ui-controller-win32.js.map +1 -0
- package/dist/cjs/lib/ui-controller.js.map +1 -0
- package/dist/cjs/lib/unkown-error.js.map +1 -0
- package/dist/cjs/lib/wayland-error.js.map +1 -0
- package/dist/cjs/main.js +5 -1
- package/dist/cjs/main.js.map +1 -0
- package/dist/cjs/shared/index.js.map +1 -0
- package/dist/cjs/shared/log-levels.js +1 -1
- package/dist/cjs/shared/log-levels.js.map +1 -0
- package/dist/cjs/shared/proxy-agent-args.d.ts +0 -1
- package/dist/cjs/shared/proxy-agent-args.js.map +1 -0
- package/dist/cjs/utils/analytics/analytics-interface.js.map +1 -0
- package/dist/cjs/utils/analytics/analytics.js.map +1 -0
- package/dist/cjs/utils/analytics/index.js.map +1 -0
- package/dist/cjs/utils/analytics/installation-timestamp-create-error.d.ts +0 -1
- package/dist/cjs/utils/analytics/installation-timestamp-create-error.js.map +1 -0
- package/dist/cjs/utils/analytics/installation-timestamp-get-error.d.ts +0 -1
- package/dist/cjs/utils/analytics/installation-timestamp-get-error.js.map +1 -0
- package/dist/cjs/utils/analytics/installation-timestamp.js.map +1 -0
- package/dist/cjs/utils/analytics/user-identifier-interface.js.map +1 -0
- package/dist/cjs/utils/analytics/user-identifier.js.map +1 -0
- package/dist/cjs/utils/base_64_image/base-64-image-error.js.map +1 -0
- package/dist/cjs/utils/base_64_image/base-64-image-string-error.js.map +1 -0
- package/dist/cjs/utils/base_64_image/base-64-image.js.map +1 -0
- package/dist/cjs/utils/base_64_image/sharp.js +6 -3
- package/dist/cjs/utils/base_64_image/sharp.js.map +1 -0
- package/dist/cjs/utils/http/credentials.js.map +1 -0
- package/dist/cjs/utils/http/custom-errors/authentication-http-client-error.js.map +1 -0
- package/dist/cjs/utils/http/custom-errors/client-http-client-error.js.map +1 -0
- package/dist/cjs/utils/http/custom-errors/general-http-client-error.js.map +1 -0
- package/dist/cjs/utils/http/custom-errors/http-client-error.js.map +1 -0
- package/dist/cjs/utils/http/custom-errors/index.js +2 -2
- package/dist/cjs/utils/http/custom-errors/index.js.map +1 -0
- package/dist/cjs/utils/http/custom-errors/server-http-client-error.js.map +1 -0
- package/dist/cjs/utils/http/custom-errors/unkown-http-client-error.js.map +1 -0
- package/dist/cjs/utils/http/http-client-got.d.ts +0 -1
- package/dist/cjs/utils/http/http-client-got.js +2 -2
- package/dist/cjs/utils/http/http-client-got.js.map +1 -0
- package/dist/cjs/utils/http/index.js.map +1 -0
- package/dist/cjs/utils/image-resize-errors/image-resizing-base-error.js.map +1 -0
- package/dist/cjs/utils/image-resize-errors/index.js.map +1 -0
- package/dist/cjs/utils/path.js +1 -2
- package/dist/cjs/utils/path.js.map +1 -0
- package/dist/cjs/utils/proxy/proxy-builder.js +7 -3
- package/dist/cjs/utils/proxy/proxy-builder.js.map +1 -0
- package/dist/cjs/utils/resized-image-interface.js.map +1 -0
- package/dist/cjs/utils/transformations.js +3 -4
- package/dist/cjs/utils/transformations.js.map +1 -0
- package/dist/esm/core/ai-element/ai-element-collection.js.map +1 -0
- package/dist/esm/core/ai-element/ai-element-error.js.map +1 -0
- package/dist/esm/core/ai-element/ai-element.js.map +1 -0
- package/dist/esm/core/annotation/annotation-writer.js.map +1 -0
- package/dist/esm/core/annotation/annotation.js.map +1 -0
- package/dist/esm/core/annotation/template.html +470 -10
- package/dist/esm/core/inference-response/inference-response.js.map +1 -0
- package/dist/esm/core/inference-response/invalid-model-type-error.js.map +1 -0
- package/dist/esm/core/inference-response/model-type.d.ts +1 -1
- package/dist/esm/core/inference-response/model-type.js.map +1 -0
- package/dist/esm/core/model/annotation-result/annotation-interface.js.map +1 -0
- package/dist/esm/core/model/annotation-result/boundary-box.js.map +1 -0
- package/dist/esm/core/model/annotation-result/detected-element.js.map +1 -0
- package/dist/esm/core/model/custom-element-json.js.map +1 -0
- package/dist/esm/core/model/custom-element.d.ts +5 -5
- package/dist/esm/core/model/custom-element.js +2 -2
- package/dist/esm/core/model/custom-element.js.map +1 -0
- package/dist/esm/core/reporting/default-step.js.map +1 -0
- package/dist/esm/core/reporting/index.js.map +1 -0
- package/dist/esm/core/reporting/instruction.js.map +1 -0
- package/dist/esm/core/reporting/reporter-config.js.map +1 -0
- package/dist/esm/core/reporting/reporter.js.map +1 -0
- package/dist/esm/core/reporting/snapshot-detail-level.d.ts +1 -1
- package/dist/esm/core/reporting/snapshot-detail-level.js.map +1 -0
- package/dist/esm/core/reporting/snapshot.js.map +1 -0
- package/dist/esm/core/reporting/step-reporter.js.map +1 -0
- package/dist/esm/core/reporting/step-run.js.map +1 -0
- package/dist/esm/core/reporting/step-status-end.d.ts +1 -1
- package/dist/esm/core/reporting/step-status-end.js.map +1 -0
- package/dist/esm/core/reporting/step-status.d.ts +1 -1
- package/dist/esm/core/reporting/step-status.js.map +1 -0
- package/dist/esm/core/reporting/step.js.map +1 -0
- package/dist/esm/core/runner-protocol/index.js.map +1 -0
- package/dist/esm/core/runner-protocol/request/capture-screenshot-request.js.map +1 -0
- package/dist/esm/core/runner-protocol/request/control-request.js.map +1 -0
- package/dist/esm/core/runner-protocol/request/get-server-process-pid.js.map +1 -0
- package/dist/esm/core/runner-protocol/request/index.js.map +1 -0
- package/dist/esm/core/runner-protocol/request/interactive-annotation-request.js.map +1 -0
- package/dist/esm/core/runner-protocol/request/read-recording-request.js.map +1 -0
- package/dist/esm/core/runner-protocol/request/runner-protocol-request.js.map +1 -0
- package/dist/esm/core/runner-protocol/request/start-recording-request.js.map +1 -0
- package/dist/esm/core/runner-protocol/request/stop-recording-request.js.map +1 -0
- package/dist/esm/core/runner-protocol/response/index.js.map +1 -0
- package/dist/esm/core/ui-control-commands/action.d.ts +1 -1
- package/dist/esm/core/ui-control-commands/action.js.map +1 -0
- package/dist/esm/core/ui-control-commands/control-command-code.js.map +1 -0
- package/dist/esm/core/ui-control-commands/control-command.js.map +1 -0
- package/dist/esm/core/ui-control-commands/index.js.map +1 -0
- package/dist/esm/core/ui-control-commands/input-event.js.map +1 -0
- package/dist/esm/execution/config-error.js.map +1 -0
- package/dist/esm/execution/context.js.map +1 -0
- package/dist/esm/execution/control-command-error.js.map +1 -0
- package/dist/esm/execution/credentials-args.js.map +1 -0
- package/dist/esm/execution/dsl.d.ts +6 -6
- package/dist/esm/execution/dsl.js.map +1 -0
- package/dist/esm/execution/execution-runtime.d.ts +3 -2
- package/dist/esm/execution/execution-runtime.js +8 -7
- package/dist/esm/execution/execution-runtime.js.map +1 -0
- package/dist/esm/execution/index.d.ts +1 -0
- package/dist/esm/execution/index.js +1 -0
- package/dist/esm/execution/index.js.map +1 -0
- package/dist/esm/execution/inference-client.js +8 -8
- package/dist/esm/execution/inference-client.js.map +1 -0
- package/dist/esm/execution/inference-response-error.js.map +1 -0
- package/dist/esm/execution/is-image-required-interface.js.map +1 -0
- package/dist/esm/execution/misc.js.map +1 -0
- package/dist/esm/execution/model-composition-branch.js.map +1 -0
- package/dist/esm/execution/read-credentials.js.map +1 -0
- package/dist/esm/execution/read-environment-credentials.js.map +1 -0
- package/dist/esm/execution/read-recording-response-stream-handler.js.map +1 -0
- package/dist/esm/execution/repeat-error.js.map +1 -0
- package/dist/esm/execution/retry-strategies/exponential-retry-strategy.d.ts +19 -0
- package/dist/esm/execution/retry-strategies/exponential-retry-strategy.js +21 -0
- package/dist/esm/execution/retry-strategies/fixed-retry-strategy.d.ts +19 -0
- package/dist/esm/execution/retry-strategies/fixed-retry-strategy.js +21 -0
- package/dist/esm/execution/retry-strategies/index.d.ts +4 -0
- package/dist/esm/execution/retry-strategies/index.js +4 -0
- package/dist/esm/execution/retry-strategies/linear-retry-strategy.d.ts +19 -0
- package/dist/esm/execution/retry-strategies/linear-retry-strategy.js +21 -0
- package/dist/esm/execution/retry-strategies/retry-strategy.d.ts +19 -0
- package/dist/esm/execution/retry-strategies/retry-strategy.js +1 -0
- package/dist/esm/execution/ui-control-client-dependency-builder.js +6 -5
- package/dist/esm/execution/ui-control-client-dependency-builder.js.map +1 -0
- package/dist/esm/execution/ui-control-client.d.ts +3 -3
- package/dist/esm/execution/ui-control-client.js +21 -15
- package/dist/esm/execution/ui-control-client.js.map +1 -0
- package/dist/esm/execution/ui-controller-client-connection-state.js.map +1 -0
- package/dist/esm/execution/ui-controller-client-error.js.map +1 -0
- package/dist/esm/execution/ui-controller-client-interface.d.ts +6 -0
- package/dist/esm/execution/ui-controller-client-interface.js.map +1 -0
- package/dist/esm/execution/ui-controller-client.js +2 -1
- package/dist/esm/execution/ui-controller-client.js.map +1 -0
- package/dist/esm/execution/ui-controller-not-connected-error.js.map +1 -0
- package/dist/esm/lib/download-binaries.d.ts +0 -1
- package/dist/esm/lib/download-binaries.js.map +1 -0
- package/dist/esm/lib/index.js.map +1 -0
- package/dist/esm/lib/interactive_cli/add-remove-script-package-json.js.map +1 -0
- package/dist/esm/lib/interactive_cli/cli-options-interface.js.map +1 -0
- package/dist/esm/lib/interactive_cli/cli.js.map +1 -0
- package/dist/esm/lib/interactive_cli/create-example-project.js.map +1 -0
- package/dist/esm/lib/interactive_cli/index.js.map +1 -0
- package/dist/esm/lib/libfuse-error.js.map +1 -0
- package/dist/esm/lib/logger.d.ts +1 -1
- package/dist/esm/lib/logger.js.map +1 -0
- package/dist/esm/lib/timeout-error.js.map +1 -0
- package/dist/esm/lib/ui-controller-args.js.map +1 -0
- package/dist/esm/lib/ui-controller-darwin.js.map +1 -0
- package/dist/esm/lib/ui-controller-facade.js +4 -4
- package/dist/esm/lib/ui-controller-facade.js.map +1 -0
- package/dist/esm/lib/ui-controller-linux.js.map +1 -0
- package/dist/esm/lib/ui-controller-win32.js.map +1 -0
- package/dist/esm/lib/ui-controller.js.map +1 -0
- package/dist/esm/lib/unkown-error.js.map +1 -0
- package/dist/esm/lib/wayland-error.js.map +1 -0
- package/dist/esm/main.js.map +1 -0
- package/dist/esm/shared/index.js.map +1 -0
- package/dist/esm/shared/log-levels.js.map +1 -0
- package/dist/esm/shared/proxy-agent-args.d.ts +0 -1
- package/dist/esm/shared/proxy-agent-args.js.map +1 -0
- package/dist/esm/utils/analytics/analytics-interface.js.map +1 -0
- package/dist/esm/utils/analytics/analytics.js.map +1 -0
- package/dist/esm/utils/analytics/index.js.map +1 -0
- package/dist/esm/utils/analytics/installation-timestamp-create-error.d.ts +0 -1
- package/dist/esm/utils/analytics/installation-timestamp-create-error.js.map +1 -0
- package/dist/esm/utils/analytics/installation-timestamp-get-error.d.ts +0 -1
- package/dist/esm/utils/analytics/installation-timestamp-get-error.js.map +1 -0
- package/dist/esm/utils/analytics/installation-timestamp.js.map +1 -0
- package/dist/esm/utils/analytics/user-identifier-interface.js.map +1 -0
- package/dist/esm/utils/analytics/user-identifier.js.map +1 -0
- package/dist/esm/utils/base_64_image/base-64-image-error.js.map +1 -0
- package/dist/esm/utils/base_64_image/base-64-image-string-error.js.map +1 -0
- package/dist/esm/utils/base_64_image/base-64-image.js.map +1 -0
- package/dist/esm/utils/base_64_image/sharp.js.map +1 -0
- package/dist/esm/utils/http/credentials.js.map +1 -0
- package/dist/esm/utils/http/custom-errors/authentication-http-client-error.js.map +1 -0
- package/dist/esm/utils/http/custom-errors/client-http-client-error.js.map +1 -0
- package/dist/esm/utils/http/custom-errors/general-http-client-error.js.map +1 -0
- package/dist/esm/utils/http/custom-errors/http-client-error.js.map +1 -0
- package/dist/esm/utils/http/custom-errors/index.js.map +1 -0
- package/dist/esm/utils/http/custom-errors/server-http-client-error.js.map +1 -0
- package/dist/esm/utils/http/custom-errors/unkown-http-client-error.js.map +1 -0
- package/dist/esm/utils/http/http-client-got.d.ts +0 -1
- package/dist/esm/utils/http/http-client-got.js +2 -2
- package/dist/esm/utils/http/http-client-got.js.map +1 -0
- package/dist/esm/utils/http/index.js.map +1 -0
- package/dist/esm/utils/image-resize-errors/image-resizing-base-error.js.map +1 -0
- package/dist/esm/utils/image-resize-errors/index.js.map +1 -0
- package/dist/esm/utils/path.js.map +1 -0
- package/dist/esm/utils/proxy/proxy-builder.js.map +1 -0
- package/dist/esm/utils/resized-image-interface.js.map +1 -0
- package/dist/esm/utils/transformations.js +2 -2
- package/dist/esm/utils/transformations.js.map +1 -0
- package/dist/example_projects_templates/templates/askui-helper-windows.nj +32 -0
- package/package.json +28 -28
|
@@ -1,16 +1,476 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
|
-
|
|
4
|
-
<
|
|
5
|
-
<meta charset="utf-8">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
6
5
|
<title>Annotated Image</title>
|
|
7
|
-
</head>
|
|
6
|
+
</head>
|
|
8
7
|
|
|
9
|
-
<body>
|
|
8
|
+
<body>
|
|
10
9
|
<bounding-box-renderer></bounding-box-renderer>
|
|
11
|
-
|
|
12
|
-
(()=>{"use strict";var e,b={},v={};function a(e){var n=v[e];if(void 0!==n)return n.exports;var r=v[e]={exports:{}};return b[e](r,r.exports,a),r.exports}a.m=b,e=[],a.O=(n,r,f,t)=>{if(!r){var l=1/0;for(o=0;o<e.length;o++){for(var[r,f,t]=e[o],c=!0,u=0;u<r.length;u++)(!1&t||l>=t)&&Object.keys(a.O).every(p=>a.O[p](r[u]))?r.splice(u--,1):(c=!1,t<l&&(l=t));if(c){e.splice(o--,1);var _=f();void 0!==_&&(n=_)}}return n}t=t||0;for(var o=e.length;o>0&&e[o-1][2]>t;o--)e[o]=e[o-1];e[o]=[r,f,t]},a.n=e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return a.d(n,{a:n}),n},a.d=(e,n)=>{for(var r in n)a.o(n,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},a.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),(()=>{var e={666:0};a.O.j=f=>0===e[f];var n=(f,t)=>{var u,_,[o,l,c]=t,s=0;for(u in l)a.o(l,u)&&(a.m[u]=l[u]);if(c)var d=c(a);for(f&&f(t);s<o.length;s++)a.o(e,_=o[s])&&e[_]&&e[_][0](),e[o[s]]=0;return a.O(d)},r=self.webpackChunkbounding_box_renderer_web_component=self.webpackChunkbounding_box_renderer_web_component||[];r.forEach(n.bind(null,0)),r.push=n.bind(null,r.push.bind(r))})()})();(self.webpackChunkbounding_box_renderer_web_component=self.webpackChunkbounding_box_renderer_web_component||[]).push([[429],{142:()=>{!function(X,re){"use strict";function ye(){var r=S.splice(0,S.length);for(G=0;r.length;)r.shift().call(null,r.shift())}function ve(r,a){for(var u=0,l=r.length;u<l;u++)V(r[u],a)}function Ge(r){return function(a){p(a)&&(V(a,r),ue.length&&ve(a.querySelectorAll(ue),r))}}function Ie(r){var a=y.call(r,"is"),u=r.nodeName.toUpperCase(),l=_e.call(Ce,a?xe+a.toUpperCase():je+u);return a&&-1<l&&!Ye(u,a)?-1:l}function Ye(r,a){return-1<ue.indexOf(r+'[is="'+a+'"]')}function $e(r){var a=r.currentTarget,u=r.attrChange,l=r.attrName,e=r.target,t=r[et]||2,m=r[Me]||3;K&&(!e||e===a)&&a[le]&&"style"!==l&&(r.prevValue!==r.newValue||""===r.newValue&&(u===t||u===m))&&a[le](l,u===t?null:r.prevValue,u===m?null:r.newValue)}function Ke(r){var a=Ge(r);return function(u){S.push(a,u.target),G&&clearTimeout(G),G=setTimeout(ye,1)}}function fe(r){x&&(x=!1,r.currentTarget.removeEventListener(ie,fe)),ue.length&&ve((r.target||W).querySelectorAll(ue),r.detail===he?he:Ee),s&&function(){for(var r,a=0,u=T.length;a<u;a++)Ve.contains(r=T[a])||(u--,T.splice(a--,1),V(r,he))}()}function ke(r,a){var u=this;j.call(u,r,a),C.call(u,{target:u})}function Ne(r,a){n(r,a),te?te.observe(r,k):($&&(r.setAttribute=ke,r[pe]=N(r),r[ce](yt,C)),r[ce](Se,$e)),r[Ae]&&K&&(r.created=!0,r[Ae](),r.created=!1)}function Je(r){throw new Error("A "+r+" type is already registered")}function V(r,a){var u,e,l=Ie(r);-1<l&&(B(r,qe[l]),l=0,a!==Ee||r[Ee]?a===he&&!r[he]&&(r[Ee]=!1,r[he]=!0,e="disconnected",l=1):(r[he]=!1,r[Ee]=!0,e="connected",l=1,s&&_e.call(T,r)<0&&T.push(r)),l&&(u=r[a+be]||r[e+be])&&u.call(r))}function He(){}function De(r,a,u){var l=u&&u[oe]||"",e=a.prototype,t=dt(e),m=a.observedAttributes||ut,_={prototype:t};h(t,Ae,{value:function(){if(nt)nt=!1;else if(!this[ge]){this[ge]=!0,new a(this),e[Ae]&&e[Ae].call(this);var H=Pe[rt.get(a)];(!Ue||H.create.length>1)&&Tt(this)}}}),h(t,le,{value:function(H){-1<_e.call(m,H)&&e[le].apply(this,arguments)}}),e[gt]&&h(t,we,{value:e[gt]}),e[Te]&&h(t,at,{value:e[Te]}),l&&(_[oe]=l),r=r.toUpperCase(),Pe[r]={constructor:a,create:l?[l,ot(r)]:[r]},rt.set(a,r),W[Re](r.toLowerCase(),_),ze(r),de[r].r()}function ee(r){var a=Pe[r.toUpperCase()];return a&&a.constructor}function Et(r){return"string"==typeof r?r:r&&r.is||""}function Tt(r){for(var e,a=r[le],u=a?r.attributes:ut,l=u.length;l--;)a.call(r,(e=u[l]).name||e.nodeName,null,e.value||e.nodeValue)}function ze(r){return(r=r.toUpperCase())in de||(de[r]={},de[r].p=new Y(function(a){de[r].r=a})),de[r].p}function _t(){Le&&delete X.customElements,Fe(X,"customElements",{configurable:!0,value:new He}),Fe(X,"CustomElementRegistry",{configurable:!0,value:He});for(var r=function(l){var e=X[l];if(e){X[l]=function(t){var m,_;return t||(t=this),t[ge]||(nt=!0,m=Pe[rt.get(t.constructor)],(t=(_=Ue&&1===m.create.length)?Reflect.construct(e,ut,m.constructor):W.createElement.apply(W,m.create))[ge]=!0,nt=!1,_||Tt(t)),t},X[l].prototype=e.prototype;try{e.prototype.constructor=X[l]}catch(t){Fe(e,ge,{value:X[l]})}}},a=Qe.get(/^HTML[A-Z]*[a-z]/),u=a.length;u--;r(a[u]));W.createElement=function(l,e){var t=Et(e);return t?F.call(this,l,ot(t)):F.call(this,l)},U||(D=!0,W[Re](""))}var W=X.document,se=X.Object,Qe=function(r){var m,_,H,f,a=/^[A-Z]+[a-z]/,l=function(i,d){(d=d.toLowerCase())in e||(e[i]=(e[i]||[]).concat(d),e[d]=e[d.toUpperCase()]=i)},e=(se.create||se)(null),t={};for(_ in r)for(f in r[_])for(e[f]=H=r[_][f],m=0;m<H.length;m++)e[H[m].toLowerCase()]=e[H[m].toUpperCase()]=f;return t.get=function(i){return"string"==typeof i?e[i]||(a.test(i)?[]:""):function(i){var E,d=[];for(E in e)i.test(E)&&d.push(E);return d}(i)},t.set=function(i,d){return a.test(i)?l(i,d):l(d,i),t},t}({collections:{HTMLAllCollection:["all"],HTMLCollection:["forms"],HTMLFormControlsCollection:["elements"],HTMLOptionsCollection:["options"]},elements:{Element:["element"],HTMLAnchorElement:["a"],HTMLAppletElement:["applet"],HTMLAreaElement:["area"],HTMLAttachmentElement:["attachment"],HTMLAudioElement:["audio"],HTMLBRElement:["br"],HTMLBaseElement:["base"],HTMLBodyElement:["body"],HTMLButtonElement:["button"],HTMLCanvasElement:["canvas"],HTMLContentElement:["content"],HTMLDListElement:["dl"],HTMLDataElement:["data"],HTMLDataListElement:["datalist"],HTMLDetailsElement:["details"],HTMLDialogElement:["dialog"],HTMLDirectoryElement:["dir"],HTMLDivElement:["div"],HTMLDocument:["document"],HTMLElement:["element","abbr","address","article","aside","b","bdi","bdo","cite","code","command","dd","dfn","dt","em","figcaption","figure","footer","header","i","kbd","mark","nav","noscript","rp","rt","ruby","s","samp","section","small","strong","sub","summary","sup","u","var","wbr"],HTMLEmbedElement:["embed"],HTMLFieldSetElement:["fieldset"],HTMLFontElement:["font"],HTMLFormElement:["form"],HTMLFrameElement:["frame"],HTMLFrameSetElement:["frameset"],HTMLHRElement:["hr"],HTMLHeadElement:["head"],HTMLHeadingElement:["h1","h2","h3","h4","h5","h6"],HTMLHtmlElement:["html"],HTMLIFrameElement:["iframe"],HTMLImageElement:["img"],HTMLInputElement:["input"],HTMLKeygenElement:["keygen"],HTMLLIElement:["li"],HTMLLabelElement:["label"],HTMLLegendElement:["legend"],HTMLLinkElement:["link"],HTMLMapElement:["map"],HTMLMarqueeElement:["marquee"],HTMLMediaElement:["media"],HTMLMenuElement:["menu"],HTMLMenuItemElement:["menuitem"],HTMLMetaElement:["meta"],HTMLMeterElement:["meter"],HTMLModElement:["del","ins"],HTMLOListElement:["ol"],HTMLObjectElement:["object"],HTMLOptGroupElement:["optgroup"],HTMLOptionElement:["option"],HTMLOutputElement:["output"],HTMLParagraphElement:["p"],HTMLParamElement:["param"],HTMLPictureElement:["picture"],HTMLPreElement:["pre"],HTMLProgressElement:["progress"],HTMLQuoteElement:["blockquote","q","quote"],HTMLScriptElement:["script"],HTMLSelectElement:["select"],HTMLShadowElement:["shadow"],HTMLSlotElement:["slot"],HTMLSourceElement:["source"],HTMLSpanElement:["span"],HTMLStyleElement:["style"],HTMLTableCaptionElement:["caption"],HTMLTableCellElement:["td","th"],HTMLTableColElement:["col","colgroup"],HTMLTableElement:["table"],HTMLTableRowElement:["tr"],HTMLTableSectionElement:["thead","tbody","tfoot"],HTMLTemplateElement:["template"],HTMLTextAreaElement:["textarea"],HTMLTimeElement:["time"],HTMLTitleElement:["title"],HTMLTrackElement:["track"],HTMLUListElement:["ul"],HTMLUnknownElement:["unknown","vhgroupv","vkeygen"],HTMLVideoElement:["video"]},nodes:{Attr:["node"],Audio:["audio"],CDATASection:["node"],CharacterData:["node"],Comment:["#comment"],Document:["#document"],DocumentFragment:["#document-fragment"],DocumentType:["node"],HTMLDocument:["#document"],Image:["img"],Option:["option"],ProcessingInstruction:["node"],ShadowRoot:["#shadow-root"],Text:["#text"],XMLDocument:["xml"]}});"object"!=typeof re&&(re={type:re||"auto"});var S,C,Z,N,te,me,B,ne,r,a,u,l,e,Re="registerElement",pe="__"+Re+(1e5*X.Math.random()>>0),ce="addEventListener",Ee="attached",be="Callback",he="detached",oe="extends",le="attributeChanged"+be,we=Ee+be,gt="connected"+be,Te="disconnected"+be,Ae="created"+be,at=he+be,et="ADDITION",ct="MODIFICATION",Me="REMOVAL",Se="DOMAttrModified",ie="DOMContentLoaded",yt="DOMSubtreeModified",je="<",xe="=",vt=/^[A-Z][A-Z0-9]*(?:-[A-Z0-9]+)+$/,Pt=["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"],Ce=[],qe=[],ue="",Ve=W.documentElement,_e=Ce.indexOf||function(r){for(var a=this.length;a--&&this[a]!==r;);return a},We=se.prototype,lt=We.hasOwnProperty,tt=We.isPrototypeOf,Fe=se.defineProperty,ut=[],ft=se.getOwnPropertyDescriptor,kt=se.getOwnPropertyNames,bt=se.getPrototypeOf,ht=se.setPrototypeOf,wt=!!se.__proto__,ge="__dreCEv1",Le=X.customElements,Ue=!/^force/.test(re.type)&&!!(Le&&Le.define&&Le.get&&Le.whenDefined),Ze=se.create||se,Mt=X.Map||function(){var u,r=[],a=[];return{get:function(l){return a[_e.call(r,l)]},set:function(l,e){(u=_e.call(r,l))<0?a[r.push(l)-1]=e:a[u]=e}}},Y=X.Promise||function(r){function a(t){for(l=!0;u.length;)u.shift()(t)}var u=[],l=!1,e={catch:function(){return e},then:function(t){return u.push(t),l&&setTimeout(a,1),e}};return r(a),e},nt=!1,Pe=Ze(null),de=Ze(null),rt=new Mt,ot=function(r){return r.toLowerCase()},dt=se.create||function r(a){return a?(r.prototype=a,new r):this},n=ht||(wt?function(r,a){return r.__proto__=a,r}:kt&&ft?function(){function r(a,u){for(var l,e=kt(u),t=0,m=e.length;t<m;t++)lt.call(a,l=e[t])||Fe(a,l,ft(u,l))}return function(a,u){do{r(a,u)}while((u=bt(u))&&!tt.call(u,a));return a}}():function(r,a){for(var u in a)r[u]=a[u];return r}),o=X.MutationObserver||X.WebKitMutationObserver,c=(X.HTMLElement||X.Element||X.Node).prototype,s=!tt.call(c,Ve),h=s?function(r,a,u){return r[a]=u.value,r}:Fe,p=s?function(r){return 1===r.nodeType}:function(r){return tt.call(c,r)},T=s&&[],v=c.attachShadow,M=c.cloneNode,b=c.dispatchEvent,y=c.getAttribute,A=c.hasAttribute,R=c.removeAttribute,j=c.setAttribute,q=W.createElement,F=q,k=o&&{attributes:!0,characterData:!0,attributeOldValue:!0},g=o||function(r){$=!1,Ve.removeEventListener(Se,g)},G=0,U=Re in W&&!/^force-all/.test(re.type),J=!0,D=!1,$=!0,x=!0,K=!0;if(U||(ht||wt?(B=function(r,a){tt.call(a,r)||Ne(r,a)},ne=Ne):ne=B=function(r,a){r[pe]||(r[pe]=se(!0),Ne(r,a))},s?($=!1,r=ft(c,ce),a=r.value,u=function(t){var m=new CustomEvent(Se,{bubbles:!0});m.attrName=t,m.prevValue=y.call(this,t),m.newValue=null,m[Me]=m.attrChange=2,R.call(this,t),b.call(this,m)},l=function(t,m){var _=A.call(this,t),H=_&&y.call(this,t),f=new CustomEvent(Se,{bubbles:!0});j.call(this,t,m),f.attrName=t,f.prevValue=_?H:null,f.newValue=m,_?f[ct]=f.attrChange=1:f[et]=f.attrChange=0,b.call(this,f)},e=function(t){var f,m=t.currentTarget,_=m[pe],H=t.propertyName;_.hasOwnProperty(H)&&(_=_[H],(f=new CustomEvent(Se,{bubbles:!0})).attrName=_.name,f.prevValue=_.value||null,f.newValue=_.value=m[H]||null,null==f.prevValue?f[et]=f.attrChange=0:f[ct]=f.attrChange=1,b.call(m,f))},r.value=function(t,m,_){t===Se&&this[le]&&this.setAttribute!==l&&(this[pe]={className:{name:"class",value:this.className}},this.setAttribute=l,this.removeAttribute=u,a.call(this,"propertychange",e)),a.call(this,t,m,_)},Fe(c,ce,r)):o||(Ve[ce](Se,g),Ve.setAttribute(pe,1),Ve.removeAttribute(pe),$&&(C=function(r){var u,l,e,a=this;if(a===r.target){for(e in u=a[pe],a[pe]=l=N(a),l){if(!(e in u))return Z(0,a,e,u[e],l[e],et);if(l[e]!==u[e])return Z(1,a,e,u[e],l[e],ct)}for(e in u)if(!(e in l))return Z(2,a,e,u[e],l[e],Me)}},Z=function(r,a,u,l,e,t){var m={attrChange:r,currentTarget:a,attrName:u,prevValue:l,newValue:e};m[t]=r,$e(m)},N=function(r){for(var a,u,l={},e=r.attributes,t=0,m=e.length;t<m;t++)"setAttribute"!==(u=(a=e[t]).name)&&(l[u]=a.value);return l})),W[Re]=function(r,a){if(m=r.toUpperCase(),J&&(J=!1,o?(te=function(H,f){function i(d,E){for(var w=0,P=d.length;w<P;E(d[w++]));}return new o(function(d){for(var E,w,P,L=0,O=d.length;L<O;L++)"childList"===(E=d[L]).type?(i(E.addedNodes,H),i(E.removedNodes,f)):(w=E.target,K&&w[le]&&"style"!==E.attributeName&&(P=y.call(w,E.attributeName))!==E.oldValue&&w[le](E.attributeName,E.oldValue,P))})}(Ge(Ee),Ge(he)),(me=function(H){return te.observe(H,{childList:!0,subtree:!0}),H})(W),v&&(c.attachShadow=function(){return me(v.apply(this,arguments))})):(S=[],W[ce]("DOMNodeInserted",Ke(Ee)),W[ce]("DOMNodeRemoved",Ke(he))),W[ce](ie,fe),W[ce]("readystatechange",fe),c.cloneNode=function(H){var f=M.call(this,!!H),i=Ie(f);return-1<i&&ne(f,qe[i]),H&&ue.length&&function(r){for(var l,a=0,u=r.length;a<u;a++)ne(l=r[a],qe[Ie(l)])}(f.querySelectorAll(ue)),f}),D)return D=!1;if(-2<_e.call(Ce,xe+m)+_e.call(Ce,je+m)&&Je(r),!vt.test(m)||-1<_e.call(Pt,m))throw new Error("The type "+r+" is invalid");var m,_,u=function(){return e?W.createElement(t,m):W.createElement(t)},l=a||We,e=lt.call(l,oe),t=e?a[oe].toUpperCase():m;return e&&-1<_e.call(Ce,je+t)&&Je(t),_=Ce.push((e?xe:je)+m)-1,ue=ue.concat(ue.length?",":"",e?t+'[is="'+r.toLowerCase()+'"]':t),u.prototype=qe[_]=lt.call(l,"prototype")?l.prototype:dt(c),ue.length&&ve(W.querySelectorAll(ue),Ee),u},W.createElement=F=function(r,a){var u=Et(a),l=u?q.call(W,r,ot(u)):q.call(W,r),e=""+r,t=_e.call(Ce,(u?xe:je)+(u||e).toUpperCase()),m=-1<t;return u&&(l.setAttribute("is",u=u.toLowerCase()),m&&(m=Ye(e.toUpperCase(),u))),K=!W.createElement.innerHTMLHelper,m&&ne(l,qe[t]),l}),He.prototype={constructor:He,define:Ue?function(r,a,u){if(u)De(r,a,u);else{var l=r.toUpperCase();Pe[l]={constructor:a,create:[l]},rt.set(a,l),Le.define(r,a)}}:De,get:Ue?function(r){return Le.get(r)||ee(r)}:ee,whenDefined:Ue?function(r){return Y.race([Le.whenDefined(r),ze(r)])}:ze},!Le||/^force/.test(re.type))_t();else if(!re.noBuiltIn)try{!function(r,a,u){if(a[oe]="a",(r.prototype=dt(HTMLAnchorElement.prototype)).constructor=r,X.customElements.define(u,r,a),y.call(W.createElement("a",{is:u}),"is")!==u||Ue&&y.call(new r,"is")!==u)throw a}(function r(){return Reflect.construct(HTMLAnchorElement,[],r)},{},"document-register-element-a")}catch(r){_t()}if(!re.noBuiltIn)try{q.call(W,"a","a")}catch(r){ot=function(a){return{is:a.toLowerCase()}}}}(window)},277:()=>{"use strict";!function(n){const o=n.performance;function c(u){o&&o.mark&&o.mark(u)}function s(u,l){o&&o.measure&&o.measure(u,l)}c("Zone");const h=n.__Zone_symbol_prefix||"__zone_symbol__";function p(u){return h+u}const T=!0===n[p("forceDuplicateZoneCheck")];if(n.Zone){if(T||"function"!=typeof n.Zone.__symbol__)throw new Error("Zone already loaded.");return n.Zone}let v=(()=>{class u{constructor(e,t){this._parent=e,this._name=t?t.name||"unnamed":"<root>",this._properties=t&&t.properties||{},this._zoneDelegate=new b(this,this._parent&&this._parent._zoneDelegate,t)}static assertZonePatched(){if(n.Promise!==te.ZoneAwarePromise)throw new Error("Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.\nMost likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)")}static get root(){let e=u.current;for(;e.parent;)e=e.parent;return e}static get current(){return B.zone}static get currentTask(){return ne}static __load_patch(e,t,m=!1){if(te.hasOwnProperty(e)){if(!m&&T)throw Error("Already loaded patch: "+e)}else if(!n["__Zone_disable_"+e]){const _="Zone:"+e;c(_),te[e]=t(n,u,me),s(_,_)}}get parent(){return this._parent}get name(){return this._name}get(e){const t=this.getZoneWith(e);if(t)return t._properties[e]}getZoneWith(e){let t=this;for(;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null}fork(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)}wrap(e,t){if("function"!=typeof e)throw new Error("Expecting function got: "+e);const m=this._zoneDelegate.intercept(this,e,t),_=this;return function(){return _.runGuarded(m,this,arguments,t)}}run(e,t,m,_){B={parent:B,zone:this};try{return this._zoneDelegate.invoke(this,e,t,m,_)}finally{B=B.parent}}runGuarded(e,t=null,m,_){B={parent:B,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,m,_)}catch(H){if(this._zoneDelegate.handleError(this,H))throw H}}finally{B=B.parent}}runTask(e,t,m){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||G).name+"; Execution: "+this.name+")");if(e.state===U&&(e.type===N||e.type===Z))return;const _=e.state!=$;_&&e._transitionTo($,D),e.runCount++;const H=ne;ne=e,B={parent:B,zone:this};try{e.type==Z&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,m)}catch(f){if(this._zoneDelegate.handleError(this,f))throw f}}finally{e.state!==U&&e.state!==K&&(e.type==N||e.data&&e.data.isPeriodic?_&&e._transitionTo(D,$):(e.runCount=0,this._updateTaskCount(e,-1),_&&e._transitionTo(U,$,U))),B=B.parent,ne=H}}scheduleTask(e){if(e.zone&&e.zone!==this){let m=this;for(;m;){if(m===e.zone)throw Error(`can not reschedule task to ${this.name} which is descendants of the original zone ${e.zone.name}`);m=m.parent}}e._transitionTo(J,U);const t=[];e._zoneDelegates=t,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(m){throw e._transitionTo(K,J,U),this._zoneDelegate.handleError(this,m),m}return e._zoneDelegates===t&&this._updateTaskCount(e,1),e.state==J&&e._transitionTo(D,J),e}scheduleMicroTask(e,t,m,_){return this.scheduleTask(new y(C,e,t,m,_,void 0))}scheduleMacroTask(e,t,m,_,H){return this.scheduleTask(new y(Z,e,t,m,_,H))}scheduleEventTask(e,t,m,_,H){return this.scheduleTask(new y(N,e,t,m,_,H))}cancelTask(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||G).name+"; Execution: "+this.name+")");e._transitionTo(x,D,$);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(K,x),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(U,x),e.runCount=0,e}_updateTaskCount(e,t){const m=e._zoneDelegates;-1==t&&(e._zoneDelegates=null);for(let _=0;_<m.length;_++)m[_]._updateTaskCount(e.type,t)}}return u.__symbol__=p,u})();const M={name:"",onHasTask:(u,l,e,t)=>u.hasTask(e,t),onScheduleTask:(u,l,e,t)=>u.scheduleTask(e,t),onInvokeTask:(u,l,e,t,m,_)=>u.invokeTask(e,t,m,_),onCancelTask:(u,l,e,t)=>u.cancelTask(e,t)};class b{constructor(l,e,t){this._taskCounts={microTask:0,macroTask:0,eventTask:0},this.zone=l,this._parentDelegate=e,this._forkZS=t&&(t&&t.onFork?t:e._forkZS),this._forkDlgt=t&&(t.onFork?e:e._forkDlgt),this._forkCurrZone=t&&(t.onFork?this.zone:e._forkCurrZone),this._interceptZS=t&&(t.onIntercept?t:e._interceptZS),this._interceptDlgt=t&&(t.onIntercept?e:e._interceptDlgt),this._interceptCurrZone=t&&(t.onIntercept?this.zone:e._interceptCurrZone),this._invokeZS=t&&(t.onInvoke?t:e._invokeZS),this._invokeDlgt=t&&(t.onInvoke?e:e._invokeDlgt),this._invokeCurrZone=t&&(t.onInvoke?this.zone:e._invokeCurrZone),this._handleErrorZS=t&&(t.onHandleError?t:e._handleErrorZS),this._handleErrorDlgt=t&&(t.onHandleError?e:e._handleErrorDlgt),this._handleErrorCurrZone=t&&(t.onHandleError?this.zone:e._handleErrorCurrZone),this._scheduleTaskZS=t&&(t.onScheduleTask?t:e._scheduleTaskZS),this._scheduleTaskDlgt=t&&(t.onScheduleTask?e:e._scheduleTaskDlgt),this._scheduleTaskCurrZone=t&&(t.onScheduleTask?this.zone:e._scheduleTaskCurrZone),this._invokeTaskZS=t&&(t.onInvokeTask?t:e._invokeTaskZS),this._invokeTaskDlgt=t&&(t.onInvokeTask?e:e._invokeTaskDlgt),this._invokeTaskCurrZone=t&&(t.onInvokeTask?this.zone:e._invokeTaskCurrZone),this._cancelTaskZS=t&&(t.onCancelTask?t:e._cancelTaskZS),this._cancelTaskDlgt=t&&(t.onCancelTask?e:e._cancelTaskDlgt),this._cancelTaskCurrZone=t&&(t.onCancelTask?this.zone:e._cancelTaskCurrZone),this._hasTaskZS=null,this._hasTaskDlgt=null,this._hasTaskDlgtOwner=null,this._hasTaskCurrZone=null;const m=t&&t.onHasTask;(m||e&&e._hasTaskZS)&&(this._hasTaskZS=m?t:M,this._hasTaskDlgt=e,this._hasTaskDlgtOwner=this,this._hasTaskCurrZone=l,t.onScheduleTask||(this._scheduleTaskZS=M,this._scheduleTaskDlgt=e,this._scheduleTaskCurrZone=this.zone),t.onInvokeTask||(this._invokeTaskZS=M,this._invokeTaskDlgt=e,this._invokeTaskCurrZone=this.zone),t.onCancelTask||(this._cancelTaskZS=M,this._cancelTaskDlgt=e,this._cancelTaskCurrZone=this.zone))}fork(l,e){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,l,e):new v(l,e)}intercept(l,e,t){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this._interceptCurrZone,l,e,t):e}invoke(l,e,t,m,_){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this._invokeCurrZone,l,e,t,m,_):e.apply(t,m)}handleError(l,e){return!this._handleErrorZS||this._handleErrorZS.onHandleError(this._handleErrorDlgt,this._handleErrorCurrZone,l,e)}scheduleTask(l,e){let t=e;if(this._scheduleTaskZS)this._hasTaskZS&&t._zoneDelegates.push(this._hasTaskDlgtOwner),t=this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt,this._scheduleTaskCurrZone,l,e),t||(t=e);else if(e.scheduleFn)e.scheduleFn(e);else{if(e.type!=C)throw new Error("Task is missing scheduleFn.");g(e)}return t}invokeTask(l,e,t,m){return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this._invokeTaskCurrZone,l,e,t,m):e.callback.apply(t,m)}cancelTask(l,e){let t;if(this._cancelTaskZS)t=this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt,this._cancelTaskCurrZone,l,e);else{if(!e.cancelFn)throw Error("Task is not cancelable");t=e.cancelFn(e)}return t}hasTask(l,e){try{this._hasTaskZS&&this._hasTaskZS.onHasTask(this._hasTaskDlgt,this._hasTaskCurrZone,l,e)}catch(t){this.handleError(l,t)}}_updateTaskCount(l,e){const t=this._taskCounts,m=t[l],_=t[l]=m+e;if(_<0)throw new Error("More tasks executed then were scheduled.");0!=m&&0!=_||this.hasTask(this.zone,{microTask:t.microTask>0,macroTask:t.macroTask>0,eventTask:t.eventTask>0,change:l})}}class y{constructor(l,e,t,m,_,H){if(this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=l,this.source=e,this.data=m,this.scheduleFn=_,this.cancelFn=H,!t)throw new Error("callback is not defined");this.callback=t;const f=this;this.invoke=l===N&&m&&m.useG?y.invokeTask:function(){return y.invokeTask.call(n,f,this,arguments)}}static invokeTask(l,e,t){l||(l=this),r++;try{return l.runCount++,l.zone.runTask(l,e,t)}finally{1==r&&S(),r--}}get zone(){return this._zone}get state(){return this._state}cancelScheduleRequest(){this._transitionTo(U,J)}_transitionTo(l,e,t){if(this._state!==e&&this._state!==t)throw new Error(`${this.type} '${this.source}': can not transition to '${l}', expecting state '${e}'${t?" or '"+t+"'":""}, was '${this._state}'.`);this._state=l,l==U&&(this._zoneDelegates=null)}toString(){return this.data&&void 0!==this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)}toJSON(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}}}const A=p("setTimeout"),R=p("Promise"),j=p("then");let k,q=[],F=!1;function g(u){if(0===r&&0===q.length)if(k||n[R]&&(k=n[R].resolve(0)),k){let l=k[j];l||(l=k.then),l.call(k,S)}else n[A](S,0);u&&q.push(u)}function S(){if(!F){for(F=!0;q.length;){const u=q;q=[];for(let l=0;l<u.length;l++){const e=u[l];try{e.zone.runTask(e,null,null)}catch(t){me.onUnhandledError(t)}}}me.microtaskDrainDone(),F=!1}}const G={name:"NO ZONE"},U="notScheduled",J="scheduling",D="scheduled",$="running",x="canceling",K="unknown",C="microTask",Z="macroTask",N="eventTask",te={},me={symbol:p,currentZoneFrame:()=>B,onUnhandledError:a,microtaskDrainDone:a,scheduleMicroTask:g,showUncaughtError:()=>!v[p("ignoreConsoleErrorUncaughtError")],patchEventTarget:()=>[],patchOnProperties:a,patchMethod:()=>a,bindArguments:()=>[],patchThen:()=>a,patchMacroTask:()=>a,patchEventPrototype:()=>a,isIEOrEdge:()=>!1,getGlobalObjects:()=>{},ObjectDefineProperty:()=>a,ObjectGetOwnPropertyDescriptor:()=>{},ObjectCreate:()=>{},ArraySlice:()=>[],patchClass:()=>a,wrapWithCurrentZone:()=>a,filterProperties:()=>[],attachOriginToPatched:()=>a,_redefineProperty:()=>a,patchCallbacks:()=>a};let B={parent:null,zone:new v(null,null)},ne=null,r=0;function a(){}s("Zone","Zone"),n.Zone=v}("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global);const re=Object.getOwnPropertyDescriptor,ye=Object.defineProperty,ve=Object.getPrototypeOf,pt=Object.create,Ge=Array.prototype.slice,Ie="addEventListener",Ye="removeEventListener",$e=Zone.__symbol__(Ie),Ke=Zone.__symbol__(Ye),fe="true",ke="false",Ne=Zone.__symbol__("");function it(n,o){return Zone.current.wrap(n,o)}function Je(n,o,c,s,h){return Zone.current.scheduleMacroTask(n,o,c,s,h)}const V=Zone.__symbol__,He="undefined"!=typeof window,De=He?window:void 0,ee=He&&De||"object"==typeof self&&self||global,Tt=[null];function ze(n,o){for(let c=n.length-1;c>=0;c--)"function"==typeof n[c]&&(n[c]=it(n[c],o+"_"+c));return n}function W(n){return!n||!1!==n.writable&&!("function"==typeof n.get&&void 0===n.set)}const se="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,Qe=!("nw"in ee)&&void 0!==ee.process&&"[object process]"==={}.toString.call(ee.process),Re=!Qe&&!se&&!(!He||!De.HTMLElement),pe=void 0!==ee.process&&"[object process]"==={}.toString.call(ee.process)&&!se&&!(!He||!De.HTMLElement),ce={},Ee=function(n){if(!(n=n||ee.event))return;let o=ce[n.type];o||(o=ce[n.type]=V("ON_PROPERTY"+n.type));const c=this||n.target||ee,s=c[o];let h;if(Re&&c===De&&"error"===n.type){const p=n;h=s&&s.call(this,p.message,p.filename,p.lineno,p.colno,p.error),!0===h&&n.preventDefault()}else h=s&&s.apply(this,arguments),null!=h&&!h&&n.preventDefault();return h};function be(n,o,c){let s=re(n,o);if(!s&&c&&re(c,o)&&(s={enumerable:!0,configurable:!0}),!s||!s.configurable)return;const h=V("on"+o+"patched");if(n.hasOwnProperty(h)&&n[h])return;delete s.writable,delete s.value;const p=s.get,T=s.set,v=o.substr(2);let M=ce[v];M||(M=ce[v]=V("ON_PROPERTY"+v)),s.set=function(b){let y=this;!y&&n===ee&&(y=ee),y&&(y[M]&&y.removeEventListener(v,Ee),T&&T.apply(y,Tt),"function"==typeof b?(y[M]=b,y.addEventListener(v,Ee,!1)):y[M]=null)},s.get=function(){let b=this;if(!b&&n===ee&&(b=ee),!b)return null;const y=b[M];if(y)return y;if(p){let A=p&&p.call(this);if(A)return s.set.call(this,A),"function"==typeof b.removeAttribute&&b.removeAttribute(o),A}return null},ye(n,o,s),n[h]=!0}function he(n,o,c){if(o)for(let s=0;s<o.length;s++)be(n,"on"+o[s],c);else{const s=[];for(const h in n)"on"==h.substr(0,2)&&s.push(h);for(let h=0;h<s.length;h++)be(n,s[h],c)}}const oe=V("originalInstance");function le(n){const o=ee[n];if(!o)return;ee[V(n)]=o,ee[n]=function(){const h=ze(arguments,n);switch(h.length){case 0:this[oe]=new o;break;case 1:this[oe]=new o(h[0]);break;case 2:this[oe]=new o(h[0],h[1]);break;case 3:this[oe]=new o(h[0],h[1],h[2]);break;case 4:this[oe]=new o(h[0],h[1],h[2],h[3]);break;default:throw new Error("Arg list too long.")}},Te(ee[n],o);const c=new o(function(){});let s;for(s in c)"XMLHttpRequest"===n&&"responseBlob"===s||function(h){"function"==typeof c[h]?ee[n].prototype[h]=function(){return this[oe][h].apply(this[oe],arguments)}:ye(ee[n].prototype,h,{set:function(p){"function"==typeof p?(this[oe][h]=it(p,n+"."+h),Te(this[oe][h],p)):this[oe][h]=p},get:function(){return this[oe][h]}})}(s);for(s in o)"prototype"!==s&&o.hasOwnProperty(s)&&(ee[n][s]=o[s])}function we(n,o,c){let s=n;for(;s&&!s.hasOwnProperty(o);)s=ve(s);!s&&n[o]&&(s=n);const h=V(o);let p=null;if(s&&(!(p=s[h])||!s.hasOwnProperty(h))&&(p=s[h]=s[o],W(s&&re(s,o)))){const v=c(p,h,o);s[o]=function(){return v(this,arguments)},Te(s[o],p)}return p}function gt(n,o,c){let s=null;function h(p){const T=p.data;return T.args[T.cbIdx]=function(){p.invoke.apply(this,arguments)},s.apply(T.target,T.args),p}s=we(n,o,p=>function(T,v){const M=c(T,v);return M.cbIdx>=0&&"function"==typeof v[M.cbIdx]?Je(M.name,v[M.cbIdx],M,h):p.apply(T,v)})}function Te(n,o){n[V("OriginalDelegate")]=o}let Ae=!1,at=!1;function ct(){if(Ae)return at;Ae=!0;try{const n=De.navigator.userAgent;(-1!==n.indexOf("MSIE ")||-1!==n.indexOf("Trident/")||-1!==n.indexOf("Edge/"))&&(at=!0)}catch(n){}return at}Zone.__load_patch("ZoneAwarePromise",(n,o,c)=>{const s=Object.getOwnPropertyDescriptor,h=Object.defineProperty,T=c.symbol,v=[],M=!0===n[T("DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION")],b=T("Promise"),y=T("then");c.onUnhandledError=f=>{if(c.showUncaughtError()){const i=f&&f.rejection;i?console.error("Unhandled Promise rejection:",i instanceof Error?i.message:i,"; Zone:",f.zone.name,"; Task:",f.task&&f.task.source,"; Value:",i,i instanceof Error?i.stack:void 0):console.error(f)}},c.microtaskDrainDone=()=>{for(;v.length;){const f=v.shift();try{f.zone.runGuarded(()=>{throw f.throwOriginal?f.rejection:f})}catch(i){j(i)}}};const R=T("unhandledPromiseRejectionHandler");function j(f){c.onUnhandledError(f);try{const i=o[R];"function"==typeof i&&i.call(this,f)}catch(i){}}function q(f){return f&&f.then}function F(f){return f}function k(f){return e.reject(f)}const g=T("state"),S=T("value"),G=T("finally"),U=T("parentPromiseValue"),J=T("parentPromiseState"),$=null,x=!0,K=!1;function Z(f,i){return d=>{try{B(f,i,d)}catch(E){B(f,!1,E)}}}const me=T("currentTaskTrace");function B(f,i,d){const E=function(){let f=!1;return function(d){return function(){f||(f=!0,d.apply(null,arguments))}}}();if(f===d)throw new TypeError("Promise resolved with itself");if(f[g]===$){let w=null;try{("object"==typeof d||"function"==typeof d)&&(w=d&&d.then)}catch(P){return E(()=>{B(f,!1,P)})(),f}if(i!==K&&d instanceof e&&d.hasOwnProperty(g)&&d.hasOwnProperty(S)&&d[g]!==$)r(d),B(f,d[g],d[S]);else if(i!==K&&"function"==typeof w)try{w.call(d,E(Z(f,i)),E(Z(f,!1)))}catch(P){E(()=>{B(f,!1,P)})()}else{f[g]=i;const P=f[S];if(f[S]=d,f[G]===G&&i===x&&(f[g]=f[J],f[S]=f[U]),i===K&&d instanceof Error){const L=o.currentTask&&o.currentTask.data&&o.currentTask.data.__creationTrace__;L&&h(d,me,{configurable:!0,enumerable:!1,writable:!0,value:L})}for(let L=0;L<P.length;)a(f,P[L++],P[L++],P[L++],P[L++]);if(0==P.length&&i==K){f[g]=0;let L=d;try{throw new Error("Uncaught (in promise): "+function(f){return f&&f.toString===Object.prototype.toString?(f.constructor&&f.constructor.name||"")+": "+JSON.stringify(f):f?f.toString():Object.prototype.toString.call(f)}(d)+(d&&d.stack?"\n"+d.stack:""))}catch(O){L=O}M&&(L.throwOriginal=!0),L.rejection=d,L.promise=f,L.zone=o.current,L.task=o.currentTask,v.push(L),c.scheduleMicroTask()}}}return f}const ne=T("rejectionHandledHandler");function r(f){if(0===f[g]){try{const i=o[ne];i&&"function"==typeof i&&i.call(this,{rejection:f[S],promise:f})}catch(i){}f[g]=K;for(let i=0;i<v.length;i++)f===v[i].promise&&v.splice(i,1)}}function a(f,i,d,E,w){r(f);const P=f[g],L=P?"function"==typeof E?E:F:"function"==typeof w?w:k;i.scheduleMicroTask("Promise.then",()=>{try{const O=f[S],I=!!d&&G===d[G];I&&(d[U]=O,d[J]=P);const z=i.run(L,void 0,I&&L!==k&&L!==F?[]:[O]);B(d,!0,z)}catch(O){B(d,!1,O)}},d)}const l=function(){};class e{static toString(){return"function ZoneAwarePromise() { [native code] }"}static resolve(i){return B(new this(null),x,i)}static reject(i){return B(new this(null),K,i)}static race(i){let d,E,w=new this((O,I)=>{d=O,E=I});function P(O){d(O)}function L(O){E(O)}for(let O of i)q(O)||(O=this.resolve(O)),O.then(P,L);return w}static all(i){return e.allWithCallback(i)}static allSettled(i){return(this&&this.prototype instanceof e?this:e).allWithCallback(i,{thenCallback:E=>({status:"fulfilled",value:E}),errorCallback:E=>({status:"rejected",reason:E})})}static allWithCallback(i,d){let E,w,P=new this((z,Q)=>{E=z,w=Q}),L=2,O=0;const I=[];for(let z of i){q(z)||(z=this.resolve(z));const Q=O;try{z.then(ae=>{I[Q]=d?d.thenCallback(ae):ae,L--,0===L&&E(I)},ae=>{d?(I[Q]=d.errorCallback(ae),L--,0===L&&E(I)):w(ae)})}catch(ae){w(ae)}L++,O++}return L-=2,0===L&&E(I),P}constructor(i){const d=this;if(!(d instanceof e))throw new Error("Must be an instanceof Promise.");d[g]=$,d[S]=[];try{i&&i(Z(d,x),Z(d,K))}catch(E){B(d,!1,E)}}get[Symbol.toStringTag](){return"Promise"}get[Symbol.species](){return e}then(i,d){let E=this.constructor[Symbol.species];(!E||"function"!=typeof E)&&(E=this.constructor||e);const w=new E(l),P=o.current;return this[g]==$?this[S].push(P,w,i,d):a(this,P,w,i,d),w}catch(i){return this.then(null,i)}finally(i){let d=this.constructor[Symbol.species];(!d||"function"!=typeof d)&&(d=e);const E=new d(l);E[G]=G;const w=o.current;return this[g]==$?this[S].push(w,E,i,i):a(this,w,E,i,i),E}}e.resolve=e.resolve,e.reject=e.reject,e.race=e.race,e.all=e.all;const t=n[b]=n.Promise;n.Promise=e;const m=T("thenPatched");function _(f){const i=f.prototype,d=s(i,"then");if(d&&(!1===d.writable||!d.configurable))return;const E=i.then;i[y]=E,f.prototype.then=function(w,P){return new e((O,I)=>{E.call(this,O,I)}).then(w,P)},f[m]=!0}return c.patchThen=_,t&&(_(t),we(n,"fetch",f=>function(f){return function(i,d){let E=f.apply(i,d);if(E instanceof e)return E;let w=E.constructor;return w[m]||_(w),E}}(f))),Promise[o.__symbol__("uncaughtPromiseErrors")]=v,e}),Zone.__load_patch("toString",n=>{const o=Function.prototype.toString,c=V("OriginalDelegate"),s=V("Promise"),h=V("Error"),p=function(){if("function"==typeof this){const b=this[c];if(b)return"function"==typeof b?o.call(b):Object.prototype.toString.call(b);if(this===Promise){const y=n[s];if(y)return o.call(y)}if(this===Error){const y=n[h];if(y)return o.call(y)}}return o.call(this)};p[c]=o,Function.prototype.toString=p;const T=Object.prototype.toString;Object.prototype.toString=function(){return"function"==typeof Promise&&this instanceof Promise?"[object Promise]":T.call(this)}});let Me=!1;if("undefined"!=typeof window)try{const n=Object.defineProperty({},"passive",{get:function(){Me=!0}});window.addEventListener("test",n,n),window.removeEventListener("test",n,n)}catch(n){Me=!1}const Se={useG:!0},ie={},yt={},je=new RegExp("^"+Ne+"(\\w+)(true|false)$"),xe=V("propagationStopped");function vt(n,o){const c=(o?o(n):n)+ke,s=(o?o(n):n)+fe,h=Ne+c,p=Ne+s;ie[n]={},ie[n][ke]=h,ie[n][fe]=p}function Pt(n,o,c){const s=c&&c.add||Ie,h=c&&c.rm||Ye,p=c&&c.listeners||"eventListeners",T=c&&c.rmAll||"removeAllListeners",v=V(s),M="."+s+":",A=function(k,g,S){if(k.isRemoved)return;const G=k.callback;"object"==typeof G&&G.handleEvent&&(k.callback=J=>G.handleEvent(J),k.originalDelegate=G),k.invoke(k,g,[S]);const U=k.options;U&&"object"==typeof U&&U.once&&g[h].call(g,S.type,k.originalDelegate?k.originalDelegate:k.callback,U)},R=function(k){if(!(k=k||n.event))return;const g=this||k.target||n,S=g[ie[k.type][ke]];if(S)if(1===S.length)A(S[0],g,k);else{const G=S.slice();for(let U=0;U<G.length&&(!k||!0!==k[xe]);U++)A(G[U],g,k)}},j=function(k){if(!(k=k||n.event))return;const g=this||k.target||n,S=g[ie[k.type][fe]];if(S)if(1===S.length)A(S[0],g,k);else{const G=S.slice();for(let U=0;U<G.length&&(!k||!0!==k[xe]);U++)A(G[U],g,k)}};function q(k,g){if(!k)return!1;let S=!0;g&&void 0!==g.useG&&(S=g.useG);const G=g&&g.vh;let U=!0;g&&void 0!==g.chkDup&&(U=g.chkDup);let J=!1;g&&void 0!==g.rt&&(J=g.rt);let D=k;for(;D&&!D.hasOwnProperty(s);)D=ve(D);if(!D&&k[s]&&(D=k),!D||D[v])return!1;const $=g&&g.eventNameToString,x={},K=D[v]=D[s],C=D[V(h)]=D[h],Z=D[V(p)]=D[p],N=D[V(T)]=D[T];let te;function me(i,d){return!Me&&"object"==typeof i&&i?!!i.capture:Me&&d?"boolean"==typeof i?{capture:i,passive:!0}:i?"object"==typeof i&&!1!==i.passive?Object.assign(Object.assign({},i),{passive:!0}):i:{passive:!0}:i}g&&g.prepend&&(te=D[V(g.prepend)]=D[g.prepend]);const l=S?function(i){if(!x.isExisting)return K.call(x.target,x.eventName,x.capture?j:R,x.options)}:function(i){return K.call(x.target,x.eventName,i.invoke,x.options)},e=S?function(i){if(!i.isRemoved){const d=ie[i.eventName];let E;d&&(E=d[i.capture?fe:ke]);const w=E&&i.target[E];if(w)for(let P=0;P<w.length;P++)if(w[P]===i){w.splice(P,1),i.isRemoved=!0,0===w.length&&(i.allRemoved=!0,i.target[E]=null);break}}if(i.allRemoved)return C.call(i.target,i.eventName,i.capture?j:R,i.options)}:function(i){return C.call(i.target,i.eventName,i.invoke,i.options)},m=g&&g.diff?g.diff:function(i,d){const E=typeof d;return"function"===E&&i.callback===d||"object"===E&&i.originalDelegate===d},_=Zone[V("UNPATCHED_EVENTS")],H=n[V("PASSIVE_EVENTS")],f=function(i,d,E,w,P=!1,L=!1){return function(){const O=this||n;let I=arguments[0];g&&g.transferEventName&&(I=g.transferEventName(I));let z=arguments[1];if(!z)return i.apply(this,arguments);if(Qe&&"uncaughtException"===I)return i.apply(this,arguments);let Q=!1;if("function"!=typeof z){if(!z.handleEvent)return i.apply(this,arguments);Q=!0}if(G&&!G(i,z,O,arguments))return;const ae=Me&&!!H&&-1!==H.indexOf(I),Oe=me(arguments[2],ae);if(_)for(let Xe=0;Xe<_.length;Xe++)if(I===_[Xe])return ae?i.call(O,I,z,Oe):i.apply(this,arguments);const Ot=!!Oe&&("boolean"==typeof Oe||Oe.capture),Ht=!(!Oe||"object"!=typeof Oe)&&Oe.once,It=Zone.current;let Nt=ie[I];Nt||(vt(I,$),Nt=ie[I]);const Dt=Nt[Ot?fe:ke];let Ct,st=O[Dt],Rt=!1;if(st){if(Rt=!0,U)for(let Xe=0;Xe<st.length;Xe++)if(m(st[Xe],z))return}else st=O[Dt]=[];const St=O.constructor.name,Zt=yt[St];Zt&&(Ct=Zt[I]),Ct||(Ct=St+d+($?$(I):I)),x.options=Oe,Ht&&(x.options.once=!1),x.target=O,x.capture=Ot,x.eventName=I,x.isExisting=Rt;const mt=S?Se:void 0;mt&&(mt.taskData=x);const Be=It.scheduleEventTask(Ct,z,mt,E,w);return x.target=null,mt&&(mt.taskData=null),Ht&&(Oe.once=!0),!Me&&"boolean"==typeof Be.options||(Be.options=Oe),Be.target=O,Be.capture=Ot,Be.eventName=I,Q&&(Be.originalDelegate=z),L?st.unshift(Be):st.push(Be),P?O:void 0}};return D[s]=f(K,M,l,e,J),te&&(D.prependListener=f(te,".prependListener:",function(i){return te.call(x.target,x.eventName,i.invoke,x.options)},e,J,!0)),D[h]=function(){const i=this||n;let d=arguments[0];g&&g.transferEventName&&(d=g.transferEventName(d));const E=arguments[2],w=!!E&&("boolean"==typeof E||E.capture),P=arguments[1];if(!P)return C.apply(this,arguments);if(G&&!G(C,P,i,arguments))return;const L=ie[d];let O;L&&(O=L[w?fe:ke]);const I=O&&i[O];if(I)for(let z=0;z<I.length;z++){const Q=I[z];if(m(Q,P))return I.splice(z,1),Q.isRemoved=!0,0===I.length&&(Q.allRemoved=!0,i[O]=null,"string"==typeof d)&&(i[Ne+"ON_PROPERTY"+d]=null),Q.zone.cancelTask(Q),J?i:void 0}return C.apply(this,arguments)},D[p]=function(){const i=this||n;let d=arguments[0];g&&g.transferEventName&&(d=g.transferEventName(d));const E=[],w=Ce(i,$?$(d):d);for(let P=0;P<w.length;P++){const L=w[P];E.push(L.originalDelegate?L.originalDelegate:L.callback)}return E},D[T]=function(){const i=this||n;let d=arguments[0];if(d){g&&g.transferEventName&&(d=g.transferEventName(d));const E=ie[d];if(E){const L=i[E[ke]],O=i[E[fe]];if(L){const I=L.slice();for(let z=0;z<I.length;z++){const Q=I[z];this[h].call(this,d,Q.originalDelegate?Q.originalDelegate:Q.callback,Q.options)}}if(O){const I=O.slice();for(let z=0;z<I.length;z++){const Q=I[z];this[h].call(this,d,Q.originalDelegate?Q.originalDelegate:Q.callback,Q.options)}}}}else{const E=Object.keys(i);for(let w=0;w<E.length;w++){const L=je.exec(E[w]);let O=L&&L[1];O&&"removeListener"!==O&&this[T].call(this,O)}this[T].call(this,"removeListener")}if(J)return this},Te(D[s],K),Te(D[h],C),N&&Te(D[T],N),Z&&Te(D[p],Z),!0}let F=[];for(let k=0;k<o.length;k++)F[k]=q(o[k],c);return F}function Ce(n,o){if(!o){const p=[];for(let T in n){const v=je.exec(T);let M=v&&v[1];if(M&&(!o||M===o)){const b=n[T];if(b)for(let y=0;y<b.length;y++)p.push(b[y])}}return p}let c=ie[o];c||(vt(o),c=ie[o]);const s=n[c[ke]],h=n[c[fe]];return s?h?s.concat(h):s.slice():h?h.slice():[]}function qe(n,o){const c=n.Event;c&&c.prototype&&o.patchMethod(c.prototype,"stopImmediatePropagation",s=>function(h,p){h[xe]=!0,s&&s.apply(h,p)})}function ue(n,o,c,s,h){const p=Zone.__symbol__(s);if(o[p])return;const T=o[p]=o[s];o[s]=function(v,M,b){return M&&M.prototype&&h.forEach(function(y){const A=`${c}.${s}::`+y,R=M.prototype;if(R.hasOwnProperty(y)){const j=n.ObjectGetOwnPropertyDescriptor(R,y);j&&j.value?(j.value=n.wrapWithCurrentZone(j.value,A),n._redefineProperty(M.prototype,y,j)):R[y]&&(R[y]=n.wrapWithCurrentZone(R[y],A))}else R[y]&&(R[y]=n.wrapWithCurrentZone(R[y],A))}),T.call(o,v,M,b)},n.attachOriginToPatched(o[s],T)}const We=["absolutedeviceorientation","afterinput","afterprint","appinstalled","beforeinstallprompt","beforeprint","beforeunload","devicelight","devicemotion","deviceorientation","deviceorientationabsolute","deviceproximity","hashchange","languagechange","message","mozbeforepaint","offline","online","paint","pageshow","pagehide","popstate","rejectionhandled","storage","unhandledrejection","unload","userproximity","vrdisplayconnected","vrdisplaydisconnected","vrdisplaypresentchange"],tt=["encrypted","waitingforkey","msneedkey","mozinterruptbegin","mozinterruptend"],bt=["load"],ht=["blur","error","focus","load","resize","scroll","messageerror"],wt=["bounce","finish","start"],Lt=["loadstart","progress","abort","error","load","progress","timeout","loadend","readystatechange"],ge=["upgradeneeded","complete","abort","success","error","blocked","versionchange","close"],Le=["close","error","open","message"],Ue=["error","message"],Ze=["abort","animationcancel","animationend","animationiteration","auxclick","beforeinput","blur","cancel","canplay","canplaythrough","change","compositionstart","compositionupdate","compositionend","cuechange","click","close","contextmenu","curechange","dblclick","drag","dragend","dragenter","dragexit","dragleave","dragover","drop","durationchange","emptied","ended","error","focus","focusin","focusout","gotpointercapture","input","invalid","keydown","keypress","keyup","load","loadstart","loadeddata","loadedmetadata","lostpointercapture","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","mousewheel","orientationchange","pause","play","playing","pointercancel","pointerdown","pointerenter","pointerleave","pointerlockchange","mozpointerlockchange","webkitpointerlockerchange","pointerlockerror","mozpointerlockerror","webkitpointerlockerror","pointermove","pointout","pointerover","pointerup","progress","ratechange","reset","resize","scroll","seeked","seeking","select","selectionchange","selectstart","show","sort","stalled","submit","suspend","timeupdate","volumechange","touchcancel","touchmove","touchstart","touchend","transitioncancel","transitionend","waiting","wheel"].concat(["webglcontextrestored","webglcontextlost","webglcontextcreationerror"],["autocomplete","autocompleteerror"],["toggle"],["afterscriptexecute","beforescriptexecute","DOMContentLoaded","freeze","fullscreenchange","mozfullscreenchange","webkitfullscreenchange","msfullscreenchange","fullscreenerror","mozfullscreenerror","webkitfullscreenerror","msfullscreenerror","readystatechange","visibilitychange","resume"],We,["beforecopy","beforecut","beforepaste","copy","cut","paste","dragstart","loadend","animationstart","search","transitionrun","transitionstart","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend"],["activate","afterupdate","ariarequest","beforeactivate","beforedeactivate","beforeeditfocus","beforeupdate","cellchange","controlselect","dataavailable","datasetchanged","datasetcomplete","errorupdate","filterchange","layoutcomplete","losecapture","move","moveend","movestart","propertychange","resizeend","resizestart","rowenter","rowexit","rowsdelete","rowsinserted","command","compassneedscalibration","deactivate","help","mscontentzoom","msmanipulationstatechanged","msgesturechange","msgesturedoubletap","msgestureend","msgesturehold","msgesturestart","msgesturetap","msgotpointercapture","msinertiastart","mslostpointercapture","mspointercancel","mspointerdown","mspointerenter","mspointerhover","mspointerleave","mspointermove","mspointerout","mspointerover","mspointerup","pointerout","mssitemodejumplistitemremoved","msthumbnailclick","stop","storagecommit"]);function Mt(n,o,c){if(!c||0===c.length)return o;const s=c.filter(p=>p.target===n);if(!s||0===s.length)return o;const h=s[0].ignoreProperties;return o.filter(p=>-1===h.indexOf(p))}function Y(n,o,c,s){n&&he(n,Mt(n,o,c),s)}Zone.__load_patch("util",(n,o,c)=>{c.patchOnProperties=he,c.patchMethod=we,c.bindArguments=ze,c.patchMacroTask=gt;const s=o.__symbol__("BLACK_LISTED_EVENTS"),h=o.__symbol__("UNPATCHED_EVENTS");n[h]&&(n[s]=n[h]),n[s]&&(o[s]=o[h]=n[s]),c.patchEventPrototype=qe,c.patchEventTarget=Pt,c.isIEOrEdge=ct,c.ObjectDefineProperty=ye,c.ObjectGetOwnPropertyDescriptor=re,c.ObjectCreate=pt,c.ArraySlice=Ge,c.patchClass=le,c.wrapWithCurrentZone=it,c.filterProperties=Mt,c.attachOriginToPatched=Te,c._redefineProperty=Object.defineProperty,c.patchCallbacks=ue,c.getGlobalObjects=()=>({globalSources:yt,zoneSymbolEventNames:ie,eventNames:Ze,isBrowser:Re,isMix:pe,isNode:Qe,TRUE_STR:fe,FALSE_STR:ke,ZONE_SYMBOL_PREFIX:Ne,ADD_EVENT_LISTENER_STR:Ie,REMOVE_EVENT_LISTENER_STR:Ye})});const Pe=V("zoneTask");function de(n,o,c,s){let h=null,p=null;c+=s;const T={};function v(b){const y=b.data;return y.args[0]=function(){return b.invoke.apply(this,arguments)},y.handleId=h.apply(n,y.args),b}function M(b){return p.call(n,b.data.handleId)}h=we(n,o+=s,b=>function(y,A){if("function"==typeof A[0]){const R={isPeriodic:"Interval"===s,delay:"Timeout"===s||"Interval"===s?A[1]||0:void 0,args:A},j=A[0];A[0]=function(){try{return j.apply(this,arguments)}finally{R.isPeriodic||("number"==typeof R.handleId?delete T[R.handleId]:R.handleId&&(R.handleId[Pe]=null))}};const q=Je(o,A[0],R,v,M);if(!q)return q;const F=q.data.handleId;return"number"==typeof F?T[F]=q:F&&(F[Pe]=q),F&&F.ref&&F.unref&&"function"==typeof F.ref&&"function"==typeof F.unref&&(q.ref=F.ref.bind(F),q.unref=F.unref.bind(F)),"number"==typeof F||F?F:q}return b.apply(n,A)}),p=we(n,c,b=>function(y,A){const R=A[0];let j;"number"==typeof R?j=T[R]:(j=R&&R[Pe],j||(j=R)),j&&"string"==typeof j.type?"notScheduled"!==j.state&&(j.cancelFn&&j.data.isPeriodic||0===j.runCount)&&("number"==typeof R?delete T[R]:R&&(R[Pe]=null),j.zone.cancelTask(j)):b.apply(n,A)})}Zone.__load_patch("legacy",n=>{const o=n[Zone.__symbol__("legacyPatch")];o&&o()}),Zone.__load_patch("queueMicrotask",(n,o,c)=>{c.patchMethod(n,"queueMicrotask",s=>function(h,p){o.current.scheduleMicroTask("queueMicrotask",p[0])})}),Zone.__load_patch("timers",n=>{const o="set",c="clear";de(n,o,c,"Timeout"),de(n,o,c,"Interval"),de(n,o,c,"Immediate")}),Zone.__load_patch("requestAnimationFrame",n=>{de(n,"request","cancel","AnimationFrame"),de(n,"mozRequest","mozCancel","AnimationFrame"),de(n,"webkitRequest","webkitCancel","AnimationFrame")}),Zone.__load_patch("blocking",(n,o)=>{const c=["alert","prompt","confirm"];for(let s=0;s<c.length;s++)we(n,c[s],(p,T,v)=>function(M,b){return o.current.run(p,n,b,v)})}),Zone.__load_patch("EventTarget",(n,o,c)=>{(function(n,o){o.patchEventPrototype(n,o)})(n,c),function(n,o){if(Zone[o.symbol("patchEventTarget")])return;const{eventNames:c,zoneSymbolEventNames:s,TRUE_STR:h,FALSE_STR:p,ZONE_SYMBOL_PREFIX:T}=o.getGlobalObjects();for(let M=0;M<c.length;M++){const b=c[M],R=T+(b+p),j=T+(b+h);s[b]={},s[b][p]=R,s[b][h]=j}const v=n.EventTarget;v&&v.prototype&&o.patchEventTarget(n,[v&&v.prototype])}(n,c);const s=n.XMLHttpRequestEventTarget;s&&s.prototype&&c.patchEventTarget(n,[s.prototype])}),Zone.__load_patch("MutationObserver",(n,o,c)=>{le("MutationObserver"),le("WebKitMutationObserver")}),Zone.__load_patch("IntersectionObserver",(n,o,c)=>{le("IntersectionObserver")}),Zone.__load_patch("FileReader",(n,o,c)=>{le("FileReader")}),Zone.__load_patch("on_property",(n,o,c)=>{!function(n,o){if(Qe&&!pe||Zone[n.symbol("patchEvents")])return;const c="undefined"!=typeof WebSocket,s=o.__Zone_ignore_on_properties;if(Re){const T=window,v=function(){try{const n=De.navigator.userAgent;if(-1!==n.indexOf("MSIE ")||-1!==n.indexOf("Trident/"))return!0}catch(n){}return!1}()?[{target:T,ignoreProperties:["error"]}]:[];Y(T,Ze.concat(["messageerror"]),s&&s.concat(v),ve(T)),Y(Document.prototype,Ze,s),void 0!==T.SVGElement&&Y(T.SVGElement.prototype,Ze,s),Y(Element.prototype,Ze,s),Y(HTMLElement.prototype,Ze,s),Y(HTMLMediaElement.prototype,tt,s),Y(HTMLFrameSetElement.prototype,We.concat(ht),s),Y(HTMLBodyElement.prototype,We.concat(ht),s),Y(HTMLFrameElement.prototype,bt,s),Y(HTMLIFrameElement.prototype,bt,s);const M=T.HTMLMarqueeElement;M&&Y(M.prototype,wt,s);const b=T.Worker;b&&Y(b.prototype,Ue,s)}const h=o.XMLHttpRequest;h&&Y(h.prototype,Lt,s);const p=o.XMLHttpRequestEventTarget;p&&Y(p&&p.prototype,Lt,s),"undefined"!=typeof IDBIndex&&(Y(IDBIndex.prototype,ge,s),Y(IDBRequest.prototype,ge,s),Y(IDBOpenDBRequest.prototype,ge,s),Y(IDBDatabase.prototype,ge,s),Y(IDBTransaction.prototype,ge,s),Y(IDBCursor.prototype,ge,s)),c&&Y(WebSocket.prototype,Le,s)}(c,n)}),Zone.__load_patch("customElements",(n,o,c)=>{!function(n,o){const{isBrowser:c,isMix:s}=o.getGlobalObjects();(c||s)&&n.customElements&&"customElements"in n&&o.patchCallbacks(o,n.customElements,"customElements","define",["connectedCallback","disconnectedCallback","adoptedCallback","attributeChangedCallback"])}(n,c)}),Zone.__load_patch("XHR",(n,o)=>{!function(b){const y=b.XMLHttpRequest;if(!y)return;const A=y.prototype;let j=A[$e],q=A[Ke];if(!j){const C=b.XMLHttpRequestEventTarget;if(C){const Z=C.prototype;j=Z[$e],q=Z[Ke]}}const F="readystatechange",k="scheduled";function g(C){const Z=C.data,N=Z.target;N[p]=!1,N[v]=!1;const te=N[h];j||(j=N[$e],q=N[Ke]),te&&q.call(N,F,te);const me=N[h]=()=>{if(N.readyState===N.DONE)if(!Z.aborted&&N[p]&&C.state===k){const ne=N[o.__symbol__("loadfalse")];if(0!==N.status&&ne&&ne.length>0){const r=C.invoke;C.invoke=function(){const a=N[o.__symbol__("loadfalse")];for(let u=0;u<a.length;u++)a[u]===C&&a.splice(u,1);!Z.aborted&&C.state===k&&r.call(C)},ne.push(C)}else C.invoke()}else!Z.aborted&&!1===N[p]&&(N[v]=!0)};return j.call(N,F,me),N[c]||(N[c]=C),x.apply(N,Z.args),N[p]=!0,C}function S(){}function G(C){const Z=C.data;return Z.aborted=!0,K.apply(Z.target,Z.args)}const U=we(A,"open",()=>function(C,Z){return C[s]=0==Z[2],C[T]=Z[1],U.apply(C,Z)}),D=V("fetchTaskAborting"),$=V("fetchTaskScheduling"),x=we(A,"send",()=>function(C,Z){if(!0===o.current[$]||C[s])return x.apply(C,Z);{const N={target:C,url:C[T],isPeriodic:!1,args:Z,aborted:!1},te=Je("XMLHttpRequest.send",S,N,g,G);C&&!0===C[v]&&!N.aborted&&te.state===k&&te.invoke()}}),K=we(A,"abort",()=>function(C,Z){const N=function(C){return C[c]}(C);if(N&&"string"==typeof N.type){if(null==N.cancelFn||N.data&&N.data.aborted)return;N.zone.cancelTask(N)}else if(!0===o.current[D])return K.apply(C,Z)})}(n);const c=V("xhrTask"),s=V("xhrSync"),h=V("xhrListener"),p=V("xhrScheduled"),T=V("xhrURL"),v=V("xhrErrorBeforeScheduled")}),Zone.__load_patch("geolocation",n=>{n.navigator&&n.navigator.geolocation&&function(n,o){const c=n.constructor.name;for(let s=0;s<o.length;s++){const h=o[s],p=n[h];if(p){if(!W(re(n,h)))continue;n[h]=(v=>{const M=function(){return v.apply(this,ze(arguments,c+"."+h))};return Te(M,v),M})(p)}}}(n.navigator.geolocation,["getCurrentPosition","watchPosition"])}),Zone.__load_patch("PromiseRejectionEvent",(n,o)=>{function c(s){return function(h){Ce(n,s).forEach(T=>{const v=n.PromiseRejectionEvent;if(v){const M=new v(s,{promise:h.promise,reason:h.rejection});T.invoke(M)}})}}n.PromiseRejectionEvent&&(o[V("unhandledPromiseRejectionHandler")]=c("unhandledrejection"),o[V("rejectionHandledHandler")]=c("rejectionhandled"))})},435:(X,re,ye)=>{"use strict";ye(277),ye(142)}},X=>{X(X.s=435)}]);(self.webpackChunkbounding_box_renderer_web_component=self.webpackChunkbounding_box_renderer_web_component||[]).push([[179],{255:$i=>{function Ee(Fn){return Promise.resolve().then(()=>{var b=new Error("Cannot find module '"+Fn+"'");throw b.code="MODULE_NOT_FOUND",b})}Ee.keys=()=>[],Ee.resolve=Ee,Ee.id=255,$i.exports=Ee},258:($i,Ee,Fn)=>{var v,f,m,d,a,u,b=b||{version:"5.0.0"};if(Ee.fabric=b,"undefined"!=typeof document&&"undefined"!=typeof window)b.document=document instanceof("undefined"!=typeof HTMLDocument?HTMLDocument:Document)?document:document.implementation.createHTMLDocument(""),b.window=window;else{var Ht=new(Fn(450).JSDOM)(decodeURIComponent("%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E"),{features:{FetchExternalResources:["img"]},resources:"usable"}).window;b.document=Ht.document,b.jsdomImplForWrapper=Fn(529).implForWrapper,b.nodeCanvas=Fn(536).Canvas,b.window=Ht,DOMParser=b.window.DOMParser}function ui(v,f){var m=v.canvas,d=f.targetCanvas,a=d.getContext("2d");a.translate(0,d.height),a.scale(1,-1),a.drawImage(m,0,m.height-d.height,d.width,d.height,0,0,d.width,d.height)}function Qr(v,f){var d=f.targetCanvas.getContext("2d"),a=f.destinationWidth,u=f.destinationHeight,o=a*u*4,h=new Uint8Array(this.imageBuffer,0,o),p=new Uint8ClampedArray(this.imageBuffer,0,o);v.readPixels(0,0,a,u,v.RGBA,v.UNSIGNED_BYTE,h);var l=new ImageData(p,a,u);d.putImageData(l,0,0)}b.isTouchSupported="ontouchstart"in b.window||"ontouchstart"in b.document||b.window&&b.window.navigator&&b.window.navigator.maxTouchPoints>0,b.isLikelyNode="undefined"!=typeof Buffer&&"undefined"==typeof window,b.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"],b.DPI=96,b.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)",b.commaWsp="(?:\\s+,?\\s*|,\\s*)",b.rePathCommand=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/gi,b.reNonWord=/[ \n\.,;!\?\-]/,b.fontPaths={},b.iMatrix=[1,0,0,1,0,0],b.svgNS="http://www.w3.org/2000/svg",b.perfLimitSizeTotal=2097152,b.maxCacheSideLimit=4096,b.minCacheSideLimit=256,b.charWidthsCache={},b.textureSize=2048,b.disableStyleCopyPaste=!1,b.enableGLFiltering=!0,b.devicePixelRatio=b.window.devicePixelRatio||b.window.webkitDevicePixelRatio||b.window.mozDevicePixelRatio||1,b.browserShadowBlurConstant=1,b.arcToSegmentsCache={},b.boundsOfCurveCache={},b.cachesBoundsOfCurve=!0,b.forceGLPutImageData=!1,b.initFilterBackend=function(){return b.enableGLFiltering&&b.isWebglSupported&&b.isWebglSupported(b.textureSize)?(console.log("max texture size: "+b.maxTextureSize),new b.WebglFilterBackend({tileSize:b.textureSize})):b.Canvas2dFilterBackend?new b.Canvas2dFilterBackend:void 0},"undefined"!=typeof document&&"undefined"!=typeof window&&(window.fabric=b),function(){function v(o,h){if(this.__eventListeners[o]){var p=this.__eventListeners[o];h?p[p.indexOf(h)]=!1:b.util.array.fill(p,!1)}}function m(o,h){var p=function(){h.apply(this,arguments),this.off(o,p)}.bind(this);this.on(o,p)}b.Observable={fire:function(o,h){if(!this.__eventListeners)return this;var p=this.__eventListeners[o];if(!p)return this;for(var l=0,y=p.length;l<y;l++)p[l]&&p[l].call(this,h||{});return this.__eventListeners[o]=p.filter(function(C){return!1!==C}),this},on:function(o,h){if(this.__eventListeners||(this.__eventListeners={}),1===arguments.length)for(var p in o)this.on(p,o[p]);else this.__eventListeners[o]||(this.__eventListeners[o]=[]),this.__eventListeners[o].push(h);return this},once:function(o,h){if(1===arguments.length)for(var p in o)m.call(this,p,o[p]);else m.call(this,o,h);return this},off:function(o,h){if(!this.__eventListeners)return this;if(0===arguments.length)for(o in this.__eventListeners)v.call(this,o);else if(1===arguments.length&&"object"==typeof arguments[0])for(var p in o)v.call(this,p,o[p]);else v.call(this,o,h);return this}}}(),b.Collection={_objects:[],add:function(){if(this._objects.push.apply(this._objects,arguments),this._onObjectAdded)for(var v=0,f=arguments.length;v<f;v++)this._onObjectAdded(arguments[v]);return this.renderOnAddRemove&&this.requestRenderAll(),this},insertAt:function(v,f,m){var d=this._objects;return m?d[f]=v:d.splice(f,0,v),this._onObjectAdded&&this._onObjectAdded(v),this.renderOnAddRemove&&this.requestRenderAll(),this},remove:function(){for(var f,v=this._objects,m=!1,d=0,a=arguments.length;d<a;d++)-1!==(f=v.indexOf(arguments[d]))&&(m=!0,v.splice(f,1),this._onObjectRemoved&&this._onObjectRemoved(arguments[d]));return this.renderOnAddRemove&&m&&this.requestRenderAll(),this},forEachObject:function(v,f){for(var m=this.getObjects(),d=0,a=m.length;d<a;d++)v.call(f,m[d],d,m);return this},getObjects:function(v){return void 0===v?this._objects.concat():this._objects.filter(function(f){return f.type===v})},item:function(v){return this._objects[v]},isEmpty:function(){return 0===this._objects.length},size:function(){return this._objects.length},contains:function(v,f){return this._objects.indexOf(v)>-1||!!f&&this._objects.some(function(m){return"function"==typeof m.contains&&m.contains(v,!0)})},complexity:function(){return this._objects.reduce(function(v,f){return v+(f.complexity?f.complexity():0)},0)}},b.CommonMethods={_setOptions:function(v){for(var f in v)this.set(f,v[f])},_initGradient:function(v,f){v&&v.colorStops&&!(v instanceof b.Gradient)&&this.set(f,new b.Gradient(v))},_initPattern:function(v,f,m){!v||!v.source||v instanceof b.Pattern?m&&m():this.set(f,new b.Pattern(v,m))},_setObject:function(v){for(var f in v)this._set(f,v[f])},set:function(v,f){return"object"==typeof v?this._setObject(v):this._set(v,f),this},_set:function(v,f){this[v]=f},toggle:function(v){var f=this.get(v);return"boolean"==typeof f&&this.set(v,!f),this},get:function(v){return this[v]}},v=Ee,f=Math.sqrt,m=Math.atan2,d=Math.pow,a=Math.PI/180,u=Math.PI/2,b.util={cos:function(o){if(0===o)return 1;switch(o<0&&(o=-o),o/u){case 1:case 3:return 0;case 2:return-1}return Math.cos(o)},sin:function(o){if(0===o)return 0;var p=1;switch(o<0&&(p=-1),o/u){case 1:return p;case 2:return 0;case 3:return-p}return Math.sin(o)},removeFromArray:function(o,h){var p=o.indexOf(h);return-1!==p&&o.splice(p,1),o},getRandomInt:function(o,h){return Math.floor(Math.random()*(h-o+1))+o},degreesToRadians:function(o){return o*a},radiansToDegrees:function(o){return o/a},rotatePoint:function(o,h,p){var l=new b.Point(o.x-h.x,o.y-h.y),y=b.util.rotateVector(l,p);return new b.Point(y.x,y.y).addEquals(h)},rotateVector:function(o,h){var p=b.util.sin(h),l=b.util.cos(h);return{x:o.x*l-o.y*p,y:o.x*p+o.y*l}},createVector:function(o,h){return new b.Point(h.x-o.x,h.y-o.y)},calcAngleBetweenVectors:function(o,h){return Math.acos((o.x*h.x+o.y*h.y)/(Math.hypot(o.x,o.y)*Math.hypot(h.x,h.y)))},getHatVector:function(o){return new b.Point(o.x,o.y).multiply(1/Math.hypot(o.x,o.y))},getBisector:function(o,h,p){var l=b.util.createVector(o,h),y=b.util.createVector(o,p),C=b.util.calcAngleBetweenVectors(l,y),D=b.util.calcAngleBetweenVectors(b.util.rotateVector(l,C),y);return{vector:b.util.getHatVector(b.util.rotateVector(l,C*(0===D?1:-1)/2)),angle:C}},projectStrokeOnPoints:function(o,h,p){var l=[],y=h.strokeWidth/2,C=h.strokeUniform?new b.Point(1/h.scaleX,1/h.scaleY):new b.Point(1,1),D=function(E){var T=y/Math.hypot(E.x,E.y);return new b.Point(E.x*T*C.x,E.y*T*C.y)};return o.length<=1||o.forEach(function(E,T){var F,B,I=new b.Point(E.x,E.y);0===T?(B=o[T+1],F=p?D(b.util.createVector(B,I)).addEquals(I):o[o.length-1]):T===o.length-1?(F=o[T-1],B=p?D(b.util.createVector(F,I)).addEquals(I):o[0]):(F=o[T-1],B=o[T+1]);var ue,de,Y=b.util.getBisector(I,F,B),ie=Y.vector;if("miter"===h.strokeLineJoin&&(ue=-y/Math.sin(Y.angle/2),de=new b.Point(ie.x*ue*C.x,ie.y*ue*C.y),Math.hypot(de.x,de.y)/y<=h.strokeMiterLimit))return l.push(I.add(de)),void l.push(I.subtract(de));ue=-y*Math.SQRT2,de=new b.Point(ie.x*ue*C.x,ie.y*ue*C.y),l.push(I.add(de)),l.push(I.subtract(de))}),l},transformPoint:function(o,h,p){return p?new b.Point(h[0]*o.x+h[2]*o.y,h[1]*o.x+h[3]*o.y):new b.Point(h[0]*o.x+h[2]*o.y+h[4],h[1]*o.x+h[3]*o.y+h[5])},makeBoundingBoxFromPoints:function(o,h){if(h)for(var p=0;p<o.length;p++)o[p]=b.util.transformPoint(o[p],h);var l=[o[0].x,o[1].x,o[2].x,o[3].x],y=b.util.array.min(l),D=b.util.array.max(l)-y,E=[o[0].y,o[1].y,o[2].y,o[3].y],T=b.util.array.min(E);return{left:y,top:T,width:D,height:b.util.array.max(E)-T}},invertTransform:function(o){var h=1/(o[0]*o[3]-o[1]*o[2]),p=[h*o[3],-h*o[1],-h*o[2],h*o[0]],l=b.util.transformPoint({x:o[4],y:o[5]},p,!0);return p[4]=-l.x,p[5]=-l.y,p},toFixed:function(o,h){return parseFloat(Number(o).toFixed(h))},parseUnit:function(o,h){var p=/\D{0,2}$/.exec(o),l=parseFloat(o);switch(h||(h=b.Text.DEFAULT_SVG_FONT_SIZE),p[0]){case"mm":return l*b.DPI/25.4;case"cm":return l*b.DPI/2.54;case"in":return l*b.DPI;case"pt":return l*b.DPI/72;case"pc":return l*b.DPI/72*12;case"em":return l*h;default:return l}},falseFunction:function(){return!1},getKlass:function(o,h){return o=b.util.string.camelize(o.charAt(0).toUpperCase()+o.slice(1)),b.util.resolveNamespace(h)[o]},getSvgAttributes:function(o){var h=["instantiated_by_use","style","id","class"];switch(o){case"linearGradient":h=h.concat(["x1","y1","x2","y2","gradientUnits","gradientTransform"]);break;case"radialGradient":h=h.concat(["gradientUnits","gradientTransform","cx","cy","r","fx","fy","fr"]);break;case"stop":h=h.concat(["offset","stop-color","stop-opacity"])}return h},resolveNamespace:function(o){if(!o)return b;var l,h=o.split("."),p=h.length,y=v||b.window;for(l=0;l<p;++l)y=y[h[l]];return y},loadImage:function(o,h,p,l){if(o){var y=b.util.createImage(),C=function(){h&&h.call(p,y,!1),y=y.onload=y.onerror=null};y.onload=C,y.onerror=function(){b.log("Error loading "+y.src),h&&h.call(p,null,!0),y=y.onload=y.onerror=null},0!==o.indexOf("data")&&null!=l&&(y.crossOrigin=l),"data:image/svg"===o.substring(0,14)&&(y.onload=null,b.util.loadImageInDom(y,C)),y.src=o}else h&&h.call(p,o)},loadImageInDom:function(o,h){var p=b.document.createElement("div");p.style.width=p.style.height="1px",p.style.left=p.style.top="-100%",p.style.position="absolute",p.appendChild(o),b.document.querySelector("body").appendChild(p),o.onload=function(){h(),p.parentNode.removeChild(p),p=null}},enlivenObjects:function(o,h,p,l){var y=[],C=0,D=(o=o||[]).length;function E(){++C===D&&h&&h(y.filter(function(T){return T}))}D?o.forEach(function(T,I){T&&T.type?b.util.getKlass(T.type,p).fromObject(T,function(B,Y){Y||(y[I]=B),l&&l(T,B,Y),E()}):E()}):h&&h(y)},enlivenObjectEnlivables:function(o,h,p){var l=b.Object.ENLIVEN_PROPS.filter(function(y){return!!o[y]});b.util.enlivenObjects(l.map(function(y){return o[y]}),function(y){var C={};l.forEach(function(D,E){C[D]=y[E],h&&(h[D]=y[E])}),p&&p(C)})},enlivenPatterns:function(o,h){function p(){++y===C&&h&&h(l)}var l=[],y=0,C=(o=o||[]).length;C?o.forEach(function(D,E){D&&D.source?new b.Pattern(D,function(T){l[E]=T,p()}):(l[E]=D,p())}):h&&h(l)},groupSVGElements:function(o,h,p){var l;return o&&1===o.length?o[0]:(h&&(h.width&&h.height?h.centerPoint={x:h.width/2,y:h.height/2}:(delete h.width,delete h.height)),l=new b.Group(o,h),void 0!==p&&(l.sourcePath=p),l)},populateWithProperties:function(o,h,p){if(p&&"[object Array]"===Object.prototype.toString.call(p))for(var l=0,y=p.length;l<y;l++)p[l]in o&&(h[p[l]]=o[p[l]])},createCanvasElement:function(){return b.document.createElement("canvas")},copyCanvasElement:function(o){var h=b.util.createCanvasElement();return h.width=o.width,h.height=o.height,h.getContext("2d").drawImage(o,0,0),h},toDataURL:function(o,h,p){return o.toDataURL("image/"+h,p)},createImage:function(){return b.document.createElement("img")},multiplyTransformMatrices:function(o,h,p){return[o[0]*h[0]+o[2]*h[1],o[1]*h[0]+o[3]*h[1],o[0]*h[2]+o[2]*h[3],o[1]*h[2]+o[3]*h[3],p?0:o[0]*h[4]+o[2]*h[5]+o[4],p?0:o[1]*h[4]+o[3]*h[5]+o[5]]},qrDecompose:function(o){var h=m(o[1],o[0]),p=d(o[0],2)+d(o[1],2),l=f(p),y=(o[0]*o[3]-o[2]*o[1])/l,C=m(o[0]*o[2]+o[1]*o[3],p);return{angle:h/a,scaleX:l,scaleY:y,skewX:C/a,skewY:0,translateX:o[4],translateY:o[5]}},calcRotateMatrix:function(o){if(!o.angle)return b.iMatrix.concat();var h=b.util.degreesToRadians(o.angle),p=b.util.cos(h),l=b.util.sin(h);return[p,l,-l,p,0,0]},calcDimensionsMatrix:function(o){var h=void 0===o.scaleX?1:o.scaleX,p=void 0===o.scaleY?1:o.scaleY,l=[o.flipX?-h:h,0,0,o.flipY?-p:p,0,0],y=b.util.multiplyTransformMatrices,C=b.util.degreesToRadians;return o.skewX&&(l=y(l,[1,0,Math.tan(C(o.skewX)),1],!0)),o.skewY&&(l=y(l,[1,Math.tan(C(o.skewY)),0,1],!0)),l},composeMatrix:function(o){var h=[1,0,0,1,o.translateX||0,o.translateY||0],p=b.util.multiplyTransformMatrices;return o.angle&&(h=p(h,b.util.calcRotateMatrix(o))),(1!==o.scaleX||1!==o.scaleY||o.skewX||o.skewY||o.flipX||o.flipY)&&(h=p(h,b.util.calcDimensionsMatrix(o))),h},resetObjectTransform:function(o){o.scaleX=1,o.scaleY=1,o.skewX=0,o.skewY=0,o.flipX=!1,o.flipY=!1,o.rotate(0)},saveObjectTransform:function(o){return{scaleX:o.scaleX,scaleY:o.scaleY,skewX:o.skewX,skewY:o.skewY,angle:o.angle,left:o.left,flipX:o.flipX,flipY:o.flipY,top:o.top}},isTransparent:function(o,h,p,l){l>0&&(h>l?h-=l:h=0,p>l?p-=l:p=0);var C,y=!0,E=o.getImageData(h,p,2*l||1,2*l||1),T=E.data.length;for(C=3;C<T&&0!=(y=E.data[C]<=0);C+=4);return E=null,y},parsePreserveAspectRatioAttribute:function(o){var C,h="meet",y=o.split(" ");return y&&y.length&&("meet"!==(h=y.pop())&&"slice"!==h?(C=h,h="meet"):y.length&&(C=y.pop())),{meetOrSlice:h,alignX:"none"!==C?C.slice(1,4):"none",alignY:"none"!==C?C.slice(5,8):"none"}},clearFabricFontCache:function(o){(o=(o||"").toLowerCase())?b.charWidthsCache[o]&&delete b.charWidthsCache[o]:b.charWidthsCache={}},limitDimsByArea:function(o,h){var p=Math.sqrt(h*o),l=Math.floor(h/p);return{x:Math.floor(p),y:l}},capValue:function(o,h,p){return Math.max(o,Math.min(h,p))},findScaleToFit:function(o,h){return Math.min(h.width/o.width,h.height/o.height)},findScaleToCover:function(o,h){return Math.max(h.width/o.width,h.height/o.height)},matrixToSVG:function(o){return"matrix("+o.map(function(h){return b.util.toFixed(h,b.Object.NUM_FRACTION_DIGITS)}).join(" ")+")"},removeTransformFromObject:function(o,h){var p=b.util.invertTransform(h),l=b.util.multiplyTransformMatrices(p,o.calcOwnMatrix());b.util.applyTransformToObject(o,l)},addTransformToObject:function(o,h){b.util.applyTransformToObject(o,b.util.multiplyTransformMatrices(h,o.calcOwnMatrix()))},applyTransformToObject:function(o,h){var p=b.util.qrDecompose(h),l=new b.Point(p.translateX,p.translateY);o.flipX=!1,o.flipY=!1,o.set("scaleX",p.scaleX),o.set("scaleY",p.scaleY),o.skewX=p.skewX,o.skewY=p.skewY,o.angle=p.angle,o.setPositionByOrigin(l,"center","center")},sizeAfterTransform:function(o,h,p){var l=o/2,y=h/2,C=[{x:-l,y:-y},{x:l,y:-y},{x:-l,y},{x:l,y}],D=b.util.calcDimensionsMatrix(p),E=b.util.makeBoundingBoxFromPoints(C,D);return{x:E.width,y:E.height}},mergeClipPaths:function(o,h){var p=o,l=h;p.inverted&&!l.inverted&&(p=h,l=o),b.util.applyTransformToObject(l,b.util.multiplyTransformMatrices(b.util.invertTransform(p.calcTransformMatrix()),l.calcTransformMatrix()));var y=p.inverted&&l.inverted;return y&&(p.inverted=l.inverted=!1),new b.Group([p],{clipPath:l,inverted:y})}},function(){var v=Array.prototype.join,f={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},m={m:"l",M:"L"};function d(O,N,k,L,$,R,A,V,W,K,z){var te=b.util.cos(O),oe=b.util.sin(O),ce=b.util.cos(N),X=b.util.sin(N),U=k*$*ce-L*R*X+A,Z=L*$*ce+k*R*X+V;return["C",K+W*(-k*$*oe-L*R*te),z+W*(-L*$*oe+k*R*te),U+W*(k*$*X+L*R*ce),Z+W*(L*$*X-k*R*ce),U,Z]}function u(O,N,k,L){var $=Math.atan2(N,O),R=Math.atan2(L,k);return R>=$?R-$:2*Math.PI-($-R)}function h(O,N,k){for(var z=function(O,N,k,L,$,R,A){var V=Math.PI,W=A*V/180,K=b.util.sin(W),z=b.util.cos(W),te=0,oe=0,ce=-z*O*.5-K*N*.5,X=-z*N*.5+K*O*.5,U=(k=Math.abs(k))*k,Z=(L=Math.abs(L))*L,ee=X*X,q=ce*ce,ne=U*Z-U*ee-Z*q,fe=0;if(ne<0){var Ie=Math.sqrt(1-ne/(U*Z));k*=Ie,L*=Ie}else fe=($===R?-1:1)*Math.sqrt(ne/(U*ee+Z*q));var ve=fe*k*X/L,J=-fe*L*ce/k,Ce=z*ve-K*J+.5*O,Fe=K*ve+z*J+.5*N,Ue=u(1,0,(ce-ve)/k,(X-J)/L),Ze=u((ce-ve)/k,(X-J)/L,(-ce-ve)/k,(-X-J)/L);0===R&&Ze>0?Ze-=2*V:1===R&&Ze<0&&(Ze+=2*V);for(var Ye=Math.ceil(Math.abs(Ze/V*2)),wt=[],at=Ze/Ye,Xn=8/3*Math.sin(at/4)*Math.sin(at/4)/Math.sin(at/2),Si=Ue+at,en=0;en<Ye;en++)wt[en]=d(Ue,Si,z,K,k,L,Ce,Fe,Xn,te,oe),te=wt[en][5],oe=wt[en][6],Ue=Si,Si+=at;return wt}(k[6]-O,k[7]-N,k[1],k[2],k[4],k[5],k[3]),te=0,oe=z.length;te<oe;te++)z[te][1]+=O,z[te][2]+=N,z[te][3]+=O,z[te][4]+=N,z[te][5]+=O,z[te][6]+=N;return z}function l(O,N,k,L){return Math.sqrt((k-O)*(k-O)+(L-N)*(L-N))}function T(O,N,k,L,$,R,A,V){return function(W){var K=function(O){return O*O*O}(W),z=function(O){return 3*O*O*(1-O)}(W),te=function(O){return 3*O*(1-O)*(1-O)}(W),oe=function(O){return(1-O)*(1-O)*(1-O)}(W);return{x:A*K+$*z+k*te+O*oe,y:V*K+R*z+L*te+N*oe}}}function I(O,N,k,L,$,R,A,V){return function(W){var K=1-W;return Math.atan2(3*K*K*(L-N)+6*K*W*(R-L)+3*W*W*(V-R),3*K*K*(k-O)+6*K*W*($-k)+3*W*W*(A-$))}}function ie(O,N,k,L,$,R){return function(A){var V=function(O){return O*O}(A),W=function(O){return 2*O*(1-O)}(A),K=function(O){return(1-O)*(1-O)}(A);return{x:$*V+k*W+O*K,y:R*V+L*W+N*K}}}function le(O,N,k,L,$,R){return function(A){var V=1-A;return Math.atan2(2*V*(L-N)+2*A*(R-L),2*V*(k-O)+2*A*($-k))}}function ue(O,N,k){var $,A,L={x:N,y:k},R=0;for(A=1;A<=100;A+=1)$=O(A/100),R+=l(L.x,L.y,$.x,$.y),L=$;return R}function he(O){for(var L,K,z,te,N=0,k=O.length,$=0,R=0,A=0,V=0,W=[],oe=0;oe<k;oe++){switch(z={x:$,y:R,command:(L=O[oe])[0]},L[0]){case"M":z.length=0,A=$=L[1],V=R=L[2];break;case"L":z.length=l($,R,L[1],L[2]),$=L[1],R=L[2];break;case"C":K=T($,R,L[1],L[2],L[3],L[4],L[5],L[6]),te=I($,R,L[1],L[2],L[3],L[4],L[5],L[6]),z.iterator=K,z.angleFinder=te,z.length=ue(K,$,R),$=L[5],R=L[6];break;case"Q":K=ie($,R,L[1],L[2],L[3],L[4]),te=le($,R,L[1],L[2],L[3],L[4]),z.iterator=K,z.angleFinder=te,z.length=ue(K,$,R),$=L[3],R=L[4];break;case"Z":case"z":z.destX=A,z.destY=V,z.length=l($,R,A,V),$=A,R=V}N+=z.length,W.push(z)}return W.push({length:N,x:$,y:R}),W}b.util.joinPath=function(O){return O.map(function(N){return N.join(" ")}).join(" ")},b.util.parsePath=function(O){var L,$,te,oe,ce,N=[],k=[],R=b.rePathCommand,A="[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?\\s*",V="("+A+")"+b.commaWsp,W="([01])"+b.commaWsp+"?",z=new RegExp(V+"?"+V+"?"+V+W+W+V+"?("+A+")","g");if(!O||!O.match)return N;for(var U,X=0,Z=(ce=O.match(/[mzlhvcsqta][^mzlhvcsqta]*/gi)).length;X<Z;X++){oe=(L=ce[X]).slice(1).trim(),k.length=0;var ee=L.charAt(0);if(U=[ee],"a"===ee.toLowerCase())for(var q;q=z.exec(oe);)for(var ne=1;ne<q.length;ne++)k.push(q[ne]);else for(;te=R.exec(oe);)k.push(te[0]);ne=0;for(var fe=k.length;ne<fe;ne++)$=parseFloat(k[ne]),isNaN($)||U.push($);var Ie=f[ee.toLowerCase()],ve=m[ee]||ee;if(U.length-1>Ie)for(var J=1,Ce=U.length;J<Ce;J+=Ie)N.push([ee].concat(U.slice(J,J+Ie))),ee=ve;else N.push(U)}return N},b.util.makePathSimpler=function(O){var A,V,W,z,te,oe,N=0,k=0,L=O.length,$=0,R=0,K=[];for(V=0;V<L;++V){switch(W=!1,(A=O[V].slice(0))[0]){case"l":A[0]="L",A[1]+=N,A[2]+=k;case"L":N=A[1],k=A[2];break;case"h":A[1]+=N;case"H":A[0]="L",A[2]=k,N=A[1];break;case"v":A[1]+=k;case"V":A[0]="L",k=A[1],A[1]=N,A[2]=k;break;case"m":A[0]="M",A[1]+=N,A[2]+=k;case"M":N=A[1],k=A[2],$=A[1],R=A[2];break;case"c":A[0]="C",A[1]+=N,A[2]+=k,A[3]+=N,A[4]+=k,A[5]+=N,A[6]+=k;case"C":te=A[3],oe=A[4],N=A[5],k=A[6];break;case"s":A[0]="S",A[1]+=N,A[2]+=k,A[3]+=N,A[4]+=k;case"S":"C"===z?(te=2*N-te,oe=2*k-oe):(te=N,oe=k),N=A[3],k=A[4],A[0]="C",A[5]=A[3],A[6]=A[4],A[3]=A[1],A[4]=A[2],A[1]=te,A[2]=oe,te=A[3],oe=A[4];break;case"q":A[0]="Q",A[1]+=N,A[2]+=k,A[3]+=N,A[4]+=k;case"Q":te=A[1],oe=A[2],N=A[3],k=A[4];break;case"t":A[0]="T",A[1]+=N,A[2]+=k;case"T":"Q"===z?(te=2*N-te,oe=2*k-oe):(te=N,oe=k),A[0]="Q",N=A[1],k=A[2],A[1]=te,A[2]=oe,A[3]=N,A[4]=k;break;case"a":A[0]="A",A[6]+=N,A[7]+=k;case"A":W=!0,K=K.concat(h(N,k,A)),N=A[6],k=A[7];break;case"z":case"Z":N=$,k=R}W||K.push(A),z=A[0]}return K},b.util.getSmoothPathFromPoints=function(O,N){var L,k=[],$=new b.Point(O[0].x,O[0].y),R=new b.Point(O[1].x,O[1].y),A=O.length,V=1,W=0,K=A>2;for(K&&(V=O[2].x<R.x?-1:O[2].x===R.x?0:1,W=O[2].y<R.y?-1:O[2].y===R.y?0:1),k.push(["M",$.x-V*(N=N||0),$.y-W*N]),L=1;L<A;L++){if(!$.eq(R)){var z=$.midPointFrom(R);k.push(["Q",$.x,$.y,z.x,z.y])}$=O[L],L+1<O.length&&(R=O[L+1])}return K&&(V=$.x>O[L-2].x?1:$.x===O[L-2].x?0:-1,W=$.y>O[L-2].y?1:$.y===O[L-2].y?0:-1),k.push(["L",$.x+V*N,$.y+W*N]),k},b.util.getPathSegmentsInfo=he,b.util.getBoundsOfCurve=function(O,N,k,L,$,R,A,V){var W;if(b.cachesBoundsOfCurve&&(W=v.call(arguments),b.boundsOfCurveCache[W]))return b.boundsOfCurveCache[W];var U,Z,ee,q,ne,fe,Ie,ve,K=Math.sqrt,z=Math.min,te=Math.max,oe=Math.abs,ce=[],X=[[],[]];Z=6*O-12*k+6*$,U=-3*O+9*k-9*$+3*A,ee=3*k-3*O;for(var J=0;J<2;++J)if(J>0&&(Z=6*N-12*L+6*R,U=-3*N+9*L-9*R+3*V,ee=3*L-3*N),oe(U)<1e-12){if(oe(Z)<1e-12)continue;0<(q=-ee/Z)&&q<1&&ce.push(q)}else!((Ie=Z*Z-4*ee*U)<0)&&(0<(ne=(-Z+(ve=K(Ie)))/(2*U))&&ne<1&&ce.push(ne),0<(fe=(-Z-ve)/(2*U))&&fe<1&&ce.push(fe));for(var Ye,Ue=ce.length,Ze=Ue;Ue--;)X[0][Ue]=(Ye=1-(q=ce[Ue]))*Ye*Ye*O+3*Ye*Ye*q*k+3*Ye*q*q*$+q*q*q*A,X[1][Ue]=Ye*Ye*Ye*N+3*Ye*Ye*q*L+3*Ye*q*q*R+q*q*q*V;X[0][Ze]=O,X[1][Ze]=N,X[0][Ze+1]=A,X[1][Ze+1]=V;var wt=[{x:z.apply(null,X[0]),y:z.apply(null,X[1])},{x:te.apply(null,X[0]),y:te.apply(null,X[1])}];return b.cachesBoundsOfCurve&&(b.boundsOfCurveCache[W]=wt),wt},b.util.getPointOnPath=function(O,N,k){k||(k=he(O));for(var L=0;N-k[L].length>0&&L<k.length-2;)N-=k[L].length,L++;var W,$=k[L],R=N/$.length,V=O[L];switch($.command){case"M":return{x:$.x,y:$.y,angle:0};case"Z":case"z":return(W=new b.Point($.x,$.y).lerp(new b.Point($.destX,$.destY),R)).angle=Math.atan2($.destY-$.y,$.destX-$.x),W;case"L":return(W=new b.Point($.x,$.y).lerp(new b.Point(V[1],V[2]),R)).angle=Math.atan2(V[2]-$.y,V[1]-$.x),W;case"C":case"Q":return function(O,N){for(var A,V,z,k=0,L=0,$=O.iterator,R={x:O.x,y:O.y},W=.01,K=O.angleFinder;L<N&&W>1e-4;)A=$(k),z=k,(V=l(R.x,R.y,A.x,A.y))+L>N?(k-=W,W/=2):(R=A,k+=W,L+=V);return A.angle=K(z),A}($,N)}},b.util.transformPath=function(O,N,k){return k&&(N=b.util.multiplyTransformMatrices(N,[1,0,0,1,-k.x,-k.y])),O.map(function(L){for(var $=L.slice(0),R={},A=1;A<L.length-1;A+=2)R.x=L[A],R.y=L[A+1],R=b.util.transformPoint(R,N),$[A]=R.x,$[A+1]=R.y;return $})}}(),function(){var v=Array.prototype.slice;function u(o,h,p){if(o&&0!==o.length){var l=o.length-1,y=h?o[l][h]:o[l];if(h)for(;l--;)p(o[l][h],y)&&(y=o[l][h]);else for(;l--;)p(o[l],y)&&(y=o[l]);return y}}b.util.array={fill:function(o,h){for(var p=o.length;p--;)o[p]=h;return o},invoke:function(o,h){for(var p=v.call(arguments,2),l=[],y=0,C=o.length;y<C;y++)l[y]=p.length?o[y][h].apply(o[y],p):o[y][h].call(o[y]);return l},min:function(o,h){return u(o,h,function(p,l){return p<l})},max:function(o,h){return u(o,h,function(p,l){return p>=l})}}}(),function(){function v(m,d,a){if(a)if(!b.isLikelyNode&&d instanceof Element)m=d;else if(d instanceof Array){m=[];for(var u=0,o=d.length;u<o;u++)m[u]=v({},d[u],a)}else if(d&&"object"==typeof d)for(var h in d)"canvas"===h||"group"===h?m[h]=null:d.hasOwnProperty(h)&&(m[h]=v({},d[h],a));else m=d;else for(var h in d)m[h]=d[h];return m}b.util.object={extend:v,clone:function(m,d){return v({},m,d)}},b.util.object.extend(b.util,b.Observable)}(),function(){function a(u,o){var h=u.charCodeAt(o);if(isNaN(h))return"";if(h<55296||h>57343)return u.charAt(o);if(55296<=h&&h<=56319){if(u.length<=o+1)throw"High surrogate without following low surrogate";var p=u.charCodeAt(o+1);if(56320>p||p>57343)throw"High surrogate without following low surrogate";return u.charAt(o)+u.charAt(o+1)}if(0===o)throw"Low surrogate without preceding high surrogate";var l=u.charCodeAt(o-1);if(55296>l||l>56319)throw"Low surrogate without preceding high surrogate";return!1}b.util.string={camelize:function(u){return u.replace(/-+(.)?/g,function(o,h){return h?h.toUpperCase():""})},capitalize:function(u,o){return u.charAt(0).toUpperCase()+(o?u.slice(1):u.slice(1).toLowerCase())},escapeXml:function(u){return u.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")},graphemeSplit:function(u){var h,o=0,p=[];for(o=0;o<u.length;o++)!1!==(h=a(u,o))&&p.push(h);return p}}}(),function(){var v=Array.prototype.slice,f=function(){},m=function(){for(var h in{toString:1})if("toString"===h)return!1;return!0}(),d=function(h,p,l){for(var y in p)h.prototype[y]=y in h.prototype&&"function"==typeof h.prototype[y]&&(p[y]+"").indexOf("callSuper")>-1?function(C){return function(){var D=this.constructor.superclass;this.constructor.superclass=l;var E=p[C].apply(this,arguments);if(this.constructor.superclass=D,"initialize"!==C)return E}}(y):p[y],m&&(p.toString!==Object.prototype.toString&&(h.prototype.toString=p.toString),p.valueOf!==Object.prototype.valueOf&&(h.prototype.valueOf=p.valueOf))};function a(){}function u(h){for(var p=null,l=this;l.constructor.superclass;){var y=l.constructor.superclass.prototype[h];if(l[h]!==y){p=y;break}l=l.constructor.superclass.prototype}return p?arguments.length>1?p.apply(this,v.call(arguments,1)):p.call(this):console.log("tried to callSuper "+h+", method not found in prototype chain",this)}b.util.createClass=function(){var h=null,p=v.call(arguments,0);function l(){this.initialize.apply(this,arguments)}"function"==typeof p[0]&&(h=p.shift()),l.superclass=h,l.subclasses=[],h&&(a.prototype=h.prototype,l.prototype=new a,h.subclasses.push(l));for(var y=0,C=p.length;y<C;y++)d(l,p[y],h);return l.prototype.initialize||(l.prototype.initialize=f),l.prototype.constructor=l,l.prototype.callSuper=u,l}}(),function(){var v=!!b.document.createElement("div").attachEvent,f=["touchstart","touchmove","touchend"];b.util.addListener=function(d,a,u,o){d&&d.addEventListener(a,u,!v&&o)},b.util.removeListener=function(d,a,u,o){d&&d.removeEventListener(a,u,!v&&o)},b.util.getPointer=function(d){var u=b.util.getScrollLeftTop(d.target),o=function(d){var a=d.changedTouches;return a&&a[0]?a[0]:d}(d);return{x:o.clientX+u.left,y:o.clientY+u.top}},b.util.isTouchEvent=function(d){return f.indexOf(d.type)>-1||"touch"===d.pointerType}}(),function(){var f=b.document.createElement("div"),a=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,u=function(o){return o};"string"==typeof f.style.opacity?u=function(o,h){return o.style.opacity=h,o}:"string"==typeof f.style.filter&&(u=function(o,h){var p=o.style;return o.currentStyle&&!o.currentStyle.hasLayout&&(p.zoom=1),a.test(p.filter)?p.filter=p.filter.replace(a,h=h>=.9999?"":"alpha(opacity="+100*h+")"):p.filter+=" alpha(opacity="+100*h+")",o}),b.util.setStyle=function(o,h){var p=o.style;if(!p)return o;if("string"==typeof h)return o.style.cssText+=";"+h,h.indexOf("opacity")>-1?u(o,h.match(/opacity:\s*(\d?\.?\d*)/)[1]):o;for(var l in h)"opacity"===l?u(o,h[l]):p["float"===l||"cssFloat"===l?void 0===p.styleFloat?"cssFloat":"styleFloat":l]=h[l];return o}}(),function(){var m,l,E,T,v=Array.prototype.slice,d=function(E){return v.call(E,0)};try{m=d(b.document.childNodes)instanceof Array}catch(E){}function a(E,T){var I=b.document.createElement(E);for(var F in T)"class"===F?I.className=T[F]:"for"===F?I.htmlFor=T[F]:I.setAttribute(F,T[F]);return I}function h(E){for(var T=0,I=0,F=b.document.documentElement,B=b.document.body||{scrollLeft:0,scrollTop:0};E&&(E.parentNode||E.host)&&((E=E.parentNode||E.host)===b.document?(T=B.scrollLeft||F.scrollLeft||0,I=B.scrollTop||F.scrollTop||0):(T+=E.scrollLeft||0,I+=E.scrollTop||0),1!==E.nodeType||"fixed"!==E.style.position););return{left:T,top:I}}m||(d=function(E){for(var T=new Array(E.length),I=E.length;I--;)T[I]=E[I];return T}),l=b.document.defaultView&&b.document.defaultView.getComputedStyle?function(E,T){var I=b.document.defaultView.getComputedStyle(E,null);return I?I[T]:void 0}:function(E,T){var I=E.style[T];return!I&&E.currentStyle&&(I=E.currentStyle[T]),I},T="userSelect"in(E=b.document.documentElement.style)?"userSelect":"MozUserSelect"in E?"MozUserSelect":"WebkitUserSelect"in E?"WebkitUserSelect":"KhtmlUserSelect"in E?"KhtmlUserSelect":"",b.util.makeElementUnselectable=function(B){return void 0!==B.onselectstart&&(B.onselectstart=b.util.falseFunction),T?B.style[T]="none":"string"==typeof B.unselectable&&(B.unselectable="on"),B},b.util.makeElementSelectable=function(B){return void 0!==B.onselectstart&&(B.onselectstart=null),T?B.style[T]="":"string"==typeof B.unselectable&&(B.unselectable=""),B},b.util.setImageSmoothing=function(E,T){E.imageSmoothingEnabled=E.imageSmoothingEnabled||E.webkitImageSmoothingEnabled||E.mozImageSmoothingEnabled||E.msImageSmoothingEnabled||E.oImageSmoothingEnabled,E.imageSmoothingEnabled=T},b.util.getById=function(E){return"string"==typeof E?b.document.getElementById(E):E},b.util.toArray=d,b.util.addClass=function(E,T){E&&-1===(" "+E.className+" ").indexOf(" "+T+" ")&&(E.className+=(E.className?" ":"")+T)},b.util.makeElement=a,b.util.wrapElement=function(E,T,I){return"string"==typeof T&&(T=a(T,I)),E.parentNode&&E.parentNode.replaceChild(T,E),T.appendChild(E),T},b.util.getScrollLeftTop=h,b.util.getElementOffset=function(E){var T,Y,I=E&&E.ownerDocument,F={left:0,top:0},B={left:0,top:0},ie={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!I)return B;for(var le in ie)B[ie[le]]+=parseInt(l(E,le),10)||0;return T=I.documentElement,void 0!==E.getBoundingClientRect&&(F=E.getBoundingClientRect()),Y=h(E),{left:F.left+Y.left-(T.clientLeft||0)+B.left,top:F.top+Y.top-(T.clientTop||0)+B.top}},b.util.getNodeCanvas=function(E){var T=b.jsdomImplForWrapper(E);return T._canvas||T._image},b.util.cleanUpJsdomNode=function(E){if(b.isLikelyNode){var T=b.jsdomImplForWrapper(E);T&&(T._image=null,T._canvas=null,T._currentSrc=null,T._attributes=null,T._classList=null)}}}(),function(){function f(){}b.util.request=function(d,a){a||(a={});var u=a.method?a.method.toUpperCase():"GET",o=a.onComplete||function(){},h=new b.window.XMLHttpRequest,p=a.body||a.parameters;return h.onreadystatechange=function(){4===h.readyState&&(o(h),h.onreadystatechange=f)},"GET"===u&&(p=null,"string"==typeof a.parameters&&(d=function(d,a){return d+(/\?/.test(d)?"&":"?")+a}(d,a.parameters))),h.open(u,d,!0),("POST"===u||"PUT"===u)&&h.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),h.send(p),h}}(),b.log=console.log,b.warn=console.warn,function(){var v=b.util.object.extend,f=b.util.object.clone,m=[];function d(){return!1}function a(y,C,D,E){return-D*Math.cos(y/E*(Math.PI/2))+D+C}b.util.object.extend(m,{cancelAll:function(){var y=this.splice(0);return y.forEach(function(C){C.cancel()}),y},cancelByCanvas:function(y){if(!y)return[];var C=this.filter(function(D){return"object"==typeof D.target&&D.target.canvas===y});return C.forEach(function(D){D.cancel()}),C},cancelByTarget:function(y){var C=this.findAnimationsByTarget(y);return C.forEach(function(D){D.cancel()}),C},findAnimationIndex:function(y){return this.indexOf(this.findAnimation(y))},findAnimation:function(y){return this.find(function(C){return C.cancel===y})},findAnimationsByTarget:function(y){return y?this.filter(function(C){return C.target===y}):[]}});var o=b.window.requestAnimationFrame||b.window.webkitRequestAnimationFrame||b.window.mozRequestAnimationFrame||b.window.oRequestAnimationFrame||b.window.msRequestAnimationFrame||function(y){return b.window.setTimeout(y,1e3/60)},h=b.window.cancelAnimationFrame||b.window.clearTimeout;function p(){return o.apply(b.window,arguments)}b.util.animate=function(y){y||(y={});var D,C=!1,E=function(){var T=b.runningAnimations.indexOf(D);return T>-1&&b.runningAnimations.splice(T,1)[0]};return D=v(f(y),{cancel:function(){return C=!0,E()},currentValue:"startValue"in y?y.startValue:0,completionRate:0,durationRate:0}),b.runningAnimations.push(D),p(function(T){var Y,I=T||+new Date,F=y.duration||500,B=I+F,ie=y.onChange||d,le=y.abort||d,ue=y.onComplete||d,de=y.easing||a,he="startValue"in y?y.startValue:0,ae="endValue"in y?y.endValue:100,_e=y.byValue||ae-he;y.onStart&&y.onStart(),function be(me){var O=(Y=me||+new Date)>B?F:Y-I,N=O/F,k=de(O,he,_e,F),L=Math.abs((k-he)/_e);if(D.currentValue=k,D.completionRate=L,D.durationRate=N,!C){if(le(k,L,N))return void E();if(Y>B)return D.currentValue=ae,D.completionRate=1,D.durationRate=1,ie(ae,1,1),ue(ae,1,1),void E();ie(k,L,N),p(be)}}(I)}),D.cancel},b.util.requestAnimFrame=p,b.util.cancelAnimFrame=function(){return h.apply(b.window,arguments)},b.runningAnimations=m}(),function(){function v(m,d,a){var u="rgba("+parseInt(m[0]+a*(d[0]-m[0]),10)+","+parseInt(m[1]+a*(d[1]-m[1]),10)+","+parseInt(m[2]+a*(d[2]-m[2]),10);return(u+=","+(m&&d?parseFloat(m[3]+a*(d[3]-m[3])):1))+")"}b.util.animateColor=function(m,d,a,u){var o=new b.Color(m).getSource(),h=new b.Color(d).getSource(),p=u.onComplete,l=u.onChange;return b.util.animate(b.util.object.extend(u=u||{},{duration:a||500,startValue:o,endValue:h,byValue:h,easing:function(y,C,D,E){return v(C,D,u.colorEasing?u.colorEasing(y,E):1-Math.cos(y/E*(Math.PI/2)))},onComplete:function(y,C,D){if(p)return p(v(h,h,0),C,D)},onChange:function(y,C,D){if(l){if(Array.isArray(y))return l(v(y,y,0),C,D);l(y,C,D)}}}))}}(),function(){function v(O,N,k,L){return O<Math.abs(N)?(O=N,L=k/4):L=0===N&&0===O?k/(2*Math.PI)*Math.asin(1):k/(2*Math.PI)*Math.asin(N/O),{a:O,c:N,p:k,s:L}}function f(O,N,k){return O.a*Math.pow(2,10*(N-=1))*Math.sin((N*k-O.s)*(2*Math.PI)/O.p)}function _e(O,N,k,L){return k-be(L-O,0,k,L)+N}function be(O,N,k,L){return(O/=L)<1/2.75?k*(7.5625*O*O)+N:O<2/2.75?k*(7.5625*(O-=1.5/2.75)*O+.75)+N:O<2.5/2.75?k*(7.5625*(O-=2.25/2.75)*O+.9375)+N:k*(7.5625*(O-=2.625/2.75)*O+.984375)+N}b.util.ease={easeInQuad:function(O,N,k,L){return k*(O/=L)*O+N},easeOutQuad:function(O,N,k,L){return-k*(O/=L)*(O-2)+N},easeInOutQuad:function(O,N,k,L){return(O/=L/2)<1?k/2*O*O+N:-k/2*(--O*(O-2)-1)+N},easeInCubic:function(O,N,k,L){return k*(O/=L)*O*O+N},easeOutCubic:function(O,N,k,L){return k*((O=O/L-1)*O*O+1)+N},easeInOutCubic:function(O,N,k,L){return(O/=L/2)<1?k/2*O*O*O+N:k/2*((O-=2)*O*O+2)+N},easeInQuart:function(O,N,k,L){return k*(O/=L)*O*O*O+N},easeOutQuart:function(O,N,k,L){return-k*((O=O/L-1)*O*O*O-1)+N},easeInOutQuart:function(O,N,k,L){return(O/=L/2)<1?k/2*O*O*O*O+N:-k/2*((O-=2)*O*O*O-2)+N},easeInQuint:function(O,N,k,L){return k*(O/=L)*O*O*O*O+N},easeOutQuint:function(O,N,k,L){return k*((O=O/L-1)*O*O*O*O+1)+N},easeInOutQuint:function(O,N,k,L){return(O/=L/2)<1?k/2*O*O*O*O*O+N:k/2*((O-=2)*O*O*O*O+2)+N},easeInSine:function(O,N,k,L){return-k*Math.cos(O/L*(Math.PI/2))+k+N},easeOutSine:function(O,N,k,L){return k*Math.sin(O/L*(Math.PI/2))+N},easeInOutSine:function(O,N,k,L){return-k/2*(Math.cos(Math.PI*O/L)-1)+N},easeInExpo:function(O,N,k,L){return 0===O?N:k*Math.pow(2,10*(O/L-1))+N},easeOutExpo:function(O,N,k,L){return O===L?N+k:k*(1-Math.pow(2,-10*O/L))+N},easeInOutExpo:function(O,N,k,L){return 0===O?N:O===L?N+k:(O/=L/2)<1?k/2*Math.pow(2,10*(O-1))+N:k/2*(2-Math.pow(2,-10*--O))+N},easeInCirc:function(O,N,k,L){return-k*(Math.sqrt(1-(O/=L)*O)-1)+N},easeOutCirc:function(O,N,k,L){return k*Math.sqrt(1-(O=O/L-1)*O)+N},easeInOutCirc:function(O,N,k,L){return(O/=L/2)<1?-k/2*(Math.sqrt(1-O*O)-1)+N:k/2*(Math.sqrt(1-(O-=2)*O)+1)+N},easeInElastic:function(O,N,k,L){var R=0;return 0===O?N:1==(O/=L)?N+k:(R||(R=.3*L),-f(v(k,k,R,1.70158),O,L)+N)},easeOutElastic:function(O,N,k,L){var R=0;if(0===O)return N;if(1==(O/=L))return N+k;R||(R=.3*L);var V=v(k,k,R,1.70158);return V.a*Math.pow(2,-10*O)*Math.sin((O*L-V.s)*(2*Math.PI)/V.p)+V.c+N},easeInOutElastic:function(O,N,k,L){var R=0;if(0===O)return N;if(2==(O/=L/2))return N+k;R||(R=L*(.3*1.5));var V=v(k,k,R,1.70158);return O<1?-.5*f(V,O,L)+N:V.a*Math.pow(2,-10*(O-=1))*Math.sin((O*L-V.s)*(2*Math.PI)/V.p)*.5+V.c+N},easeInBack:function(O,N,k,L,$){return void 0===$&&($=1.70158),k*(O/=L)*O*(($+1)*O-$)+N},easeOutBack:function(O,N,k,L,$){return void 0===$&&($=1.70158),k*((O=O/L-1)*O*(($+1)*O+$)+1)+N},easeInOutBack:function(O,N,k,L,$){return void 0===$&&($=1.70158),(O/=L/2)<1?k/2*(O*O*((1+($*=1.525))*O-$))+N:k/2*((O-=2)*O*((1+($*=1.525))*O+$)+2)+N},easeInBounce:_e,easeOutBounce:be,easeInOutBounce:function(O,N,k,L){return O<L/2?.5*_e(2*O,0,k,L)+N:.5*be(2*O-L,0,k,L)+.5*k+N}}}(),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.util.object.extend,d=f.util.object.clone,a=f.util.toFixed,u=f.util.parseUnit,o=f.util.multiplyTransformMatrices,C={cx:"left",x:"left",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"},D={stroke:"strokeOpacity",fill:"fillOpacity"},E="font-size",T="clip-path";function I(R){return R in C?C[R]:R}function F(R,A,V,W){var z,K="[object Array]"===Object.prototype.toString.call(A);if("fill"!==R&&"stroke"!==R||"none"!==A){if("strokeUniform"===R)return"non-scaling-stroke"===A;if("strokeDashArray"===R)A="none"===A?null:A.replace(/,/g," ").split(/\s+/).map(parseFloat);else if("transformMatrix"===R)A=V&&V.transformMatrix?o(V.transformMatrix,f.parseTransformAttribute(A)):f.parseTransformAttribute(A);else if("visible"===R)A="none"!==A&&"hidden"!==A,V&&!1===V.visible&&(A=!1);else if("opacity"===R)A=parseFloat(A),V&&void 0!==V.opacity&&(A*=V.opacity);else if("textAnchor"===R)A="start"===A?"left":"end"===A?"right":"center";else if("charSpacing"===R)z=u(A,W)/W*1e3;else if("paintFirst"===R){var te=A.indexOf("fill"),oe=A.indexOf("stroke");A="fill",(te>-1&&oe>-1&&oe<te||-1===te&&oe>-1)&&(A="stroke")}else{if("href"===R||"xlink:href"===R||"font"===R)return A;if("imageSmoothing"===R)return"optimizeQuality"===A;z=K?A.map(u):u(A,W)}}else A="";return!K&&isNaN(z)?A:z}function B(R){return new RegExp("^("+R.join("|")+")\\b","i")}function ie(R,A){var K,z,te,W=[];for(z=0,te=A.length;z<te;z++)K=R.getElementsByTagName(A[z]),W=W.concat(Array.prototype.slice.call(K));return W}function he(R,A){var V,W=!0;return(V=_e(R,A.pop()))&&A.length&&(W=function(R,A){for(var V,W=!0;R.parentNode&&1===R.parentNode.nodeType&&A.length;)W&&(V=A.pop()),W=_e(R=R.parentNode,V);return 0===A.length}(R,A)),V&&W&&0===A.length}function _e(R,A){var z,te,V=R.nodeName,W=R.getAttribute("class"),K=R.getAttribute("id");if(z=new RegExp("^"+V,"i"),A=A.replace(z,""),K&&A.length&&(z=new RegExp("#"+K+"(?![a-zA-Z\\-]+)","i"),A=A.replace(z,"")),W&&A.length)for(te=(W=W.split(" ")).length;te--;)z=new RegExp("\\."+W[te]+"(?![a-zA-Z\\-]+)","i"),A=A.replace(z,"");return 0===A.length}function be(R,A){var V;if(R.getElementById&&(V=R.getElementById(A)),V)return V;var W,K,z,te=R.getElementsByTagName("*");for(K=0,z=te.length;K<z;K++)if(A===(W=te[K]).getAttribute("id"))return W}f.svgValidTagNamesRegEx=B(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),f.svgViewBoxElementsRegEx=B(["symbol","image","marker","pattern","view","svg"]),f.svgInvalidAncestorsRegEx=B(["pattern","defs","symbol","metadata","clipPath","mask","desc"]),f.svgValidParentsRegEx=B(["symbol","g","a","svg","clipPath","defs"]),f.cssRules={},f.gradientDefs={},f.clipPaths={},f.parseTransformAttribute=function(){function V(J,Ce,Fe){J[Fe]=Math.tan(f.util.degreesToRadians(Ce[0]))}var K=f.iMatrix,z=f.reNum,te=f.commaWsp,q="(?:(?:(matrix)\\s*\\(\\s*("+z+")"+te+"("+z+")"+te+"("+z+")"+te+"("+z+")"+te+"("+z+")"+te+"("+z+")\\s*\\))|(?:(translate)\\s*\\(\\s*("+z+")(?:"+te+"("+z+"))?\\s*\\))|(?:(scale)\\s*\\(\\s*("+z+")(?:"+te+"("+z+"))?\\s*\\))|(?:(rotate)\\s*\\(\\s*("+z+")(?:"+te+"("+z+")"+te+"("+z+"))?\\s*\\))|(?:(skewX)\\s*\\(\\s*("+z+")\\s*\\))|(?:(skewY)\\s*\\(\\s*("+z+")\\s*\\)))",Ie=new RegExp("^\\s*(?:(?:"+q+"(?:"+te+"*"+q+")*)?)\\s*$"),ve=new RegExp(q,"g");return function(J){var Ce=K.concat(),Fe=[];if(!J||J&&!Ie.test(J))return Ce;J.replace(ve,function(Ze){var Ye=new RegExp(q).exec(Ze).filter(function(Xn){return!!Xn}),wt=Ye[1],at=Ye.slice(2).map(parseFloat);switch(wt){case"translate":!function(J,Ce){J[4]=Ce[0],2===Ce.length&&(J[5]=Ce[1])}(Ce,at);break;case"rotate":at[0]=f.util.degreesToRadians(at[0]),function(J,Ce){var Fe=f.util.cos(Ce[0]),Ue=f.util.sin(Ce[0]),Ze=0,Ye=0;3===Ce.length&&(Ze=Ce[1],Ye=Ce[2]),J[0]=Fe,J[1]=Ue,J[2]=-Ue,J[3]=Fe,J[4]=Ze-(Fe*Ze-Ue*Ye),J[5]=Ye-(Ue*Ze+Fe*Ye)}(Ce,at);break;case"scale":!function(J,Ce){var Ue=2===Ce.length?Ce[1]:Ce[0];J[0]=Ce[0],J[3]=Ue}(Ce,at);break;case"skewX":V(Ce,at,2);break;case"skewY":V(Ce,at,1);break;case"matrix":Ce=at}Fe.push(Ce.concat()),Ce=K.concat()});for(var Ue=Fe[0];Fe.length>1;)Fe.shift(),Ue=f.util.multiplyTransformMatrices(Ue,Fe[0]);return Ue}}();var O=new RegExp("^\\s*("+f.reNum+"+)\\s*,?\\s*("+f.reNum+"+)\\s*,?\\s*("+f.reNum+"+)\\s*,?\\s*("+f.reNum+"+)\\s*$");function N(R){if(!f.svgViewBoxElementsRegEx.test(R.nodeName))return{};var K,z,te,oe,ce,X,A=R.getAttribute("viewBox"),V=1,W=1,U=R.getAttribute("width"),Z=R.getAttribute("height"),ee=R.getAttribute("x")||0,q=R.getAttribute("y")||0,ne=R.getAttribute("preserveAspectRatio")||"",fe=!A||!(A=A.match(O)),Ie=!U||!Z||"100%"===U||"100%"===Z,ve=fe&&Ie,J={},Ce="",Fe=0,Ue=0;if(J.width=0,J.height=0,J.toBeParsed=ve,fe&&(ee||q)&&R.parentNode&&"#document"!==R.parentNode.nodeName&&(Ce=" translate("+u(ee)+" "+u(q)+") ",ce=(R.getAttribute("transform")||"")+Ce,R.setAttribute("transform",ce),R.removeAttribute("x"),R.removeAttribute("y")),ve)return J;if(fe)return J.width=u(U),J.height=u(Z),J;if(K=-parseFloat(A[1]),z=-parseFloat(A[2]),te=parseFloat(A[3]),oe=parseFloat(A[4]),J.minX=K,J.minY=z,J.viewBoxWidth=te,J.viewBoxHeight=oe,Ie?(J.width=te,J.height=oe):(J.width=u(U),J.height=u(Z),V=J.width/te,W=J.height/oe),"none"!==(ne=f.util.parsePreserveAspectRatioAttribute(ne)).alignX&&("meet"===ne.meetOrSlice&&(W=V=V>W?W:V),"slice"===ne.meetOrSlice&&(W=V=V>W?V:W),Fe=J.width-te*V,Ue=J.height-oe*V,"Mid"===ne.alignX&&(Fe/=2),"Mid"===ne.alignY&&(Ue/=2),"Min"===ne.alignX&&(Fe=0),"Min"===ne.alignY&&(Ue=0)),1===V&&1===W&&0===K&&0===z&&0===ee&&0===q)return J;if((ee||q)&&"#document"!==R.parentNode.nodeName&&(Ce=" translate("+u(ee)+" "+u(q)+") "),ce=Ce+" matrix("+V+" 0 0 "+W+" "+(K*V+Fe)+" "+(z*W+Ue)+") ","svg"===R.nodeName){for(X=R.ownerDocument.createElementNS(f.svgNS,"g");R.firstChild;)X.appendChild(R.firstChild);R.appendChild(X)}else(X=R).removeAttribute("x"),X.removeAttribute("y"),ce=X.getAttribute("transform")+ce;return X.setAttribute("transform",ce),J}function L(R,A){var W="xlink:href",z=be(R,A.getAttribute(W).substr(1));if(z&&z.getAttribute(W)&&L(R,z),["gradientTransform","x1","x2","y1","y2","gradientUnits","cx","cy","r","fx","fy"].forEach(function(oe){z&&!A.hasAttribute(oe)&&z.hasAttribute(oe)&&A.setAttribute(oe,z.getAttribute(oe))}),!A.children.length)for(var te=z.cloneNode(!0);te.firstChild;)A.appendChild(te.firstChild);A.removeAttribute(W)}f.parseSVGDocument=function(R,A,V,W){if(R){!function(R){for(var A=ie(R,["use","svg:use"]),V=0;A.length&&V<A.length;){var W=A[V],K=W.getAttribute("xlink:href")||W.getAttribute("href");if(null===K)return;var ee,q,ne,fe,z=K.substr(1),te=W.getAttribute("x")||0,oe=W.getAttribute("y")||0,ce=be(R,z).cloneNode(!0),X=(ce.getAttribute("transform")||"")+" translate("+te+", "+oe+")",Z=A.length,Ie=f.svgNS;if(N(ce),/^svg$/i.test(ce.nodeName)){var ve=ce.ownerDocument.createElementNS(Ie,"g");for(q=0,fe=(ne=ce.attributes).length;q<fe;q++)ee=ne.item(q),ve.setAttributeNS(Ie,ee.nodeName,ee.nodeValue);for(;ce.firstChild;)ve.appendChild(ce.firstChild);ce=ve}for(q=0,fe=(ne=W.attributes).length;q<fe;q++)"x"!==(ee=ne.item(q)).nodeName&&"y"!==ee.nodeName&&"xlink:href"!==ee.nodeName&&"href"!==ee.nodeName&&("transform"===ee.nodeName?X=ee.nodeValue+" "+X:ce.setAttribute(ee.nodeName,ee.nodeValue));ce.setAttribute("transform",X),ce.setAttribute("instantiated_by_use","1"),ce.removeAttribute("id"),W.parentNode.replaceChild(ce,W),A.length===Z&&V++}}(R);var z,te,K=f.Object.__uid++,oe=N(R),ce=f.util.toArray(R.getElementsByTagName("*"));if(oe.crossOrigin=W&&W.crossOrigin,oe.svgUid=K,0===ce.length&&f.isLikelyNode){var X=[];for(z=0,te=(ce=R.selectNodes('//*[name(.)!="svg"]')).length;z<te;z++)X[z]=ce[z];ce=X}var U=ce.filter(function(ee){return N(ee),f.svgValidTagNamesRegEx.test(ee.nodeName.replace("svg:",""))&&!function(R,A){for(;R&&(R=R.parentNode);)if(R.nodeName&&A.test(R.nodeName.replace("svg:",""))&&!R.getAttribute("instantiated_by_use"))return!0;return!1}(ee,f.svgInvalidAncestorsRegEx)});if(!U||U&&!U.length)return void(A&&A([],{}));var Z={};ce.filter(function(ee){return"clipPath"===ee.nodeName.replace("svg:","")}).forEach(function(ee){var q=ee.getAttribute("id");Z[q]=f.util.toArray(ee.getElementsByTagName("*")).filter(function(ne){return f.svgValidTagNamesRegEx.test(ne.nodeName.replace("svg:",""))})}),f.gradientDefs[K]=f.getGradientDefs(R),f.cssRules[K]=f.getCSSRules(R),f.clipPaths[K]=Z,f.parseElements(U,function(ee,q){A&&(A(ee,oe,q,ce),delete f.gradientDefs[K],delete f.cssRules[K],delete f.clipPaths[K])},d(oe),V,W)}};var $=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+f.reNum+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+f.reNum+"))?\\s+(.*)");m(f,{parseFontDeclaration:function(R,A){var V=R.match($);if(V){var W=V[1],K=V[3],z=V[4],te=V[5],oe=V[6];W&&(A.fontStyle=W),K&&(A.fontWeight=isNaN(parseFloat(K))?K:parseFloat(K)),z&&(A.fontSize=u(z)),oe&&(A.fontFamily=oe),te&&(A.lineHeight="normal"===te?1:te)}},getGradientDefs:function(R){var W,V=ie(R,["linearGradient","radialGradient","svg:linearGradient","svg:radialGradient"]),K=0,z={};for(K=V.length;K--;)(W=V[K]).getAttribute("xlink:href")&&L(R,W),z[W.getAttribute("id")]=W;return z},parseAttributes:function(R,A,V){if(R){var W,z,te,K={};void 0===V&&(V=R.getAttribute("svgUid")),R.parentNode&&f.svgValidParentsRegEx.test(R.parentNode.nodeName)&&(K=f.parseAttributes(R.parentNode,A,V));var oe=A.reduce(function(ne,fe){return(W=R.getAttribute(fe))&&(ne[fe]=W),ne},{}),ce=m(function(R,A){var V={};for(var W in f.cssRules[A])if(he(R,W.split(" ")))for(var K in f.cssRules[A][W])V[K]=f.cssRules[A][W][K];return V}(R,V),f.parseStyleAttribute(R));oe=m(oe,ce),ce[T]&&R.setAttribute(T,ce[T]),z=te=K.fontSize||f.Text.DEFAULT_SVG_FONT_SIZE,oe[E]&&(oe[E]=z=u(oe[E],te));var X,U,Z={};for(var ee in oe)U=F(X=I(ee),oe[ee],K,z),Z[X]=U;Z&&Z.font&&f.parseFontDeclaration(Z.font,Z);var q=m(K,Z);return f.svgValidParentsRegEx.test(R.nodeName)?q:function(R){for(var A in D)if(void 0!==R[D[A]]&&""!==R[A]){if(void 0===R[A]){if(!f.Object.prototype[A])continue;R[A]=f.Object.prototype[A]}if(0!==R[A].indexOf("url(")){var V=new f.Color(R[A]);R[A]=V.setAlpha(a(V.getAlpha()*R[D[A]],2)).toRgba()}}return R}(q)}},parseElements:function(R,A,V,W,K){new f.ElementsParser(R,A,V,W,K).parse()},parseStyleAttribute:function(R){var A={},V=R.getAttribute("style");return V&&("string"==typeof V?function(R,A){var V,W;R.replace(/;\s*$/,"").split(";").forEach(function(K){var z=K.split(":");V=z[0].trim().toLowerCase(),W=z[1].trim(),A[V]=W})}(V,A):function(R,A){for(var K in R)void 0!==R[K]&&(A[K.toLowerCase()]=R[K])}(V,A)),A},parsePointsAttribute:function(R){if(!R)return null;var V,W,A=[];for(V=0,W=(R=(R=R.replace(/,/g," ").trim()).split(/\s+/)).length;V<W;V+=2)A.push({x:parseFloat(R[V]),y:parseFloat(R[V+1])});return A},getCSSRules:function(R){var V,W,A=R.getElementsByTagName("style"),K={};for(V=0,W=A.length;V<W;V++){var te=A[V].textContent;""!==(te=te.replace(/\/\*[\s\S]*?\*\//g,"")).trim()&&te.split("}").filter(function(oe){return oe.trim()}).forEach(function(oe){var ce=oe.split("{"),X={},Z=ce[1].trim().split(";").filter(function(fe){return fe.trim()});for(V=0,W=Z.length;V<W;V++){var ee=Z[V].split(":"),q=ee[0].trim(),ne=ee[1].trim();X[q]=ne}(oe=ce[0].trim()).split(",").forEach(function(fe){""!==(fe=fe.replace(/^svg/i,"").trim())&&(K[fe]?f.util.object.extend(K[fe],X):K[fe]=f.util.object.clone(X))})})}return K},loadSVGFromURL:function(R,A,V,W){R=R.replace(/^\n\s*/,"").trim(),new f.util.request(R,{method:"get",onComplete:function(z){var te=z.responseXML;if(!te||!te.documentElement)return A&&A(null),!1;f.parseSVGDocument(te.documentElement,function(oe,ce,X,U){A&&A(oe,ce,X,U)},V,W)}})},loadSVGFromString:function(R,A,V,W){var z=(new f.window.DOMParser).parseFromString(R.trim(),"text/xml");f.parseSVGDocument(z.documentElement,function(te,oe,ce,X){A(te,oe,ce,X)},V,W)}})}(Ee),b.ElementsParser=function(v,f,m,d,a,u){this.elements=v,this.callback=f,this.options=m,this.reviver=d,this.svgUid=m&&m.svgUid||0,this.parsingOptions=a,this.regexUrl=/^url\(['"]?#([^'"]+)['"]?\)/g,this.doc=u},function(v){v.parse=function(){this.instances=new Array(this.elements.length),this.numElements=this.elements.length,this.createObjects()},v.createObjects=function(){var f=this;this.elements.forEach(function(m,d){m.setAttribute("svgUid",f.svgUid),f.createObject(m,d)})},v.findTag=function(f){return b[b.util.string.capitalize(f.tagName.replace("svg:",""))]},v.createObject=function(f,m){var d=this.findTag(f);if(d&&d.fromElement)try{d.fromElement(f,this.createCallback(m,f),this.options)}catch(a){b.log(a)}else this.checkIfDone()},v.createCallback=function(f,m){var d=this;return function(a){var u;d.resolveGradient(a,m,"fill"),d.resolveGradient(a,m,"stroke"),a instanceof b.Image&&a._originalElement&&(u=a.parsePreserveAspectRatioAttribute(m)),a._removeTransformMatrix(u),d.resolveClipPath(a,m),d.reviver&&d.reviver(m,a),d.instances[f]=a,d.checkIfDone()}},v.extractPropertyDefinition=function(f,m,d){var a=f[m],u=this.regexUrl;if(u.test(a)){u.lastIndex=0;var o=u.exec(a)[1];return u.lastIndex=0,b[d][this.svgUid][o]}},v.resolveGradient=function(f,m,d){var a=this.extractPropertyDefinition(f,d,"gradientDefs");if(a){var u=m.getAttribute(d+"-opacity"),o=b.Gradient.fromElement(a,f,u,this.options);f.set(d,o)}},v.createClipPathCallback=function(f,m){return function(d){d._removeTransformMatrix(),d.fillRule=d.clipRule,m.push(d)}},v.resolveClipPath=function(f,m){var a,o,h,p,d=this.extractPropertyDefinition(f,"clipPath","clipPaths");if(d){h=[],o=b.util.invertTransform(f.calcTransformMatrix());for(var y=d[0].parentNode,C=m;C.parentNode&&C.getAttribute("clip-path")!==f.clipPath;)C=C.parentNode;C.parentNode.appendChild(y);for(var D=0;D<d.length;D++)this.findTag(a=d[D]).fromElement(a,this.createClipPathCallback(f,h),this.options);d=1===h.length?h[0]:new b.Group(h),p=b.util.multiplyTransformMatrices(o,d.calcTransformMatrix()),d.clipPath&&this.resolveClipPath(d,C);var l=b.util.qrDecompose(p);d.flipX=!1,d.flipY=!1,d.set("scaleX",l.scaleX),d.set("scaleY",l.scaleY),d.angle=l.angle,d.skewX=l.skewX,d.skewY=0,d.setPositionByOrigin({x:l.translateX,y:l.translateY},"center","center"),f.clipPath=d}else delete f.clipPath},v.checkIfDone=function(){0==--this.numElements&&(this.instances=this.instances.filter(function(f){return null!=f}),this.callback(this.instances,this.elements))}}(b.ElementsParser.prototype),function(v){"use strict";var f=v.fabric||(v.fabric={});function m(d,a){this.x=d,this.y=a}f.Point?f.warn("fabric.Point is already defined"):(f.Point=m,m.prototype={type:"point",constructor:m,add:function(d){return new m(this.x+d.x,this.y+d.y)},addEquals:function(d){return this.x+=d.x,this.y+=d.y,this},scalarAdd:function(d){return new m(this.x+d,this.y+d)},scalarAddEquals:function(d){return this.x+=d,this.y+=d,this},subtract:function(d){return new m(this.x-d.x,this.y-d.y)},subtractEquals:function(d){return this.x-=d.x,this.y-=d.y,this},scalarSubtract:function(d){return new m(this.x-d,this.y-d)},scalarSubtractEquals:function(d){return this.x-=d,this.y-=d,this},multiply:function(d){return new m(this.x*d,this.y*d)},multiplyEquals:function(d){return this.x*=d,this.y*=d,this},divide:function(d){return new m(this.x/d,this.y/d)},divideEquals:function(d){return this.x/=d,this.y/=d,this},eq:function(d){return this.x===d.x&&this.y===d.y},lt:function(d){return this.x<d.x&&this.y<d.y},lte:function(d){return this.x<=d.x&&this.y<=d.y},gt:function(d){return this.x>d.x&&this.y>d.y},gte:function(d){return this.x>=d.x&&this.y>=d.y},lerp:function(d,a){return void 0===a&&(a=.5),a=Math.max(Math.min(1,a),0),new m(this.x+(d.x-this.x)*a,this.y+(d.y-this.y)*a)},distanceFrom:function(d){var a=this.x-d.x,u=this.y-d.y;return Math.sqrt(a*a+u*u)},midPointFrom:function(d){return this.lerp(d)},min:function(d){return new m(Math.min(this.x,d.x),Math.min(this.y,d.y))},max:function(d){return new m(Math.max(this.x,d.x),Math.max(this.y,d.y))},toString:function(){return this.x+","+this.y},setXY:function(d,a){return this.x=d,this.y=a,this},setX:function(d){return this.x=d,this},setY:function(d){return this.y=d,this},setFromPoint:function(d){return this.x=d.x,this.y=d.y,this},swap:function(d){var a=this.x,u=this.y;this.x=d.x,this.y=d.y,d.x=a,d.y=u},clone:function(){return new m(this.x,this.y)}})}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={});function m(d){this.status=d,this.points=[]}f.Intersection?f.warn("fabric.Intersection is already defined"):(f.Intersection=m,f.Intersection.prototype={constructor:m,appendPoint:function(d){return this.points.push(d),this},appendPoints:function(d){return this.points=this.points.concat(d),this}},f.Intersection.intersectLineLine=function(d,a,u,o){var h,p=(o.x-u.x)*(d.y-u.y)-(o.y-u.y)*(d.x-u.x),l=(a.x-d.x)*(d.y-u.y)-(a.y-d.y)*(d.x-u.x),y=(o.y-u.y)*(a.x-d.x)-(o.x-u.x)*(a.y-d.y);if(0!==y){var C=p/y,D=l/y;0<=C&&C<=1&&0<=D&&D<=1?(h=new m("Intersection")).appendPoint(new f.Point(d.x+C*(a.x-d.x),d.y+C*(a.y-d.y))):h=new m}else h=new m(0===p||0===l?"Coincident":"Parallel");return h},f.Intersection.intersectLinePolygon=function(d,a,u){var y,C,o=new m,h=u.length;for(C=0;C<h;C++)y=m.intersectLineLine(d,a,u[C],u[(C+1)%h]),o.appendPoints(y.points);return o.points.length>0&&(o.status="Intersection"),o},f.Intersection.intersectPolygonPolygon=function(d,a){var h,u=new m,o=d.length;for(h=0;h<o;h++){var y=m.intersectLinePolygon(d[h],d[(h+1)%o],a);u.appendPoints(y.points)}return u.points.length>0&&(u.status="Intersection"),u},f.Intersection.intersectPolygonRectangle=function(d,a,u){var o=a.min(u),h=a.max(u),p=new f.Point(h.x,o.y),l=new f.Point(o.x,h.y),y=m.intersectLinePolygon(o,p,d),C=m.intersectLinePolygon(p,h,d),D=m.intersectLinePolygon(h,l,d),E=m.intersectLinePolygon(l,o,d),T=new m;return T.appendPoints(y.points),T.appendPoints(C.points),T.appendPoints(D.points),T.appendPoints(E.points),T.points.length>0&&(T.status="Intersection"),T})}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={});function m(a){a?this._tryParsingColor(a):this.setSource([0,0,0,1])}function d(a,u,o){return o<0&&(o+=1),o>1&&(o-=1),o<1/6?a+6*(u-a)*o:o<.5?u:o<2/3?a+(u-a)*(2/3-o)*6:a}f.Color?f.warn("fabric.Color is already defined."):(f.Color=m,f.Color.prototype={_tryParsingColor:function(a){var u;a in m.colorNameMap&&(a=m.colorNameMap[a]),"transparent"===a&&(u=[255,255,255,0]),u||(u=m.sourceFromHex(a)),u||(u=m.sourceFromRgb(a)),u||(u=m.sourceFromHsl(a)),u||(u=[0,0,0,1]),u&&this.setSource(u)},_rgbToHsl:function(a,u,o){var h,p,l,y=f.util.array.max([a/=255,u/=255,o/=255]),C=f.util.array.min([a,u,o]);if(l=(y+C)/2,y===C)h=p=0;else{var D=y-C;switch(p=l>.5?D/(2-y-C):D/(y+C),y){case a:h=(u-o)/D+(u<o?6:0);break;case u:h=(o-a)/D+2;break;case o:h=(a-u)/D+4}h/=6}return[Math.round(360*h),Math.round(100*p),Math.round(100*l)]},getSource:function(){return this._source},setSource:function(a){this._source=a},toRgb:function(){var a=this.getSource();return"rgb("+a[0]+","+a[1]+","+a[2]+")"},toRgba:function(){var a=this.getSource();return"rgba("+a[0]+","+a[1]+","+a[2]+","+a[3]+")"},toHsl:function(){var a=this.getSource(),u=this._rgbToHsl(a[0],a[1],a[2]);return"hsl("+u[0]+","+u[1]+"%,"+u[2]+"%)"},toHsla:function(){var a=this.getSource(),u=this._rgbToHsl(a[0],a[1],a[2]);return"hsla("+u[0]+","+u[1]+"%,"+u[2]+"%,"+a[3]+")"},toHex:function(){var u,o,h,a=this.getSource();return u=1===(u=a[0].toString(16)).length?"0"+u:u,o=1===(o=a[1].toString(16)).length?"0"+o:o,h=1===(h=a[2].toString(16)).length?"0"+h:h,u.toUpperCase()+o.toUpperCase()+h.toUpperCase()},toHexa:function(){var u,a=this.getSource();return u=1===(u=(u=Math.round(255*a[3])).toString(16)).length?"0"+u:u,this.toHex()+u.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(a){var u=this.getSource();return u[3]=a,this.setSource(u),this},toGrayscale:function(){var a=this.getSource(),u=parseInt((.3*a[0]+.59*a[1]+.11*a[2]).toFixed(0),10);return this.setSource([u,u,u,a[3]]),this},toBlackWhite:function(a){var u=this.getSource(),o=(.3*u[0]+.59*u[1]+.11*u[2]).toFixed(0),h=u[3];return a=a||127,o=Number(o)<Number(a)?0:255,this.setSource([o,o,o,h]),this},overlayWith:function(a){a instanceof m||(a=new m(a));var y,u=[],o=this.getAlpha(),p=this.getSource(),l=a.getSource();for(y=0;y<3;y++)u.push(Math.round(.5*p[y]+.5*l[y]));return u[3]=o,this.setSource(u),this}},f.Color.reRGBa=/^rgba?\(\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*(?:\s*,\s*((?:\d*\.?\d+)?)\s*)?\)$/i,f.Color.reHSLa=/^hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3}\%)\s*,\s*(\d{1,3}\%)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/i,f.Color.reHex=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,f.Color.colorNameMap={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",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:"#FF00FF",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:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",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:"#663399",red:"#FF0000",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:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"},f.Color.fromRgb=function(a){return m.fromSource(m.sourceFromRgb(a))},f.Color.sourceFromRgb=function(a){var u=a.match(m.reRGBa);if(u){var o=parseInt(u[1],10)/(/%$/.test(u[1])?100:1)*(/%$/.test(u[1])?255:1),h=parseInt(u[2],10)/(/%$/.test(u[2])?100:1)*(/%$/.test(u[2])?255:1),p=parseInt(u[3],10)/(/%$/.test(u[3])?100:1)*(/%$/.test(u[3])?255:1);return[parseInt(o,10),parseInt(h,10),parseInt(p,10),u[4]?parseFloat(u[4]):1]}},f.Color.fromRgba=m.fromRgb,f.Color.fromHsl=function(a){return m.fromSource(m.sourceFromHsl(a))},f.Color.sourceFromHsl=function(a){var u=a.match(m.reHSLa);if(u){var l,y,C,o=(parseFloat(u[1])%360+360)%360/360,h=parseFloat(u[2])/(/%$/.test(u[2])?100:1),p=parseFloat(u[3])/(/%$/.test(u[3])?100:1);if(0===h)l=y=C=p;else{var D=p<=.5?p*(h+1):p+h-p*h,E=2*p-D;l=d(E,D,o+1/3),y=d(E,D,o),C=d(E,D,o-1/3)}return[Math.round(255*l),Math.round(255*y),Math.round(255*C),u[4]?parseFloat(u[4]):1]}},f.Color.fromHsla=m.fromHsl,f.Color.fromHex=function(a){return m.fromSource(m.sourceFromHex(a))},f.Color.sourceFromHex=function(a){if(a.match(m.reHex)){var u=a.slice(a.indexOf("#")+1),o=3===u.length||4===u.length,h=8===u.length||4===u.length,p=o?u.charAt(0)+u.charAt(0):u.substring(0,2),l=o?u.charAt(1)+u.charAt(1):u.substring(2,4),y=o?u.charAt(2)+u.charAt(2):u.substring(4,6),C=h?o?u.charAt(3)+u.charAt(3):u.substring(6,8):"FF";return[parseInt(p,16),parseInt(l,16),parseInt(y,16),parseFloat((parseInt(C,16)/255).toFixed(2))]}},f.Color.fromSource=function(a){var u=new m;return u.setSource(a),u})}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=["e","se","s","sw","w","nw","n","ne","e"],d=["ns","nesw","ew","nwse"],a={},u="left",o="top",h="right",p="bottom",l="center",y={top:p,bottom:o,left:h,right:u,center:l},C=f.util.radiansToDegrees,D=Math.sign||function(X){return(X>0)-(X<0)||+X};function E(X,U){var Z=X.angle+C(Math.atan2(U.y,U.x))+360;return Math.round(Z%360/45)}function T(X,U){var Z=U.transform.target,ee=Z.canvas,q=f.util.object.clone(U);q.target=Z,ee&&ee.fire("object:"+X,q),Z.fire(X,U)}function I(X,U){var Z=U.canvas,q=X[Z.uniScaleKey];return Z.uniformScaling&&!q||!Z.uniformScaling&&q}function F(X){return X.originX===l&&X.originY===l}function B(X,U,Z){var ee=X.lockScalingX,q=X.lockScalingY;return!!(ee&&q||!U&&(ee||q)&&Z||ee&&"x"===U||q&&"y"===U)}function he(X,U,Z,ee){return{e:X,transform:U,pointer:{x:Z,y:ee}}}function ae(X){return function(U,Z,ee,q){var ne=Z.target,fe=ne.getCenterPoint(),Ie=ne.translateToOriginPoint(fe,Z.originX,Z.originY),ve=X(U,Z,ee,q);return ne.setPositionByOrigin(Ie,Z.originX,Z.originY),ve}}function _e(X,U){return function(Z,ee,q,ne){var fe=U(Z,ee,q,ne);return fe&&T(X,he(Z,ee,q,ne)),fe}}function be(X,U,Z,ee,q){var ne=X.target,fe=ne.controls[X.corner],Ie=ne.canvas.getZoom(),ve=ne.padding/Ie,J=ne.toLocalPoint(new f.Point(ee,q),U,Z);return J.x>=ve&&(J.x-=ve),J.x<=-ve&&(J.x+=ve),J.y>=ve&&(J.y-=ve),J.y<=ve&&(J.y+=ve),J.x-=fe.offsetX,J.y-=fe.offsetY,J}function me(X){return X.flipX!==X.flipY}function O(X,U,Z,ee,q){if(0!==X[U]){var ne=X._getTransformedDimensions()[ee];X.set(Z,q/ne*X[Z])}}function N(X,U,Z,ee){var J,q=U.target,ne=q._getTransformedDimensions(0,q.skewY),fe=be(U,U.originX,U.originY,Z,ee),Ie=Math.abs(2*fe.x)-ne.x,ve=q.skewX;Ie<2?J=0:(J=C(Math.atan2(Ie/q.scaleX,ne.y/q.scaleY)),U.originX===u&&U.originY===p&&(J=-J),U.originX===h&&U.originY===o&&(J=-J),me(q)&&(J=-J));var Ce=ve!==J;if(Ce){var Fe=q._getTransformedDimensions().y;q.set("skewX",J),O(q,"skewY","scaleY","y",Fe)}return Ce}function k(X,U,Z,ee){var J,q=U.target,ne=q._getTransformedDimensions(q.skewX,0),fe=be(U,U.originX,U.originY,Z,ee),Ie=Math.abs(2*fe.y)-ne.y,ve=q.skewY;Ie<2?J=0:(J=C(Math.atan2(Ie/q.scaleY,ne.x/q.scaleX)),U.originX===u&&U.originY===p&&(J=-J),U.originX===h&&U.originY===o&&(J=-J),me(q)&&(J=-J));var Ce=ve!==J;if(Ce){var Fe=q._getTransformedDimensions().x;q.set("skewY",J),O(q,"skewX","scaleX","x",Fe)}return Ce}function A(X,U,Z,ee,q){var J,Ce,Fe,Ue,wt,at,ne=U.target,fe=ne.lockScalingX,Ie=ne.lockScalingY,ve=(q=q||{}).by,Ze=I(X,ne),Ye=B(ne,ve,Ze),Xn=U.gestureScale;if(Ye)return!1;if(Xn)Ce=U.scaleX*Xn,Fe=U.scaleY*Xn;else{if(J=be(U,U.originX,U.originY,Z,ee),wt="y"!==ve?D(J.x):1,at="x"!==ve?D(J.y):1,U.signX||(U.signX=wt),U.signY||(U.signY=at),ne.lockScalingFlip&&(U.signX!==wt||U.signY!==at))return!1;if(Ue=ne._getTransformedDimensions(),Ze&&!ve){var Si=Math.abs(J.x)+Math.abs(J.y),en=U.original,Ga=Si/(Math.abs(Ue.x*en.scaleX/ne.scaleX)+Math.abs(Ue.y*en.scaleY/ne.scaleY));Ce=en.scaleX*Ga,Fe=en.scaleY*Ga}else Ce=Math.abs(J.x*ne.scaleX/Ue.x),Fe=Math.abs(J.y*ne.scaleY/Ue.y);F(U)&&(Ce*=2,Fe*=2),U.signX!==wt&&"y"!==ve&&(U.originX=y[U.originX],Ce*=-1,U.signX=wt),U.signY!==at&&"x"!==ve&&(U.originY=y[U.originY],Fe*=-1,U.signY=at)}var Ya=ne.scaleX,za=ne.scaleY;return ve?("x"===ve&&ne.set("scaleX",Ce),"y"===ve&&ne.set("scaleY",Fe)):(!fe&&ne.set("scaleX",Ce),!Ie&&ne.set("scaleY",Fe)),Ya!==ne.scaleX||za!==ne.scaleY}a.scaleCursorStyleHandler=function(X,U,Z){var q=I(X,Z),ne="";if(0!==U.x&&0===U.y?ne="x":0===U.x&&0!==U.y&&(ne="y"),B(Z,ne,q))return"not-allowed";var fe=E(Z,U);return m[fe]+"-resize"},a.skewCursorStyleHandler=function(X,U,Z){if(0!==U.x&&Z.lockSkewingY||0!==U.y&&Z.lockSkewingX)return"not-allowed";var q=E(Z,U)%4;return d[q]+"-resize"},a.scaleSkewCursorStyleHandler=function(X,U,Z){return X[Z.canvas.altActionKey]?a.skewCursorStyleHandler(X,U,Z):a.scaleCursorStyleHandler(X,U,Z)},a.rotationWithSnapping=_e("rotating",ae(function(X,U,Z,ee){var q=U,ne=q.target,fe=ne.translateToOriginPoint(ne.getCenterPoint(),q.originX,q.originY);if(ne.lockRotation)return!1;var Ce,Ie=Math.atan2(q.ey-fe.y,q.ex-fe.x),ve=Math.atan2(ee-fe.y,Z-fe.x),J=C(ve-Ie+q.theta);if(ne.snapAngle>0){var Fe=ne.snapAngle,Ue=ne.snapThreshold||Fe,Ze=Math.ceil(J/Fe)*Fe,Ye=Math.floor(J/Fe)*Fe;Math.abs(J-Ye)<Ue?J=Ye:Math.abs(J-Ze)<Ue&&(J=Ze)}return J<0&&(J=360+J),Ce=ne.angle!==(J%=360),ne.angle=J,Ce})),a.scalingEqually=_e("scaling",ae(function(X,U,Z,ee){return A(X,U,Z,ee)})),a.scalingX=_e("scaling",ae(function(X,U,Z,ee){return A(X,U,Z,ee,{by:"x"})})),a.scalingY=_e("scaling",ae(function(X,U,Z,ee){return A(X,U,Z,ee,{by:"y"})})),a.scalingYOrSkewingX=function(X,U,Z,ee){return X[U.target.canvas.altActionKey]?a.skewHandlerX(X,U,Z,ee):a.scalingY(X,U,Z,ee)},a.scalingXOrSkewingY=function(X,U,Z,ee){return X[U.target.canvas.altActionKey]?a.skewHandlerY(X,U,Z,ee):a.scalingX(X,U,Z,ee)},a.changeWidth=_e("resizing",ae(function(X,U,Z,ee){var q=U.target,ne=be(U,U.originX,U.originY,Z,ee),fe=q.strokeWidth/(q.strokeUniform?q.scaleX:1),Ie=F(U)?2:1,ve=q.width,J=Math.abs(ne.x*Ie/q.scaleX)-fe;return q.set("width",Math.max(J,0)),ve!==J})),a.skewHandlerX=function(X,U,Z,ee){var fe,q=U.target,ne=q.skewX,Ie=U.originY;return!q.lockSkewingX&&(0===ne?fe=be(U,l,l,Z,ee).x>0?u:h:(ne>0&&(fe=Ie===o?u:h),ne<0&&(fe=Ie===o?h:u),me(q)&&(fe=fe===u?h:u)),U.originX=fe,_e("skewing",ae(N))(X,U,Z,ee))},a.skewHandlerY=function(X,U,Z,ee){var fe,q=U.target,ne=q.skewY,Ie=U.originX;return!q.lockSkewingY&&(0===ne?fe=be(U,l,l,Z,ee).y>0?o:p:(ne>0&&(fe=Ie===u?o:p),ne<0&&(fe=Ie===u?p:o),me(q)&&(fe=fe===o?p:o)),U.originY=fe,_e("skewing",ae(k))(X,U,Z,ee))},a.dragHandler=function(X,U,Z,ee){var q=U.target,ne=Z-U.offsetX,fe=ee-U.offsetY,Ie=!q.get("lockMovementX")&&q.left!==ne,ve=!q.get("lockMovementY")&&q.top!==fe;return Ie&&q.set("left",ne),ve&&q.set("top",fe),(Ie||ve)&&T("moving",he(X,U,Z,ee)),Ie||ve},a.scaleOrSkewActionName=function(X,U,Z){var ee=X[Z.canvas.altActionKey];return 0===U.x?ee?"skewX":"scaleY":0===U.y?ee?"skewY":"scaleX":void 0},a.rotationStyleHandler=function(X,U,Z){return Z.lockRotation?"not-allowed":U.cursorStyle},a.fireEvent=T,a.wrapWithFixedAnchor=ae,a.wrapWithFireEvent=_e,a.getLocalPoint=be,f.controlsUtils=a}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.util.degreesToRadians,d=f.controlsUtils;d.renderCircleControl=function(o,h,p,l,y){l=l||{};var Y,C=this.sizeX||l.cornerSize||y.cornerSize,D=this.sizeY||l.cornerSize||y.cornerSize,E=void 0!==l.transparentCorners?l.transparentCorners:y.transparentCorners,T=E?"stroke":"fill",I=!E&&(l.cornerStrokeColor||y.cornerStrokeColor),F=h,B=p;o.save(),o.fillStyle=l.cornerColor||y.cornerColor,o.strokeStyle=l.cornerStrokeColor||y.cornerStrokeColor,C>D?(Y=C,o.scale(1,D/C),B=p*C/D):D>C?(Y=D,o.scale(C/D,1),F=h*D/C):Y=C,o.lineWidth=1,o.beginPath(),o.arc(F,B,Y/2,0,2*Math.PI,!1),o[T](),I&&o.stroke(),o.restore()},d.renderSquareControl=function(o,h,p,l,y){l=l||{};var C=this.sizeX||l.cornerSize||y.cornerSize,D=this.sizeY||l.cornerSize||y.cornerSize,E=void 0!==l.transparentCorners?l.transparentCorners:y.transparentCorners,T=E?"stroke":"fill",I=!E&&(l.cornerStrokeColor||y.cornerStrokeColor),F=C/2,B=D/2;o.save(),o.fillStyle=l.cornerColor||y.cornerColor,o.strokeStyle=l.cornerStrokeColor||y.cornerStrokeColor,o.lineWidth=1,o.translate(h,p),o.rotate(m(y.angle)),o[T+"Rect"](-F,-B,C,D),I&&o.strokeRect(-F,-B,C,D),o.restore()}}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={});f.Control=function(d){for(var a in d)this[a]=d[a]},f.Control.prototype={visible:!0,actionName:"scale",angle:0,x:0,y:0,offsetX:0,offsetY:0,sizeX:null,sizeY:null,touchSizeX:null,touchSizeY:null,cursorStyle:"crosshair",withConnection:!1,actionHandler:function(){},mouseDownHandler:function(){},mouseUpHandler:function(){},getActionHandler:function(){return this.actionHandler},getMouseDownHandler:function(){return this.mouseDownHandler},getMouseUpHandler:function(){return this.mouseUpHandler},cursorStyleHandler:function(d,a){return a.cursorStyle},getActionName:function(d,a){return a.actionName},getVisibility:function(d,a){var u=d._controlsVisibility;return u&&void 0!==u[a]?u[a]:this.visible},setVisibility:function(d){this.visible=d},positionHandler:function(d,a){return f.util.transformPoint({x:this.x*d.x+this.offsetX,y:this.y*d.y+this.offsetY},a)},calcCornerCoords:function(d,a,u,o,h){var p,l,y,C,D=h?this.touchSizeX:this.sizeX,E=h?this.touchSizeY:this.sizeY;if(D&&E&&D!==E){var T=Math.atan2(E,D),I=Math.sqrt(D*D+E*E)/2,F=T-f.util.degreesToRadians(d),B=Math.PI/2-T-f.util.degreesToRadians(d);p=I*f.util.cos(F),l=I*f.util.sin(F),y=I*f.util.cos(B),C=I*f.util.sin(B)}else I=.7071067812*(D&&E?D:a),F=f.util.degreesToRadians(45-d),p=y=I*f.util.cos(F),l=C=I*f.util.sin(F);return{tl:{x:u-C,y:o-y},tr:{x:u+p,y:o-l},bl:{x:u-p,y:o+l},br:{x:u+C,y:o+y}}},render:function(d,a,u,o,h){switch((o=o||{}).cornerStyle||h.cornerStyle){case"circle":f.controlsUtils.renderCircleControl.call(this,d,a,u,o,h);break;default:f.controlsUtils.renderSquareControl.call(this,d,a,u,o,h)}}}}(Ee),function(){function v(u,o){var l,y,C,D,h=u.getAttribute("style"),p=u.getAttribute("offset")||0;if(p=(p=parseFloat(p)/(/%$/.test(p)?100:1))<0?0:p>1?1:p,h){var E=h.split(/\s*;\s*/);for(""===E[E.length-1]&&E.pop(),D=E.length;D--;){var T=E[D].split(/\s*:\s*/),I=T[0].trim(),F=T[1].trim();"stop-color"===I?l=F:"stop-opacity"===I&&(C=F)}}return l||(l=u.getAttribute("stop-color")||"rgb(0,0,0)"),C||(C=u.getAttribute("stop-opacity")),y=(l=new b.Color(l)).getAlpha(),C=isNaN(parseFloat(C))?1:parseFloat(C),C*=y*o,{offset:p,color:l.toRgb(),opacity:C}}var d=b.util.object.clone;b.Gradient=b.util.createClass({offsetX:0,offsetY:0,gradientTransform:null,gradientUnits:"pixels",type:"linear",initialize:function(u){u||(u={}),u.coords||(u.coords={});var o,h=this;Object.keys(u).forEach(function(p){h[p]=u[p]}),this.id?this.id+="_"+b.Object.__uid++:this.id=b.Object.__uid++,o={x1:u.coords.x1||0,y1:u.coords.y1||0,x2:u.coords.x2||0,y2:u.coords.y2||0},"radial"===this.type&&(o.r1=u.coords.r1||0,o.r2=u.coords.r2||0),this.coords=o,this.colorStops=u.colorStops.slice()},addColorStop:function(u){for(var o in u){var h=new b.Color(u[o]);this.colorStops.push({offset:parseFloat(o),color:h.toRgb(),opacity:h.getAlpha()})}return this},toObject:function(u){var o={type:this.type,coords:this.coords,colorStops:this.colorStops,offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?this.gradientTransform.concat():this.gradientTransform};return b.util.populateWithProperties(this,o,u),o},toSVG:function(u,o){var p,l,y,C,h=d(this.coords,!0),D=(o=o||{},d(this.colorStops,!0)),E=h.r1>h.r2,T=this.gradientTransform?this.gradientTransform.concat():b.iMatrix.concat(),I=-this.offsetX,F=-this.offsetY,B=!!o.additionalTransform,Y="pixels"===this.gradientUnits?"userSpaceOnUse":"objectBoundingBox";if(D.sort(function(he,ae){return he.offset-ae.offset}),"objectBoundingBox"===Y?(I/=u.width,F/=u.height):(I+=u.width/2,F+=u.height/2),"path"===u.type&&"percentage"!==this.gradientUnits&&(I-=u.pathOffset.x,F-=u.pathOffset.y),T[4]-=I,T[5]-=F,C='id="SVGID_'+this.id+'" gradientUnits="'+Y+'"',C+=' gradientTransform="'+(B?o.additionalTransform+" ":"")+b.util.matrixToSVG(T)+'" ',"linear"===this.type?y=["<linearGradient ",C,' x1="',h.x1,'" y1="',h.y1,'" x2="',h.x2,'" y2="',h.y2,'">\n']:"radial"===this.type&&(y=["<radialGradient ",C,' cx="',E?h.x1:h.x2,'" cy="',E?h.y1:h.y2,'" r="',E?h.r1:h.r2,'" fx="',E?h.x2:h.x1,'" fy="',E?h.y2:h.y1,'">\n']),"radial"===this.type){if(E)for((D=D.concat()).reverse(),p=0,l=D.length;p<l;p++)D[p].offset=1-D[p].offset;var ie=Math.min(h.r1,h.r2);if(ie>0){var ue=ie/Math.max(h.r1,h.r2);for(p=0,l=D.length;p<l;p++)D[p].offset+=ue*(1-D[p].offset)}}for(p=0,l=D.length;p<l;p++){var de=D[p];y.push("<stop ",'offset="',100*de.offset+"%",'" style="stop-color:',de.color,void 0!==de.opacity?";stop-opacity: "+de.opacity:";",'"/>\n')}return y.push("linear"===this.type?"</linearGradient>\n":"</radialGradient>\n"),y.join("")},toLive:function(u){var o,p,l,h=b.util.object.clone(this.coords);if(this.type){for("linear"===this.type?o=u.createLinearGradient(h.x1,h.y1,h.x2,h.y2):"radial"===this.type&&(o=u.createRadialGradient(h.x1,h.y1,h.r1,h.x2,h.y2,h.r2)),p=0,l=this.colorStops.length;p<l;p++){var y=this.colorStops[p].color,C=this.colorStops[p].opacity,D=this.colorStops[p].offset;void 0!==C&&(y=new b.Color(y).setAlpha(C).toRgba()),o.addColorStop(D,y)}return o}}}),b.util.object.extend(b.Gradient,{fromElement:function(u,o,h,p){var l=parseFloat(h)/(/%$/.test(h)?100:1);l=l<0?0:l>1?1:l,isNaN(l)&&(l=1);var C,I,F,ie,y=u.getElementsByTagName("stop"),D="userSpaceOnUse"===u.getAttribute("gradientUnits")?"pixels":"percentage",E=u.getAttribute("gradientTransform")||"",T=[],B=0,Y=0;for("linearGradient"===u.nodeName||"LINEARGRADIENT"===u.nodeName?(C="linear",I=function(u){return{x1:u.getAttribute("x1")||0,y1:u.getAttribute("y1")||0,x2:u.getAttribute("x2")||"100%",y2:u.getAttribute("y2")||0}}(u)):(C="radial",I=function(u){return{x1:u.getAttribute("fx")||u.getAttribute("cx")||"50%",y1:u.getAttribute("fy")||u.getAttribute("cy")||"50%",r1:0,x2:u.getAttribute("cx")||"50%",y2:u.getAttribute("cy")||"50%",r2:u.getAttribute("r")||"50%"}}(u)),F=y.length;F--;)T.push(v(y[F],l));return ie=b.parseTransformAttribute(E),function(u,o,h,p){var l,y;Object.keys(o).forEach(function(C){"Infinity"===(l=o[C])?y=1:"-Infinity"===l?y=0:(y=parseFloat(o[C],10),"string"==typeof l&&/^(\d+\.\d+)%|(\d+)%$/.test(l)&&(y*=.01,"pixels"===p&&(("x1"===C||"x2"===C||"r2"===C)&&(y*=h.viewBoxWidth||h.width),("y1"===C||"y2"===C)&&(y*=h.viewBoxHeight||h.height)))),o[C]=y})}(0,I,p,D),"pixels"===D&&(B=-o.left,Y=-o.top),new b.Gradient({id:u.getAttribute("id"),type:C,coords:I,colorStops:T,gradientUnits:D,gradientTransform:ie,offsetX:B,offsetY:Y})}})}(),function(){"use strict";var v=b.util.toFixed;b.Pattern=b.util.createClass({repeat:"repeat",offsetX:0,offsetY:0,crossOrigin:"",patternTransform:null,initialize:function(f,m){if(f||(f={}),this.id=b.Object.__uid++,this.setOptions(f),!f.source||f.source&&"string"!=typeof f.source)m&&m(this);else{var d=this;this.source=b.util.createImage(),b.util.loadImage(f.source,function(a,u){d.source=a,m&&m(d,u)},null,this.crossOrigin)}},toObject:function(f){var d,a,m=b.Object.NUM_FRACTION_DIGITS;return"string"==typeof this.source.src?d=this.source.src:"object"==typeof this.source&&this.source.toDataURL&&(d=this.source.toDataURL()),a={type:"pattern",source:d,repeat:this.repeat,crossOrigin:this.crossOrigin,offsetX:v(this.offsetX,m),offsetY:v(this.offsetY,m),patternTransform:this.patternTransform?this.patternTransform.concat():null},b.util.populateWithProperties(this,a,f),a},toSVG:function(f){var m="function"==typeof this.source?this.source():this.source,d=m.width/f.width,a=m.height/f.height,u=this.offsetX/f.width,o=this.offsetY/f.height,h="";return("repeat-x"===this.repeat||"no-repeat"===this.repeat)&&(a=1,o&&(a+=Math.abs(o))),("repeat-y"===this.repeat||"no-repeat"===this.repeat)&&(d=1,u&&(d+=Math.abs(u))),m.src?h=m.src:m.toDataURL&&(h=m.toDataURL()),'<pattern id="SVGID_'+this.id+'" x="'+u+'" y="'+o+'" width="'+d+'" height="'+a+'">\n<image x="0" y="0" width="'+m.width+'" height="'+m.height+'" xlink:href="'+h+'"></image>\n</pattern>\n'},setOptions:function(f){for(var m in f)this[m]=f[m]},toLive:function(f){var m=this.source;return m&&(void 0===m.src||m.complete&&0!==m.naturalWidth&&0!==m.naturalHeight)?f.createPattern(m,this.repeat):""}})}(),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.util.toFixed;f.Shadow?f.warn("fabric.Shadow is already defined."):(f.Shadow=f.util.createClass({color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1,initialize:function(d){for(var a in"string"==typeof d&&(d=this._parseShadow(d)),d)this[a]=d[a];this.id=f.Object.__uid++},_parseShadow:function(d){var a=d.trim(),u=f.Shadow.reOffsetsAndBlur.exec(a)||[];return{color:(a.replace(f.Shadow.reOffsetsAndBlur,"")||"rgb(0,0,0)").trim(),offsetX:parseFloat(u[1],10)||0,offsetY:parseFloat(u[2],10)||0,blur:parseFloat(u[3],10)||0}},toString:function(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")},toSVG:function(d){var a=40,u=40,o=f.Object.NUM_FRACTION_DIGITS,h=f.util.rotateVector({x:this.offsetX,y:this.offsetY},f.util.degreesToRadians(-d.angle)),l=new f.Color(this.color);return d.width&&d.height&&(a=100*m((Math.abs(h.x)+this.blur)/d.width,o)+20,u=100*m((Math.abs(h.y)+this.blur)/d.height,o)+20),d.flipX&&(h.x*=-1),d.flipY&&(h.y*=-1),'<filter id="SVGID_'+this.id+'" y="-'+u+'%" height="'+(100+2*u)+'%" x="-'+a+'%" width="'+(100+2*a)+'%" >\n\t<feGaussianBlur in="SourceAlpha" stdDeviation="'+m(this.blur?this.blur/2:0,o)+'"></feGaussianBlur>\n\t<feOffset dx="'+m(h.x,o)+'" dy="'+m(h.y,o)+'" result="oBlur" ></feOffset>\n\t<feFlood flood-color="'+l.toRgb()+'" flood-opacity="'+l.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:function(){if(this.includeDefaultValues)return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling};var d={},a=f.Shadow.prototype;return["color","blur","offsetX","offsetY","affectStroke","nonScaling"].forEach(function(u){this[u]!==a[u]&&(d[u]=this[u])},this),d}}),f.Shadow.reOffsetsAndBlur=/(?:\s|^)(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(\d+(?:\.\d*)?(?:px)?)?(?:\s?|$)(?:$|\s)/)}(Ee),function(){"use strict";if(b.StaticCanvas)b.warn("fabric.StaticCanvas is already defined.");else{var v=b.util.object.extend,f=b.util.getElementOffset,m=b.util.removeFromArray,d=b.util.toFixed,a=b.util.transformPoint,u=b.util.invertTransform,o=b.util.getNodeCanvas,h=b.util.createCanvasElement,p=new Error("Could not initialize `canvas` element");b.StaticCanvas=b.util.createClass(b.CommonMethods,{initialize:function(l,y){y||(y={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(l,y)},backgroundColor:"",backgroundImage:null,overlayColor:"",overlayImage:null,includeDefaultValues:!0,stateful:!1,renderOnAddRemove:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,imageSmoothingEnabled:!0,viewportTransform:b.iMatrix.concat(),backgroundVpt:!0,overlayVpt:!0,enableRetinaScaling:!0,vptCoords:{},skipOffscreen:!0,clipPath:void 0,_initStatic:function(l,y){var C=this.requestRenderAllBound;this._objects=[],this._createLowerCanvas(l),this._initOptions(y),this.interactive||this._initRetinaScaling(),y.overlayImage&&this.setOverlayImage(y.overlayImage,C),y.backgroundImage&&this.setBackgroundImage(y.backgroundImage,C),y.backgroundColor&&this.setBackgroundColor(y.backgroundColor,C),y.overlayColor&&this.setOverlayColor(y.overlayColor,C),this.calcOffset()},_isRetinaScaling:function(){return b.devicePixelRatio>1&&this.enableRetinaScaling},getRetinaScaling:function(){return this._isRetinaScaling()?Math.max(1,b.devicePixelRatio):1},_initRetinaScaling:function(){if(this._isRetinaScaling()){var l=b.devicePixelRatio;this.__initRetinaScaling(l,this.lowerCanvasEl,this.contextContainer),this.upperCanvasEl&&this.__initRetinaScaling(l,this.upperCanvasEl,this.contextTop)}},__initRetinaScaling:function(l,y,C){y.setAttribute("width",this.width*l),y.setAttribute("height",this.height*l),C.scale(l,l)},calcOffset:function(){return this._offset=f(this.lowerCanvasEl),this},setOverlayImage:function(l,y,C){return this.__setBgOverlayImage("overlayImage",l,y,C)},setBackgroundImage:function(l,y,C){return this.__setBgOverlayImage("backgroundImage",l,y,C)},setOverlayColor:function(l,y){return this.__setBgOverlayColor("overlayColor",l,y)},setBackgroundColor:function(l,y){return this.__setBgOverlayColor("backgroundColor",l,y)},__setBgOverlayImage:function(l,y,C,D){return"string"==typeof y?b.util.loadImage(y,function(E,T){if(E){var I=new b.Image(E,D);this[l]=I,I.canvas=this}C&&C(E,T)},this,D&&D.crossOrigin):(D&&y.setOptions(D),this[l]=y,y&&(y.canvas=this),C&&C(y,!1)),this},__setBgOverlayColor:function(l,y,C){return this[l]=y,this._initGradient(y,l),this._initPattern(y,l,C),this},_createCanvasElement:function(){var l=h();if(!l||(l.style||(l.style={}),void 0===l.getContext))throw p;return l},_initOptions:function(l){var y=this.lowerCanvasEl;this._setOptions(l),this.width=this.width||parseInt(y.width,10)||0,this.height=this.height||parseInt(y.height,10)||0,this.lowerCanvasEl.style&&(y.width=this.width,y.height=this.height,y.style.width=this.width+"px",y.style.height=this.height+"px",this.viewportTransform=this.viewportTransform.slice())},_createLowerCanvas:function(l){this.lowerCanvasEl=l&&l.getContext?l:b.util.getById(l)||this._createCanvasElement(),b.util.addClass(this.lowerCanvasEl,"lower-canvas"),this._originalCanvasStyle=this.lowerCanvasEl.style,this.interactive&&this._applyCanvasStyle(this.lowerCanvasEl),this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(l,y){return this.setDimensions({width:l},y)},setHeight:function(l,y){return this.setDimensions({height:l},y)},setDimensions:function(l,y){var C;for(var D in y=y||{},l)C=l[D],y.cssOnly||(this._setBackstoreDimension(D,l[D]),C+="px",this.hasLostContext=!0),y.backstoreOnly||this._setCssDimension(D,C);return this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop),this._initRetinaScaling(),this.calcOffset(),y.cssOnly||this.requestRenderAll(),this},_setBackstoreDimension:function(l,y){return this.lowerCanvasEl[l]=y,this.upperCanvasEl&&(this.upperCanvasEl[l]=y),this.cacheCanvasEl&&(this.cacheCanvasEl[l]=y),this[l]=y,this},_setCssDimension:function(l,y){return this.lowerCanvasEl.style[l]=y,this.upperCanvasEl&&(this.upperCanvasEl.style[l]=y),this.wrapperEl&&(this.wrapperEl.style[l]=y),this},getZoom:function(){return this.viewportTransform[0]},setViewportTransform:function(l){var E,T,I,y=this._activeObject,C=this.backgroundImage,D=this.overlayImage;for(this.viewportTransform=l,T=0,I=this._objects.length;T<I;T++)(E=this._objects[T]).group||E.setCoords(!0);return y&&y.setCoords(),C&&C.setCoords(!0),D&&D.setCoords(!0),this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll(),this},zoomToPoint:function(l,y){var C=l,D=this.viewportTransform.slice(0);l=a(l,u(this.viewportTransform)),D[0]=y,D[3]=y;var E=a(l,D);return D[4]+=C.x-E.x,D[5]+=C.y-E.y,this.setViewportTransform(D)},setZoom:function(l){return this.zoomToPoint(new b.Point(0,0),l),this},absolutePan:function(l){var y=this.viewportTransform.slice(0);return y[4]=-l.x,y[5]=-l.y,this.setViewportTransform(y)},relativePan:function(l){return this.absolutePan(new b.Point(-l.x-this.viewportTransform[4],-l.y-this.viewportTransform[5]))},getElement:function(){return this.lowerCanvasEl},_onObjectAdded:function(l){this.stateful&&l.setupState(),l._set("canvas",this),l.setCoords(),this.fire("object:added",{target:l}),l.fire("added")},_onObjectRemoved:function(l){this.fire("object:removed",{target:l}),l.fire("removed"),delete l.canvas},clearContext:function(l){return l.clearRect(0,0,this.width,this.height),this},getContext:function(){return this.contextContainer},clear:function(){return this.remove.apply(this,this.getObjects()),this.backgroundImage=null,this.overlayImage=null,this.backgroundColor="",this.overlayColor="",this._hasITextHandlers&&(this.off("mouse:up",this._mouseUpITextHandler),this._iTextInstances=null,this._hasITextHandlers=!1),this.clearContext(this.contextContainer),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll(),this},renderAll:function(){return this.renderCanvas(this.contextContainer,this._objects),this},renderAndReset:function(){this.isRendering=0,this.renderAll()},requestRenderAll:function(){return this.isRendering||(this.isRendering=b.util.requestAnimFrame(this.renderAndResetBound)),this},calcViewportBoundaries:function(){var l={},y=this.width,C=this.height,D=u(this.viewportTransform);return l.tl=a({x:0,y:0},D),l.br=a({x:y,y:C},D),l.tr=new b.Point(l.br.x,l.tl.y),l.bl=new b.Point(l.tl.x,l.br.y),this.vptCoords=l,l},cancelRequestedRender:function(){this.isRendering&&(b.util.cancelAnimFrame(this.isRendering),this.isRendering=0)},renderCanvas:function(l,y){var C=this.viewportTransform,D=this.clipPath;this.cancelRequestedRender(),this.calcViewportBoundaries(),this.clearContext(l),b.util.setImageSmoothing(l,this.imageSmoothingEnabled),this.fire("before:render",{ctx:l}),this._renderBackground(l),l.save(),l.transform(C[0],C[1],C[2],C[3],C[4],C[5]),this._renderObjects(l,y),l.restore(),!this.controlsAboveOverlay&&this.interactive&&this.drawControls(l),D&&(D.canvas=this,D.shouldCache(),D._transformDone=!0,D.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(l)),this._renderOverlay(l),this.controlsAboveOverlay&&this.interactive&&this.drawControls(l),this.fire("after:render",{ctx:l})},drawClipPathOnCanvas:function(l){var y=this.viewportTransform,C=this.clipPath;l.save(),l.transform(y[0],y[1],y[2],y[3],y[4],y[5]),l.globalCompositeOperation="destination-in",C.transform(l),l.scale(1/C.zoomX,1/C.zoomY),l.drawImage(C._cacheCanvas,-C.cacheTranslationX,-C.cacheTranslationY),l.restore()},_renderObjects:function(l,y){var C,D;for(C=0,D=y.length;C<D;++C)y[C]&&y[C].render(l)},_renderBackgroundOrOverlay:function(l,y){var C=this[y+"Color"],D=this[y+"Image"],E=this.viewportTransform,T=this[y+"Vpt"];if(C||D){if(C){l.save(),l.beginPath(),l.moveTo(0,0),l.lineTo(this.width,0),l.lineTo(this.width,this.height),l.lineTo(0,this.height),l.closePath(),l.fillStyle=C.toLive?C.toLive(l,this):C,T&&l.transform(E[0],E[1],E[2],E[3],E[4],E[5]),l.transform(1,0,0,1,C.offsetX||0,C.offsetY||0);var I=C.gradientTransform||C.patternTransform;I&&l.transform(I[0],I[1],I[2],I[3],I[4],I[5]),l.fill(),l.restore()}D&&(l.save(),T&&l.transform(E[0],E[1],E[2],E[3],E[4],E[5]),D.render(l),l.restore())}},_renderBackground:function(l){this._renderBackgroundOrOverlay(l,"background")},_renderOverlay:function(l){this._renderBackgroundOrOverlay(l,"overlay")},getCenter:function(){return{top:this.height/2,left:this.width/2}},centerObjectH:function(l){return this._centerObject(l,new b.Point(this.getCenter().left,l.getCenterPoint().y))},centerObjectV:function(l){return this._centerObject(l,new b.Point(l.getCenterPoint().x,this.getCenter().top))},centerObject:function(l){var y=this.getCenter();return this._centerObject(l,new b.Point(y.left,y.top))},viewportCenterObject:function(l){var y=this.getVpCenter();return this._centerObject(l,y)},viewportCenterObjectH:function(l){var y=this.getVpCenter();return this._centerObject(l,new b.Point(y.x,l.getCenterPoint().y)),this},viewportCenterObjectV:function(l){var y=this.getVpCenter();return this._centerObject(l,new b.Point(l.getCenterPoint().x,y.y))},getVpCenter:function(){var l=this.getCenter(),y=u(this.viewportTransform);return a({x:l.left,y:l.top},y)},_centerObject:function(l,y){return l.setPositionByOrigin(y,"center","center"),l.setCoords(),this.renderOnAddRemove&&this.requestRenderAll(),this},toDatalessJSON:function(l){return this.toDatalessObject(l)},toObject:function(l){return this._toObjectMethod("toObject",l)},toDatalessObject:function(l){return this._toObjectMethod("toDatalessObject",l)},_toObjectMethod:function(l,y){var C=this.clipPath,D={version:b.version,objects:this._toObjects(l,y)};return C&&!C.excludeFromExport&&(D.clipPath=this._toObject(this.clipPath,l,y)),v(D,this.__serializeBgOverlay(l,y)),b.util.populateWithProperties(this,D,y),D},_toObjects:function(l,y){return this._objects.filter(function(C){return!C.excludeFromExport}).map(function(C){return this._toObject(C,l,y)},this)},_toObject:function(l,y,C){var D;this.includeDefaultValues||(D=l.includeDefaultValues,l.includeDefaultValues=!1);var E=l[y](C);return this.includeDefaultValues||(l.includeDefaultValues=D),E},__serializeBgOverlay:function(l,y){var C={},D=this.backgroundImage,E=this.overlayImage,T=this.backgroundColor,I=this.overlayColor;return T&&T.toObject?T.excludeFromExport||(C.background=T.toObject(y)):T&&(C.background=T),I&&I.toObject?I.excludeFromExport||(C.overlay=I.toObject(y)):I&&(C.overlay=I),D&&!D.excludeFromExport&&(C.backgroundImage=this._toObject(D,l,y)),E&&!E.excludeFromExport&&(C.overlayImage=this._toObject(E,l,y)),C},svgViewportTransformation:!0,toSVG:function(l,y){l||(l={}),l.reviver=y;var C=[];return this._setSVGPreamble(C,l),this._setSVGHeader(C,l),this.clipPath&&C.push('<g clip-path="url(#'+this.clipPath.clipPathId+')" >\n'),this._setSVGBgOverlayColor(C,"background"),this._setSVGBgOverlayImage(C,"backgroundImage",y),this._setSVGObjects(C,y),this.clipPath&&C.push("</g>\n"),this._setSVGBgOverlayColor(C,"overlay"),this._setSVGBgOverlayImage(C,"overlayImage",y),C.push("</svg>"),C.join("")},_setSVGPreamble:function(l,y){y.suppressPreamble||l.push('<?xml version="1.0" encoding="',y.encoding||"UTF-8",'" standalone="no" ?>\n','<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ','"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n')},_setSVGHeader:function(l,y){var E,C=y.width||this.width,D=y.height||this.height,T='viewBox="0 0 '+this.width+" "+this.height+'" ',I=b.Object.NUM_FRACTION_DIGITS;y.viewBox?T='viewBox="'+y.viewBox.x+" "+y.viewBox.y+" "+y.viewBox.width+" "+y.viewBox.height+'" ':this.svgViewportTransformation&&(T='viewBox="'+d(-(E=this.viewportTransform)[4]/E[0],I)+" "+d(-E[5]/E[3],I)+" "+d(this.width/E[0],I)+" "+d(this.height/E[3],I)+'" '),l.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',C,'" ','height="',D,'" ',T,'xml:space="preserve">\n',"<desc>Created with Fabric.js ",b.version,"</desc>\n","<defs>\n",this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(y),"</defs>\n")},createSVGClipPathMarkup:function(l){var y=this.clipPath;return y?(y.clipPathId="CLIPPATH_"+b.Object.__uid++,'<clipPath id="'+y.clipPathId+'" >\n'+this.clipPath.toClipPathSVG(l.reviver)+"</clipPath>\n"):""},createSVGRefElementsMarkup:function(){var l=this;return["background","overlay"].map(function(C){var D=l[C+"Color"];if(D&&D.toLive){var E=l[C+"Vpt"],T=l.viewportTransform;return D.toSVG({width:l.width/(E?T[0]:1),height:l.height/(E?T[3]:1)},{additionalTransform:E?b.util.matrixToSVG(T):""})}}).join("")},createSVGFontFacesMarkup:function(){var C,D,E,T,I,B,Y,ie,l="",y={},le=b.fontPaths,ue=[];for(this._objects.forEach(function he(ae){ue.push(ae),ae._objects&&ae._objects.forEach(he)}),Y=0,ie=ue.length;Y<ie;Y++)if(D=(C=ue[Y]).fontFamily,-1!==C.type.indexOf("text")&&!y[D]&&le[D]&&(y[D]=!0,C.styles))for(I in E=C.styles)for(B in T=E[I])!y[D=T[B].fontFamily]&&le[D]&&(y[D]=!0);for(var de in y)l+=["\t\t@font-face {\n","\t\t\tfont-family: '",de,"';\n","\t\t\tsrc: url('",le[de],"');\n","\t\t}\n"].join("");return l&&(l=['\t<style type="text/css">',"<![CDATA[\n",l,"]]>","</style>\n"].join("")),l},_setSVGObjects:function(l,y){var C,D,E,T=this._objects;for(D=0,E=T.length;D<E;D++)!(C=T[D]).excludeFromExport&&this._setSVGObject(l,C,y)},_setSVGObject:function(l,y,C){l.push(y.toSVG(C))},_setSVGBgOverlayImage:function(l,y,C){this[y]&&!this[y].excludeFromExport&&this[y].toSVG&&l.push(this[y].toSVG(C))},_setSVGBgOverlayColor:function(l,y){var C=this[y+"Color"],E=this.width,T=this.height;if(C)if(C.toLive){var I=C.repeat,F=b.util.invertTransform(this.viewportTransform),Y=this[y+"Vpt"]?b.util.matrixToSVG(F):"";l.push('<rect transform="'+Y+" translate(",E/2,",",T/2,')"',' x="',C.offsetX-E/2,'" y="',C.offsetY-T/2,'" ','width="',"repeat-y"===I||"no-repeat"===I?C.source.width:E,'" height="',"repeat-x"===I||"no-repeat"===I?C.source.height:T,'" fill="url(#SVGID_'+C.id+')"',"></rect>\n")}else l.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',C,'"',"></rect>\n")},sendToBack:function(l){if(!l)return this;var C,D,E,y=this._activeObject;if(l===y&&"activeSelection"===l.type)for(C=(E=y._objects).length;C--;)m(this._objects,D=E[C]),this._objects.unshift(D);else m(this._objects,l),this._objects.unshift(l);return this.renderOnAddRemove&&this.requestRenderAll(),this},bringToFront:function(l){if(!l)return this;var C,D,E,y=this._activeObject;if(l===y&&"activeSelection"===l.type)for(E=y._objects,C=0;C<E.length;C++)m(this._objects,D=E[C]),this._objects.push(D);else m(this._objects,l),this._objects.push(l);return this.renderOnAddRemove&&this.requestRenderAll(),this},sendBackwards:function(l,y){if(!l)return this;var D,E,T,I,F,C=this._activeObject,B=0;if(l===C&&"activeSelection"===l.type)for(F=C._objects,D=0;D<F.length;D++)(T=this._objects.indexOf(E=F[D]))>0+B&&(I=T-1,m(this._objects,E),this._objects.splice(I,0,E)),B++;else 0!==(T=this._objects.indexOf(l))&&(I=this._findNewLowerIndex(l,T,y),m(this._objects,l),this._objects.splice(I,0,l));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewLowerIndex:function(l,y,C){var D,E;if(C){for(D=y,E=y-1;E>=0;--E)if(l.intersectsWithObject(this._objects[E])||l.isContainedWithinObject(this._objects[E])||this._objects[E].isContainedWithinObject(l)){D=E;break}}else D=y-1;return D},bringForward:function(l,y){if(!l)return this;var D,E,T,I,F,C=this._activeObject,B=0;if(l===C&&"activeSelection"===l.type)for(D=(F=C._objects).length;D--;)(T=this._objects.indexOf(E=F[D]))<this._objects.length-1-B&&(I=T+1,m(this._objects,E),this._objects.splice(I,0,E)),B++;else(T=this._objects.indexOf(l))!==this._objects.length-1&&(I=this._findNewUpperIndex(l,T,y),m(this._objects,l),this._objects.splice(I,0,l));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewUpperIndex:function(l,y,C){var D,E,T;if(C){for(D=y,E=y+1,T=this._objects.length;E<T;++E)if(l.intersectsWithObject(this._objects[E])||l.isContainedWithinObject(this._objects[E])||this._objects[E].isContainedWithinObject(l)){D=E;break}}else D=y+1;return D},moveTo:function(l,y){return m(this._objects,l),this._objects.splice(y,0,l),this.renderOnAddRemove&&this.requestRenderAll()},dispose:function(){return this.isRendering&&(b.util.cancelAnimFrame(this.isRendering),this.isRendering=0),this.forEachObject(function(l){l.dispose&&l.dispose(),b.runningAnimations&&b.runningAnimations.cancelByTarget(l)}),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose&&this.backgroundImage.dispose(),this.backgroundImage=null,this.overlayImage&&this.overlayImage.dispose&&this.overlayImage.dispose(),this.overlayImage=null,this._iTextInstances=null,this.contextContainer=null,this.lowerCanvasEl.classList.remove("lower-canvas"),b.util.setStyle(this.lowerCanvasEl,this._originalCanvasStyle),delete this._originalCanvasStyle,this.lowerCanvasEl.setAttribute("width",this.width),this.lowerCanvasEl.setAttribute("height",this.height),b.util.cleanUpJsdomNode(this.lowerCanvasEl),this.lowerCanvasEl=void 0,this},toString:function(){return"#<fabric.Canvas ("+this.complexity()+"): { objects: "+this._objects.length+" }>"}}),v(b.StaticCanvas.prototype,b.Observable),v(b.StaticCanvas.prototype,b.Collection),v(b.StaticCanvas.prototype,b.DataURLExporter),v(b.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',supports:function(l){var y=h();if(!y||!y.getContext)return null;var C=y.getContext("2d");if(!C)return null;switch(l){case"setLineDash":return void 0!==C.setLineDash;default:return null}}}),b.StaticCanvas.prototype.toJSON=b.StaticCanvas.prototype.toObject,b.isLikelyNode&&(b.StaticCanvas.prototype.createPNGStream=function(){var l=o(this.lowerCanvasEl);return l&&l.createPNGStream()},b.StaticCanvas.prototype.createJPEGStream=function(l){var y=o(this.lowerCanvasEl);return y&&y.createJPEGStream(l)})}}(),b.BaseBrush=b.util.createClass({color:"rgb(0, 0, 0)",width:1,shadow:null,strokeLineCap:"round",strokeLineJoin:"round",strokeMiterLimit:10,strokeDashArray:null,limitedToCanvasSize:!1,_setBrushStyles:function(v){v.strokeStyle=this.color,v.lineWidth=this.width,v.lineCap=this.strokeLineCap,v.miterLimit=this.strokeMiterLimit,v.lineJoin=this.strokeLineJoin,v.setLineDash(this.strokeDashArray||[])},_saveAndTransform:function(v){var f=this.canvas.viewportTransform;v.save(),v.transform(f[0],f[1],f[2],f[3],f[4],f[5])},_setShadow:function(){if(this.shadow){var v=this.canvas,f=this.shadow,m=v.contextTop,d=v.getZoom();v&&v._isRetinaScaling()&&(d*=b.devicePixelRatio),m.shadowColor=f.color,m.shadowBlur=f.blur*d,m.shadowOffsetX=f.offsetX*d,m.shadowOffsetY=f.offsetY*d}},needsFullRender:function(){return new b.Color(this.color).getAlpha()<1||!!this.shadow},_resetShadow:function(){var v=this.canvas.contextTop;v.shadowColor="",v.shadowBlur=v.shadowOffsetX=v.shadowOffsetY=0},_isOutSideCanvas:function(v){return v.x<0||v.x>this.canvas.getWidth()||v.y<0||v.y>this.canvas.getHeight()}}),b.PencilBrush=b.util.createClass(b.BaseBrush,{decimate:.4,drawStraightLine:!1,straightLineKey:"shiftKey",initialize:function(v){this.canvas=v,this._points=[]},needsFullRender:function(){return this.callSuper("needsFullRender")||this._hasStraightLine},_drawSegment:function(v,f,m){var d=f.midPointFrom(m);return v.quadraticCurveTo(f.x,f.y,d.x,d.y),d},onMouseDown:function(v,f){!this.canvas._isMainEvent(f.e)||(this.drawStraightLine=f.e[this.straightLineKey],this._prepareForDrawing(v),this._captureDrawingPath(v),this._render())},onMouseMove:function(v,f){if(this.canvas._isMainEvent(f.e)&&(this.drawStraightLine=f.e[this.straightLineKey],(!0!==this.limitedToCanvasSize||!this._isOutSideCanvas(v))&&this._captureDrawingPath(v)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{var m=this._points,d=m.length,a=this.canvas.contextTop;this._saveAndTransform(a),this.oldEnd&&(a.beginPath(),a.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=this._drawSegment(a,m[d-2],m[d-1],!0),a.stroke(),a.restore()}},onMouseUp:function(v){return!this.canvas._isMainEvent(v.e)||(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1)},_prepareForDrawing:function(v){var f=new b.Point(v.x,v.y);this._reset(),this._addPoint(f),this.canvas.contextTop.moveTo(f.x,f.y)},_addPoint:function(v){return!(this._points.length>1&&v.eq(this._points[this._points.length-1])||(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(v),0))},_reset:function(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1},_captureDrawingPath:function(v){var f=new b.Point(v.x,v.y);return this._addPoint(f)},_render:function(v){var f,m,d=this._points[0],a=this._points[1];if(this._saveAndTransform(v=v||this.canvas.contextTop),v.beginPath(),2===this._points.length&&d.x===a.x&&d.y===a.y){var u=this.width/1e3;d=new b.Point(d.x,d.y),a=new b.Point(a.x,a.y),d.x-=u,a.x+=u}for(v.moveTo(d.x,d.y),f=1,m=this._points.length;f<m;f++)this._drawSegment(v,d,a),d=this._points[f],a=this._points[f+1];v.lineTo(d.x,d.y),v.stroke(),v.restore()},convertPointsToSVGPath:function(v){return b.util.getSmoothPathFromPoints(v,this.width/1e3)},_isEmptySVGPath:function(v){return"M 0 0 Q 0 0 0 0 L 0 0"===b.util.joinPath(v)},createPath:function(v){var f=new b.Path(v,{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,f.shadow=new b.Shadow(this.shadow)),f},decimatePoints:function(v,f){if(v.length<=2)return v;var a,m=this.canvas.getZoom(),d=Math.pow(f/m,2),u=v.length-1,o=v[0],h=[o];for(a=1;a<u-1;a++)Math.pow(o.x-v[a].x,2)+Math.pow(o.y-v[a].y,2)>=d&&h.push(o=v[a]);return h.push(v[u]),h},_finalizeAndAddPath:function(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));var f=this.convertPointsToSVGPath(this._points);if(this._isEmptySVGPath(f))this.canvas.requestRenderAll();else{var m=this.createPath(f);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:m}),this.canvas.add(m),this.canvas.requestRenderAll(),m.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:m})}}}),b.CircleBrush=b.util.createClass(b.BaseBrush,{width:10,initialize:function(v){this.canvas=v,this.points=[]},drawDot:function(v){var f=this.addPoint(v),m=this.canvas.contextTop;this._saveAndTransform(m),this.dot(m,f),m.restore()},dot:function(v,f){v.fillStyle=f.fill,v.beginPath(),v.arc(f.x,f.y,f.radius,0,2*Math.PI,!1),v.closePath(),v.fill()},onMouseDown:function(v){this.points.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(v)},_render:function(){var f,m,v=this.canvas.contextTop,d=this.points;for(this._saveAndTransform(v),f=0,m=d.length;f<m;f++)this.dot(v,d[f]);v.restore()},onMouseMove:function(v){!0===this.limitedToCanvasSize&&this._isOutSideCanvas(v)||(this.needsFullRender()?(this.canvas.clearContext(this.canvas.contextTop),this.addPoint(v),this._render()):this.drawDot(v))},onMouseUp:function(){var f,m,v=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;var d=[];for(f=0,m=this.points.length;f<m;f++){var a=this.points[f],u=new b.Circle({radius:a.radius,left:a.x,top:a.y,originX:"center",originY:"center",fill:a.fill});this.shadow&&(u.shadow=new b.Shadow(this.shadow)),d.push(u)}var o=new b.Group(d);o.canvas=this.canvas,this.canvas.fire("before:path:created",{path:o}),this.canvas.add(o),this.canvas.fire("path:created",{path:o}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=v,this.canvas.requestRenderAll()},addPoint:function(v){var f=new b.Point(v.x,v.y),m=b.util.getRandomInt(Math.max(0,this.width-20),this.width+20)/2,d=new b.Color(this.color).setAlpha(b.util.getRandomInt(0,100)/100).toRgba();return f.radius=m,f.fill=d,this.points.push(f),f}}),b.SprayBrush=b.util.createClass(b.BaseBrush,{width:10,density:20,dotWidth:1,dotWidthVariance:1,randomOpacity:!1,optimizeOverlapping:!0,initialize:function(v){this.canvas=v,this.sprayChunks=[]},onMouseDown:function(v){this.sprayChunks.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.addSprayChunk(v),this.render(this.sprayChunkPoints)},onMouseMove:function(v){!0===this.limitedToCanvasSize&&this._isOutSideCanvas(v)||(this.addSprayChunk(v),this.render(this.sprayChunkPoints))},onMouseUp:function(){var v=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;for(var f=[],m=0,d=this.sprayChunks.length;m<d;m++)for(var a=this.sprayChunks[m],u=0,o=a.length;u<o;u++){var h=new b.Rect({width:a[u].width,height:a[u].width,left:a[u].x+1,top:a[u].y+1,originX:"center",originY:"center",fill:this.color});f.push(h)}this.optimizeOverlapping&&(f=this._getOptimizedRects(f));var p=new b.Group(f);this.shadow&&p.set("shadow",new b.Shadow(this.shadow)),this.canvas.fire("before:path:created",{path:p}),this.canvas.add(p),this.canvas.fire("path:created",{path:p}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=v,this.canvas.requestRenderAll()},_getOptimizedRects:function(v){var m,d,a,f={};for(d=0,a=v.length;d<a;d++)f[m=v[d].left+""+v[d].top]||(f[m]=v[d]);var u=[];for(m in f)u.push(f[m]);return u},render:function(v){var m,d,f=this.canvas.contextTop;for(f.fillStyle=this.color,this._saveAndTransform(f),m=0,d=v.length;m<d;m++){var a=v[m];void 0!==a.opacity&&(f.globalAlpha=a.opacity),f.fillRect(a.x,a.y,a.width,a.width)}f.restore()},_render:function(){var f,m,v=this.canvas.contextTop;for(v.fillStyle=this.color,this._saveAndTransform(v),f=0,m=this.sprayChunks.length;f<m;f++)this.render(this.sprayChunks[f]);v.restore()},addSprayChunk:function(v){this.sprayChunkPoints=[];var f,m,d,u,a=this.width/2;for(u=0;u<this.density;u++){f=b.util.getRandomInt(v.x-a,v.x+a),m=b.util.getRandomInt(v.y-a,v.y+a),d=this.dotWidthVariance?b.util.getRandomInt(Math.max(1,this.dotWidth-this.dotWidthVariance),this.dotWidth+this.dotWidthVariance):this.dotWidth;var o=new b.Point(f,m);o.width=d,this.randomOpacity&&(o.opacity=b.util.getRandomInt(0,100)/100),this.sprayChunkPoints.push(o)}this.sprayChunks.push(this.sprayChunkPoints)}}),b.PatternBrush=b.util.createClass(b.PencilBrush,{getPatternSrc:function(){var m=b.util.createCanvasElement(),d=m.getContext("2d");return m.width=m.height=25,d.fillStyle=this.color,d.beginPath(),d.arc(10,10,10,0,2*Math.PI,!1),d.closePath(),d.fill(),m},getPatternSrcFunction:function(){return String(this.getPatternSrc).replace("this.color",'"'+this.color+'"')},getPattern:function(v){return v.createPattern(this.source||this.getPatternSrc(),"repeat")},_setBrushStyles:function(v){this.callSuper("_setBrushStyles",v),v.strokeStyle=this.getPattern(v)},createPath:function(v){var f=this.callSuper("createPath",v),m=f._getLeftTopCoords().scalarAdd(f.strokeWidth/2);return f.stroke=new b.Pattern({source:this.source||this.getPatternSrcFunction(),offsetX:-m.x,offsetY:-m.y}),f}}),function(){var v=b.util.getPointer,f=b.util.degreesToRadians,m=b.util.isTouchEvent;for(var d in b.Canvas=b.util.createClass(b.StaticCanvas,{initialize:function(a,u){u||(u={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(a,u),this._initInteractive(),this._createCacheCanvas()},uniformScaling:!0,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",interactive:!0,selection:!0,selectionKey:"shiftKey",altSelectionKey:null,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",containerClass:"canvas-container",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,isDrawingMode:!1,preserveObjectStacking:!1,snapAngle:0,snapThreshold:null,stopContextMenu:!1,fireRightClick:!1,fireMiddleClick:!1,targets:[],enablePointerEvents:!1,_hoveredTarget:null,_hoveredTargets:[],_initInteractive:function(){this._currentTransform=null,this._groupSelector=null,this._initWrapperElement(),this._createUpperCanvas(),this._initEventListeners(),this._initRetinaScaling(),this.freeDrawingBrush=b.PencilBrush&&new b.PencilBrush(this),this.calcOffset()},_chooseObjectsToRender:function(){var u,o,h,a=this.getActiveObjects();if(a.length>0&&!this.preserveObjectStacking){o=[],h=[];for(var p=0,l=this._objects.length;p<l;p++)-1===a.indexOf(u=this._objects[p])?o.push(u):h.push(u);a.length>1&&(this._activeObject._objects=h),o.push.apply(o,h)}else o=this._objects;return o},renderAll:function(){return this.contextTopDirty&&!this._groupSelector&&!this.isDrawingMode&&(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1),this.renderCanvas(this.contextContainer,this._chooseObjectsToRender()),this},renderTopLayer:function(a){a.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(a),this.contextTopDirty=!0),a.restore()},renderTop:function(){var a=this.contextTop;return this.clearContext(a),this.renderTopLayer(a),this.fire("after:render"),this},_normalizePointer:function(a,u){var o=a.calcTransformMatrix(),h=b.util.invertTransform(o),p=this.restorePointerVpt(u);return b.util.transformPoint(p,h)},isTargetTransparent:function(a,u,o){if(a.shouldCache()&&a._cacheCanvas&&a!==this._activeObject){var h=this._normalizePointer(a,{x:u,y:o}),p=Math.max(a.cacheTranslationX+h.x*a.zoomX,0),l=Math.max(a.cacheTranslationY+h.y*a.zoomY,0);return b.util.isTransparent(a._cacheContext,Math.round(p),Math.round(l),this.targetFindTolerance)}var y=this.contextCache,C=a.selectionBackgroundColor,D=this.viewportTransform;return a.selectionBackgroundColor="",this.clearContext(y),y.save(),y.transform(D[0],D[1],D[2],D[3],D[4],D[5]),a.render(y),y.restore(),a.selectionBackgroundColor=C,b.util.isTransparent(y,u,o,this.targetFindTolerance)},_isSelectionKeyPressed:function(a){return"[object Array]"===Object.prototype.toString.call(this.selectionKey)?!!this.selectionKey.find(function(o){return!0===a[o]}):a[this.selectionKey]},_shouldClearSelection:function(a,u){var o=this.getActiveObjects(),h=this._activeObject;return!u||u&&h&&o.length>1&&-1===o.indexOf(u)&&h!==u&&!this._isSelectionKeyPressed(a)||u&&!u.evented||u&&!u.selectable&&h&&h!==u},_shouldCenterTransform:function(a,u,o){var h;if(a)return"scale"===u||"scaleX"===u||"scaleY"===u||"resizing"===u?h=this.centeredScaling||a.centeredScaling:"rotate"===u&&(h=this.centeredRotation||a.centeredRotation),h?!o:o},_getOriginFromCorner:function(a,u){var o={x:a.originX,y:a.originY};return"ml"===u||"tl"===u||"bl"===u?o.x="right":("mr"===u||"tr"===u||"br"===u)&&(o.x="left"),"tl"===u||"mt"===u||"tr"===u?o.y="bottom":("bl"===u||"mb"===u||"br"===u)&&(o.y="top"),o},_getActionFromCorner:function(a,u,o,h){if(!u||!a)return"drag";var p=h.controls[u];return p.getActionName(o,p,h)},_setupCurrentTransform:function(a,u,o){if(u){var h=this.getPointer(a),p=u.__corner,l=u.controls[p],y=o&&p?l.getActionHandler(a,u,l):b.controlsUtils.dragHandler,C=this._getActionFromCorner(o,p,a,u),D=this._getOriginFromCorner(u,p),E=a[this.centeredKey],T={target:u,action:C,actionHandler:y,corner:p,scaleX:u.scaleX,scaleY:u.scaleY,skewX:u.skewX,skewY:u.skewY,offsetX:h.x-u.left,offsetY:h.y-u.top,originX:D.x,originY:D.y,ex:h.x,ey:h.y,lastX:h.x,lastY:h.y,theta:f(u.angle),width:u.width*u.scaleX,shiftKey:a.shiftKey,altKey:E,original:b.util.saveObjectTransform(u)};this._shouldCenterTransform(u,C,E)&&(T.originX="center",T.originY="center"),T.original.originX=D.x,T.original.originY=D.y,this._currentTransform=T,this._beforeTransform(a)}},setCursor:function(a){this.upperCanvasEl.style.cursor=a},_drawSelection:function(a){var u=this._groupSelector,o=new b.Point(u.ex,u.ey),h=b.util.transformPoint(o,this.viewportTransform),p=new b.Point(u.ex+u.left,u.ey+u.top),l=b.util.transformPoint(p,this.viewportTransform),y=Math.min(h.x,l.x),C=Math.min(h.y,l.y),D=Math.max(h.x,l.x),E=Math.max(h.y,l.y),T=this.selectionLineWidth/2;this.selectionColor&&(a.fillStyle=this.selectionColor,a.fillRect(y,C,D-y,E-C)),this.selectionLineWidth&&this.selectionBorderColor&&(a.lineWidth=this.selectionLineWidth,a.strokeStyle=this.selectionBorderColor,y+=T,C+=T,D-=T,E-=T,b.Object.prototype._setLineDash.call(this,a,this.selectionDashArray),a.strokeRect(y,C,D-y,E-C))},findTarget:function(a,u){if(!this.skipTargetFind){var y,C,h=this.getPointer(a,!0),p=this._activeObject,l=this.getActiveObjects(),D=m(a),E=l.length>1&&!u||1===l.length;if(this.targets=[],E&&p._findTargetCorner(h,D)||l.length>1&&!u&&p===this._searchPossibleTargets([p],h))return p;if(1===l.length&&p===this._searchPossibleTargets([p],h)){if(!this.preserveObjectStacking)return p;y=p,C=this.targets,this.targets=[]}var T=this._searchPossibleTargets(this._objects,h);return a[this.altSelectionKey]&&T&&y&&T!==y&&(T=y,this.targets=C),T}},_checkTarget:function(a,u,o){if(u&&u.visible&&u.evented&&u.containsPoint(a)){if(!this.perPixelTargetFind&&!u.perPixelTargetFind||u.isEditing)return!0;if(!this.isTargetTransparent(u,o.x,o.y))return!0}},_searchPossibleTargets:function(a,u){for(var o,p,h=a.length;h--;){var l=a[h],y=l.group?this._normalizePointer(l.group,u):u;if(this._checkTarget(y,l,u)){(o=a[h]).subTargetCheck&&o instanceof b.Group&&(p=this._searchPossibleTargets(o._objects,u))&&this.targets.push(p);break}}return o},restorePointerVpt:function(a){return b.util.transformPoint(a,b.util.invertTransform(this.viewportTransform))},getPointer:function(a,u){if(this._absolutePointer&&!u)return this._absolutePointer;if(this._pointer&&u)return this._pointer;var C,o=v(a),h=this.upperCanvasEl,p=h.getBoundingClientRect(),l=p.width||0,y=p.height||0;(!l||!y)&&("top"in p&&"bottom"in p&&(y=Math.abs(p.top-p.bottom)),"right"in p&&"left"in p&&(l=Math.abs(p.right-p.left))),this.calcOffset(),o.x=o.x-this._offset.left,o.y=o.y-this._offset.top,u||(o=this.restorePointerVpt(o));var D=this.getRetinaScaling();return 1!==D&&(o.x/=D,o.y/=D),{x:o.x*(C=0===l||0===y?{width:1,height:1}:{width:h.width/l,height:h.height/y}).width,y:o.y*C.height}},_createUpperCanvas:function(){var a=this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/,""),u=this.lowerCanvasEl,o=this.upperCanvasEl;o?o.className="":(o=this._createCanvasElement(),this.upperCanvasEl=o),b.util.addClass(o,"upper-canvas "+a),this.wrapperEl.appendChild(o),this._copyCanvasStyle(u,o),this._applyCanvasStyle(o),this.contextTop=o.getContext("2d")},_createCacheCanvas:function(){this.cacheCanvasEl=this._createCanvasElement(),this.cacheCanvasEl.setAttribute("width",this.width),this.cacheCanvasEl.setAttribute("height",this.height),this.contextCache=this.cacheCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=b.util.wrapElement(this.lowerCanvasEl,"div",{class:this.containerClass}),b.util.setStyle(this.wrapperEl,{width:this.width+"px",height:this.height+"px",position:"relative"}),b.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(a){var u=this.width||a.width,o=this.height||a.height;b.util.setStyle(a,{position:"absolute",width:u+"px",height:o+"px",left:0,top:0,"touch-action":this.allowTouchScrolling?"manipulation":"none","-ms-touch-action":this.allowTouchScrolling?"manipulation":"none"}),a.width=u,a.height=o,b.util.makeElementUnselectable(a)},_copyCanvasStyle:function(a,u){u.style.cssText=a.style.cssText},getSelectionContext:function(){return this.contextTop},getSelectionElement:function(){return this.upperCanvasEl},getActiveObject:function(){return this._activeObject},getActiveObjects:function(){var a=this._activeObject;return a?"activeSelection"===a.type&&a._objects?a._objects.slice(0):[a]:[]},_onObjectRemoved:function(a){a===this._activeObject&&(this.fire("before:selection:cleared",{target:a}),this._discardActiveObject(),this.fire("selection:cleared",{target:a}),a.fire("deselected")),a===this._hoveredTarget&&(this._hoveredTarget=null,this._hoveredTargets=[]),this.callSuper("_onObjectRemoved",a)},_fireSelectionEvents:function(a,u){var o=!1,h=this.getActiveObjects(),p=[],l=[];a.forEach(function(y){-1===h.indexOf(y)&&(o=!0,y.fire("deselected",{e:u,target:y}),l.push(y))}),h.forEach(function(y){-1===a.indexOf(y)&&(o=!0,y.fire("selected",{e:u,target:y}),p.push(y))}),a.length>0&&h.length>0?o&&this.fire("selection:updated",{e:u,selected:p,deselected:l}):h.length>0?this.fire("selection:created",{e:u,selected:p}):a.length>0&&this.fire("selection:cleared",{e:u,deselected:l})},setActiveObject:function(a,u){var o=this.getActiveObjects();return this._setActiveObject(a,u),this._fireSelectionEvents(o,u),this},_setActiveObject:function(a,u){return!(this._activeObject===a||!this._discardActiveObject(u,a)||a.onSelect({e:u})||(this._activeObject=a,0))},_discardActiveObject:function(a,u){var o=this._activeObject;if(o){if(o.onDeselect({e:a,object:u}))return!1;this._activeObject=null}return!0},discardActiveObject:function(a){var u=this.getActiveObjects(),o=this.getActiveObject();return u.length&&this.fire("before:selection:cleared",{target:o,e:a}),this._discardActiveObject(a),this._fireSelectionEvents(u,a),this},dispose:function(){var a=this.wrapperEl;return this.removeListeners(),a.removeChild(this.upperCanvasEl),a.removeChild(this.lowerCanvasEl),this.contextCache=null,this.contextTop=null,["upperCanvasEl","cacheCanvasEl"].forEach(function(u){b.util.cleanUpJsdomNode(this[u]),this[u]=void 0}.bind(this)),a.parentNode&&a.parentNode.replaceChild(this.lowerCanvasEl,this.wrapperEl),delete this.wrapperEl,b.StaticCanvas.prototype.dispose.call(this),this},clear:function(){return this.discardActiveObject(),this.clearContext(this.contextTop),this.callSuper("clear")},drawControls:function(a){var u=this._activeObject;u&&u._renderControls(a)},_toObject:function(a,u,o){var h=this._realizeGroupTransformOnObject(a),p=this.callSuper("_toObject",a,u,o);return this._unwindGroupTransformOnObject(a,h),p},_realizeGroupTransformOnObject:function(a){if(a.group&&"activeSelection"===a.group.type&&this._activeObject===a.group){var o={};return["angle","flipX","flipY","left","scaleX","scaleY","skewX","skewY","top"].forEach(function(h){o[h]=a[h]}),b.util.addTransformToObject(a,this._activeObject.calcOwnMatrix()),o}return null},_unwindGroupTransformOnObject:function(a,u){u&&a.set(u)},_setSVGObject:function(a,u,o){var h=this._realizeGroupTransformOnObject(u);this.callSuper("_setSVGObject",a,u,o),this._unwindGroupTransformOnObject(u,h)},setViewportTransform:function(a){this.renderOnAddRemove&&this._activeObject&&this._activeObject.isEditing&&this._activeObject.clearContextTop(),b.StaticCanvas.prototype.setViewportTransform.call(this,a)}}),b.StaticCanvas)"prototype"!==d&&(b.Canvas[d]=b.StaticCanvas[d])}(),function(){var v=b.util.addListener,f=b.util.removeListener,u={passive:!1};function o(h,p){return h.button&&h.button===p-1}b.util.object.extend(b.Canvas.prototype,{mainTouchId:null,_initEventListeners:function(){this.removeListeners(),this._bindEvents(),this.addOrRemove(v,"add")},_getEventPrefix:function(){return this.enablePointerEvents?"pointer":"mouse"},addOrRemove:function(h,p){var l=this.upperCanvasEl,y=this._getEventPrefix();h(b.window,"resize",this._onResize),h(l,y+"down",this._onMouseDown),h(l,y+"move",this._onMouseMove,u),h(l,y+"out",this._onMouseOut),h(l,y+"enter",this._onMouseEnter),h(l,"wheel",this._onMouseWheel),h(l,"contextmenu",this._onContextMenu),h(l,"dblclick",this._onDoubleClick),h(l,"dragover",this._onDragOver),h(l,"dragenter",this._onDragEnter),h(l,"dragleave",this._onDragLeave),h(l,"drop",this._onDrop),this.enablePointerEvents||h(l,"touchstart",this._onTouchStart,u),"undefined"!=typeof eventjs&&p in eventjs&&(eventjs[p](l,"gesture",this._onGesture),eventjs[p](l,"drag",this._onDrag),eventjs[p](l,"orientation",this._onOrientationChange),eventjs[p](l,"shake",this._onShake),eventjs[p](l,"longpress",this._onLongPress))},removeListeners:function(){this.addOrRemove(f,"remove");var h=this._getEventPrefix();f(b.document,h+"up",this._onMouseUp),f(b.document,"touchend",this._onTouchEnd,u),f(b.document,h+"move",this._onMouseMove,u),f(b.document,"touchmove",this._onMouseMove,u)},_bindEvents:function(){this.eventsBound||(this._onMouseDown=this._onMouseDown.bind(this),this._onTouchStart=this._onTouchStart.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onResize=this._onResize.bind(this),this._onGesture=this._onGesture.bind(this),this._onDrag=this._onDrag.bind(this),this._onShake=this._onShake.bind(this),this._onLongPress=this._onLongPress.bind(this),this._onOrientationChange=this._onOrientationChange.bind(this),this._onMouseWheel=this._onMouseWheel.bind(this),this._onMouseOut=this._onMouseOut.bind(this),this._onMouseEnter=this._onMouseEnter.bind(this),this._onContextMenu=this._onContextMenu.bind(this),this._onDoubleClick=this._onDoubleClick.bind(this),this._onDragOver=this._onDragOver.bind(this),this._onDragEnter=this._simpleEventHandler.bind(this,"dragenter"),this._onDragLeave=this._simpleEventHandler.bind(this,"dragleave"),this._onDrop=this._onDrop.bind(this),this.eventsBound=!0)},_onGesture:function(h,p){this.__onTransformGesture&&this.__onTransformGesture(h,p)},_onDrag:function(h,p){this.__onDrag&&this.__onDrag(h,p)},_onMouseWheel:function(h){this.__onMouseWheel(h)},_onMouseOut:function(h){var p=this._hoveredTarget;this.fire("mouse:out",{target:p,e:h}),this._hoveredTarget=null,p&&p.fire("mouseout",{e:h});var l=this;this._hoveredTargets.forEach(function(y){l.fire("mouse:out",{target:p,e:h}),y&&p.fire("mouseout",{e:h})}),this._hoveredTargets=[],this._iTextInstances&&this._iTextInstances.forEach(function(y){y.isEditing&&y.hiddenTextarea.focus()})},_onMouseEnter:function(h){!this._currentTransform&&!this.findTarget(h)&&(this.fire("mouse:over",{target:null,e:h}),this._hoveredTarget=null,this._hoveredTargets=[])},_onOrientationChange:function(h,p){this.__onOrientationChange&&this.__onOrientationChange(h,p)},_onShake:function(h,p){this.__onShake&&this.__onShake(h,p)},_onLongPress:function(h,p){this.__onLongPress&&this.__onLongPress(h,p)},_onDragOver:function(h){h.preventDefault();var p=this._simpleEventHandler("dragover",h);this._fireEnterLeaveEvents(p,h)},_onDrop:function(h){return this._simpleEventHandler("drop:before",h),this._simpleEventHandler("drop",h)},_onContextMenu:function(h){return this.stopContextMenu&&(h.stopPropagation(),h.preventDefault()),!1},_onDoubleClick:function(h){this._cacheTransformEventData(h),this._handleEvent(h,"dblclick"),this._resetTransformEventData(h)},getPointerId:function(h){var p=h.changedTouches;return p?p[0]&&p[0].identifier:this.enablePointerEvents?h.pointerId:-1},_isMainEvent:function(h){return!0===h.isPrimary||!1!==h.isPrimary&&("touchend"===h.type&&0===h.touches.length||!h.changedTouches||h.changedTouches[0].identifier===this.mainTouchId)},_onTouchStart:function(h){h.preventDefault(),null===this.mainTouchId&&(this.mainTouchId=this.getPointerId(h)),this.__onMouseDown(h),this._resetTransformEventData();var p=this.upperCanvasEl,l=this._getEventPrefix();v(b.document,"touchend",this._onTouchEnd,u),v(b.document,"touchmove",this._onMouseMove,u),f(p,l+"down",this._onMouseDown)},_onMouseDown:function(h){this.__onMouseDown(h),this._resetTransformEventData();var p=this.upperCanvasEl,l=this._getEventPrefix();f(p,l+"move",this._onMouseMove,u),v(b.document,l+"up",this._onMouseUp),v(b.document,l+"move",this._onMouseMove,u)},_onTouchEnd:function(h){if(!(h.touches.length>0)){this.__onMouseUp(h),this._resetTransformEventData(),this.mainTouchId=null;var p=this._getEventPrefix();f(b.document,"touchend",this._onTouchEnd,u),f(b.document,"touchmove",this._onMouseMove,u);var l=this;this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(function(){v(l.upperCanvasEl,p+"down",l._onMouseDown),l._willAddMouseDown=0},400)}},_onMouseUp:function(h){this.__onMouseUp(h),this._resetTransformEventData();var p=this.upperCanvasEl,l=this._getEventPrefix();this._isMainEvent(h)&&(f(b.document,l+"up",this._onMouseUp),f(b.document,l+"move",this._onMouseMove,u),v(p,l+"move",this._onMouseMove,u))},_onMouseMove:function(h){!this.allowTouchScrolling&&h.preventDefault&&h.preventDefault(),this.__onMouseMove(h)},_onResize:function(){this.calcOffset()},_shouldRender:function(h){var p=this._activeObject;return!!(!!p!=!!h||p&&h&&p!==h)},__onMouseUp:function(h){var p,l=this._currentTransform,y=this._groupSelector,C=!1,D=!y||0===y.left&&0===y.top;if(this._cacheTransformEventData(h),p=this._target,this._handleEvent(h,"up:before"),o(h,3))this.fireRightClick&&this._handleEvent(h,"up",3,D);else{if(o(h,2))return this.fireMiddleClick&&this._handleEvent(h,"up",2,D),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)this._onMouseUpInDrawingMode(h);else if(this._isMainEvent(h)){if(l&&(this._finalizeCurrentTransform(h),C=l.actionPerformed),!D){var E=p===this._activeObject;this._maybeGroupObjects(h),C||(C=this._shouldRender(p)||!E&&p===this._activeObject)}var T,I;if(p){if(T=p._findTargetCorner(this.getPointer(h,!0),b.util.isTouchEvent(h)),p.selectable&&p!==this._activeObject&&"up"===p.activeOn)this.setActiveObject(p,h),C=!0;else{var F=p.controls[T],B=F&&F.getMouseUpHandler(h,p,F);B&&B(h,l,(I=this.getPointer(h)).x,I.y)}p.isMoving=!1}if(l&&(l.target!==p||l.corner!==T)){var Y=l.target&&l.target.controls[l.corner],ie=Y&&Y.getMouseUpHandler(h,p,F);I=I||this.getPointer(h),ie&&ie(h,l,I.x,I.y)}this._setCursorFromEvent(h,p),this._handleEvent(h,"up",1,D),this._groupSelector=null,this._currentTransform=null,p&&(p.__corner=0),C?this.requestRenderAll():D||this.renderTop()}}},_simpleEventHandler:function(h,p){var l=this.findTarget(p),y=this.targets,C={e:p,target:l,subTargets:y};if(this.fire(h,C),l&&l.fire(h,C),!y)return l;for(var D=0;D<y.length;D++)y[D].fire(h,C);return l},_handleEvent:function(h,p,l,y){var C=this._target,D=this.targets||[],E={e:h,target:C,subTargets:D,button:l||1,isClick:y||!1,pointer:this._pointer,absolutePointer:this._absolutePointer,transform:this._currentTransform};"up"===p&&(E.currentTarget=this.findTarget(h),E.currentSubTargets=this.targets),this.fire("mouse:"+p,E),C&&C.fire("mouse"+p,E);for(var T=0;T<D.length;T++)D[T].fire("mouse"+p,E)},_finalizeCurrentTransform:function(h){var p=this._currentTransform,l=p.target,y={e:h,target:l,transform:p,action:p.action};l._scaling&&(l._scaling=!1),l.setCoords(),(p.actionPerformed||this.stateful&&l.hasStateChanged())&&this._fire("modified",y)},_onMouseDownInDrawingMode:function(h){this._isCurrentlyDrawing=!0,this.getActiveObject()&&this.discardActiveObject(h).requestRenderAll();var p=this.getPointer(h);this.freeDrawingBrush.onMouseDown(p,{e:h,pointer:p}),this._handleEvent(h,"down")},_onMouseMoveInDrawingMode:function(h){if(this._isCurrentlyDrawing){var p=this.getPointer(h);this.freeDrawingBrush.onMouseMove(p,{e:h,pointer:p})}this.setCursor(this.freeDrawingCursor),this._handleEvent(h,"move")},_onMouseUpInDrawingMode:function(h){var p=this.getPointer(h);this._isCurrentlyDrawing=this.freeDrawingBrush.onMouseUp({e:h,pointer:p}),this._handleEvent(h,"up")},__onMouseDown:function(h){this._cacheTransformEventData(h),this._handleEvent(h,"down:before");var p=this._target;if(o(h,3))this.fireRightClick&&this._handleEvent(h,"down",3);else if(o(h,2))this.fireMiddleClick&&this._handleEvent(h,"down",2);else if(this.isDrawingMode)this._onMouseDownInDrawingMode(h);else if(this._isMainEvent(h)&&!this._currentTransform){this._previousPointer=l=this._pointer;var y=this._shouldRender(p),C=this._shouldGroup(h,p);if(this._shouldClearSelection(h,p)?this.discardActiveObject(h):C&&(this._handleGrouping(h,p),p=this._activeObject),this.selection&&(!p||!p.selectable&&!p.isEditing&&p!==this._activeObject)&&(this._groupSelector={ex:this._absolutePointer.x,ey:this._absolutePointer.y,top:0,left:0}),p){var D=p===this._activeObject;p.selectable&&"down"===p.activeOn&&this.setActiveObject(p,h);var E=p._findTargetCorner(this.getPointer(h,!0),b.util.isTouchEvent(h));if(p.__corner=E,p===this._activeObject&&(E||!C)){this._setupCurrentTransform(h,p,D);var T=p.controls[E],l=this.getPointer(h),I=T&&T.getMouseDownHandler(h,p,T);I&&I(h,this._currentTransform,l.x,l.y)}}this._handleEvent(h,"down"),(y||C)&&this.requestRenderAll()}},_resetTransformEventData:function(){this._target=null,this._pointer=null,this._absolutePointer=null},_cacheTransformEventData:function(h){this._resetTransformEventData(),this._pointer=this.getPointer(h,!0),this._absolutePointer=this.restorePointerVpt(this._pointer),this._target=this._currentTransform?this._currentTransform.target:this.findTarget(h)||null},_beforeTransform:function(h){var p=this._currentTransform;this.stateful&&p.target.saveState(),this.fire("before:transform",{e:h,transform:p})},__onMouseMove:function(h){var p,l;if(this._handleEvent(h,"move:before"),this._cacheTransformEventData(h),this.isDrawingMode)this._onMouseMoveInDrawingMode(h);else if(this._isMainEvent(h)){var y=this._groupSelector;y?(y.left=(l=this._absolutePointer).x-y.ex,y.top=l.y-y.ey,this.renderTop()):this._currentTransform?this._transformObject(h):(p=this.findTarget(h)||null,this._setCursorFromEvent(h,p),this._fireOverOutEvents(p,h)),this._handleEvent(h,"move"),this._resetTransformEventData()}},_fireOverOutEvents:function(h,p){var l=this._hoveredTarget,y=this._hoveredTargets,C=this.targets,D=Math.max(y.length,C.length);this.fireSyntheticInOutEvents(h,p,{oldTarget:l,evtOut:"mouseout",canvasEvtOut:"mouse:out",evtIn:"mouseover",canvasEvtIn:"mouse:over"});for(var E=0;E<D;E++)this.fireSyntheticInOutEvents(C[E],p,{oldTarget:y[E],evtOut:"mouseout",evtIn:"mouseover"});this._hoveredTarget=h,this._hoveredTargets=this.targets.concat()},_fireEnterLeaveEvents:function(h,p){var l=this._draggedoverTarget,y=this._hoveredTargets,C=this.targets,D=Math.max(y.length,C.length);this.fireSyntheticInOutEvents(h,p,{oldTarget:l,evtOut:"dragleave",evtIn:"dragenter"});for(var E=0;E<D;E++)this.fireSyntheticInOutEvents(C[E],p,{oldTarget:y[E],evtOut:"dragleave",evtIn:"dragenter"});this._draggedoverTarget=h},fireSyntheticInOutEvents:function(h,p,l){var y,C,T,D=l.oldTarget,I=D!==h,F=l.canvasEvtIn,B=l.canvasEvtOut;I&&(y={e:p,target:h,previousTarget:D},C={e:p,target:D,nextTarget:h}),T=h&&I,D&&I&&(B&&this.fire(B,C),D.fire(l.evtOut,C)),T&&(F&&this.fire(F,y),h.fire(l.evtIn,y))},__onMouseWheel:function(h){this._cacheTransformEventData(h),this._handleEvent(h,"wheel"),this._resetTransformEventData()},_transformObject:function(h){var p=this.getPointer(h),l=this._currentTransform;l.reset=!1,l.shiftKey=h.shiftKey,l.altKey=h[this.centeredKey],this._performTransformAction(h,l,p),l.actionPerformed&&this.requestRenderAll()},_performTransformAction:function(h,p,l){var D=p.action,E=!1,T=p.actionHandler;T&&(E=T(h,p,l.x,l.y)),"drag"===D&&E&&(p.target.isMoving=!0,this.setCursor(p.target.moveCursor||this.moveCursor)),p.actionPerformed=p.actionPerformed||E},_fire:b.controlsUtils.fireEvent,_setCursorFromEvent:function(h,p){if(!p)return this.setCursor(this.defaultCursor),!1;var l=p.hoverCursor||this.hoverCursor,y=this._activeObject&&"activeSelection"===this._activeObject.type?this._activeObject:null,C=(!y||!y.contains(p))&&p._findTargetCorner(this.getPointer(h,!0));C?this.setCursor(this.getCornerCursor(C,p,h)):(p.subTargetCheck&&this.targets.concat().reverse().map(function(D){l=D.hoverCursor||l}),this.setCursor(l))},getCornerCursor:function(h,p,l){var y=p.controls[h];return y.cursorStyleHandler(l,y,p)}})}(),function(){var v=Math.min,f=Math.max;b.util.object.extend(b.Canvas.prototype,{_shouldGroup:function(m,d){var a=this._activeObject;return a&&this._isSelectionKeyPressed(m)&&d&&d.selectable&&this.selection&&(a!==d||"activeSelection"===a.type)&&!d.onSelect({e:m})},_handleGrouping:function(m,d){var a=this._activeObject;a.__corner||d===a&&(!(d=this.findTarget(m,!0))||!d.selectable)||(a&&"activeSelection"===a.type?this._updateActiveSelection(d,m):this._createActiveSelection(d,m))},_updateActiveSelection:function(m,d){var a=this._activeObject,u=a._objects.slice(0);a.contains(m)?(a.removeWithUpdate(m),this._hoveredTarget=m,this._hoveredTargets=this.targets.concat(),1===a.size()&&this._setActiveObject(a.item(0),d)):(a.addWithUpdate(m),this._hoveredTarget=a,this._hoveredTargets=this.targets.concat()),this._fireSelectionEvents(u,d)},_createActiveSelection:function(m,d){var a=this.getActiveObjects(),u=this._createGroup(m);this._hoveredTarget=u,this._setActiveObject(u,d),this._fireSelectionEvents(a,d)},_createGroup:function(m){var d=this._objects,u=d.indexOf(this._activeObject)<d.indexOf(m)?[this._activeObject,m]:[m,this._activeObject];return this._activeObject.isEditing&&this._activeObject.exitEditing(),new b.ActiveSelection(u,{canvas:this})},_groupSelectedObjects:function(m){var a,d=this._collectObjects(m);1===d.length?this.setActiveObject(d[0],m):d.length>1&&(a=new b.ActiveSelection(d.reverse(),{canvas:this}),this.setActiveObject(a,m))},_collectObjects:function(m){for(var a,d=[],u=this._groupSelector.ex,o=this._groupSelector.ey,h=u+this._groupSelector.left,p=o+this._groupSelector.top,l=new b.Point(v(u,h),v(o,p)),y=new b.Point(f(u,h),f(o,p)),C=!this.selectionFullyContained,D=u===h&&o===p,E=this._objects.length;E--&&!((a=this._objects[E])&&a.selectable&&a.visible&&(C&&a.intersectsWithRect(l,y,!0)||a.isContainedWithinRect(l,y,!0)||C&&a.containsPoint(l,null,!0)||C&&a.containsPoint(y,null,!0))&&(d.push(a),D)););return d.length>1&&(d=d.filter(function(T){return!T.onSelect({e:m})})),d},_maybeGroupObjects:function(m){this.selection&&this._groupSelector&&this._groupSelectedObjects(m),this.setCursor(this.defaultCursor),this._groupSelector=null}})}(),b.util.object.extend(b.StaticCanvas.prototype,{toDataURL:function(v){v||(v={});var f=v.format||"png",m=v.quality||1,d=(v.multiplier||1)*(v.enableRetinaScaling?this.getRetinaScaling():1),a=this.toCanvasElement(d,v);return b.util.toDataURL(a,f,m)},toCanvasElement:function(v,f){var m=((f=f||{}).width||this.width)*(v=v||1),d=(f.height||this.height)*v,a=this.getZoom(),u=this.width,o=this.height,h=a*v,p=this.viewportTransform,C=this.interactive,D=[h,0,0,h,(p[4]-(f.left||0))*v,(p[5]-(f.top||0))*v],E=this.enableRetinaScaling,T=b.util.createCanvasElement(),I=this.contextTop;return T.width=m,T.height=d,this.contextTop=null,this.enableRetinaScaling=!1,this.interactive=!1,this.viewportTransform=D,this.width=m,this.height=d,this.calcViewportBoundaries(),this.renderCanvas(T.getContext("2d"),this._objects),this.viewportTransform=p,this.width=u,this.height=o,this.calcViewportBoundaries(),this.interactive=C,this.enableRetinaScaling=E,this.contextTop=I,T}}),b.util.object.extend(b.StaticCanvas.prototype,{loadFromJSON:function(v,f,m){if(v){var d="string"==typeof v?JSON.parse(v):b.util.object.clone(v),a=this,u=d.clipPath,o=this.renderOnAddRemove;return this.renderOnAddRemove=!1,delete d.clipPath,this._enlivenObjects(d.objects,function(h){a.clear(),a._setBgOverlay(d,function(){u?a._enlivenObjects([u],function(p){a.clipPath=p[0],a.__setupCanvas.call(a,d,h,o,f)}):a.__setupCanvas.call(a,d,h,o,f)})},m),this}},__setupCanvas:function(v,f,m,d){var a=this;f.forEach(function(u,o){a.insertAt(u,o)}),this.renderOnAddRemove=m,delete v.objects,delete v.backgroundImage,delete v.overlayImage,delete v.background,delete v.overlay,this._setOptions(v),this.renderAll(),d&&d()},_setBgOverlay:function(v,f){var m={backgroundColor:!1,overlayColor:!1,backgroundImage:!1,overlayImage:!1};if(v.backgroundImage||v.overlayImage||v.background||v.overlay){var d=function(){m.backgroundImage&&m.overlayImage&&m.backgroundColor&&m.overlayColor&&f&&f()};this.__setBgOverlay("backgroundImage",v.backgroundImage,m,d),this.__setBgOverlay("overlayImage",v.overlayImage,m,d),this.__setBgOverlay("backgroundColor",v.background,m,d),this.__setBgOverlay("overlayColor",v.overlay,m,d)}else f&&f()},__setBgOverlay:function(v,f,m,d){var a=this;if(!f)return m[v]=!0,void(d&&d());"backgroundImage"===v||"overlayImage"===v?b.util.enlivenObjects([f],function(u){a[v]=u[0],m[v]=!0,d&&d()}):this["set"+b.util.string.capitalize(v,!0)](f,function(){m[v]=!0,d&&d()})},_enlivenObjects:function(v,f,m){v&&0!==v.length?b.util.enlivenObjects(v,function(d){f&&f(d)},null,m):f&&f([])},_toDataURL:function(v,f){this.clone(function(m){f(m.toDataURL(v))})},_toDataURLWithMultiplier:function(v,f,m){this.clone(function(d){m(d.toDataURLWithMultiplier(v,f))})},clone:function(v,f){var m=JSON.stringify(this.toJSON(f));this.cloneWithoutData(function(d){d.loadFromJSON(m,function(){v&&v(d)})})},cloneWithoutData:function(v){var f=b.util.createCanvasElement();f.width=this.width,f.height=this.height;var m=new b.Canvas(f);this.backgroundImage?(m.setBackgroundImage(this.backgroundImage.src,function(){m.renderAll(),v&&v(m)}),m.backgroundImageOpacity=this.backgroundImageOpacity,m.backgroundImageStretch=this.backgroundImageStretch):v&&v(m)}}),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.util.object.extend,d=f.util.object.clone,a=f.util.toFixed,u=f.util.string.capitalize,o=f.util.degreesToRadians;f.Object||(f.Object=f.util.createClass(f.CommonMethods,{type:"object",originX:"left",originY:"top",top:0,left:0,width:0,height:0,scaleX:1,scaleY:1,flipX:!1,flipY:!1,opacity:1,angle:0,skewX:0,skewY:0,cornerSize:13,touchCornerSize:24,transparentCorners:!0,hoverCursor:null,moveCursor:null,padding:0,borderColor:"rgb(178,204,255)",borderDashArray:null,cornerColor:"rgb(178,204,255)",cornerStrokeColor:null,cornerStyle:"rect",cornerDashArray:null,centeredScaling:!1,centeredRotation:!0,fill:"rgb(0,0,0)",fillRule:"nonzero",globalCompositeOperation:"source-over",backgroundColor:"",selectionBackgroundColor:"",stroke:null,strokeWidth:1,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,shadow:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,minScaleLimit:0,selectable:!0,evented:!0,visible:!0,hasControls:!0,hasBorders:!0,perPixelTargetFind:!1,includeDefaultValues:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,excludeFromExport:!1,objectCaching:!f.isLikelyNode,statefullCache:!1,noScaleCache:!0,strokeUniform:!1,dirty:!0,__corner:0,paintFirst:"fill",activeOn:"down",stateProperties:"top left width height scaleX scaleY flipX flipY originX originY transformMatrix stroke strokeWidth strokeDashArray strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit angle opacity fill globalCompositeOperation shadow visible backgroundColor skewX skewY fillRule paintFirst clipPath strokeUniform".split(" "),cacheProperties:"fill stroke strokeWidth strokeDashArray width height paintFirst strokeUniform strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit backgroundColor clipPath".split(" "),colorProperties:"fill stroke backgroundColor".split(" "),clipPath:void 0,inverted:!1,absolutePositioned:!1,initialize:function(l){l&&this.setOptions(l)},_createCacheCanvas:function(){this._cacheProperties={},this._cacheCanvas=f.util.createCanvasElement(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0},_limitCacheSize:function(l){var y=f.perfLimitSizeTotal,C=l.width,D=l.height,E=f.maxCacheSideLimit,T=f.minCacheSideLimit;if(C<=E&&D<=E&&C*D<=y)return C<T&&(l.width=T),D<T&&(l.height=T),l;var F=f.util.limitDimsByArea(C/D,y),B=f.util.capValue,Y=B(T,F.x,E),ie=B(T,F.y,E);return C>Y&&(l.zoomX/=C/Y,l.width=Y,l.capped=!0),D>ie&&(l.zoomY/=D/ie,l.height=ie,l.capped=!0),l},_getCacheCanvasDimensions:function(){var l=this.getTotalObjectScaling(),y=this._getTransformedDimensions(0,0),C=y.x*l.scaleX/this.scaleX,D=y.y*l.scaleY/this.scaleY;return{width:C+2,height:D+2,zoomX:l.scaleX,zoomY:l.scaleY,x:C,y:D}},_updateCacheCanvas:function(){var l=this.canvas;if(this.noScaleCache&&l&&l._currentTransform){var C=l._currentTransform.action;if(this===l._currentTransform.target&&C.slice&&"scale"===C.slice(0,5))return!1}var B,Y,D=this._cacheCanvas,E=this._limitCacheSize(this._getCacheCanvasDimensions()),T=f.minCacheSideLimit,I=E.width,F=E.height,ie=E.zoomX,le=E.zoomY,ue=I!==this.cacheWidth||F!==this.cacheHeight,he=ue||this.zoomX!==ie||this.zoomY!==le,ae=0,_e=0,be=!1;if(ue){var me=this._cacheCanvas.width,O=this._cacheCanvas.height,N=I>me||F>O;be=N||(I<.9*me||F<.9*O)&&me>T&&O>T,N&&!E.capped&&(I>T||F>T)&&(ae=.1*I,_e=.1*F)}return this instanceof f.Text&&this.path&&(he=!0,be=!0,ae+=this.getHeightOfLine(0)*this.zoomX,_e+=this.getHeightOfLine(0)*this.zoomY),!!he&&(be?(D.width=Math.ceil(I+ae),D.height=Math.ceil(F+_e)):(this._cacheContext.setTransform(1,0,0,1,0,0),this._cacheContext.clearRect(0,0,D.width,D.height)),B=E.x/2,Y=E.y/2,this.cacheTranslationX=Math.round(D.width/2-B)+B,this.cacheTranslationY=Math.round(D.height/2-Y)+Y,this.cacheWidth=I,this.cacheHeight=F,this._cacheContext.translate(this.cacheTranslationX,this.cacheTranslationY),this._cacheContext.scale(ie,le),this.zoomX=ie,this.zoomY=le,!0)},setOptions:function(l){this._setOptions(l),this._initGradient(l.fill,"fill"),this._initGradient(l.stroke,"stroke"),this._initPattern(l.fill,"fill"),this._initPattern(l.stroke,"stroke")},transform:function(l){var C=this.calcTransformMatrix(!(this.group&&!this.group._transformDone||this.group&&this.canvas&&l===this.canvas.contextTop));l.transform(C[0],C[1],C[2],C[3],C[4],C[5])},toObject:function(l){var y=f.Object.NUM_FRACTION_DIGITS,C={type:this.type,version:f.version,originX:this.originX,originY:this.originY,left:a(this.left,y),top:a(this.top,y),width:a(this.width,y),height:a(this.height,y),fill:this.fill&&this.fill.toObject?this.fill.toObject():this.fill,stroke:this.stroke&&this.stroke.toObject?this.stroke.toObject():this.stroke,strokeWidth:a(this.strokeWidth,y),strokeDashArray:this.strokeDashArray?this.strokeDashArray.concat():this.strokeDashArray,strokeLineCap:this.strokeLineCap,strokeDashOffset:this.strokeDashOffset,strokeLineJoin:this.strokeLineJoin,strokeUniform:this.strokeUniform,strokeMiterLimit:a(this.strokeMiterLimit,y),scaleX:a(this.scaleX,y),scaleY:a(this.scaleY,y),angle:a(this.angle,y),flipX:this.flipX,flipY:this.flipY,opacity:a(this.opacity,y),shadow:this.shadow&&this.shadow.toObject?this.shadow.toObject():this.shadow,visible:this.visible,backgroundColor:this.backgroundColor,fillRule:this.fillRule,paintFirst:this.paintFirst,globalCompositeOperation:this.globalCompositeOperation,skewX:a(this.skewX,y),skewY:a(this.skewY,y)};return this.clipPath&&!this.clipPath.excludeFromExport&&(C.clipPath=this.clipPath.toObject(l),C.clipPath.inverted=this.clipPath.inverted,C.clipPath.absolutePositioned=this.clipPath.absolutePositioned),f.util.populateWithProperties(this,C,l),this.includeDefaultValues||(C=this._removeDefaultValues(C)),C},toDatalessObject:function(l){return this.toObject(l)},_removeDefaultValues:function(l){var y=f.util.getKlass(l.type).prototype;return y.stateProperties.forEach(function(D){"left"!==D&&"top"!==D&&(l[D]===y[D]&&delete l[D],"[object Array]"===Object.prototype.toString.call(l[D])&&"[object Array]"===Object.prototype.toString.call(y[D])&&0===l[D].length&&0===y[D].length&&delete l[D])}),l},toString:function(){return"#<fabric."+u(this.type)+">"},getObjectScaling:function(){if(!this.group)return{scaleX:this.scaleX,scaleY:this.scaleY};var l=f.util.qrDecompose(this.calcTransformMatrix());return{scaleX:Math.abs(l.scaleX),scaleY:Math.abs(l.scaleY)}},getTotalObjectScaling:function(){var l=this.getObjectScaling(),y=l.scaleX,C=l.scaleY;if(this.canvas){var D=this.canvas.getZoom(),E=this.canvas.getRetinaScaling();y*=D*E,C*=D*E}return{scaleX:y,scaleY:C}},getObjectOpacity:function(){var l=this.opacity;return this.group&&(l*=this.group.getObjectOpacity()),l},_set:function(l,y){var D=this[l]!==y,E=!1;return("scaleX"===l||"scaleY"===l)&&(y=this._constrainScale(y)),"scaleX"===l&&y<0?(this.flipX=!this.flipX,y*=-1):"scaleY"===l&&y<0?(this.flipY=!this.flipY,y*=-1):"shadow"!==l||!y||y instanceof f.Shadow?"dirty"===l&&this.group&&this.group.set("dirty",y):y=new f.Shadow(y),this[l]=y,D&&(E=this.group&&this.group.isOnACache(),this.cacheProperties.indexOf(l)>-1?(this.dirty=!0,E&&this.group.set("dirty",!0)):E&&this.stateProperties.indexOf(l)>-1&&this.group.set("dirty",!0)),this},setOnGroup:function(){},getViewportTransform:function(){return this.canvas&&this.canvas.viewportTransform?this.canvas.viewportTransform:f.iMatrix.concat()},isNotVisible:function(){return 0===this.opacity||!this.width&&!this.height&&0===this.strokeWidth||!this.visible},render:function(l){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(l.save(),this._setupCompositeOperation(l),this.drawSelectionBackground(l),this.transform(l),this._setOpacity(l),this._setShadow(l,this),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(l)):(this._removeCacheCanvas(),this.dirty=!1,this.drawObject(l),this.objectCaching&&this.statefullCache&&this.saveState({propertySet:"cacheProperties"})),l.restore())},renderCache:function(l){l=l||{},this._cacheCanvas||this._createCacheCanvas(),this.isCacheDirty()&&(this.statefullCache&&this.saveState({propertySet:"cacheProperties"}),this.drawObject(this._cacheContext,l.forClipping),this.dirty=!1)},_removeCacheCanvas:function(){this._cacheCanvas=null,this.cacheWidth=0,this.cacheHeight=0},hasStroke:function(){return this.stroke&&"transparent"!==this.stroke&&0!==this.strokeWidth},hasFill:function(){return this.fill&&"transparent"!==this.fill},needsItsOwnCache:function(){return!!("stroke"===this.paintFirst&&this.hasFill()&&this.hasStroke()&&"object"==typeof this.shadow||this.clipPath)},shouldCache:function(){return this.ownCaching=this.needsItsOwnCache()||this.objectCaching&&(!this.group||!this.group.isOnACache()),this.ownCaching},willDrawShadow:function(){return!!this.shadow&&(0!==this.shadow.offsetX||0!==this.shadow.offsetY)},drawClipPathOnCache:function(l,y){if(l.save(),l.globalCompositeOperation=y.inverted?"destination-out":"destination-in",y.absolutePositioned){var C=f.util.invertTransform(this.calcTransformMatrix());l.transform(C[0],C[1],C[2],C[3],C[4],C[5])}y.transform(l),l.scale(1/y.zoomX,1/y.zoomY),l.drawImage(y._cacheCanvas,-y.cacheTranslationX,-y.cacheTranslationY),l.restore()},drawObject:function(l,y){var C=this.fill,D=this.stroke;y?(this.fill="black",this.stroke="",this._setClippingProperties(l)):this._renderBackground(l),this._render(l),this._drawClipPath(l,this.clipPath),this.fill=C,this.stroke=D},_drawClipPath:function(l,y){!y||(y.canvas=this.canvas,y.shouldCache(),y._transformDone=!0,y.renderCache({forClipping:!0}),this.drawClipPathOnCache(l,y))},drawCacheOnCanvas:function(l){l.scale(1/this.zoomX,1/this.zoomY),l.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)},isCacheDirty:function(l){if(this.isNotVisible())return!1;if(this._cacheCanvas&&!l&&this._updateCacheCanvas())return!0;if(this.dirty||this.clipPath&&this.clipPath.absolutePositioned||this.statefullCache&&this.hasStateChanged("cacheProperties")){if(this._cacheCanvas&&!l){var y=this.cacheWidth/this.zoomX,C=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-y/2,-C/2,y,C)}return!0}return!1},_renderBackground:function(l){if(this.backgroundColor){var y=this._getNonTransformedDimensions();l.fillStyle=this.backgroundColor,l.fillRect(-y.x/2,-y.y/2,y.x,y.y),this._removeShadow(l)}},_setOpacity:function(l){this.group&&!this.group._transformDone?l.globalAlpha=this.getObjectOpacity():l.globalAlpha*=this.opacity},_setStrokeStyles:function(l,y){var C=y.stroke;C&&(l.lineWidth=y.strokeWidth,l.lineCap=y.strokeLineCap,l.lineDashOffset=y.strokeDashOffset,l.lineJoin=y.strokeLineJoin,l.miterLimit=y.strokeMiterLimit,C.toLive?"percentage"===C.gradientUnits||C.gradientTransform||C.patternTransform?this._applyPatternForTransformedGradient(l,C):(l.strokeStyle=C.toLive(l,this),this._applyPatternGradientTransform(l,C)):l.strokeStyle=y.stroke)},_setFillStyles:function(l,y){var C=y.fill;C&&(C.toLive?(l.fillStyle=C.toLive(l,this),this._applyPatternGradientTransform(l,y.fill)):l.fillStyle=C)},_setClippingProperties:function(l){l.globalAlpha=1,l.strokeStyle="transparent",l.fillStyle="#000000"},_setLineDash:function(l,y){!y||0===y.length||(1&y.length&&y.push.apply(y,y),l.setLineDash(y))},_renderControls:function(l,y){var E,T,I,C=this.getViewportTransform(),D=this.calcTransformMatrix();T=void 0!==(y=y||{}).hasBorders?y.hasBorders:this.hasBorders,I=void 0!==y.hasControls?y.hasControls:this.hasControls,D=f.util.multiplyTransformMatrices(C,D),E=f.util.qrDecompose(D),l.save(),l.translate(E.translateX,E.translateY),l.lineWidth=1*this.borderScaleFactor,this.group||(l.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(E.angle-=180),l.rotate(o(this.group?E.angle:this.angle)),y.forActiveSelection||this.group?T&&this.drawBordersInGroup(l,E,y):T&&this.drawBorders(l,y),I&&this.drawControls(l,y),l.restore()},_setShadow:function(l){if(this.shadow){var D,y=this.shadow,C=this.canvas,E=C&&C.viewportTransform[0]||1,T=C&&C.viewportTransform[3]||1;D=y.nonScaling?{scaleX:1,scaleY:1}:this.getObjectScaling(),C&&C._isRetinaScaling()&&(E*=f.devicePixelRatio,T*=f.devicePixelRatio),l.shadowColor=y.color,l.shadowBlur=y.blur*f.browserShadowBlurConstant*(E+T)*(D.scaleX+D.scaleY)/4,l.shadowOffsetX=y.offsetX*E*D.scaleX,l.shadowOffsetY=y.offsetY*T*D.scaleY}},_removeShadow:function(l){!this.shadow||(l.shadowColor="",l.shadowBlur=l.shadowOffsetX=l.shadowOffsetY=0)},_applyPatternGradientTransform:function(l,y){if(!y||!y.toLive)return{offsetX:0,offsetY:0};var C=y.gradientTransform||y.patternTransform,D=-this.width/2+y.offsetX||0,E=-this.height/2+y.offsetY||0;return"percentage"===y.gradientUnits?l.transform(this.width,0,0,this.height,D,E):l.transform(1,0,0,1,D,E),C&&l.transform(C[0],C[1],C[2],C[3],C[4],C[5]),{offsetX:D,offsetY:E}},_renderPaintInOrder:function(l){"stroke"===this.paintFirst?(this._renderStroke(l),this._renderFill(l)):(this._renderFill(l),this._renderStroke(l))},_render:function(){},_renderFill:function(l){!this.fill||(l.save(),this._setFillStyles(l,this),"evenodd"===this.fillRule?l.fill("evenodd"):l.fill(),l.restore())},_renderStroke:function(l){if(this.stroke&&0!==this.strokeWidth){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(l),l.save(),this.strokeUniform&&this.group){var y=this.getObjectScaling();l.scale(1/y.scaleX,1/y.scaleY)}else this.strokeUniform&&l.scale(1/this.scaleX,1/this.scaleY);this._setLineDash(l,this.strokeDashArray),this._setStrokeStyles(l,this),l.stroke(),l.restore()}},_applyPatternForTransformedGradient:function(l,y){var E,C=this._limitCacheSize(this._getCacheCanvasDimensions()),D=f.util.createCanvasElement(),T=this.canvas.getRetinaScaling(),I=C.x/this.scaleX/T,F=C.y/this.scaleY/T;D.width=I,D.height=F,(E=D.getContext("2d")).beginPath(),E.moveTo(0,0),E.lineTo(I,0),E.lineTo(I,F),E.lineTo(0,F),E.closePath(),E.translate(I/2,F/2),E.scale(C.zoomX/this.scaleX/T,C.zoomY/this.scaleY/T),this._applyPatternGradientTransform(E,y),E.fillStyle=y.toLive(l),E.fill(),l.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),l.scale(T*this.scaleX/C.zoomX,T*this.scaleY/C.zoomY),l.strokeStyle=E.createPattern(D,"no-repeat")},_findCenterFromElement:function(){return{x:this.left+this.width/2,y:this.top+this.height/2}},_assignTransformMatrixProps:function(){if(this.transformMatrix){var l=f.util.qrDecompose(this.transformMatrix);this.flipX=!1,this.flipY=!1,this.set("scaleX",l.scaleX),this.set("scaleY",l.scaleY),this.angle=l.angle,this.skewX=l.skewX,this.skewY=0}},_removeTransformMatrix:function(l){var y=this._findCenterFromElement();this.transformMatrix&&(this._assignTransformMatrixProps(),y=f.util.transformPoint(y,this.transformMatrix)),this.transformMatrix=null,l&&(this.scaleX*=l.scaleX,this.scaleY*=l.scaleY,this.cropX=l.cropX,this.cropY=l.cropY,y.x+=l.offsetLeft,y.y+=l.offsetTop,this.width=l.width,this.height=l.height),this.setPositionByOrigin(y,"center","center")},clone:function(l,y){var C=this.toObject(y);this.constructor.fromObject?this.constructor.fromObject(C,l):f.Object._fromObject("Object",C,l)},cloneAsImage:function(l,y){var C=this.toCanvasElement(y);return l&&l(new f.Image(C)),this},toCanvasElement:function(l){l||(l={});var y=f.util,C=y.saveObjectTransform(this),D=this.group,E=this.shadow,T=Math.abs,I=(l.multiplier||1)*(l.enableRetinaScaling?f.devicePixelRatio:1);delete this.group,l.withoutTransform&&y.resetObjectTransform(this),l.withoutShadow&&(this.shadow=null);var ie,ue,he,F=f.util.createCanvasElement(),B=this.getBoundingRect(!0,!0),Y=this.shadow,le={x:0,y:0};Y&&(ue=Y.blur,ie=Y.nonScaling?{scaleX:1,scaleY:1}:this.getObjectScaling(),le.x=2*Math.round(T(Y.offsetX)+ue)*T(ie.scaleX),le.y=2*Math.round(T(Y.offsetY)+ue)*T(ie.scaleY)),he=B.height+le.y,F.width=Math.ceil(B.width+le.x),F.height=Math.ceil(he);var ae=new f.StaticCanvas(F,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1});"jpeg"===l.format&&(ae.backgroundColor="#fff"),this.setPositionByOrigin(new f.Point(ae.width/2,ae.height/2),"center","center");var _e=this.canvas;ae.add(this);var be=ae.toCanvasElement(I||1,l);return this.shadow=E,this.set("canvas",_e),D&&(this.group=D),this.set(C).setCoords(),ae._objects=[],ae.dispose(),ae=null,be},toDataURL:function(l){return l||(l={}),f.util.toDataURL(this.toCanvasElement(l),l.format||"png",l.quality||1)},isType:function(l){return this.type===l},complexity:function(){return 1},toJSON:function(l){return this.toObject(l)},rotate:function(l){var y=("center"!==this.originX||"center"!==this.originY)&&this.centeredRotation;return y&&this._setOriginToCenter(),this.set("angle",l),y&&this._resetOrigin(),this},centerH:function(){return this.canvas&&this.canvas.centerObjectH(this),this},viewportCenterH:function(){return this.canvas&&this.canvas.viewportCenterObjectH(this),this},centerV:function(){return this.canvas&&this.canvas.centerObjectV(this),this},viewportCenterV:function(){return this.canvas&&this.canvas.viewportCenterObjectV(this),this},center:function(){return this.canvas&&this.canvas.centerObject(this),this},viewportCenter:function(){return this.canvas&&this.canvas.viewportCenterObject(this),this},getLocalPointer:function(l,y){y=y||this.canvas.getPointer(l);var C=new f.Point(y.x,y.y),D=this._getLeftTopCoords();return this.angle&&(C=f.util.rotatePoint(C,D,o(-this.angle))),{x:C.x-D.x,y:C.y-D.y}},_setupCompositeOperation:function(l){this.globalCompositeOperation&&(l.globalCompositeOperation=this.globalCompositeOperation)},dispose:function(){f.runningAnimations&&f.runningAnimations.cancelByTarget(this)}}),f.util.createAccessors&&f.util.createAccessors(f.Object),m(f.Object.prototype,f.Observable),f.Object.NUM_FRACTION_DIGITS=2,f.Object.ENLIVEN_PROPS=["clipPath"],f.Object._fromObject=function(l,y,C,D){var E=f[l];y=d(y,!0),f.util.enlivenPatterns([y.fill,y.stroke],function(T){void 0!==T[0]&&(y.fill=T[0]),void 0!==T[1]&&(y.stroke=T[1]),f.util.enlivenObjectEnlivables(y,y,function(){var I=D?new E(y[D],y):new E(y);C&&C(I)})})},f.Object.__uid=0)}(Ee),function(){var v=b.util.degreesToRadians,f={left:-.5,center:0,right:.5},m={top:-.5,center:0,bottom:.5};b.util.object.extend(b.Object.prototype,{translateToGivenOrigin:function(d,a,u,o,h){var y,C,D,p=d.x,l=d.y;return"string"==typeof a?a=f[a]:a-=.5,"string"==typeof o?o=f[o]:o-=.5,"string"==typeof u?u=m[u]:u-=.5,"string"==typeof h?h=m[h]:h-=.5,C=h-u,((y=o-a)||C)&&(D=this._getTransformedDimensions(),p=d.x+y*D.x,l=d.y+C*D.y),new b.Point(p,l)},translateToCenterPoint:function(d,a,u){var o=this.translateToGivenOrigin(d,a,u,"center","center");return this.angle?b.util.rotatePoint(o,d,v(this.angle)):o},translateToOriginPoint:function(d,a,u){var o=this.translateToGivenOrigin(d,"center","center",a,u);return this.angle?b.util.rotatePoint(o,d,v(this.angle)):o},getCenterPoint:function(){var d=new b.Point(this.left,this.top);return this.translateToCenterPoint(d,this.originX,this.originY)},getPointByOrigin:function(d,a){var u=this.getCenterPoint();return this.translateToOriginPoint(u,d,a)},toLocalPoint:function(d,a,u){var h,p,o=this.getCenterPoint();return h=void 0!==a&&void 0!==u?this.translateToGivenOrigin(o,"center","center",a,u):new b.Point(this.left,this.top),p=new b.Point(d.x,d.y),this.angle&&(p=b.util.rotatePoint(p,o,-v(this.angle))),p.subtractEquals(h)},setPositionByOrigin:function(d,a,u){var o=this.translateToCenterPoint(d,a,u),h=this.translateToOriginPoint(o,this.originX,this.originY);this.set("left",h.x),this.set("top",h.y)},adjustPosition:function(d){var p,l,a=v(this.angle),u=this.getScaledWidth(),o=b.util.cos(a)*u,h=b.util.sin(a)*u;this.left+=o*((l="string"==typeof d?f[d]:d-.5)-(p="string"==typeof this.originX?f[this.originX]:this.originX-.5)),this.top+=h*(l-p),this.setCoords(),this.originX=d},_setOriginToCenter:function(){this._originalOriginX=this.originX,this._originalOriginY=this.originY;var d=this.getCenterPoint();this.originX="center",this.originY="center",this.left=d.x,this.top=d.y},_resetOrigin:function(){var d=this.translateToOriginPoint(this.getCenterPoint(),this._originalOriginX,this._originalOriginY);this.originX=this._originalOriginX,this.originY=this._originalOriginY,this.left=d.x,this.top=d.y,this._originalOriginX=null,this._originalOriginY=null},_getLeftTopCoords:function(){return this.translateToOriginPoint(this.getCenterPoint(),"left","top")}})}(),function(){var f=b.util,m=f.degreesToRadians,d=f.multiplyTransformMatrices,a=f.transformPoint;f.object.extend(b.Object.prototype,{oCoords:null,aCoords:null,lineCoords:null,ownMatrixCache:null,matrixCache:null,controls:{},_getCoords:function(u,o){return o?u?this.calcACoords():this.calcLineCoords():((!this.aCoords||!this.lineCoords)&&this.setCoords(!0),u?this.aCoords:this.lineCoords)},getCoords:function(u,o){return function(u){return[new b.Point(u.tl.x,u.tl.y),new b.Point(u.tr.x,u.tr.y),new b.Point(u.br.x,u.br.y),new b.Point(u.bl.x,u.bl.y)]}(this._getCoords(u,o))},intersectsWithRect:function(u,o,h,p){var l=this.getCoords(h,p);return"Intersection"===b.Intersection.intersectPolygonRectangle(l,u,o).status},intersectsWithObject:function(u,o,h){return"Intersection"===b.Intersection.intersectPolygonPolygon(this.getCoords(o,h),u.getCoords(o,h)).status||u.isContainedWithinObject(this,o,h)||this.isContainedWithinObject(u,o,h)},isContainedWithinObject:function(u,o,h){for(var p=this.getCoords(o,h),y=0,C=u._getImageLines(o?u.aCoords:u.lineCoords);y<4;y++)if(!u.containsPoint(p[y],C))return!1;return!0},isContainedWithinRect:function(u,o,h,p){var l=this.getBoundingRect(h,p);return l.left>=u.x&&l.left+l.width<=o.x&&l.top>=u.y&&l.top+l.height<=o.y},containsPoint:function(u,o,h,p){var l=this._getCoords(h,p),y=(o=o||this._getImageLines(l),this._findCrossPoints(u,o));return 0!==y&&y%2==1},isOnScreen:function(u){if(!this.canvas)return!1;var o=this.canvas.vptCoords.tl,h=this.canvas.vptCoords.br;return!(!this.getCoords(!0,u).some(function(l){return l.x<=h.x&&l.x>=o.x&&l.y<=h.y&&l.y>=o.y})&&!this.intersectsWithRect(o,h,!0,u))||this._containsCenterOfCanvas(o,h,u)},_containsCenterOfCanvas:function(u,o,h){return!!this.containsPoint({x:(u.x+o.x)/2,y:(u.y+o.y)/2},null,!0,h)},isPartiallyOnScreen:function(u){if(!this.canvas)return!1;var o=this.canvas.vptCoords.tl,h=this.canvas.vptCoords.br;return!!this.intersectsWithRect(o,h,!0,u)||this.getCoords(!0,u).every(function(l){return(l.x>=h.x||l.x<=o.x)&&(l.y>=h.y||l.y<=o.y)})&&this._containsCenterOfCanvas(o,h,u)},_getImageLines:function(u){return{topline:{o:u.tl,d:u.tr},rightline:{o:u.tr,d:u.br},bottomline:{o:u.br,d:u.bl},leftline:{o:u.bl,d:u.tl}}},_findCrossPoints:function(u,o){var p,l,y,C,E,D=0;for(var T in o)if(!((E=o[T]).o.y<u.y&&E.d.y<u.y||E.o.y>=u.y&&E.d.y>=u.y||(E.o.x===E.d.x&&E.o.x>=u.x?C=E.o.x:(p=(E.d.y-E.o.y)/(E.d.x-E.o.x),l=u.y-0*u.x,y=E.o.y-p*E.o.x,C=-(l-y)/(0-p)),C>=u.x&&(D+=1),2!==D)))break;return D},getBoundingRect:function(u,o){var h=this.getCoords(u,o);return f.makeBoundingBoxFromPoints(h)},getScaledWidth:function(){return this._getTransformedDimensions().x},getScaledHeight:function(){return this._getTransformedDimensions().y},_constrainScale:function(u){return Math.abs(u)<this.minScaleLimit?u<0?-this.minScaleLimit:this.minScaleLimit:0===u?1e-4:u},scale:function(u){return this._set("scaleX",u),this._set("scaleY",u),this.setCoords()},scaleToWidth:function(u,o){var h=this.getBoundingRect(o).width/this.getScaledWidth();return this.scale(u/this.width/h)},scaleToHeight:function(u,o){var h=this.getBoundingRect(o).height/this.getScaledHeight();return this.scale(u/this.height/h)},calcLineCoords:function(){var u=this.getViewportTransform(),o=this.padding,h=m(this.angle),y=f.cos(h)*o,C=f.sin(h)*o,D=y+C,E=y-C,T=this.calcACoords(),I={tl:a(T.tl,u),tr:a(T.tr,u),bl:a(T.bl,u),br:a(T.br,u)};return o&&(I.tl.x-=E,I.tl.y-=D,I.tr.x+=D,I.tr.y-=E,I.bl.x-=D,I.bl.y+=E,I.br.x+=E,I.br.y+=D),I},calcOCoords:function(){var u=this._calcRotateMatrix(),o=this._calcTranslateMatrix(),h=this.getViewportTransform(),p=d(h,o),l=d(p,u),y=(l=d(l,[1/h[0],0,0,1/h[3],0,0]),this._calculateCurrentDimensions()),C={};return this.forEachControl(function(D,E,T){C[E]=D.positionHandler(y,l,T)}),C},calcACoords:function(){var u=this._calcRotateMatrix(),o=this._calcTranslateMatrix(),h=d(o,u),p=this._getTransformedDimensions(),l=p.x/2,y=p.y/2;return{tl:a({x:-l,y:-y},h),tr:a({x:l,y:-y},h),bl:a({x:-l,y},h),br:a({x:l,y},h)}},setCoords:function(u){return this.aCoords=this.calcACoords(),this.lineCoords=this.group?this.aCoords:this.calcLineCoords(),u||(this.oCoords=this.calcOCoords(),this._setCornerCoords&&this._setCornerCoords()),this},_calcRotateMatrix:function(){return f.calcRotateMatrix(this)},_calcTranslateMatrix:function(){var u=this.getCenterPoint();return[1,0,0,1,u.x,u.y]},transformMatrixKey:function(u){var o="_",h="";return!u&&this.group&&(h=this.group.transformMatrixKey(u)+o),h+this.top+o+this.left+o+this.scaleX+o+this.scaleY+o+this.skewX+o+this.skewY+o+this.angle+o+this.originX+o+this.originY+o+this.width+o+this.height+o+this.strokeWidth+this.flipX+this.flipY},calcTransformMatrix:function(u){var o=this.calcOwnMatrix();if(u||!this.group)return o;var h=this.transformMatrixKey(u),p=this.matrixCache||(this.matrixCache={});return p.key===h?p.value:(this.group&&(o=d(this.group.calcTransformMatrix(!1),o)),p.key=h,p.value=o,o)},calcOwnMatrix:function(){var u=this.transformMatrixKey(!0),o=this.ownMatrixCache||(this.ownMatrixCache={});if(o.key===u)return o.value;var h=this._calcTranslateMatrix(),p={angle:this.angle,translateX:h[4],translateY:h[5],scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY};return o.key=u,o.value=f.composeMatrix(p),o.value},_getNonTransformedDimensions:function(){var u=this.strokeWidth;return{x:this.width+u,y:this.height+u}},_getTransformedDimensions:function(u,o){void 0===u&&(u=this.skewX),void 0===o&&(o=this.skewY);var h,p,l,y=0===u&&0===o;if(this.strokeUniform?(p=this.width,l=this.height):(p=(h=this._getNonTransformedDimensions()).x,l=h.y),y)return this._finalizeDimensions(p*this.scaleX,l*this.scaleY);var C=f.sizeAfterTransform(p,l,{scaleX:this.scaleX,scaleY:this.scaleY,skewX:u,skewY:o});return this._finalizeDimensions(C.x,C.y)},_finalizeDimensions:function(u,o){return this.strokeUniform?{x:u+this.strokeWidth,y:o+this.strokeWidth}:{x:u,y:o}},_calculateCurrentDimensions:function(){var u=this.getViewportTransform(),o=this._getTransformedDimensions();return a(o,u,!0).scalarAdd(2*this.padding)}})}(),b.util.object.extend(b.Object.prototype,{sendToBack:function(){return this.group?b.StaticCanvas.prototype.sendToBack.call(this.group,this):this.canvas&&this.canvas.sendToBack(this),this},bringToFront:function(){return this.group?b.StaticCanvas.prototype.bringToFront.call(this.group,this):this.canvas&&this.canvas.bringToFront(this),this},sendBackwards:function(v){return this.group?b.StaticCanvas.prototype.sendBackwards.call(this.group,this,v):this.canvas&&this.canvas.sendBackwards(this,v),this},bringForward:function(v){return this.group?b.StaticCanvas.prototype.bringForward.call(this.group,this,v):this.canvas&&this.canvas.bringForward(this,v),this},moveTo:function(v){return this.group&&"activeSelection"!==this.group.type?b.StaticCanvas.prototype.moveTo.call(this.group,this,v):this.canvas&&this.canvas.moveTo(this,v),this}}),function(){function v(m,d){if(d){if(d.toLive)return m+": url(#SVGID_"+d.id+"); ";var a=new b.Color(d),u=m+": "+a.toRgb()+"; ",o=a.getAlpha();return 1!==o&&(u+=m+"-opacity: "+o.toString()+"; "),u}return m+": none; "}var f=b.util.toFixed;b.util.object.extend(b.Object.prototype,{getSvgStyles:function(m){var d=this.fillRule?this.fillRule:"nonzero",a=this.strokeWidth?this.strokeWidth:"0",u=this.strokeDashArray?this.strokeDashArray.join(" "):"none",o=this.strokeDashOffset?this.strokeDashOffset:"0",h=this.strokeLineCap?this.strokeLineCap:"butt",p=this.strokeLineJoin?this.strokeLineJoin:"miter",l=this.strokeMiterLimit?this.strokeMiterLimit:"4",y=void 0!==this.opacity?this.opacity:"1",C=this.visible?"":" visibility: hidden;",D=m?"":this.getSvgFilter(),E=v("fill",this.fill);return[v("stroke",this.stroke),"stroke-width: ",a,"; ","stroke-dasharray: ",u,"; ","stroke-linecap: ",h,"; ","stroke-dashoffset: ",o,"; ","stroke-linejoin: ",p,"; ","stroke-miterlimit: ",l,"; ",E,"fill-rule: ",d,"; ","opacity: ",y,";",D,C].join("")},getSvgSpanStyles:function(m,d){var a="; ",u=m.fontFamily?"font-family: "+(-1===m.fontFamily.indexOf("'")&&-1===m.fontFamily.indexOf('"')?"'"+m.fontFamily+"'":m.fontFamily)+a:"",o=m.strokeWidth?"stroke-width: "+m.strokeWidth+a:"",h=(u=u,m.fontSize?"font-size: "+m.fontSize+"px"+a:""),p=m.fontStyle?"font-style: "+m.fontStyle+a:"",l=m.fontWeight?"font-weight: "+m.fontWeight+a:"",y=m.fill?v("fill",m.fill):"",C=m.stroke?v("stroke",m.stroke):"",D=this.getSvgTextDecoration(m);return D&&(D="text-decoration: "+D+a),[C,o,u,h,p,l,D,y,m.deltaY?"baseline-shift: "+-m.deltaY+"; ":"",d?"white-space: pre; ":""].join("")},getSvgTextDecoration:function(m){return["overline","underline","line-through"].filter(function(d){return m[d.replace("-","")]}).join(" ")},getSvgFilter:function(){return this.shadow?"filter: url(#SVGID_"+this.shadow.id+");":""},getSvgCommons:function(){return[this.id?'id="'+this.id+'" ':"",this.clipPath?'clip-path="url(#'+this.clipPath.clipPathId+')" ':""].join("")},getSvgTransform:function(m,d){var a=m?this.calcTransformMatrix():this.calcOwnMatrix();return'transform="'+b.util.matrixToSVG(a)+(d||"")+'" '},_setSVGBg:function(m){if(this.backgroundColor){var d=b.Object.NUM_FRACTION_DIGITS;m.push("\t\t<rect ",this._getFillAttributes(this.backgroundColor),' x="',f(-this.width/2,d),'" y="',f(-this.height/2,d),'" width="',f(this.width,d),'" height="',f(this.height,d),'"></rect>\n')}},toSVG:function(m){return this._createBaseSVGMarkup(this._toSVG(m),{reviver:m})},toClipPathSVG:function(m){return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(m),{reviver:m})},_createBaseClipPathSVGMarkup:function(m,d){var a=(d=d||{}).reviver,o=[this.getSvgTransform(!0,d.additionalTransform||""),this.getSvgCommons()].join(""),h=m.indexOf("COMMON_PARTS");return m[h]=o,a?a(m.join("")):m.join("")},_createBaseSVGMarkup:function(m,d){var T,F,a=(d=d||{}).noStyle,u=d.reviver,o=a?"":'style="'+this.getSvgStyles()+'" ',h=d.withShadow?'style="'+this.getSvgFilter()+'" ':"",p=this.clipPath,l=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",y=p&&p.absolutePositioned,C=this.stroke,D=this.fill,E=this.shadow,I=[],B=m.indexOf("COMMON_PARTS"),Y=d.additionalTransform;return p&&(p.clipPathId="CLIPPATH_"+b.Object.__uid++,F='<clipPath id="'+p.clipPathId+'" >\n'+p.toClipPathSVG(u)+"</clipPath>\n"),y&&I.push("<g ",h,this.getSvgCommons()," >\n"),I.push("<g ",this.getSvgTransform(!1),y?"":h+this.getSvgCommons()," >\n"),T=[o,l,a?"":this.addPaintOrder()," ",Y?'transform="'+Y+'" ':""].join(""),m[B]=T,D&&D.toLive&&I.push(D.toSVG(this)),C&&C.toLive&&I.push(C.toSVG(this)),E&&I.push(E.toSVG(this)),p&&I.push(F),I.push(m.join("")),I.push("</g>\n"),y&&I.push("</g>\n"),u?u(I.join("")):I.join("")},addPaintOrder:function(){return"fill"!==this.paintFirst?' paint-order="'+this.paintFirst+'" ':""}})}(),function(){var v=b.util.object.extend,f="stateProperties";function m(a,u,o){var h={};o.forEach(function(l){h[l]=a[l]}),v(a[u],h,!0)}function d(a,u,o){if(a===u)return!0;if(Array.isArray(a)){if(!Array.isArray(u)||a.length!==u.length)return!1;for(var h=0,p=a.length;h<p;h++)if(!d(a[h],u[h]))return!1;return!0}if(a&&"object"==typeof a){var y,l=Object.keys(a);if(!u||"object"!=typeof u||!o&&l.length!==Object.keys(u).length)return!1;for(h=0,p=l.length;h<p;h++)if("canvas"!==(y=l[h])&&"group"!==y&&!d(a[y],u[y]))return!1;return!0}}b.util.object.extend(b.Object.prototype,{hasStateChanged:function(a){var u="_"+(a=a||f);return Object.keys(this[u]).length<this[a].length||!d(this[u],this,!0)},saveState:function(a){var u=a&&a.propertySet||f,o="_"+u;return this[o]?(m(this,o,this[u]),a&&a.stateProperties&&m(this,o,a.stateProperties),this):this.setupState(a)},setupState:function(a){var u=(a=a||{}).propertySet||f;return a.propertySet=u,this["_"+u]={},this.saveState(a),this}})}(),function(){var v=b.util.degreesToRadians;b.util.object.extend(b.Object.prototype,{_findTargetCorner:function(f,m){if(!this.hasControls||this.group||!this.canvas||this.canvas._activeObject!==this)return!1;var u,o,l,d=f.x,a=f.y,h=Object.keys(this.oCoords),p=h.length-1;for(this.__corner=0;p>=0;p--)if(this.isControlVisible(l=h[p])&&(o=this._getImageLines(m?this.oCoords[l].touchCorner:this.oCoords[l].corner),0!==(u=this._findCrossPoints({x:d,y:a},o))&&u%2==1))return this.__corner=l,l;return!1},forEachControl:function(f){for(var m in this.controls)f(this.controls[m],m,this)},_setCornerCoords:function(){var f=this.oCoords;for(var m in f){var d=this.controls[m];f[m].corner=d.calcCornerCoords(this.angle,this.cornerSize,f[m].x,f[m].y,!1),f[m].touchCorner=d.calcCornerCoords(this.angle,this.touchCornerSize,f[m].x,f[m].y,!0)}},drawSelectionBackground:function(f){if(!this.selectionBackgroundColor||this.canvas&&!this.canvas.interactive||this.canvas&&this.canvas._activeObject!==this)return this;f.save();var m=this.getCenterPoint(),d=this._calculateCurrentDimensions(),a=this.canvas.viewportTransform;return f.translate(m.x,m.y),f.scale(1/a[0],1/a[3]),f.rotate(v(this.angle)),f.fillStyle=this.selectionBackgroundColor,f.fillRect(-d.x/2,-d.y/2,d.x,d.y),f.restore(),this},drawBorders:function(f,m){m=m||{};var d=this._calculateCurrentDimensions(),a=this.borderScaleFactor,u=d.x+a,o=d.y+a,h=void 0!==m.hasControls?m.hasControls:this.hasControls,p=!1;return f.save(),f.strokeStyle=m.borderColor||this.borderColor,this._setLineDash(f,m.borderDashArray||this.borderDashArray),f.strokeRect(-u/2,-o/2,u,o),h&&(f.beginPath(),this.forEachControl(function(l,y,C){l.withConnection&&l.getVisibility(C,y)&&(p=!0,f.moveTo(l.x*u,l.y*o),f.lineTo(l.x*u+l.offsetX,l.y*o+l.offsetY))}),p&&f.stroke()),f.restore(),this},drawBordersInGroup:function(f,m,d){d=d||{};var a=b.util.sizeAfterTransform(this.width,this.height,m),u=this.strokeWidth,o=this.strokeUniform,h=this.borderScaleFactor,p=a.x+u*(o?this.canvas.getZoom():m.scaleX)+h,l=a.y+u*(o?this.canvas.getZoom():m.scaleY)+h;return f.save(),this._setLineDash(f,d.borderDashArray||this.borderDashArray),f.strokeStyle=d.borderColor||this.borderColor,f.strokeRect(-p/2,-l/2,p,l),f.restore(),this},drawControls:function(f,m){m=m||{},f.save();var a,u,d=this.canvas.getRetinaScaling();return f.setTransform(d,0,0,d,0,0),f.strokeStyle=f.fillStyle=m.cornerColor||this.cornerColor,this.transparentCorners||(f.strokeStyle=m.cornerStrokeColor||this.cornerStrokeColor),this._setLineDash(f,m.cornerDashArray||this.cornerDashArray),this.setCoords(),this.group&&(a=this.group.calcTransformMatrix()),this.forEachControl(function(o,h,p){u=p.oCoords[h],o.getVisibility(p,h)&&(a&&(u=b.util.transformPoint(u,a)),o.render(f,u.x,u.y,m,p))}),f.restore(),this},isControlVisible:function(f){return this.controls[f]&&this.controls[f].getVisibility(this,f)},setControlVisible:function(f,m){return this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[f]=m,this},setControlsVisibility:function(f){for(var m in f||(f={}),f)this.setControlVisible(m,f[m]);return this},onDeselect:function(){},onSelect:function(){}})}(),b.util.object.extend(b.StaticCanvas.prototype,{FX_DURATION:500,fxCenterObjectH:function(v,f){var m=function(){},d=(f=f||{}).onComplete||m,a=f.onChange||m,u=this;return b.util.animate({target:this,startValue:v.left,endValue:this.getCenter().left,duration:this.FX_DURATION,onChange:function(o){v.set("left",o),u.requestRenderAll(),a()},onComplete:function(){v.setCoords(),d()}})},fxCenterObjectV:function(v,f){var m=function(){},d=(f=f||{}).onComplete||m,a=f.onChange||m,u=this;return b.util.animate({target:this,startValue:v.top,endValue:this.getCenter().top,duration:this.FX_DURATION,onChange:function(o){v.set("top",o),u.requestRenderAll(),a()},onComplete:function(){v.setCoords(),d()}})},fxRemove:function(v,f){var m=function(){},d=(f=f||{}).onComplete||m,a=f.onChange||m,u=this;return b.util.animate({target:this,startValue:v.opacity,endValue:0,duration:this.FX_DURATION,onChange:function(o){v.set("opacity",o),u.requestRenderAll(),a()},onComplete:function(){u.remove(v),d()}})}}),b.util.object.extend(b.Object.prototype,{animate:function(){if(arguments[0]&&"object"==typeof arguments[0]){var f,v=[],d=[];for(f in arguments[0])v.push(f);for(var a=0,u=v.length;a<u;a++)d.push(this._animate(f=v[a],arguments[0][f],arguments[1],a!==u-1));return d}return this._animate.apply(this,arguments)},_animate:function(v,f,m,d){var u,a=this;f=f.toString(),m=m?b.util.object.clone(m):{},~v.indexOf(".")&&(u=v.split("."));var o=a.colorProperties.indexOf(v)>-1||u&&a.colorProperties.indexOf(u[1])>-1,h=u?this.get(u[0])[u[1]]:this.get(v);"from"in m||(m.from=h),o||(f=~f.indexOf("=")?h+parseFloat(f.replace("=","")):parseFloat(f));var p={target:this,startValue:m.from,endValue:f,byValue:m.by,easing:m.easing,duration:m.duration,abort:m.abort&&function(l,y,C){return m.abort.call(a,l,y,C)},onChange:function(l,y,C){u?a[u[0]][u[1]]=l:a.set(v,l),!d&&m.onChange&&m.onChange(l,y,C)},onComplete:function(l,y,C){d||(a.setCoords(),m.onComplete&&m.onComplete(l,y,C))}};return o?b.util.animateColor(p.startValue,p.endValue,p.duration,p):b.util.animate(p)}}),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.util.object.extend,d=f.util.object.clone,a={x1:1,x2:1,y1:1,y2:1};function u(o,h){var p=o.origin,l=o.axis1,y=o.axis2,C=o.dimension,D=h.nearest,E=h.center,T=h.farthest;return function(){switch(this.get(p)){case D:return Math.min(this.get(l),this.get(y));case E:return Math.min(this.get(l),this.get(y))+.5*this.get(C);case T:return Math.max(this.get(l),this.get(y))}}}f.Line?f.warn("fabric.Line is already defined"):(f.Line=f.util.createClass(f.Object,{type:"line",x1:0,y1:0,x2:0,y2:0,cacheProperties:f.Object.prototype.cacheProperties.concat("x1","x2","y1","y2"),initialize:function(o,h){o||(o=[0,0,0,0]),this.callSuper("initialize",h),this.set("x1",o[0]),this.set("y1",o[1]),this.set("x2",o[2]),this.set("y2",o[3]),this._setWidthHeight(h)},_setWidthHeight:function(o){o||(o={}),this.width=Math.abs(this.x2-this.x1),this.height=Math.abs(this.y2-this.y1),this.left="left"in o?o.left:this._getLeftToOriginX(),this.top="top"in o?o.top:this._getTopToOriginY()},_set:function(o,h){return this.callSuper("_set",o,h),void 0!==a[o]&&this._setWidthHeight(),this},_getLeftToOriginX:u({origin:"originX",axis1:"x1",axis2:"x2",dimension:"width"},{nearest:"left",center:"center",farthest:"right"}),_getTopToOriginY:u({origin:"originY",axis1:"y1",axis2:"y2",dimension:"height"},{nearest:"top",center:"center",farthest:"bottom"}),_render:function(o){o.beginPath();var h=this.calcLinePoints();o.moveTo(h.x1,h.y1),o.lineTo(h.x2,h.y2),o.lineWidth=this.strokeWidth;var p=o.strokeStyle;o.strokeStyle=this.stroke||o.fillStyle,this.stroke&&this._renderStroke(o),o.strokeStyle=p},_findCenterFromElement:function(){return{x:(this.x1+this.x2)/2,y:(this.y1+this.y2)/2}},toObject:function(o){return m(this.callSuper("toObject",o),this.calcLinePoints())},_getNonTransformedDimensions:function(){var o=this.callSuper("_getNonTransformedDimensions");return"butt"===this.strokeLineCap&&(0===this.width&&(o.y-=this.strokeWidth),0===this.height&&(o.x-=this.strokeWidth)),o},calcLinePoints:function(){var o=this.x1<=this.x2?-1:1,h=this.y1<=this.y2?-1:1;return{x1:o*this.width*.5,x2:o*this.width*-.5,y1:h*this.height*.5,y2:h*this.height*-.5}},_toSVG:function(){var o=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="',o.x1,'" y1="',o.y1,'" x2="',o.x2,'" y2="',o.y2,'" />\n']}}),f.Line.ATTRIBUTE_NAMES=f.SHARED_ATTRIBUTES.concat("x1 y1 x2 y2".split(" ")),f.Line.fromElement=function(o,h,p){p=p||{};var l=f.parseAttributes(o,f.Line.ATTRIBUTE_NAMES);h(new f.Line([l.x1||0,l.y1||0,l.x2||0,l.y2||0],m(l,p)))},f.Line.fromObject=function(o,h){var l=d(o,!0);l.points=[o.x1,o.y1,o.x2,o.y2],f.Object._fromObject("Line",l,function(y){delete y.points,h&&h(y)},"points")})}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.util.degreesToRadians;f.Circle?f.warn("fabric.Circle is already defined."):(f.Circle=f.util.createClass(f.Object,{type:"circle",radius:0,startAngle:0,endAngle:360,cacheProperties:f.Object.prototype.cacheProperties.concat("radius","startAngle","endAngle"),_set:function(a,u){return this.callSuper("_set",a,u),"radius"===a&&this.setRadius(u),this},toObject:function(a){return this.callSuper("toObject",["radius","startAngle","endAngle"].concat(a))},_toSVG:function(){var a,h=(this.endAngle-this.startAngle)%360;if(0===h)a=["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',this.radius,'" />\n'];else{var p=m(this.startAngle),l=m(this.endAngle),y=this.radius;a=['<path d="M '+f.util.cos(p)*y+" "+f.util.sin(p)*y," A "+y+" "+y," 0 ",+(h>180?"1":"0")+" 1"," "+f.util.cos(l)*y+" "+f.util.sin(l)*y,'" ',"COMMON_PARTS"," />\n"]}return a},_render:function(a){a.beginPath(),a.arc(0,0,this.radius,m(this.startAngle),m(this.endAngle),!1),this._renderPaintInOrder(a)},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(a){return this.radius=a,this.set("width",2*a).set("height",2*a)}}),f.Circle.ATTRIBUTE_NAMES=f.SHARED_ATTRIBUTES.concat("cx cy r".split(" ")),f.Circle.fromElement=function(a,u){var o=f.parseAttributes(a,f.Circle.ATTRIBUTE_NAMES);if(!function(a){return"radius"in a&&a.radius>=0}(o))throw new Error("value of `r` attribute is required and can not be negative");o.left=(o.left||0)-o.radius,o.top=(o.top||0)-o.radius,u(new f.Circle(o))},f.Circle.fromObject=function(a,u){f.Object._fromObject("Circle",a,u)})}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={});f.Triangle?f.warn("fabric.Triangle is already defined"):(f.Triangle=f.util.createClass(f.Object,{type:"triangle",width:100,height:100,_render:function(m){var d=this.width/2,a=this.height/2;m.beginPath(),m.moveTo(-d,a),m.lineTo(0,-a),m.lineTo(d,a),m.closePath(),this._renderPaintInOrder(m)},_toSVG:function(){var m=this.width/2,d=this.height/2;return["<polygon ","COMMON_PARTS",'points="',[-m+" "+d,"0 "+-d,m+" "+d].join(","),'" />']}}),f.Triangle.fromObject=function(m,d){return f.Object._fromObject("Triangle",m,d)})}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=2*Math.PI;f.Ellipse?f.warn("fabric.Ellipse is already defined."):(f.Ellipse=f.util.createClass(f.Object,{type:"ellipse",rx:0,ry:0,cacheProperties:f.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(d){this.callSuper("initialize",d),this.set("rx",d&&d.rx||0),this.set("ry",d&&d.ry||0)},_set:function(d,a){switch(this.callSuper("_set",d,a),d){case"rx":this.rx=a,this.set("width",2*a);break;case"ry":this.ry=a,this.set("height",2*a)}return this},getRx:function(){return this.get("rx")*this.get("scaleX")},getRy:function(){return this.get("ry")*this.get("scaleY")},toObject:function(d){return this.callSuper("toObject",["rx","ry"].concat(d))},_toSVG:function(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" ','rx="',this.rx,'" ry="',this.ry,'" />\n']},_render:function(d){d.beginPath(),d.save(),d.transform(1,0,0,this.ry/this.rx,0,0),d.arc(0,0,this.rx,0,m,!1),d.restore(),this._renderPaintInOrder(d)}}),f.Ellipse.ATTRIBUTE_NAMES=f.SHARED_ATTRIBUTES.concat("cx cy rx ry".split(" ")),f.Ellipse.fromElement=function(d,a){var u=f.parseAttributes(d,f.Ellipse.ATTRIBUTE_NAMES);u.left=(u.left||0)-u.rx,u.top=(u.top||0)-u.ry,a(new f.Ellipse(u))},f.Ellipse.fromObject=function(d,a){f.Object._fromObject("Ellipse",d,a)})}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.util.object.extend;f.Rect?f.warn("fabric.Rect is already defined"):(f.Rect=f.util.createClass(f.Object,{stateProperties:f.Object.prototype.stateProperties.concat("rx","ry"),type:"rect",rx:0,ry:0,cacheProperties:f.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(d){this.callSuper("initialize",d),this._initRxRy()},_initRxRy:function(){this.rx&&!this.ry?this.ry=this.rx:this.ry&&!this.rx&&(this.rx=this.ry)},_render:function(d){var a=this.rx?Math.min(this.rx,this.width/2):0,u=this.ry?Math.min(this.ry,this.height/2):0,o=this.width,h=this.height,p=-this.width/2,l=-this.height/2,y=0!==a||0!==u,C=.4477152502;d.beginPath(),d.moveTo(p+a,l),d.lineTo(p+o-a,l),y&&d.bezierCurveTo(p+o-C*a,l,p+o,l+C*u,p+o,l+u),d.lineTo(p+o,l+h-u),y&&d.bezierCurveTo(p+o,l+h-C*u,p+o-C*a,l+h,p+o-a,l+h),d.lineTo(p+a,l+h),y&&d.bezierCurveTo(p+C*a,l+h,p,l+h-C*u,p,l+h-u),d.lineTo(p,l+u),y&&d.bezierCurveTo(p,l+C*u,p+C*a,l,p+a,l),d.closePath(),this._renderPaintInOrder(d)},toObject:function(d){return this.callSuper("toObject",["rx","ry"].concat(d))},_toSVG:function(){return["<rect ","COMMON_PARTS",'x="',-this.width/2,'" y="',-this.height/2,'" rx="',this.rx,'" ry="',this.ry,'" width="',this.width,'" height="',this.height,'" />\n']}}),f.Rect.ATTRIBUTE_NAMES=f.SHARED_ATTRIBUTES.concat("x y rx ry width height".split(" ")),f.Rect.fromElement=function(d,a,u){if(!d)return a(null);u=u||{};var o=f.parseAttributes(d,f.Rect.ATTRIBUTE_NAMES);o.left=o.left||0,o.top=o.top||0,o.height=o.height||0,o.width=o.width||0;var h=new f.Rect(m(u?f.util.object.clone(u):{},o));h.visible=h.visible&&h.width>0&&h.height>0,a(h)},f.Rect.fromObject=function(d,a){return f.Object._fromObject("Rect",d,a)})}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.util.object.extend,d=f.util.array.min,a=f.util.array.max,u=f.util.toFixed,o=f.util.projectStrokeOnPoints;f.Polyline?f.warn("fabric.Polyline is already defined"):(f.Polyline=f.util.createClass(f.Object,{type:"polyline",points:null,exactBoundingBox:!1,cacheProperties:f.Object.prototype.cacheProperties.concat("points"),initialize:function(h,p){p=p||{},this.points=h||[],this.callSuper("initialize",p),this._setPositionDimensions(p)},_projectStrokeOnPoints:function(){return o(this.points,this,!0)},_setPositionDimensions:function(h){var l,p=this._calcDimensions(h),y=this.exactBoundingBox?this.strokeWidth:0;this.width=p.width-y,this.height=p.height-y,h.fromSVG||(l=this.translateToGivenOrigin({x:p.left-this.strokeWidth/2+y/2,y:p.top-this.strokeWidth/2+y/2},"left","top",this.originX,this.originY)),void 0===h.left&&(this.left=h.fromSVG?p.left:l.x),void 0===h.top&&(this.top=h.fromSVG?p.top:l.y),this.pathOffset={x:p.left+this.width/2+y/2,y:p.top+this.height/2+y/2}},_calcDimensions:function(){var h=this.exactBoundingBox?this._projectStrokeOnPoints():this.points,p=d(h,"x")||0,l=d(h,"y")||0;return{left:p,top:l,width:(a(h,"x")||0)-p,height:(a(h,"y")||0)-l}},toObject:function(h){return m(this.callSuper("toObject",h),{points:this.points.concat()})},_toSVG:function(){for(var h=[],p=this.pathOffset.x,l=this.pathOffset.y,y=f.Object.NUM_FRACTION_DIGITS,C=0,D=this.points.length;C<D;C++)h.push(u(this.points[C].x-p,y),",",u(this.points[C].y-l,y)," ");return["<"+this.type+" ","COMMON_PARTS",'points="',h.join(""),'" />\n']},commonRender:function(h){var p,l=this.points.length,y=this.pathOffset.x,C=this.pathOffset.y;if(!l||isNaN(this.points[l-1].y))return!1;h.beginPath(),h.moveTo(this.points[0].x-y,this.points[0].y-C);for(var D=0;D<l;D++)h.lineTo((p=this.points[D]).x-y,p.y-C);return!0},_render:function(h){!this.commonRender(h)||this._renderPaintInOrder(h)},complexity:function(){return this.get("points").length}}),f.Polyline.ATTRIBUTE_NAMES=f.SHARED_ATTRIBUTES.concat(),f.Polyline.fromElementGenerator=function(h){return function(p,l,y){if(!p)return l(null);y||(y={});var C=f.parsePointsAttribute(p.getAttribute("points")),D=f.parseAttributes(p,f[h].ATTRIBUTE_NAMES);D.fromSVG=!0,l(new f[h](C,m(D,y)))}},f.Polyline.fromElement=f.Polyline.fromElementGenerator("Polyline"),f.Polyline.fromObject=function(h,p){return f.Object._fromObject("Polyline",h,p,"points")})}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.util.projectStrokeOnPoints;f.Polygon?f.warn("fabric.Polygon is already defined"):(f.Polygon=f.util.createClass(f.Polyline,{type:"polygon",_projectStrokeOnPoints:function(){return m(this.points,this)},_render:function(d){!this.commonRender(d)||(d.closePath(),this._renderPaintInOrder(d))}}),f.Polygon.ATTRIBUTE_NAMES=f.SHARED_ATTRIBUTES.concat(),f.Polygon.fromElement=f.Polyline.fromElementGenerator("Polygon"),f.Polygon.fromObject=function(d,a){f.Object._fromObject("Polygon",d,a,"points")})}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.util.array.min,d=f.util.array.max,a=f.util.object.extend,u=f.util.object.clone,o=Object.prototype.toString,h=f.util.toFixed;f.Path?f.warn("fabric.Path is already defined"):(f.Path=f.util.createClass(f.Object,{type:"path",path:null,cacheProperties:f.Object.prototype.cacheProperties.concat("path","fillRule"),stateProperties:f.Object.prototype.stateProperties.concat("path"),initialize:function(p,l){delete(l=u(l||{})).path,this.callSuper("initialize",l),this._setPath(p||[],l)},_setPath:function(p,l){var y="[object Array]"===o.call(p);this.path=f.util.makePathSimpler(y?p:f.util.parsePath(p)),f.Polyline.prototype._setPositionDimensions.call(this,l||{})},_renderPathCommands:function(p){var l,y=0,C=0,D=0,E=0,F=-this.pathOffset.x,B=-this.pathOffset.y;p.beginPath();for(var Y=0,ie=this.path.length;Y<ie;++Y)switch(l=this.path[Y],l[0]){case"L":p.lineTo((D=l[1])+F,(E=l[2])+B);break;case"M":y=D=l[1],C=E=l[2],p.moveTo(D+F,E+B);break;case"C":p.bezierCurveTo(l[1]+F,l[2]+B,l[3]+F,l[4]+B,(D=l[5])+F,(E=l[6])+B);break;case"Q":p.quadraticCurveTo(l[1]+F,l[2]+B,l[3]+F,l[4]+B),D=l[3],E=l[4];break;case"z":case"Z":D=y,E=C,p.closePath()}},_render:function(p){this._renderPathCommands(p),this._renderPaintInOrder(p)},toString:function(){return"#<fabric.Path ("+this.complexity()+'): { "top": '+this.top+', "left": '+this.left+" }>"},toObject:function(p){return a(this.callSuper("toObject",p),{path:this.path.map(function(l){return l.slice()})})},toDatalessObject:function(p){var l=this.toObject(["sourcePath"].concat(p));return l.sourcePath&&delete l.path,l},_toSVG:function(){return["<path ","COMMON_PARTS",'d="',f.util.joinPath(this.path),'" stroke-linecap="round" ',"/>\n"]},_getOffsetTransform:function(){var p=f.Object.NUM_FRACTION_DIGITS;return" translate("+h(-this.pathOffset.x,p)+", "+h(-this.pathOffset.y,p)+")"},toClipPathSVG:function(p){var l=this._getOffsetTransform();return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:p,additionalTransform:l})},toSVG:function(p){var l=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:p,additionalTransform:l})},complexity:function(){return this.path.length},_calcDimensions:function(){for(var y,I,p=[],l=[],C=0,D=0,E=0,T=0,F=0,B=this.path.length;F<B;++F){switch((y=this.path[F])[0]){case"L":E=y[1],T=y[2],I=[];break;case"M":C=E=y[1],D=T=y[2],I=[];break;case"C":I=f.util.getBoundsOfCurve(E,T,y[1],y[2],y[3],y[4],y[5],y[6]),E=y[5],T=y[6];break;case"Q":I=f.util.getBoundsOfCurve(E,T,y[1],y[2],y[1],y[2],y[3],y[4]),E=y[3],T=y[4];break;case"z":case"Z":E=C,T=D}I.forEach(function(ae){p.push(ae.x),l.push(ae.y)}),p.push(E),l.push(T)}var Y=m(p)||0,ie=m(l)||0;return{left:Y,top:ie,width:(d(p)||0)-Y,height:(d(l)||0)-ie}}}),f.Path.fromObject=function(p,l){"string"==typeof p.sourcePath?f.loadSVGFromURL(p.sourcePath,function(C){var D=C[0];D.setOptions(p),l&&l(D)}):f.Object._fromObject("Path",p,l,"path")},f.Path.ATTRIBUTE_NAMES=f.SHARED_ATTRIBUTES.concat(["d"]),f.Path.fromElement=function(p,l,y){var C=f.parseAttributes(p,f.Path.ATTRIBUTE_NAMES);C.fromSVG=!0,l(new f.Path(C.d,a(C,y)))})}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.util.array.min,d=f.util.array.max;f.Group||(f.Group=f.util.createClass(f.Object,f.Collection,{type:"group",strokeWidth:0,subTargetCheck:!1,cacheProperties:[],useSetOnGroup:!1,initialize:function(a,u,o){u=u||{},this._objects=[],o&&this.callSuper("initialize",u),this._objects=a||[];for(var h=this._objects.length;h--;)this._objects[h].group=this;if(o)this._updateObjectsACoords();else{var p=u&&u.centerPoint;void 0!==u.originX&&(this.originX=u.originX),void 0!==u.originY&&(this.originY=u.originY),p||this._calcBounds(),this._updateObjectsCoords(p),delete u.centerPoint,this.callSuper("initialize",u)}this.setCoords()},_updateObjectsACoords:function(){for(var u=this._objects.length;u--;)this._objects[u].setCoords(!0)},_updateObjectsCoords:function(a){a=a||this.getCenterPoint();for(var u=this._objects.length;u--;)this._updateObjectCoords(this._objects[u],a)},_updateObjectCoords:function(a,u){a.set({left:a.left-u.x,top:a.top-u.y}),a.group=this,a.setCoords(!0)},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},addWithUpdate:function(a){var u=!!this.group;return this._restoreObjectsState(),f.util.resetObjectTransform(this),a&&(u&&f.util.removeTransformFromObject(a,this.group.calcTransformMatrix()),this._objects.push(a),a.group=this,a._set("canvas",this.canvas)),this._calcBounds(),this._updateObjectsCoords(),this.dirty=!0,u?this.group.addWithUpdate():this.setCoords(),this},removeWithUpdate:function(a){return this._restoreObjectsState(),f.util.resetObjectTransform(this),this.remove(a),this._calcBounds(),this._updateObjectsCoords(),this.setCoords(),this.dirty=!0,this},_onObjectAdded:function(a){this.dirty=!0,a.group=this,a._set("canvas",this.canvas)},_onObjectRemoved:function(a){this.dirty=!0,delete a.group},_set:function(a,u){var o=this._objects.length;if(this.useSetOnGroup)for(;o--;)this._objects[o].setOnGroup(a,u);if("canvas"===a)for(;o--;)this._objects[o]._set(a,u);f.Object.prototype._set.call(this,a,u)},toObject:function(a){var u=this.includeDefaultValues,o=this._objects.filter(function(p){return!p.excludeFromExport}).map(function(p){var l=p.includeDefaultValues;p.includeDefaultValues=u;var y=p.toObject(a);return p.includeDefaultValues=l,y}),h=f.Object.prototype.toObject.call(this,a);return h.objects=o,h},toDatalessObject:function(a){var u,o=this.sourcePath;if(o)u=o;else{var h=this.includeDefaultValues;u=this._objects.map(function(l){var y=l.includeDefaultValues;l.includeDefaultValues=h;var C=l.toDatalessObject(a);return l.includeDefaultValues=y,C})}var p=f.Object.prototype.toDatalessObject.call(this,a);return p.objects=u,p},render:function(a){this._transformDone=!0,this.callSuper("render",a),this._transformDone=!1},shouldCache:function(){var a=f.Object.prototype.shouldCache.call(this);if(a)for(var u=0,o=this._objects.length;u<o;u++)if(this._objects[u].willDrawShadow())return this.ownCaching=!1,!1;return a},willDrawShadow:function(){if(f.Object.prototype.willDrawShadow.call(this))return!0;for(var a=0,u=this._objects.length;a<u;a++)if(this._objects[a].willDrawShadow())return!0;return!1},isOnACache:function(){return this.ownCaching||this.group&&this.group.isOnACache()},drawObject:function(a){for(var u=0,o=this._objects.length;u<o;u++)this._objects[u].render(a);this._drawClipPath(a,this.clipPath)},isCacheDirty:function(a){if(this.callSuper("isCacheDirty",a))return!0;if(!this.statefullCache)return!1;for(var u=0,o=this._objects.length;u<o;u++)if(this._objects[u].isCacheDirty(!0)){if(this._cacheCanvas){var h=this.cacheWidth/this.zoomX,p=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-h/2,-p/2,h,p)}return!0}return!1},_restoreObjectsState:function(){var a=this.calcOwnMatrix();return this._objects.forEach(function(u){f.util.addTransformToObject(u,a),delete u.group,u.setCoords()}),this},destroy:function(){return this._objects.forEach(function(a){a.set("dirty",!0)}),this._restoreObjectsState()},dispose:function(){this.callSuper("dispose"),this.forEachObject(function(a){a.dispose&&a.dispose()}),this._objects=[]},toActiveSelection:function(){if(this.canvas){var a=this._objects,u=this.canvas;this._objects=[];var o=this.toObject();delete o.objects;var h=new f.ActiveSelection([]);return h.set(o),h.type="activeSelection",u.remove(this),a.forEach(function(p){p.group=h,p.dirty=!0,u.add(p)}),h.canvas=u,h._objects=a,u._activeObject=h,h.setCoords(),h}},ungroupOnCanvas:function(){return this._restoreObjectsState()},setObjectsCoords:function(){return this.forEachObject(function(u){u.setCoords(!0)}),this},_calcBounds:function(a){for(var h,p,l,E,u=[],o=[],y=["tr","br","bl","tl"],C=0,D=this._objects.length,T=y.length;C<D;++C){for(l=(h=this._objects[C]).calcACoords(),E=0;E<T;E++)u.push(l[p=y[E]].x),o.push(l[p].y);h.aCoords=l}this._getBounds(u,o,a)},_getBounds:function(a,u,o){var h=new f.Point(m(a),m(u)),p=new f.Point(d(a),d(u)),l=h.y||0,y=h.x||0,D=p.y-h.y||0;this.width=p.x-h.x||0,this.height=D,o||this.setPositionByOrigin({x:y,y:l},"left","top")},_toSVG:function(a){for(var u=["<g ","COMMON_PARTS"," >\n"],o=0,h=this._objects.length;o<h;o++)u.push("\t\t",this._objects[o].toSVG(a));return u.push("</g>\n"),u},getSvgStyles:function(){var u=this.visible?"":" visibility: hidden;";return[void 0!==this.opacity&&1!==this.opacity?"opacity: "+this.opacity+";":"",this.getSvgFilter(),u].join("")},toClipPathSVG:function(a){for(var u=[],o=0,h=this._objects.length;o<h;o++)u.push("\t",this._objects[o].toClipPathSVG(a));return this._createBaseClipPathSVGMarkup(u,{reviver:a})}}),f.Group.fromObject=function(a,u){var o=a.objects,h=f.util.object.clone(a,!0);delete h.objects,"string"!=typeof o?f.util.enlivenObjects(o,function(p){var l=f.util.object.clone(a,!0);delete l.objects,f.util.enlivenObjectEnlivables(a,l,function(){u&&u(new f.Group(p,l,!0))})}):f.loadSVGFromURL(o,function(p){var l=f.util.groupSVGElements(p,a,o);l.set(h),u&&u(l)})})}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={});f.ActiveSelection||(f.ActiveSelection=f.util.createClass(f.Group,{type:"activeSelection",initialize:function(m,d){d=d||{},this._objects=m||[];for(var a=this._objects.length;a--;)this._objects[a].group=this;d.originX&&(this.originX=d.originX),d.originY&&(this.originY=d.originY),this._calcBounds(),this._updateObjectsCoords(),f.Object.prototype.initialize.call(this,d),this.setCoords()},toGroup:function(){var m=this._objects.concat();this._objects=[];var d=f.Object.prototype.toObject.call(this),a=new f.Group([]);if(delete d.type,a.set(d),m.forEach(function(o){o.canvas.remove(o),o.group=a}),a._objects=m,!this.canvas)return a;var u=this.canvas;return u.add(a),u._activeObject=a,a.setCoords(),a},onDeselect:function(){return this.destroy(),!1},toString:function(){return"#<fabric.ActiveSelection: ("+this.complexity()+")>"},shouldCache:function(){return!1},isOnACache:function(){return!1},_renderControls:function(m,d,a){m.save(),m.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,this.callSuper("_renderControls",m,d),void 0===(a=a||{}).hasControls&&(a.hasControls=!1),a.forActiveSelection=!0;for(var u=0,o=this._objects.length;u<o;u++)this._objects[u]._renderControls(m,a);m.restore()}}),f.ActiveSelection.fromObject=function(m,d){f.util.enlivenObjects(m.objects,function(a){delete m.objects,d&&d(new f.ActiveSelection(a,m,!0))})})}(Ee),function(v){"use strict";var f=b.util.object.extend;v.fabric||(v.fabric={}),v.fabric.Image?b.warn("fabric.Image is already defined."):(b.Image=b.util.createClass(b.Object,{type:"image",strokeWidth:0,srcFromAttribute:!1,_lastScaleX:1,_lastScaleY:1,_filterScalingX:1,_filterScalingY:1,minimumScaleTrigger:.5,stateProperties:b.Object.prototype.stateProperties.concat("cropX","cropY"),cacheProperties:b.Object.prototype.cacheProperties.concat("cropX","cropY"),cacheKey:"",cropX:0,cropY:0,imageSmoothing:!0,initialize:function(m,d){d||(d={}),this.filters=[],this.cacheKey="texture"+b.Object.__uid++,this.callSuper("initialize",d),this._initElement(m,d)},getElement:function(){return this._element||{}},setElement:function(m,d){return this.removeTexture(this.cacheKey),this.removeTexture(this.cacheKey+"_filtered"),this._element=m,this._originalElement=m,this._initConfig(d),0!==this.filters.length&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters(),this},removeTexture:function(m){var d=b.filterBackend;d&&d.evictCachesForKey&&d.evictCachesForKey(m)},dispose:function(){this.callSuper("dispose"),this.removeTexture(this.cacheKey),this.removeTexture(this.cacheKey+"_filtered"),this._cacheContext=void 0,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach(function(m){b.util.cleanUpJsdomNode(this[m]),this[m]=void 0}.bind(this))},getCrossOrigin:function(){return this._originalElement&&(this._originalElement.crossOrigin||null)},getOriginalSize:function(){var m=this.getElement();return{width:m.naturalWidth||m.width,height:m.naturalHeight||m.height}},_stroke:function(m){if(this.stroke&&0!==this.strokeWidth){var d=this.width/2,a=this.height/2;m.beginPath(),m.moveTo(-d,-a),m.lineTo(d,-a),m.lineTo(d,a),m.lineTo(-d,a),m.lineTo(-d,-a),m.closePath()}},toObject:function(m){var d=[];this.filters.forEach(function(u){u&&d.push(u.toObject())});var a=f(this.callSuper("toObject",["cropX","cropY"].concat(m)),{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:d});return this.resizeFilter&&(a.resizeFilter=this.resizeFilter.toObject()),a},hasCrop:function(){return this.cropX||this.cropY||this.width<this._element.width||this.height<this._element.height},_toSVG:function(){var a,m=[],d=[],u=this._element,o=-this.width/2,h=-this.height/2,p="",l="";if(!u)return[];if(this.hasCrop()){var y=b.Object.__uid++;m.push('<clipPath id="imageCrop_'+y+'">\n','\t<rect x="'+o+'" y="'+h+'" width="'+this.width+'" height="'+this.height+'" />\n',"</clipPath>\n"),p=' clip-path="url(#imageCrop_'+y+')" '}if(this.imageSmoothing||(l='" image-rendering="optimizeSpeed'),d.push("\t<image ","COMMON_PARTS",'xlink:href="',this.getSvgSrc(!0),'" x="',o-this.cropX,'" y="',h-this.cropY,'" width="',u.width||u.naturalWidth,'" height="',u.height||u.height,l,'"',p,"></image>\n"),this.stroke||this.strokeDashArray){var C=this.fill;this.fill=null,a=["\t<rect ",'x="',o,'" y="',h,'" width="',this.width,'" height="',this.height,'" style="',this.getSvgStyles(),'"/>\n'],this.fill=C}return"fill"!==this.paintFirst?m.concat(a,d):m.concat(d,a)},getSrc:function(m){var d=m?this._element:this._originalElement;return d?d.toDataURL?d.toDataURL():this.srcFromAttribute?d.getAttribute("src"):d.src:this.src||""},setSrc:function(m,d,a){return b.util.loadImage(m,function(u,o){this.setElement(u,a),this._setWidthHeight(),d&&d(this,o)},this,a&&a.crossOrigin),this},toString:function(){return'#<fabric.Image: { src: "'+this.getSrc()+'" }>'},applyResizeFilters:function(){var m=this.resizeFilter,d=this.minimumScaleTrigger,a=this.getTotalObjectScaling(),u=a.scaleX,o=a.scaleY,h=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!m||u>d&&o>d)return this._element=h,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=u,void(this._lastScaleY=o);b.filterBackend||(b.filterBackend=b.initFilterBackend());var p=b.util.createCanvasElement(),l=this._filteredEl?this.cacheKey+"_filtered":this.cacheKey,y=h.width,C=h.height;p.width=y,p.height=C,this._element=p,this._lastScaleX=m.scaleX=u,this._lastScaleY=m.scaleY=o,b.filterBackend.applyFilters([m],h,y,C,this._element,l),this._filterScalingX=p.width/this._originalElement.width,this._filterScalingY=p.height/this._originalElement.height},applyFilters:function(m){if(m=(m=m||this.filters||[]).filter(function(h){return h&&!h.isNeutralState()}),this.set("dirty",!0),this.removeTexture(this.cacheKey+"_filtered"),0===m.length)return this._element=this._originalElement,this._filteredEl=null,this._filterScalingX=1,this._filterScalingY=1,this;var d=this._originalElement,a=d.naturalWidth||d.width,u=d.naturalHeight||d.height;if(this._element===this._originalElement){var o=b.util.createCanvasElement();o.width=a,o.height=u,this._element=o,this._filteredEl=o}else this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,a,u),this._lastScaleX=1,this._lastScaleY=1;return b.filterBackend||(b.filterBackend=b.initFilterBackend()),b.filterBackend.applyFilters(m,this._originalElement,a,u,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),this},_render:function(m){b.util.setImageSmoothing(m,this.imageSmoothing),!0!==this.isMoving&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(m),this._renderPaintInOrder(m)},drawCacheOnCanvas:function(m){b.util.setImageSmoothing(m,this.imageSmoothing),b.Object.prototype.drawCacheOnCanvas.call(this,m)},shouldCache:function(){return this.needsItsOwnCache()},_renderFill:function(m){var d=this._element;if(d){var a=this._filterScalingX,u=this._filterScalingY,o=this.width,h=this.height,p=Math.min,l=Math.max,y=l(this.cropX,0),C=l(this.cropY,0),D=d.naturalWidth||d.width,E=d.naturalHeight||d.height,T=y*a,I=C*u,F=p(o*a,D-T),B=p(h*u,E-I),Y=-o/2,ie=-h/2,le=p(o,D/a-y),ue=p(h,E/u-C);d&&m.drawImage(d,T,I,F,B,Y,ie,le,ue)}},_needsResize:function(){var m=this.getTotalObjectScaling();return m.scaleX!==this._lastScaleX||m.scaleY!==this._lastScaleY},_resetWidthHeight:function(){this.set(this.getOriginalSize())},_initElement:function(m,d){this.setElement(b.util.getById(m),d),b.util.addClass(this.getElement(),b.Image.CSS_CANVAS)},_initConfig:function(m){m||(m={}),this.setOptions(m),this._setWidthHeight(m)},_initFilters:function(m,d){m&&m.length?b.util.enlivenObjects(m,function(a){d&&d(a)},"fabric.Image.filters"):d&&d()},_setWidthHeight:function(m){m||(m={});var d=this.getElement();this.width=m.width||d.naturalWidth||d.width||0,this.height=m.height||d.naturalHeight||d.height||0},parsePreserveAspectRatioAttribute:function(){var C,m=b.util.parsePreserveAspectRatioAttribute(this.preserveAspectRatio||""),d=this._element.width,a=this._element.height,u=1,o=1,h=0,p=0,l=0,y=0,D=this.width,E=this.height,T={width:D,height:E};return!m||"none"===m.alignX&&"none"===m.alignY?(u=D/d,o=E/a):("meet"===m.meetOrSlice&&(C=(D-d*(u=o=b.util.findScaleToFit(this._element,T)))/2,"Min"===m.alignX&&(h=-C),"Max"===m.alignX&&(h=C),C=(E-a*o)/2,"Min"===m.alignY&&(p=-C),"Max"===m.alignY&&(p=C)),"slice"===m.meetOrSlice&&(C=d-D/(u=o=b.util.findScaleToCover(this._element,T)),"Mid"===m.alignX&&(l=C/2),"Max"===m.alignX&&(l=C),C=a-E/o,"Mid"===m.alignY&&(y=C/2),"Max"===m.alignY&&(y=C),d=D/u,a=E/o)),{width:d,height:a,scaleX:u,scaleY:o,offsetLeft:h,offsetTop:p,cropX:l,cropY:y}}}),b.Image.CSS_CANVAS="canvas-img",b.Image.prototype.getSvgSrc=b.Image.prototype.getSrc,b.Image.fromObject=function(m,d){var a=b.util.object.clone(m);b.util.loadImage(a.src,function(u,o){o?d&&d(null,!0):b.Image.prototype._initFilters.call(a,a.filters,function(h){a.filters=h||[],b.Image.prototype._initFilters.call(a,[a.resizeFilter],function(p){a.resizeFilter=p[0],b.util.enlivenObjectEnlivables(a,a,function(){var l=new b.Image(u,a);d(l,!1)})})})},null,a.crossOrigin)},b.Image.fromURL=function(m,d,a){b.util.loadImage(m,function(u,o){d&&d(new b.Image(u,a),o)},null,a&&a.crossOrigin)},b.Image.ATTRIBUTE_NAMES=b.SHARED_ATTRIBUTES.concat("x y width height preserveAspectRatio xlink:href crossOrigin image-rendering".split(" ")),b.Image.fromElement=function(m,d,a){var u=b.parseAttributes(m,b.Image.ATTRIBUTE_NAMES);b.Image.fromURL(u["xlink:href"],d,f(a?b.util.object.clone(a):{},u))})}(Ee),b.util.object.extend(b.Object.prototype,{_getAngleValueForStraighten:function(){var v=this.angle%360;return v>0?90*Math.round((v-1)/90):90*Math.round(v/90)},straighten:function(){return this.rotate(this._getAngleValueForStraighten())},fxStraighten:function(v){var f=function(){},m=(v=v||{}).onComplete||f,d=v.onChange||f,a=this;return b.util.animate({target:this,startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(u){a.rotate(u),d()},onComplete:function(){a.setCoords(),m()}})}}),b.util.object.extend(b.StaticCanvas.prototype,{straightenObject:function(v){return v.straighten(),this.requestRenderAll(),this},fxStraightenObject:function(v){return v.fxStraighten({onChange:this.requestRenderAllBound})}}),function(){"use strict";function v(m,d){var a="precision "+d+" float;\nvoid main(){}",u=m.createShader(m.FRAGMENT_SHADER);return m.shaderSource(u,a),m.compileShader(u),!!m.getShaderParameter(u,m.COMPILE_STATUS)}function f(m){m&&m.tileSize&&(this.tileSize=m.tileSize),this.setupGLContext(this.tileSize,this.tileSize),this.captureGPUInfo()}b.isWebglSupported=function(m){if(b.isLikelyNode)return!1;m=m||b.WebglFilterBackend.prototype.tileSize;var d=document.createElement("canvas"),a=d.getContext("webgl")||d.getContext("experimental-webgl"),u=!1;if(a){b.maxTextureSize=a.getParameter(a.MAX_TEXTURE_SIZE),u=b.maxTextureSize>=m;for(var o=["highp","mediump","lowp"],h=0;h<3;h++)if(v(a,o[h])){b.webGlPrecision=o[h];break}}return this.isSupported=u,u},b.WebglFilterBackend=f,f.prototype={tileSize:2048,resources:{},setupGLContext:function(m,d){this.dispose(),this.createWebGLCanvas(m,d),this.aPosition=new Float32Array([0,0,0,1,1,0,1,1]),this.chooseFastestCopyGLTo2DMethod(m,d)},chooseFastestCopyGLTo2DMethod:function(m,d){var u,a=void 0!==window.performance;try{new ImageData(1,1),u=!0}catch(T){u=!1}var o="undefined"!=typeof ArrayBuffer,h="undefined"!=typeof Uint8ClampedArray;if(a&&u&&o&&h){var p=b.util.createCanvasElement(),l=new ArrayBuffer(m*d*4);if(b.forceGLPutImageData)return this.imageBuffer=l,void(this.copyGLTo2D=Qr);var C,D,y={imageBuffer:l,destinationWidth:m,destinationHeight:d,targetCanvas:p};p.width=m,p.height=d,C=window.performance.now(),ui.call(y,this.gl,y),D=window.performance.now()-C,C=window.performance.now(),Qr.call(y,this.gl,y),D>window.performance.now()-C?(this.imageBuffer=l,this.copyGLTo2D=Qr):this.copyGLTo2D=ui}},createWebGLCanvas:function(m,d){var a=b.util.createCanvasElement();a.width=m,a.height=d;var u={alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1},o=a.getContext("webgl",u);o||(o=a.getContext("experimental-webgl",u)),o&&(o.clearColor(0,0,0,0),this.canvas=a,this.gl=o)},applyFilters:function(m,d,a,u,o,h){var l,p=this.gl;h&&(l=this.getCachedTexture(h,d));var y={originalWidth:d.width||d.originalWidth,originalHeight:d.height||d.originalHeight,sourceWidth:a,sourceHeight:u,destinationWidth:a,destinationHeight:u,context:p,sourceTexture:this.createTexture(p,a,u,!l&&d),targetTexture:this.createTexture(p,a,u),originalTexture:l||this.createTexture(p,a,u,!l&&d),passes:m.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:o},C=p.createFramebuffer();return p.bindFramebuffer(p.FRAMEBUFFER,C),m.forEach(function(D){D&&D.applyTo(y)}),function(v){var f=v.targetCanvas,a=v.destinationWidth,u=v.destinationHeight;(f.width!==a||f.height!==u)&&(f.width=a,f.height=u)}(y),this.copyGLTo2D(p,y),p.bindTexture(p.TEXTURE_2D,null),p.deleteTexture(y.sourceTexture),p.deleteTexture(y.targetTexture),p.deleteFramebuffer(C),o.getContext("2d").setTransform(1,0,0,1,0,0),y},dispose:function(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()},clearWebGLCaches:function(){this.programCache={},this.textureCache={}},createTexture:function(m,d,a,u){var o=m.createTexture();return m.bindTexture(m.TEXTURE_2D,o),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MAG_FILTER,m.NEAREST),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MIN_FILTER,m.NEAREST),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_S,m.CLAMP_TO_EDGE),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_T,m.CLAMP_TO_EDGE),u?m.texImage2D(m.TEXTURE_2D,0,m.RGBA,m.RGBA,m.UNSIGNED_BYTE,u):m.texImage2D(m.TEXTURE_2D,0,m.RGBA,d,a,0,m.RGBA,m.UNSIGNED_BYTE,null),o},getCachedTexture:function(m,d){if(this.textureCache[m])return this.textureCache[m];var a=this.createTexture(this.gl,d.width,d.height,d);return this.textureCache[m]=a,a},evictCachesForKey:function(m){this.textureCache[m]&&(this.gl.deleteTexture(this.textureCache[m]),delete this.textureCache[m])},copyGLTo2D:ui,captureGPUInfo:function(){if(this.gpuInfo)return this.gpuInfo;var m=this.gl,d={renderer:"",vendor:""};if(!m)return d;var a=m.getExtension("WEBGL_debug_renderer_info");if(a){var u=m.getParameter(a.UNMASKED_RENDERER_WEBGL),o=m.getParameter(a.UNMASKED_VENDOR_WEBGL);u&&(d.renderer=u.toLowerCase()),o&&(d.vendor=o.toLowerCase())}return this.gpuInfo=d,d}}}(),function(){"use strict";var v=function(){};function f(){}b.Canvas2dFilterBackend=f,f.prototype={evictCachesForKey:v,dispose:v,clearWebGLCaches:v,resources:{},applyFilters:function(m,d,a,u,o){var h=o.getContext("2d");h.drawImage(d,0,0,a,u);var y={sourceWidth:a,sourceHeight:u,imageData:h.getImageData(0,0,a,u),originalEl:d,originalImageData:h.getImageData(0,0,a,u),canvasEl:o,ctx:h,filterBackend:this};return m.forEach(function(C){C.applyTo(y)}),(y.imageData.width!==a||y.imageData.height!==u)&&(o.width=y.imageData.width,o.height=y.imageData.height),h.putImageData(y.imageData,0,0),y}}}(),b.Image=b.Image||{},b.Image.filters=b.Image.filters||{},b.Image.filters.BaseFilter=b.util.createClass({type:"BaseFilter",vertexSource:"attribute vec2 aPosition;\nvarying vec2 vTexCoord;\nvoid main() {\nvTexCoord = aPosition;\ngl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n}",fragmentSource:"precision highp float;\nvarying vec2 vTexCoord;\nuniform sampler2D uTexture;\nvoid main() {\ngl_FragColor = texture2D(uTexture, vTexCoord);\n}",initialize:function(v){v&&this.setOptions(v)},setOptions:function(v){for(var f in v)this[f]=v[f]},createProgram:function(v,f,m){f=f||this.fragmentSource,m=m||this.vertexSource,"highp"!==b.webGlPrecision&&(f=f.replace(/precision highp float/g,"precision "+b.webGlPrecision+" float"));var d=v.createShader(v.VERTEX_SHADER);if(v.shaderSource(d,m),v.compileShader(d),!v.getShaderParameter(d,v.COMPILE_STATUS))throw new Error("Vertex shader compile error for "+this.type+": "+v.getShaderInfoLog(d));var a=v.createShader(v.FRAGMENT_SHADER);if(v.shaderSource(a,f),v.compileShader(a),!v.getShaderParameter(a,v.COMPILE_STATUS))throw new Error("Fragment shader compile error for "+this.type+": "+v.getShaderInfoLog(a));var u=v.createProgram();if(v.attachShader(u,d),v.attachShader(u,a),v.linkProgram(u),!v.getProgramParameter(u,v.LINK_STATUS))throw new Error('Shader link error for "${this.type}" '+v.getProgramInfoLog(u));var o=this.getAttributeLocations(v,u),h=this.getUniformLocations(v,u)||{};return h.uStepW=v.getUniformLocation(u,"uStepW"),h.uStepH=v.getUniformLocation(u,"uStepH"),{program:u,attributeLocations:o,uniformLocations:h}},getAttributeLocations:function(v,f){return{aPosition:v.getAttribLocation(f,"aPosition")}},getUniformLocations:function(){return{}},sendAttributeData:function(v,f,m){var d=f.aPosition,a=v.createBuffer();v.bindBuffer(v.ARRAY_BUFFER,a),v.enableVertexAttribArray(d),v.vertexAttribPointer(d,2,v.FLOAT,!1,0,0),v.bufferData(v.ARRAY_BUFFER,m,v.STATIC_DRAW)},_setupFrameBuffer:function(v){var m,d,f=v.context;v.passes>1?(d=v.destinationHeight,(v.sourceWidth!==(m=v.destinationWidth)||v.sourceHeight!==d)&&(f.deleteTexture(v.targetTexture),v.targetTexture=v.filterBackend.createTexture(f,m,d)),f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,v.targetTexture,0)):(f.bindFramebuffer(f.FRAMEBUFFER,null),f.finish())},_swapTextures:function(v){v.passes--,v.pass++;var f=v.targetTexture;v.targetTexture=v.sourceTexture,v.sourceTexture=f},isNeutralState:function(){var v=this.mainParameter,f=b.Image.filters[this.type].prototype;if(v){if(Array.isArray(f[v])){for(var m=f[v].length;m--;)if(this[v][m]!==f[v][m])return!1;return!0}return f[v]===this[v]}return!1},applyTo:function(v){v.webgl?(this._setupFrameBuffer(v),this.applyToWebGL(v),this._swapTextures(v)):this.applyTo2d(v)},retrieveShader:function(v){return v.programCache.hasOwnProperty(this.type)||(v.programCache[this.type]=this.createProgram(v.context)),v.programCache[this.type]},applyToWebGL:function(v){var f=v.context,m=this.retrieveShader(v);f.bindTexture(f.TEXTURE_2D,0===v.pass&&v.originalTexture?v.originalTexture:v.sourceTexture),f.useProgram(m.program),this.sendAttributeData(f,m.attributeLocations,v.aPosition),f.uniform1f(m.uniformLocations.uStepW,1/v.sourceWidth),f.uniform1f(m.uniformLocations.uStepH,1/v.sourceHeight),this.sendUniformData(f,m.uniformLocations),f.viewport(0,0,v.destinationWidth,v.destinationHeight),f.drawArrays(f.TRIANGLE_STRIP,0,4)},bindAdditionalTexture:function(v,f,m){v.activeTexture(m),v.bindTexture(v.TEXTURE_2D,f),v.activeTexture(v.TEXTURE0)},unbindAdditionalTexture:function(v,f){v.activeTexture(f),v.bindTexture(v.TEXTURE_2D,null),v.activeTexture(v.TEXTURE0)},getMainParameter:function(){return this[this.mainParameter]},setMainParameter:function(v){this[this.mainParameter]=v},sendUniformData:function(){},createHelpLayer:function(v){if(!v.helpLayer){var f=document.createElement("canvas");f.width=v.sourceWidth,f.height=v.sourceHeight,v.helpLayer=f}},toObject:function(){var v={type:this.type},f=this.mainParameter;return f&&(v[f]=this[f]),v},toJSON:function(){return this.toObject()}}),b.Image.filters.BaseFilter.fromObject=function(v,f){var m=new b.Image.filters[v.type](v);return f&&f(m),m},function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.Image.filters;m.ColorMatrix=(0,f.util.createClass)(m.BaseFilter,{type:"ColorMatrix",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nuniform mat4 uColorMatrix;\nuniform vec4 uConstants;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor *= uColorMatrix;\ncolor += uConstants;\ngl_FragColor = color;\n}",matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],mainParameter:"matrix",colorsOnly:!0,initialize:function(a){this.callSuper("initialize",a),this.matrix=this.matrix.slice(0)},applyTo2d:function(a){var l,y,C,D,E,o=a.imageData.data,h=o.length,p=this.matrix,T=this.colorsOnly;for(E=0;E<h;E+=4)l=o[E],y=o[E+1],C=o[E+2],T?(o[E]=l*p[0]+y*p[1]+C*p[2]+255*p[4],o[E+1]=l*p[5]+y*p[6]+C*p[7]+255*p[9],o[E+2]=l*p[10]+y*p[11]+C*p[12]+255*p[14]):(o[E]=l*p[0]+y*p[1]+C*p[2]+(D=o[E+3])*p[3]+255*p[4],o[E+1]=l*p[5]+y*p[6]+C*p[7]+D*p[8]+255*p[9],o[E+2]=l*p[10]+y*p[11]+C*p[12]+D*p[13]+255*p[14],o[E+3]=l*p[15]+y*p[16]+C*p[17]+D*p[18]+255*p[19])},getUniformLocations:function(a,u){return{uColorMatrix:a.getUniformLocation(u,"uColorMatrix"),uConstants:a.getUniformLocation(u,"uConstants")}},sendUniformData:function(a,u){var o=this.matrix,p=[o[4],o[9],o[14],o[19]];a.uniformMatrix4fv(u.uColorMatrix,!1,[o[0],o[1],o[2],o[3],o[5],o[6],o[7],o[8],o[10],o[11],o[12],o[13],o[15],o[16],o[17],o[18]]),a.uniform4fv(u.uConstants,p)}}),f.Image.filters.ColorMatrix.fromObject=f.Image.filters.BaseFilter.fromObject}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.Image.filters;m.Brightness=(0,f.util.createClass)(m.BaseFilter,{type:"Brightness",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uBrightness;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor.rgb += uBrightness;\ngl_FragColor = color;\n}",brightness:0,mainParameter:"brightness",applyTo2d:function(a){if(0!==this.brightness){var h,o=a.imageData.data,p=o.length,l=Math.round(255*this.brightness);for(h=0;h<p;h+=4)o[h]=o[h]+l,o[h+1]=o[h+1]+l,o[h+2]=o[h+2]+l}},getUniformLocations:function(a,u){return{uBrightness:a.getUniformLocation(u,"uBrightness")}},sendUniformData:function(a,u){a.uniform1f(u.uBrightness,this.brightness)}}),f.Image.filters.Brightness.fromObject=f.Image.filters.BaseFilter.fromObject}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.util.object.extend,d=f.Image.filters;d.Convolute=(0,f.util.createClass)(d.BaseFilter,{type:"Convolute",opaque:!1,matrix:[0,0,0,0,1,0,0,0,0],fragmentSource:{Convolute_3_1:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[9];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 3.0; h+=1.0) {\nfor (float w = 0.0; w < 3.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];\n}\n}\ngl_FragColor = color;\n}",Convolute_3_0:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[9];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 3.0; h+=1.0) {\nfor (float w = 0.0; w < 3.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}",Convolute_5_1:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[25];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 5.0; h+=1.0) {\nfor (float w = 0.0; w < 5.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];\n}\n}\ngl_FragColor = color;\n}",Convolute_5_0:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[25];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 5.0; h+=1.0) {\nfor (float w = 0.0; w < 5.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}",Convolute_7_1:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[49];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 7.0; h+=1.0) {\nfor (float w = 0.0; w < 7.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];\n}\n}\ngl_FragColor = color;\n}",Convolute_7_0:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[49];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 7.0; h+=1.0) {\nfor (float w = 0.0; w < 7.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}",Convolute_9_1:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[81];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 9.0; h+=1.0) {\nfor (float w = 0.0; w < 9.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];\n}\n}\ngl_FragColor = color;\n}",Convolute_9_0:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[81];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 9.0; h+=1.0) {\nfor (float w = 0.0; w < 9.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}"},retrieveShader:function(u){var o=Math.sqrt(this.matrix.length),h=this.type+"_"+o+"_"+(this.opaque?1:0),p=this.fragmentSource[h];return u.programCache.hasOwnProperty(h)||(u.programCache[h]=this.createProgram(u.context,p)),u.programCache[h]},applyTo2d:function(u){var F,B,Y,ie,le,ue,de,he,ae,_e,be,me,O,o=u.imageData,h=o.data,p=this.matrix,l=Math.round(Math.sqrt(p.length)),y=Math.floor(l/2),C=o.width,D=o.height,E=u.ctx.createImageData(C,D),T=E.data,I=this.opaque?1:0;for(be=0;be<D;be++)for(_e=0;_e<C;_e++){for(le=4*(be*C+_e),F=0,B=0,Y=0,ie=0,O=0;O<l;O++)for(me=0;me<l;me++)ue=_e+me-y,!((de=be+O-y)<0||de>=D||ue<0||ue>=C)&&(F+=h[he=4*(de*C+ue)]*(ae=p[O*l+me]),B+=h[he+1]*ae,Y+=h[he+2]*ae,I||(ie+=h[he+3]*ae));T[le]=F,T[le+1]=B,T[le+2]=Y,T[le+3]=I?h[le+3]:ie}u.imageData=E},getUniformLocations:function(u,o){return{uMatrix:u.getUniformLocation(o,"uMatrix"),uOpaque:u.getUniformLocation(o,"uOpaque"),uHalfSize:u.getUniformLocation(o,"uHalfSize"),uSize:u.getUniformLocation(o,"uSize")}},sendUniformData:function(u,o){u.uniform1fv(o.uMatrix,this.matrix)},toObject:function(){return m(this.callSuper("toObject"),{opaque:this.opaque,matrix:this.matrix})}}),f.Image.filters.Convolute.fromObject=f.Image.filters.BaseFilter.fromObject}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.Image.filters;m.Grayscale=(0,f.util.createClass)(m.BaseFilter,{type:"Grayscale",fragmentSource:{average:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat average = (color.r + color.b + color.g) / 3.0;\ngl_FragColor = vec4(average, average, average, color.a);\n}",lightness:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;\ngl_FragColor = vec4(average, average, average, col.a);\n}",luminosity:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;\ngl_FragColor = vec4(average, average, average, col.a);\n}"},mode:"average",mainParameter:"mode",applyTo2d:function(a){var h,l,o=a.imageData.data,p=o.length,y=this.mode;for(h=0;h<p;h+=4)"average"===y?l=(o[h]+o[h+1]+o[h+2])/3:"lightness"===y?l=(Math.min(o[h],o[h+1],o[h+2])+Math.max(o[h],o[h+1],o[h+2]))/2:"luminosity"===y&&(l=.21*o[h]+.72*o[h+1]+.07*o[h+2]),o[h]=l,o[h+1]=l,o[h+2]=l},retrieveShader:function(a){var u=this.type+"_"+this.mode;return a.programCache.hasOwnProperty(u)||(a.programCache[u]=this.createProgram(a.context,this.fragmentSource[this.mode])),a.programCache[u]},getUniformLocations:function(a,u){return{uMode:a.getUniformLocation(u,"uMode")}},sendUniformData:function(a,u){a.uniform1i(u.uMode,1)},isNeutralState:function(){return!1}}),f.Image.filters.Grayscale.fromObject=f.Image.filters.BaseFilter.fromObject}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.Image.filters;m.Invert=(0,f.util.createClass)(m.BaseFilter,{type:"Invert",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uInvert;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nif (uInvert == 1) {\ngl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);\n} else {\ngl_FragColor = color;\n}\n}",invert:!0,mainParameter:"invert",applyTo2d:function(a){var h,o=a.imageData.data,p=o.length;for(h=0;h<p;h+=4)o[h]=255-o[h],o[h+1]=255-o[h+1],o[h+2]=255-o[h+2]},isNeutralState:function(){return!this.invert},getUniformLocations:function(a,u){return{uInvert:a.getUniformLocation(u,"uInvert")}},sendUniformData:function(a,u){a.uniform1i(u.uInvert,this.invert)}}),f.Image.filters.Invert.fromObject=f.Image.filters.BaseFilter.fromObject}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.util.object.extend,d=f.Image.filters;d.Noise=(0,f.util.createClass)(d.BaseFilter,{type:"Noise",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uStepH;\nuniform float uNoise;\nuniform float uSeed;\nvarying vec2 vTexCoord;\nfloat rand(vec2 co, float seed, float vScale) {\nreturn fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);\n}\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;\ngl_FragColor = color;\n}",mainParameter:"noise",noise:0,applyTo2d:function(u){if(0!==this.noise){var p,l,C,h=u.imageData.data,y=this.noise;for(p=0,l=h.length;p<l;p+=4)C=(.5-Math.random())*y,h[p]+=C,h[p+1]+=C,h[p+2]+=C}},getUniformLocations:function(u,o){return{uNoise:u.getUniformLocation(o,"uNoise"),uSeed:u.getUniformLocation(o,"uSeed")}},sendUniformData:function(u,o){u.uniform1f(o.uNoise,this.noise/255),u.uniform1f(o.uSeed,Math.random())},toObject:function(){return m(this.callSuper("toObject"),{noise:this.noise})}}),f.Image.filters.Noise.fromObject=f.Image.filters.BaseFilter.fromObject}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.Image.filters;m.Pixelate=(0,f.util.createClass)(m.BaseFilter,{type:"Pixelate",blocksize:4,mainParameter:"blocksize",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uBlocksize;\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nfloat blockW = uBlocksize * uStepW;\nfloat blockH = uBlocksize * uStepW;\nint posX = int(vTexCoord.x / blockW);\nint posY = int(vTexCoord.y / blockH);\nfloat fposX = float(posX);\nfloat fposY = float(posY);\nvec2 squareCoords = vec2(fposX * blockW, fposY * blockH);\nvec4 color = texture2D(uTexture, squareCoords);\ngl_FragColor = color;\n}",applyTo2d:function(a){var l,y,C,D,E,T,I,F,B,Y,ie,u=a.imageData,o=u.data,h=u.height,p=u.width;for(y=0;y<h;y+=this.blocksize)for(C=0;C<p;C+=this.blocksize)for(D=o[l=4*y*p+4*C],E=o[l+1],T=o[l+2],I=o[l+3],Y=Math.min(y+this.blocksize,h),ie=Math.min(C+this.blocksize,p),F=y;F<Y;F++)for(B=C;B<ie;B++)o[l=4*F*p+4*B]=D,o[l+1]=E,o[l+2]=T,o[l+3]=I},isNeutralState:function(){return 1===this.blocksize},getUniformLocations:function(a,u){return{uBlocksize:a.getUniformLocation(u,"uBlocksize"),uStepW:a.getUniformLocation(u,"uStepW"),uStepH:a.getUniformLocation(u,"uStepH")}},sendUniformData:function(a,u){a.uniform1f(u.uBlocksize,this.blocksize)}}),f.Image.filters.Pixelate.fromObject=f.Image.filters.BaseFilter.fromObject}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.util.object.extend,d=f.Image.filters;d.RemoveColor=(0,f.util.createClass)(d.BaseFilter,{type:"RemoveColor",color:"#FFFFFF",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec4 uLow;\nuniform vec4 uHigh;\nvarying vec2 vTexCoord;\nvoid main() {\ngl_FragColor = texture2D(uTexture, vTexCoord);\nif(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {\ngl_FragColor.a = 0.0;\n}\n}",distance:.02,useAlpha:!1,applyTo2d:function(u){var p,y,C,D,h=u.imageData.data,l=255*this.distance,E=new f.Color(this.color).getSource(),T=[E[0]-l,E[1]-l,E[2]-l],I=[E[0]+l,E[1]+l,E[2]+l];for(p=0;p<h.length;p+=4)C=h[p+1],D=h[p+2],(y=h[p])>T[0]&&C>T[1]&&D>T[2]&&y<I[0]&&C<I[1]&&D<I[2]&&(h[p+3]=0)},getUniformLocations:function(u,o){return{uLow:u.getUniformLocation(o,"uLow"),uHigh:u.getUniformLocation(o,"uHigh")}},sendUniformData:function(u,o){var h=new f.Color(this.color).getSource(),p=parseFloat(this.distance),y=[h[0]/255+p,h[1]/255+p,h[2]/255+p,1];u.uniform4fv(o.uLow,[0+h[0]/255-p,0+h[1]/255-p,0+h[2]/255-p,1]),u.uniform4fv(o.uHigh,y)},toObject:function(){return m(this.callSuper("toObject"),{color:this.color,distance:this.distance})}}),f.Image.filters.RemoveColor.fromObject=f.Image.filters.BaseFilter.fromObject}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.Image.filters,d=f.util.createClass,a={Brownie:[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0],Vintage:[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0],Kodachrome:[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0],Technicolor:[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0],Polaroid:[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0],Sepia:[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0],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]};for(var u in a)m[u]=d(m.ColorMatrix,{type:u,matrix:a[u],mainParameter:!1,colorsOnly:!0}),f.Image.filters[u].fromObject=f.Image.filters.BaseFilter.fromObject}(Ee),function(v){"use strict";var f=v.fabric,m=f.Image.filters;m.BlendColor=(0,f.util.createClass)(m.BaseFilter,{type:"BlendColor",color:"#F95C63",mode:"multiply",alpha:1,fragmentSource:{multiply:"gl_FragColor.rgb *= uColor.rgb;\n",screen:"gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);\n",add:"gl_FragColor.rgb += uColor.rgb;\n",diff:"gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);\n",subtract:"gl_FragColor.rgb -= uColor.rgb;\n",lighten:"gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);\n",darken:"gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);\n",exclusion:"gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);\n",overlay:"if (uColor.r < 0.5) {\ngl_FragColor.r *= 2.0 * uColor.r;\n} else {\ngl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);\n}\nif (uColor.g < 0.5) {\ngl_FragColor.g *= 2.0 * uColor.g;\n} else {\ngl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);\n}\nif (uColor.b < 0.5) {\ngl_FragColor.b *= 2.0 * uColor.b;\n} else {\ngl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);\n}\n",tint:"gl_FragColor.rgb *= (1.0 - uColor.a);\ngl_FragColor.rgb += uColor.rgb;\n"},buildSource:function(a){return"precision highp float;\nuniform sampler2D uTexture;\nuniform vec4 uColor;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ngl_FragColor = color;\nif (color.a > 0.0) {\n"+this.fragmentSource[a]+"}\n}"},retrieveShader:function(a){var o,u=this.type+"_"+this.mode;return a.programCache.hasOwnProperty(u)||(o=this.buildSource(this.mode),a.programCache[u]=this.createProgram(a.context,o)),a.programCache[u]},applyTo2d:function(a){var p,l,y,C,D,E,T,o=a.imageData.data,h=o.length,I=1-this.alpha;p=(T=new f.Color(this.color).getSource())[0]*this.alpha,l=T[1]*this.alpha,y=T[2]*this.alpha;for(var F=0;F<h;F+=4)switch(C=o[F],D=o[F+1],E=o[F+2],this.mode){case"multiply":o[F]=C*p/255,o[F+1]=D*l/255,o[F+2]=E*y/255;break;case"screen":o[F]=255-(255-C)*(255-p)/255,o[F+1]=255-(255-D)*(255-l)/255,o[F+2]=255-(255-E)*(255-y)/255;break;case"add":o[F]=C+p,o[F+1]=D+l,o[F+2]=E+y;break;case"diff":case"difference":o[F]=Math.abs(C-p),o[F+1]=Math.abs(D-l),o[F+2]=Math.abs(E-y);break;case"subtract":o[F]=C-p,o[F+1]=D-l,o[F+2]=E-y;break;case"darken":o[F]=Math.min(C,p),o[F+1]=Math.min(D,l),o[F+2]=Math.min(E,y);break;case"lighten":o[F]=Math.max(C,p),o[F+1]=Math.max(D,l),o[F+2]=Math.max(E,y);break;case"overlay":o[F]=p<128?2*C*p/255:255-2*(255-C)*(255-p)/255,o[F+1]=l<128?2*D*l/255:255-2*(255-D)*(255-l)/255,o[F+2]=y<128?2*E*y/255:255-2*(255-E)*(255-y)/255;break;case"exclusion":o[F]=p+C-2*p*C/255,o[F+1]=l+D-2*l*D/255,o[F+2]=y+E-2*y*E/255;break;case"tint":o[F]=p+C*I,o[F+1]=l+D*I,o[F+2]=y+E*I}},getUniformLocations:function(a,u){return{uColor:a.getUniformLocation(u,"uColor")}},sendUniformData:function(a,u){var o=new f.Color(this.color).getSource();o[0]=this.alpha*o[0]/255,o[1]=this.alpha*o[1]/255,o[2]=this.alpha*o[2]/255,o[3]=this.alpha,a.uniform4fv(u.uColor,o)},toObject:function(){return{type:this.type,color:this.color,mode:this.mode,alpha:this.alpha}}}),f.Image.filters.BlendColor.fromObject=f.Image.filters.BaseFilter.fromObject}(Ee),function(v){"use strict";var f=v.fabric,m=f.Image.filters;m.BlendImage=(0,f.util.createClass)(m.BaseFilter,{type:"BlendImage",image:null,mode:"multiply",alpha:1,vertexSource:"attribute vec2 aPosition;\nvarying vec2 vTexCoord;\nvarying vec2 vTexCoord2;\nuniform mat3 uTransformMatrix;\nvoid main() {\nvTexCoord = aPosition;\nvTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\ngl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n}",fragmentSource:{multiply:"precision highp float;\nuniform sampler2D uTexture;\nuniform sampler2D uImage;\nuniform vec4 uColor;\nvarying vec2 vTexCoord;\nvarying vec2 vTexCoord2;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec4 color2 = texture2D(uImage, vTexCoord2);\ncolor.rgba *= color2.rgba;\ngl_FragColor = color;\n}",mask:"precision highp float;\nuniform sampler2D uTexture;\nuniform sampler2D uImage;\nuniform vec4 uColor;\nvarying vec2 vTexCoord;\nvarying vec2 vTexCoord2;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec4 color2 = texture2D(uImage, vTexCoord2);\ncolor.a = color2.a;\ngl_FragColor = color;\n}"},retrieveShader:function(a){var u=this.type+"_"+this.mode,o=this.fragmentSource[this.mode];return a.programCache.hasOwnProperty(u)||(a.programCache[u]=this.createProgram(a.context,o)),a.programCache[u]},applyToWebGL:function(a){var u=a.context,o=this.createTexture(a.filterBackend,this.image);this.bindAdditionalTexture(u,o,u.TEXTURE1),this.callSuper("applyToWebGL",a),this.unbindAdditionalTexture(u,u.TEXTURE1)},createTexture:function(a,u){return a.getCachedTexture(u.cacheKey,u._element)},calculateMatrix:function(){var a=this.image;return[1/a.scaleX,0,0,0,1/a.scaleY,0,-a.left/a._element.width,-a.top/a._element.height,1]},applyTo2d:function(a){var C,D,E,T,I,F,B,Y,ie,le,de,u=a.imageData,o=a.filterBackend.resources,h=u.data,p=h.length,l=u.width,y=u.height,ue=this.image;o.blendImage||(o.blendImage=f.util.createCanvasElement()),le=(ie=o.blendImage).getContext("2d"),ie.width!==l||ie.height!==y?(ie.width=l,ie.height=y):le.clearRect(0,0,l,y),le.setTransform(ue.scaleX,0,0,ue.scaleY,ue.left,ue.top),le.drawImage(ue._element,0,0,l,y),de=le.getImageData(0,0,l,y).data;for(var he=0;he<p;he+=4)switch(I=h[he],F=h[he+1],B=h[he+2],Y=h[he+3],C=de[he],D=de[he+1],E=de[he+2],T=de[he+3],this.mode){case"multiply":h[he]=I*C/255,h[he+1]=F*D/255,h[he+2]=B*E/255,h[he+3]=Y*T/255;break;case"mask":h[he+3]=T}},getUniformLocations:function(a,u){return{uTransformMatrix:a.getUniformLocation(u,"uTransformMatrix"),uImage:a.getUniformLocation(u,"uImage")}},sendUniformData:function(a,u){var o=this.calculateMatrix();a.uniform1i(u.uImage,1),a.uniformMatrix3fv(u.uTransformMatrix,!1,o)},toObject:function(){return{type:this.type,image:this.image&&this.image.toObject(),mode:this.mode,alpha:this.alpha}}}),f.Image.filters.BlendImage.fromObject=function(a,u){f.Image.fromObject(a.image,function(o){var h=f.util.object.clone(a);h.image=o,u(new f.Image.filters.BlendImage(h))})}}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=Math.pow,d=Math.floor,a=Math.sqrt,u=Math.abs,o=Math.round,h=Math.sin,p=Math.ceil,l=f.Image.filters;l.Resize=(0,f.util.createClass)(l.BaseFilter,{type:"Resize",resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3,getUniformLocations:function(C,D){return{uDelta:C.getUniformLocation(D,"uDelta"),uTaps:C.getUniformLocation(D,"uTaps")}},sendUniformData:function(C,D){C.uniform2fv(D.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),C.uniform1fv(D.uTaps,this.taps)},retrieveShader:function(C){var D=this.getFilterWindow(),E=this.type+"_"+D;if(!C.programCache.hasOwnProperty(E)){var T=this.generateShader(D);C.programCache[E]=this.createProgram(C.context,T)}return C.programCache[E]},getFilterWindow:function(){return Math.ceil(this.lanczosLobes/this.tempScale)},getTaps:function(){for(var C=this.lanczosCreate(this.lanczosLobes),D=this.tempScale,E=this.getFilterWindow(),T=new Array(E),I=1;I<=E;I++)T[I-1]=C(I*D);return T},generateShader:function(C){for(var D=new Array(C),E=this.fragmentSourceTOP,T=1;T<=C;T++)D[T-1]=T+".0 * uDelta";return E+="uniform float uTaps["+C+"];\n",E+="void main() {\n",E+=" vec4 color = texture2D(uTexture, vTexCoord);\n",E+=" float sum = 1.0;\n",D.forEach(function(I,F){E+=" color += texture2D(uTexture, vTexCoord + "+I+") * uTaps["+F+"];\n",E+=" color += texture2D(uTexture, vTexCoord - "+I+") * uTaps["+F+"];\n",E+=" sum += 2.0 * uTaps["+F+"];\n"}),E+=" gl_FragColor = color / sum;\n",E+="}"},fragmentSourceTOP:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec2 uDelta;\nvarying vec2 vTexCoord;\n",applyTo:function(C){C.webgl?(C.passes++,this.width=C.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=C.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),C.destinationWidth=this.dW,this._setupFrameBuffer(C),this.applyToWebGL(C),this._swapTextures(C),C.sourceWidth=C.destinationWidth,this.height=C.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),C.destinationHeight=this.dH,this._setupFrameBuffer(C),this.applyToWebGL(C),this._swapTextures(C),C.sourceHeight=C.destinationHeight):this.applyTo2d(C)},isNeutralState:function(){return 1===this.scaleX&&1===this.scaleY},lanczosCreate:function(C){return function(D){if(D>=C||D<=-C)return 0;if(D<1.1920929e-7&&D>-1.1920929e-7)return 1;var E=(D*=Math.PI)/C;return h(D)/D*h(E)/E}},applyTo2d:function(C){var D=C.imageData,E=this.scaleX,T=this.scaleY;this.rcpScaleX=1/E,this.rcpScaleY=1/T;var ie,I=D.width,F=D.height,B=o(I*E),Y=o(F*T);"sliceHack"===this.resizeType?ie=this.sliceByTwo(C,I,F,B,Y):"hermite"===this.resizeType?ie=this.hermiteFastResize(C,I,F,B,Y):"bilinear"===this.resizeType?ie=this.bilinearFiltering(C,I,F,B,Y):"lanczos"===this.resizeType&&(ie=this.lanczosResize(C,I,F,B,Y)),C.imageData=ie},sliceByTwo:function(C,D,E,T,I){var he,ae,F=C.imageData,B=.5,Y=!1,ie=!1,le=D*B,ue=E*B,de=f.filterBackend.resources,_e=0,be=0,me=D,O=0;for(de.sliceByTwo||(de.sliceByTwo=document.createElement("canvas")),((he=de.sliceByTwo).width<1.5*D||he.height<E)&&(he.width=1.5*D,he.height=E),(ae=he.getContext("2d")).clearRect(0,0,1.5*D,E),ae.putImageData(F,0,0),T=d(T),I=d(I);!Y||!ie;)D=le,E=ue,T<d(le*B)?le=d(le*B):(le=T,Y=!0),I<d(ue*B)?ue=d(ue*B):(ue=I,ie=!0),ae.drawImage(he,_e,be,D,E,me,O,le,ue),_e=me,be=O,O+=ue;return ae.getImageData(_e,be,T,I)},lanczosResize:function(C,D,E,T,I){var B=C.imageData.data,Y=C.ctx.createImageData(T,I),ie=Y.data,le=this.lanczosCreate(this.lanczosLobes),ue=this.rcpScaleX,de=this.rcpScaleY,he=2/this.rcpScaleX,ae=2/this.rcpScaleY,_e=p(ue*this.lanczosLobes/2),be=p(de*this.lanczosLobes/2),me={},O={},N={};return function F(k){var L,$,R,A,V,W,K,z,te,oe,ce;for(O.x=(k+.5)*ue,N.x=d(O.x),L=0;L<I;L++){for(O.y=(L+.5)*de,N.y=d(O.y),V=0,W=0,K=0,z=0,te=0,$=N.x-_e;$<=N.x+_e;$++)if(!($<0||$>=D)){oe=d(1e3*u($-O.x)),me[oe]||(me[oe]={});for(var X=N.y-be;X<=N.y+be;X++)X<0||X>=E||(ce=d(1e3*u(X-O.y)),me[oe][ce]||(me[oe][ce]=le(a(m(oe*he,2)+m(ce*ae,2))/1e3)),(R=me[oe][ce])>0&&(V+=R,W+=R*B[A=4*(X*D+$)],K+=R*B[A+1],z+=R*B[A+2],te+=R*B[A+3]))}ie[A=4*(L*T+k)]=W/V,ie[A+1]=K/V,ie[A+2]=z/V,ie[A+3]=te/V}return++k<T?F(k):Y}(0)},bilinearFiltering:function(C,D,E,T,I){var le,ue,de,he,ae,_e,be,N,O=0,k=this.rcpScaleX,L=this.rcpScaleY,$=4*(D-1),A=C.imageData.data,V=C.ctx.createImageData(T,I),W=V.data;for(de=0;de<I;de++)for(he=0;he<T;he++)for(ae=k*he-(le=d(k*he)),_e=L*de-(ue=d(L*de)),N=4*(ue*D+le),be=0;be<4;be++)W[O++]=A[N+be]*(1-ae)*(1-_e)+A[N+4+be]*ae*(1-_e)+A[N+$+be]*_e*(1-ae)+A[N+$+4+be]*ae*_e;return V},hermiteFastResize:function(C,D,E,T,I){for(var F=this.rcpScaleX,B=this.rcpScaleY,Y=p(F/2),ie=p(B/2),ue=C.imageData.data,de=C.ctx.createImageData(T,I),he=de.data,ae=0;ae<I;ae++)for(var _e=0;_e<T;_e++){for(var be=4*(_e+ae*T),me=0,O=0,N=0,k=0,L=0,$=0,R=0,A=(ae+.5)*B,V=d(ae*B);V<(ae+1)*B;V++)for(var W=u(A-(V+.5))/ie,K=(_e+.5)*F,z=W*W,te=d(_e*F);te<(_e+1)*F;te++){var oe=u(K-(te+.5))/Y,ce=a(z+oe*oe);ce>1&&ce<-1||(me=2*ce*ce*ce-3*ce*ce+1)>0&&(R+=me*ue[3+(oe=4*(te+V*D))],N+=me,ue[oe+3]<255&&(me=me*ue[oe+3]/250),k+=me*ue[oe],L+=me*ue[oe+1],$+=me*ue[oe+2],O+=me)}he[be]=k/O,he[be+1]=L/O,he[be+2]=$/O,he[be+3]=R/N}return de},toObject:function(){return{type:this.type,scaleX:this.scaleX,scaleY:this.scaleY,resizeType:this.resizeType,lanczosLobes:this.lanczosLobes}}}),f.Image.filters.Resize.fromObject=f.Image.filters.BaseFilter.fromObject}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.Image.filters;m.Contrast=(0,f.util.createClass)(m.BaseFilter,{type:"Contrast",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uContrast;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));\ncolor.rgb = contrastF * (color.rgb - 0.5) + 0.5;\ngl_FragColor = color;\n}",contrast:0,mainParameter:"contrast",applyTo2d:function(a){if(0!==this.contrast){var o,p=a.imageData.data,h=p.length,l=Math.floor(255*this.contrast),y=259*(l+255)/(255*(259-l));for(o=0;o<h;o+=4)p[o]=y*(p[o]-128)+128,p[o+1]=y*(p[o+1]-128)+128,p[o+2]=y*(p[o+2]-128)+128}},getUniformLocations:function(a,u){return{uContrast:a.getUniformLocation(u,"uContrast")}},sendUniformData:function(a,u){a.uniform1f(u.uContrast,this.contrast)}}),f.Image.filters.Contrast.fromObject=f.Image.filters.BaseFilter.fromObject}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.Image.filters;m.Saturation=(0,f.util.createClass)(m.BaseFilter,{type:"Saturation",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uSaturation;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat rgMax = max(color.r, color.g);\nfloat rgbMax = max(rgMax, color.b);\ncolor.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;\ncolor.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;\ncolor.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;\ngl_FragColor = color;\n}",saturation:0,mainParameter:"saturation",applyTo2d:function(a){if(0!==this.saturation){var l,y,o=a.imageData.data,h=o.length,p=-this.saturation;for(l=0;l<h;l+=4)y=Math.max(o[l],o[l+1],o[l+2]),o[l]+=y!==o[l]?(y-o[l])*p:0,o[l+1]+=y!==o[l+1]?(y-o[l+1])*p:0,o[l+2]+=y!==o[l+2]?(y-o[l+2])*p:0}},getUniformLocations:function(a,u){return{uSaturation:a.getUniformLocation(u,"uSaturation")}},sendUniformData:function(a,u){a.uniform1f(u.uSaturation,-this.saturation)}}),f.Image.filters.Saturation.fromObject=f.Image.filters.BaseFilter.fromObject}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.Image.filters;m.Vibrance=(0,f.util.createClass)(m.BaseFilter,{type:"Vibrance",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uVibrance;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat max = max(color.r, max(color.g, color.b));\nfloat avg = (color.r + color.g + color.b) / 3.0;\nfloat amt = (abs(max - avg) * 2.0) * uVibrance;\ncolor.r += max != color.r ? (max - color.r) * amt : 0.00;\ncolor.g += max != color.g ? (max - color.g) * amt : 0.00;\ncolor.b += max != color.b ? (max - color.b) * amt : 0.00;\ngl_FragColor = color;\n}",vibrance:0,mainParameter:"vibrance",applyTo2d:function(a){if(0!==this.vibrance){var l,y,D,o=a.imageData.data,h=o.length,p=-this.vibrance;for(l=0;l<h;l+=4)y=Math.max(o[l],o[l+1],o[l+2]),D=2*Math.abs(y-(o[l]+o[l+1]+o[l+2])/3)/255*p,o[l]+=y!==o[l]?(y-o[l])*D:0,o[l+1]+=y!==o[l+1]?(y-o[l+1])*D:0,o[l+2]+=y!==o[l+2]?(y-o[l+2])*D:0}},getUniformLocations:function(a,u){return{uVibrance:a.getUniformLocation(u,"uVibrance")}},sendUniformData:function(a,u){a.uniform1f(u.uVibrance,-this.vibrance)}}),f.Image.filters.Vibrance.fromObject=f.Image.filters.BaseFilter.fromObject}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.Image.filters;m.Blur=(0,f.util.createClass)(m.BaseFilter,{type:"Blur",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec2 uDelta;\nvarying vec2 vTexCoord;\nconst float nSamples = 15.0;\nvec3 v3offset = vec3(12.9898, 78.233, 151.7182);\nfloat random(vec3 scale) {\nreturn fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);\n}\nvoid main() {\nvec4 color = vec4(0.0);\nfloat total = 0.0;\nfloat offset = random(v3offset);\nfor (float t = -nSamples; t <= nSamples; t++) {\nfloat percent = (t + offset - 0.5) / nSamples;\nfloat weight = 1.0 - abs(percent);\ncolor += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;\ntotal += weight;\n}\ngl_FragColor = color / total;\n}",blur:0,mainParameter:"blur",applyTo:function(a){a.webgl?(this.aspectRatio=a.sourceWidth/a.sourceHeight,a.passes++,this._setupFrameBuffer(a),this.horizontal=!0,this.applyToWebGL(a),this._swapTextures(a),this._setupFrameBuffer(a),this.horizontal=!1,this.applyToWebGL(a),this._swapTextures(a)):this.applyTo2d(a)},applyTo2d:function(a){a.imageData=this.simpleBlur(a)},simpleBlur:function(a){var o,h,u=a.filterBackend.resources,p=a.imageData.width,l=a.imageData.height;u.blurLayer1||(u.blurLayer1=f.util.createCanvasElement(),u.blurLayer2=f.util.createCanvasElement()),h=u.blurLayer2,((o=u.blurLayer1).width!==p||o.height!==l)&&(h.width=o.width=p,h.height=o.height=l);var E,T,I,F,y=o.getContext("2d"),C=h.getContext("2d"),D=15,B=.06*this.blur*.5;for(y.putImageData(a.imageData,0,0),C.clearRect(0,0,p,l),F=-D;F<=D;F++)I=B*(T=F/D)*p+(E=(Math.random()-.5)/4),C.globalAlpha=1-Math.abs(T),C.drawImage(o,I,E),y.drawImage(h,0,0),C.globalAlpha=1,C.clearRect(0,0,h.width,h.height);for(F=-D;F<=D;F++)I=B*(T=F/D)*l+(E=(Math.random()-.5)/4),C.globalAlpha=1-Math.abs(T),C.drawImage(o,E,I),y.drawImage(h,0,0),C.globalAlpha=1,C.clearRect(0,0,h.width,h.height);a.ctx.drawImage(o,0,0);var Y=a.ctx.getImageData(0,0,o.width,o.height);return y.globalAlpha=1,y.clearRect(0,0,o.width,o.height),Y},getUniformLocations:function(a,u){return{delta:a.getUniformLocation(u,"uDelta")}},sendUniformData:function(a,u){var o=this.chooseRightDelta();a.uniform2fv(u.delta,o)},chooseRightDelta:function(){var o,a=1,u=[0,0];return this.horizontal?this.aspectRatio>1&&(a=1/this.aspectRatio):this.aspectRatio<1&&(a=this.aspectRatio),o=a*this.blur*.12,this.horizontal?u[0]=o:u[1]=o,u}}),m.Blur.fromObject=f.Image.filters.BaseFilter.fromObject}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.Image.filters;m.Gamma=(0,f.util.createClass)(m.BaseFilter,{type:"Gamma",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec3 uGamma;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec3 correction = (1.0 / uGamma);\ncolor.r = pow(color.r, correction.r);\ncolor.g = pow(color.g, correction.g);\ncolor.b = pow(color.b, correction.b);\ngl_FragColor = color;\ngl_FragColor.rgb *= color.a;\n}",gamma:[1,1,1],mainParameter:"gamma",initialize:function(a){this.gamma=[1,1,1],m.BaseFilter.prototype.initialize.call(this,a)},applyTo2d:function(a){var D,o=a.imageData.data,h=this.gamma,p=o.length,l=1/h[0],y=1/h[1],C=1/h[2];for(this.rVals||(this.rVals=new Uint8Array(256),this.gVals=new Uint8Array(256),this.bVals=new Uint8Array(256)),D=0,p=256;D<p;D++)this.rVals[D]=255*Math.pow(D/255,l),this.gVals[D]=255*Math.pow(D/255,y),this.bVals[D]=255*Math.pow(D/255,C);for(D=0,p=o.length;D<p;D+=4)o[D]=this.rVals[o[D]],o[D+1]=this.gVals[o[D+1]],o[D+2]=this.bVals[o[D+2]]},getUniformLocations:function(a,u){return{uGamma:a.getUniformLocation(u,"uGamma")}},sendUniformData:function(a,u){a.uniform3fv(u.uGamma,this.gamma)}}),f.Image.filters.Gamma.fromObject=f.Image.filters.BaseFilter.fromObject}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.Image.filters;m.Composed=(0,f.util.createClass)(m.BaseFilter,{type:"Composed",subFilters:[],initialize:function(a){this.callSuper("initialize",a),this.subFilters=this.subFilters.slice(0)},applyTo:function(a){a.passes+=this.subFilters.length-1,this.subFilters.forEach(function(u){u.applyTo(a)})},toObject:function(){return f.util.object.extend(this.callSuper("toObject"),{subFilters:this.subFilters.map(function(a){return a.toObject()})})},isNeutralState:function(){return!this.subFilters.some(function(a){return!a.isNeutralState()})}}),f.Image.filters.Composed.fromObject=function(a,u){var h=(a.subFilters||[]).map(function(l){return new f.Image.filters[l.type](l)}),p=new f.Image.filters.Composed({subFilters:h});return u&&u(p),p}}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.Image.filters;m.HueRotation=(0,f.util.createClass)(m.ColorMatrix,{type:"HueRotation",rotation:0,mainParameter:"rotation",calculateMatrix:function(){var a=this.rotation*Math.PI,u=f.util.cos(a),o=f.util.sin(a),h=1/3,p=Math.sqrt(h)*o,l=1-u;this.matrix=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],this.matrix[0]=u+l/3,this.matrix[1]=h*l-p,this.matrix[2]=h*l+p,this.matrix[5]=h*l+p,this.matrix[6]=u+h*l,this.matrix[7]=h*l-p,this.matrix[10]=h*l-p,this.matrix[11]=h*l+p,this.matrix[12]=u+h*l},isNeutralState:function(a){return this.calculateMatrix(),m.BaseFilter.prototype.isNeutralState.call(this,a)},applyTo:function(a){this.calculateMatrix(),m.BaseFilter.prototype.applyTo.call(this,a)}}),f.Image.filters.HueRotation.fromObject=f.Image.filters.BaseFilter.fromObject}(Ee),function(v){"use strict";var f=v.fabric||(v.fabric={}),m=f.util.object.clone;if(f.Text)f.warn("fabric.Text is already defined");else{var d="fontFamily fontWeight fontSize text underline overline linethrough textAlign fontStyle lineHeight textBackgroundColor charSpacing styles direction path pathStartOffset pathSide pathAlign".split(" ");f.Text=f.util.createClass(f.Object,{_dimensionAffectingProps:["fontSize","fontWeight","fontFamily","fontStyle","lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],_reNewline:/\r?\n/,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,type:"text",fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:"left",fontStyle:"normal",lineHeight:1.16,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},textBackgroundColor:"",stateProperties:f.Object.prototype.stateProperties.concat(d),cacheProperties:f.Object.prototype.cacheProperties.concat(d),stroke:null,shadow:null,path:null,pathStartOffset:0,pathSide:"left",pathAlign:"baseline",_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.315,overline:-.88},_fontSizeMult:1.13,charSpacing:0,styles:null,_measuringContext:null,deltaY:0,direction:"ltr",_styleProperties:["stroke","strokeWidth","fill","fontFamily","fontSize","fontWeight","fontStyle","underline","overline","linethrough","deltaY","textBackgroundColor"],__charBounds:[],CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2,initialize:function(a,u){this.styles=u&&u.styles||{},this.text=a,this.__skipDimension=!0,this.callSuper("initialize",u),this.path&&this.setPathInfo(),this.__skipDimension=!1,this.initDimensions(),this.setCoords(),this.setupState({propertySet:"_dimensionAffectingProps"})},setPathInfo:function(){var a=this.path;a&&(a.segmentsInfo=f.util.getPathSegmentsInfo(a.path))},getMeasuringContext:function(){return f._measuringContext||(f._measuringContext=this.canvas&&this.canvas.contextCache||f.util.createCanvasElement().getContext("2d")),f._measuringContext},_splitText:function(){var a=this._splitTextIntoLines(this.text);return this.textLines=a.lines,this._textLines=a.graphemeLines,this._unwrappedTextLines=a._unwrappedLines,this._text=a.graphemeText,a},initDimensions:function(){this.__skipDimension||(this._splitText(),this._clearCache(),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()),-1!==this.textAlign.indexOf("justify")&&this.enlargeSpaces(),this.saveState({propertySet:"_dimensionAffectingProps"}))},enlargeSpaces:function(){for(var a,u,h,p,l,y,C=0,D=this._textLines.length;C<D;C++)if(("justify"===this.textAlign||C!==D-1&&!this.isEndOfWrapping(C))&&(h=0,p=this._textLines[C],(u=this.getLineWidth(C))<this.width&&(y=this.textLines[C].match(this._reSpacesAndTabs)))){a=(this.width-u)/y.length;for(var E=0,T=p.length;E<=T;E++)l=this.__charBounds[C][E],this._reSpaceAndTab.test(p[E])?(l.width+=a,l.kernedWidth+=a,l.left+=h,h+=a):l.left+=h}},isEndOfWrapping:function(a){return a===this._textLines.length-1},missingNewlineOffset:function(){return 1},toString:function(){return"#<fabric.Text ("+this.complexity()+'): { "text": "'+this.text+'", "fontFamily": "'+this.fontFamily+'" }>'},_getCacheCanvasDimensions:function(){var a=this.callSuper("_getCacheCanvasDimensions"),u=this.fontSize;return a.width+=u*a.zoomX,a.height+=u*a.zoomY,a},_render:function(a){var u=this.path;u&&!u.isNotVisible()&&u._render(a),this._setTextStyles(a),this._renderTextLinesBackground(a),this._renderTextDecoration(a,"underline"),this._renderText(a),this._renderTextDecoration(a,"overline"),this._renderTextDecoration(a,"linethrough")},_renderText:function(a){"stroke"===this.paintFirst?(this._renderTextStroke(a),this._renderTextFill(a)):(this._renderTextFill(a),this._renderTextStroke(a))},_setTextStyles:function(a,u,o){if(a.textBaseline="alphabetical",this.path)switch(this.pathAlign){case"center":a.textBaseline="middle";break;case"ascender":a.textBaseline="top";break;case"descender":a.textBaseline="bottom"}a.font=this._getFontDeclaration(u,o)},calcTextWidth:function(){for(var a=this.getLineWidth(0),u=1,o=this._textLines.length;u<o;u++){var h=this.getLineWidth(u);h>a&&(a=h)}return a},_renderTextLine:function(a,u,o,h,p,l){this._renderChars(a,u,o,h,p,l)},_renderTextLinesBackground:function(a){if(this.textBackgroundColor||this.styleHas("textBackgroundColor")){for(var u,o,p,l,T,I,B,h=a.fillStyle,y=this._getLeftOffset(),C=this._getTopOffset(),D=0,E=0,F=this.path,Y=0,ie=this._textLines.length;Y<ie;Y++)if(u=this.getHeightOfLine(Y),this.textBackgroundColor||this.styleHas("textBackgroundColor",Y)){p=this._textLines[Y],o=this._getLineLeftOffset(Y),E=0,D=0,l=this.getValueOfPropertyAt(Y,0,"textBackgroundColor");for(var le=0,ue=p.length;le<ue;le++)T=this.__charBounds[Y][le],I=this.getValueOfPropertyAt(Y,le,"textBackgroundColor"),F?(a.save(),a.translate(T.renderLeft,T.renderTop),a.rotate(T.angle),a.fillStyle=I,I&&a.fillRect(-T.width/2,-u/this.lineHeight*(1-this._fontSizeFraction),T.width,u/this.lineHeight),a.restore()):I!==l?(B=y+o+D,"rtl"===this.direction&&(B=this.width-B-E),a.fillStyle=l,l&&a.fillRect(B,C,E,u/this.lineHeight),D=T.left,E=T.width,l=I):E+=T.kernedWidth;I&&!F&&(B=y+o+D,"rtl"===this.direction&&(B=this.width-B-E),a.fillStyle=I,a.fillRect(B,C,E,u/this.lineHeight)),C+=u}else C+=u;a.fillStyle=h,this._removeShadow(a)}},getFontCache:function(a){var u=a.fontFamily.toLowerCase();f.charWidthsCache[u]||(f.charWidthsCache[u]={});var o=f.charWidthsCache[u],h=a.fontStyle.toLowerCase()+"_"+(a.fontWeight+"").toLowerCase();return o[h]||(o[h]={}),o[h]},_measureChar:function(a,u,o,h){var E,T,I,B,p=this.getFontCache(u),C=o+a,D=this._getFontDeclaration(u)===this._getFontDeclaration(h),F=u.fontSize/this.CACHE_FONT_SIZE;if(o&&void 0!==p[o]&&(I=p[o]),void 0!==p[a]&&(B=E=p[a]),D&&void 0!==p[C]&&(B=(T=p[C])-I),void 0===E||void 0===I||void 0===T){var Y=this.getMeasuringContext();this._setTextStyles(Y,u,!0)}return void 0===E&&(B=E=Y.measureText(a).width,p[a]=E),void 0===I&&D&&o&&(I=Y.measureText(o).width,p[o]=I),D&&void 0===T&&(T=Y.measureText(C).width,p[C]=T,B=T-I),{width:E*F,kernedWidth:B*F}},getHeightOfChar:function(a,u){return this.getValueOfPropertyAt(a,u,"fontSize")},measureLine:function(a){var u=this._measureLine(a);return 0!==this.charSpacing&&(u.width-=this._getWidthOfCharSpacing()),u.width<0&&(u.width=0),u},_measureLine:function(a){var o,h,l,y,T,I,u=0,p=this._textLines[a],D=new Array(p.length),E=0,F=this.path,B="right"===this.pathSide;for(this.__charBounds[a]=D,o=0;o<p.length;o++)y=this._getGraphemeBox(h=p[o],a,o,l),D[o]=y,u+=y.kernedWidth,l=h;if(D[o]={left:y?y.left+y.width:0,width:0,kernedWidth:0,height:this.fontSize},F){switch(I=F.segmentsInfo[F.segmentsInfo.length-1].length,(T=f.util.getPointOnPath(F.path,0,F.segmentsInfo)).x+=F.pathOffset.x,T.y+=F.pathOffset.y,this.textAlign){case"left":E=B?I-u:0;break;case"center":E=(I-u)/2;break;case"right":E=B?0:I-u}for(E+=this.pathStartOffset*(B?-1:1),o=B?p.length-1:0;B?o>=0:o<p.length;B?o--:o++)E>I?E%=I:E<0&&(E+=I),this._setGraphemeOnPath(E,y=D[o],T),E+=y.kernedWidth}return{width:u,numOfSpaces:0}},_setGraphemeOnPath:function(a,u,o){var p=this.path,l=f.util.getPointOnPath(p.path,a+u.kernedWidth/2,p.segmentsInfo);u.renderLeft=l.x-o.x,u.renderTop=l.y-o.y,u.angle=l.angle+("right"===this.pathSide?Math.PI:0)},_getGraphemeBox:function(a,u,o,h,p){var T,l=this.getCompleteStyleDeclaration(u,o),y=h?this.getCompleteStyleDeclaration(u,o-1):{},C=this._measureChar(a,l,h,y),D=C.kernedWidth,E=C.width;0!==this.charSpacing&&(E+=T=this._getWidthOfCharSpacing(),D+=T);var I={width:E,left:0,height:l.fontSize,kernedWidth:D,deltaY:l.deltaY};if(o>0&&!p){var F=this.__charBounds[u][o-1];I.left=F.left+F.width+C.kernedWidth-C.width}return I},getHeightOfLine:function(a){if(this.__lineHeights[a])return this.__lineHeights[a];for(var u=this._textLines[a],o=this.getHeightOfChar(a,0),h=1,p=u.length;h<p;h++)o=Math.max(this.getHeightOfChar(a,h),o);return this.__lineHeights[a]=o*this.lineHeight*this._fontSizeMult},calcTextHeight:function(){for(var a,u=0,o=0,h=this._textLines.length;o<h;o++)a=this.getHeightOfLine(o),u+=o===h-1?a/this.lineHeight:a;return u},_getLeftOffset:function(){return"ltr"===this.direction?-this.width/2:this.width/2},_getTopOffset:function(){return-this.height/2},_renderTextCommon:function(a,u){a.save();for(var o=0,h=this._getLeftOffset(),p=this._getTopOffset(),l=0,y=this._textLines.length;l<y;l++){var C=this.getHeightOfLine(l),D=C/this.lineHeight,E=this._getLineLeftOffset(l);this._renderTextLine(u,a,this._textLines[l],h+E,p+o+D,l),o+=C}a.restore()},_renderTextFill:function(a){!this.fill&&!this.styleHas("fill")||this._renderTextCommon(a,"fillText")},_renderTextStroke:function(a){(!this.stroke||0===this.strokeWidth)&&this.isEmptyStyles()||(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(a),a.save(),this._setLineDash(a,this.strokeDashArray),a.beginPath(),this._renderTextCommon(a,"strokeText"),a.closePath(),a.restore())},_renderChars:function(a,u,o,h,p,l){var D,E,I,B,y=this.getHeightOfLine(l),C=-1!==this.textAlign.indexOf("justify"),T="",F=0,Y=this.path,ie=!C&&0===this.charSpacing&&this.isEmptyStyles(l)&&!Y,le="ltr"===this.direction,ue="ltr"===this.direction?1:-1,he=u.canvas.getAttribute("dir");if(u.save(),he!==this.direction&&(u.canvas.setAttribute("dir",le?"ltr":"rtl"),u.direction=le?"ltr":"rtl",u.textAlign=le?"left":"right"),p-=y*this._fontSizeFraction/this.lineHeight,ie)return this._renderChar(a,u,l,0,o.join(""),h,p,y),void u.restore();for(var ae=0,_e=o.length-1;ae<=_e;ae++)B=ae===_e||this.charSpacing||Y,T+=o[ae],I=this.__charBounds[l][ae],0===F?(h+=ue*(I.kernedWidth-I.width),F+=I.width):F+=I.kernedWidth,C&&!B&&this._reSpaceAndTab.test(o[ae])&&(B=!0),B||(D=D||this.getCompleteStyleDeclaration(l,ae),E=this.getCompleteStyleDeclaration(l,ae+1),B=this._hasStyleChanged(D,E)),B&&(Y?(u.save(),u.translate(I.renderLeft,I.renderTop),u.rotate(I.angle),this._renderChar(a,u,l,ae,T,-F/2,0,y),u.restore()):this._renderChar(a,u,l,ae,T,h,p,y),T="",D=E,h+=ue*F,F=0);u.restore()},_applyPatternGradientTransformText:function(a){var o,u=f.util.createCanvasElement(),h=this.width+this.strokeWidth,p=this.height+this.strokeWidth;return u.width=h,u.height=p,(o=u.getContext("2d")).beginPath(),o.moveTo(0,0),o.lineTo(h,0),o.lineTo(h,p),o.lineTo(0,p),o.closePath(),o.translate(h/2,p/2),o.fillStyle=a.toLive(o),this._applyPatternGradientTransform(o,a),o.fill(),o.createPattern(u,"no-repeat")},handleFiller:function(a,u,o){var h,p;return o.toLive?"percentage"===o.gradientUnits||o.gradientTransform||o.patternTransform?(a.translate(h=-this.width/2,p=-this.height/2),a[u]=this._applyPatternGradientTransformText(o),{offsetX:h,offsetY:p}):(a[u]=o.toLive(a,this),this._applyPatternGradientTransform(a,o)):(a[u]=o,{offsetX:0,offsetY:0})},_setStrokeStyles:function(a,u){return a.lineWidth=u.strokeWidth,a.lineCap=this.strokeLineCap,a.lineDashOffset=this.strokeDashOffset,a.lineJoin=this.strokeLineJoin,a.miterLimit=this.strokeMiterLimit,this.handleFiller(a,"strokeStyle",u.stroke)},_setFillStyles:function(a,u){return this.handleFiller(a,"fillStyle",u.fill)},_renderChar:function(a,u,o,h,p,l,y){var I,F,C=this._getStyleDeclaration(o,h),D=this.getCompleteStyleDeclaration(o,h),E="fillText"===a&&D.fill,T="strokeText"===a&&D.stroke&&D.strokeWidth;!T&&!E||(u.save(),E&&(I=this._setFillStyles(u,D)),T&&(F=this._setStrokeStyles(u,D)),u.font=this._getFontDeclaration(D),C&&C.textBackgroundColor&&this._removeShadow(u),C&&C.deltaY&&(y+=C.deltaY),E&&u.fillText(p,l-I.offsetX,y-I.offsetY),T&&u.strokeText(p,l-F.offsetX,y-F.offsetY),u.restore())},setSuperscript:function(a,u){return this._setScript(a,u,this.superscript)},setSubscript:function(a,u){return this._setScript(a,u,this.subscript)},_setScript:function(a,u,o){var h=this.get2DCursorLocation(a,!0),p=this.getValueOfPropertyAt(h.lineIndex,h.charIndex,"fontSize"),l=this.getValueOfPropertyAt(h.lineIndex,h.charIndex,"deltaY");return this.setSelectionStyles({fontSize:p*o.size,deltaY:l+p*o.baseline},a,u),this},_hasStyleChanged:function(a,u){return a.fill!==u.fill||a.stroke!==u.stroke||a.strokeWidth!==u.strokeWidth||a.fontSize!==u.fontSize||a.fontFamily!==u.fontFamily||a.fontWeight!==u.fontWeight||a.fontStyle!==u.fontStyle||a.deltaY!==u.deltaY},_hasStyleChangedForSvg:function(a,u){return this._hasStyleChanged(a,u)||a.overline!==u.overline||a.underline!==u.underline||a.linethrough!==u.linethrough},_getLineLeftOffset:function(a){var u=this.getLineWidth(a),o=this.width-u,h=this.textAlign,p=this.direction,y=0,l=this.isEndOfWrapping(a);return"justify"===h||"justify-center"===h&&!l||"justify-right"===h&&!l||"justify-left"===h&&!l?0:("center"===h&&(y=o/2),"right"===h&&(y=o),"justify-center"===h&&(y=o/2),"justify-right"===h&&(y=o),"rtl"===p&&(y-=o),y)},_clearCache:function(){this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]},_shouldClearDimensionCache:function(){var a=this._forceClearCache;return a||(a=this.hasStateChanged("_dimensionAffectingProps")),a&&(this.dirty=!0,this._forceClearCache=!1),a},getLineWidth:function(a){if(void 0!==this.__lineWidths[a])return this.__lineWidths[a];var o=this.measureLine(a).width;return this.__lineWidths[a]=o,o},_getWidthOfCharSpacing:function(){return 0!==this.charSpacing?this.fontSize*this.charSpacing/1e3:0},getValueOfPropertyAt:function(a,u,o){var h=this._getStyleDeclaration(a,u);return h&&void 0!==h[o]?h[o]:this[o]},_renderTextDecoration:function(a,u){if(this[u]||this.styleHas(u)){for(var o,h,p,l,y,C,D,E,F,B,Y,ie,le,ue,de,he,T=this._getLeftOffset(),I=this._getTopOffset(),ae=this.path,_e=this._getWidthOfCharSpacing(),be=this.offsets[u],me=0,O=this._textLines.length;me<O;me++)if(o=this.getHeightOfLine(me),this[u]||this.styleHas(u,me)){D=this._textLines[me],ue=o/this.lineHeight,l=this._getLineLeftOffset(me),B=0,Y=0,E=this.getValueOfPropertyAt(me,0,u),he=this.getValueOfPropertyAt(me,0,"fill"),F=I+ue*(1-this._fontSizeFraction),h=this.getHeightOfChar(me,0),y=this.getValueOfPropertyAt(me,0,"deltaY");for(var N=0,k=D.length;N<k;N++)if(ie=this.__charBounds[me][N],le=this.getValueOfPropertyAt(me,N,u),de=this.getValueOfPropertyAt(me,N,"fill"),p=this.getHeightOfChar(me,N),C=this.getValueOfPropertyAt(me,N,"deltaY"),ae&&le&&de)a.save(),a.fillStyle=he,a.translate(ie.renderLeft,ie.renderTop),a.rotate(ie.angle),a.fillRect(-ie.kernedWidth/2,be*p+C,ie.kernedWidth,this.fontSize/15),a.restore();else if((le!==E||de!==he||p!==h||C!==y)&&Y>0){var L=T+l+B;"rtl"===this.direction&&(L=this.width-L-Y),E&&he&&(a.fillStyle=he,a.fillRect(L,F+be*h+y,Y,this.fontSize/15)),B=ie.left,Y=ie.width,E=le,he=de,h=p,y=C}else Y+=ie.kernedWidth;L=T+l+B,"rtl"===this.direction&&(L=this.width-L-Y),a.fillStyle=de,le&&de&&a.fillRect(L,F+be*h+y,Y-_e,this.fontSize/15),I+=o}else I+=o;this._removeShadow(a)}},_getFontDeclaration:function(a,u){var o=a||this,h=this.fontFamily,p=f.Text.genericFonts.indexOf(h.toLowerCase())>-1,l=void 0===h||h.indexOf("'")>-1||h.indexOf(",")>-1||h.indexOf('"')>-1||p?o.fontFamily:'"'+o.fontFamily+'"';return[f.isLikelyNode?o.fontWeight:o.fontStyle,f.isLikelyNode?o.fontStyle:o.fontWeight,u?this.CACHE_FONT_SIZE+"px":o.fontSize+"px",l].join(" ")},render:function(a){!this.visible||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._shouldClearDimensionCache()&&this.initDimensions(),this.callSuper("render",a))},_splitTextIntoLines:function(a){for(var u=a.split(this._reNewline),o=new Array(u.length),h=["\n"],p=[],l=0;l<u.length;l++)o[l]=f.util.string.graphemeSplit(u[l]),p=p.concat(o[l],h);return p.pop(),{_unwrappedLines:o,lines:u,graphemeText:p,graphemeLines:o}},toObject:function(a){var u=d.concat(a),o=this.callSuper("toObject",u);return o.styles=m(this.styles,!0),o.path&&(o.path=this.path.toObject()),o},set:function(a,u){this.callSuper("set",a,u);var o=!1,h=!1;if("object"==typeof a)for(var p in a)"path"===p&&this.setPathInfo(),o=o||-1!==this._dimensionAffectingProps.indexOf(p),h=h||"path"===p;else o=-1!==this._dimensionAffectingProps.indexOf(a),h="path"===a;return h&&this.setPathInfo(),o&&(this.initDimensions(),this.setCoords()),this},complexity:function(){return 1}}),f.Text.ATTRIBUTE_NAMES=f.SHARED_ATTRIBUTES.concat("x y dx dy font-family font-style font-weight font-size letter-spacing text-decoration text-anchor".split(" ")),f.Text.DEFAULT_SVG_FONT_SIZE=16,f.Text.fromElement=function(a,u,o){if(!a)return u(null);var h=f.parseAttributes(a,f.Text.ATTRIBUTE_NAMES),p=h.textAnchor||"left";if((o=f.util.object.extend(o?m(o):{},h)).top=o.top||0,o.left=o.left||0,h.textDecoration){var l=h.textDecoration;-1!==l.indexOf("underline")&&(o.underline=!0),-1!==l.indexOf("overline")&&(o.overline=!0),-1!==l.indexOf("line-through")&&(o.linethrough=!0),delete o.textDecoration}"dx"in h&&(o.left+=h.dx),"dy"in h&&(o.top+=h.dy),"fontSize"in o||(o.fontSize=f.Text.DEFAULT_SVG_FONT_SIZE);var y="";"textContent"in a?y=a.textContent:"firstChild"in a&&null!==a.firstChild&&"data"in a.firstChild&&null!==a.firstChild.data&&(y=a.firstChild.data),y=y.replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," ");var C=o.strokeWidth;o.strokeWidth=0;var D=new f.Text(y,o),E=D.getScaledHeight()/D.height,I=((D.height+D.strokeWidth)*D.lineHeight-D.height)*E,F=D.getScaledHeight()+I,B=0;"center"===p&&(B=D.getScaledWidth()/2),"right"===p&&(B=D.getScaledWidth()),D.set({left:D.left-B,top:D.top-(F-D.fontSize*(.07+D._fontSizeFraction))/D.lineHeight,strokeWidth:void 0!==C?C:1}),u(D)},f.Text.fromObject=function(a,u){var o=m(a),h=a.path;return delete o.path,f.Object._fromObject("Text",o,function(p){h?f.Object._fromObject("Path",h,function(l){p.set("path",l),u(p)},"path"):u(p)},"text")},f.Text.genericFonts=["sans-serif","serif","cursive","fantasy","monospace"],f.util.createAccessors&&f.util.createAccessors(f.Text)}}(Ee),b.util.object.extend(b.Text.prototype,{isEmptyStyles:function(v){if(!this.styles||void 0!==v&&!this.styles[v])return!0;var f=void 0===v?this.styles:{line:this.styles[v]};for(var m in f)for(var d in f[m])for(var a in f[m][d])return!1;return!0},styleHas:function(v,f){if(!this.styles||!v||""===v||void 0!==f&&!this.styles[f])return!1;var m=void 0===f?this.styles:{0:this.styles[f]};for(var d in m)for(var a in m[d])if(void 0!==m[d][a][v])return!0;return!1},cleanStyle:function(v){if(!this.styles||!v||""===v)return!1;var d,a,f=this.styles,m=0,u=!0,o=0;for(var p in f){for(var l in d=0,f[p]){var h;m++,(h=f[p][l]).hasOwnProperty(v)?(a?h[v]!==a&&(u=!1):a=h[v],h[v]===this[v]&&delete h[v]):u=!1,0!==Object.keys(h).length?d++:delete f[p][l]}0===d&&delete f[p]}for(var C=0;C<this._textLines.length;C++)o+=this._textLines[C].length;u&&m===o&&(this[v]=a,this.removeStyle(v))},removeStyle:function(v){if(this.styles&&v&&""!==v){var m,d,a,f=this.styles;for(d in f){for(a in m=f[d])delete m[a][v],0===Object.keys(m[a]).length&&delete m[a];0===Object.keys(m).length&&delete f[d]}}},_extendStyles:function(v,f){var m=this.get2DCursorLocation(v);this._getLineStyle(m.lineIndex)||this._setLineStyle(m.lineIndex),this._getStyleDeclaration(m.lineIndex,m.charIndex)||this._setStyleDeclaration(m.lineIndex,m.charIndex,{}),b.util.object.extend(this._getStyleDeclaration(m.lineIndex,m.charIndex),f)},get2DCursorLocation:function(v,f){void 0===v&&(v=this.selectionStart);for(var m=f?this._unwrappedTextLines:this._textLines,d=m.length,a=0;a<d;a++){if(v<=m[a].length)return{lineIndex:a,charIndex:v};v-=m[a].length+this.missingNewlineOffset(a)}return{lineIndex:a-1,charIndex:m[a-1].length<v?m[a-1].length:v}},getSelectionStyles:function(v,f,m){void 0===v&&(v=this.selectionStart||0),void 0===f&&(f=this.selectionEnd||v);for(var d=[],a=v;a<f;a++)d.push(this.getStyleAtPosition(a,m));return d},getStyleAtPosition:function(v,f){var m=this.get2DCursorLocation(v);return(f?this.getCompleteStyleDeclaration(m.lineIndex,m.charIndex):this._getStyleDeclaration(m.lineIndex,m.charIndex))||{}},setSelectionStyles:function(v,f,m){void 0===f&&(f=this.selectionStart||0),void 0===m&&(m=this.selectionEnd||f);for(var d=f;d<m;d++)this._extendStyles(d,v);return this._forceClearCache=!0,this},_getStyleDeclaration:function(v,f){var m=this.styles&&this.styles[v];return m?m[f]:null},getCompleteStyleDeclaration:function(v,f){for(var a,m=this._getStyleDeclaration(v,f)||{},d={},u=0;u<this._styleProperties.length;u++)d[a=this._styleProperties[u]]=void 0===m[a]?this[a]:m[a];return d},_setStyleDeclaration:function(v,f,m){this.styles[v][f]=m},_deleteStyleDeclaration:function(v,f){delete this.styles[v][f]},_getLineStyle:function(v){return!!this.styles[v]},_setLineStyle:function(v){this.styles[v]={}},_deleteLineStyle:function(v){delete this.styles[v]}}),function(){function v(f){f.textDecoration&&(f.textDecoration.indexOf("underline")>-1&&(f.underline=!0),f.textDecoration.indexOf("line-through")>-1&&(f.linethrough=!0),f.textDecoration.indexOf("overline")>-1&&(f.overline=!0),delete f.textDecoration)}b.IText=b.util.createClass(b.Text,b.Observable,{type:"i-text",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,_reSpace:/\s|\n/,_currentCursorOpacity:0,_selectionDirection:null,_abortCursorAnimation:!1,__widthOfSpace:[],inCompositionMode:!1,initialize:function(f,m){this.callSuper("initialize",f,m),this.initBehavior()},setSelectionStart:function(f){f=Math.max(f,0),this._updateAndFire("selectionStart",f)},setSelectionEnd:function(f){f=Math.min(f,this.text.length),this._updateAndFire("selectionEnd",f)},_updateAndFire:function(f,m){this[f]!==m&&(this._fireSelectionChanged(),this[f]=m),this._updateTextarea()},_fireSelectionChanged:function(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},initDimensions:function(){this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this.callSuper("initDimensions")},render:function(f){this.clearContextTop(),this.callSuper("render",f),this.cursorOffsetCache={},this.renderCursorOrSelection()},_render:function(f){this.callSuper("_render",f)},clearContextTop:function(f){if(this.isEditing&&this.canvas&&this.canvas.contextTop){var m=this.canvas.contextTop,d=this.canvas.viewportTransform;m.save(),m.transform(d[0],d[1],d[2],d[3],d[4],d[5]),this.transform(m),this._clearTextArea(m),f||m.restore()}},renderCursorOrSelection:function(){if(this.isEditing&&this.canvas&&this.canvas.contextTop){var f=this._getCursorBoundaries(),m=this.canvas.contextTop;this.clearContextTop(!0),this.selectionStart===this.selectionEnd?this.renderCursor(f,m):this.renderSelection(f,m),m.restore()}},_clearTextArea:function(f){var m=this.width+4,d=this.height+4;f.clearRect(-m/2,-d/2,m,d)},_getCursorBoundaries:function(f){void 0===f&&(f=this.selectionStart);var m=this._getLeftOffset(),d=this._getTopOffset(),a=this._getCursorBoundariesOffsets(f);return{left:m,top:d,leftOffset:a.left,topOffset:a.top}},_getCursorBoundariesOffsets:function(f){if(this.cursorOffsetCache&&"top"in this.cursorOffsetCache)return this.cursorOffsetCache;var m,d,a,h,u=0,o=0,p=this.get2DCursorLocation(f);a=p.charIndex,d=p.lineIndex;for(var l=0;l<d;l++)u+=this.getHeightOfLine(l);m=this._getLineLeftOffset(d);var y=this.__charBounds[d][a];return y&&(o=y.left),0!==this.charSpacing&&a===this._textLines[d].length&&(o-=this._getWidthOfCharSpacing()),h={top:u,left:m+(o>0?o:0)},"rtl"===this.direction&&(h.left*=-1),this.cursorOffsetCache=h,this.cursorOffsetCache},renderCursor:function(f,m){var d=this.get2DCursorLocation(),a=d.lineIndex,u=d.charIndex>0?d.charIndex-1:0,o=this.getValueOfPropertyAt(a,u,"fontSize"),h=this.scaleX*this.canvas.getZoom(),p=this.cursorWidth/h,l=f.topOffset,y=this.getValueOfPropertyAt(a,u,"deltaY");l+=(1-this._fontSizeFraction)*this.getHeightOfLine(a)/this.lineHeight-o*(1-this._fontSizeFraction),this.inCompositionMode&&this.renderSelection(f,m),m.fillStyle=this.cursorColor||this.getValueOfPropertyAt(a,u,"fill"),m.globalAlpha=this.__isMousedown?1:this._currentCursorOpacity,m.fillRect(f.left+f.leftOffset-p/2,l+f.top+y,p,o)},renderSelection:function(f,m){for(var d=this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,a=this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd,u=-1!==this.textAlign.indexOf("justify"),o=this.get2DCursorLocation(d),h=this.get2DCursorLocation(a),p=o.lineIndex,l=h.lineIndex,y=o.charIndex<0?0:o.charIndex,C=h.charIndex<0?0:h.charIndex,D=p;D<=l;D++){var I,E=this._getLineLeftOffset(D)||0,T=this.getHeightOfLine(D),F=0,B=0;if(D===p&&(F=this.__charBounds[p][y].left),D>=p&&D<l)B=u&&!this.isEndOfWrapping(D)?this.width:this.getLineWidth(D)||5;else if(D===l)if(0===C)B=this.__charBounds[l][C].left;else{var Y=this._getWidthOfCharSpacing();B=this.__charBounds[l][C-1].left+this.__charBounds[l][C-1].width-Y}I=T,(this.lineHeight<1||D===l&&this.lineHeight>1)&&(T/=this.lineHeight);var ie=f.left+E+F,le=B-F,ue=T,de=0;this.inCompositionMode?(m.fillStyle=this.compositionColor||"black",ue=1,de=T):m.fillStyle=this.selectionColor,"rtl"===this.direction&&(ie=this.width-ie-le),m.fillRect(ie,f.top+f.topOffset+de,le,ue),f.topOffset+=I}},getCurrentCharFontSize:function(){var f=this._getCurrentCharIndex();return this.getValueOfPropertyAt(f.l,f.c,"fontSize")},getCurrentCharColor:function(){var f=this._getCurrentCharIndex();return this.getValueOfPropertyAt(f.l,f.c,"fill")},_getCurrentCharIndex:function(){var f=this.get2DCursorLocation(this.selectionStart,!0);return{l:f.lineIndex,c:f.charIndex>0?f.charIndex-1:0}}}),b.IText.fromObject=function(f,m){if(v(f),f.styles)for(var d in f.styles)for(var a in f.styles[d])v(f.styles[d][a]);b.Object._fromObject("IText",f,m,"text")}}(),function(){var v=b.util.object.clone;b.util.object.extend(b.IText.prototype,{initBehavior:function(){this.initAddedHandler(),this.initRemovedHandler(),this.initCursorSelectionHandlers(),this.initDoubleClickSimulation(),this.mouseMoveHandler=this.mouseMoveHandler.bind(this)},onDeselect:function(){this.isEditing&&this.exitEditing(),this.selected=!1},initAddedHandler:function(){var f=this;this.on("added",function(){var m=f.canvas;m&&(m._hasITextHandlers||(m._hasITextHandlers=!0,f._initCanvasHandlers(m)),m._iTextInstances=m._iTextInstances||[],m._iTextInstances.push(f))})},initRemovedHandler:function(){var f=this;this.on("removed",function(){var m=f.canvas;m&&(m._iTextInstances=m._iTextInstances||[],b.util.removeFromArray(m._iTextInstances,f),0===m._iTextInstances.length&&(m._hasITextHandlers=!1,f._removeCanvasHandlers(m)))})},_initCanvasHandlers:function(f){f._mouseUpITextHandler=function(){f._iTextInstances&&f._iTextInstances.forEach(function(m){m.__isMousedown=!1})},f.on("mouse:up",f._mouseUpITextHandler)},_removeCanvasHandlers:function(f){f.off("mouse:up",f._mouseUpITextHandler)},_tick:function(){this._currentTickState=this._animateCursor(this,1,this.cursorDuration,"_onTickComplete")},_animateCursor:function(f,m,d,a){var u;return u={isAborted:!1,abort:function(){this.isAborted=!0}},f.animate("_currentCursorOpacity",m,{duration:d,onComplete:function(){u.isAborted||f[a]()},onChange:function(){f.canvas&&f.selectionStart===f.selectionEnd&&f.renderCursorOrSelection()},abort:function(){return u.isAborted}}),u},_onTickComplete:function(){var f=this;this._cursorTimeout1&&clearTimeout(this._cursorTimeout1),this._cursorTimeout1=setTimeout(function(){f._currentTickCompleteState=f._animateCursor(f,0,this.cursorDuration/2,"_tick")},100)},initDelayedCursor:function(f){var m=this,d=f?0:this.cursorDelay;this.abortCursorAnimation(),this._currentCursorOpacity=1,this._cursorTimeout2=setTimeout(function(){m._tick()},d)},abortCursorAnimation:function(){var f=this._currentTickState||this._currentTickCompleteState,m=this.canvas;this._currentTickState&&this._currentTickState.abort(),this._currentTickCompleteState&&this._currentTickCompleteState.abort(),clearTimeout(this._cursorTimeout1),clearTimeout(this._cursorTimeout2),this._currentCursorOpacity=0,f&&m&&m.clearContext(m.contextTop||m.contextContainer)},selectAll:function(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this},getSelectedText:function(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")},findWordBoundaryLeft:function(f){var m=0,d=f-1;if(this._reSpace.test(this._text[d]))for(;this._reSpace.test(this._text[d]);)m++,d--;for(;/\S/.test(this._text[d])&&d>-1;)m++,d--;return f-m},findWordBoundaryRight:function(f){var m=0,d=f;if(this._reSpace.test(this._text[d]))for(;this._reSpace.test(this._text[d]);)m++,d++;for(;/\S/.test(this._text[d])&&d<this._text.length;)m++,d++;return f+m},findLineBoundaryLeft:function(f){for(var m=0,d=f-1;!/\n/.test(this._text[d])&&d>-1;)m++,d--;return f-m},findLineBoundaryRight:function(f){for(var m=0,d=f;!/\n/.test(this._text[d])&&d<this._text.length;)m++,d++;return f+m},searchWordBoundary:function(f,m){for(var d=this._text,a=this._reSpace.test(d[f])?f-1:f,u=d[a],o=b.reNonWord;!o.test(u)&&a>0&&a<d.length;)u=d[a+=m];return o.test(u)&&(a+=1===m?0:1),a},selectWord:function(f){var m=this.searchWordBoundary(f=f||this.selectionStart,-1),d=this.searchWordBoundary(f,1);this.selectionStart=m,this.selectionEnd=d,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()},selectLine:function(f){var m=this.findLineBoundaryLeft(f=f||this.selectionStart),d=this.findLineBoundaryRight(f);return this.selectionStart=m,this.selectionEnd=d,this._fireSelectionChanged(),this._updateTextarea(),this},enterEditing:function(f){if(!this.isEditing&&this.editable)return this.canvas&&(this.canvas.calcOffset(),this.exitEditingOnOthers(this.canvas)),this.isEditing=!0,this.initHiddenTextarea(f),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick(),this.fire("editing:entered"),this._fireSelectionChanged(),this.canvas?(this.canvas.fire("text:editing:entered",{target:this}),this.initMouseMoveHandler(),this.canvas.requestRenderAll(),this):this},exitEditingOnOthers:function(f){f._iTextInstances&&f._iTextInstances.forEach(function(m){m.selected=!1,m.isEditing&&m.exitEditing()})},initMouseMoveHandler:function(){this.canvas.on("mouse:move",this.mouseMoveHandler)},mouseMoveHandler:function(f){if(this.__isMousedown&&this.isEditing){var m=this.getSelectionStartFromPointer(f.e),d=this.selectionStart,a=this.selectionEnd;(m!==this.__selectionStartOnMouseDown||d===a)&&(d===m||a===m)||(m>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=m):(this.selectionStart=m,this.selectionEnd=this.__selectionStartOnMouseDown),(this.selectionStart!==d||this.selectionEnd!==a)&&(this.restartCursorIfNeeded(),this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}},_setEditingProps:function(){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:function(f,m,d){var a=d.slice(0,f),u=b.util.string.graphemeSplit(a).length;if(f===m)return{selectionStart:u,selectionEnd:u};var o=d.slice(f,m);return{selectionStart:u,selectionEnd:u+b.util.string.graphemeSplit(o).length}},fromGraphemeToStringSelection:function(f,m,d){var u=d.slice(0,f).join("").length;return f===m?{selectionStart:u,selectionEnd:u}:{selectionStart:u,selectionEnd:u+d.slice(f,m).join("").length}},_updateTextarea:function(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){var f=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=f.selectionStart,this.hiddenTextarea.selectionEnd=f.selectionEnd}this.updateTextareaPosition()}},updateFromTextArea:function(){if(this.hiddenTextarea){this.cursorOffsetCache={},this.text=this.hiddenTextarea.value,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords());var f=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value);this.selectionEnd=this.selectionStart=f.selectionEnd,this.inCompositionMode||(this.selectionStart=f.selectionStart),this.updateTextareaPosition()}},updateTextareaPosition:function(){if(this.selectionStart===this.selectionEnd){var f=this._calcTextareaPosition();this.hiddenTextarea.style.left=f.left,this.hiddenTextarea.style.top=f.top}},_calcTextareaPosition:function(){if(!this.canvas)return{x:1,y:1};var f=this.inCompositionMode?this.compositionStart:this.selectionStart,m=this._getCursorBoundaries(f),d=this.get2DCursorLocation(f),o=this.getValueOfPropertyAt(d.lineIndex,d.charIndex,"fontSize")*this.lineHeight,h=m.leftOffset,p=this.calcTransformMatrix(),l={x:m.left+h,y:m.top+m.topOffset+o},y=this.canvas.getRetinaScaling(),C=this.canvas.upperCanvasEl,D=C.width/y,E=C.height/y,T=D-o,I=E-o,F=C.clientWidth/D,B=C.clientHeight/E;return l=b.util.transformPoint(l,p),(l=b.util.transformPoint(l,this.canvas.viewportTransform)).x*=F,l.y*=B,l.x<0&&(l.x=0),l.x>T&&(l.x=T),l.y<0&&(l.y=0),l.y>I&&(l.y=I),l.x+=this.canvas._offset.left,l.y+=this.canvas._offset.top,{left:l.x+"px",top:l.y+"px",fontSize:o+"px",charHeight:o}},_saveEditingProps:function(){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:function(){!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.moveCursor=this._savedProps.moveCursor))},exitEditing:function(){var f=this._textBeforeEdit!==this.text,m=this.hiddenTextarea;return this.selected=!1,this.isEditing=!1,this.selectionEnd=this.selectionStart,m&&(m.blur&&m.blur(),m.parentNode&&m.parentNode.removeChild(m)),this.hiddenTextarea=null,this.abortCursorAnimation(),this._restoreEditingProps(),this._currentCursorOpacity=0,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this.fire("editing:exited"),f&&this.fire("modified"),this.canvas&&(this.canvas.off("mouse:move",this.mouseMoveHandler),this.canvas.fire("text:editing:exited",{target:this}),f&&this.canvas.fire("object:modified",{target:this})),this},_removeExtraneousStyles:function(){for(var f in this.styles)this._textLines[f]||delete this.styles[f]},removeStyleFromTo:function(f,m){var l,y,d=this.get2DCursorLocation(f,!0),a=this.get2DCursorLocation(m,!0),u=d.lineIndex,o=d.charIndex,h=a.lineIndex,p=a.charIndex;if(u!==h){if(this.styles[u])for(l=o;l<this._unwrappedTextLines[u].length;l++)delete this.styles[u][l];if(this.styles[h])for(l=p;l<this._unwrappedTextLines[h].length;l++)(y=this.styles[h][l])&&(this.styles[u]||(this.styles[u]={}),this.styles[u][o+l-p]=y);for(l=u+1;l<=h;l++)delete this.styles[l];this.shiftLineStyles(h,u-h)}else if(this.styles[u]){y=this.styles[u];var D,E,C=p-o;for(l=o;l<p;l++)delete y[l];for(E in this.styles[u])(D=parseInt(E,10))>=p&&(y[D-C]=y[E],delete y[E])}},shiftLineStyles:function(f,m){var d=v(this.styles);for(var a in this.styles){var u=parseInt(a,10);u>f&&(this.styles[u+m]=d[u],d[u-m]||delete this.styles[u])}},restartCursorIfNeeded:function(){(!this._currentTickState||this._currentTickState.isAborted||!this._currentTickCompleteState||this._currentTickCompleteState.isAborted)&&this.initDelayedCursor()},insertNewlineStyleObject:function(f,m,d,a){var u,o={},h=!1,p=this._unwrappedTextLines[f].length===m;for(var l in d||(d=1),this.shiftLineStyles(f,d),this.styles[f]&&(u=this.styles[f][0===m?m:m-1]),this.styles[f]){var y=parseInt(l,10);y>=m&&(h=!0,o[y-m]=this.styles[f][l],p&&0===m||delete this.styles[f][l])}var C=!1;for(h&&!p&&(this.styles[f+d]=o,C=!0),C&&d--;d>0;)a&&a[d-1]?this.styles[f+d]={0:v(a[d-1])}:u?this.styles[f+d]={0:v(u)}:delete this.styles[f+d],d--;this._forceClearCache=!0},insertCharStyleObject:function(f,m,d,a){this.styles||(this.styles={});var u=this.styles[f],o=u?v(u):{};for(var h in d||(d=1),o){var p=parseInt(h,10);p>=m&&(u[p+d]=o[p],o[p-d]||delete u[p])}if(this._forceClearCache=!0,a)for(;d--;)!Object.keys(a[d]).length||(this.styles[f]||(this.styles[f]={}),this.styles[f][m+d]=v(a[d]));else if(u)for(var l=u[m?m-1:1];l&&d--;)this.styles[f][m+d]=v(l)},insertNewStyleBlock:function(f,m,d){for(var a=this.get2DCursorLocation(m,!0),u=[0],o=0,h=0;h<f.length;h++)"\n"===f[h]?u[++o]=0:u[o]++;for(u[0]>0&&(this.insertCharStyleObject(a.lineIndex,a.charIndex,u[0],d),d=d&&d.slice(u[0]+1)),o&&this.insertNewlineStyleObject(a.lineIndex,a.charIndex+u[0],o),h=1;h<o;h++)u[h]>0?this.insertCharStyleObject(a.lineIndex+h,0,u[h],d):d&&this.styles[a.lineIndex+h]&&d[0]&&(this.styles[a.lineIndex+h][0]=d[0]),d=d&&d.slice(u[h]+1);u[h]>0&&this.insertCharStyleObject(a.lineIndex+h,0,u[h],d)},setSelectionStartEndWithShift:function(f,m,d){d<=f?(m===f?this._selectionDirection="left":"right"===this._selectionDirection&&(this._selectionDirection="left",this.selectionEnd=f),this.selectionStart=d):d>f&&d<m?"right"===this._selectionDirection?this.selectionEnd=d:this.selectionStart=d:(m===f?this._selectionDirection="right":"left"===this._selectionDirection&&(this._selectionDirection="right",this.selectionStart=m),this.selectionEnd=d)},setSelectionInBoundaries:function(){var f=this.text.length;this.selectionStart>f?this.selectionStart=f:this.selectionStart<0&&(this.selectionStart=0),this.selectionEnd>f?this.selectionEnd=f:this.selectionEnd<0&&(this.selectionEnd=0)}})}(),b.util.object.extend(b.IText.prototype,{initDoubleClickSimulation:function(){this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown)},onMouseDown:function(v){if(this.canvas){this.__newClickTime=+new Date;var f=v.pointer;this.isTripleClick(f)&&(this.fire("tripleclick",v),this._stopEvent(v.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=f,this.__lastIsEditing=this.isEditing,this.__lastSelected=this.selected}},isTripleClick:function(v){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===v.x&&this.__lastPointer.y===v.y},_stopEvent:function(v){v.preventDefault&&v.preventDefault(),v.stopPropagation&&v.stopPropagation()},initCursorSelectionHandlers:function(){this.initMousedownHandler(),this.initMouseupHandler(),this.initClicks()},doubleClickHandler:function(v){!this.isEditing||this.selectWord(this.getSelectionStartFromPointer(v.e))},tripleClickHandler:function(v){!this.isEditing||this.selectLine(this.getSelectionStartFromPointer(v.e))},initClicks:function(){this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler)},_mouseDownHandler:function(v){!this.canvas||!this.editable||v.e.button&&1!==v.e.button||(this.__isMousedown=!0,this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(v.e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()))},_mouseDownHandlerBefore:function(v){!this.canvas||!this.editable||v.e.button&&1!==v.e.button||(this.selected=this===this.canvas._activeObject)},initMousedownHandler:function(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore)},initMouseupHandler:function(){this.on("mouseup",this.mouseUpHandler)},mouseUpHandler:function(v){if(this.__isMousedown=!1,!(!this.editable||this.group||v.transform&&v.transform.actionPerformed||v.e.button&&1!==v.e.button)){if(this.canvas){var f=this.canvas._activeObject;if(f&&f!==this)return}this.__lastSelected&&!this.__corner?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(v.e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0}},setCursorByClick:function(v){var f=this.getSelectionStartFromPointer(v);v.shiftKey?this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,f):(this.selectionStart=f,this.selectionEnd=f),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())},getSelectionStartFromPointer:function(v){for(var p,f=this.getLocalPointer(v),m=0,d=0,a=0,u=0,o=0,l=0,y=this._textLines.length;l<y&&a<=f.y;l++)a+=this.getHeightOfLine(l)*this.scaleY,o=l,l>0&&(u+=this._textLines[l-1].length+this.missingNewlineOffset(l-1));d=this._getLineLeftOffset(o)*this.scaleX,p=this._textLines[o],"rtl"===this.direction&&(f.x=this.width*this.scaleX-f.x+d);for(var C=0,D=p.length;C<D&&(m=d,(d+=this.__charBounds[o][C].kernedWidth*this.scaleX)<=f.x);C++)u++;return this._getNewSelectionStartFromOffset(f,m,d,u,D)},_getNewSelectionStartFromOffset:function(v,f,m,d,a){var o=m-v.x,p=d+(o>v.x-f||o<0?0:1);return this.flipX&&(p=a-p),p>this._text.length&&(p=this._text.length),p}}),b.util.object.extend(b.IText.prototype,{initHiddenTextarea:function(){this.hiddenTextarea=b.document.createElement("textarea"),this.hiddenTextarea.setAttribute("autocapitalize","off"),this.hiddenTextarea.setAttribute("autocorrect","off"),this.hiddenTextarea.setAttribute("autocomplete","off"),this.hiddenTextarea.setAttribute("spellcheck","false"),this.hiddenTextarea.setAttribute("data-fabric-hiddentextarea",""),this.hiddenTextarea.setAttribute("wrap","off");var v=this._calcTextareaPosition();this.hiddenTextarea.style.cssText="position: absolute; top: "+v.top+"; left: "+v.left+"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding\uff70top: "+v.fontSize+";",this.hiddenTextareaContainer?this.hiddenTextareaContainer.appendChild(this.hiddenTextarea):b.document.body.appendChild(this.hiddenTextarea),b.util.addListener(this.hiddenTextarea,"keydown",this.onKeyDown.bind(this)),b.util.addListener(this.hiddenTextarea,"keyup",this.onKeyUp.bind(this)),b.util.addListener(this.hiddenTextarea,"input",this.onInput.bind(this)),b.util.addListener(this.hiddenTextarea,"copy",this.copy.bind(this)),b.util.addListener(this.hiddenTextarea,"cut",this.copy.bind(this)),b.util.addListener(this.hiddenTextarea,"paste",this.paste.bind(this)),b.util.addListener(this.hiddenTextarea,"compositionstart",this.onCompositionStart.bind(this)),b.util.addListener(this.hiddenTextarea,"compositionupdate",this.onCompositionUpdate.bind(this)),b.util.addListener(this.hiddenTextarea,"compositionend",this.onCompositionEnd.bind(this)),!this._clickHandlerInitialized&&this.canvas&&(b.util.addListener(this.canvas.upperCanvasEl,"click",this.onClick.bind(this)),this._clickHandlerInitialized=!0)},keysMap:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorRight",36:"moveCursorLeft",37:"moveCursorLeft",38:"moveCursorUp",39:"moveCursorRight",40:"moveCursorDown"},keysMapRtl:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorLeft",36:"moveCursorRight",37:"moveCursorRight",38:"moveCursorUp",39:"moveCursorLeft",40:"moveCursorDown"},ctrlKeysMapUp:{67:"copy",88:"cut"},ctrlKeysMapDown:{65:"selectAll"},onClick:function(){this.hiddenTextarea&&this.hiddenTextarea.focus()},onKeyDown:function(v){if(this.isEditing){var f="rtl"===this.direction?this.keysMapRtl:this.keysMap;if(v.keyCode in f)this[f[v.keyCode]](v);else{if(!(v.keyCode in this.ctrlKeysMapDown)||!v.ctrlKey&&!v.metaKey)return;this[this.ctrlKeysMapDown[v.keyCode]](v)}v.stopImmediatePropagation(),v.preventDefault(),v.keyCode>=33&&v.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}},onKeyUp:function(v){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:v.keyCode in this.ctrlKeysMapUp&&(v.ctrlKey||v.metaKey)&&(this[this.ctrlKeysMapUp[v.keyCode]](v),v.stopImmediatePropagation(),v.preventDefault(),this.canvas&&this.canvas.requestRenderAll())},onInput:function(v){var f=this.fromPaste;if(this.fromPaste=!1,v&&v.stopPropagation(),this.isEditing){var u,o,C,D,E,m=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,d=this._text.length,a=m.length,h=a-d,p=this.selectionStart,l=this.selectionEnd,y=p!==l;if(""===this.hiddenTextarea.value)return this.styles={},this.updateFromTextArea(),this.fire("changed"),void(this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll()));var T=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),I=p>T.selectionStart;y?(u=this._text.slice(p,l),h+=l-p):a<d&&(u=I?this._text.slice(l+h,l):this._text.slice(p,p-h)),o=m.slice(T.selectionEnd-h,T.selectionEnd),u&&u.length&&(o.length&&(C=this.getSelectionStyles(p,p+1,!1),C=o.map(function(){return C[0]})),y?(D=p,E=l):I?(D=l-u.length,E=l):(D=l,E=l+u.length),this.removeStyleFromTo(D,E)),o.length&&(f&&o.join("")===b.copiedText&&!b.disableStyleCopyPaste&&(C=b.copiedTextStyle),this.insertNewStyleBlock(o,p,C)),this.updateFromTextArea(),this.fire("changed"),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())}},onCompositionStart:function(){this.inCompositionMode=!0},onCompositionEnd:function(){this.inCompositionMode=!1},onCompositionUpdate:function(v){this.compositionStart=v.target.selectionStart,this.compositionEnd=v.target.selectionEnd,this.updateTextareaPosition()},copy:function(){this.selectionStart!==this.selectionEnd&&(b.copiedText=this.getSelectedText(),b.copiedTextStyle=b.disableStyleCopyPaste?null:this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0)},paste:function(){this.fromPaste=!0},_getClipboardData:function(v){return v&&v.clipboardData||b.window.clipboardData},_getWidthBeforeCursor:function(v,f){var d,m=this._getLineLeftOffset(v);return f>0&&(m+=(d=this.__charBounds[v][f-1]).left+d.width),m},getDownCursorOffset:function(v,f){var m=this._getSelectionForOffset(v,f),d=this.get2DCursorLocation(m),a=d.lineIndex;if(a===this._textLines.length-1||v.metaKey||34===v.keyCode)return this._text.length-m;var u=d.charIndex,o=this._getWidthBeforeCursor(a,u),h=this._getIndexOnLine(a+1,o);return this._textLines[a].slice(u).length+h+1+this.missingNewlineOffset(a)},_getSelectionForOffset:function(v,f){return v.shiftKey&&this.selectionStart!==this.selectionEnd&&f?this.selectionEnd:this.selectionStart},getUpCursorOffset:function(v,f){var m=this._getSelectionForOffset(v,f),d=this.get2DCursorLocation(m),a=d.lineIndex;if(0===a||v.metaKey||33===v.keyCode)return-m;var u=d.charIndex,o=this._getWidthBeforeCursor(a,u),h=this._getIndexOnLine(a-1,o),p=this._textLines[a].slice(0,u),l=this.missingNewlineOffset(a-1);return-this._textLines[a-1].length+h-p.length+(1-l)},_getIndexOnLine:function(v,f){for(var o,h,m=this._textLines[v],a=this._getLineLeftOffset(v),u=0,p=0,l=m.length;p<l;p++)if((a+=o=this.__charBounds[v][p].width)>f){h=!0;var C=a,D=Math.abs(a-o-f);u=Math.abs(C-f)<D?p:p-1;break}return h||(u=m.length-1),u},moveCursorDown:function(v){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",v)},moveCursorUp:function(v){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorUpOrDown("Up",v)},_moveCursorUpOrDown:function(v,f){var d=this["get"+v+"CursorOffset"](f,"right"===this._selectionDirection);f.shiftKey?this.moveCursorWithShift(d):this.moveCursorWithoutShift(d),0!==d&&(this.setSelectionInBoundaries(),this.abortCursorAnimation(),this._currentCursorOpacity=1,this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorWithShift:function(v){return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,"left"===this._selectionDirection?this.selectionStart+v:this.selectionEnd+v),0!==v},moveCursorWithoutShift:function(v){return v<0?(this.selectionStart+=v,this.selectionEnd=this.selectionStart):(this.selectionEnd+=v,this.selectionStart=this.selectionEnd),0!==v},moveCursorLeft:function(v){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorLeftOrRight("Left",v)},_move:function(v,f,m){var d;if(v.altKey)d=this["findWordBoundary"+m](this[f]);else{if(!v.metaKey&&35!==v.keyCode&&36!==v.keyCode)return this[f]+="Left"===m?-1:1,!0;d=this["findLineBoundary"+m](this[f])}if(void 0!==typeof d&&this[f]!==d)return this[f]=d,!0},_moveLeft:function(v,f){return this._move(v,f,"Left")},_moveRight:function(v,f){return this._move(v,f,"Right")},moveCursorLeftWithoutShift:function(v){var f=!0;return this._selectionDirection="left",this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(f=this._moveLeft(v,"selectionStart")),this.selectionEnd=this.selectionStart,f},moveCursorLeftWithShift:function(v){return"right"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveLeft(v,"selectionEnd"):0!==this.selectionStart?(this._selectionDirection="left",this._moveLeft(v,"selectionStart")):void 0},moveCursorRight:function(v){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",v)},_moveCursorLeftOrRight:function(v,f){var m="moveCursor"+v+"With";this._currentCursorOpacity=1,this[m+=f.shiftKey?"Shift":"outShift"](f)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorRightWithShift:function(v){return"left"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveRight(v,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection="right",this._moveRight(v,"selectionEnd")):void 0},moveCursorRightWithoutShift:function(v){var f=!0;return this._selectionDirection="right",this.selectionStart===this.selectionEnd?(f=this._moveRight(v,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,f},removeChars:function(v,f){void 0===f&&(f=v+1),this.removeStyleFromTo(v,f),this._text.splice(v,f-v),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()},insertChars:function(v,f,m,d){void 0===d&&(d=m),d>m&&this.removeStyleFromTo(m,d);var a=b.util.string.graphemeSplit(v);this.insertNewStyleBlock(a,m,f),this._text=[].concat(this._text.slice(0,m),a,this._text.slice(d)),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()}}),function(){var v=b.util.toFixed,f=/ +/g;b.util.object.extend(b.Text.prototype,{_toSVG:function(){var m=this._getSVGLeftTopOffsets(),d=this._getSVGTextAndBg(m.textTop,m.textLeft);return this._wrapSVGTextAndBg(d)},toSVG:function(m){return this._createBaseSVGMarkup(this._toSVG(),{reviver:m,noStyle:!0,withShadow:!0})},_getSVGLeftTopOffsets:function(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}},_wrapSVGTextAndBg:function(m){var a=this.getSvgTextDecoration(this);return[m.textBgRects.join(""),'\t\t<text xml:space="preserve" ',this.fontFamily?'font-family="'+this.fontFamily.replace(/"/g,"'")+'" ':"",this.fontSize?'font-size="'+this.fontSize+'" ':"",this.fontStyle?'font-style="'+this.fontStyle+'" ':"",this.fontWeight?'font-weight="'+this.fontWeight+'" ':"",a?'text-decoration="'+a+'" ':"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",m.textSpans.join(""),"</text>\n"]},_getSVGTextAndBg:function(m,d){var h,a=[],u=[],o=m;this._setSVGBg(u);for(var p=0,l=this._textLines.length;p<l;p++)h=this._getLineLeftOffset(p),(this.textBackgroundColor||this.styleHas("textBackgroundColor",p))&&this._setSVGTextLineBg(u,p,d+h,o),this._setSVGTextLineText(a,p,d+h,o),o+=this.getHeightOfLine(p);return{textSpans:a,textBgRects:u}},_createTextCharSpan:function(m,d,a,u){var o=m!==m.trim()||m.match(f),h=this.getSvgSpanStyles(d,o),p=h?'style="'+h+'"':"",l=d.deltaY,y="",C=b.Object.NUM_FRACTION_DIGITS;return l&&(y=' dy="'+v(l,C)+'" '),['<tspan x="',v(a,C),'" y="',v(u,C),'" ',y,p,">",b.util.string.escapeXml(m),"</tspan>"].join("")},_setSVGTextLineText:function(m,d,a,u){var p,l,C,D,I,o=this.getHeightOfLine(d),h=-1!==this.textAlign.indexOf("justify"),y="",E=0,T=this._textLines[d];u+=o*(1-this._fontSizeFraction)/this.lineHeight;for(var F=0,B=T.length-1;F<=B;F++)I=F===B||this.charSpacing,y+=T[F],C=this.__charBounds[d][F],0===E?(a+=C.kernedWidth-C.width,E+=C.width):E+=C.kernedWidth,h&&!I&&this._reSpaceAndTab.test(T[F])&&(I=!0),I||(p=p||this.getCompleteStyleDeclaration(d,F),l=this.getCompleteStyleDeclaration(d,F+1),I=this._hasStyleChangedForSvg(p,l)),I&&(D=this._getStyleDeclaration(d,F)||{},m.push(this._createTextCharSpan(y,D,a,u)),y="",p=l,a+=E,E=0)},_pushTextBgRect:function(m,d,a,u,o,h){var p=b.Object.NUM_FRACTION_DIGITS;m.push("\t\t<rect ",this._getFillAttributes(d),' x="',v(a,p),'" y="',v(u,p),'" width="',v(o,p),'" height="',v(h,p),'"></rect>\n')},_setSVGTextLineBg:function(m,d,a,u){for(var y,C,o=this._textLines[d],h=this.getHeightOfLine(d)/this.lineHeight,p=0,l=0,D=this.getValueOfPropertyAt(d,0,"textBackgroundColor"),E=0,T=o.length;E<T;E++)y=this.__charBounds[d][E],(C=this.getValueOfPropertyAt(d,E,"textBackgroundColor"))!==D?(D&&this._pushTextBgRect(m,D,a+l,u,p,h),l=y.left,p=y.width,D=C):p+=y.kernedWidth;C&&this._pushTextBgRect(m,C,a+l,u,p,h)},_getFillAttributes:function(m){var d=m&&"string"==typeof m?new b.Color(m):"";return d&&d.getSource()&&1!==d.getAlpha()?'opacity="'+d.getAlpha()+'" fill="'+d.setAlpha(1).toRgb()+'"':'fill="'+m+'"'},_getSVGLineTopOffset:function(m){for(var a,d=0,u=0;u<m;u++)d+=this.getHeightOfLine(u);return a=this.getHeightOfLine(u),{lineTop:d,offset:(this._fontSizeMult-this._fontSizeFraction)*a/(this.lineHeight*this._fontSizeMult)}},getSvgStyles:function(m){return b.Object.prototype.getSvgStyles.call(this,m)+" white-space: pre;"}})}(),function(v){"use strict";var f=v.fabric||(v.fabric={});f.Textbox=f.util.createClass(f.IText,f.Observable,{type:"textbox",minWidth:20,dynamicMinWidth:2,__cachedLines:null,lockScalingFlip:!0,noScaleCache:!1,_dimensionAffectingProps:f.Text.prototype._dimensionAffectingProps.concat("width"),_wordJoiners:/[ \t\r]/,splitByGrapheme:!1,initDimensions:function(){this.__skipDimension||(this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),-1!==this.textAlign.indexOf("justify")&&this.enlargeSpaces(),this.height=this.calcTextHeight(),this.saveState({propertySet:"_dimensionAffectingProps"}))},_generateStyleMap:function(m){for(var d=0,a=0,u=0,o={},h=0;h<m.graphemeLines.length;h++)"\n"===m.graphemeText[u]&&h>0?(a=0,u++,d++):!this.splitByGrapheme&&this._reSpaceAndTab.test(m.graphemeText[u])&&h>0&&(a++,u++),o[h]={line:d,offset:a},u+=m.graphemeLines[h].length,a+=m.graphemeLines[h].length;return o},styleHas:function(m,d){if(this._styleMap&&!this.isWrapping){var a=this._styleMap[d];a&&(d=a.line)}return f.Text.prototype.styleHas.call(this,m,d)},isEmptyStyles:function(m){if(!this.styles)return!0;var u,o,d=0,h=!1,p=this._styleMap[m],l=this._styleMap[m+1];for(var y in p&&(m=p.line,d=p.offset),l&&(h=l.line===m,u=l.offset),o=void 0===m?this.styles:{line:this.styles[m]})for(var C in o[y])if(C>=d&&(!h||C<u))for(var D in o[y][C])return!1;return!0},_getStyleDeclaration:function(m,d){if(this._styleMap&&!this.isWrapping){var a=this._styleMap[m];if(!a)return null;m=a.line,d=a.offset+d}return this.callSuper("_getStyleDeclaration",m,d)},_setStyleDeclaration:function(m,d,a){var u=this._styleMap[m];this.styles[m=u.line][d=u.offset+d]=a},_deleteStyleDeclaration:function(m,d){var a=this._styleMap[m];delete this.styles[m=a.line][d=a.offset+d]},_getLineStyle:function(m){return!!this.styles[this._styleMap[m].line]},_setLineStyle:function(m){this.styles[this._styleMap[m].line]={}},_wrapText:function(m,d){var u,a=[];for(this.isWrapping=!0,u=0;u<m.length;u++)a=a.concat(this._wrapLine(m[u],u,d));return this.isWrapping=!1,a},_measureWord:function(m,d,a){var o,u=0;a=a||0;for(var p=0,l=m.length;p<l;p++)u+=this._getGraphemeBox(m[p],d,p+a,o,!0).kernedWidth,o=m[p];return u},_wrapLine:function(m,d,a,u){var o=0,h=this.splitByGrapheme,p=[],l=[],y=h?f.util.string.graphemeSplit(m):m.split(this._wordJoiners),C="",D=0,E=h?"":" ",T=0,I=0,F=0,B=!0,Y=this._getWidthOfCharSpacing();u=u||0,0===y.length&&y.push([]),a-=u;for(var ie=0;ie<y.length;ie++)C=h?y[ie]:f.util.string.graphemeSplit(y[ie]),T=this._measureWord(C,d,D),D+=C.length,(o+=I+T-Y)>a&&!B?(p.push(l),l=[],o=T,B=!0):o+=Y,!B&&!h&&l.push(E),l=l.concat(C),I=h?0:this._measureWord([E],d,D),D++,B=!1,T>F&&(F=T);return ie&&p.push(l),F+u>this.dynamicMinWidth&&(this.dynamicMinWidth=F-Y+u),p},isEndOfWrapping:function(m){return!this._styleMap[m+1]||this._styleMap[m+1].line!==this._styleMap[m].line},missingNewlineOffset:function(m){return this.splitByGrapheme?this.isEndOfWrapping(m)?1:0:1},_splitTextIntoLines:function(m){for(var d=f.Text.prototype._splitTextIntoLines.call(this,m),a=this._wrapText(d.lines,this.width),u=new Array(a.length),o=0;o<a.length;o++)u[o]=a[o].join("");return d.lines=u,d.graphemeLines=a,d},getMinWidth:function(){return Math.max(this.minWidth,this.dynamicMinWidth)},_removeExtraneousStyles:function(){var m={};for(var d in this._styleMap)this._textLines[d]&&(m[this._styleMap[d].line]=1);for(var d in this.styles)m[d]||delete this.styles[d]},toObject:function(m){return this.callSuper("toObject",["minWidth","splitByGrapheme"].concat(m))}}),f.Textbox.fromObject=function(m,d){return f.Object._fromObject("Textbox",m,d,"text")}}(Ee),function(){var v=b.controlsUtils,f=v.scaleSkewCursorStyleHandler,m=v.scaleCursorStyleHandler,d=v.scalingEqually,a=v.scalingYOrSkewingX,u=v.scalingXOrSkewingY,o=v.scaleOrSkewActionName,h=b.Object.prototype.controls;if(h.ml=new b.Control({x:-.5,y:0,cursorStyleHandler:f,actionHandler:u,getActionName:o}),h.mr=new b.Control({x:.5,y:0,cursorStyleHandler:f,actionHandler:u,getActionName:o}),h.mb=new b.Control({x:0,y:.5,cursorStyleHandler:f,actionHandler:a,getActionName:o}),h.mt=new b.Control({x:0,y:-.5,cursorStyleHandler:f,actionHandler:a,getActionName:o}),h.tl=new b.Control({x:-.5,y:-.5,cursorStyleHandler:m,actionHandler:d}),h.tr=new b.Control({x:.5,y:-.5,cursorStyleHandler:m,actionHandler:d}),h.bl=new b.Control({x:-.5,y:.5,cursorStyleHandler:m,actionHandler:d}),h.br=new b.Control({x:.5,y:.5,cursorStyleHandler:m,actionHandler:d}),h.mtr=new b.Control({x:0,y:-.5,actionHandler:v.rotationWithSnapping,cursorStyleHandler:v.rotationStyleHandler,offsetY:-40,withConnection:!0,actionName:"rotate"}),b.Textbox){var p=b.Textbox.prototype.controls={};p.mtr=h.mtr,p.tr=h.tr,p.br=h.br,p.tl=h.tl,p.bl=h.bl,p.mt=h.mt,p.mb=h.mb,p.mr=new b.Control({x:.5,y:0,actionHandler:v.changeWidth,cursorStyleHandler:f,actionName:"resizing"}),p.ml=new b.Control({x:-.5,y:0,actionHandler:v.changeWidth,cursorStyleHandler:f,actionName:"resizing"})}}()},38:($i,Ee,Fn)=>{"use strict";function b(t){return"function"==typeof t}let qr=!1;const Ht={Promise:void 0,set useDeprecatedSynchronousErrorHandling(t){if(t){const e=new Error;console.warn("DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n"+e.stack)}else qr&&console.log("RxJS: Back to a better error behavior. Thank you. <3");qr=t},get useDeprecatedSynchronousErrorHandling(){return qr}};function li(t){setTimeout(()=>{throw t},0)}const ui={closed:!0,next(t){},error(t){if(Ht.useDeprecatedSynchronousErrorHandling)throw t;li(t)},complete(){}},Qr=Array.isArray||(t=>t&&"number"==typeof t.length);function v(t){return null!==t&&"object"==typeof t}const m=(()=>{function t(e){return Error.call(this),this.message=e?`${e.length} errors occurred during unsubscription:\n${e.map((n,i)=>`${i+1}) ${n.toString()}`).join("\n ")}`:"",this.name="UnsubscriptionError",this.errors=e,this}return t.prototype=Object.create(Error.prototype),t})();class d{constructor(e){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,e&&(this._ctorUnsubscribe=!0,this._unsubscribe=e)}unsubscribe(){let e;if(this.closed)return;let{_parentOrParents:n,_ctorUnsubscribe:i,_unsubscribe:r,_subscriptions:s}=this;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,n instanceof d)n.remove(this);else if(null!==n)for(let c=0;c<n.length;++c)n[c].remove(this);if(b(r)){i&&(this._unsubscribe=void 0);try{r.call(this)}catch(c){e=c instanceof m?a(c.errors):[c]}}if(Qr(s)){let c=-1,g=s.length;for(;++c<g;){const _=s[c];if(v(_))try{_.unsubscribe()}catch(w){e=e||[],w instanceof m?e=e.concat(a(w.errors)):e.push(w)}}}if(e)throw new m(e)}add(e){let n=e;if(!e)return d.EMPTY;switch(typeof e){case"function":n=new d(e);case"object":if(n===this||n.closed||"function"!=typeof n.unsubscribe)return n;if(this.closed)return n.unsubscribe(),n;if(!(n instanceof d)){const s=n;n=new d,n._subscriptions=[s]}break;default:throw new Error("unrecognized teardown "+e+" added to Subscription.")}let{_parentOrParents:i}=n;if(null===i)n._parentOrParents=this;else if(i instanceof d){if(i===this)return n;n._parentOrParents=[i,this]}else{if(-1!==i.indexOf(this))return n;i.push(this)}const r=this._subscriptions;return null===r?this._subscriptions=[n]:r.push(n),n}remove(e){const n=this._subscriptions;if(n){const i=n.indexOf(e);-1!==i&&n.splice(i,1)}}}var t;function a(t){return t.reduce((e,n)=>e.concat(n instanceof m?n.errors:n),[])}d.EMPTY=((t=new d).closed=!0,t);const u="function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random();class h extends d{constructor(e,n,i){switch(super(),this.syncErrorValue=null,this.syncErrorThrown=!1,this.syncErrorThrowable=!1,this.isStopped=!1,arguments.length){case 0:this.destination=ui;break;case 1:if(!e){this.destination=ui;break}if("object"==typeof e){e instanceof h?(this.syncErrorThrowable=e.syncErrorThrowable,this.destination=e,e.add(this)):(this.syncErrorThrowable=!0,this.destination=new p(this,e));break}default:this.syncErrorThrowable=!0,this.destination=new p(this,e,n,i)}}[u](){return this}static create(e,n,i){const r=new h(e,n,i);return r.syncErrorThrowable=!1,r}next(e){this.isStopped||this._next(e)}error(e){this.isStopped||(this.isStopped=!0,this._error(e))}complete(){this.isStopped||(this.isStopped=!0,this._complete())}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}_next(e){this.destination.next(e)}_error(e){this.destination.error(e),this.unsubscribe()}_complete(){this.destination.complete(),this.unsubscribe()}_unsubscribeAndRecycle(){const{_parentOrParents:e}=this;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=e,this}}class p extends h{constructor(e,n,i,r){super(),this._parentSubscriber=e;let s,c=this;b(n)?s=n:n&&(s=n.next,i=n.error,r=n.complete,n!==ui&&(c=Object.create(n),b(c.unsubscribe)&&this.add(c.unsubscribe.bind(c)),c.unsubscribe=this.unsubscribe.bind(this))),this._context=c,this._next=s,this._error=i,this._complete=r}next(e){if(!this.isStopped&&this._next){const{_parentSubscriber:n}=this;Ht.useDeprecatedSynchronousErrorHandling&&n.syncErrorThrowable?this.__tryOrSetError(n,this._next,e)&&this.unsubscribe():this.__tryOrUnsub(this._next,e)}}error(e){if(!this.isStopped){const{_parentSubscriber:n}=this,{useDeprecatedSynchronousErrorHandling:i}=Ht;if(this._error)i&&n.syncErrorThrowable?(this.__tryOrSetError(n,this._error,e),this.unsubscribe()):(this.__tryOrUnsub(this._error,e),this.unsubscribe());else if(n.syncErrorThrowable)i?(n.syncErrorValue=e,n.syncErrorThrown=!0):li(e),this.unsubscribe();else{if(this.unsubscribe(),i)throw e;li(e)}}}complete(){if(!this.isStopped){const{_parentSubscriber:e}=this;if(this._complete){const n=()=>this._complete.call(this._context);Ht.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?(this.__tryOrSetError(e,n),this.unsubscribe()):(this.__tryOrUnsub(n),this.unsubscribe())}else this.unsubscribe()}}__tryOrUnsub(e,n){try{e.call(this._context,n)}catch(i){if(this.unsubscribe(),Ht.useDeprecatedSynchronousErrorHandling)throw i;li(i)}}__tryOrSetError(e,n,i){if(!Ht.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{n.call(this._context,i)}catch(r){return Ht.useDeprecatedSynchronousErrorHandling?(e.syncErrorValue=r,e.syncErrorThrown=!0,!0):(li(r),!0)}return!1}_unsubscribe(){const{_parentSubscriber:e}=this;this._context=null,this._parentSubscriber=null,e.unsubscribe()}}const C="function"==typeof Symbol&&Symbol.observable||"@@observable";function D(t){return t}function E(...t){return T(t)}function T(t){return 0===t.length?D:1===t.length?t[0]:function(n){return t.reduce((i,r)=>r(i),n)}}let I=(()=>{class t{constructor(n){this._isScalar=!1,n&&(this._subscribe=n)}lift(n){const i=new t;return i.source=this,i.operator=n,i}subscribe(n,i,r){const{operator:s}=this,c=function(t,e,n){if(t){if(t instanceof h)return t;if(t[u])return t[u]()}return t||e||n?new h(t,e,n):new h(ui)}(n,i,r);if(c.add(s?s.call(c,this.source):this.source||Ht.useDeprecatedSynchronousErrorHandling&&!c.syncErrorThrowable?this._subscribe(c):this._trySubscribe(c)),Ht.useDeprecatedSynchronousErrorHandling&&c.syncErrorThrowable&&(c.syncErrorThrowable=!1,c.syncErrorThrown))throw c.syncErrorValue;return c}_trySubscribe(n){try{return this._subscribe(n)}catch(i){Ht.useDeprecatedSynchronousErrorHandling&&(n.syncErrorThrown=!0,n.syncErrorValue=i),function(t){for(;t;){const{closed:e,destination:n,isStopped:i}=t;if(e||i)return!1;t=n&&n instanceof h?n:null}return!0}(n)?n.error(i):console.warn(i)}}forEach(n,i){return new(i=F(i))((r,s)=>{let c;c=this.subscribe(g=>{try{n(g)}catch(_){s(_),c&&c.unsubscribe()}},s,r)})}_subscribe(n){const{source:i}=this;return i&&i.subscribe(n)}[C](){return this}pipe(...n){return 0===n.length?this:T(n)(this)}toPromise(n){return new(n=F(n))((i,r)=>{let s;this.subscribe(c=>s=c,c=>r(c),()=>i(s))})}}return t.create=e=>new t(e),t})();function F(t){if(t||(t=Ht.Promise||Promise),!t)throw new Error("no Promise impl found");return t}const Y=(()=>{function t(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return t.prototype=Object.create(Error.prototype),t})();class ie extends d{constructor(e,n){super(),this.subject=e,this.subscriber=n,this.closed=!1}unsubscribe(){if(this.closed)return;this.closed=!0;const e=this.subject,n=e.observers;if(this.subject=null,!n||0===n.length||e.isStopped||e.closed)return;const i=n.indexOf(this.subscriber);-1!==i&&n.splice(i,1)}}class le extends h{constructor(e){super(e),this.destination=e}}let ue=(()=>{class t extends I{constructor(){super(),this.observers=[],this.closed=!1,this.isStopped=!1,this.hasError=!1,this.thrownError=null}[u](){return new le(this)}lift(n){const i=new de(this,this);return i.operator=n,i}next(n){if(this.closed)throw new Y;if(!this.isStopped){const{observers:i}=this,r=i.length,s=i.slice();for(let c=0;c<r;c++)s[c].next(n)}}error(n){if(this.closed)throw new Y;this.hasError=!0,this.thrownError=n,this.isStopped=!0;const{observers:i}=this,r=i.length,s=i.slice();for(let c=0;c<r;c++)s[c].error(n);this.observers.length=0}complete(){if(this.closed)throw new Y;this.isStopped=!0;const{observers:n}=this,i=n.length,r=n.slice();for(let s=0;s<i;s++)r[s].complete();this.observers.length=0}unsubscribe(){this.isStopped=!0,this.closed=!0,this.observers=null}_trySubscribe(n){if(this.closed)throw new Y;return super._trySubscribe(n)}_subscribe(n){if(this.closed)throw new Y;return this.hasError?(n.error(this.thrownError),d.EMPTY):this.isStopped?(n.complete(),d.EMPTY):(this.observers.push(n),new ie(this,n))}asObservable(){const n=new I;return n.source=this,n}}return t.create=(e,n)=>new de(e,n),t})();class de extends ue{constructor(e,n){super(),this.destination=e,this.source=n}next(e){const{destination:n}=this;n&&n.next&&n.next(e)}error(e){const{destination:n}=this;n&&n.error&&this.destination.error(e)}complete(){const{destination:e}=this;e&&e.complete&&this.destination.complete()}_subscribe(e){const{source:n}=this;return n?this.source.subscribe(e):d.EMPTY}}function he(t){return t&&"function"==typeof t.schedule}function ae(t,e){return function(i){if("function"!=typeof t)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return i.lift(new _e(t,e))}}class _e{constructor(e,n){this.project=e,this.thisArg=n}call(e,n){return n.subscribe(new be(e,this.project,this.thisArg))}}class be extends h{constructor(e,n,i){super(e),this.project=n,this.count=0,this.thisArg=i||this}_next(e){let n;try{n=this.project.call(this.thisArg,e,this.count++)}catch(i){return void this.destination.error(i)}this.destination.next(n)}}const me=t=>e=>{for(let n=0,i=t.length;n<i&&!e.closed;n++)e.next(t[n]);e.complete()},k="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator",A=t=>t&&"number"==typeof t.length&&"function"!=typeof t;function V(t){return!!t&&"function"!=typeof t.subscribe&&"function"==typeof t.then}const W=t=>{if(t&&"function"==typeof t[C])return(t=>e=>{const n=t[C]();if("function"!=typeof n.subscribe)throw new TypeError("Provided object does not correctly implement Symbol.observable");return n.subscribe(e)})(t);if(A(t))return me(t);if(V(t))return(t=>e=>(t.then(n=>{e.closed||(e.next(n),e.complete())},n=>e.error(n)).then(null,li),e))(t);if(t&&"function"==typeof t[k])return(t=>e=>{const n=t[k]();for(;;){let i;try{i=n.next()}catch(r){return e.error(r),e}if(i.done){e.complete();break}if(e.next(i.value),e.closed)break}return"function"==typeof n.return&&e.add(()=>{n.return&&n.return()}),e})(t);{const n=`You provided ${v(t)?"an invalid object":`'${t}'`} where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.`;throw new TypeError(n)}};function te(t,e){return new I(n=>{const i=new d;let r=0;return i.add(e.schedule(function(){r!==t.length?(n.next(t[r++]),n.closed||i.add(this.schedule())):n.complete()})),i})}function Z(t,e){return e?function(t,e){if(null!=t){if(function(t){return t&&"function"==typeof t[C]}(t))return function(t,e){return new I(n=>{const i=new d;return i.add(e.schedule(()=>{const r=t[C]();i.add(r.subscribe({next(s){i.add(e.schedule(()=>n.next(s)))},error(s){i.add(e.schedule(()=>n.error(s)))},complete(){i.add(e.schedule(()=>n.complete()))}}))})),i})}(t,e);if(V(t))return function(t,e){return new I(n=>{const i=new d;return i.add(e.schedule(()=>t.then(r=>{i.add(e.schedule(()=>{n.next(r),i.add(e.schedule(()=>n.complete()))}))},r=>{i.add(e.schedule(()=>n.error(r)))}))),i})}(t,e);if(A(t))return te(t,e);if(function(t){return t&&"function"==typeof t[k]}(t)||"string"==typeof t)return function(t,e){if(!t)throw new Error("Iterable cannot be null");return new I(n=>{const i=new d;let r;return i.add(()=>{r&&"function"==typeof r.return&&r.return()}),i.add(e.schedule(()=>{r=t[k](),i.add(e.schedule(function(){if(n.closed)return;let s,c;try{const g=r.next();s=g.value,c=g.done}catch(g){return void n.error(g)}c?n.complete():(n.next(s),this.schedule())}))})),i})}(t,e)}throw new TypeError((null!==t&&typeof t||t)+" is not observable")}(t,e):t instanceof I?t:new I(W(t))}class ee extends h{constructor(e){super(),this.parent=e}_next(e){this.parent.notifyNext(e)}_error(e){this.parent.notifyError(e),this.unsubscribe()}_complete(){this.parent.notifyComplete(),this.unsubscribe()}}class ne extends h{notifyNext(e){this.destination.next(e)}notifyError(e){this.destination.error(e)}notifyComplete(){this.destination.complete()}}function Ie(t,e){if(e.closed)return;if(t instanceof I)return t.subscribe(e);let n;try{n=W(t)(e)}catch(i){e.error(i)}return n}function ve(t,e,n=Number.POSITIVE_INFINITY){return"function"==typeof e?i=>i.pipe(ve((r,s)=>Z(t(r,s)).pipe(ae((c,g)=>e(r,c,s,g))),n)):("number"==typeof e&&(n=e),i=>i.lift(new J(t,n)))}class J{constructor(e,n=Number.POSITIVE_INFINITY){this.project=e,this.concurrent=n}call(e,n){return n.subscribe(new Ce(e,this.project,this.concurrent))}}class Ce extends ne{constructor(e,n,i=Number.POSITIVE_INFINITY){super(e),this.project=n,this.concurrent=i,this.hasCompleted=!1,this.buffer=[],this.active=0,this.index=0}_next(e){this.active<this.concurrent?this._tryNext(e):this.buffer.push(e)}_tryNext(e){let n;const i=this.index++;try{n=this.project(e,i)}catch(r){return void this.destination.error(r)}this.active++,this._innerSub(n)}_innerSub(e){const n=new ee(this),i=this.destination;i.add(n);const r=Ie(e,n);r!==n&&i.add(r)}_complete(){this.hasCompleted=!0,0===this.active&&0===this.buffer.length&&this.destination.complete(),this.unsubscribe()}notifyNext(e){this.destination.next(e)}notifyComplete(){const e=this.buffer;this.active--,e.length>0?this._next(e.shift()):0===this.active&&this.hasCompleted&&this.destination.complete()}}const Fe=ve;function Ze(t,e){return e?te(t,e):new I(me(t))}function Ye(...t){let e=Number.POSITIVE_INFINITY,n=null,i=t[t.length-1];return he(i)?(n=t.pop(),t.length>1&&"number"==typeof t[t.length-1]&&(e=t.pop())):"number"==typeof i&&(e=t.pop()),null===n&&1===t.length&&t[0]instanceof I?t[0]:function(t=Number.POSITIVE_INFINITY){return ve(D,t)}(e)(Ze(t,n))}function wt(){return function(e){return e.lift(new at(e))}}class at{constructor(e){this.connectable=e}call(e,n){const{connectable:i}=this;i._refCount++;const r=new Xn(e,i),s=n.subscribe(r);return r.closed||(r.connection=i.connect()),s}}class Xn extends h{constructor(e,n){super(e),this.connectable=n}_unsubscribe(){const{connectable:e}=this;if(!e)return void(this.connection=null);this.connectable=null;const n=e._refCount;if(n<=0)return void(this.connection=null);if(e._refCount=n-1,n>1)return void(this.connection=null);const{connection:i}=this,r=e._connection;this.connection=null,r&&(!i||r===i)&&r.unsubscribe()}}class Si extends I{constructor(e,n){super(),this.source=e,this.subjectFactory=n,this._refCount=0,this._isComplete=!1}_subscribe(e){return this.getSubject().subscribe(e)}getSubject(){const e=this._subject;return(!e||e.isStopped)&&(this._subject=this.subjectFactory()),this._subject}connect(){let e=this._connection;return e||(this._isComplete=!1,e=this._connection=new d,e.add(this.source.subscribe(new Wa(this.getSubject(),this))),e.closed&&(this._connection=null,e=d.EMPTY)),e}refCount(){return wt()(this)}}const en=(()=>{const t=Si.prototype;return{operator:{value:null},_refCount:{value:0,writable:!0},_subject:{value:null,writable:!0},_connection:{value:null,writable:!0},_subscribe:{value:t._subscribe},_isComplete:{value:t._isComplete,writable:!0},getSubject:{value:t.getSubject},connect:{value:t.connect},refCount:{value:t.refCount}}})();class Wa extends le{constructor(e,n){super(e),this.connectable=n}_error(e){this._unsubscribe(),super._error(e)}_complete(){this.connectable._isComplete=!0,this._unsubscribe(),super._complete()}_unsubscribe(){const e=this.connectable;if(e){this.connectable=null;const n=e._connection;e._refCount=0,e._subject=null,e._connection=null,n&&n.unsubscribe()}}}function Kv(){return new ue}function ze(t){for(let e in t)if(t[e]===ze)return e;throw Error("Could not find renamed property on target object.")}function Le(t){if("string"==typeof t)return t;if(Array.isArray(t))return"["+t.map(Le).join(", ")+"]";if(null==t)return""+t;if(t.overriddenName)return`${t.overriddenName}`;if(t.name)return`${t.name}`;const e=t.toString();if(null==e)return""+e;const n=e.indexOf("\n");return-1===n?e:e.substring(0,n)}function Xa(t,e){return null==t||""===t?null===e?"":e:null==e||""===e?t:t+" "+e}const Jv=ze({__forward_ref__:ze});function qa(t){return t.__forward_ref__=qa,t.toString=function(){return Le(this())},t}function we(t){return function(t){return"function"==typeof t&&t.hasOwnProperty(Jv)&&t.__forward_ref__===qa}(t)?t():t}class Ti extends Error{constructor(e,n){super(function(t,e){return`${t?`NG0${t}: `:""}${e}`}(e,n)),this.code=e}}function Pt(t){return"function"==typeof t?t.name||t.toString():"object"==typeof t&&null!=t&&"function"==typeof t.type?t.type.name||t.type.toString():function(t){return"string"==typeof t?t:null==t?"":String(t)}(t)}function ro(t,e){const n=e?` in ${e}`:"";throw new Ti("201",`No provider for ${Pt(t)} found${n}`)}function $t(t,e){null==t&&function(t,e,n,i){throw new Error(`ASSERTION ERROR: ${t}`+(null==i?"":` [Expected=> ${n} ${i} ${e} <=Actual]`))}(e,t,null,"!=")}function qe(t){return{token:t.token,providedIn:t.providedIn||null,factory:t.factory,value:void 0}}function xi(t){return{providers:t.providers||[],imports:t.imports||[]}}function Qn(t){return Ih(t,so)||Ih(t,Oh)}function Ih(t,e){return t.hasOwnProperty(e)?t[e]:null}function Mh(t){return t&&(t.hasOwnProperty(Ka)||t.hasOwnProperty(o_))?t[Ka]:null}const so=ze({\u0275prov:ze}),Ka=ze({\u0275inj:ze}),Oh=ze({ngInjectableDef:ze}),o_=ze({ngInjectorDef:ze});var Te=(()=>((Te=Te||{})[Te.Default=0]="Default",Te[Te.Host=1]="Host",Te[Te.Self=2]="Self",Te[Te.SkipSelf=4]="SkipSelf",Te[Te.Optional=8]="Optional",Te))();let Za;function ci(t){const e=Za;return Za=t,e}function Ah(t,e,n){const i=Qn(t);return i&&"root"==i.providedIn?void 0===i.value?i.value=i.factory():i.value:n&Te.Optional?null:void 0!==e?e:void ro(Le(t),"Injector")}function hi(t){return{toString:t}.toString()}var tn=(()=>((tn=tn||{})[tn.OnPush=0]="OnPush",tn[tn.Default=1]="Default",tn))(),mt=(()=>((mt=mt||{})[mt.Emulated=0]="Emulated",mt[mt.None=2]="None",mt[mt.ShadowDom=3]="ShadowDom",mt))();const l_="undefined"!=typeof globalThis&&globalThis,u_="undefined"!=typeof window&&window,c_="undefined"!=typeof self&&"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&self,$e=l_||"undefined"!=typeof global&&global||u_||c_,Xi={},Qe=[],oo=ze({\u0275cmp:ze}),Ja=ze({\u0275dir:ze}),el=ze({\u0275pipe:ze}),Ph=ze({\u0275mod:ze}),h_=ze({\u0275loc:ze}),Kn=ze({\u0275fac:ze}),Kr=ze({__NG_ELEMENT_ID__:ze});let f_=0;function tl(t){return hi(()=>{const n={},i={type:t.type,providersResolver:null,decls:t.decls,vars:t.vars,factory:null,template:t.template||null,consts:t.consts||null,ngContentSelectors:t.ngContentSelectors,hostBindings:t.hostBindings||null,hostVars:t.hostVars||0,hostAttrs:t.hostAttrs||null,contentQueries:t.contentQueries||null,declaredInputs:n,inputs:null,outputs:null,exportAs:t.exportAs||null,onPush:t.changeDetection===tn.OnPush,directiveDefs:null,pipeDefs:null,selectors:t.selectors||Qe,viewQuery:t.viewQuery||null,features:t.features||null,data:t.data||{},encapsulation:t.encapsulation||mt.Emulated,id:"c",styles:t.styles||Qe,_:null,setInput:null,schemas:t.schemas||null,tView:null},r=t.directives,s=t.features,c=t.pipes;return i.id+=f_++,i.inputs=Nh(t.inputs,n),i.outputs=Nh(t.outputs),s&&s.forEach(g=>g(i)),i.directiveDefs=r?()=>("function"==typeof r?r():r).map(Fh):null,i.pipeDefs=c?()=>("function"==typeof c?c():c).map(Rh):null,i})}function Fh(t){return Ft(t)||function(t){return t[Ja]||null}(t)}function Rh(t){return function(t){return t[el]||null}(t)}const kh={};function Zr(t){return hi(()=>{const e={type:t.type,bootstrap:t.bootstrap||Qe,declarations:t.declarations||Qe,imports:t.imports||Qe,exports:t.exports||Qe,transitiveCompileScopes:null,schemas:t.schemas||null,id:t.id||null};return null!=t.id&&(kh[t.id]=t.type),e})}function Nh(t,e){if(null==t)return Xi;const n={};for(const i in t)if(t.hasOwnProperty(i)){let r=t[i],s=r;Array.isArray(r)&&(s=r[1],r=r[0]),n[r]=i,e&&(e[r]=s)}return n}function Ft(t){return t[oo]||null}function rn(t,e){const n=t[Ph]||null;if(!n&&!0===e)throw new Error(`Type ${Le(t)} does not have '\u0275mod' property.`);return n}function Rn(t){return Array.isArray(t)&&"object"==typeof t[1]}function yn(t){return Array.isArray(t)&&!0===t[1]}function rl(t){return 0!=(8&t.flags)}function co(t){return 2==(2&t.flags)}function vn(t){return null!==t.template}function __(t){return 0!=(512&t[2])}function Pi(t,e){return t.hasOwnProperty(Kn)?t[Kn]:null}class ol{constructor(e,n,i){this.previousValue=e,this.currentValue=n,this.firstChange=i}isFirstChange(){return this.firstChange}}function jh(t){return t.type.prototype.ngOnChanges&&(t.setInput=D_),w_}function w_(){const t=Vh(this),e=null==t?void 0:t.current;if(e){const n=t.previous;if(n===Xi)t.previous=e;else for(let i in e)n[i]=e[i];t.current=null,this.ngOnChanges(e)}}function D_(t,e,n,i){const r=Vh(t)||function(t,e){return t[Bh]=e}(t,{previous:Xi,current:null}),s=r.current||(r.current={}),c=r.previous,g=this.declaredInputs[n],_=c[g];s[g]=new ol(_&&_.currentValue,e,c===Xi),t[i]=e}const Bh="__ngSimpleChanges__";function Vh(t){return t[Bh]||null}let ll;function lt(t){return!!t.listen}const Wh={createRenderer:(t,e)=>void 0!==ll?ll:"undefined"!=typeof document?document:void 0};function dt(t){for(;Array.isArray(t);)t=t[0];return t}function an(t,e){return dt(e[t.index])}function qt(t,e){const n=e[t];return Rn(n)?n:n[0]}function Gh(t){return 4==(4&t[2])}function hl(t){return 128==(128&t[2])}function di(t,e){return null==e?null:t[e]}function Yh(t){t[18]=0}function fl(t,e){t[5]+=e;let n=t,i=t[3];for(;null!==i&&(1===e&&1===n[5]||-1===e&&0===n[5]);)i[5]+=e,n=i,i=i[3]}const Me={lFrame:Jh(null),bindingsEnabled:!0,isInCheckNoChangesMode:!1};function zh(){return Me.bindingsEnabled}function re(){return Me.lFrame.lView}function Ge(){return Me.lFrame.tView}function yt(){let t=$h();for(;null!==t&&64===t.type;)t=t.parent;return t}function $h(){return Me.lFrame.currentTNode}function kn(t,e){const n=Me.lFrame;n.currentTNode=t,n.isParent=e}function dl(){return Me.lFrame.isParent}function po(){return Me.isInCheckNoChangesMode}function mo(t){Me.isInCheckNoChangesMode=t}function B_(t,e){const n=Me.lFrame;n.bindingIndex=n.bindingRootIndex=t,pl(e)}function pl(t){Me.lFrame.currentDirectiveIndex=t}function Qh(){return Me.lFrame.currentQueryIndex}function yl(t){Me.lFrame.currentQueryIndex=t}function H_(t){const e=t[1];return 2===e.type?e.declTNode:1===e.type?t[6]:null}function Kh(t,e,n){if(n&Te.SkipSelf){let r=e,s=t;for(;!(r=r.parent,null!==r||n&Te.Host||(r=H_(s),null===r||(s=s[15],10&r.type))););if(null===r)return!1;e=r,t=s}const i=Me.lFrame=Zh();return i.currentTNode=e,i.lView=t,!0}function yo(t){const e=Zh(),n=t[1];Me.lFrame=e,e.currentTNode=n.firstChild,e.lView=t,e.tView=n,e.contextLView=t,e.bindingIndex=n.bindingStartIndex,e.inI18n=!1}function Zh(){const t=Me.lFrame,e=null===t?null:t.child;return null===e?Jh(t):e}function Jh(t){const e={currentTNode:null,isParent:!0,lView:null,tView:null,selectedIndex:-1,contextLView:null,elementDepthCount:0,currentNamespace:null,currentDirectiveIndex:-1,bindingRootIndex:-1,bindingIndex:-1,currentQueryIndex:0,parent:t,child:null,inI18n:!1};return null!==t&&(t.child=e),e}function ef(){const t=Me.lFrame;return Me.lFrame=t.parent,t.currentTNode=null,t.lView=null,t}const tf=ef;function vo(){const t=ef();t.isParent=!0,t.tView=null,t.selectedIndex=-1,t.contextLView=null,t.elementDepthCount=0,t.currentDirectiveIndex=-1,t.currentNamespace=null,t.bindingRootIndex=-1,t.bindingIndex=-1,t.currentQueryIndex=0}function gi(t){Me.lFrame.selectedIndex=t}function _o(t,e){for(let n=e.directiveStart,i=e.directiveEnd;n<i;n++){const s=t.data[n].type.prototype,{ngAfterContentInit:c,ngAfterContentChecked:g,ngAfterViewInit:_,ngAfterViewChecked:w,ngOnDestroy:S}=s;c&&(t.contentHooks||(t.contentHooks=[])).push(-n,c),g&&((t.contentHooks||(t.contentHooks=[])).push(n,g),(t.contentCheckHooks||(t.contentCheckHooks=[])).push(n,g)),_&&(t.viewHooks||(t.viewHooks=[])).push(-n,_),w&&((t.viewHooks||(t.viewHooks=[])).push(n,w),(t.viewCheckHooks||(t.viewCheckHooks=[])).push(n,w)),null!=S&&(t.destroyHooks||(t.destroyHooks=[])).push(n,S)}}function Co(t,e,n){nf(t,e,3,n)}function bo(t,e,n,i){(3&t[2])===n&&nf(t,e,n,i)}function vl(t,e){let n=t[2];(3&n)===e&&(n&=2047,n+=1,t[2]=n)}function nf(t,e,n,i){const s=null!=i?i:-1,c=e.length-1;let g=0;for(let _=void 0!==i?65535&t[18]:0;_<c;_++)if("number"==typeof e[_+1]){if(g=e[_],null!=i&&g>=i)break}else e[_]<0&&(t[18]+=65536),(g<s||-1==s)&&(Q_(t,n,e,_),t[18]=(4294901760&t[18])+_+2),_++}function Q_(t,e,n,i){const r=n[i]<0,s=n[i+1],g=t[r?-n[i]:n[i]];if(r){if(t[2]>>11<t[18]>>16&&(3&t[2])===e){t[2]+=2048;try{s.call(g)}finally{}}}else try{s.call(g)}finally{}}class is{constructor(e,n,i){this.factory=e,this.resolving=!1,this.canSeeViewProviders=n,this.injectImpl=i}}function wo(t,e,n){const i=lt(t);let r=0;for(;r<n.length;){const s=n[r];if("number"==typeof s){if(0!==s)break;r++;const c=n[r++],g=n[r++],_=n[r++];i?t.setAttribute(e,g,_,c):e.setAttributeNS(c,g,_)}else{const c=s,g=n[++r];Cl(c)?i&&t.setProperty(e,c,g):i?t.setAttribute(e,c,g):e.setAttribute(c,g),r++}}return r}function rf(t){return 3===t||4===t||6===t}function Cl(t){return 64===t.charCodeAt(0)}function Do(t,e){if(null!==e&&0!==e.length)if(null===t||0===t.length)t=e.slice();else{let n=-1;for(let i=0;i<e.length;i++){const r=e[i];"number"==typeof r?n=r:0===n||sf(t,n,r,null,-1===n||2===n?e[++i]:null)}}return t}function sf(t,e,n,i,r){let s=0,c=t.length;if(-1===e)c=-1;else for(;s<t.length;){const g=t[s++];if("number"==typeof g){if(g===e){c=-1;break}if(g>e){c=s-1;break}}}for(;s<t.length;){const g=t[s];if("number"==typeof g)break;if(g===n){if(null===i)return void(null!==r&&(t[s+1]=r));if(i===t[s+1])return void(t[s+2]=r)}s++,null!==i&&s++,null!==r&&s++}-1!==c&&(t.splice(c,0,e),s=c+1),t.splice(s++,0,n),null!==i&&t.splice(s++,0,i),null!==r&&t.splice(s++,0,r)}function of(t){return-1!==t}function tr(t){return 32767&t}function nr(t,e){let n=function(t){return t>>16}(t),i=e;for(;n>0;)i=i[15],n--;return i}let bl=!0;function Eo(t){const e=bl;return bl=t,e}let nC=0;function ss(t,e){const n=Dl(t,e);if(-1!==n)return n;const i=e[1];i.firstCreatePass&&(t.injectorIndex=e.length,wl(i.data,t),wl(e,null),wl(i.blueprint,null));const r=So(t,e),s=t.injectorIndex;if(of(r)){const c=tr(r),g=nr(r,e),_=g[1].data;for(let w=0;w<8;w++)e[s+w]=g[c+w]|_[c+w]}return e[s+8]=r,s}function wl(t,e){t.push(0,0,0,0,0,0,0,0,e)}function Dl(t,e){return-1===t.injectorIndex||t.parent&&t.parent.injectorIndex===t.injectorIndex||null===e[t.injectorIndex+8]?-1:t.injectorIndex}function So(t,e){if(t.parent&&-1!==t.parent.injectorIndex)return t.parent.injectorIndex;let n=0,i=null,r=e;for(;null!==r;){const s=r[1],c=s.type;if(i=2===c?s.declTNode:1===c?r[6]:null,null===i)return-1;if(n++,r=r[15],-1!==i.injectorIndex)return i.injectorIndex|n<<16}return-1}function To(t,e,n){!function(t,e,n){let i;"string"==typeof n?i=n.charCodeAt(0)||0:n.hasOwnProperty(Kr)&&(i=n[Kr]),null==i&&(i=n[Kr]=nC++);const r=255&i;e.data[t+(r>>5)]|=1<<r}(t,e,n)}function uf(t,e,n){if(n&Te.Optional)return t;ro(e,"NodeInjector")}function cf(t,e,n,i){if(n&Te.Optional&&void 0===i&&(i=null),0==(n&(Te.Self|Te.Host))){const r=t[9],s=ci(void 0);try{return r?r.get(e,i,n&Te.Optional):Ah(e,i,n&Te.Optional)}finally{ci(s)}}return uf(i,e,n)}const ff={};function sC(){return new ir(yt(),re())}function oC(t,e,n,i,r,s){const c=e[1],g=c.data[t+8],S=xo(g,c,n,null==i?co(g)&&bl:i!=c&&0!=(3&g.type),r&Te.Host&&s===g);return null!==S?os(e,c,S,g):ff}function xo(t,e,n,i,r){const s=t.providerIndexes,c=e.data,g=1048575&s,_=t.directiveStart,S=s>>20,M=r?g+S:t.directiveEnd;for(let P=i?g:g+S;P<M;P++){const j=c[P];if(P<_&&n===j||P>=_&&j.type===n)return P}if(r){const P=c[_];if(P&&vn(P)&&P.type===n)return _}return null}function os(t,e,n,i){let r=t[n];const s=e.data;if(function(t){return t instanceof is}(r)){const c=r;c.resolving&&function(t,e){throw new Ti("200",`Circular dependency in DI detected for ${t}`)}(Pt(s[n]));const g=Eo(c.canSeeViewProviders);c.resolving=!0;const _=c.injectImpl?ci(c.injectImpl):null;Kh(t,i,Te.Default);try{r=t[n]=c.factory(void 0,s,t,i),e.firstCreatePass&&n>=i.directiveStart&&function(t,e,n){const{ngOnChanges:i,ngOnInit:r,ngDoCheck:s}=e.type.prototype;if(i){const c=jh(e);(n.preOrderHooks||(n.preOrderHooks=[])).push(t,c),(n.preOrderCheckHooks||(n.preOrderCheckHooks=[])).push(t,c)}r&&(n.preOrderHooks||(n.preOrderHooks=[])).push(0-t,r),s&&((n.preOrderHooks||(n.preOrderHooks=[])).push(t,s),(n.preOrderCheckHooks||(n.preOrderCheckHooks=[])).push(t,s))}(n,s[n],e)}finally{null!==_&&ci(_),Eo(g),c.resolving=!1,tf()}}return r}function df(t,e,n){return!!(n[e+(t>>5)]&1<<t)}function gf(t,e){return!(t&Te.Self||t&Te.Host&&e)}class ir{constructor(e,n){this._tNode=e,this._lView=n}get(e,n,i){return function(t,e,n,i=Te.Default,r){if(null!==t){const s=function(t){if("string"==typeof t)return t.charCodeAt(0)||0;const e=t.hasOwnProperty(Kr)?t[Kr]:void 0;return"number"==typeof e?e>=0?255&e:sC:e}(n);if("function"==typeof s){if(!Kh(e,t,i))return i&Te.Host?uf(r,n,i):cf(e,n,i,r);try{const c=s(i);if(null!=c||i&Te.Optional)return c;ro(n)}finally{tf()}}else if("number"==typeof s){let c=null,g=Dl(t,e),_=-1,w=i&Te.Host?e[16][6]:null;for((-1===g||i&Te.SkipSelf)&&(_=-1===g?So(t,e):e[g+8],-1!==_&&gf(i,!1)?(c=e[1],g=tr(_),e=nr(_,e)):g=-1);-1!==g;){const S=e[1];if(df(s,g,S.data)){const x=oC(g,e,n,c,i,w);if(x!==ff)return x}_=e[g+8],-1!==_&&gf(i,e[1].data[g+8]===w)&&df(s,g,e)?(c=S,g=tr(_),e=nr(_,e)):g=-1}}}return cf(e,n,i,r)}(this._tNode,this._lView,e,i,n)}}const sr="__parameters__";function Fi(t,e,n){return hi(()=>{const i=function(t){return function(...n){if(t){const i=t(...n);for(const r in i)this[r]=i[r]}}}(e);function r(...s){if(this instanceof r)return i.apply(this,s),this;const c=new r(...s);return g.annotation=c,g;function g(_,w,S){const x=_.hasOwnProperty(sr)?_[sr]:Object.defineProperty(_,sr,{value:[]})[sr];for(;x.length<=S;)x.push(null);return(x[S]=x[S]||[]).push(c),_}}return n&&(r.prototype=Object.create(n.prototype)),r.prototype.ngMetadataName=t,r.annotationCls=r,r})}class Ke{constructor(e,n){this._desc=e,this.ngMetadataName="InjectionToken",this.\u0275prov=void 0,"number"==typeof n?this.__NG_ELEMENT_ID__=n:void 0!==n&&(this.\u0275prov=qe({token:this,providedIn:n.providedIn||"root",factory:n.factory}))}toString(){return`InjectionToken ${this._desc}`}}function ln(t,e){void 0===e&&(e=t);for(let n=0;n<t.length;n++){let i=t[n];Array.isArray(i)?(e===t&&(e=t.slice(0,n)),ln(i,e)):e!==t&&e.push(i)}return e}function Ln(t,e){t.forEach(n=>Array.isArray(n)?Ln(n,e):e(n))}function Mo(t,e,n){e>=t.length?t.push(n):t.splice(e,0,n)}function Ri(t,e){return e>=t.length-1?t.pop():t.splice(e,1)[0]}const cs={},Ol="__NG_DI_FLAG__",lr="ngTempTokenPath",CC=/\n/gm,Al="__source",Pl=ze({provide:String,useValue:ze});let hs;function ur(t){const e=hs;return hs=t,e}function wC(t,e=Te.Default){if(void 0===hs)throw new Error("inject() must be called from an injection context");return null===hs?Ah(t,void 0,e):hs.get(t,e&Te.Optional?null:void 0,e)}function Ve(t,e=Te.Default){return(Za||wC)(we(t),e)}function ki(t){const e=[];for(let n=0;n<t.length;n++){const i=we(t[n]);if(Array.isArray(i)){if(0===i.length)throw new Error("Arguments array must have arguments.");let r,s=Te.Default;for(let c=0;c<i.length;c++){const g=i[c],_=DC(g);"number"==typeof _?-1===_?r=g.token:s|=_:r=g}e.push(Ve(r,s))}else e.push(Ve(i))}return e}function fs(t,e){return t[Ol]=e,t.prototype[Ol]=e,t}function DC(t){return t[Ol]}function Cf(t,e,n,i){const r=t[lr];throw e[Al]&&r.unshift(e[Al]),t.message=function(t,e,n,i=null){t=t&&"\n"===t.charAt(0)&&"\u0275"==t.charAt(1)?t.substr(2):t;let r=Le(e);if(Array.isArray(e))r=e.map(Le).join(" -> ");else if("object"==typeof e){let s=[];for(let c in e)if(e.hasOwnProperty(c)){let g=e[c];s.push(c+":"+("string"==typeof g?JSON.stringify(g):Le(g)))}r=`{${s.join(", ")}}`}return`${n}${i?"("+i+")":""}[${r}]: ${t.replace(CC,"\n ")}`}("\n"+t.message,r,n,i),t.ngTokenPath=r,t[lr]=null,t}const ds=fs(Fi("Inject",t=>({token:t})),-1),jn=fs(Fi("Optional"),8),Ni=fs(Fi("SkipSelf"),4),Vf="__ngContext__";function It(t,e){t[Vf]=e}function Hl(t){const e=function(t){return t[Vf]||null}(t);return e?Array.isArray(e)?e:e.lView:null}function No(t){return t.ngOriginalError}function m0(t,...e){t.error(...e)}class ji{constructor(){this._console=console}handleError(e){const n=this._findOriginalError(e),i=this._findContext(e),r=function(t){return t&&t.ngErrorLogger||m0}(e);r(this._console,"ERROR",e),n&&r(this._console,"ORIGINAL ERROR",n),i&&r(this._console,"ERROR CONTEXT",i)}_findContext(e){return e?function(t){return t.ngDebugContext}(e)||this._findContext(No(e)):null}_findOriginalError(e){let n=e&&No(e);for(;n&&No(n);)n=No(n);return n||null}}const qf=(()=>("undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||setTimeout).bind($e))();function Hn(t){return t instanceof Function?t():t}var Zt=(()=>((Zt=Zt||{})[Zt.Important=1]="Important",Zt[Zt.DashCase=2]="DashCase",Zt))();function Gl(t,e){return undefined(t,e)}function _s(t){const e=t[3];return yn(e)?e[3]:e}function Yl(t){return ed(t[13])}function zl(t){return ed(t[4])}function ed(t){for(;null!==t&&!yn(t);)t=t[4];return t}function dr(t,e,n,i,r){if(null!=i){let s,c=!1;yn(i)?s=i:Rn(i)&&(c=!0,i=i[0]);const g=dt(i);0===t&&null!==n?null==r?od(e,n,g):Bi(e,n,g,r||null,!0):1===t&&null!==n?Bi(e,n,g,r||null,!0):2===t?function(t,e,n){const i=jo(t,e);i&&function(t,e,n,i){lt(t)?t.removeChild(e,n,i):e.removeChild(n)}(t,i,e,n)}(e,g,c):3===t&&e.destroyNode(g),null!=s&&function(t,e,n,i,r){const s=n[7];s!==dt(n)&&dr(e,t,i,s,r);for(let g=10;g<n.length;g++){const _=n[g];Cs(_[1],_,t,e,i,s)}}(e,t,s,n,r)}}function Xl(t,e,n){return lt(t)?t.createElement(e,n):null===n?t.createElement(e):t.createElementNS(n,e)}function nd(t,e){const n=t[9],i=n.indexOf(e),r=e[3];1024&e[2]&&(e[2]&=-1025,fl(r,-1)),n.splice(i,1)}function ql(t,e){if(t.length<=10)return;const n=10+e,i=t[n];if(i){const r=i[17];null!==r&&r!==t&&nd(r,i),e>0&&(t[n-1][4]=i[4]);const s=Ri(t,10+e);!function(t,e){Cs(t,e,e[11],2,null,null),e[0]=null,e[6]=null}(i[1],i);const c=s[19];null!==c&&c.detachView(s[1]),i[3]=null,i[4]=null,i[2]&=-129}return i}function id(t,e){if(!(256&e[2])){const n=e[11];lt(n)&&n.destroyNode&&Cs(t,e,n,3,null,null),function(t){let e=t[13];if(!e)return Ql(t[1],t);for(;e;){let n=null;if(Rn(e))n=e[13];else{const i=e[10];i&&(n=i)}if(!n){for(;e&&!e[4]&&e!==t;)Rn(e)&&Ql(e[1],e),e=e[3];null===e&&(e=t),Rn(e)&&Ql(e[1],e),n=e&&e[4]}e=n}}(e)}}function Ql(t,e){if(!(256&e[2])){e[2]&=-129,e[2]|=256,function(t,e){let n;if(null!=t&&null!=(n=t.destroyHooks))for(let i=0;i<n.length;i+=2){const r=e[n[i]];if(!(r instanceof is)){const s=n[i+1];if(Array.isArray(s))for(let c=0;c<s.length;c+=2){const g=r[s[c]],_=s[c+1];try{_.call(g)}finally{}}else try{s.call(r)}finally{}}}}(t,e),function(t,e){const n=t.cleanup,i=e[7];let r=-1;if(null!==n)for(let s=0;s<n.length-1;s+=2)if("string"==typeof n[s]){const c=n[s+1],g="function"==typeof c?c(e):dt(e[c]),_=i[r=n[s+2]],w=n[s+3];"boolean"==typeof w?g.removeEventListener(n[s],_,w):w>=0?i[r=w]():i[r=-w].unsubscribe(),s+=2}else{const c=i[r=n[s+1]];n[s].call(c)}if(null!==i){for(let s=r+1;s<i.length;s++)i[s]();e[7]=null}}(t,e),1===e[1].type&<(e[11])&&e[11].destroy();const n=e[17];if(null!==n&&yn(e[3])){n!==e[3]&&nd(n,e);const i=e[19];null!==i&&i.detachView(t)}}}function rd(t,e,n){return function(t,e,n){let i=e;for(;null!==i&&40&i.type;)i=(e=i).parent;if(null===i)return n[0];if(2&i.flags){const r=t.data[i.directiveStart].encapsulation;if(r===mt.None||r===mt.Emulated)return null}return an(i,n)}(t,e.parent,n)}function Bi(t,e,n,i,r){lt(t)?t.insertBefore(e,n,i,r):e.insertBefore(n,i,r)}function od(t,e,n){lt(t)?t.appendChild(e,n):e.appendChild(n)}function ad(t,e,n,i,r){null!==i?Bi(t,e,n,i,r):od(t,e,n)}function jo(t,e){return lt(t)?t.parentNode(e):e.parentNode}let cd=function(t,e,n){return 40&t.type?an(t,n):null};function Bo(t,e,n,i){const r=rd(t,i,e),s=e[11],g=function(t,e,n){return cd(t,e,n)}(i.parent||e[6],i,e);if(null!=r)if(Array.isArray(n))for(let _=0;_<n.length;_++)ad(s,r,n[_],g,!1);else ad(s,r,n,g,!1)}function Vo(t,e){if(null!==e){const n=e.type;if(3&n)return an(e,t);if(4&n)return Zl(-1,t[e.index]);if(8&n){const i=e.child;if(null!==i)return Vo(t,i);{const r=t[e.index];return yn(r)?Zl(-1,r):dt(r)}}if(32&n)return Gl(e,t)()||dt(t[e.index]);{const i=fd(t,e);return null!==i?Array.isArray(i)?i[0]:Vo(_s(t[16]),i):Vo(t,e.next)}}return null}function fd(t,e){return null!==e?t[16][6].projection[e.projection]:null}function Zl(t,e){const n=10+t+1;if(n<e.length){const i=e[n],r=i[1].firstChild;if(null!==r)return Vo(i,r)}return e[7]}function Jl(t,e,n,i,r,s,c){for(;null!=n;){const g=i[n.index],_=n.type;if(c&&0===e&&(g&&It(dt(g),i),n.flags|=4),64!=(64&n.flags))if(8&_)Jl(t,e,n.child,i,r,s,!1),dr(e,t,r,g,s);else if(32&_){const w=Gl(n,i);let S;for(;S=w();)dr(e,t,r,S,s);dr(e,t,r,g,s)}else 16&_?gd(t,e,i,n,r,s):dr(e,t,r,g,s);n=c?n.projectionNext:n.next}}function Cs(t,e,n,i,r,s){Jl(n,i,t.firstChild,e,r,s,!1)}function gd(t,e,n,i,r,s){const c=n[16],_=c[6].projection[i.projection];if(Array.isArray(_))for(let w=0;w<_.length;w++)dr(e,t,r,_[w],s);else Jl(t,e,_,c[3],r,s,!0)}function pd(t,e,n){lt(t)?t.setAttribute(e,"style",n):e.style.cssText=n}function eu(t,e,n){lt(t)?""===n?t.removeAttribute(e,"class"):t.setAttribute(e,"class",n):e.className=n}function md(t,e,n){let i=t.length;for(;;){const r=t.indexOf(e,n);if(-1===r)return r;if(0===r||t.charCodeAt(r-1)<=32){const s=e.length;if(r+s===i||t.charCodeAt(r+s)<=32)return r}n=r+1}}const yd="ng-template";function U0(t,e,n){let i=0;for(;i<t.length;){let r=t[i++];if(n&&"class"===r){if(r=t[i],-1!==md(r.toLowerCase(),e,0))return!0}else if(1===r){for(;i<t.length&&"string"==typeof(r=t[i++]);)if(r.toLowerCase()===e)return!0;return!1}}return!1}function vd(t){return 4===t.type&&t.value!==yd}function W0(t,e,n){return e===(4!==t.type||n?t.value:yd)}function G0(t,e,n){let i=4;const r=t.attrs||[],s=function(t){for(let e=0;e<t.length;e++)if(rf(t[e]))return e;return t.length}(r);let c=!1;for(let g=0;g<e.length;g++){const _=e[g];if("number"!=typeof _){if(!c)if(4&i){if(i=2|1&i,""!==_&&!W0(t,_,n)||""===_&&1===e.length){if(_n(i))return!1;c=!0}}else{const w=8&i?_:e[++g];if(8&i&&null!==t.attrs){if(!U0(t.attrs,w,n)){if(_n(i))return!1;c=!0}continue}const x=Y0(8&i?"class":_,r,vd(t),n);if(-1===x){if(_n(i))return!1;c=!0;continue}if(""!==w){let M;M=x>s?"":r[x+1].toLowerCase();const P=8&i?M:null;if(P&&-1!==md(P,w,0)||2&i&&w!==M){if(_n(i))return!1;c=!0}}}}else{if(!c&&!_n(i)&&!_n(_))return!1;if(c&&_n(_))continue;c=!1,i=_|1&i}}return _n(i)||c}function _n(t){return 0==(1&t)}function Y0(t,e,n,i){if(null===e)return-1;let r=0;if(i||!n){let s=!1;for(;r<e.length;){const c=e[r];if(c===t)return r;if(3===c||6===c)s=!0;else{if(1===c||2===c){let g=e[++r];for(;"string"==typeof g;)g=e[++r];continue}if(4===c)break;if(0===c){r+=4;continue}}r+=s?1:2}return-1}return function(t,e){let n=t.indexOf(4);if(n>-1)for(n++;n<t.length;){const i=t[n];if("number"==typeof i)return-1;if(i===e)return n;n++}return-1}(e,t)}function _d(t,e,n=!1){for(let i=0;i<e.length;i++)if(G0(t,e[i],n))return!0;return!1}function Cd(t,e){return t?":not("+e.trim()+")":e}function Q0(t){let e=t[0],n=1,i=2,r="",s=!1;for(;n<t.length;){let c=t[n];if("string"==typeof c)if(2&i){const g=t[++n];r+="["+c+(g.length>0?'="'+g+'"':"")+"]"}else 8&i?r+="."+c:4&i&&(r+=" "+c);else""!==r&&!_n(c)&&(e+=Cd(s,r),r=""),i=c,s=s||!_n(i);n++}return""!==r&&(e+=Cd(s,r)),e}const Ae={};function Ad(t,e){const n=t.contentQueries;if(null!==n)for(let i=0;i<n.length;i+=2){const r=n[i],s=n[i+1];if(-1!==s){const c=t.data[s];yl(r),c.contentQueries(2,e[s],s)}}}function bs(t,e,n,i,r,s,c,g,_,w){const S=e.blueprint.slice();return S[0]=r,S[2]=140|i,Yh(S),S[3]=S[15]=t,S[8]=n,S[10]=c||t&&t[10],S[11]=g||t&&t[11],S[12]=_||t&&t[12]||null,S[9]=w||t&&t[9]||null,S[6]=s,S[16]=2==e.type?t[16]:S,S}function gr(t,e,n,i,r){let s=t.data[e];if(null===s)s=function(t,e,n,i,r){const s=$h(),c=dl(),_=t.data[e]=function(t,e,n,i,r,s){return{type:n,index:i,insertBeforeIndex:null,injectorIndex:e?e.injectorIndex:-1,directiveStart:-1,directiveEnd:-1,directiveStylingLast:-1,propertyBindings:null,flags:0,providerIndexes:0,value:r,attrs:s,mergedAttrs:null,localNames:null,initialInputs:void 0,inputs:null,outputs:null,tViews:null,next:null,projectionNext:null,child:null,parent:e,projection:null,styles:null,stylesWithoutHost:null,residualStyles:void 0,classes:null,classesWithoutHost:null,residualClasses:void 0,classBindings:0,styleBindings:0}}(0,c?s:s&&s.parent,n,e,i,r);return null===t.firstChild&&(t.firstChild=_),null!==s&&(c?null==s.child&&null!==_.parent&&(s.child=_):null===s.next&&(s.next=_)),_}(t,e,n,i,r),Me.lFrame.inI18n&&(s.flags|=64);else if(64&s.type){s.type=n,s.value=i,s.attrs=r;const c=function(){const t=Me.lFrame,e=t.currentTNode;return t.isParent?e:e.parent}();s.injectorIndex=null===c?-1:c.injectorIndex}return kn(s,!0),s}function pr(t,e,n,i){if(0===n)return-1;const r=e.length;for(let s=0;s<n;s++)e.push(i),t.blueprint.push(i),t.data.push(null);return r}function ws(t,e,n){yo(e);try{const i=t.viewQuery;null!==i&&_u(1,i,n);const r=t.template;null!==r&&Pd(t,e,r,1,n),t.firstCreatePass&&(t.firstCreatePass=!1),t.staticContentQueries&&Ad(t,e),t.staticViewQueries&&_u(2,t.viewQuery,n);const s=t.components;null!==s&&function(t,e){for(let n=0;n<e.length;n++)Ob(t,e[n])}(e,s)}catch(i){throw t.firstCreatePass&&(t.incompleteFirstPass=!0,t.firstCreatePass=!1),i}finally{e[2]&=-5,vo()}}function mr(t,e,n,i){const r=e[2];if(256==(256&r))return;yo(e);const s=po();try{Yh(e),function(t){Me.lFrame.bindingIndex=t}(t.bindingStartIndex),null!==n&&Pd(t,e,n,2,i);const c=3==(3&r);if(!s)if(c){const w=t.preOrderCheckHooks;null!==w&&Co(e,w,null)}else{const w=t.preOrderHooks;null!==w&&bo(e,w,0,null),vl(e,0)}if(function(t){for(let e=Yl(t);null!==e;e=zl(e)){if(!e[2])continue;const n=e[9];for(let i=0;i<n.length;i++){const r=n[i],s=r[3];0==(1024&r[2])&&fl(s,1),r[2]|=1024}}}(e),function(t){for(let e=Yl(t);null!==e;e=zl(e))for(let n=10;n<e.length;n++){const i=e[n],r=i[1];hl(i)&&mr(r,i,r.template,i[8])}}(e),null!==t.contentQueries&&Ad(t,e),!s)if(c){const w=t.contentCheckHooks;null!==w&&Co(e,w)}else{const w=t.contentHooks;null!==w&&bo(e,w,1),vl(e,1)}!function(t,e){const n=t.hostBindingOpCodes;if(null!==n)try{for(let i=0;i<n.length;i++){const r=n[i];if(r<0)gi(~r);else{const s=r,c=n[++i],g=n[++i];B_(c,s),g(2,e[s])}}}finally{gi(-1)}}(t,e);const g=t.components;null!==g&&function(t,e){for(let n=0;n<e.length;n++)Mb(t,e[n])}(e,g);const _=t.viewQuery;if(null!==_&&_u(2,_,i),!s)if(c){const w=t.viewCheckHooks;null!==w&&Co(e,w)}else{const w=t.viewHooks;null!==w&&bo(e,w,2),vl(e,2)}!0===t.firstUpdatePass&&(t.firstUpdatePass=!1),s||(e[2]&=-73),1024&e[2]&&(e[2]&=-1025,fl(e[3],-1))}finally{vo()}}function cb(t,e,n,i){const r=e[10],s=!po(),c=Gh(e);try{s&&!c&&r.begin&&r.begin(),c&&ws(t,e,i),mr(t,e,n,i)}finally{s&&!c&&r.end&&r.end()}}function Pd(t,e,n,i,r){const s=Me.lFrame.selectedIndex,c=2&i;try{gi(-1),c&&e.length>20&&function(t,e,n,i){if(!i)if(3==(3&e[2])){const s=t.preOrderCheckHooks;null!==s&&Co(e,s,n)}else{const s=t.preOrderHooks;null!==s&&bo(e,s,0,n)}gi(n)}(t,e,20,po()),n(i,r)}finally{gi(s)}}function Rd(t){const e=t.tView;return null===e||e.incompleteFirstPass?t.tView=Go(1,null,t.template,t.decls,t.vars,t.directiveDefs,t.pipeDefs,t.viewQuery,t.schemas,t.consts):e}function Go(t,e,n,i,r,s,c,g,_,w){const S=20+i,x=S+r,M=function(t,e){const n=[];for(let i=0;i<e;i++)n.push(i<t?null:Ae);return n}(S,x),P="function"==typeof w?w():w;return M[1]={type:t,blueprint:M,template:n,queries:null,viewQuery:g,declTNode:e,data:M.slice().fill(null,S),bindingStartIndex:S,expandoStartIndex:x,hostBindingOpCodes:null,firstCreatePass:!0,firstUpdatePass:!0,staticViewQueries:!1,staticContentQueries:!1,preOrderHooks:null,preOrderCheckHooks:null,contentHooks:null,contentCheckHooks:null,viewHooks:null,viewCheckHooks:null,destroyHooks:null,cleanup:null,contentQueries:null,components:null,directiveRegistry:"function"==typeof s?s():s,pipeRegistry:"function"==typeof c?c():c,firstChild:null,schemas:_,consts:P,incompleteFirstPass:!1}}function Ld(t,e,n,i){const r=function(t){return t[7]||(t[7]=[])}(e);null===n?r.push(i):(r.push(n),t.firstCreatePass&&function(t){return t.cleanup||(t.cleanup=[])}(t).push(i,r.length-1))}function jd(t,e,n){for(let i in t)if(t.hasOwnProperty(i)){const r=t[i];(n=null===n?{}:n).hasOwnProperty(i)?n[i].push(e,r):n[i]=[e,r]}return n}function Vd(t,e,n,i,r,s){const c=s.hostBindings;if(c){let g=t.hostBindingOpCodes;null===g&&(g=t.hostBindingOpCodes=[]);const _=~e.index;(function(t){let e=t.length;for(;e>0;){const n=t[--e];if("number"==typeof n&&n<0)return n}return 0})(g)!=_&&g.push(_),g.push(i,r,c)}}function Hd(t,e){null!==t.hostBindings&&t.hostBindings(1,e)}function Ud(t,e){e.flags|=2,(t.components||(t.components=[])).push(e.index)}function Db(t,e,n){if(n){if(e.exportAs)for(let i=0;i<e.exportAs.length;i++)n[e.exportAs[i]]=t;vn(e)&&(n[""]=t)}}function Wd(t,e,n){t.flags|=1,t.directiveStart=e,t.directiveEnd=e+n,t.providerIndexes=e}function Gd(t,e,n,i,r){t.data[i]=r;const s=r.factory||(r.factory=Pi(r.type)),c=new is(s,vn(r),null);t.blueprint[i]=c,n[i]=c,Vd(t,e,0,i,pr(t,n,r.hostVars,Ae),r)}function Eb(t,e,n){const i=an(e,t),r=Rd(n),s=t[10],c=Yo(t,bs(t,r,null,n.onPush?64:16,i,e,s,s.createRenderer(i,n),null,null));t[e.index]=c}function Sb(t,e,n,i,r,s){const c=s[e];if(null!==c){const g=i.setInput;for(let _=0;_<c.length;){const w=c[_++],S=c[_++],x=c[_++];null!==g?i.setInput(n,x,w,S):n[S]=x}}}function Tb(t,e){let n=null,i=0;for(;i<e.length;){const r=e[i];if(0!==r)if(5!==r){if("number"==typeof r)break;t.hasOwnProperty(r)&&(null===n&&(n=[]),n.push(r,t[r],e[i+1])),i+=2}else i+=2;else i+=4}return n}function Mb(t,e){const n=qt(e,t);if(hl(n)){const i=n[1];80&n[2]?mr(i,n,i.template,n[8]):n[5]>0&&pu(n)}}function pu(t){for(let i=Yl(t);null!==i;i=zl(i))for(let r=10;r<i.length;r++){const s=i[r];if(1024&s[2]){const c=s[1];mr(c,s,c.template,s[8])}else s[5]>0&&pu(s)}const n=t[1].components;if(null!==n)for(let i=0;i<n.length;i++){const r=qt(n[i],t);hl(r)&&r[5]>0&&pu(r)}}function Ob(t,e){const n=qt(e,t),i=n[1];(function(t,e){for(let n=e.length;n<t.blueprint.length;n++)e.push(t.blueprint[n])})(i,n),ws(i,n,n[8])}function Yo(t,e){return t[13]?t[14][4]=e:t[13]=e,t[14]=e,e}function vu(t,e,n){const i=e[10];i.begin&&i.begin();try{mr(t,e,t.template,n)}catch(r){throw function(t,e){const n=t[9],i=n?n.get(ji,null):null;i&&i.handleError(e)}(e,r),r}finally{i.end&&i.end()}}function zd(t){!function(t){for(let e=0;e<t.components.length;e++){const n=t.components[e],i=Hl(n),r=i[1];cb(r,i,r.template,n)}}(t[8])}function _u(t,e,n){yl(0),e(t,n)}const kb=(()=>Promise.resolve(null))();function zo(t,e,n){let i=n?t.styles:null,r=n?t.classes:null,s=0;if(null!==e)for(let c=0;c<e.length;c++){const g=e[c];"number"==typeof g?s=g:1==s?r=Xa(r,g):2==s&&(i=Xa(i,g+": "+e[++c]+";"))}n?t.styles=i:t.stylesWithoutHost=i,n?t.classes=r:t.classesWithoutHost=r}const yr=new Ke("INJECTOR",-1);class Zd{get(e,n=cs){if(n===cs){const i=new Error(`NullInjectorError: No provider for ${Le(e)}!`);throw i.name="NullInjectorError",i}return n}}const Ds=new Ke("Set Injector scope."),Es={},jb={};let Cu;function Jd(){return void 0===Cu&&(Cu=new Zd),Cu}function eg(t,e=null,n=null,i){return new Vb(t,n,e||Jd(),i)}class Vb{constructor(e,n,i,r=null){this.parent=i,this.records=new Map,this.injectorDefTypes=new Set,this.onDestroy=new Set,this._destroyed=!1;const s=[];n&&Ln(n,g=>this.processProvider(g,e,n)),Ln([e],g=>this.processInjectorType(g,[],s)),this.records.set(yr,vr(void 0,this));const c=this.records.get(Ds);this.scope=null!=c?c.value:null,this.source=r||("object"==typeof e?null:Le(e))}get destroyed(){return this._destroyed}destroy(){this.assertNotDestroyed(),this._destroyed=!0;try{this.onDestroy.forEach(e=>e.ngOnDestroy())}finally{this.records.clear(),this.onDestroy.clear(),this.injectorDefTypes.clear()}}get(e,n=cs,i=Te.Default){this.assertNotDestroyed();const r=ur(this),s=ci(void 0);try{if(!(i&Te.SkipSelf)){let g=this.records.get(e);if(void 0===g){const _=function(t){return"function"==typeof t||"object"==typeof t&&t instanceof Ke}(e)&&Qn(e);g=_&&this.injectableDefInScope(_)?vr(bu(e),Es):null,this.records.set(e,g)}if(null!=g)return this.hydrate(e,g)}return(i&Te.Self?Jd():this.parent).get(e,n=i&Te.Optional&&n===cs?null:n)}catch(c){if("NullInjectorError"===c.name){if((c[lr]=c[lr]||[]).unshift(Le(e)),r)throw c;return Cf(c,e,"R3InjectorError",this.source)}throw c}finally{ci(s),ur(r)}}_resolveInjectorDefTypes(){this.injectorDefTypes.forEach(e=>this.get(e))}toString(){const e=[];return this.records.forEach((i,r)=>e.push(Le(r))),`R3Injector[${e.join(", ")}]`}assertNotDestroyed(){if(this._destroyed)throw new Error("Injector has already been destroyed.")}processInjectorType(e,n,i){if(!(e=we(e)))return!1;let r=Mh(e);const s=null==r&&e.ngModule||void 0,c=void 0===s?e:s,g=-1!==i.indexOf(c);if(void 0!==s&&(r=Mh(s)),null==r)return!1;if(null!=r.imports&&!g){let S;i.push(c);try{Ln(r.imports,x=>{this.processInjectorType(x,n,i)&&(void 0===S&&(S=[]),S.push(x))})}finally{}if(void 0!==S)for(let x=0;x<S.length;x++){const{ngModule:M,providers:P}=S[x];Ln(P,j=>this.processProvider(j,M,P||Qe))}}this.injectorDefTypes.add(c);const _=Pi(c)||(()=>new c);this.records.set(c,vr(_,Es));const w=r.providers;if(null!=w&&!g){const S=e;Ln(w,x=>this.processProvider(x,S,w))}return void 0!==s&&void 0!==e.providers}processProvider(e,n,i){let r=_r(e=we(e))?e:we(e&&e.provide);const s=function(t,e,n){return ng(t)?vr(void 0,t.useValue):vr(function(t,e,n){let i;if(_r(t)){const r=we(t);return Pi(r)||bu(r)}if(ng(t))i=()=>we(t.useValue);else if(function(t){return!(!t||!t.useFactory)}(t))i=()=>t.useFactory(...ki(t.deps||[]));else if(function(t){return!(!t||!t.useExisting)}(t))i=()=>Ve(we(t.useExisting));else{const r=we(t&&(t.useClass||t.provide));if(!function(t){return!!t.deps}(t))return Pi(r)||bu(r);i=()=>new r(...ki(t.deps))}return i}(t),Es)}(e);if(_r(e)||!0!==e.multi)this.records.get(r);else{let c=this.records.get(r);c||(c=vr(void 0,Es,!0),c.factory=()=>ki(c.multi),this.records.set(r,c)),r=e,c.multi.push(e)}this.records.set(r,s)}hydrate(e,n){return n.value===Es&&(n.value=jb,n.value=n.factory()),"object"==typeof n.value&&n.value&&function(t){return null!==t&&"object"==typeof t&&"function"==typeof t.ngOnDestroy}(n.value)&&this.onDestroy.add(n.value),n.value}injectableDefInScope(e){if(!e.providedIn)return!1;const n=we(e.providedIn);return"string"==typeof n?"any"===n||n===this.scope:this.injectorDefTypes.has(n)}}function bu(t){const e=Qn(t),n=null!==e?e.factory:Pi(t);if(null!==n)return n;if(t instanceof Ke)throw new Error(`Token ${Le(t)} is missing a \u0275prov definition.`);if(t instanceof Function)return function(t){const e=t.length;if(e>0){const i=function(t,e){const n=[];for(let i=0;i<t;i++)n.push(e);return n}(e,"?");throw new Error(`Can't resolve all parameters for ${Le(t)}: (${i.join(", ")}).`)}const n=function(t){const e=t&&(t[so]||t[Oh]);if(e){const n=function(t){if(t.hasOwnProperty("name"))return t.name;const e=(""+t).match(/^function\s*([^\s(]+)/);return null===e?"":e[1]}(t);return console.warn(`DEPRECATED: DI is instantiating a token "${n}" that inherits its @Injectable decorator but does not provide one itself.\nThis will become an error in a future version of Angular. Please add @Injectable() to the "${n}" class.`),e}return null}(t);return null!==n?()=>n.factory(t):()=>new t}(t);throw new Error("unreachable")}function vr(t,e,n=!1){return{factory:t,value:e,multi:n?[]:void 0}}function ng(t){return null!==t&&"object"==typeof t&&Pl in t}function _r(t){return"function"==typeof t}const ig=function(t,e,n){return function(t,e=null,n=null,i){const r=eg(t,e,n,i);return r._resolveInjectorDefTypes(),r}({name:n},e,t,n)};let tt=(()=>{class t{static create(n,i){return Array.isArray(n)?ig(n,i,""):ig(n.providers,n.parent,n.name||"")}}return t.THROW_IF_NOT_FOUND=cs,t.NULL=new Zd,t.\u0275prov=qe({token:t,providedIn:"any",factory:()=>Ve(yr)}),t.__NG_ELEMENT_ID__=-1,t})();function aw(t,e){_o(Hl(t)[1],yt())}let $o=null;function Cr(){if(!$o){const t=$e.Symbol;if(t&&t.iterator)$o=t.iterator;else{const e=Object.getOwnPropertyNames(Map.prototype);for(let n=0;n<e.length;++n){const i=e[n];"entries"!==i&&"size"!==i&&Map.prototype[i]===Map.prototype.entries&&($o=i)}}}return $o}function Ts(t){return!!Iu(t)&&(Array.isArray(t)||!(t instanceof Map)&&Cr()in t)}function Iu(t){return null!==t&&("function"==typeof t||"object"==typeof t)}function Fu(t,e,n,i,r){const c=r?"class":"style";!function(t,e,n,i,r){for(let s=0;s<n.length;){const c=n[s++],g=n[s++],_=e[c],w=t.data[c];null!==w.setInput?w.setInput(_,r,i,g):_[g]=r}}(t,n,e.inputs[c],c,i)}function Ru(t,e,n,i){const r=re(),s=Ge(),c=20+t,g=r[11],_=r[c]=Xl(g,e,Me.lFrame.currentNamespace),w=s.firstCreatePass?function(t,e,n,i,r,s,c){const g=e.consts,w=gr(e,t,2,r,di(g,s));return function(t,e,n,i){let r=!1;if(zh()){const s=function(t,e,n){const i=t.directiveRegistry;let r=null;if(i)for(let s=0;s<i.length;s++){const c=i[s];_d(n,c.selectors,!1)&&(r||(r=[]),To(ss(n,e),t,c.type),vn(c)?(Ud(t,n),r.unshift(c)):r.push(c))}return r}(t,e,n),c=null===i?null:{"":-1};if(null!==s){r=!0,Wd(n,t.data.length,s.length);for(let S=0;S<s.length;S++){const x=s[S];x.providersResolver&&x.providersResolver(x)}let g=!1,_=!1,w=pr(t,e,s.length,null);for(let S=0;S<s.length;S++){const x=s[S];n.mergedAttrs=Do(n.mergedAttrs,x.hostAttrs),Gd(t,n,e,w,x),Db(w,x,c),null!==x.contentQueries&&(n.flags|=8),(null!==x.hostBindings||null!==x.hostAttrs||0!==x.hostVars)&&(n.flags|=128);const M=x.type.prototype;!g&&(M.ngOnChanges||M.ngOnInit||M.ngDoCheck)&&((t.preOrderHooks||(t.preOrderHooks=[])).push(n.index),g=!0),!_&&(M.ngOnChanges||M.ngDoCheck)&&((t.preOrderCheckHooks||(t.preOrderCheckHooks=[])).push(n.index),_=!0),w++}!function(t,e){const i=e.directiveEnd,r=t.data,s=e.attrs,c=[];let g=null,_=null;for(let w=e.directiveStart;w<i;w++){const S=r[w],x=S.inputs,M=null===s||vd(e)?null:Tb(x,s);c.push(M),g=jd(x,w,g),_=jd(S.outputs,w,_)}null!==g&&(g.hasOwnProperty("class")&&(e.flags|=16),g.hasOwnProperty("style")&&(e.flags|=32)),e.initialInputs=c,e.inputs=g,e.outputs=_}(t,n)}c&&function(t,e,n){if(e){const i=t.localNames=[];for(let r=0;r<e.length;r+=2){const s=n[e[r+1]];if(null==s)throw new Ti("301",`Export of name '${e[r+1]}' not found!`);i.push(e[r],s)}}}(n,i,c)}n.mergedAttrs=Do(n.mergedAttrs,n.attrs)}(e,n,w,di(g,c)),null!==w.attrs&&zo(w,w.attrs,!1),null!==w.mergedAttrs&&zo(w,w.mergedAttrs,!0),null!==e.queries&&e.queries.elementStart(e,w),w}(c,s,r,0,e,n,i):s.data[c];kn(w,!0);const S=w.mergedAttrs;null!==S&&wo(g,_,S);const x=w.classes;null!==x&&eu(g,_,x);const M=w.styles;null!==M&&pd(g,_,M),64!=(64&w.flags)&&Bo(s,r,_,w),0===Me.lFrame.elementDepthCount&&It(_,r),Me.lFrame.elementDepthCount++,function(t){return 1==(1&t.flags)}(w)&&(function(t,e,n){!zh()||(function(t,e,n,i){const r=n.directiveStart,s=n.directiveEnd;t.firstCreatePass||ss(n,e),It(i,e);const c=n.initialInputs;for(let g=r;g<s;g++){const _=t.data[g],w=vn(_);w&&Eb(e,n,_);const S=os(e,t,g,n);It(S,e),null!==c&&Sb(0,g-r,S,_,0,c),w&&(qt(n.index,e)[8]=S)}}(t,e,n,an(n,e)),128==(128&n.flags)&&function(t,e,n){const i=n.directiveStart,r=n.directiveEnd,c=n.index,g=Me.lFrame.currentDirectiveIndex;try{gi(c);for(let _=i;_<r;_++){const w=t.data[_],S=e[_];pl(_),(null!==w.hostBindings||0!==w.hostVars||null!==w.hostAttrs)&&Hd(w,S)}}finally{gi(-1),pl(g)}}(t,e,n))}(s,r,w),function(t,e,n){if(rl(e)){const r=e.directiveEnd;for(let s=e.directiveStart;s<r;s++){const c=t.data[s];c.contentQueries&&c.contentQueries(1,n[s],s)}}}(s,w,r)),null!==i&&function(t,e,n=an){const i=e.localNames;if(null!==i){let r=e.index+1;for(let s=0;s<i.length;s+=2){const c=i[s+1],g=-1===c?n(e,t):t[c];t[r++]=g}}}(r,w)}function ku(){let t=yt();dl()?Me.lFrame.isParent=!1:(t=t.parent,kn(t,!1));const e=t;Me.lFrame.elementDepthCount--;const n=Ge();n.firstCreatePass&&(_o(n,t),rl(t)&&n.queries.elementEnd(t)),null!=e.classesWithoutHost&&function(t){return 0!=(16&t.flags)}(e)&&Fu(n,e,re(),e.classesWithoutHost,!0),null!=e.stylesWithoutHost&&function(t){return 0!=(32&t.flags)}(e)&&Fu(n,e,re(),e.stylesWithoutHost,!1)}function Nu(t){return!!t&&"function"==typeof t.then}const Xg=function(t){return!!t&&"function"==typeof t.subscribe},Hi=void 0;var LD=["en",[["a","p"],["AM","PM"],Hi],[["AM","PM"],Hi,Hi],[["S","M","T","W","T","F","S"],["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],["Su","Mo","Tu","We","Th","Fr","Sa"]],Hi,[["J","F","M","A","M","J","J","A","S","O","N","D"],["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],["January","February","March","April","May","June","July","August","September","October","November","December"]],Hi,[["B","A"],["BC","AD"],["Before Christ","Anno Domini"]],0,[6,0],["M/d/yy","MMM d, y","MMMM d, y","EEEE, MMMM d, y"],["h:mm a","h:mm:ss a","h:mm:ss a z","h:mm:ss a zzzz"],["{1}, {0}",Hi,"{1} 'at' {0}",Hi],[".",",",";","%","+","-","E","\xd7","\u2030","\u221e","NaN",":"],["#,##0.###","#,##0%","\xa4#,##0.00","#E0"],"USD","$","US Dollar",{},"ltr",function(t){const e=Math.floor(Math.abs(t)),n=t.toString().replace(/^[^.]*\.?/,"").length;return 1===e&&0===n?1:5}];let Pr={};function Gp(t){return t in Pr||(Pr[t]=$e.ng&&$e.ng.common&&$e.ng.common.locales&&$e.ng.common.locales[t]),Pr[t]}var pe=(()=>((pe=pe||{})[pe.LocaleId=0]="LocaleId",pe[pe.DayPeriodsFormat=1]="DayPeriodsFormat",pe[pe.DayPeriodsStandalone=2]="DayPeriodsStandalone",pe[pe.DaysFormat=3]="DaysFormat",pe[pe.DaysStandalone=4]="DaysStandalone",pe[pe.MonthsFormat=5]="MonthsFormat",pe[pe.MonthsStandalone=6]="MonthsStandalone",pe[pe.Eras=7]="Eras",pe[pe.FirstDayOfWeek=8]="FirstDayOfWeek",pe[pe.WeekendRange=9]="WeekendRange",pe[pe.DateFormat=10]="DateFormat",pe[pe.TimeFormat=11]="TimeFormat",pe[pe.DateTimeFormat=12]="DateTimeFormat",pe[pe.NumberSymbols=13]="NumberSymbols",pe[pe.NumberFormats=14]="NumberFormats",pe[pe.CurrencyCode=15]="CurrencyCode",pe[pe.CurrencySymbol=16]="CurrencySymbol",pe[pe.CurrencyName=17]="CurrencyName",pe[pe.Currencies=18]="Currencies",pe[pe.Directionality=19]="Directionality",pe[pe.PluralCase=20]="PluralCase",pe[pe.ExtraData=21]="ExtraData",pe))();const Ko="en-US";let Yp=Ko;function Hu(t){$t(t,"Expected localeId to be defined"),"string"==typeof t&&(Yp=t.toLowerCase().replace(/_/g,"-"))}class mm{}const vm="ngComponent";class jE{resolveComponentFactory(e){throw function(t){const e=Error(`No component factory found for ${Le(t)}. Did you add it to @NgModule.entryComponents?`);return e[vm]=t,e}(e)}}let _i=(()=>{class t{}return t.NULL=new jE,t})();function na(...t){}function Rr(t,e){return new Sn(an(t,e))}const HE=function(){return Rr(yt(),re())};let Sn=(()=>{class t{constructor(n){this.nativeElement=n}}return t.__NG_ELEMENT_ID__=HE,t})();function _m(t){return t instanceof Sn?t.nativeElement:t}class ia{}let qu=(()=>{class t{}return t.\u0275prov=qe({token:t,providedIn:"root",factory:()=>null}),t})();class ra{constructor(e){this.full=e,this.major=e.split(".")[0],this.minor=e.split(".")[1],this.patch=e.split(".").slice(2).join(".")}}const bm=new ra("12.2.16");class wm{constructor(){}supports(e){return Ts(e)}create(e){return new $E(e)}}const zE=(t,e)=>e;class $E{constructor(e){this.length=0,this._linkedRecords=null,this._unlinkedRecords=null,this._previousItHead=null,this._itHead=null,this._itTail=null,this._additionsHead=null,this._additionsTail=null,this._movesHead=null,this._movesTail=null,this._removalsHead=null,this._removalsTail=null,this._identityChangesHead=null,this._identityChangesTail=null,this._trackByFn=e||zE}forEachItem(e){let n;for(n=this._itHead;null!==n;n=n._next)e(n)}forEachOperation(e){let n=this._itHead,i=this._removalsHead,r=0,s=null;for(;n||i;){const c=!i||n&&n.currentIndex<Em(i,r,s)?n:i,g=Em(c,r,s),_=c.currentIndex;if(c===i)r--,i=i._nextRemoved;else if(n=n._next,null==c.previousIndex)r++;else{s||(s=[]);const w=g-r,S=_-r;if(w!=S){for(let M=0;M<w;M++){const P=M<s.length?s[M]:s[M]=0,j=P+M;S<=j&&j<w&&(s[M]=P+1)}s[c.previousIndex]=S-w}}g!==_&&e(c,g,_)}}forEachPreviousItem(e){let n;for(n=this._previousItHead;null!==n;n=n._nextPrevious)e(n)}forEachAddedItem(e){let n;for(n=this._additionsHead;null!==n;n=n._nextAdded)e(n)}forEachMovedItem(e){let n;for(n=this._movesHead;null!==n;n=n._nextMoved)e(n)}forEachRemovedItem(e){let n;for(n=this._removalsHead;null!==n;n=n._nextRemoved)e(n)}forEachIdentityChange(e){let n;for(n=this._identityChangesHead;null!==n;n=n._nextIdentityChange)e(n)}diff(e){if(null==e&&(e=[]),!Ts(e))throw new Error(`Error trying to diff '${Le(e)}'. Only arrays and iterables are allowed`);return this.check(e)?this:null}onDestroy(){}check(e){this._reset();let r,s,c,n=this._itHead,i=!1;if(Array.isArray(e)){this.length=e.length;for(let g=0;g<this.length;g++)s=e[g],c=this._trackByFn(g,s),null!==n&&Object.is(n.trackById,c)?(i&&(n=this._verifyReinsertion(n,s,c,g)),Object.is(n.item,s)||this._addIdentityChange(n,s)):(n=this._mismatch(n,s,c,g),i=!0),n=n._next}else r=0,function(t,e){if(Array.isArray(t))for(let n=0;n<t.length;n++)e(t[n]);else{const n=t[Cr()]();let i;for(;!(i=n.next()).done;)e(i.value)}}(e,g=>{c=this._trackByFn(r,g),null!==n&&Object.is(n.trackById,c)?(i&&(n=this._verifyReinsertion(n,g,c,r)),Object.is(n.item,g)||this._addIdentityChange(n,g)):(n=this._mismatch(n,g,c,r),i=!0),n=n._next,r++}),this.length=r;return this._truncate(n),this.collection=e,this.isDirty}get isDirty(){return null!==this._additionsHead||null!==this._movesHead||null!==this._removalsHead||null!==this._identityChangesHead}_reset(){if(this.isDirty){let e;for(e=this._previousItHead=this._itHead;null!==e;e=e._next)e._nextPrevious=e._next;for(e=this._additionsHead;null!==e;e=e._nextAdded)e.previousIndex=e.currentIndex;for(this._additionsHead=this._additionsTail=null,e=this._movesHead;null!==e;e=e._nextMoved)e.previousIndex=e.currentIndex;this._movesHead=this._movesTail=null,this._removalsHead=this._removalsTail=null,this._identityChangesHead=this._identityChangesTail=null}}_mismatch(e,n,i,r){let s;return null===e?s=this._itTail:(s=e._prev,this._remove(e)),null!==(e=null===this._unlinkedRecords?null:this._unlinkedRecords.get(i,null))?(Object.is(e.item,n)||this._addIdentityChange(e,n),this._reinsertAfter(e,s,r)):null!==(e=null===this._linkedRecords?null:this._linkedRecords.get(i,r))?(Object.is(e.item,n)||this._addIdentityChange(e,n),this._moveAfter(e,s,r)):e=this._addAfter(new XE(n,i),s,r),e}_verifyReinsertion(e,n,i,r){let s=null===this._unlinkedRecords?null:this._unlinkedRecords.get(i,null);return null!==s?e=this._reinsertAfter(s,e._prev,r):e.currentIndex!=r&&(e.currentIndex=r,this._addToMoves(e,r)),e}_truncate(e){for(;null!==e;){const n=e._next;this._addToRemovals(this._unlink(e)),e=n}null!==this._unlinkedRecords&&this._unlinkedRecords.clear(),null!==this._additionsTail&&(this._additionsTail._nextAdded=null),null!==this._movesTail&&(this._movesTail._nextMoved=null),null!==this._itTail&&(this._itTail._next=null),null!==this._removalsTail&&(this._removalsTail._nextRemoved=null),null!==this._identityChangesTail&&(this._identityChangesTail._nextIdentityChange=null)}_reinsertAfter(e,n,i){null!==this._unlinkedRecords&&this._unlinkedRecords.remove(e);const r=e._prevRemoved,s=e._nextRemoved;return null===r?this._removalsHead=s:r._nextRemoved=s,null===s?this._removalsTail=r:s._prevRemoved=r,this._insertAfter(e,n,i),this._addToMoves(e,i),e}_moveAfter(e,n,i){return this._unlink(e),this._insertAfter(e,n,i),this._addToMoves(e,i),e}_addAfter(e,n,i){return this._insertAfter(e,n,i),this._additionsTail=null===this._additionsTail?this._additionsHead=e:this._additionsTail._nextAdded=e,e}_insertAfter(e,n,i){const r=null===n?this._itHead:n._next;return e._next=r,e._prev=n,null===r?this._itTail=e:r._prev=e,null===n?this._itHead=e:n._next=e,null===this._linkedRecords&&(this._linkedRecords=new Dm),this._linkedRecords.put(e),e.currentIndex=i,e}_remove(e){return this._addToRemovals(this._unlink(e))}_unlink(e){null!==this._linkedRecords&&this._linkedRecords.remove(e);const n=e._prev,i=e._next;return null===n?this._itHead=i:n._next=i,null===i?this._itTail=n:i._prev=n,e}_addToMoves(e,n){return e.previousIndex===n||(this._movesTail=null===this._movesTail?this._movesHead=e:this._movesTail._nextMoved=e),e}_addToRemovals(e){return null===this._unlinkedRecords&&(this._unlinkedRecords=new Dm),this._unlinkedRecords.put(e),e.currentIndex=null,e._nextRemoved=null,null===this._removalsTail?(this._removalsTail=this._removalsHead=e,e._prevRemoved=null):(e._prevRemoved=this._removalsTail,this._removalsTail=this._removalsTail._nextRemoved=e),e}_addIdentityChange(e,n){return e.item=n,this._identityChangesTail=null===this._identityChangesTail?this._identityChangesHead=e:this._identityChangesTail._nextIdentityChange=e,e}}class XE{constructor(e,n){this.item=e,this.trackById=n,this.currentIndex=null,this.previousIndex=null,this._nextPrevious=null,this._prev=null,this._next=null,this._prevDup=null,this._nextDup=null,this._prevRemoved=null,this._nextRemoved=null,this._nextAdded=null,this._nextMoved=null,this._nextIdentityChange=null}}class qE{constructor(){this._head=null,this._tail=null}add(e){null===this._head?(this._head=this._tail=e,e._nextDup=null,e._prevDup=null):(this._tail._nextDup=e,e._prevDup=this._tail,e._nextDup=null,this._tail=e)}get(e,n){let i;for(i=this._head;null!==i;i=i._nextDup)if((null===n||n<=i.currentIndex)&&Object.is(i.trackById,e))return i;return null}remove(e){const n=e._prevDup,i=e._nextDup;return null===n?this._head=i:n._nextDup=i,null===i?this._tail=n:i._prevDup=n,null===this._head}}class Dm{constructor(){this.map=new Map}put(e){const n=e.trackById;let i=this.map.get(n);i||(i=new qE,this.map.set(n,i)),i.add(e)}get(e,n){const r=this.map.get(e);return r?r.get(e,n):null}remove(e){const n=e.trackById;return this.map.get(n).remove(e)&&this.map.delete(n),e}get isEmpty(){return 0===this.map.size}clear(){this.map.clear()}}function Em(t,e,n){const i=t.previousIndex;if(null===i)return i;let r=0;return n&&i<n.length&&(r=n[i]),i+e+r}class Sm{constructor(){}supports(e){return e instanceof Map||Iu(e)}create(){return new QE}}class QE{constructor(){this._records=new Map,this._mapHead=null,this._appendAfter=null,this._previousMapHead=null,this._changesHead=null,this._changesTail=null,this._additionsHead=null,this._additionsTail=null,this._removalsHead=null,this._removalsTail=null}get isDirty(){return null!==this._additionsHead||null!==this._changesHead||null!==this._removalsHead}forEachItem(e){let n;for(n=this._mapHead;null!==n;n=n._next)e(n)}forEachPreviousItem(e){let n;for(n=this._previousMapHead;null!==n;n=n._nextPrevious)e(n)}forEachChangedItem(e){let n;for(n=this._changesHead;null!==n;n=n._nextChanged)e(n)}forEachAddedItem(e){let n;for(n=this._additionsHead;null!==n;n=n._nextAdded)e(n)}forEachRemovedItem(e){let n;for(n=this._removalsHead;null!==n;n=n._nextRemoved)e(n)}diff(e){if(e){if(!(e instanceof Map||Iu(e)))throw new Error(`Error trying to diff '${Le(e)}'. Only maps and objects are allowed`)}else e=new Map;return this.check(e)?this:null}onDestroy(){}check(e){this._reset();let n=this._mapHead;if(this._appendAfter=null,this._forEach(e,(i,r)=>{if(n&&n.key===r)this._maybeAddToChanges(n,i),this._appendAfter=n,n=n._next;else{const s=this._getOrCreateRecordForKey(r,i);n=this._insertBeforeOrAppend(n,s)}}),n){n._prev&&(n._prev._next=null),this._removalsHead=n;for(let i=n;null!==i;i=i._nextRemoved)i===this._mapHead&&(this._mapHead=null),this._records.delete(i.key),i._nextRemoved=i._next,i.previousValue=i.currentValue,i.currentValue=null,i._prev=null,i._next=null}return this._changesTail&&(this._changesTail._nextChanged=null),this._additionsTail&&(this._additionsTail._nextAdded=null),this.isDirty}_insertBeforeOrAppend(e,n){if(e){const i=e._prev;return n._next=e,n._prev=i,e._prev=n,i&&(i._next=n),e===this._mapHead&&(this._mapHead=n),this._appendAfter=e,e}return this._appendAfter?(this._appendAfter._next=n,n._prev=this._appendAfter):this._mapHead=n,this._appendAfter=n,null}_getOrCreateRecordForKey(e,n){if(this._records.has(e)){const r=this._records.get(e);this._maybeAddToChanges(r,n);const s=r._prev,c=r._next;return s&&(s._next=c),c&&(c._prev=s),r._next=null,r._prev=null,r}const i=new KE(e);return this._records.set(e,i),i.currentValue=n,this._addToAdditions(i),i}_reset(){if(this.isDirty){let e;for(this._previousMapHead=this._mapHead,e=this._previousMapHead;null!==e;e=e._next)e._nextPrevious=e._next;for(e=this._changesHead;null!==e;e=e._nextChanged)e.previousValue=e.currentValue;for(e=this._additionsHead;null!=e;e=e._nextAdded)e.previousValue=e.currentValue;this._changesHead=this._changesTail=null,this._additionsHead=this._additionsTail=null,this._removalsHead=null}}_maybeAddToChanges(e,n){Object.is(n,e.currentValue)||(e.previousValue=e.currentValue,e.currentValue=n,this._addToChanges(e))}_addToAdditions(e){null===this._additionsHead?this._additionsHead=this._additionsTail=e:(this._additionsTail._nextAdded=e,this._additionsTail=e)}_addToChanges(e){null===this._changesHead?this._changesHead=this._changesTail=e:(this._changesTail._nextChanged=e,this._changesTail=e)}_forEach(e,n){e instanceof Map?e.forEach(n):Object.keys(e).forEach(i=>n(e[i],i))}}class KE{constructor(e){this.key=e,this.previousValue=null,this.currentValue=null,this._nextPrevious=null,this._next=null,this._prev=null,this._nextAdded=null,this._nextRemoved=null,this._nextChanged=null}}function Tm(){return new Fs([new wm])}let Fs=(()=>{class t{constructor(n){this.factories=n}static create(n,i){if(null!=i){const r=i.factories.slice();n=n.concat(r)}return new t(n)}static extend(n){return{provide:t,useFactory:i=>t.create(n,i||Tm()),deps:[[t,new Ni,new jn]]}}find(n){const i=this.factories.find(r=>r.supports(n));if(null!=i)return i;throw new Error(`Cannot find a differ supporting object '${n}' of type '${function(t){return t.name||typeof t}(n)}'`)}}return t.\u0275prov=qe({token:t,providedIn:"root",factory:Tm}),t})();function xm(){return new kr([new Sm])}let kr=(()=>{class t{constructor(n){this.factories=n}static create(n,i){if(i){const r=i.factories.slice();n=n.concat(r)}return new t(n)}static extend(n){return{provide:t,useFactory:i=>t.create(n,i||xm()),deps:[[t,new Ni,new jn]]}}find(n){const i=this.factories.find(r=>r.supports(n));if(i)return i;throw new Error(`Cannot find a differ supporting object '${n}'`)}}return t.\u0275prov=qe({token:t,providedIn:"root",factory:xm}),t})();function sa(t,e,n,i,r=!1){for(;null!==n;){const s=e[n.index];if(null!==s&&i.push(dt(s)),yn(s))for(let g=10;g<s.length;g++){const _=s[g],w=_[1].firstChild;null!==w&&sa(_[1],_,w,i)}const c=n.type;if(8&c)sa(t,e,n.child,i);else if(32&c){const g=Gl(n,e);let _;for(;_=g();)i.push(_)}else if(16&c){const g=fd(e,n);if(Array.isArray(g))i.push(...g);else{const _=_s(e[16]);sa(_[1],_,g,i,!0)}}n=r?n.projectionNext:n.next}return i}class Rs{constructor(e,n){this._lView=e,this._cdRefInjectingView=n,this._appRef=null,this._attachedToViewContainer=!1}get rootNodes(){const e=this._lView,n=e[1];return sa(n,e,n.firstChild,[])}get context(){return this._lView[8]}set context(e){this._lView[8]=e}get destroyed(){return 256==(256&this._lView[2])}destroy(){if(this._appRef)this._appRef.detachView(this);else if(this._attachedToViewContainer){const e=this._lView[3];if(yn(e)){const n=e[8],i=n?n.indexOf(this):-1;i>-1&&(ql(e,i),Ri(n,i))}this._attachedToViewContainer=!1}id(this._lView[1],this._lView)}onDestroy(e){Ld(this._lView[1],this._lView,null,e)}markForCheck(){!function(t){for(;t;){t[2]|=64;const e=_s(t);if(__(t)&&!e)return t;t=e}}(this._cdRefInjectingView||this._lView)}detach(){this._lView[2]&=-129}reattach(){this._lView[2]|=128}detectChanges(){vu(this._lView[1],this._lView,this.context)}checkNoChanges(){!function(t,e,n){mo(!0);try{vu(t,e,n)}finally{mo(!1)}}(this._lView[1],this._lView,this.context)}attachToViewContainerRef(){if(this._appRef)throw new Error("This view is already attached directly to the ApplicationRef!");this._attachedToViewContainer=!0}detachFromAppRef(){this._appRef=null,function(t,e){Cs(t,e,e[11],2,null,null)}(this._lView[1],this._lView)}attachToAppRef(e){if(this._attachedToViewContainer)throw new Error("This view is already attached to a ViewContainer!");this._appRef=e}}class JE extends Rs{constructor(e){super(e),this._view=e}detectChanges(){zd(this._view)}checkNoChanges(){!function(t){mo(!0);try{zd(t)}finally{mo(!1)}}(this._view)}get context(){return null}}const tS=function(t){return function(t,e,n){if(co(t)&&!n){const i=qt(t.index,e);return new Rs(i,i)}return 47&t.type?new Rs(e[16],e):null}(yt(),re(),16==(16&t))};let Im=(()=>{class t{}return t.__NG_ELEMENT_ID__=tS,t})();const rS=[new Sm],oS=new Fs([new wm]),aS=new kr(rS),uS=function(){return oa(yt(),re())};let ii=(()=>{class t{}return t.__NG_ELEMENT_ID__=uS,t})();const cS=ii,hS=class extends cS{constructor(e,n,i){super(),this._declarationLView=e,this._declarationTContainer=n,this.elementRef=i}createEmbeddedView(e){const n=this._declarationTContainer.tViews,i=bs(this._declarationLView,n,e,16,null,n.declTNode,null,null,null,null);i[17]=this._declarationLView[this._declarationTContainer.index];const s=this._declarationLView[19];return null!==s&&(i[19]=s.createEmbeddedView(n)),ws(n,i,e),new Rs(i)}};function oa(t,e){return 4&t.type?new hS(e,t,Rr(t,e)):null}class Ui{}const pS=function(){return Am(yt(),re())};let zn=(()=>{class t{}return t.__NG_ELEMENT_ID__=pS,t})();const yS=zn,Mm=class extends yS{constructor(e,n,i){super(),this._lContainer=e,this._hostTNode=n,this._hostLView=i}get element(){return Rr(this._hostTNode,this._hostLView)}get injector(){return new ir(this._hostTNode,this._hostLView)}get parentInjector(){const e=So(this._hostTNode,this._hostLView);if(of(e)){const n=nr(e,this._hostLView),i=tr(e);return new ir(n[1].data[i+8],n)}return new ir(null,this._hostLView)}clear(){for(;this.length>0;)this.remove(this.length-1)}get(e){const n=Om(this._lContainer);return null!==n&&n[e]||null}get length(){return this._lContainer.length-10}createEmbeddedView(e,n,i){const r=e.createEmbeddedView(n||{});return this.insert(r,i),r}createComponent(e,n,i,r,s){const c=i||this.parentInjector;if(!s&&null==e.ngModule&&c){const _=c.get(Ui,null);_&&(s=_)}const g=e.create(c,r,void 0,s);return this.insert(g.hostView,n),g}insert(e,n){const i=e._lView,r=i[1];if(function(t){return yn(t[3])}(i)){const S=this.indexOf(e);if(-1!==S)this.detach(S);else{const x=i[3],M=new Mm(x,x[6],x[3]);M.detach(M.indexOf(e))}}const s=this._adjustIndex(n),c=this._lContainer;!function(t,e,n,i){const r=10+i,s=n.length;i>0&&(n[r-1][4]=e),i<s-10?(e[4]=n[r],Mo(n,10+i,e)):(n.push(e),e[4]=null),e[3]=n;const c=e[17];null!==c&&n!==c&&function(t,e){const n=t[9];e[16]!==e[3][3][16]&&(t[2]=!0),null===n?t[9]=[e]:n.push(e)}(c,e);const g=e[19];null!==g&&g.insertView(t),e[2]|=128}(r,i,c,s);const g=Zl(s,c),_=i[11],w=jo(_,c[7]);return null!==w&&function(t,e,n,i,r,s){i[0]=r,i[6]=e,Cs(t,i,n,1,r,s)}(r,c[6],_,i,w,g),e.attachToViewContainerRef(),Mo(Qu(c),s,e),e}move(e,n){return this.insert(e,n)}indexOf(e){const n=Om(this._lContainer);return null!==n?n.indexOf(e):-1}remove(e){const n=this._adjustIndex(e,-1),i=ql(this._lContainer,n);i&&(Ri(Qu(this._lContainer),n),id(i[1],i))}detach(e){const n=this._adjustIndex(e,-1),i=ql(this._lContainer,n);return i&&null!=Ri(Qu(this._lContainer),n)?new Rs(i):null}_adjustIndex(e,n=0){return null==e?this.length+n:e}};function Om(t){return t[8]}function Qu(t){return t[8]||(t[8]=[])}function Am(t,e){let n;const i=e[t.index];if(yn(i))n=i;else{let r;if(8&t.type)r=dt(i);else{const s=e[11];r=s.createComment("");const c=an(t,e);Bi(s,jo(s,c),r,function(t,e){return lt(t)?t.nextSibling(e):e.nextSibling}(s,c),!1)}e[t.index]=n=function(t,e,n,i){return new Array(t,!0,!1,e,null,0,i,n,null,null)}(i,e,r,t),Yo(e,n)}return new Mm(n,t,e)}const Br={};class Km extends _i{constructor(e){super(),this.ngModule=e}resolveComponentFactory(e){const n=Ft(e);return new Jm(n,this.ngModule)}}function Zm(t){const e=[];for(let n in t)t.hasOwnProperty(n)&&e.push({propName:t[n],templateName:n});return e}const dT=new Ke("SCHEDULER_TOKEN",{providedIn:"root",factory:()=>qf});class Jm extends mm{constructor(e,n){super(),this.componentDef=e,this.ngModule=n,this.componentType=e.type,this.selector=function(t){return t.map(Q0).join(",")}(e.selectors),this.ngContentSelectors=e.ngContentSelectors?e.ngContentSelectors:[],this.isBoundToModule=!!n}get inputs(){return Zm(this.componentDef.inputs)}get outputs(){return Zm(this.componentDef.outputs)}create(e,n,i,r){const s=(r=r||this.ngModule)?function(t,e){return{get:(n,i,r)=>{const s=t.get(n,Br,r);return s!==Br||i===Br?s:e.get(n,i,r)}}}(e,r.injector):e,c=s.get(ia,Wh),g=s.get(qu,null),_=c.createRenderer(null,this.componentDef),w=this.componentDef.selectors[0][0]||"div",S=i?function(t,e,n){if(lt(t))return t.selectRootElement(e,n===mt.ShadowDom);let i="string"==typeof e?t.querySelector(e):e;return i.textContent="",i}(_,i,this.componentDef.encapsulation):Xl(c.createRenderer(null,this.componentDef),w,function(t){const e=t.toLowerCase();return"svg"===e?"http://www.w3.org/2000/svg":"math"===e?"http://www.w3.org/1998/MathML/":null}(w)),x=this.componentDef.onPush?576:528,M=function(t,e){return{components:[],scheduler:t||qf,clean:kb,playerHandler:e||null,flags:0}}(),P=Go(0,null,null,1,0,null,null,null,null,null),j=bs(null,P,M,x,null,null,c,_,g,s);let G,H;yo(j);try{const se=function(t,e,n,i,r,s){const c=n[1];n[20]=t;const _=gr(c,20,2,"#host",null),w=_.mergedAttrs=e.hostAttrs;null!==w&&(zo(_,w,!0),null!==t&&(wo(r,t,w),null!==_.classes&&eu(r,t,_.classes),null!==_.styles&&pd(r,t,_.styles)));const S=i.createRenderer(t,e),x=bs(n,Rd(e),null,e.onPush?64:16,n[20],_,i,S,s||null,null);return c.firstCreatePass&&(To(ss(_,n),c,e.type),Ud(c,_),Wd(_,n.length,1)),Yo(n,x),n[20]=x}(S,this.componentDef,j,c,_);if(S)if(i)wo(_,S,["ng-version",bm.full]);else{const{attrs:Q,classes:ye}=function(t){const e=[],n=[];let i=1,r=2;for(;i<t.length;){let s=t[i];if("string"==typeof s)2===r?""!==s&&e.push(s,t[++i]):8===r&&n.push(s);else{if(!_n(r))break;r=s}i++}return{attrs:e,classes:n}}(this.componentDef.selectors[0]);Q&&wo(_,S,Q),ye&&ye.length>0&&eu(_,S,ye.join(" "))}if(H=function(t,e){return t.data[e]}(P,20),void 0!==n){const Q=H.projection=[];for(let ye=0;ye<this.ngContentSelectors.length;ye++){const De=n[ye];Q.push(null!=De?Array.from(De):null)}}G=function(t,e,n,i,r){const s=n[1],c=function(t,e,n){const i=yt();t.firstCreatePass&&(n.providersResolver&&n.providersResolver(n),Gd(t,i,e,pr(t,e,1,null),n));const r=os(e,t,i.directiveStart,i);It(r,e);const s=an(i,e);return s&&It(s,e),r}(s,n,e);if(i.components.push(c),t[8]=c,r&&r.forEach(_=>_(c,e)),e.contentQueries){const _=yt();e.contentQueries(1,c,_.directiveStart)}const g=yt();return!s.firstCreatePass||null===e.hostBindings&&null===e.hostAttrs||(gi(g.index),Vd(n[1],g,0,g.directiveStart,g.directiveEnd,e),Hd(e,c)),c}(se,this.componentDef,j,M,[aw]),ws(P,j,null)}finally{vo()}return new mT(this.componentType,G,Rr(H,j),j,H)}}class mT extends class{}{constructor(e,n,i,r,s){super(),this.location=i,this._rootLView=r,this._tNode=s,this.instance=n,this.hostView=this.changeDetectorRef=new JE(r),this.componentType=e}get injector(){return new ir(this._tNode,this._rootLView)}destroy(){this.hostView.destroy()}onDestroy(e){this.hostView.onDestroy(e)}}const Vr=new Map;class _T extends Ui{constructor(e,n){super(),this._parent=n,this._bootstrapComponents=[],this.injector=this,this.destroyCbs=[],this.componentFactoryResolver=new Km(this);const i=rn(e),r=function(t){return t[h_]||null}(e);r&&Hu(r),this._bootstrapComponents=Hn(i.bootstrap),this._r3Injector=eg(e,n,[{provide:Ui,useValue:this},{provide:_i,useValue:this.componentFactoryResolver}],Le(e)),this._r3Injector._resolveInjectorDefTypes(),this.instance=this.get(e)}get(e,n=tt.THROW_IF_NOT_FOUND,i=Te.Default){return e===tt||e===Ui||e===yr?this:this._r3Injector.get(e,n,i)}destroy(){const e=this._r3Injector;!e.destroyed&&e.destroy(),this.destroyCbs.forEach(n=>n()),this.destroyCbs=null}onDestroy(e){this.destroyCbs.push(e)}}class uc extends class{}{constructor(e){super(),this.moduleType=e,null!==rn(e)&&function(t){const e=new Set;!function n(i){const r=rn(i,!0),s=r.id;null!==s&&(function(t,e,n){if(e&&e!==n)throw new Error(`Duplicate module registered for ${t} - ${Le(e)} vs ${Le(e.name)}`)}(s,Vr.get(s),i),Vr.set(s,i));const c=Hn(r.imports);for(const g of c)e.has(g)||(e.add(g),n(g))}(t)}(e)}create(e){return new _T(this.moduleType,e)}}function cc(t){return e=>{setTimeout(t,void 0,e)}}const ri=class extends ue{constructor(e=!1){super(),this.__isAsync=e}emit(e){super.next(e)}subscribe(e,n,i){var r,s,c;let g=e,_=n||(()=>null),w=i;if(e&&"object"==typeof e){const x=e;g=null===(r=x.next)||void 0===r?void 0:r.bind(x),_=null===(s=x.error)||void 0===s?void 0:s.bind(x),w=null===(c=x.complete)||void 0===c?void 0:c.bind(x)}this.__isAsync&&(_=cc(_),g&&(g=cc(g)),w&&(w=cc(w)));const S=super.subscribe({next:g,error:_,complete:w});return e instanceof d&&e.add(S),S}};function jT(){return this._results[Cr()]()}class ha{constructor(e=!1){this._emitDistinctChangesOnly=e,this.dirty=!0,this._results=[],this._changesDetected=!1,this._changes=null,this.length=0,this.first=void 0,this.last=void 0;const n=Cr(),i=ha.prototype;i[n]||(i[n]=jT)}get changes(){return this._changes||(this._changes=new ri)}get(e){return this._results[e]}map(e){return this._results.map(e)}filter(e){return this._results.filter(e)}find(e){return this._results.find(e)}reduce(e,n){return this._results.reduce(e,n)}forEach(e){this._results.forEach(e)}some(e){return this._results.some(e)}toArray(){return this._results.slice()}toString(){return this._results.toString()}reset(e,n){const i=this;i.dirty=!1;const r=ln(e);(this._changesDetected=!function(t,e,n){if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++){let r=t[i],s=e[i];if(n&&(r=n(r),s=n(s)),s!==r)return!1}return!0}(i._results,r,n))&&(i._results=r,i.length=r.length,i.last=r[this.length-1],i.first=r[0])}notifyOnChanges(){this._changes&&(this._changesDetected||!this._emitDistinctChangesOnly)&&this._changes.emit(this)}setDirty(){this.dirty=!0}destroy(){this.changes.complete(),this.changes.unsubscribe()}}Symbol;class hc{constructor(e){this.queryList=e,this.matches=null}clone(){return new hc(this.queryList)}setDirty(){this.queryList.setDirty()}}class fc{constructor(e=[]){this.queries=e}createEmbeddedView(e){const n=e.queries;if(null!==n){const i=null!==e.contentQueries?e.contentQueries[0]:n.length,r=[];for(let s=0;s<i;s++){const c=n.getByIndex(s);r.push(this.queries[c.indexInDeclarationView].clone())}return new fc(r)}return null}insertView(e){this.dirtyQueriesWithMatches(e)}detachView(e){this.dirtyQueriesWithMatches(e)}dirtyQueriesWithMatches(e){for(let n=0;n<this.queries.length;n++)null!==hy(e,n).matches&&this.queries[n].setDirty()}}class ay{constructor(e,n,i=null){this.predicate=e,this.flags=n,this.read=i}}class dc{constructor(e=[]){this.queries=e}elementStart(e,n){for(let i=0;i<this.queries.length;i++)this.queries[i].elementStart(e,n)}elementEnd(e){for(let n=0;n<this.queries.length;n++)this.queries[n].elementEnd(e)}embeddedTView(e){let n=null;for(let i=0;i<this.length;i++){const r=null!==n?n.length:0,s=this.getByIndex(i).embeddedTView(e,r);s&&(s.indexInDeclarationView=i,null!==n?n.push(s):n=[s])}return null!==n?new dc(n):null}template(e,n){for(let i=0;i<this.queries.length;i++)this.queries[i].template(e,n)}getByIndex(e){return this.queries[e]}get length(){return this.queries.length}track(e){this.queries.push(e)}}class gc{constructor(e,n=-1){this.metadata=e,this.matches=null,this.indexInDeclarationView=-1,this.crossesNgTemplate=!1,this._appliesToNextNode=!0,this._declarationNodeIndex=n}elementStart(e,n){this.isApplyingToNode(n)&&this.matchTNode(e,n)}elementEnd(e){this._declarationNodeIndex===e.index&&(this._appliesToNextNode=!1)}template(e,n){this.elementStart(e,n)}embeddedTView(e,n){return this.isApplyingToNode(e)?(this.crossesNgTemplate=!0,this.addMatch(-e.index,n),new gc(this.metadata)):null}isApplyingToNode(e){if(this._appliesToNextNode&&1!=(1&this.metadata.flags)){const n=this._declarationNodeIndex;let i=e.parent;for(;null!==i&&8&i.type&&i.index!==n;)i=i.parent;return n===(null!==i?i.index:-1)}return this._appliesToNextNode}matchTNode(e,n){const i=this.metadata.predicate;if(Array.isArray(i))for(let r=0;r<i.length;r++){const s=i[r];this.matchTNodeWithReadOption(e,n,HT(n,s)),this.matchTNodeWithReadOption(e,n,xo(n,e,s,!1,!1))}else i===ii?4&n.type&&this.matchTNodeWithReadOption(e,n,-1):this.matchTNodeWithReadOption(e,n,xo(n,e,i,!1,!1))}matchTNodeWithReadOption(e,n,i){if(null!==i){const r=this.metadata.read;if(null!==r)if(r===Sn||r===zn||r===ii&&4&n.type)this.addMatch(n.index,-2);else{const s=xo(n,e,r,!1,!1);null!==s&&this.addMatch(n.index,s)}else this.addMatch(n.index,i)}}addMatch(e,n){null===this.matches?this.matches=[e,n]:this.matches.push(e,n)}}function HT(t,e){const n=t.localNames;if(null!==n)for(let i=0;i<n.length;i+=2)if(n[i]===e)return n[i+1];return null}function WT(t,e,n,i){return-1===n?function(t,e){return 11&t.type?Rr(t,e):4&t.type?oa(t,e):null}(e,t):-2===n?function(t,e,n){return n===Sn?Rr(e,t):n===ii?oa(e,t):n===zn?Am(e,t):void 0}(t,e,i):os(t,t[1],n,e)}function ly(t,e,n,i){const r=e[19].queries[i];if(null===r.matches){const s=t.data,c=n.matches,g=[];for(let _=0;_<c.length;_+=2){const w=c[_];g.push(w<0?null:WT(e,s[w],c[_+1],n.metadata.read))}r.matches=g}return r.matches}function pc(t,e,n,i){const r=t.queries.getByIndex(n),s=r.matches;if(null!==s){const c=ly(t,e,r,n);for(let g=0;g<s.length;g+=2){const _=s[g];if(_>0)i.push(c[g/2]);else{const w=s[g+1],S=e[-_];for(let x=10;x<S.length;x++){const M=S[x];M[17]===M[3]&&pc(M[1],M,w,i)}if(null!==S[9]){const x=S[9];for(let M=0;M<x.length;M++){const P=x[M];pc(P[1],P,w,i)}}}}}return i}function mc(t){const e=re(),n=Ge(),i=Qh();yl(i+1);const r=hy(n,i);if(t.dirty&&Gh(e)===(2==(2&r.metadata.flags))){if(null===r.matches)t.reset([]);else{const s=r.crossesNgTemplate?pc(n,e,i,[]):ly(n,e,r,i);t.reset(s,_m),t.notifyOnChanges()}return!0}return!1}function yc(t,e,n){const i=Ge();i.firstCreatePass&&(function(t,e,n){null===t.queries&&(t.queries=new dc),t.queries.track(new gc(e,n))}(i,new ay(t,e,n),-1),2==(2&e)&&(i.staticViewQueries=!0)),function(t,e,n){const i=new ha(4==(4&n));Ld(t,e,i,i.destroy),null===e[19]&&(e[19]=new fc),e[19].queries.push(new hc(i))}(i,re(),e)}function vc(){return function(t,e){return t[19].queries[e].queryList}(re(),Qh())}function hy(t,e){return t.queries.getByIndex(e)}const ga=new Ke("Application Initializer");let Ur=(()=>{class t{constructor(n){this.appInits=n,this.resolve=na,this.reject=na,this.initialized=!1,this.done=!1,this.donePromise=new Promise((i,r)=>{this.resolve=i,this.reject=r})}runInitializers(){if(this.initialized)return;const n=[],i=()=>{this.done=!0,this.resolve()};if(this.appInits)for(let r=0;r<this.appInits.length;r++){const s=this.appInits[r]();if(Nu(s))n.push(s);else if(Xg(s)){const c=new Promise((g,_)=>{s.subscribe({complete:g,error:_})});n.push(c)}}Promise.all(n).then(()=>{i()}).catch(r=>{this.reject(r)}),0===n.length&&i(),this.initialized=!0}}return t.\u0275fac=function(n){return new(n||t)(Ve(ga,8))},t.\u0275prov=qe({token:t,factory:t.\u0275fac}),t})();const zs=new Ke("AppId"),bx={provide:zs,useFactory:function(){return`${Ec()}${Ec()}${Ec()}`},deps:[]};function Ec(){return String.fromCharCode(97+Math.floor(25*Math.random()))}const My=new Ke("Platform Initializer"),Sc=new Ke("Platform ID"),wx=new Ke("appBootstrapListener");let Tc=(()=>{class t{log(n){console.log(n)}warn(n){console.warn(n)}}return t.\u0275fac=function(n){return new(n||t)},t.\u0275prov=qe({token:t,factory:t.\u0275fac}),t})();const bi=new Ke("LocaleId"),Oy=new Ke("DefaultCurrencyCode");class Ex{constructor(e,n){this.ngModuleFactory=e,this.componentFactories=n}}const xc=function(t){return new uc(t)},Sx=xc,Tx=function(t){return Promise.resolve(xc(t))},Ay=function(t){const e=xc(t),i=Hn(rn(t).declarations).reduce((r,s)=>{const c=Ft(s);return c&&r.push(new Jm(c)),r},[]);return new Ex(e,i)},xx=Ay,Ix=function(t){return Promise.resolve(Ay(t))};let ma=(()=>{class t{constructor(){this.compileModuleSync=Sx,this.compileModuleAsync=Tx,this.compileModuleAndAllComponentsSync=xx,this.compileModuleAndAllComponentsAsync=Ix}clearCache(){}clearCacheFor(n){}getModuleId(n){}}return t.\u0275fac=function(n){return new(n||t)},t.\u0275prov=qe({token:t,factory:t.\u0275fac}),t})();const Ax=(()=>Promise.resolve(0))();function Ic(t){"undefined"==typeof Zone?Ax.then(()=>{t&&t.apply(null,null)}):Zone.current.scheduleMicroTask("scheduleMicrotask",t)}class Et{constructor({enableLongStackTrace:e=!1,shouldCoalesceEventChangeDetection:n=!1,shouldCoalesceRunChangeDetection:i=!1}){if(this.hasPendingMacrotasks=!1,this.hasPendingMicrotasks=!1,this.isStable=!0,this.onUnstable=new ri(!1),this.onMicrotaskEmpty=new ri(!1),this.onStable=new ri(!1),this.onError=new ri(!1),"undefined"==typeof Zone)throw new Error("In this configuration Angular requires Zone.js");Zone.assertZonePatched();const r=this;r._nesting=0,r._outer=r._inner=Zone.current,Zone.TaskTrackingZoneSpec&&(r._inner=r._inner.fork(new Zone.TaskTrackingZoneSpec)),e&&Zone.longStackTraceZoneSpec&&(r._inner=r._inner.fork(Zone.longStackTraceZoneSpec)),r.shouldCoalesceEventChangeDetection=!i&&n,r.shouldCoalesceRunChangeDetection=i,r.lastRequestAnimationFrameId=-1,r.nativeRequestAnimationFrame=function(){let t=$e.requestAnimationFrame,e=$e.cancelAnimationFrame;if("undefined"!=typeof Zone&&t&&e){const n=t[Zone.__symbol__("OriginalDelegate")];n&&(t=n);const i=e[Zone.__symbol__("OriginalDelegate")];i&&(e=i)}return{nativeRequestAnimationFrame:t,nativeCancelAnimationFrame:e}}().nativeRequestAnimationFrame,function(t){const e=()=>{!function(t){t.isCheckStableRunning||-1!==t.lastRequestAnimationFrameId||(t.lastRequestAnimationFrameId=t.nativeRequestAnimationFrame.call($e,()=>{t.fakeTopEventTask||(t.fakeTopEventTask=Zone.root.scheduleEventTask("fakeTopEventTask",()=>{t.lastRequestAnimationFrameId=-1,Oc(t),t.isCheckStableRunning=!0,Mc(t),t.isCheckStableRunning=!1},void 0,()=>{},()=>{})),t.fakeTopEventTask.invoke()}),Oc(t))}(t)};t._inner=t._inner.fork({name:"angular",properties:{isAngularZone:!0},onInvokeTask:(n,i,r,s,c,g)=>{try{return Py(t),n.invokeTask(r,s,c,g)}finally{(t.shouldCoalesceEventChangeDetection&&"eventTask"===s.type||t.shouldCoalesceRunChangeDetection)&&e(),Fy(t)}},onInvoke:(n,i,r,s,c,g,_)=>{try{return Py(t),n.invoke(r,s,c,g,_)}finally{t.shouldCoalesceRunChangeDetection&&e(),Fy(t)}},onHasTask:(n,i,r,s)=>{n.hasTask(r,s),i===r&&("microTask"==s.change?(t._hasPendingMicrotasks=s.microTask,Oc(t),Mc(t)):"macroTask"==s.change&&(t.hasPendingMacrotasks=s.macroTask))},onHandleError:(n,i,r,s)=>(n.handleError(r,s),t.runOutsideAngular(()=>t.onError.emit(s)),!1)})}(r)}static isInAngularZone(){return!0===Zone.current.get("isAngularZone")}static assertInAngularZone(){if(!Et.isInAngularZone())throw new Error("Expected to be in Angular Zone, but it is not!")}static assertNotInAngularZone(){if(Et.isInAngularZone())throw new Error("Expected to not be in Angular Zone, but it is!")}run(e,n,i){return this._inner.run(e,n,i)}runTask(e,n,i,r){const s=this._inner,c=s.scheduleEventTask("NgZoneEvent: "+r,e,Fx,na,na);try{return s.runTask(c,n,i)}finally{s.cancelTask(c)}}runGuarded(e,n,i){return this._inner.runGuarded(e,n,i)}runOutsideAngular(e){return this._outer.run(e)}}const Fx={};function Mc(t){if(0==t._nesting&&!t.hasPendingMicrotasks&&!t.isStable)try{t._nesting++,t.onMicrotaskEmpty.emit(null)}finally{if(t._nesting--,!t.hasPendingMicrotasks)try{t.runOutsideAngular(()=>t.onStable.emit(null))}finally{t.isStable=!0}}}function Oc(t){t.hasPendingMicrotasks=!!(t._hasPendingMicrotasks||(t.shouldCoalesceEventChangeDetection||t.shouldCoalesceRunChangeDetection)&&-1!==t.lastRequestAnimationFrameId)}function Py(t){t._nesting++,t.isStable&&(t.isStable=!1,t.onUnstable.emit(null))}function Fy(t){t._nesting--,Mc(t)}class Nx{constructor(){this.hasPendingMicrotasks=!1,this.hasPendingMacrotasks=!1,this.isStable=!0,this.onUnstable=new ri,this.onMicrotaskEmpty=new ri,this.onStable=new ri,this.onError=new ri}run(e,n,i){return e.apply(n,i)}runGuarded(e,n,i){return e.apply(n,i)}runOutsideAngular(e){return e()}runTask(e,n,i,r){return e.apply(n,i)}}let Ac=(()=>{class t{constructor(n){this._ngZone=n,this._pendingCount=0,this._isZoneStable=!0,this._didWork=!1,this._callbacks=[],this.taskTrackingZone=null,this._watchAngularEvents(),n.run(()=>{this.taskTrackingZone="undefined"==typeof Zone?null:Zone.current.get("TaskTrackingZone")})}_watchAngularEvents(){this._ngZone.onUnstable.subscribe({next:()=>{this._didWork=!0,this._isZoneStable=!1}}),this._ngZone.runOutsideAngular(()=>{this._ngZone.onStable.subscribe({next:()=>{Et.assertNotInAngularZone(),Ic(()=>{this._isZoneStable=!0,this._runCallbacksIfReady()})}})})}increasePendingRequestCount(){return this._pendingCount+=1,this._didWork=!0,this._pendingCount}decreasePendingRequestCount(){if(this._pendingCount-=1,this._pendingCount<0)throw new Error("pending async requests below zero");return this._runCallbacksIfReady(),this._pendingCount}isStable(){return this._isZoneStable&&0===this._pendingCount&&!this._ngZone.hasPendingMacrotasks}_runCallbacksIfReady(){if(this.isStable())Ic(()=>{for(;0!==this._callbacks.length;){let n=this._callbacks.pop();clearTimeout(n.timeoutId),n.doneCb(this._didWork)}this._didWork=!1});else{let n=this.getPendingTasks();this._callbacks=this._callbacks.filter(i=>!i.updateCb||!i.updateCb(n)||(clearTimeout(i.timeoutId),!1)),this._didWork=!0}}getPendingTasks(){return this.taskTrackingZone?this.taskTrackingZone.macroTasks.map(n=>({source:n.source,creationLocation:n.creationLocation,data:n.data})):[]}addCallback(n,i,r){let s=-1;i&&i>0&&(s=setTimeout(()=>{this._callbacks=this._callbacks.filter(c=>c.timeoutId!==s),n(this._didWork,this.getPendingTasks())},i)),this._callbacks.push({doneCb:n,timeoutId:s,updateCb:r})}whenStable(n,i,r){if(r&&!this.taskTrackingZone)throw new Error('Task tracking zone is required when passing an update callback to whenStable(). Is "zone.js/plugins/task-tracking" loaded?');this.addCallback(n,i,r),this._runCallbacksIfReady()}getPendingRequestCount(){return this._pendingCount}findProviders(n,i,r){return[]}}return t.\u0275fac=function(n){return new(n||t)(Ve(Et))},t.\u0275prov=qe({token:t,factory:t.\u0275fac}),t})(),Ry=(()=>{class t{constructor(){this._applications=new Map,Pc.addToWindow(this)}registerApplication(n,i){this._applications.set(n,i)}unregisterApplication(n){this._applications.delete(n)}unregisterAllApplications(){this._applications.clear()}getTestability(n){return this._applications.get(n)||null}getAllTestabilities(){return Array.from(this._applications.values())}getAllRootElements(){return Array.from(this._applications.keys())}findTestabilityInTree(n,i=!0){return Pc.findTestabilityInTree(this,n,i)}}return t.\u0275fac=function(n){return new(n||t)},t.\u0275prov=qe({token:t,factory:t.\u0275fac}),t})();class Lx{addToWindow(e){}findTestabilityInTree(e,n,i){return null}}let Pc=new Lx,ky=!0,Ny=!1;let In;const jy=new Ke("AllowMultipleToken");function By(t,e,n=[]){const i=`Platform: ${e}`,r=new Ke(i);return(s=[])=>{let c=Vy();if(!c||c.injector.get(jy,!1))if(t)t(n.concat(s).concat({provide:r,useValue:!0}));else{const g=n.concat(s).concat({provide:r,useValue:!0},{provide:Ds,useValue:"platform"});!function(t){if(In&&!In.destroyed&&!In.injector.get(jy,!1))throw new Error("There can be only one platform. Destroy the previous one to create a new one.");In=t.get(Hy);const e=t.get(My,null);e&&e.forEach(n=>n())}(tt.create({providers:g,name:i}))}return function(t){const e=Vy();if(!e)throw new Error("No platform exists!");if(!e.injector.get(t,null))throw new Error("A platform with a different configuration has been created. Please destroy it first.");return e}(r)}}function Vy(){return In&&!In.destroyed?In:null}let Hy=(()=>{class t{constructor(n){this._injector=n,this._modules=[],this._destroyListeners=[],this._destroyed=!1}bootstrapModuleFactory(n,i){const g=function(t,e){let n;return n="noop"===t?new Nx:("zone.js"===t?void 0:t)||new Et({enableLongStackTrace:(Ny=!0,ky),shouldCoalesceEventChangeDetection:!!(null==e?void 0:e.ngZoneEventCoalescing),shouldCoalesceRunChangeDetection:!!(null==e?void 0:e.ngZoneRunCoalescing)}),n}(i?i.ngZone:void 0,{ngZoneEventCoalescing:i&&i.ngZoneEventCoalescing||!1,ngZoneRunCoalescing:i&&i.ngZoneRunCoalescing||!1}),_=[{provide:Et,useValue:g}];return g.run(()=>{const w=tt.create({providers:_,parent:this.injector,name:n.moduleType.name}),S=n.create(w),x=S.injector.get(ji,null);if(!x)throw new Error("No ErrorHandler. Is platform module (BrowserModule) included?");return g.runOutsideAngular(()=>{const M=g.onError.subscribe({next:P=>{x.handleError(P)}});S.onDestroy(()=>{Fc(this._modules,S),M.unsubscribe()})}),function(t,e,n){try{const i=n();return Nu(i)?i.catch(r=>{throw e.runOutsideAngular(()=>t.handleError(r)),r}):i}catch(i){throw e.runOutsideAngular(()=>t.handleError(i)),i}}(x,g,()=>{const M=S.injector.get(Ur);return M.runInitializers(),M.donePromise.then(()=>(Hu(S.injector.get(bi,Ko)||Ko),this._moduleDoBootstrap(S),S))})})}bootstrapModule(n,i=[]){const r=Uy({},i);return function(t,e,n){const i=new uc(n);return Promise.resolve(i)}(0,0,n).then(s=>this.bootstrapModuleFactory(s,r))}_moduleDoBootstrap(n){const i=n.injector.get(Wr);if(n._bootstrapComponents.length>0)n._bootstrapComponents.forEach(r=>i.bootstrap(r));else{if(!n.instance.ngDoBootstrap)throw new Error(`The module ${Le(n.instance.constructor)} was bootstrapped, but it does not declare "@NgModule.bootstrap" components nor a "ngDoBootstrap" method. Please define one of these.`);n.instance.ngDoBootstrap(i)}this._modules.push(n)}onDestroy(n){this._destroyListeners.push(n)}get injector(){return this._injector}destroy(){if(this._destroyed)throw new Error("The platform has already been destroyed!");this._modules.slice().forEach(n=>n.destroy()),this._destroyListeners.forEach(n=>n()),this._destroyed=!0}get destroyed(){return this._destroyed}}return t.\u0275fac=function(n){return new(n||t)(Ve(tt))},t.\u0275prov=qe({token:t,factory:t.\u0275fac}),t})();function Uy(t,e){return Array.isArray(e)?e.reduce(Uy,t):Object.assign(Object.assign({},t),e)}let Wr=(()=>{class t{constructor(n,i,r,s,c){this._zone=n,this._injector=i,this._exceptionHandler=r,this._componentFactoryResolver=s,this._initStatus=c,this._bootstrapListeners=[],this._views=[],this._runningTick=!1,this._stable=!0,this.componentTypes=[],this.components=[],this._onMicrotaskEmptySubscription=this._zone.onMicrotaskEmpty.subscribe({next:()=>{this._zone.run(()=>{this.tick()})}});const g=new I(w=>{this._stable=this._zone.isStable&&!this._zone.hasPendingMacrotasks&&!this._zone.hasPendingMicrotasks,this._zone.runOutsideAngular(()=>{w.next(this._stable),w.complete()})}),_=new I(w=>{let S;this._zone.runOutsideAngular(()=>{S=this._zone.onStable.subscribe(()=>{Et.assertNotInAngularZone(),Ic(()=>{!this._stable&&!this._zone.hasPendingMacrotasks&&!this._zone.hasPendingMicrotasks&&(this._stable=!0,w.next(!0))})})});const x=this._zone.onUnstable.subscribe(()=>{Et.assertInAngularZone(),this._stable&&(this._stable=!1,this._zone.runOutsideAngular(()=>{w.next(!1)}))});return()=>{S.unsubscribe(),x.unsubscribe()}});this.isStable=Ye(g,_.pipe(t=>wt()(function(t,e){return function(i){let r;r="function"==typeof t?t:function(){return t};const s=Object.create(i,en);return s.source=i,s.subjectFactory=r,s}}(Kv)(t))))}bootstrap(n,i){if(!this._initStatus.done)throw new Error("Cannot bootstrap as there are still asynchronous initializers running. Bootstrap components in the `ngDoBootstrap` method of the root module.");let r;r=n instanceof mm?n:this._componentFactoryResolver.resolveComponentFactory(n),this.componentTypes.push(r.componentType);const s=function(t){return t.isBoundToModule}(r)?void 0:this._injector.get(Ui),g=r.create(tt.NULL,[],i||r.selector,s),_=g.location.nativeElement,w=g.injector.get(Ac,null),S=w&&g.injector.get(Ry);return w&&S&&S.registerApplication(_,w),g.onDestroy(()=>{this.detachView(g.hostView),Fc(this.components,g),S&&S.unregisterApplication(_)}),this._loadComponent(g),g}tick(){if(this._runningTick)throw new Error("ApplicationRef.tick is called recursively");try{this._runningTick=!0;for(let n of this._views)n.detectChanges()}catch(n){this._zone.runOutsideAngular(()=>this._exceptionHandler.handleError(n))}finally{this._runningTick=!1}}attachView(n){const i=n;this._views.push(i),i.attachToAppRef(this)}detachView(n){const i=n;Fc(this._views,i),i.detachFromAppRef()}_loadComponent(n){this.attachView(n.hostView),this.tick(),this.components.push(n),this._injector.get(wx,[]).concat(this._bootstrapListeners).forEach(r=>r(n))}ngOnDestroy(){this._views.slice().forEach(n=>n.destroy()),this._onMicrotaskEmptySubscription.unsubscribe()}get viewCount(){return this._views.length}}return t.\u0275fac=function(n){return new(n||t)(Ve(Et),Ve(tt),Ve(ji),Ve(_i),Ve(Ur))},t.\u0275prov=qe({token:t,factory:t.\u0275fac}),t})();function Fc(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const c1=By(null,"core",[{provide:Sc,useValue:"unknown"},{provide:Hy,deps:[tt]},{provide:Ry,deps:[]},{provide:Tc,deps:[]}]),p1=[{provide:Wr,useClass:Wr,deps:[Et,tt,ji,_i,Ur]},{provide:dT,deps:[Et],useFactory:function(t){let e=[];return t.onStable.subscribe(()=>{for(;e.length;)e.pop()()}),function(n){e.push(n)}}},{provide:Ur,useClass:Ur,deps:[[new jn,ga]]},{provide:ma,useClass:ma,deps:[]},bx,{provide:Fs,useFactory:function(){return oS},deps:[]},{provide:kr,useFactory:function(){return aS},deps:[]},{provide:bi,useFactory:function(t){return Hu(t=t||"undefined"!=typeof $localize&&$localize.locale||Ko),t},deps:[[new ds(bi),new jn,new Ni]]},{provide:Oy,useValue:"USD"}];let y1=(()=>{class t{constructor(n){}}return t.\u0275fac=function(n){return new(n||t)(Ve(Wr))},t.\u0275mod=Zr({type:t}),t.\u0275inj=xi({providers:p1}),t})(),Ta=null;function Ks(){return Ta}const Vt=new Ke("DocumentToken");var gt=(()=>((gt=gt||{})[gt.Zero=0]="Zero",gt[gt.One=1]="One",gt[gt.Two=2]="Two",gt[gt.Few=3]="Few",gt[gt.Many=4]="Many",gt[gt.Other=5]="Other",gt))();const SI=function(t){return function(t){const e=function(t){return t.toLowerCase().replace(/_/g,"-")}(t);let n=Gp(e);if(n)return n;const i=e.split("-")[0];if(n=Gp(i),n)return n;if("en"===i)return LD;throw new Error(`Missing locale data for the locale "${t}".`)}(t)[pe.PluralCase]};class Na{}let eM=(()=>{class t extends Na{constructor(n){super(),this.locale=n}getPluralCategory(n,i){switch(SI(i||this.locale)(n)){case gt.Zero:return"zero";case gt.One:return"one";case gt.Two:return"two";case gt.Few:return"few";case gt.Many:return"many";default:return"other"}}}return t.\u0275fac=function(n){return new(n||t)(Ve(bi))},t.\u0275prov=qe({token:t,factory:t.\u0275fac}),t})(),RM=(()=>{class t{}return t.\u0275fac=function(n){return new(n||t)},t.\u0275mod=Zr({type:t}),t.\u0275inj=xi({providers:[{provide:Na,useClass:eM}]}),t})();class oh extends class extends class{}{constructor(){super(...arguments),this.supportsDOMEvents=!0}}{static makeCurrent(){!function(t){Ta||(Ta=t)}(new oh)}onAndCancel(e,n,i){return e.addEventListener(n,i,!1),()=>{e.removeEventListener(n,i,!1)}}dispatchEvent(e,n){e.dispatchEvent(n)}remove(e){e.parentNode&&e.parentNode.removeChild(e)}createElement(e,n){return(n=n||this.getDefaultDocument()).createElement(e)}createHtmlDocument(){return document.implementation.createHTMLDocument("fakeTitle")}getDefaultDocument(){return document}isElementNode(e){return e.nodeType===Node.ELEMENT_NODE}isShadowRoot(e){return e instanceof DocumentFragment}getGlobalEventTarget(e,n){return"window"===n?window:"document"===n?e:"body"===n?e.body:null}getBaseHref(e){const n=(eo=eo||document.querySelector("base"),eo?eo.getAttribute("href"):null);return null==n?null:function(t){La=La||document.createElement("a"),La.setAttribute("href",t);const e=La.pathname;return"/"===e.charAt(0)?e:`/${e}`}(n)}resetBaseElement(){eo=null}getUserAgent(){return window.navigator.userAgent}getCookie(e){return function(t,e){e=encodeURIComponent(e);for(const n of t.split(";")){const i=n.indexOf("="),[r,s]=-1==i?[n,""]:[n.slice(0,i),n.slice(i+1)];if(r.trim()===e)return decodeURIComponent(s)}return null}(document.cookie,e)}}let La,eo=null;const Pv=new Ke("TRANSITION_ID"),GM=[{provide:ga,useFactory:function(t,e,n){return()=>{n.get(Ur).donePromise.then(()=>{const i=Ks(),r=e.querySelectorAll(`style[ng-transition="${t}"]`);for(let s=0;s<r.length;s++)i.remove(r[s])})}},deps:[Pv,Vt,tt],multi:!0}];class ah{static init(){!function(t){Pc=t}(new ah)}addToWindow(e){$e.getAngularTestability=(i,r=!0)=>{const s=e.findTestabilityInTree(i,r);if(null==s)throw new Error("Could not find testability for element.");return s},$e.getAllAngularTestabilities=()=>e.getAllTestabilities(),$e.getAllAngularRootElements=()=>e.getAllRootElements(),$e.frameworkStabilizers||($e.frameworkStabilizers=[]),$e.frameworkStabilizers.push(i=>{const r=$e.getAllAngularTestabilities();let s=r.length,c=!1;const g=function(_){c=c||_,s--,0==s&&i(c)};r.forEach(function(_){_.whenStable(g)})})}findTestabilityInTree(e,n,i){if(null==n)return null;const r=e.getTestability(n);return null!=r?r:i?Ks().isShadowRoot(n)?this.findTestabilityInTree(e,n.host,!0):this.findTestabilityInTree(e,n.parentElement,!0):null}}let YM=(()=>{class t{build(){return new XMLHttpRequest}}return t.\u0275fac=function(n){return new(n||t)},t.\u0275prov=qe({token:t,factory:t.\u0275fac}),t})();const to=new Ke("EventManagerPlugins");let Ba=(()=>{class t{constructor(n,i){this._zone=i,this._eventNameToPlugin=new Map,n.forEach(r=>r.manager=this),this._plugins=n.slice().reverse()}addEventListener(n,i,r){return this._findPluginFor(i).addEventListener(n,i,r)}addGlobalEventListener(n,i,r){return this._findPluginFor(i).addGlobalEventListener(n,i,r)}getZone(){return this._zone}_findPluginFor(n){const i=this._eventNameToPlugin.get(n);if(i)return i;const r=this._plugins;for(let s=0;s<r.length;s++){const c=r[s];if(c.supports(n))return this._eventNameToPlugin.set(n,c),c}throw new Error(`No event manager plugin found for event ${n}`)}}return t.\u0275fac=function(n){return new(n||t)(Ve(to),Ve(Et))},t.\u0275prov=qe({token:t,factory:t.\u0275fac}),t})();class lh{constructor(e){this._doc=e}addGlobalEventListener(e,n,i){const r=Ks().getGlobalEventTarget(this._doc,e);if(!r)throw new Error(`Unsupported event target ${r} for event ${n}`);return this.addEventListener(r,n,i)}}let Rv=(()=>{class t{constructor(){this._stylesSet=new Set}addStyles(n){const i=new Set;n.forEach(r=>{this._stylesSet.has(r)||(this._stylesSet.add(r),i.add(r))}),this.onStylesAdded(i)}onStylesAdded(n){}getAllStyles(){return Array.from(this._stylesSet)}}return t.\u0275fac=function(n){return new(n||t)},t.\u0275prov=qe({token:t,factory:t.\u0275fac}),t})(),no=(()=>{class t extends Rv{constructor(n){super(),this._doc=n,this._hostNodes=new Map,this._hostNodes.set(n.head,[])}_addStylesToHost(n,i,r){n.forEach(s=>{const c=this._doc.createElement("style");c.textContent=s,r.push(i.appendChild(c))})}addHost(n){const i=[];this._addStylesToHost(this._stylesSet,n,i),this._hostNodes.set(n,i)}removeHost(n){const i=this._hostNodes.get(n);i&&i.forEach(kv),this._hostNodes.delete(n)}onStylesAdded(n){this._hostNodes.forEach((i,r)=>{this._addStylesToHost(n,r,i)})}ngOnDestroy(){this._hostNodes.forEach(n=>n.forEach(kv))}}return t.\u0275fac=function(n){return new(n||t)(Ve(Vt))},t.\u0275prov=qe({token:t,factory:t.\u0275fac}),t})();function kv(t){Ks().remove(t)}const uh={svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},ch=/%COMP%/g;function Va(t,e,n){for(let i=0;i<e.length;i++){let r=e[i];Array.isArray(r)?Va(t,r,n):(r=r.replace(ch,t),n.push(r))}return n}function jv(t){return e=>{if("__ngUnwrap__"===e)return t;!1===t(e)&&(e.preventDefault(),e.returnValue=!1)}}let hh=(()=>{class t{constructor(n,i,r){this.eventManager=n,this.sharedStylesHost=i,this.appId=r,this.rendererByCompId=new Map,this.defaultRenderer=new fh(n)}createRenderer(n,i){if(!n||!i)return this.defaultRenderer;switch(i.encapsulation){case mt.Emulated:{let r=this.rendererByCompId.get(i.id);return r||(r=new oO(this.eventManager,this.sharedStylesHost,i,this.appId),this.rendererByCompId.set(i.id,r)),r.applyToHost(n),r}case 1:case mt.ShadowDom:return new aO(this.eventManager,this.sharedStylesHost,n,i);default:if(!this.rendererByCompId.has(i.id)){const r=Va(i.id,i.styles,[]);this.sharedStylesHost.addStyles(r),this.rendererByCompId.set(i.id,this.defaultRenderer)}return this.defaultRenderer}}begin(){}end(){}}return t.\u0275fac=function(n){return new(n||t)(Ve(Ba),Ve(no),Ve(zs))},t.\u0275prov=qe({token:t,factory:t.\u0275fac}),t})();class fh{constructor(e){this.eventManager=e,this.data=Object.create(null)}destroy(){}createElement(e,n){return n?document.createElementNS(uh[n]||n,e):document.createElement(e)}createComment(e){return document.createComment(e)}createText(e){return document.createTextNode(e)}appendChild(e,n){e.appendChild(n)}insertBefore(e,n,i){e&&e.insertBefore(n,i)}removeChild(e,n){e&&e.removeChild(n)}selectRootElement(e,n){let i="string"==typeof e?document.querySelector(e):e;if(!i)throw new Error(`The selector "${e}" did not match any elements`);return n||(i.textContent=""),i}parentNode(e){return e.parentNode}nextSibling(e){return e.nextSibling}setAttribute(e,n,i,r){if(r){n=r+":"+n;const s=uh[r];s?e.setAttributeNS(s,n,i):e.setAttribute(n,i)}else e.setAttribute(n,i)}removeAttribute(e,n,i){if(i){const r=uh[i];r?e.removeAttributeNS(r,n):e.removeAttribute(`${i}:${n}`)}else e.removeAttribute(n)}addClass(e,n){e.classList.add(n)}removeClass(e,n){e.classList.remove(n)}setStyle(e,n,i,r){r&(Zt.DashCase|Zt.Important)?e.style.setProperty(n,i,r&Zt.Important?"important":""):e.style[n]=i}removeStyle(e,n,i){i&Zt.DashCase?e.style.removeProperty(n):e.style[n]=""}setProperty(e,n,i){e[n]=i}setValue(e,n){e.nodeValue=n}listen(e,n,i){return"string"==typeof e?this.eventManager.addGlobalEventListener(e,n,jv(i)):this.eventManager.addEventListener(e,n,jv(i))}}class oO extends fh{constructor(e,n,i,r){super(e),this.component=i;const s=Va(r+"-"+i.id,i.styles,[]);n.addStyles(s),this.contentAttr=function(t){return"_ngcontent-%COMP%".replace(ch,t)}(r+"-"+i.id),this.hostAttr=function(t){return"_nghost-%COMP%".replace(ch,t)}(r+"-"+i.id)}applyToHost(e){super.setAttribute(e,this.hostAttr,"")}createElement(e,n){const i=super.createElement(e,n);return super.setAttribute(i,this.contentAttr,""),i}}class aO extends fh{constructor(e,n,i,r){super(e),this.sharedStylesHost=n,this.hostEl=i,this.shadowRoot=i.attachShadow({mode:"open"}),this.sharedStylesHost.addHost(this.shadowRoot);const s=Va(r.id,r.styles,[]);for(let c=0;c<s.length;c++){const g=document.createElement("style");g.textContent=s[c],this.shadowRoot.appendChild(g)}}nodeOrShadowRoot(e){return e===this.hostEl?this.shadowRoot:e}destroy(){this.sharedStylesHost.removeHost(this.shadowRoot)}appendChild(e,n){return super.appendChild(this.nodeOrShadowRoot(e),n)}insertBefore(e,n,i){return super.insertBefore(this.nodeOrShadowRoot(e),n,i)}removeChild(e,n){return super.removeChild(this.nodeOrShadowRoot(e),n)}parentNode(e){return this.nodeOrShadowRoot(super.parentNode(this.nodeOrShadowRoot(e)))}}let lO=(()=>{class t extends lh{constructor(n){super(n)}supports(n){return!0}addEventListener(n,i,r){return n.addEventListener(i,r,!1),()=>this.removeEventListener(n,i,r)}removeEventListener(n,i,r){return n.removeEventListener(i,r)}}return t.\u0275fac=function(n){return new(n||t)(Ve(Vt))},t.\u0275prov=qe({token:t,factory:t.\u0275fac}),t})();const Hv=["alt","control","meta","shift"],pO={"\b":"Backspace","\t":"Tab","\x7f":"Delete","\x1b":"Escape",Del:"Delete",Esc:"Escape",Left:"ArrowLeft",Right:"ArrowRight",Up:"ArrowUp",Down:"ArrowDown",Menu:"ContextMenu",Scroll:"ScrollLock",Win:"OS"},Uv={A:"1",B:"2",C:"3",D:"4",E:"5",F:"6",G:"7",H:"8",I:"9",J:"*",K:"+",M:"-",N:".",O:"/","`":"0","\x90":"NumLock"},mO={alt:t=>t.altKey,control:t=>t.ctrlKey,meta:t=>t.metaKey,shift:t=>t.shiftKey};let yO=(()=>{class t extends lh{constructor(n){super(n)}supports(n){return null!=t.parseEventName(n)}addEventListener(n,i,r){const s=t.parseEventName(i),c=t.eventCallback(s.fullKey,r,this.manager.getZone());return this.manager.getZone().runOutsideAngular(()=>Ks().onAndCancel(n,s.domEventName,c))}static parseEventName(n){const i=n.toLowerCase().split("."),r=i.shift();if(0===i.length||"keydown"!==r&&"keyup"!==r)return null;const s=t._normalizeKey(i.pop());let c="";if(Hv.forEach(_=>{const w=i.indexOf(_);w>-1&&(i.splice(w,1),c+=_+".")}),c+=s,0!=i.length||0===s.length)return null;const g={};return g.domEventName=r,g.fullKey=c,g}static getEventFullKey(n){let i="",r=function(t){let e=t.key;if(null==e){if(e=t.keyIdentifier,null==e)return"Unidentified";e.startsWith("U+")&&(e=String.fromCharCode(parseInt(e.substring(2),16)),3===t.location&&Uv.hasOwnProperty(e)&&(e=Uv[e]))}return pO[e]||e}(n);return r=r.toLowerCase()," "===r?r="space":"."===r&&(r="dot"),Hv.forEach(s=>{s!=r&&mO[s](n)&&(i+=s+".")}),i+=r,i}static eventCallback(n,i,r){return s=>{t.getEventFullKey(s)===n&&r.runGuarded(()=>i(s))}}static _normalizeKey(n){switch(n){case"esc":return"escape";default:return n}}}return t.\u0275fac=function(n){return new(n||t)(Ve(Vt))},t.\u0275prov=qe({token:t,factory:t.\u0275fac}),t})();const SO=By(c1,"browser",[{provide:Sc,useValue:"browser"},{provide:My,useValue:function(){oh.makeCurrent(),ah.init()},multi:!0},{provide:Vt,useFactory:function(){return function(t){ll=t}(document),document},deps:[]}]),TO=[[],{provide:Ds,useValue:"root"},{provide:ji,useFactory:function(){return new ji},deps:[]},{provide:to,useClass:lO,multi:!0,deps:[Vt,Et,Sc]},{provide:to,useClass:yO,multi:!0,deps:[Vt]},[],{provide:hh,useClass:hh,deps:[Ba,no,zs]},{provide:ia,useExisting:hh},{provide:Rv,useExisting:no},{provide:no,useClass:no,deps:[Vt]},{provide:Ac,useClass:Ac,deps:[Et]},{provide:Ba,useClass:Ba,deps:[to,Et]},{provide:class{},useClass:YM,deps:[]},[]];let xO=(()=>{class t{constructor(n){if(n)throw new Error("BrowserModule has already been loaded. If you need access to common directives such as NgIf and NgFor from a lazy loaded module, import CommonModule instead.")}static withServerTransition(n){return{ngModule:t,providers:[{provide:zs,useValue:n.appId},{provide:Pv,useExisting:zs},GM]}}}return t.\u0275fac=function(n){return new(n||t)(Ve(t,12))},t.\u0275mod=Zr({type:t}),t.\u0275inj=xi({providers:TO,imports:[RM,y1]}),t})();"undefined"!=typeof window&&window;class kO extends d{constructor(e,n){super()}schedule(e,n=0){return this}}class Gv extends kO{constructor(e,n){super(e,n),this.scheduler=e,this.work=n,this.pending=!1}schedule(e,n=0){if(this.closed)return this;this.state=e;const i=this.id,r=this.scheduler;return null!=i&&(this.id=this.recycleAsyncId(r,i,n)),this.pending=!0,this.delay=n,this.id=this.id||this.requestAsyncId(r,this.id,n),this}requestAsyncId(e,n,i=0){return setInterval(e.flush.bind(e,this),i)}recycleAsyncId(e,n,i=0){if(null!==i&&this.delay===i&&!1===this.pending)return n;clearInterval(n)}execute(e,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;const i=this._execute(e,n);if(i)return i;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))}_execute(e,n){let r,i=!1;try{this.work(e)}catch(s){i=!0,r=!!s&&s||new Error(s)}if(i)return this.unsubscribe(),r}_unsubscribe(){const e=this.id,n=this.scheduler,i=n.actions,r=i.indexOf(this);this.work=null,this.state=null,this.pending=!1,this.scheduler=null,-1!==r&&i.splice(r,1),null!=e&&(this.id=this.recycleAsyncId(n,e,null)),this.delay=null}}let Yv=(()=>{class t{constructor(n,i=t.now){this.SchedulerAction=n,this.now=i}schedule(n,i=0,r){return new this.SchedulerAction(this,n).schedule(r,i)}}return t.now=()=>Date.now(),t})();class ai extends Yv{constructor(e,n=Yv.now){super(e,()=>ai.delegate&&ai.delegate!==this?ai.delegate.now():n()),this.actions=[],this.active=!1,this.scheduled=void 0}schedule(e,n=0,i){return ai.delegate&&ai.delegate!==this?ai.delegate.schedule(e,n,i):super.schedule(e,n,i)}flush(e){const{actions:n}=this;if(this.active)return void n.push(e);let i;this.active=!0;do{if(i=e.execute(e.state,e.delay))break}while(e=n.shift());if(this.active=!1,i){for(;e=n.shift();)e.unsubscribe();throw i}}}const jO=new class extends ai{}(class extends Gv{constructor(e,n){super(e,n),this.scheduler=e,this.work=n}schedule(e,n=0){return n>0?super.schedule(e,n):(this.delay=n,this.state=e,this.scheduler.flush(this),this)}execute(e,n){return n>0||this.closed?super.execute(e,n):this._execute(e,n)}requestAsyncId(e,n,i=0){return null!==i&&i>0||null===i&&this.delay>0?super.requestAsyncId(e,n,i):e.flush(this)}}),BO=new I(t=>t.complete());class Yt{constructor(e,n,i){this.kind=e,this.value=n,this.error=i,this.hasValue="N"===e}observe(e){switch(this.kind){case"N":return e.next&&e.next(this.value);case"E":return e.error&&e.error(this.error);case"C":return e.complete&&e.complete()}}do(e,n,i){switch(this.kind){case"N":return e&&e(this.value);case"E":return n&&n(this.error);case"C":return i&&i()}}accept(e,n,i){return e&&"function"==typeof e.next?this.observe(e):this.do(e,n,i)}toObservable(){switch(this.kind){case"N":return function(...t){let e=t[t.length-1];return he(e)?(t.pop(),te(t,e)):Ze(t)}(this.value);case"E":return function(t,e){return new I(n=>n.error(t))}(this.error);case"C":return function(t){return t?function(t){return new I(e=>t.schedule(()=>e.complete()))}(t):BO}()}throw new Error("unexpected notification kind value")}static createNext(e){return void 0!==e?new Yt("N",e):Yt.undefinedValueNotification}static createError(e){return new Yt("E",void 0,e)}static createComplete(){return Yt.completeNotification}}Yt.completeNotification=new Yt("C"),Yt.undefinedValueNotification=new Yt("N",void 0);class Ha extends h{constructor(e,n,i=0){super(e),this.scheduler=n,this.delay=i}static dispatch(e){const{notification:n,destination:i}=e;n.observe(i),this.unsubscribe()}scheduleMessage(e){this.destination.add(this.scheduler.schedule(Ha.dispatch,this.delay,new zO(e,this.destination)))}_next(e){this.scheduleMessage(Yt.createNext(e))}_error(e){this.scheduleMessage(Yt.createError(e)),this.unsubscribe()}_complete(){this.scheduleMessage(Yt.createComplete()),this.unsubscribe()}}class zO{constructor(e,n){this.notification=e,this.destination=n}}class $O extends ue{constructor(e=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,i){super(),this.scheduler=i,this._events=[],this._infiniteTimeWindow=!1,this._bufferSize=e<1?1:e,this._windowTime=n<1?1:n,n===Number.POSITIVE_INFINITY?(this._infiniteTimeWindow=!0,this.next=this.nextInfiniteTimeWindow):this.next=this.nextTimeWindow}nextInfiniteTimeWindow(e){if(!this.isStopped){const n=this._events;n.push(e),n.length>this._bufferSize&&n.shift()}super.next(e)}nextTimeWindow(e){this.isStopped||(this._events.push(new XO(this._getNow(),e)),this._trimBufferThenGetEvents()),super.next(e)}_subscribe(e){const n=this._infiniteTimeWindow,i=n?this._events:this._trimBufferThenGetEvents(),r=this.scheduler,s=i.length;let c;if(this.closed)throw new Y;if(this.isStopped||this.hasError?c=d.EMPTY:(this.observers.push(e),c=new ie(this,e)),r&&e.add(e=new Ha(e,r)),n)for(let g=0;g<s&&!e.closed;g++)e.next(i[g]);else for(let g=0;g<s&&!e.closed;g++)e.next(i[g].value);return this.hasError?e.error(this.thrownError):this.isStopped&&e.complete(),c}_getNow(){return(this.scheduler||jO).now()}_trimBufferThenGetEvents(){const e=this._getNow(),n=this._bufferSize,i=this._windowTime,r=this._events,s=r.length;let c=0;for(;c<s&&!(e-r[c].time<i);)c++;return s>n&&(c=Math.max(c,s-n)),c>0&&r.splice(0,c),r}}class XO{constructor(e,n){this.time=e,this.value=n}}function zv(t,e){return"function"==typeof e?n=>n.pipe(zv((i,r)=>Z(t(i,r)).pipe(ae((s,c)=>e(i,s,r,c))))):n=>n.lift(new qO(t))}class qO{constructor(e){this.project=e}call(e,n){return n.subscribe(new QO(e,this.project))}}class QO extends ne{constructor(e,n){super(e),this.project=n,this.index=0}_next(e){let n;const i=this.index++;try{n=this.project(e,i)}catch(r){return void this.destination.error(r)}this._innerSub(n)}_innerSub(e){const n=this.innerSubscription;n&&n.unsubscribe();const i=new ee(this),r=this.destination;r.add(i),this.innerSubscription=Ie(e,i),this.innerSubscription!==i&&r.add(this.innerSubscription)}_complete(){const{innerSubscription:e}=this;(!e||e.closed)&&super._complete(),this.unsubscribe()}_unsubscribe(){this.innerSubscription=void 0}notifyComplete(){this.innerSubscription=void 0,this.isStopped&&super._complete()}notifyNext(e){this.destination.next(e)}}const Ua={schedule(t,e){const n=setTimeout(t,e);return()=>clearTimeout(n)},scheduleBeforeRender(t){if("undefined"==typeof window)return Ua.schedule(t,0);if(void 0===window.requestAnimationFrame)return Ua.schedule(t,16);const e=window.requestAnimationFrame(t);return()=>window.cancelAnimationFrame(e)}};let yh;function oA(t,e,n){let i=n;return function(t){return!!t&&t.nodeType===Node.ELEMENT_NODE}(t)&&e.some((r,s)=>!("*"===r||!function(t,e){if(!yh){const n=Element.prototype;yh=n.matches||n.matchesSelector||n.mozMatchesSelector||n.msMatchesSelector||n.oMatchesSelector||n.webkitMatchesSelector}return t.nodeType===Node.ELEMENT_NODE&&yh.call(t,e)}(t,r)||(i=s,0))),i}class lA{constructor(e,n){this.componentFactory=n.get(_i).resolveComponentFactory(e)}create(e){return new uA(this.componentFactory,e)}}class uA{constructor(e,n){this.componentFactory=e,this.injector=n,this.eventEmitters=new $O(1),this.events=this.eventEmitters.pipe(zv(i=>Ye(...i))),this.componentRef=null,this.viewChangeDetectorRef=null,this.inputChanges=null,this.hasInputChanges=!1,this.implementsOnChanges=!1,this.scheduledChangeDetectionFn=null,this.scheduledDestroyFn=null,this.initialInputValues=new Map,this.unchangedInputs=new Set(this.componentFactory.inputs.map(({propName:i})=>i)),this.ngZone=this.injector.get(Et),this.elementZone="undefined"==typeof Zone?null:this.ngZone.run(()=>Zone.current)}connect(e){this.runInZone(()=>{if(null!==this.scheduledDestroyFn)return this.scheduledDestroyFn(),void(this.scheduledDestroyFn=null);null===this.componentRef&&this.initializeComponent(e)})}disconnect(){this.runInZone(()=>{null===this.componentRef||null!==this.scheduledDestroyFn||(this.scheduledDestroyFn=Ua.schedule(()=>{null!==this.componentRef&&(this.componentRef.destroy(),this.componentRef=null,this.viewChangeDetectorRef=null)},10))})}getInputValue(e){return this.runInZone(()=>null===this.componentRef?this.initialInputValues.get(e):this.componentRef.instance[e])}setInputValue(e,n){this.runInZone(()=>{null!==this.componentRef?function(t,e){return t===e||t!=t&&e!=e}(n,this.getInputValue(e))&&(void 0!==n||!this.unchangedInputs.has(e))||(this.recordInputChange(e,n),this.unchangedInputs.delete(e),this.hasInputChanges=!0,this.componentRef.instance[e]=n,this.scheduleDetectChanges()):this.initialInputValues.set(e,n)})}initializeComponent(e){const n=tt.create({providers:[],parent:this.injector}),i=function(t,e){const n=t.childNodes,i=e.map(()=>[]);let r=-1;e.some((s,c)=>"*"===s&&(r=c,!0));for(let s=0,c=n.length;s<c;++s){const g=n[s],_=oA(g,e,r);-1!==_&&i[_].push(g)}return i}(e,this.componentFactory.ngContentSelectors);this.componentRef=this.componentFactory.create(n,i,e),this.viewChangeDetectorRef=this.componentRef.injector.get(Im),this.implementsOnChanges=function(t){return"function"==typeof t}(this.componentRef.instance.ngOnChanges),this.initializeInputs(),this.initializeOutputs(this.componentRef),this.detectChanges(),this.injector.get(Wr).attachView(this.componentRef.hostView)}initializeInputs(){this.componentFactory.inputs.forEach(({propName:e})=>{this.initialInputValues.has(e)&&this.setInputValue(e,this.initialInputValues.get(e))}),this.initialInputValues.clear()}initializeOutputs(e){const n=this.componentFactory.outputs.map(({propName:i,templateName:r})=>e.instance[i].pipe(ae(c=>({name:r,value:c}))));this.eventEmitters.next(n)}callNgOnChanges(e){if(!this.implementsOnChanges||null===this.inputChanges)return;const n=this.inputChanges;this.inputChanges=null,e.instance.ngOnChanges(n)}markViewForCheck(e){this.hasInputChanges&&(this.hasInputChanges=!1,e.markForCheck())}scheduleDetectChanges(){this.scheduledChangeDetectionFn||(this.scheduledChangeDetectionFn=Ua.scheduleBeforeRender(()=>{this.scheduledChangeDetectionFn=null,this.detectChanges()}))}recordInputChange(e,n){if(!this.implementsOnChanges)return;null===this.inputChanges&&(this.inputChanges={});const i=this.inputChanges[e];if(i)return void(i.currentValue=n);const r=this.unchangedInputs.has(e),s=r?void 0:this.getInputValue(e);this.inputChanges[e]=new ol(s,n,r)}detectChanges(){null!==this.componentRef&&(this.callNgOnChanges(this.componentRef),this.markViewForCheck(this.viewChangeDetectorRef),this.componentRef.changeDetectorRef.detectChanges())}runInZone(e){return this.elementZone&&Zone.current!==this.elementZone?this.ngZone.run(e):e()}}class cA extends HTMLElement{constructor(){super(...arguments),this.ngElementEventsSubscription=null}}var $n=Fn(258);const fA=new ai(Gv);class pA{constructor(e,n){this.delay=e,this.scheduler=n}call(e,n){return n.subscribe(new vh(e,this.delay,this.scheduler))}}class vh extends h{constructor(e,n,i){super(e),this.delay=n,this.scheduler=i,this.queue=[],this.active=!1,this.errored=!1}static dispatch(e){const n=e.source,i=n.queue,r=e.scheduler,s=e.destination;for(;i.length>0&&i[0].time-r.now()<=0;)i.shift().notification.observe(s);if(i.length>0){const c=Math.max(0,i[0].time-r.now());this.schedule(e,c)}else this.unsubscribe(),n.active=!1}_schedule(e){this.active=!0,this.destination.add(e.schedule(vh.dispatch,this.delay,{source:this,destination:this.destination,scheduler:e}))}scheduleNotification(e){if(!0===this.errored)return;const n=this.scheduler,i=new mA(n.now()+this.delay,e);this.queue.push(i),!1===this.active&&this._schedule(n)}_next(e){this.scheduleNotification(Yt.createNext(e))}_error(e){this.errored=!0,this.queue=[],this.destination.error(e),this.unsubscribe()}_complete(){this.scheduleNotification(Yt.createComplete()),this.unsubscribe()}}class mA{constructor(e,n){this.time=e,this.notification=n}}class vA extends class{constructor(e,n=!1){this.detectedElement=e,this.includeColorDes=n}getDetectedElementDescription(){return{elementType:this.detectedElement.name,text:this.detectedElement.text,colors:this.detectedElement.colors}}}{upperSnakeCaseToCamlCase(e){return e.replace(/_/g," ").replace(/(?:^\w|[A-Z]|\b\w|\s+)/g,function(i,r){return 0==+i?"":0===r?i.toLowerCase():i.toUpperCase()})}getCodeString(){var e;const n=this.getDetectedElementDescription();let i=[`element().special("${n.elementType}")`,n.text?'.withText("'+n.text+'")':""];return this.includeColorDes&&i.push((null===(e=n.colors)||void 0===e?void 0:e.join("").length)>0?'.colored("'+n.colors[0]+'")':""),i=i.filter(r=>!!r),i.join("")}}function Ei(){}function _h(t,e,n){return function(r){return r.lift(new _A(t,e,n))}}class _A{constructor(e,n,i){this.nextOrObserver=e,this.error=n,this.complete=i}call(e,n){return n.subscribe(new CA(e,this.nextOrObserver,this.error,this.complete))}}class CA extends h{constructor(e,n,i,r){super(e),this._tapNext=Ei,this._tapError=Ei,this._tapComplete=Ei,this._tapError=i||Ei,this._tapComplete=r||Ei,b(n)?(this._context=this,this._tapNext=n):n&&(this._context=n,this._tapNext=n.next||Ei,this._tapError=n.error||Ei,this._tapComplete=n.complete||Ei)}_next(e){try{this._tapNext.call(this._context,e)}catch(n){return void this.destination.error(n)}this.destination.next(e)}_error(e){try{this._tapError.call(this._context,e)}catch(n){return void this.destination.error(n)}this.destination.error(e)}_complete(){try{this._tapComplete.call(this._context)}catch(e){return void this.destination.error(e)}return this.destination.complete()}}function $v(t,e="1",n=100){return E(Fe(i=>Z(new Promise(r=>{i.animate("opacity",e,{duration:n,onChange:t.renderAll.bind(t),onComplete:()=>r(i)})}))))}const Xv="tooltip";class Ch{constructor(e=new $n.fabric.Canvas("canvas",{fireRightClick:!0,stopContextMenu:!0}),n){this.canvas=e,this.canvasWrapper=n,this.canvas.selection=!1,this.registerMouseEvents()}registerMouseEvents(){const e=this;this.canvas.on("mouse:move",n=>e.onMouseMove(n)),this.canvas.on("mouse:over",n=>e.onMouseOver(n)),this.canvas.on("mouse:out",n=>e.onMouseOut(n)),this.canvas.on("mouse:up",n=>e.onMouseUp(n))}destroy(){this.canvas.off("mouse:move"),this.canvas.off("mouse:over"),this.canvas.off("mouse:out"),this.canvas.off("mouse:up"),this.canvas.dispose(),this.canvas=void 0}onMouseMove(e){this.currentMousePoint=this.canvas.getPointer(e.e)}isRect(e){var n,i;return"rect"===(null===(i=null===(n=e.target)||void 0===n?void 0:n.data)||void 0===i?void 0:i.type)}drawClipboardCheck(e){return Z(new Promise(e=>$n.fabric.loadSVGFromURL("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzODQgNTEyIj48IS0tIEZvbnQgQXdlc29tZSBGcmVlIDUuMTUuMiBieSBAZm9udGF3ZXNvbWUgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbSBMaWNlbnNlIC0gaHR0cHM6Ly9mb250YXdlc29tZS5jb20vbGljZW5zZS9mcmVlIChJY29uczogQ0MgQlkgNC4wLCBGb250czogU0lMIE9GTCAxLjEsIENvZGU6IE1JVCBMaWNlbnNlKSAtLT48cGF0aCBkPSJNMzM2IDY0aC04MGMwLTM1LjMtMjguNy02NC02NC02NHMtNjQgMjguNy02NCA2NEg0OEMyMS41IDY0IDAgODUuNSAwIDExMnYzNTJjMCAyNi41IDIxLjUgNDggNDggNDhoMjg4YzI2LjUgMCA0OC0yMS41IDQ4LTQ4VjExMmMwLTI2LjUtMjEuNS00OC00OC00OHpNMTkyIDQwYzEzLjMgMCAyNCAxMC43IDI0IDI0cy0xMC43IDI0LTI0IDI0LTI0LTEwLjctMjQtMjQgMTAuNy0yNCAyNC0yNHptMTIxLjIgMjMxLjhsLTE0MyAxNDEuOGMtNC43IDQuNy0xMi4zIDQuNi0xNy0uMWwtODIuNi04My4zYy00LjctNC43LTQuNi0xMi4zLjEtMTdMOTkuMSAyODVjNC43LTQuNyAxMi4zLTQuNiAxNyAuMWw0NiA0Ni40IDEwNi0xMDUuMmM0LjctNC43IDEyLjMtNC42IDE3IC4xbDI4LjIgMjguNGM0LjcgNC44IDQuNiAxMi4zLS4xIDE3eiIvPjwvc3ZnPg==",n=>e(n[0])))).pipe((t=>E(_h(e=>{t.add(e)})))(this.canvas),((t,e)=>E(_h(n=>{const i=t.getPointer(e.e);n.left=i.x+20,n.top=i.y-13;const r=Math.round(25/t.getZoom()),s=Math.round(r*n.width/n.height);n.fill="#0E9F6E",n.scaleToWidth(s,!0),n.scaleToHeight(r,!0),n.opacity=0})))(this.canvas,e),$v(this.canvas,"1"),function(t,e=fA){const i=function(t){return t instanceof Date&&!isNaN(+t)}(t)?+t-e.now():Math.abs(t);return r=>r.lift(new pA(i,e))}(200),$v(this.canvas,"0"),(t=>E(_h(e=>{t.remove(e)})))(this.canvas))}copyToClipboard(e){navigator.clipboard.writeText(e).then()}onMouseUp(e){if(this.isRect(e)){const r=new vA(e.target.data.detectedObject).getCodeString();return this.copyToClipboard(r),void this.drawClipboardCheck(e).subscribe()}}onMouseOut(e){if(this.isRect(e)){e.target.set("stroke","red");const n=this.findObjectByTypeAndId(Xv,e.target.data.id);return this.canvas.remove(n),void this.canvas.renderAll()}}rightBottomCorner(){return{x:$n.fabric.util.invertTransform(this.canvas.viewportTransform)[4]+this.canvas.width/this.canvas.getZoom(),y:$n.fabric.util.invertTransform(this.canvas.viewportTransform)[5]+this.canvas.height/this.canvas.getZoom()}}onMouseOver(e){var n,i,r;this.isRect(e)&&(this.currentMousePoint=this.canvas.getPointer(e.e),null===(n=e.target)||void 0===n||n.set("stroke","green"),this.drawTooltip(null===(i=e.target)||void 0===i?void 0:i.data.id,null===(r=e.target)||void 0===r?void 0:r.data.detectedObject),this.canvas.renderAll())}findObjectByTypeAndId(e,n){return this.canvas.getObjects().find(i=>{var r,s;return(null===(r=i.data)||void 0===r?void 0:r.id)===n&&(null===(s=i.data)||void 0===s?void 0:s.type)===e})}static imageStrToFabricImage(e){return new I(n=>{$n.fabric.Image.fromURL(e,i=>{if(void 0===i.getElement())return n.error(i),void n.complete();n.next(i),n.complete()})})}setCanvasSizeToImageSize(e){const n=this.canvasWrapper.clientWidth;this.canvas.setWidth(n),this.canvas.setHeight(n*e.height/e.width),this.canvas.setZoom(n/e.width)}drawImage(e,n){return Ch.imageStrToFabricImage(e).pipe(ae(i=>{this.setCanvasSizeToImageSize(i),i.lockMovementX=!0,i.lockMovementY=!0,i.lockScalingX=!0,i.lockScalingY=!0,i.hasControls=!1,i.selectable=!1,i.hoverCursor="default",n&&this.canvas.add(i)}))}placeObjectAroundPoint(e,n){return e.left=n.x-e.width/2,e.left<=0&&(e.left=0),e.left+e.width>this.rightBottomCorner().x&&(e.left=this.rightBottomCorner().x-e.width),e.top=n.y+20/this.canvas.getZoom(),e.top+e.height>this.rightBottomCorner().y&&(e.top=n.y-e.height-10),e}placeObjectAroundMouse(e){return this.placeObjectAroundPoint(e,this.currentMousePoint)}buildTooltip(e,n){const i=new $n.fabric.Text(e,{fontFamily:"Source Sans Pro",fontSize:Math.round(18/this.canvas.getZoom()),originX:"center",originY:"center",fill:"white",lockMovementX:!0,lockMovementY:!0,lockScalingX:!0,lockScalingY:!0,lockRotation:!0,hasControls:!1}),r=new $n.fabric.Rect({fill:"rgba(0,0,0, 0.9)",originX:"center",originY:"center",rx:10,ry:10,stroke:"black",strokeWidth:1,strokeUniform:!0,width:i.getLineWidth(0)+20,height:i.getHeightOfLine(0)+20});return new $n.fabric.Group([r,i],{data:{type:Xv,id:n},visible:!0,lockMovementX:!0,lockMovementY:!0,lockScalingX:!0,lockScalingY:!0,lockRotation:!0,hasControls:!1})}drawTooltip(e,n){let i=n.name.replace(/_/g," ");n.hasText()&&(i+=": "+n.text),n.hasSimilarityScore()&&(i+=`, match result: ${n.similarityScore}%`),n.hasColors()&&(i+=", colors: "+n.colors.join(", "));const r=this.buildTooltip(i,e);this.placeObjectAroundMouse(r),this.canvas.add(r)}drawRect(e,n){const i=new $n.fabric.Rect({data:{id:e,type:"rect",detectedObject:n},top:n.bbox.ymin,left:n.bbox.xmin,width:n.bbox.width,height:n.bbox.height,stroke:"red",strokeWidth:1,strokeUniform:!0,fill:"rgba(0,0,0,0)",lockMovementX:!0,lockMovementY:!0,lockScalingX:!0,lockScalingY:!0,lockRotation:!0,hasControls:!1,hoverCursor:n.hasText()?"pointer":"default"});this.canvas.add(i)}resizeCanvas(){if(void 0===this.canvas)return;const e=this.canvasWrapper.clientWidth,n=this.canvas.getWidth()/this.canvas.getHeight(),i=e,r=i/this.canvas.getWidth(),s=this.canvas.getZoom()*r;this.canvas.setDimensions({width:i,height:i/n}),this.canvas.setViewportTransform([s,0,0,s,0,0])}}class TA{constructor(e,n,i,r){this.xmin=e,this.ymin=n,this.xmax=i,this.ymax=r}get width(){return this.xmax-this.xmin}get height(){return this.ymax-this.ymin}get size(){return this.width*this.height}}class bh{constructor(e,n,i,r,s=0){this.name=e,this.text=n,this.bbox=i,this.colors=r,this.similarityScore=s}hasText(){return this.text.length>0}hasColors(){var e;return(null===(e=this.colors)||void 0===e?void 0:e.join("").length)>0}hasSimilarityScore(){return this.similarityScore>0}isIcon(){return"icon"===this.name}static fromJson(e){return new bh(e.name,e.text,new TA(e.bndbox.xmin,e.bndbox.ymin,e.bndbox.xmax,e.bndbox.ymax),e.colors,e.similarityScore)}}const xA=["canvas"],IA=["canvaswrapper"];let qv=(()=>{class t{constructor(){this.imagestr="",this.shouldrenderimage=!0,this.detectedobjects=[]}ngOnDestroy(){this.observer.disconnect(),this.destroyCanvas()}ngAfterViewInit(){this.setupMutationObserver()}startDrawing(){""!==this.imagestr&&(this.canvas&&this.destroyCanvas(),this.initCanvas(),this.renderCanvas())}initCanvas(){this.canvas=new Ch(new $n.fabric.Canvas(this.canvasHtml.nativeElement,{fireRightClick:!0,stopContextMenu:!0}),this.canvasWrapperHtml.nativeElement)}destroyCanvas(){this.canvas.destroy()}renderCanvas(){!this.canvas||this.canvas.drawImage(this.imagestr,this.shouldrenderimage).subscribe(()=>{this.drawRects()})}drawRects(){Array.from(this.detectedobjects).sort((i,r)=>-i.bbox.size+r.bbox.size).forEach((i,r)=>{this.canvas.drawRect(r,i)})}setupMutationObserver(){const n=document.getElementsByTagName("bounding-box-renderer")[0],r=this;this.observer=new MutationObserver(function(c){for(const g of c)"attributes"===g.type&&"imagestr"==g.attributeName&&(r.imagestr=g.target.getAttribute("imagestr"),r.startDrawing()),"attributes"===g.type&&"shouldrenderimage"==g.attributeName&&(r.shouldrenderimage="true"==g.target.getAttribute("shouldrenderimage"),r.startDrawing()),"attributes"===g.type&&"detectedobjects"==g.attributeName&&(r.detectedobjects=JSON.parse(g.target.getAttribute("detectedobjects")).map(_=>bh.fromJson(_)),r.startDrawing())}),this.observer.observe(n,{attributes:!0,childList:!0,subtree:!0})}}return t.\u0275fac=function(n){return new(n||t)},t.\u0275cmp=tl({type:t,selectors:[["bounding-box-renderer"]],viewQuery:function(n,i){if(1&n&&(yc(xA,5),yc(IA,5)),2&n){let r;mc(r=vc())&&(i.canvasHtml=r.first),mc(r=vc())&&(i.canvasWrapperHtml=r.first)}},inputs:{imagestr:"imagestr",shouldrenderimage:"shouldrenderimage",detectedobjects:"detectedobjects"},decls:4,vars:0,consts:[["id","canvas-wrapper"],["canvaswrapper",""],["id","canvas"],["canvas",""]],template:function(n,i){1&n&&(Ru(0,"div",0,1),function(t,e,n,i){Ru(t,e,n,i),ku()}(2,"canvas",2,3),ku())},encapsulation:2}),t})(),MA=(()=>{class t{constructor(n){this.injector=n}ngDoBootstrap(){const n=function(t,e){const n=function(t,e){return e.get(_i).resolveComponentFactory(t).inputs}(t,e.injector),i=e.strategyFactory||new lA(t,e.injector),r=function(t){const e={};return t.forEach(({propName:n,templateName:i})=>{e[function(t){return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}(i)]=n}),e}(n);class s extends cA{constructor(g){super(),this.injector=g}get ngElementStrategy(){if(!this._ngElementStrategy){const g=this._ngElementStrategy=i.create(this.injector||e.injector);n.forEach(({propName:_})=>{if(!this.hasOwnProperty(_))return;const w=this[_];delete this[_],g.setInputValue(_,w)})}return this._ngElementStrategy}attributeChangedCallback(g,_,w,S){this.ngElementStrategy.setInputValue(r[g],w)}connectedCallback(){let g=!1;this.ngElementStrategy.events&&(this.subscribeToEvents(),g=!0),this.ngElementStrategy.connect(this),g||this.subscribeToEvents()}disconnectedCallback(){this._ngElementStrategy&&this._ngElementStrategy.disconnect(),this.ngElementEventsSubscription&&(this.ngElementEventsSubscription.unsubscribe(),this.ngElementEventsSubscription=null)}subscribeToEvents(){this.ngElementEventsSubscription=this.ngElementStrategy.events.subscribe(g=>{const _=function(t,e,n){if("function"!=typeof CustomEvent){const s=t.createEvent("CustomEvent");return s.initCustomEvent(e,!1,!1,n),s}return new CustomEvent(e,{bubbles:!1,cancelable:!1,detail:n})}(this.ownerDocument,g.name,g.value);this.dispatchEvent(_)})}}return s.observedAttributes=Object.keys(r),n.forEach(({propName:c})=>{Object.defineProperty(s.prototype,c,{get(){return this.ngElementStrategy.getInputValue(c)},set(g){this.ngElementStrategy.setInputValue(c,g)},configurable:!0,enumerable:!0})}),s}(qv,{injector:this.injector});customElements.define("bounding-box-renderer",n)}}return t.\u0275fac=function(n){return new(n||t)(Ve(tt))},t.\u0275mod=Zr({type:t,bootstrap:[qv]}),t.\u0275inj=xi({imports:[[xO]]}),t})();(function(){if(Ny)throw new Error("Cannot enable prod mode after platform setup.");ky=!1})(),SO().bootstrapModule(MA).catch(t=>console.error(t))},450:()=>{},529:()=>{},536:()=>{}},$i=>{$i($i.s=38)}]);
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
<script>
|
|
11
|
+
(()=>{var oe=Object.create;var Ot=Object.defineProperty;var he=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var ce=Object.getPrototypeOf,fe=Object.prototype.hasOwnProperty;var ue=(c,i,a)=>i in c?Ot(c,i,{enumerable:!0,configurable:!0,writable:!0,value:a}):c[i]=a;var pt=(c,i)=>()=>(i||c((i={exports:{}}).exports,i),i.exports);var de=(c,i,a,o)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of le(i))!fe.call(c,t)&&t!==a&&Ot(c,t,{get:()=>i[t],enumerable:!(o=he(i,t))||o.enumerable});return c};var Et=(c,i,a)=>(a=c!=null?oe(ce(c)):{},de(i||!c||!c.__esModule?Ot(a,"default",{value:c,enumerable:!0}):a,c));var at=(c,i,a)=>ue(c,typeof i!="symbol"?i+"":i,a);var gt=(c,i,a)=>new Promise((o,t)=>{var r=h=>{try{s(a.next(h))}catch(n){t(n)}},e=h=>{try{s(a.throw(h))}catch(n){t(n)}},s=h=>h.done?o(h.value):Promise.resolve(h.value).then(r,e);s((a=a.apply(c,i)).next())});var Lt=pt(()=>{});var It=pt(()=>{});var jt=pt(()=>{});var vt=pt(F=>{var u=u||{version:"5.1.0"};typeof F!="undefined"?F.fabric=u:typeof define=="function"&&define.amd&&define([],function(){return u});typeof document!="undefined"&&typeof window!="undefined"?(document instanceof(typeof HTMLDocument!="undefined"?HTMLDocument:Document)?u.document=document:u.document=document.implementation.createHTMLDocument(""),u.window=window):(Rt=Lt(),Pt=new Rt.JSDOM(decodeURIComponent("%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E"),{features:{FetchExternalResources:["img"]},resources:"usable"}).window,u.document=Pt.document,u.jsdomImplForWrapper=It().implForWrapper,u.nodeCanvas=jt().Canvas,u.window=Pt,DOMParser=u.window.DOMParser);var Rt,Pt;u.isTouchSupported="ontouchstart"in u.window||"ontouchstart"in u.document||u.window&&u.window.navigator&&u.window.navigator.maxTouchPoints>0;u.isLikelyNode=typeof Buffer!="undefined"&&typeof window=="undefined";u.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"];u.DPI=96;u.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)";u.commaWsp="(?:\\s+,?\\s*|,\\s*)";u.rePathCommand=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/ig;u.reNonWord=/[ \n\.,;!\?\-]/;u.fontPaths={};u.iMatrix=[1,0,0,1,0,0];u.svgNS="http://www.w3.org/2000/svg";u.perfLimitSizeTotal=2097152;u.maxCacheSideLimit=4096;u.minCacheSideLimit=256;u.charWidthsCache={};u.textureSize=2048;u.disableStyleCopyPaste=!1;u.enableGLFiltering=!0;u.devicePixelRatio=u.window.devicePixelRatio||u.window.webkitDevicePixelRatio||u.window.mozDevicePixelRatio||1;u.browserShadowBlurConstant=1;u.arcToSegmentsCache={};u.boundsOfCurveCache={};u.cachesBoundsOfCurve=!0;u.forceGLPutImageData=!1;u.initFilterBackend=function(){if(u.enableGLFiltering&&u.isWebglSupported&&u.isWebglSupported(u.textureSize))return console.log("max texture size: "+u.maxTextureSize),new u.WebglFilterBackend({tileSize:u.textureSize});if(u.Canvas2dFilterBackend)return new u.Canvas2dFilterBackend};typeof document!="undefined"&&typeof window!="undefined"&&(window.fabric=u);(function(){function c(e,s){if(this.__eventListeners[e]){var h=this.__eventListeners[e];s?h[h.indexOf(s)]=!1:u.util.array.fill(h,!1)}}function i(e,s){if(this.__eventListeners||(this.__eventListeners={}),arguments.length===1)for(var h in e)this.on(h,e[h]);else this.__eventListeners[e]||(this.__eventListeners[e]=[]),this.__eventListeners[e].push(s);return this}function a(e,s){var h=function(){s.apply(this,arguments),this.off(e,h)}.bind(this);this.on(e,h)}function o(e,s){if(arguments.length===1)for(var h in e)a.call(this,h,e[h]);else a.call(this,e,s);return this}function t(e,s){if(!this.__eventListeners)return this;if(arguments.length===0)for(e in this.__eventListeners)c.call(this,e);else if(arguments.length===1&&typeof arguments[0]=="object")for(var h in e)c.call(this,h,e[h]);else c.call(this,e,s);return this}function r(e,s){if(!this.__eventListeners)return this;var h=this.__eventListeners[e];if(!h)return this;for(var n=0,l=h.length;n<l;n++)h[n]&&h[n].call(this,s||{});return this.__eventListeners[e]=h.filter(function(f){return f!==!1}),this}u.Observable={fire:r,on:i,once:o,off:t}})();u.Collection={_objects:[],add:function(){if(this._objects.push.apply(this._objects,arguments),this._onObjectAdded)for(var c=0,i=arguments.length;c<i;c++)this._onObjectAdded(arguments[c]);return this.renderOnAddRemove&&this.requestRenderAll(),this},insertAt:function(c,i,a){var o=this._objects;return a?o[i]=c:o.splice(i,0,c),this._onObjectAdded&&this._onObjectAdded(c),this.renderOnAddRemove&&this.requestRenderAll(),this},remove:function(){for(var c=this._objects,i,a=!1,o=0,t=arguments.length;o<t;o++)i=c.indexOf(arguments[o]),i!==-1&&(a=!0,c.splice(i,1),this._onObjectRemoved&&this._onObjectRemoved(arguments[o]));return this.renderOnAddRemove&&a&&this.requestRenderAll(),this},forEachObject:function(c,i){for(var a=this.getObjects(),o=0,t=a.length;o<t;o++)c.call(i,a[o],o,a);return this},getObjects:function(c){return typeof c=="undefined"?this._objects.concat():this._objects.filter(function(i){return i.type===c})},item:function(c){return this._objects[c]},isEmpty:function(){return this._objects.length===0},size:function(){return this._objects.length},contains:function(c,i){return this._objects.indexOf(c)>-1?!0:i?this._objects.some(function(a){return typeof a.contains=="function"&&a.contains(c,!0)}):!1},complexity:function(){return this._objects.reduce(function(c,i){return c+=i.complexity?i.complexity():0,c},0)}};u.CommonMethods={_setOptions:function(c){for(var i in c)this.set(i,c[i])},_initGradient:function(c,i){c&&c.colorStops&&!(c instanceof u.Gradient)&&this.set(i,new u.Gradient(c))},_initPattern:function(c,i,a){c&&c.source&&!(c instanceof u.Pattern)?this.set(i,new u.Pattern(c,a)):a&&a()},_setObject:function(c){for(var i in c)this._set(i,c[i])},set:function(c,i){return typeof c=="object"?this._setObject(c):this._set(c,i),this},_set:function(c,i){this[c]=i},toggle:function(c){var i=this.get(c);return typeof i=="boolean"&&this.set(c,!i),this},get:function(c){return this[c]}};(function(c){var i=Math.sqrt,a=Math.atan2,o=Math.pow,t=Math.PI/180,r=Math.PI/2;u.util={cos:function(e){if(e===0)return 1;e<0&&(e=-e);var s=e/r;switch(s){case 1:case 3:return 0;case 2:return-1}return Math.cos(e)},sin:function(e){if(e===0)return 0;var s=e/r,h=1;switch(e<0&&(h=-1),s){case 1:return h;case 2:return 0;case 3:return-h}return Math.sin(e)},removeFromArray:function(e,s){var h=e.indexOf(s);return h!==-1&&e.splice(h,1),e},getRandomInt:function(e,s){return Math.floor(Math.random()*(s-e+1))+e},degreesToRadians:function(e){return e*t},radiansToDegrees:function(e){return e/t},rotatePoint:function(e,s,h){var n=new u.Point(e.x-s.x,e.y-s.y),l=u.util.rotateVector(n,h);return new u.Point(l.x,l.y).addEquals(s)},rotateVector:function(e,s){var h=u.util.sin(s),n=u.util.cos(s),l=e.x*n-e.y*h,f=e.x*h+e.y*n;return{x:l,y:f}},createVector:function(e,s){return new u.Point(s.x-e.x,s.y-e.y)},calcAngleBetweenVectors:function(e,s){return Math.acos((e.x*s.x+e.y*s.y)/(Math.hypot(e.x,e.y)*Math.hypot(s.x,s.y)))},getHatVector:function(e){return new u.Point(e.x,e.y).multiply(1/Math.hypot(e.x,e.y))},getBisector:function(e,s,h){var n=u.util.createVector(e,s),l=u.util.createVector(e,h),f=u.util.calcAngleBetweenVectors(n,l),d=u.util.calcAngleBetweenVectors(u.util.rotateVector(n,f),l),g=f*(d===0?1:-1)/2;return{vector:u.util.getHatVector(u.util.rotateVector(n,g)),angle:f}},projectStrokeOnPoints:function(e,s,h){var n=[],l=s.strokeWidth/2,f=s.strokeUniform?new u.Point(1/s.scaleX,1/s.scaleY):new u.Point(1,1),d=function(g){var m=l/Math.hypot(g.x,g.y);return new u.Point(g.x*m*f.x,g.y*m*f.y)};return e.length<=1||e.forEach(function(g,m){var p=new u.Point(g.x,g.y),_,w;m===0?(w=e[m+1],_=h?d(u.util.createVector(w,p)).addEquals(p):e[e.length-1]):m===e.length-1?(_=e[m-1],w=h?d(u.util.createVector(_,p)).addEquals(p):e[0]):(_=e[m-1],w=e[m+1]);var D=u.util.getBisector(p,_,w),B=D.vector,N=D.angle,G,z;if(s.strokeLineJoin==="miter"&&(G=-l/Math.sin(N/2),z=new u.Point(B.x*G*f.x,B.y*G*f.y),Math.hypot(z.x,z.y)/l<=s.strokeMiterLimit)){n.push(p.add(z)),n.push(p.subtract(z));return}G=-l*Math.SQRT2,z=new u.Point(B.x*G*f.x,B.y*G*f.y),n.push(p.add(z)),n.push(p.subtract(z))}),n},transformPoint:function(e,s,h){return h?new u.Point(s[0]*e.x+s[2]*e.y,s[1]*e.x+s[3]*e.y):new u.Point(s[0]*e.x+s[2]*e.y+s[4],s[1]*e.x+s[3]*e.y+s[5])},makeBoundingBoxFromPoints:function(e,s){if(s)for(var h=0;h<e.length;h++)e[h]=u.util.transformPoint(e[h],s);var n=[e[0].x,e[1].x,e[2].x,e[3].x],l=u.util.array.min(n),f=u.util.array.max(n),d=f-l,g=[e[0].y,e[1].y,e[2].y,e[3].y],m=u.util.array.min(g),p=u.util.array.max(g),_=p-m;return{left:l,top:m,width:d,height:_}},invertTransform:function(e){var s=1/(e[0]*e[3]-e[1]*e[2]),h=[s*e[3],-s*e[1],-s*e[2],s*e[0]],n=u.util.transformPoint({x:e[4],y:e[5]},h,!0);return h[4]=-n.x,h[5]=-n.y,h},toFixed:function(e,s){return parseFloat(Number(e).toFixed(s))},parseUnit:function(e,s){var h=/\D{0,2}$/.exec(e),n=parseFloat(e);switch(s||(s=u.Text.DEFAULT_SVG_FONT_SIZE),h[0]){case"mm":return n*u.DPI/25.4;case"cm":return n*u.DPI/2.54;case"in":return n*u.DPI;case"pt":return n*u.DPI/72;case"pc":return n*u.DPI/72*12;case"em":return n*s;default:return n}},falseFunction:function(){return!1},getKlass:function(e,s){return e=u.util.string.camelize(e.charAt(0).toUpperCase()+e.slice(1)),u.util.resolveNamespace(s)[e]},getSvgAttributes:function(e){var s=["instantiated_by_use","style","id","class"];switch(e){case"linearGradient":s=s.concat(["x1","y1","x2","y2","gradientUnits","gradientTransform"]);break;case"radialGradient":s=s.concat(["gradientUnits","gradientTransform","cx","cy","r","fx","fy","fr"]);break;case"stop":s=s.concat(["offset","stop-color","stop-opacity"]);break}return s},resolveNamespace:function(e){if(!e)return u;var s=e.split("."),h=s.length,n,l=c||u.window;for(n=0;n<h;++n)l=l[s[n]];return l},loadImage:function(e,s,h,n){if(!e){s&&s.call(h,e);return}var l=u.util.createImage(),f=function(){s&&s.call(h,l,!1),l=l.onload=l.onerror=null};l.onload=f,l.onerror=function(){u.log("Error loading "+l.src),s&&s.call(h,null,!0),l=l.onload=l.onerror=null},e.indexOf("data")!==0&&n!==void 0&&n!==null&&(l.crossOrigin=n),e.substring(0,14)==="data:image/svg"&&(l.onload=null,u.util.loadImageInDom(l,f)),l.src=e},loadImageInDom:function(e,s){var h=u.document.createElement("div");h.style.width=h.style.height="1px",h.style.left=h.style.top="-100%",h.style.position="absolute",h.appendChild(e),u.document.querySelector("body").appendChild(h),e.onload=function(){s(),h.parentNode.removeChild(h),h=null}},enlivenObjects:function(e,s,h,n){e=e||[];var l=[],f=0,d=e.length;function g(){++f===d&&s&&s(l.filter(function(m){return m}))}if(!d){s&&s(l);return}e.forEach(function(m,p){if(!m||!m.type){g();return}var _=u.util.getKlass(m.type,h);_.fromObject(m,function(w,D){D||(l[p]=w),n&&n(m,w,D),g()})})},enlivenObjectEnlivables:function(e,s,h){var n=u.Object.ENLIVEN_PROPS.filter(function(l){return!!e[l]});u.util.enlivenObjects(n.map(function(l){return e[l]}),function(l){var f={};n.forEach(function(d,g){f[d]=l[g],s&&(s[d]=l[g])}),h&&h(f)})},enlivenPatterns:function(e,s){e=e||[];function h(){++l===f&&s&&s(n)}var n=[],l=0,f=e.length;if(!f){s&&s(n);return}e.forEach(function(d,g){d&&d.source?new u.Pattern(d,function(m){n[g]=m,h()}):(n[g]=d,h())})},groupSVGElements:function(e,s,h){var n;return e&&e.length===1?e[0]:(s&&(s.width&&s.height?s.centerPoint={x:s.width/2,y:s.height/2}:(delete s.width,delete s.height)),n=new u.Group(e,s),typeof h!="undefined"&&(n.sourcePath=h),n)},populateWithProperties:function(e,s,h){if(h&&Object.prototype.toString.call(h)==="[object Array]")for(var n=0,l=h.length;n<l;n++)h[n]in e&&(s[h[n]]=e[h[n]])},createCanvasElement:function(){return u.document.createElement("canvas")},copyCanvasElement:function(e){var s=u.util.createCanvasElement();return s.width=e.width,s.height=e.height,s.getContext("2d").drawImage(e,0,0),s},toDataURL:function(e,s,h){return e.toDataURL("image/"+s,h)},createImage:function(){return u.document.createElement("img")},multiplyTransformMatrices:function(e,s,h){return[e[0]*s[0]+e[2]*s[1],e[1]*s[0]+e[3]*s[1],e[0]*s[2]+e[2]*s[3],e[1]*s[2]+e[3]*s[3],h?0:e[0]*s[4]+e[2]*s[5]+e[4],h?0:e[1]*s[4]+e[3]*s[5]+e[5]]},qrDecompose:function(e){var s=a(e[1],e[0]),h=o(e[0],2)+o(e[1],2),n=i(h),l=(e[0]*e[3]-e[2]*e[1])/n,f=a(e[0]*e[2]+e[1]*e[3],h);return{angle:s/t,scaleX:n,scaleY:l,skewX:f/t,skewY:0,translateX:e[4],translateY:e[5]}},calcRotateMatrix:function(e){if(!e.angle)return u.iMatrix.concat();var s=u.util.degreesToRadians(e.angle),h=u.util.cos(s),n=u.util.sin(s);return[h,n,-n,h,0,0]},calcDimensionsMatrix:function(e){var s=typeof e.scaleX=="undefined"?1:e.scaleX,h=typeof e.scaleY=="undefined"?1:e.scaleY,n=[e.flipX?-s:s,0,0,e.flipY?-h:h,0,0],l=u.util.multiplyTransformMatrices,f=u.util.degreesToRadians;return e.skewX&&(n=l(n,[1,0,Math.tan(f(e.skewX)),1],!0)),e.skewY&&(n=l(n,[1,Math.tan(f(e.skewY)),0,1],!0)),n},composeMatrix:function(e){var s=[1,0,0,1,e.translateX||0,e.translateY||0],h=u.util.multiplyTransformMatrices;return e.angle&&(s=h(s,u.util.calcRotateMatrix(e))),(e.scaleX!==1||e.scaleY!==1||e.skewX||e.skewY||e.flipX||e.flipY)&&(s=h(s,u.util.calcDimensionsMatrix(e))),s},resetObjectTransform:function(e){e.scaleX=1,e.scaleY=1,e.skewX=0,e.skewY=0,e.flipX=!1,e.flipY=!1,e.rotate(0)},saveObjectTransform:function(e){return{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}},isTransparent:function(e,s,h,n){n>0&&(s>n?s-=n:s=0,h>n?h-=n:h=0);var l=!0,f,d,g=e.getImageData(s,h,n*2||1,n*2||1),m=g.data.length;for(f=3;f<m&&(d=g.data[f],l=d<=0,l!==!1);f+=4);return g=null,l},parsePreserveAspectRatioAttribute:function(e){var s="meet",h="Mid",n="Mid",l=e.split(" "),f;return l&&l.length&&(s=l.pop(),s!=="meet"&&s!=="slice"?(f=s,s="meet"):l.length&&(f=l.pop())),h=f!=="none"?f.slice(1,4):"none",n=f!=="none"?f.slice(5,8):"none",{meetOrSlice:s,alignX:h,alignY:n}},clearFabricFontCache:function(e){e=(e||"").toLowerCase(),e?u.charWidthsCache[e]&&delete u.charWidthsCache[e]:u.charWidthsCache={}},limitDimsByArea:function(e,s){var h=Math.sqrt(s*e),n=Math.floor(s/h);return{x:Math.floor(h),y:n}},capValue:function(e,s,h){return Math.max(e,Math.min(s,h))},findScaleToFit:function(e,s){return Math.min(s.width/e.width,s.height/e.height)},findScaleToCover:function(e,s){return Math.max(s.width/e.width,s.height/e.height)},matrixToSVG:function(e){return"matrix("+e.map(function(s){return u.util.toFixed(s,u.Object.NUM_FRACTION_DIGITS)}).join(" ")+")"},removeTransformFromObject:function(e,s){var h=u.util.invertTransform(s),n=u.util.multiplyTransformMatrices(h,e.calcOwnMatrix());u.util.applyTransformToObject(e,n)},addTransformToObject:function(e,s){u.util.applyTransformToObject(e,u.util.multiplyTransformMatrices(s,e.calcOwnMatrix()))},applyTransformToObject:function(e,s){var h=u.util.qrDecompose(s),n=new u.Point(h.translateX,h.translateY);e.flipX=!1,e.flipY=!1,e.set("scaleX",h.scaleX),e.set("scaleY",h.scaleY),e.skewX=h.skewX,e.skewY=h.skewY,e.angle=h.angle,e.setPositionByOrigin(n,"center","center")},sizeAfterTransform:function(e,s,h){var n=e/2,l=s/2,f=[{x:-n,y:-l},{x:n,y:-l},{x:-n,y:l},{x:n,y:l}],d=u.util.calcDimensionsMatrix(h),g=u.util.makeBoundingBoxFromPoints(f,d);return{x:g.width,y:g.height}},mergeClipPaths:function(e,s){var h=e,n=s;h.inverted&&!n.inverted&&(h=s,n=e),u.util.applyTransformToObject(n,u.util.multiplyTransformMatrices(u.util.invertTransform(h.calcTransformMatrix()),n.calcTransformMatrix()));var l=h.inverted&&n.inverted;return l&&(h.inverted=n.inverted=!1),new u.Group([h],{clipPath:n,inverted:l})}}})(F);(function(){var c=Array.prototype.join,i={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},a={m:"l",M:"L"};function o(v,b,S,C,P,x,y,T,E,L,k){var W=u.util.cos(v),Y=u.util.sin(v),V=u.util.cos(b),M=u.util.sin(b),O=S*P*V-C*x*M+y,j=C*P*V+S*x*M+T,R=L+E*(-S*P*Y-C*x*W),A=k+E*(-C*P*Y+S*x*W),X=O+E*(S*P*M+C*x*V),q=j+E*(C*P*M-S*x*V);return["C",R,A,X,q,O,j]}function t(v,b,S,C,P,x,y){var T=Math.PI,E=y*T/180,L=u.util.sin(E),k=u.util.cos(E),W=0,Y=0;S=Math.abs(S),C=Math.abs(C);var V=-k*v*.5-L*b*.5,M=-k*b*.5+L*v*.5,O=S*S,j=C*C,R=M*M,A=V*V,X=O*j-O*R-j*A,q=0;if(X<0){var tt=Math.sqrt(1-X/(O*j));S*=tt,C*=tt}else q=(P===x?-1:1)*Math.sqrt(X/(O*R+j*A));var Z=q*S*M/C,I=-q*C*V/S,$=k*Z-L*I+v*.5,et=L*Z+k*I+b*.5,it=r(1,0,(V-Z)/S,(M-I)/C),nt=r((V-Z)/S,(M-I)/C,(-V-Z)/S,(-M-I)/C);x===0&&nt>0?nt-=2*T:x===1&&nt<0&&(nt+=2*T);for(var rt=Math.ceil(Math.abs(nt/T*2)),ot=[],st=nt/rt,ct=8/3*Math.sin(st/4)*Math.sin(st/4)/Math.sin(st/2),dt=it+st,lt=0;lt<rt;lt++)ot[lt]=o(it,dt,k,L,S,C,$,et,ct,W,Y),W=ot[lt][5],Y=ot[lt][6],it=dt,dt+=st;return ot}function r(v,b,S,C){var P=Math.atan2(b,v),x=Math.atan2(C,S);return x>=P?x-P:2*Math.PI-(P-x)}function e(v,b,S,C,P,x,y,T){var E;if(u.cachesBoundsOfCurve&&(E=c.call(arguments),u.boundsOfCurveCache[E]))return u.boundsOfCurveCache[E];var L=Math.sqrt,k=Math.min,W=Math.max,Y=Math.abs,V=[],M=[[],[]],O,j,R,A,X,q,tt,Z;j=6*v-12*S+6*P,O=-3*v+9*S-9*P+3*y,R=3*S-3*v;for(var I=0;I<2;++I){if(I>0&&(j=6*b-12*C+6*x,O=-3*b+9*C-9*x+3*T,R=3*C-3*b),Y(O)<1e-12){if(Y(j)<1e-12)continue;A=-R/j,0<A&&A<1&&V.push(A);continue}tt=j*j-4*R*O,!(tt<0)&&(Z=L(tt),X=(-j+Z)/(2*O),0<X&&X<1&&V.push(X),q=(-j-Z)/(2*O),0<q&&q<1&&V.push(q))}for(var $,et,it=V.length,nt=it,rt;it--;)A=V[it],rt=1-A,$=rt*rt*rt*v+3*rt*rt*A*S+3*rt*A*A*P+A*A*A*y,M[0][it]=$,et=rt*rt*rt*b+3*rt*rt*A*C+3*rt*A*A*x+A*A*A*T,M[1][it]=et;M[0][nt]=v,M[1][nt]=b,M[0][nt+1]=y,M[1][nt+1]=T;var ot=[{x:k.apply(null,M[0]),y:k.apply(null,M[1])},{x:W.apply(null,M[0]),y:W.apply(null,M[1])}];return u.cachesBoundsOfCurve&&(u.boundsOfCurveCache[E]=ot),ot}function s(v,b,S){for(var C=S[1],P=S[2],x=S[3],y=S[4],T=S[5],E=S[6],L=S[7],k=t(E-v,L-b,C,P,y,T,x),W=0,Y=k.length;W<Y;W++)k[W][1]+=v,k[W][2]+=b,k[W][3]+=v,k[W][4]+=b,k[W][5]+=v,k[W][6]+=b;return k}function h(v){var b=0,S=0,C=v.length,P=0,x=0,y,T,E,L=[],k,W,Y;for(T=0;T<C;++T){switch(E=!1,y=v[T].slice(0),y[0]){case"l":y[0]="L",y[1]+=b,y[2]+=S;case"L":b=y[1],S=y[2];break;case"h":y[1]+=b;case"H":y[0]="L",y[2]=S,b=y[1];break;case"v":y[1]+=S;case"V":y[0]="L",S=y[1],y[1]=b,y[2]=S;break;case"m":y[0]="M",y[1]+=b,y[2]+=S;case"M":b=y[1],S=y[2],P=y[1],x=y[2];break;case"c":y[0]="C",y[1]+=b,y[2]+=S,y[3]+=b,y[4]+=S,y[5]+=b,y[6]+=S;case"C":W=y[3],Y=y[4],b=y[5],S=y[6];break;case"s":y[0]="S",y[1]+=b,y[2]+=S,y[3]+=b,y[4]+=S;case"S":k==="C"?(W=2*b-W,Y=2*S-Y):(W=b,Y=S),b=y[3],S=y[4],y[0]="C",y[5]=y[3],y[6]=y[4],y[3]=y[1],y[4]=y[2],y[1]=W,y[2]=Y,W=y[3],Y=y[4];break;case"q":y[0]="Q",y[1]+=b,y[2]+=S,y[3]+=b,y[4]+=S;case"Q":W=y[1],Y=y[2],b=y[3],S=y[4];break;case"t":y[0]="T",y[1]+=b,y[2]+=S;case"T":k==="Q"?(W=2*b-W,Y=2*S-Y):(W=b,Y=S),y[0]="Q",b=y[1],S=y[2],y[1]=W,y[2]=Y,y[3]=b,y[4]=S;break;case"a":y[0]="A",y[6]+=b,y[7]+=S;case"A":E=!0,L=L.concat(s(b,S,y)),b=y[6],S=y[7];break;case"z":case"Z":b=P,S=x;break;default:}E||L.push(y),k=y[0]}return L}function n(v,b,S,C){return Math.sqrt((S-v)*(S-v)+(C-b)*(C-b))}function l(v){return v*v*v}function f(v){return 3*v*v*(1-v)}function d(v){return 3*v*(1-v)*(1-v)}function g(v){return(1-v)*(1-v)*(1-v)}function m(v,b,S,C,P,x,y,T){return function(E){var L=l(E),k=f(E),W=d(E),Y=g(E);return{x:y*L+P*k+S*W+v*Y,y:T*L+x*k+C*W+b*Y}}}function p(v,b,S,C,P,x,y,T){return function(E){var L=1-E,k=3*L*L*(S-v)+6*L*E*(P-S)+3*E*E*(y-P),W=3*L*L*(C-b)+6*L*E*(x-C)+3*E*E*(T-x);return Math.atan2(W,k)}}function _(v){return v*v}function w(v){return 2*v*(1-v)}function D(v){return(1-v)*(1-v)}function B(v,b,S,C,P,x){return function(y){var T=_(y),E=w(y),L=D(y);return{x:P*T+S*E+v*L,y:x*T+C*E+b*L}}}function N(v,b,S,C,P,x){return function(y){var T=1-y,E=2*T*(S-v)+2*y*(P-S),L=2*T*(C-b)+2*y*(x-C);return Math.atan2(L,E)}}function G(v,b,S){var C={x:b,y:S},P,x=0,y;for(y=1;y<=100;y+=1)P=v(y/100),x+=n(C.x,C.y,P.x,P.y),C=P;return x}function z(v,b){for(var S=0,C=0,P=v.iterator,x={x:v.x,y:v.y},y,T,E=.01,L=v.angleFinder,k;C<b&&E>1e-4;)y=P(S),k=S,T=n(x.x,x.y,y.x,y.y),T+C>b?(S-=E,E/=2):(x=y,S+=E,C+=T);return y.angle=L(k),y}function H(v){for(var b=0,S=v.length,C,P=0,x=0,y=0,T=0,E=[],L,k,W,Y=0;Y<S;Y++){switch(C=v[Y],k={x:P,y:x,command:C[0]},C[0]){case"M":k.length=0,y=P=C[1],T=x=C[2];break;case"L":k.length=n(P,x,C[1],C[2]),P=C[1],x=C[2];break;case"C":L=m(P,x,C[1],C[2],C[3],C[4],C[5],C[6]),W=p(P,x,C[1],C[2],C[3],C[4],C[5],C[6]),k.iterator=L,k.angleFinder=W,k.length=G(L,P,x),P=C[5],x=C[6];break;case"Q":L=B(P,x,C[1],C[2],C[3],C[4]),W=N(P,x,C[1],C[2],C[3],C[4]),k.iterator=L,k.angleFinder=W,k.length=G(L,P,x),P=C[3],x=C[4];break;case"Z":case"z":k.destX=y,k.destY=T,k.length=n(P,x,y,T),P=y,x=T;break}b+=k.length,E.push(k)}return E.push({length:b,x:P,y:x}),E}function U(v,b,S){S||(S=H(v));for(var C=0;b-S[C].length>0&&C<S.length-2;)b-=S[C].length,C++;var P=S[C],x=b/P.length,y=P.command,T=v[C],E;switch(y){case"M":return{x:P.x,y:P.y,angle:0};case"Z":case"z":return E=new u.Point(P.x,P.y).lerp(new u.Point(P.destX,P.destY),x),E.angle=Math.atan2(P.destY-P.y,P.destX-P.x),E;case"L":return E=new u.Point(P.x,P.y).lerp(new u.Point(T[1],T[2]),x),E.angle=Math.atan2(T[2]-P.y,T[1]-P.x),E;case"C":return z(P,b);case"Q":return z(P,b)}}function K(v){var b=[],S=[],C,P,x=u.rePathCommand,y="[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?\\s*",T="("+y+")"+u.commaWsp,E="([01])"+u.commaWsp+"?",L=T+"?"+T+"?"+T+E+E+T+"?("+y+")",k=new RegExp(L,"g"),W,Y,V;if(!v||!v.match)return b;V=v.match(/[mzlhvcsqta][^mzlhvcsqta]*/gi);for(var M=0,O,j=V.length;M<j;M++){C=V[M],Y=C.slice(1).trim(),S.length=0;var R=C.charAt(0);if(O=[R],R.toLowerCase()==="a")for(var A;A=k.exec(Y);)for(var X=1;X<A.length;X++)S.push(A[X]);else for(;W=x.exec(Y);)S.push(W[0]);for(var X=0,q=S.length;X<q;X++)P=parseFloat(S[X]),isNaN(P)||O.push(P);var tt=i[R.toLowerCase()],Z=a[R]||R;if(O.length-1>tt)for(var I=1,$=O.length;I<$;I+=tt)b.push([R].concat(O.slice(I,I+tt))),R=Z;else b.push(O)}return b}function Q(v,b){var S=[],C,P=new u.Point(v[0].x,v[0].y),x=new u.Point(v[1].x,v[1].y),y=v.length,T=1,E=0,L=y>2;for(b=b||0,L&&(T=v[2].x<x.x?-1:v[2].x===x.x?0:1,E=v[2].y<x.y?-1:v[2].y===x.y?0:1),S.push(["M",P.x-T*b,P.y-E*b]),C=1;C<y;C++){if(!P.eq(x)){var k=P.midPointFrom(x);S.push(["Q",P.x,P.y,k.x,k.y])}P=v[C],C+1<v.length&&(x=v[C+1])}return L&&(T=P.x>v[C-2].x?1:P.x===v[C-2].x?0:-1,E=P.y>v[C-2].y?1:P.y===v[C-2].y?0:-1),S.push(["L",P.x+T*b,P.y+E*b]),S}function J(v,b,S){return S&&(b=u.util.multiplyTransformMatrices(b,[1,0,0,1,-S.x,-S.y])),v.map(function(C){for(var P=C.slice(0),x={},y=1;y<C.length-1;y+=2)x.x=C[y],x.y=C[y+1],x=u.util.transformPoint(x,b),P[y]=x.x,P[y+1]=x.y;return P})}u.util.joinPath=function(v){return v.map(function(b){return b.join(" ")}).join(" ")},u.util.parsePath=K,u.util.makePathSimpler=h,u.util.getSmoothPathFromPoints=Q,u.util.getPathSegmentsInfo=H,u.util.getBoundsOfCurve=e,u.util.getPointOnPath=U,u.util.transformPath=J})();(function(){var c=Array.prototype.slice;function i(e,s){for(var h=c.call(arguments,2),n=[],l=0,f=e.length;l<f;l++)n[l]=h.length?e[l][s].apply(e[l],h):e[l][s].call(e[l]);return n}function a(e,s){return r(e,s,function(h,n){return h>=n})}function o(e,s){return r(e,s,function(h,n){return h<n})}function t(e,s){for(var h=e.length;h--;)e[h]=s;return e}function r(e,s,h){if(!(!e||e.length===0)){var n=e.length-1,l=s?e[n][s]:e[n];if(s)for(;n--;)h(e[n][s],l)&&(l=e[n][s]);else for(;n--;)h(e[n],l)&&(l=e[n]);return l}}u.util.array={fill:t,invoke:i,min:o,max:a}})();(function(){function c(a,o,t){if(t)if(!u.isLikelyNode&&o instanceof Element)a=o;else if(o instanceof Array){a=[];for(var r=0,e=o.length;r<e;r++)a[r]=c({},o[r],t)}else if(o&&typeof o=="object")for(var s in o)s==="canvas"||s==="group"?a[s]=null:o.hasOwnProperty(s)&&(a[s]=c({},o[s],t));else a=o;else for(var s in o)a[s]=o[s];return a}function i(a,o){return c({},a,o)}u.util.object={extend:c,clone:i},u.util.object.extend(u.util,u.Observable)})();(function(){function c(r){return r.replace(/-+(.)?/g,function(e,s){return s?s.toUpperCase():""})}function i(r,e){return r.charAt(0).toUpperCase()+(e?r.slice(1):r.slice(1).toLowerCase())}function a(r){return r.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function o(r){var e=0,s,h=[];for(e=0,s;e<r.length;e++)(s=t(r,e))!==!1&&h.push(s);return h}function t(r,e){var s=r.charCodeAt(e);if(isNaN(s))return"";if(s<55296||s>57343)return r.charAt(e);if(55296<=s&&s<=56319){if(r.length<=e+1)throw"High surrogate without following low surrogate";var h=r.charCodeAt(e+1);if(56320>h||h>57343)throw"High surrogate without following low surrogate";return r.charAt(e)+r.charAt(e+1)}if(e===0)throw"Low surrogate without preceding high surrogate";var n=r.charCodeAt(e-1);if(55296>n||n>56319)throw"Low surrogate without preceding high surrogate";return!1}u.util.string={camelize:c,capitalize:i,escapeXml:a,graphemeSplit:o}})();(function(){var c=Array.prototype.slice,i=function(){},a=function(){for(var s in{toString:1})if(s==="toString")return!1;return!0}(),o=function(s,h,n){for(var l in h)l in s.prototype&&typeof s.prototype[l]=="function"&&(h[l]+"").indexOf("callSuper")>-1?s.prototype[l]=function(f){return function(){var d=this.constructor.superclass;this.constructor.superclass=n;var g=h[f].apply(this,arguments);if(this.constructor.superclass=d,f!=="initialize")return g}}(l):s.prototype[l]=h[l],a&&(h.toString!==Object.prototype.toString&&(s.prototype.toString=h.toString),h.valueOf!==Object.prototype.valueOf&&(s.prototype.valueOf=h.valueOf))};function t(){}function r(s){for(var h=null,n=this;n.constructor.superclass;){var l=n.constructor.superclass.prototype[s];if(n[s]!==l){h=l;break}n=n.constructor.superclass.prototype}return h?arguments.length>1?h.apply(this,c.call(arguments,1)):h.call(this):console.log("tried to callSuper "+s+", method not found in prototype chain",this)}function e(){var s=null,h=c.call(arguments,0);typeof h[0]=="function"&&(s=h.shift());function n(){this.initialize.apply(this,arguments)}n.superclass=s,n.subclasses=[],s&&(t.prototype=s.prototype,n.prototype=new t,s.subclasses.push(n));for(var l=0,f=h.length;l<f;l++)o(n,h[l],s);return n.prototype.initialize||(n.prototype.initialize=i),n.prototype.constructor=n,n.prototype.callSuper=r,n}u.util.createClass=e})();(function(){var c=!!u.document.createElement("div").attachEvent,i=["touchstart","touchmove","touchend"];u.util.addListener=function(o,t,r,e){o&&o.addEventListener(t,r,c?!1:e)},u.util.removeListener=function(o,t,r,e){o&&o.removeEventListener(t,r,c?!1:e)};function a(o){var t=o.changedTouches;return t&&t[0]?t[0]:o}u.util.getPointer=function(o){var t=o.target,r=u.util.getScrollLeftTop(t),e=a(o);return{x:e.clientX+r.left,y:e.clientY+r.top}},u.util.isTouchEvent=function(o){return i.indexOf(o.type)>-1||o.pointerType==="touch"}})();(function(){function c(e,s){var h=e.style;if(!h)return e;if(typeof s=="string")return e.style.cssText+=";"+s,s.indexOf("opacity")>-1?r(e,s.match(/opacity:\s*(\d?\.?\d*)/)[1]):e;for(var n in s)if(n==="opacity")r(e,s[n]);else{var l=n==="float"||n==="cssFloat"?typeof h.styleFloat=="undefined"?"cssFloat":"styleFloat":n;h[l]=s[n]}return e}var i=u.document.createElement("div"),a=typeof i.style.opacity=="string",o=typeof i.style.filter=="string",t=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,r=function(e){return e};a?r=function(e,s){return e.style.opacity=s,e}:o&&(r=function(e,s){var h=e.style;return e.currentStyle&&!e.currentStyle.hasLayout&&(h.zoom=1),t.test(h.filter)?(s=s>=.9999?"":"alpha(opacity="+s*100+")",h.filter=h.filter.replace(t,s)):h.filter+=" alpha(opacity="+s*100+")",e}),u.util.setStyle=c})();(function(){var c=Array.prototype.slice;function i(g){return typeof g=="string"?u.document.getElementById(g):g}var a,o=function(g){return c.call(g,0)};try{a=o(u.document.childNodes)instanceof Array}catch(g){}a||(o=function(g){for(var m=new Array(g.length),p=g.length;p--;)m[p]=g[p];return m});function t(g,m){var p=u.document.createElement(g);for(var _ in m)_==="class"?p.className=m[_]:_==="for"?p.htmlFor=m[_]:p.setAttribute(_,m[_]);return p}function r(g,m){g&&(" "+g.className+" ").indexOf(" "+m+" ")===-1&&(g.className+=(g.className?" ":"")+m)}function e(g,m,p){return typeof m=="string"&&(m=t(m,p)),g.parentNode&&g.parentNode.replaceChild(m,g),m.appendChild(g),m}function s(g){for(var m=0,p=0,_=u.document.documentElement,w=u.document.body||{scrollLeft:0,scrollTop:0};g&&(g.parentNode||g.host)&&(g=g.parentNode||g.host,g===u.document?(m=w.scrollLeft||_.scrollLeft||0,p=w.scrollTop||_.scrollTop||0):(m+=g.scrollLeft||0,p+=g.scrollTop||0),!(g.nodeType===1&&g.style.position==="fixed")););return{left:m,top:p}}function h(g){var m,p=g&&g.ownerDocument,_={left:0,top:0},w={left:0,top:0},D,B={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!p)return w;for(var N in B)w[B[N]]+=parseInt(n(g,N),10)||0;return m=p.documentElement,typeof g.getBoundingClientRect!="undefined"&&(_=g.getBoundingClientRect()),D=s(g),{left:_.left+D.left-(m.clientLeft||0)+w.left,top:_.top+D.top-(m.clientTop||0)+w.top}}var n;u.document.defaultView&&u.document.defaultView.getComputedStyle?n=function(g,m){var p=u.document.defaultView.getComputedStyle(g,null);return p?p[m]:void 0}:n=function(g,m){var p=g.style[m];return!p&&g.currentStyle&&(p=g.currentStyle[m]),p},function(){var g=u.document.documentElement.style,m="userSelect"in g?"userSelect":"MozUserSelect"in g?"MozUserSelect":"WebkitUserSelect"in g?"WebkitUserSelect":"KhtmlUserSelect"in g?"KhtmlUserSelect":"";function p(w){return typeof w.onselectstart!="undefined"&&(w.onselectstart=u.util.falseFunction),m?w.style[m]="none":typeof w.unselectable=="string"&&(w.unselectable="on"),w}function _(w){return typeof w.onselectstart!="undefined"&&(w.onselectstart=null),m?w.style[m]="":typeof w.unselectable=="string"&&(w.unselectable=""),w}u.util.makeElementUnselectable=p,u.util.makeElementSelectable=_}();function l(g){var m=u.jsdomImplForWrapper(g);return m._canvas||m._image}function f(g){if(u.isLikelyNode){var m=u.jsdomImplForWrapper(g);m&&(m._image=null,m._canvas=null,m._currentSrc=null,m._attributes=null,m._classList=null)}}function d(g,m){g.imageSmoothingEnabled=g.imageSmoothingEnabled||g.webkitImageSmoothingEnabled||g.mozImageSmoothingEnabled||g.msImageSmoothingEnabled||g.oImageSmoothingEnabled,g.imageSmoothingEnabled=m}u.util.setImageSmoothing=d,u.util.getById=i,u.util.toArray=o,u.util.addClass=r,u.util.makeElement=t,u.util.wrapElement=e,u.util.getScrollLeftTop=s,u.util.getElementOffset=h,u.util.getNodeCanvas=l,u.util.cleanUpJsdomNode=f})();(function(){function c(o,t){return o+(/\?/.test(o)?"&":"?")+t}function i(){}function a(o,t){t||(t={});var r=t.method?t.method.toUpperCase():"GET",e=t.onComplete||function(){},s=new u.window.XMLHttpRequest,h=t.body||t.parameters;return s.onreadystatechange=function(){s.readyState===4&&(e(s),s.onreadystatechange=i)},r==="GET"&&(h=null,typeof t.parameters=="string"&&(o=c(o,t.parameters))),s.open(r,o,!0),(r==="POST"||r==="PUT")&&s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s.send(h),s}u.util.request=a})();u.log=console.log;u.warn=console.warn;(function(){var c=u.util.object.extend,i=u.util.object.clone,a=[];u.util.object.extend(a,{cancelAll:function(){var l=this.splice(0);return l.forEach(function(f){f.cancel()}),l},cancelByCanvas:function(l){if(!l)return[];var f=this.filter(function(d){return typeof d.target=="object"&&d.target.canvas===l});return f.forEach(function(d){d.cancel()}),f},cancelByTarget:function(l){var f=this.findAnimationsByTarget(l);return f.forEach(function(d){d.cancel()}),f},findAnimationIndex:function(l){return this.indexOf(this.findAnimation(l))},findAnimation:function(l){return this.find(function(f){return f.cancel===l})},findAnimationsByTarget:function(l){return l?this.filter(function(f){return f.target===l}):[]}});function o(){return!1}function t(l,f,d,g){return-d*Math.cos(l/g*(Math.PI/2))+d+f}function r(l){l||(l={});var f=!1,d,g=function(){var m=u.runningAnimations.indexOf(d);return m>-1&&u.runningAnimations.splice(m,1)[0]};return d=c(i(l),{cancel:function(){return f=!0,g()},currentValue:"startValue"in l?l.startValue:0,completionRate:0,durationRate:0}),u.runningAnimations.push(d),h(function(m){var p=m||+new Date,_=l.duration||500,w=p+_,D,B=l.onChange||o,N=l.abort||o,G=l.onComplete||o,z=l.easing||t,H="startValue"in l?l.startValue.length>0:!1,U="startValue"in l?l.startValue:0,K="endValue"in l?l.endValue:100,Q=l.byValue||(H?U.map(function(J,v){return K[v]-U[v]}):K-U);l.onStart&&l.onStart(),function J(v){D=v||+new Date;var b=D>w?_:D-p,S=b/_,C=H?U.map(function(x,y){return z(b,U[y],Q[y],_)}):z(b,U,Q,_),P=Math.abs(H?(C[0]-U[0])/Q[0]:(C-U)/Q);if(d.currentValue=H?C.slice():C,d.completionRate=P,d.durationRate=S,!f){if(N(C,P,S)){g();return}if(D>w){d.currentValue=H?K.slice():K,d.completionRate=1,d.durationRate=1,B(H?K.slice():K,1,1),G(K,1,1),g();return}else B(C,P,S),h(J)}}(p)}),d.cancel}var e=u.window.requestAnimationFrame||u.window.webkitRequestAnimationFrame||u.window.mozRequestAnimationFrame||u.window.oRequestAnimationFrame||u.window.msRequestAnimationFrame||function(l){return u.window.setTimeout(l,1e3/60)},s=u.window.cancelAnimationFrame||u.window.clearTimeout;function h(){return e.apply(u.window,arguments)}function n(){return s.apply(u.window,arguments)}u.util.animate=r,u.util.requestAnimFrame=h,u.util.cancelAnimFrame=n,u.runningAnimations=a})();(function(){function c(a,o,t){var r="rgba("+parseInt(a[0]+t*(o[0]-a[0]),10)+","+parseInt(a[1]+t*(o[1]-a[1]),10)+","+parseInt(a[2]+t*(o[2]-a[2]),10);return r+=","+(a&&o?parseFloat(a[3]+t*(o[3]-a[3])):1),r+=")",r}function i(a,o,t,r){var e=new u.Color(a).getSource(),s=new u.Color(o).getSource(),h=r.onComplete,n=r.onChange;return r=r||{},u.util.animate(u.util.object.extend(r,{duration:t||500,startValue:e,endValue:s,byValue:s,easing:function(l,f,d,g){var m=r.colorEasing?r.colorEasing(l,g):1-Math.cos(l/g*(Math.PI/2));return c(f,d,m)},onComplete:function(l,f,d){if(h)return h(c(s,s,0),f,d)},onChange:function(l,f,d){if(n){if(Array.isArray(l))return n(c(l,l,0),f,d);n(l,f,d)}}}))}u.util.animateColor=i})();(function(){function c(v,b,S,C){return v<Math.abs(b)?(v=b,C=S/4):b===0&&v===0?C=S/(2*Math.PI)*Math.asin(1):C=S/(2*Math.PI)*Math.asin(b/v),{a:v,c:b,p:S,s:C}}function i(v,b,S){return v.a*Math.pow(2,10*(b-=1))*Math.sin((b*S-v.s)*(2*Math.PI)/v.p)}function a(v,b,S,C){return S*((v=v/C-1)*v*v+1)+b}function o(v,b,S,C){return v/=C/2,v<1?S/2*v*v*v+b:S/2*((v-=2)*v*v+2)+b}function t(v,b,S,C){return S*(v/=C)*v*v*v+b}function r(v,b,S,C){return-S*((v=v/C-1)*v*v*v-1)+b}function e(v,b,S,C){return v/=C/2,v<1?S/2*v*v*v*v+b:-S/2*((v-=2)*v*v*v-2)+b}function s(v,b,S,C){return S*(v/=C)*v*v*v*v+b}function h(v,b,S,C){return S*((v=v/C-1)*v*v*v*v+1)+b}function n(v,b,S,C){return v/=C/2,v<1?S/2*v*v*v*v*v+b:S/2*((v-=2)*v*v*v*v+2)+b}function l(v,b,S,C){return-S*Math.cos(v/C*(Math.PI/2))+S+b}function f(v,b,S,C){return S*Math.sin(v/C*(Math.PI/2))+b}function d(v,b,S,C){return-S/2*(Math.cos(Math.PI*v/C)-1)+b}function g(v,b,S,C){return v===0?b:S*Math.pow(2,10*(v/C-1))+b}function m(v,b,S,C){return v===C?b+S:S*(-Math.pow(2,-10*v/C)+1)+b}function p(v,b,S,C){return v===0?b:v===C?b+S:(v/=C/2,v<1?S/2*Math.pow(2,10*(v-1))+b:S/2*(-Math.pow(2,-10*--v)+2)+b)}function _(v,b,S,C){return-S*(Math.sqrt(1-(v/=C)*v)-1)+b}function w(v,b,S,C){return S*Math.sqrt(1-(v=v/C-1)*v)+b}function D(v,b,S,C){return v/=C/2,v<1?-S/2*(Math.sqrt(1-v*v)-1)+b:S/2*(Math.sqrt(1-(v-=2)*v)+1)+b}function B(v,b,S,C){var P=1.70158,x=0,y=S;if(v===0)return b;if(v/=C,v===1)return b+S;x||(x=C*.3);var T=c(y,S,x,P);return-i(T,v,C)+b}function N(v,b,S,C){var P=1.70158,x=0,y=S;if(v===0)return b;if(v/=C,v===1)return b+S;x||(x=C*.3);var T=c(y,S,x,P);return T.a*Math.pow(2,-10*v)*Math.sin((v*C-T.s)*(2*Math.PI)/T.p)+T.c+b}function G(v,b,S,C){var P=1.70158,x=0,y=S;if(v===0)return b;if(v/=C/2,v===2)return b+S;x||(x=C*(.3*1.5));var T=c(y,S,x,P);return v<1?-.5*i(T,v,C)+b:T.a*Math.pow(2,-10*(v-=1))*Math.sin((v*C-T.s)*(2*Math.PI)/T.p)*.5+T.c+b}function z(v,b,S,C,P){return P===void 0&&(P=1.70158),S*(v/=C)*v*((P+1)*v-P)+b}function H(v,b,S,C,P){return P===void 0&&(P=1.70158),S*((v=v/C-1)*v*((P+1)*v+P)+1)+b}function U(v,b,S,C,P){return P===void 0&&(P=1.70158),v/=C/2,v<1?S/2*(v*v*(((P*=1.525)+1)*v-P))+b:S/2*((v-=2)*v*(((P*=1.525)+1)*v+P)+2)+b}function K(v,b,S,C){return S-Q(C-v,0,S,C)+b}function Q(v,b,S,C){return(v/=C)<1/2.75?S*(7.5625*v*v)+b:v<2/2.75?S*(7.5625*(v-=1.5/2.75)*v+.75)+b:v<2.5/2.75?S*(7.5625*(v-=2.25/2.75)*v+.9375)+b:S*(7.5625*(v-=2.625/2.75)*v+.984375)+b}function J(v,b,S,C){return v<C/2?K(v*2,0,S,C)*.5+b:Q(v*2-C,0,S,C)*.5+S*.5+b}u.util.ease={easeInQuad:function(v,b,S,C){return S*(v/=C)*v+b},easeOutQuad:function(v,b,S,C){return-S*(v/=C)*(v-2)+b},easeInOutQuad:function(v,b,S,C){return v/=C/2,v<1?S/2*v*v+b:-S/2*(--v*(v-2)-1)+b},easeInCubic:function(v,b,S,C){return S*(v/=C)*v*v+b},easeOutCubic:a,easeInOutCubic:o,easeInQuart:t,easeOutQuart:r,easeInOutQuart:e,easeInQuint:s,easeOutQuint:h,easeInOutQuint:n,easeInSine:l,easeOutSine:f,easeInOutSine:d,easeInExpo:g,easeOutExpo:m,easeInOutExpo:p,easeInCirc:_,easeOutCirc:w,easeInOutCirc:D,easeInElastic:B,easeOutElastic:N,easeInOutElastic:G,easeInBack:z,easeOutBack:H,easeInOutBack:U,easeInBounce:K,easeOutBounce:Q,easeInOutBounce:J}})();(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.util.object.extend,o=i.util.object.clone,t=i.util.toFixed,r=i.util.parseUnit,e=i.util.multiplyTransformMatrices,s=["path","circle","polygon","polyline","ellipse","rect","line","image","text"],h=["symbol","image","marker","pattern","view","svg"],n=["pattern","defs","symbol","metadata","clipPath","mask","desc"],l=["symbol","g","a","svg","clipPath","defs"],f={cx:"left",x:"left",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"},d={stroke:"strokeOpacity",fill:"fillOpacity"},g="font-size",m="clip-path";i.svgValidTagNamesRegEx=w(s),i.svgViewBoxElementsRegEx=w(h),i.svgInvalidAncestorsRegEx=w(n),i.svgValidParentsRegEx=w(l),i.cssRules={},i.gradientDefs={},i.clipPaths={};function p(x){return x in f?f[x]:x}function _(x,y,T,E){var L=Object.prototype.toString.call(y)==="[object Array]",k;if((x==="fill"||x==="stroke")&&y==="none")y="";else{if(x==="strokeUniform")return y==="non-scaling-stroke";if(x==="strokeDashArray")y==="none"?y=null:y=y.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(x==="transformMatrix")T&&T.transformMatrix?y=e(T.transformMatrix,i.parseTransformAttribute(y)):y=i.parseTransformAttribute(y);else if(x==="visible")y=y!=="none"&&y!=="hidden",T&&T.visible===!1&&(y=!1);else if(x==="opacity")y=parseFloat(y),T&&typeof T.opacity!="undefined"&&(y*=T.opacity);else if(x==="textAnchor")y=y==="start"?"left":y==="end"?"right":"center";else if(x==="charSpacing")k=r(y,E)/E*1e3;else if(x==="paintFirst"){var W=y.indexOf("fill"),Y=y.indexOf("stroke"),y="fill";(W>-1&&Y>-1&&Y<W||W===-1&&Y>-1)&&(y="stroke")}else{if(x==="href"||x==="xlink:href"||x==="font")return y;if(x==="imageSmoothing")return y==="optimizeQuality";k=L?y.map(r):r(y,E)}}return!L&&isNaN(k)?y:k}function w(x){return new RegExp("^("+x.join("|")+")\\b","i")}function D(x){for(var y in d)if(!(typeof x[d[y]]=="undefined"||x[y]==="")){if(typeof x[y]=="undefined"){if(!i.Object.prototype[y])continue;x[y]=i.Object.prototype[y]}if(x[y].indexOf("url(")!==0){var T=new i.Color(x[y]);x[y]=T.setAlpha(t(T.getAlpha()*x[d[y]],2)).toRgba()}}return x}function B(x,y){var T,E=[],L,k,W;for(k=0,W=y.length;k<W;k++)T=y[k],L=x.getElementsByTagName(T),E=E.concat(Array.prototype.slice.call(L));return E}i.parseTransformAttribute=function(){function x(I,$){var et=i.util.cos($[0]),it=i.util.sin($[0]),nt=0,rt=0;$.length===3&&(nt=$[1],rt=$[2]),I[0]=et,I[1]=it,I[2]=-it,I[3]=et,I[4]=nt-(et*nt-it*rt),I[5]=rt-(it*nt+et*rt)}function y(I,$){var et=$[0],it=$.length===2?$[1]:$[0];I[0]=et,I[3]=it}function T(I,$,et){I[et]=Math.tan(i.util.degreesToRadians($[0]))}function E(I,$){I[4]=$[0],$.length===2&&(I[5]=$[1])}var L=i.iMatrix,k=i.reNum,W=i.commaWsp,Y="(?:(skewX)\\s*\\(\\s*("+k+")\\s*\\))",V="(?:(skewY)\\s*\\(\\s*("+k+")\\s*\\))",M="(?:(rotate)\\s*\\(\\s*("+k+")(?:"+W+"("+k+")"+W+"("+k+"))?\\s*\\))",O="(?:(scale)\\s*\\(\\s*("+k+")(?:"+W+"("+k+"))?\\s*\\))",j="(?:(translate)\\s*\\(\\s*("+k+")(?:"+W+"("+k+"))?\\s*\\))",R="(?:(matrix)\\s*\\(\\s*("+k+")"+W+"("+k+")"+W+"("+k+")"+W+"("+k+")"+W+"("+k+")"+W+"("+k+")\\s*\\))",A="(?:"+R+"|"+j+"|"+O+"|"+M+"|"+Y+"|"+V+")",X="(?:"+A+"(?:"+W+"*"+A+")*)",q="^\\s*(?:"+X+"?)\\s*$",tt=new RegExp(q),Z=new RegExp(A,"g");return function(I){var $=L.concat(),et=[];if(!I||I&&!tt.test(I))return $;I.replace(Z,function(nt){var rt=new RegExp(A).exec(nt).filter(function(ct){return!!ct}),ot=rt[1],st=rt.slice(2).map(parseFloat);switch(ot){case"translate":E($,st);break;case"rotate":st[0]=i.util.degreesToRadians(st[0]),x($,st);break;case"scale":y($,st);break;case"skewX":T($,st,2);break;case"skewY":T($,st,1);break;case"matrix":$=st;break}et.push($.concat()),$=L.concat()});for(var it=et[0];et.length>1;)et.shift(),it=i.util.multiplyTransformMatrices(it,et[0]);return it}}();function N(x,y){var T,E;x.replace(/;\s*$/,"").split(";").forEach(function(L){var k=L.split(":");T=k[0].trim().toLowerCase(),E=k[1].trim(),y[T]=E})}function G(x,y){var T,E;for(var L in x)typeof x[L]!="undefined"&&(T=L.toLowerCase(),E=x[L],y[T]=E)}function z(x,y){var T={};for(var E in i.cssRules[y])if(H(x,E.split(" ")))for(var L in i.cssRules[y][E])T[L]=i.cssRules[y][E][L];return T}function H(x,y){var T,E=!0;return T=K(x,y.pop()),T&&y.length&&(E=U(x,y)),T&&E&&y.length===0}function U(x,y){for(var T,E=!0;x.parentNode&&x.parentNode.nodeType===1&&y.length;)E&&(T=y.pop()),x=x.parentNode,E=K(x,T);return y.length===0}function K(x,y){var T=x.nodeName,E=x.getAttribute("class"),L=x.getAttribute("id"),k,W;if(k=new RegExp("^"+T,"i"),y=y.replace(k,""),L&&y.length&&(k=new RegExp("#"+L+"(?![a-zA-Z\\-]+)","i"),y=y.replace(k,"")),E&&y.length)for(E=E.split(" "),W=E.length;W--;)k=new RegExp("\\."+E[W]+"(?![a-zA-Z\\-]+)","i"),y=y.replace(k,"");return y.length===0}function Q(x,y){var T;if(x.getElementById&&(T=x.getElementById(y)),T)return T;var E,L,k,W=x.getElementsByTagName("*");for(L=0,k=W.length;L<k;L++)if(E=W[L],y===E.getAttribute("id"))return E}function J(x){for(var y=B(x,["use","svg:use"]),T=0;y.length&&T<y.length;){var E=y[T],L=E.getAttribute("xlink:href")||E.getAttribute("href");if(L===null)return;var k=L.substr(1),W=E.getAttribute("x")||0,Y=E.getAttribute("y")||0,V=Q(x,k).cloneNode(!0),M=(V.getAttribute("transform")||"")+" translate("+W+", "+Y+")",O,j=y.length,R,A,X,q,tt=i.svgNS;if(b(V),/^svg$/i.test(V.nodeName)){var Z=V.ownerDocument.createElementNS(tt,"g");for(A=0,X=V.attributes,q=X.length;A<q;A++)R=X.item(A),Z.setAttributeNS(tt,R.nodeName,R.nodeValue);for(;V.firstChild;)Z.appendChild(V.firstChild);V=Z}for(A=0,X=E.attributes,q=X.length;A<q;A++)R=X.item(A),!(R.nodeName==="x"||R.nodeName==="y"||R.nodeName==="xlink:href"||R.nodeName==="href")&&(R.nodeName==="transform"?M=R.nodeValue+" "+M:V.setAttribute(R.nodeName,R.nodeValue));V.setAttribute("transform",M),V.setAttribute("instantiated_by_use","1"),V.removeAttribute("id"),O=E.parentNode,O.replaceChild(V,E),y.length===j&&T++}}var v=new RegExp("^\\s*("+i.reNum+"+)\\s*,?\\s*("+i.reNum+"+)\\s*,?\\s*("+i.reNum+"+)\\s*,?\\s*("+i.reNum+"+)\\s*$");function b(x){if(!i.svgViewBoxElementsRegEx.test(x.nodeName))return{};var y=x.getAttribute("viewBox"),T=1,E=1,L=0,k=0,W,Y,V,M,O=x.getAttribute("width"),j=x.getAttribute("height"),R=x.getAttribute("x")||0,A=x.getAttribute("y")||0,X=x.getAttribute("preserveAspectRatio")||"",q=!y||!(y=y.match(v)),tt=!O||!j||O==="100%"||j==="100%",Z=q&&tt,I={},$="",et=0,it=0;if(I.width=0,I.height=0,I.toBeParsed=Z,q&&(R||A)&&x.parentNode&&x.parentNode.nodeName!=="#document"&&($=" translate("+r(R)+" "+r(A)+") ",V=(x.getAttribute("transform")||"")+$,x.setAttribute("transform",V),x.removeAttribute("x"),x.removeAttribute("y")),Z)return I;if(q)return I.width=r(O),I.height=r(j),I;if(L=-parseFloat(y[1]),k=-parseFloat(y[2]),W=parseFloat(y[3]),Y=parseFloat(y[4]),I.minX=L,I.minY=k,I.viewBoxWidth=W,I.viewBoxHeight=Y,tt?(I.width=W,I.height=Y):(I.width=r(O),I.height=r(j),T=I.width/W,E=I.height/Y),X=i.util.parsePreserveAspectRatioAttribute(X),X.alignX!=="none"&&(X.meetOrSlice==="meet"&&(E=T=T>E?E:T),X.meetOrSlice==="slice"&&(E=T=T>E?T:E),et=I.width-W*T,it=I.height-Y*T,X.alignX==="Mid"&&(et/=2),X.alignY==="Mid"&&(it/=2),X.alignX==="Min"&&(et=0),X.alignY==="Min"&&(it=0)),T===1&&E===1&&L===0&&k===0&&R===0&&A===0)return I;if((R||A)&&x.parentNode.nodeName!=="#document"&&($=" translate("+r(R)+" "+r(A)+") "),V=$+" matrix("+T+" 0 0 "+E+" "+(L*T+et)+" "+(k*E+it)+") ",x.nodeName==="svg"){for(M=x.ownerDocument.createElementNS(i.svgNS,"g");x.firstChild;)M.appendChild(x.firstChild);x.appendChild(M)}else M=x,M.removeAttribute("x"),M.removeAttribute("y"),V=M.getAttribute("transform")+V;return M.setAttribute("transform",V),I}function S(x,y){for(;x&&(x=x.parentNode);)if(x.nodeName&&y.test(x.nodeName.replace("svg:",""))&&!x.getAttribute("instantiated_by_use"))return!0;return!1}i.parseSVGDocument=function(x,y,T,E){if(x){J(x);var L=i.Object.__uid++,k,W,Y=b(x),V=i.util.toArray(x.getElementsByTagName("*"));if(Y.crossOrigin=E&&E.crossOrigin,Y.svgUid=L,V.length===0&&i.isLikelyNode){V=x.selectNodes('//*[name(.)!="svg"]');var M=[];for(k=0,W=V.length;k<W;k++)M[k]=V[k];V=M}var O=V.filter(function(R){return b(R),i.svgValidTagNamesRegEx.test(R.nodeName.replace("svg:",""))&&!S(R,i.svgInvalidAncestorsRegEx)});if(!O||O&&!O.length){y&&y([],{});return}var j={};V.filter(function(R){return R.nodeName.replace("svg:","")==="clipPath"}).forEach(function(R){var A=R.getAttribute("id");j[A]=i.util.toArray(R.getElementsByTagName("*")).filter(function(X){return i.svgValidTagNamesRegEx.test(X.nodeName.replace("svg:",""))})}),i.gradientDefs[L]=i.getGradientDefs(x),i.cssRules[L]=i.getCSSRules(x),i.clipPaths[L]=j,i.parseElements(O,function(R,A){y&&(y(R,Y,A,V),delete i.gradientDefs[L],delete i.cssRules[L],delete i.clipPaths[L])},o(Y),T,E)}};function C(x,y){var T=["gradientTransform","x1","x2","y1","y2","gradientUnits","cx","cy","r","fx","fy"],E="xlink:href",L=y.getAttribute(E).substr(1),k=Q(x,L);if(k&&k.getAttribute(E)&&C(x,k),T.forEach(function(Y){k&&!y.hasAttribute(Y)&&k.hasAttribute(Y)&&y.setAttribute(Y,k.getAttribute(Y))}),!y.children.length)for(var W=k.cloneNode(!0);W.firstChild;)y.appendChild(W.firstChild);y.removeAttribute(E)}var P=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+i.reNum+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+i.reNum+"))?\\s+(.*)");a(i,{parseFontDeclaration:function(x,y){var T=x.match(P);if(T){var E=T[1],L=T[3],k=T[4],W=T[5],Y=T[6];E&&(y.fontStyle=E),L&&(y.fontWeight=isNaN(parseFloat(L))?L:parseFloat(L)),k&&(y.fontSize=r(k)),Y&&(y.fontFamily=Y),W&&(y.lineHeight=W==="normal"?1:W)}},getGradientDefs:function(x){var y=["linearGradient","radialGradient","svg:linearGradient","svg:radialGradient"],T=B(x,y),E,L=0,k={};for(L=T.length;L--;)E=T[L],E.getAttribute("xlink:href")&&C(x,E),k[E.getAttribute("id")]=E;return k},parseAttributes:function(x,y,T){if(x){var E,L={},k,W;typeof T=="undefined"&&(T=x.getAttribute("svgUid")),x.parentNode&&i.svgValidParentsRegEx.test(x.parentNode.nodeName)&&(L=i.parseAttributes(x.parentNode,y,T));var Y=y.reduce(function(X,q){return E=x.getAttribute(q),E&&(X[q]=E),X},{}),V=a(z(x,T),i.parseStyleAttribute(x));Y=a(Y,V),V[m]&&x.setAttribute(m,V[m]),k=W=L.fontSize||i.Text.DEFAULT_SVG_FONT_SIZE,Y[g]&&(Y[g]=k=r(Y[g],W));var M,O,j={};for(var R in Y)M=p(R),O=_(M,Y[R],L,k),j[M]=O;j&&j.font&&i.parseFontDeclaration(j.font,j);var A=a(L,j);return i.svgValidParentsRegEx.test(x.nodeName)?A:D(A)}},parseElements:function(x,y,T,E,L){new i.ElementsParser(x,y,T,E,L).parse()},parseStyleAttribute:function(x){var y={},T=x.getAttribute("style");return T&&(typeof T=="string"?N(T,y):G(T,y)),y},parsePointsAttribute:function(x){if(!x)return null;x=x.replace(/,/g," ").trim(),x=x.split(/\s+/);var y=[],T,E;for(T=0,E=x.length;T<E;T+=2)y.push({x:parseFloat(x[T]),y:parseFloat(x[T+1])});return y},getCSSRules:function(x){var y=x.getElementsByTagName("style"),T,E,L={},k;for(T=0,E=y.length;T<E;T++){var W=y[T].textContent;W=W.replace(/\/\*[\s\S]*?\*\//g,""),W.trim()!==""&&(k=W.split("}"),k=k.filter(function(Y){return Y.trim()}),k.forEach(function(Y){var V=Y.split("{"),M={},O=V[1].trim(),j=O.split(";").filter(function(q){return q.trim()});for(T=0,E=j.length;T<E;T++){var R=j[T].split(":"),A=R[0].trim(),X=R[1].trim();M[A]=X}Y=V[0].trim(),Y.split(",").forEach(function(q){q=q.replace(/^svg/i,"").trim(),q!==""&&(L[q]?i.util.object.extend(L[q],M):L[q]=i.util.object.clone(M))})}))}return L},loadSVGFromURL:function(x,y,T,E){x=x.replace(/^\n\s*/,"").trim(),new i.util.request(x,{method:"get",onComplete:L});function L(k){var W=k.responseXML;if(!W||!W.documentElement)return y&&y(null),!1;i.parseSVGDocument(W.documentElement,function(Y,V,M,O){y&&y(Y,V,M,O)},T,E)}},loadSVGFromString:function(x,y,T,E){var L=new i.window.DOMParser,k=L.parseFromString(x.trim(),"text/xml");i.parseSVGDocument(k.documentElement,function(W,Y,V,M){y(W,Y,V,M)},T,E)}})})(F);u.ElementsParser=function(c,i,a,o,t,r){this.elements=c,this.callback=i,this.options=a,this.reviver=o,this.svgUid=a&&a.svgUid||0,this.parsingOptions=t,this.regexUrl=/^url\(['"]?#([^'"]+)['"]?\)/g,this.doc=r};(function(c){c.parse=function(){this.instances=new Array(this.elements.length),this.numElements=this.elements.length,this.createObjects()},c.createObjects=function(){var i=this;this.elements.forEach(function(a,o){a.setAttribute("svgUid",i.svgUid),i.createObject(a,o)})},c.findTag=function(i){return u[u.util.string.capitalize(i.tagName.replace("svg:",""))]},c.createObject=function(i,a){var o=this.findTag(i);if(o&&o.fromElement)try{o.fromElement(i,this.createCallback(a,i),this.options)}catch(t){u.log(t)}else this.checkIfDone()},c.createCallback=function(i,a){var o=this;return function(t){var r;o.resolveGradient(t,a,"fill"),o.resolveGradient(t,a,"stroke"),t instanceof u.Image&&t._originalElement&&(r=t.parsePreserveAspectRatioAttribute(a)),t._removeTransformMatrix(r),o.resolveClipPath(t,a),o.reviver&&o.reviver(a,t),o.instances[i]=t,o.checkIfDone()}},c.extractPropertyDefinition=function(i,a,o){var t=i[a],r=this.regexUrl;if(r.test(t)){r.lastIndex=0;var e=r.exec(t)[1];return r.lastIndex=0,u[o][this.svgUid][e]}},c.resolveGradient=function(i,a,o){var t=this.extractPropertyDefinition(i,o,"gradientDefs");if(t){var r=a.getAttribute(o+"-opacity"),e=u.Gradient.fromElement(t,i,r,this.options);i.set(o,e)}},c.createClipPathCallback=function(i,a){return function(o){o._removeTransformMatrix(),o.fillRule=o.clipRule,a.push(o)}},c.resolveClipPath=function(i,a){var o=this.extractPropertyDefinition(i,"clipPath","clipPaths"),t,r,e,s,h,n;if(o){s=[],e=u.util.invertTransform(i.calcTransformMatrix());for(var l=o[0].parentNode,f=a;f.parentNode&&f.getAttribute("clip-path")!==i.clipPath;)f=f.parentNode;f.parentNode.appendChild(l);for(var d=0;d<o.length;d++)t=o[d],r=this.findTag(t),r.fromElement(t,this.createClipPathCallback(i,s),this.options);s.length===1?o=s[0]:o=new u.Group(s),h=u.util.multiplyTransformMatrices(e,o.calcTransformMatrix()),o.clipPath&&this.resolveClipPath(o,f);var n=u.util.qrDecompose(h);o.flipX=!1,o.flipY=!1,o.set("scaleX",n.scaleX),o.set("scaleY",n.scaleY),o.angle=n.angle,o.skewX=n.skewX,o.skewY=0,o.setPositionByOrigin({x:n.translateX,y:n.translateY},"center","center"),i.clipPath=o}else delete i.clipPath},c.checkIfDone=function(){--this.numElements===0&&(this.instances=this.instances.filter(function(i){return i!=null}),this.callback(this.instances,this.elements))}})(u.ElementsParser.prototype);(function(c){"use strict";var i=c.fabric||(c.fabric={});if(i.Point){i.warn("fabric.Point is already defined");return}i.Point=a;function a(o,t){this.x=o,this.y=t}a.prototype={type:"point",constructor:a,add:function(o){return new a(this.x+o.x,this.y+o.y)},addEquals:function(o){return this.x+=o.x,this.y+=o.y,this},scalarAdd:function(o){return new a(this.x+o,this.y+o)},scalarAddEquals:function(o){return this.x+=o,this.y+=o,this},subtract:function(o){return new a(this.x-o.x,this.y-o.y)},subtractEquals:function(o){return this.x-=o.x,this.y-=o.y,this},scalarSubtract:function(o){return new a(this.x-o,this.y-o)},scalarSubtractEquals:function(o){return this.x-=o,this.y-=o,this},multiply:function(o){return new a(this.x*o,this.y*o)},multiplyEquals:function(o){return this.x*=o,this.y*=o,this},divide:function(o){return new a(this.x/o,this.y/o)},divideEquals:function(o){return this.x/=o,this.y/=o,this},eq:function(o){return this.x===o.x&&this.y===o.y},lt:function(o){return this.x<o.x&&this.y<o.y},lte:function(o){return this.x<=o.x&&this.y<=o.y},gt:function(o){return this.x>o.x&&this.y>o.y},gte:function(o){return this.x>=o.x&&this.y>=o.y},lerp:function(o,t){return typeof t=="undefined"&&(t=.5),t=Math.max(Math.min(1,t),0),new a(this.x+(o.x-this.x)*t,this.y+(o.y-this.y)*t)},distanceFrom:function(o){var t=this.x-o.x,r=this.y-o.y;return Math.sqrt(t*t+r*r)},midPointFrom:function(o){return this.lerp(o)},min:function(o){return new a(Math.min(this.x,o.x),Math.min(this.y,o.y))},max:function(o){return new a(Math.max(this.x,o.x),Math.max(this.y,o.y))},toString:function(){return this.x+","+this.y},setXY:function(o,t){return this.x=o,this.y=t,this},setX:function(o){return this.x=o,this},setY:function(o){return this.y=o,this},setFromPoint:function(o){return this.x=o.x,this.y=o.y,this},swap:function(o){var t=this.x,r=this.y;this.x=o.x,this.y=o.y,o.x=t,o.y=r},clone:function(){return new a(this.x,this.y)}}})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={});if(i.Intersection){i.warn("fabric.Intersection is already defined");return}function a(o){this.status=o,this.points=[]}i.Intersection=a,i.Intersection.prototype={constructor:a,appendPoint:function(o){return this.points.push(o),this},appendPoints:function(o){return this.points=this.points.concat(o),this}},i.Intersection.intersectLineLine=function(o,t,r,e){var s,h=(e.x-r.x)*(o.y-r.y)-(e.y-r.y)*(o.x-r.x),n=(t.x-o.x)*(o.y-r.y)-(t.y-o.y)*(o.x-r.x),l=(e.y-r.y)*(t.x-o.x)-(e.x-r.x)*(t.y-o.y);if(l!==0){var f=h/l,d=n/l;0<=f&&f<=1&&0<=d&&d<=1?(s=new a("Intersection"),s.appendPoint(new i.Point(o.x+f*(t.x-o.x),o.y+f*(t.y-o.y)))):s=new a}else h===0||n===0?s=new a("Coincident"):s=new a("Parallel");return s},i.Intersection.intersectLinePolygon=function(o,t,r){var e=new a,s=r.length,h,n,l,f;for(f=0;f<s;f++)h=r[f],n=r[(f+1)%s],l=a.intersectLineLine(o,t,h,n),e.appendPoints(l.points);return e.points.length>0&&(e.status="Intersection"),e},i.Intersection.intersectPolygonPolygon=function(o,t){var r=new a,e=o.length,s;for(s=0;s<e;s++){var h=o[s],n=o[(s+1)%e],l=a.intersectLinePolygon(h,n,t);r.appendPoints(l.points)}return r.points.length>0&&(r.status="Intersection"),r},i.Intersection.intersectPolygonRectangle=function(o,t,r){var e=t.min(r),s=t.max(r),h=new i.Point(s.x,e.y),n=new i.Point(e.x,s.y),l=a.intersectLinePolygon(e,h,o),f=a.intersectLinePolygon(h,s,o),d=a.intersectLinePolygon(s,n,o),g=a.intersectLinePolygon(n,e,o),m=new a;return m.appendPoints(l.points),m.appendPoints(f.points),m.appendPoints(d.points),m.appendPoints(g.points),m.points.length>0&&(m.status="Intersection"),m}})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={});if(i.Color){i.warn("fabric.Color is already defined.");return}function a(t){t?this._tryParsingColor(t):this.setSource([0,0,0,1])}i.Color=a,i.Color.prototype={_tryParsingColor:function(t){var r;t in a.colorNameMap&&(t=a.colorNameMap[t]),t==="transparent"&&(r=[255,255,255,0]),r||(r=a.sourceFromHex(t)),r||(r=a.sourceFromRgb(t)),r||(r=a.sourceFromHsl(t)),r||(r=[0,0,0,1]),r&&this.setSource(r)},_rgbToHsl:function(t,r,e){t/=255,r/=255,e/=255;var s,h,n,l=i.util.array.max([t,r,e]),f=i.util.array.min([t,r,e]);if(n=(l+f)/2,l===f)s=h=0;else{var d=l-f;switch(h=n>.5?d/(2-l-f):d/(l+f),l){case t:s=(r-e)/d+(r<e?6:0);break;case r:s=(e-t)/d+2;break;case e:s=(t-r)/d+4;break}s/=6}return[Math.round(s*360),Math.round(h*100),Math.round(n*100)]},getSource:function(){return this._source},setSource:function(t){this._source=t},toRgb:function(){var t=this.getSource();return"rgb("+t[0]+","+t[1]+","+t[2]+")"},toRgba:function(){var t=this.getSource();return"rgba("+t[0]+","+t[1]+","+t[2]+","+t[3]+")"},toHsl:function(){var t=this.getSource(),r=this._rgbToHsl(t[0],t[1],t[2]);return"hsl("+r[0]+","+r[1]+"%,"+r[2]+"%)"},toHsla:function(){var t=this.getSource(),r=this._rgbToHsl(t[0],t[1],t[2]);return"hsla("+r[0]+","+r[1]+"%,"+r[2]+"%,"+t[3]+")"},toHex:function(){var t=this.getSource(),r,e,s;return r=t[0].toString(16),r=r.length===1?"0"+r:r,e=t[1].toString(16),e=e.length===1?"0"+e:e,s=t[2].toString(16),s=s.length===1?"0"+s:s,r.toUpperCase()+e.toUpperCase()+s.toUpperCase()},toHexa:function(){var t=this.getSource(),r;return r=Math.round(t[3]*255),r=r.toString(16),r=r.length===1?"0"+r:r,this.toHex()+r.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(t){var r=this.getSource();return r[3]=t,this.setSource(r),this},toGrayscale:function(){var t=this.getSource(),r=parseInt((t[0]*.3+t[1]*.59+t[2]*.11).toFixed(0),10),e=t[3];return this.setSource([r,r,r,e]),this},toBlackWhite:function(t){var r=this.getSource(),e=(r[0]*.3+r[1]*.59+r[2]*.11).toFixed(0),s=r[3];return t=t||127,e=Number(e)<Number(t)?0:255,this.setSource([e,e,e,s]),this},overlayWith:function(t){t instanceof a||(t=new a(t));var r=[],e=this.getAlpha(),s=.5,h=this.getSource(),n=t.getSource(),l;for(l=0;l<3;l++)r.push(Math.round(h[l]*(1-s)+n[l]*s));return r[3]=e,this.setSource(r),this}},i.Color.reRGBa=/^rgba?\(\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*(?:\s*,\s*((?:\d*\.?\d+)?)\s*)?\)$/i,i.Color.reHSLa=/^hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3}\%)\s*,\s*(\d{1,3}\%)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/i,i.Color.reHex=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,i.Color.colorNameMap={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",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:"#FF00FF",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:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",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:"#663399",red:"#FF0000",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:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"};function o(t,r,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?t+(r-t)*6*e:e<1/2?r:e<2/3?t+(r-t)*(2/3-e)*6:t}i.Color.fromRgb=function(t){return a.fromSource(a.sourceFromRgb(t))},i.Color.sourceFromRgb=function(t){var r=t.match(a.reRGBa);if(r){var e=parseInt(r[1],10)/(/%$/.test(r[1])?100:1)*(/%$/.test(r[1])?255:1),s=parseInt(r[2],10)/(/%$/.test(r[2])?100:1)*(/%$/.test(r[2])?255:1),h=parseInt(r[3],10)/(/%$/.test(r[3])?100:1)*(/%$/.test(r[3])?255:1);return[parseInt(e,10),parseInt(s,10),parseInt(h,10),r[4]?parseFloat(r[4]):1]}},i.Color.fromRgba=a.fromRgb,i.Color.fromHsl=function(t){return a.fromSource(a.sourceFromHsl(t))},i.Color.sourceFromHsl=function(t){var r=t.match(a.reHSLa);if(r){var e=(parseFloat(r[1])%360+360)%360/360,s=parseFloat(r[2])/(/%$/.test(r[2])?100:1),h=parseFloat(r[3])/(/%$/.test(r[3])?100:1),n,l,f;if(s===0)n=l=f=h;else{var d=h<=.5?h*(s+1):h+s-h*s,g=h*2-d;n=o(g,d,e+1/3),l=o(g,d,e),f=o(g,d,e-1/3)}return[Math.round(n*255),Math.round(l*255),Math.round(f*255),r[4]?parseFloat(r[4]):1]}},i.Color.fromHsla=a.fromHsl,i.Color.fromHex=function(t){return a.fromSource(a.sourceFromHex(t))},i.Color.sourceFromHex=function(t){if(t.match(a.reHex)){var r=t.slice(t.indexOf("#")+1),e=r.length===3||r.length===4,s=r.length===8||r.length===4,h=e?r.charAt(0)+r.charAt(0):r.substring(0,2),n=e?r.charAt(1)+r.charAt(1):r.substring(2,4),l=e?r.charAt(2)+r.charAt(2):r.substring(4,6),f=s?e?r.charAt(3)+r.charAt(3):r.substring(6,8):"FF";return[parseInt(h,16),parseInt(n,16),parseInt(l,16),parseFloat((parseInt(f,16)/255).toFixed(2))]}},i.Color.fromSource=function(t){var r=new a;return r.setSource(t),r}})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=["e","se","s","sw","w","nw","n","ne","e"],o=["ns","nesw","ew","nwse"],t={},r="left",e="top",s="right",h="bottom",n="center",l={top:h,bottom:e,left:s,right:r,center:n},f=i.util.radiansToDegrees,d=Math.sign||function(M){return(M>0)-(M<0)||+M};function g(M,O){var j=M.angle+f(Math.atan2(O.y,O.x))+360;return Math.round(j%360/45)}function m(M,O){var j=O.transform.target,R=j.canvas,A=i.util.object.clone(O);A.target=j,R&&R.fire("object:"+M,A),j.fire(M,O)}function p(M,O){var j=O.canvas,R=j.uniScaleKey,A=M[R];return j.uniformScaling&&!A||!j.uniformScaling&&A}function _(M){return M.originX===n&&M.originY===n}function w(M,O,j){var R=M.lockScalingX,A=M.lockScalingY;return!!(R&&A||!O&&(R||A)&&j||R&&O==="x"||A&&O==="y")}function D(M,O,j){var R="not-allowed",A=p(M,j),X="";if(O.x!==0&&O.y===0?X="x":O.x===0&&O.y!==0&&(X="y"),w(j,X,A))return R;var q=g(j,O);return a[q]+"-resize"}function B(M,O,j){var R="not-allowed";if(O.x!==0&&j.lockSkewingY||O.y!==0&&j.lockSkewingX)return R;var A=g(j,O)%4;return o[A]+"-resize"}function N(M,O,j){return M[j.canvas.altActionKey]?t.skewCursorStyleHandler(M,O,j):t.scaleCursorStyleHandler(M,O,j)}function G(M,O,j){var R=M[j.canvas.altActionKey];if(O.x===0)return R?"skewX":"scaleY";if(O.y===0)return R?"skewY":"scaleX"}function z(M,O,j){return j.lockRotation?"not-allowed":O.cursorStyle}function H(M,O,j,R){return{e:M,transform:O,pointer:{x:j,y:R}}}function U(M){return function(O,j,R,A){var X=j.target,q=X.getCenterPoint(),tt=X.translateToOriginPoint(q,j.originX,j.originY),Z=M(O,j,R,A);return X.setPositionByOrigin(tt,j.originX,j.originY),Z}}function K(M,O){return function(j,R,A,X){var q=O(j,R,A,X);return q&&m(M,H(j,R,A,X)),q}}function Q(M,O,j,R,A){var X=M.target,q=X.controls[M.corner],tt=X.canvas.getZoom(),Z=X.padding/tt,I=X.toLocalPoint(new i.Point(R,A),O,j);return I.x>=Z&&(I.x-=Z),I.x<=-Z&&(I.x+=Z),I.y>=Z&&(I.y-=Z),I.y<=Z&&(I.y+=Z),I.x-=q.offsetX,I.y-=q.offsetY,I}function J(M){return M.flipX!==M.flipY}function v(M,O,j,R,A){if(M[O]!==0){var X=M._getTransformedDimensions()[R],q=A/X*M[j];M.set(j,q)}}function b(M,O,j,R){var A=O.target,X=A._getTransformedDimensions(0,A.skewY),q=Q(O,O.originX,O.originY,j,R),tt=Math.abs(q.x*2)-X.x,Z=A.skewX,I;tt<2?I=0:(I=f(Math.atan2(tt/A.scaleX,X.y/A.scaleY)),O.originX===r&&O.originY===h&&(I=-I),O.originX===s&&O.originY===e&&(I=-I),J(A)&&(I=-I));var $=Z!==I;if($){var et=A._getTransformedDimensions().y;A.set("skewX",I),v(A,"skewY","scaleY","y",et)}return $}function S(M,O,j,R){var A=O.target,X=A._getTransformedDimensions(A.skewX,0),q=Q(O,O.originX,O.originY,j,R),tt=Math.abs(q.y*2)-X.y,Z=A.skewY,I;tt<2?I=0:(I=f(Math.atan2(tt/A.scaleY,X.x/A.scaleX)),O.originX===r&&O.originY===h&&(I=-I),O.originX===s&&O.originY===e&&(I=-I),J(A)&&(I=-I));var $=Z!==I;if($){var et=A._getTransformedDimensions().x;A.set("skewY",I),v(A,"skewX","scaleX","x",et)}return $}function C(M,O,j,R){var A=O.target,X=A.skewX,q,tt=O.originY;if(A.lockSkewingX)return!1;if(X===0){var Z=Q(O,n,n,j,R);Z.x>0?q=r:q=s}else X>0&&(q=tt===e?r:s),X<0&&(q=tt===e?s:r),J(A)&&(q=q===r?s:r);O.originX=q;var I=K("skewing",U(b));return I(M,O,j,R)}function P(M,O,j,R){var A=O.target,X=A.skewY,q,tt=O.originX;if(A.lockSkewingY)return!1;if(X===0){var Z=Q(O,n,n,j,R);Z.y>0?q=e:q=h}else X>0&&(q=tt===r?e:h),X<0&&(q=tt===r?h:e),J(A)&&(q=q===e?h:e);O.originY=q;var I=K("skewing",U(S));return I(M,O,j,R)}function x(M,O,j,R){var A=O,X=A.target,q=X.translateToOriginPoint(X.getCenterPoint(),A.originX,A.originY);if(X.lockRotation)return!1;var tt=Math.atan2(A.ey-q.y,A.ex-q.x),Z=Math.atan2(R-q.y,j-q.x),I=f(Z-tt+A.theta),$=!0;if(X.snapAngle>0){var et=X.snapAngle,it=X.snapThreshold||et,nt=Math.ceil(I/et)*et,rt=Math.floor(I/et)*et;Math.abs(I-rt)<it?I=rt:Math.abs(I-nt)<it&&(I=nt)}return I<0&&(I=360+I),I%=360,$=X.angle!==I,X.angle=I,$}function y(M,O,j,R,A){A=A||{};var X=O.target,q=X.lockScalingX,tt=X.lockScalingY,Z=A.by,I,$,et,it,nt=p(M,X),rt=w(X,Z,nt),ot,st,ct=O.gestureScale;if(rt)return!1;if(ct)$=O.scaleX*ct,et=O.scaleY*ct;else{if(I=Q(O,O.originX,O.originY,j,R),ot=Z!=="y"?d(I.x):1,st=Z!=="x"?d(I.y):1,O.signX||(O.signX=ot),O.signY||(O.signY=st),X.lockScalingFlip&&(O.signX!==ot||O.signY!==st))return!1;if(it=X._getTransformedDimensions(),nt&&!Z){var dt=Math.abs(I.x)+Math.abs(I.y),lt=O.original,ne=Math.abs(it.x*lt.scaleX/X.scaleX)+Math.abs(it.y*lt.scaleY/X.scaleY),Ft=dt/ne;$=lt.scaleX*Ft,et=lt.scaleY*Ft}else $=Math.abs(I.x*X.scaleX/it.x),et=Math.abs(I.y*X.scaleY/it.y);_(O)&&($*=2,et*=2),O.signX!==ot&&Z!=="y"&&(O.originX=l[O.originX],$*=-1,O.signX=ot),O.signY!==st&&Z!=="x"&&(O.originY=l[O.originY],et*=-1,O.signY=st)}var se=X.scaleX,ae=X.scaleY;return Z?(Z==="x"&&X.set("scaleX",$),Z==="y"&&X.set("scaleY",et)):(!q&&X.set("scaleX",$),!tt&&X.set("scaleY",et)),se!==X.scaleX||ae!==X.scaleY}function T(M,O,j,R){return y(M,O,j,R)}function E(M,O,j,R){return y(M,O,j,R,{by:"x"})}function L(M,O,j,R){return y(M,O,j,R,{by:"y"})}function k(M,O,j,R){return M[O.target.canvas.altActionKey]?t.skewHandlerX(M,O,j,R):t.scalingY(M,O,j,R)}function W(M,O,j,R){return M[O.target.canvas.altActionKey]?t.skewHandlerY(M,O,j,R):t.scalingX(M,O,j,R)}function Y(M,O,j,R){var A=O.target,X=Q(O,O.originX,O.originY,j,R),q=A.strokeWidth/(A.strokeUniform?A.scaleX:1),tt=_(O)?2:1,Z=A.width,I=Math.abs(X.x*tt/A.scaleX)-q;return A.set("width",Math.max(I,0)),Z!==I}function V(M,O,j,R){var A=O.target,X=j-O.offsetX,q=R-O.offsetY,tt=!A.get("lockMovementX")&&A.left!==X,Z=!A.get("lockMovementY")&&A.top!==q;return tt&&A.set("left",X),Z&&A.set("top",q),(tt||Z)&&m("moving",H(M,O,j,R)),tt||Z}t.scaleCursorStyleHandler=D,t.skewCursorStyleHandler=B,t.scaleSkewCursorStyleHandler=N,t.rotationWithSnapping=K("rotating",U(x)),t.scalingEqually=K("scaling",U(T)),t.scalingX=K("scaling",U(E)),t.scalingY=K("scaling",U(L)),t.scalingYOrSkewingX=k,t.scalingXOrSkewingY=W,t.changeWidth=K("resizing",U(Y)),t.skewHandlerX=C,t.skewHandlerY=P,t.dragHandler=V,t.scaleOrSkewActionName=G,t.rotationStyleHandler=z,t.fireEvent=m,t.wrapWithFixedAnchor=U,t.wrapWithFireEvent=K,t.getLocalPoint=Q,i.controlsUtils=t})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.util.degreesToRadians,o=i.controlsUtils;function t(e,s,h,n,l){n=n||{};var f=this.sizeX||n.cornerSize||l.cornerSize,d=this.sizeY||n.cornerSize||l.cornerSize,g=typeof n.transparentCorners!="undefined"?n.transparentCorners:l.transparentCorners,m=g?"stroke":"fill",p=!g&&(n.cornerStrokeColor||l.cornerStrokeColor),_=s,w=h,D;e.save(),e.fillStyle=n.cornerColor||l.cornerColor,e.strokeStyle=n.cornerStrokeColor||l.cornerStrokeColor,f>d?(D=f,e.scale(1,d/f),w=h*f/d):d>f?(D=d,e.scale(f/d,1),_=s*d/f):D=f,e.lineWidth=1,e.beginPath(),e.arc(_,w,D/2,0,2*Math.PI,!1),e[m](),p&&e.stroke(),e.restore()}function r(e,s,h,n,l){n=n||{};var f=this.sizeX||n.cornerSize||l.cornerSize,d=this.sizeY||n.cornerSize||l.cornerSize,g=typeof n.transparentCorners!="undefined"?n.transparentCorners:l.transparentCorners,m=g?"stroke":"fill",p=!g&&(n.cornerStrokeColor||l.cornerStrokeColor),_=f/2,w=d/2;e.save(),e.fillStyle=n.cornerColor||l.cornerColor,e.strokeStyle=n.cornerStrokeColor||l.cornerStrokeColor,e.lineWidth=1,e.translate(s,h),e.rotate(a(l.angle)),e[m+"Rect"](-_,-w,f,d),p&&e.strokeRect(-_,-w,f,d),e.restore()}o.renderCircleControl=t,o.renderSquareControl=r})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={});function a(o){for(var t in o)this[t]=o[t]}i.Control=a,i.Control.prototype={visible:!0,actionName:"scale",angle:0,x:0,y:0,offsetX:0,offsetY:0,sizeX:null,sizeY:null,touchSizeX:null,touchSizeY:null,cursorStyle:"crosshair",withConnection:!1,actionHandler:function(){},mouseDownHandler:function(){},mouseUpHandler:function(){},getActionHandler:function(){return this.actionHandler},getMouseDownHandler:function(){return this.mouseDownHandler},getMouseUpHandler:function(){return this.mouseUpHandler},cursorStyleHandler:function(o,t){return t.cursorStyle},getActionName:function(o,t){return t.actionName},getVisibility:function(o,t){var r=o._controlsVisibility;return r&&typeof r[t]!="undefined"?r[t]:this.visible},setVisibility:function(o){this.visible=o},positionHandler:function(o,t){var r=i.util.transformPoint({x:this.x*o.x+this.offsetX,y:this.y*o.y+this.offsetY},t);return r},calcCornerCoords:function(o,t,r,e,s){var h,n,l,f,d=s?this.touchSizeX:this.sizeX,g=s?this.touchSizeY:this.sizeY;if(d&&g&&d!==g){var m=Math.atan2(g,d),p=Math.sqrt(d*d+g*g)/2,_=m-i.util.degreesToRadians(o),w=Math.PI/2-m-i.util.degreesToRadians(o);h=p*i.util.cos(_),n=p*i.util.sin(_),l=p*i.util.cos(w),f=p*i.util.sin(w)}else{var D=d&&g?d:t;p=D*.7071067812;var _=i.util.degreesToRadians(45-o);h=l=p*i.util.cos(_),n=f=p*i.util.sin(_)}return{tl:{x:r-f,y:e-l},tr:{x:r+h,y:e-n},bl:{x:r-h,y:e+n},br:{x:r+f,y:e+l}}},render:function(o,t,r,e,s){switch(e=e||{},e.cornerStyle||s.cornerStyle){case"circle":i.controlsUtils.renderCircleControl.call(this,o,t,r,e,s);break;default:i.controlsUtils.renderSquareControl.call(this,o,t,r,e,s)}}}})(F);(function(){function c(r,e){var s=r.getAttribute("style"),h=r.getAttribute("offset")||0,n,l,f,d;if(h=parseFloat(h)/(/%$/.test(h)?100:1),h=h<0?0:h>1?1:h,s){var g=s.split(/\s*;\s*/);for(g[g.length-1]===""&&g.pop(),d=g.length;d--;){var m=g[d].split(/\s*:\s*/),p=m[0].trim(),_=m[1].trim();p==="stop-color"?n=_:p==="stop-opacity"&&(f=_)}}return n||(n=r.getAttribute("stop-color")||"rgb(0,0,0)"),f||(f=r.getAttribute("stop-opacity")),n=new u.Color(n),l=n.getAlpha(),f=isNaN(parseFloat(f))?1:parseFloat(f),f*=l*e,{offset:h,color:n.toRgb(),opacity:f}}function i(r){return{x1:r.getAttribute("x1")||0,y1:r.getAttribute("y1")||0,x2:r.getAttribute("x2")||"100%",y2:r.getAttribute("y2")||0}}function a(r){return{x1:r.getAttribute("fx")||r.getAttribute("cx")||"50%",y1:r.getAttribute("fy")||r.getAttribute("cy")||"50%",r1:0,x2:r.getAttribute("cx")||"50%",y2:r.getAttribute("cy")||"50%",r2:r.getAttribute("r")||"50%"}}var o=u.util.object.clone;u.Gradient=u.util.createClass({offsetX:0,offsetY:0,gradientTransform:null,gradientUnits:"pixels",type:"linear",initialize:function(r){r||(r={}),r.coords||(r.coords={});var e,s=this;Object.keys(r).forEach(function(h){s[h]=r[h]}),this.id?this.id+="_"+u.Object.__uid++:this.id=u.Object.__uid++,e={x1:r.coords.x1||0,y1:r.coords.y1||0,x2:r.coords.x2||0,y2:r.coords.y2||0},this.type==="radial"&&(e.r1=r.coords.r1||0,e.r2=r.coords.r2||0),this.coords=e,this.colorStops=r.colorStops.slice()},addColorStop:function(r){for(var e in r){var s=new u.Color(r[e]);this.colorStops.push({offset:parseFloat(e),color:s.toRgb(),opacity:s.getAlpha()})}return this},toObject:function(r){var e={type:this.type,coords:this.coords,colorStops:this.colorStops,offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?this.gradientTransform.concat():this.gradientTransform};return u.util.populateWithProperties(this,e,r),e},toSVG:function(r,l){var s=o(this.coords,!0),h,n,l=l||{},f,d,g=o(this.colorStops,!0),m=s.r1>s.r2,p=this.gradientTransform?this.gradientTransform.concat():u.iMatrix.concat(),_=-this.offsetX,w=-this.offsetY,D=!!l.additionalTransform,B=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox";if(g.sort(function(U,K){return U.offset-K.offset}),B==="objectBoundingBox"?(_/=r.width,w/=r.height):(_+=r.width/2,w+=r.height/2),r.type==="path"&&this.gradientUnits!=="percentage"&&(_-=r.pathOffset.x,w-=r.pathOffset.y),p[4]-=_,p[5]-=w,d='id="SVGID_'+this.id+'" gradientUnits="'+B+'"',d+=' gradientTransform="'+(D?l.additionalTransform+" ":"")+u.util.matrixToSVG(p)+'" ',this.type==="linear"?f=["<linearGradient ",d,' x1="',s.x1,'" y1="',s.y1,'" x2="',s.x2,'" y2="',s.y2,`">
|
|
12
|
+
`]:this.type==="radial"&&(f=["<radialGradient ",d,' cx="',m?s.x1:s.x2,'" cy="',m?s.y1:s.y2,'" r="',m?s.r1:s.r2,'" fx="',m?s.x2:s.x1,'" fy="',m?s.y2:s.y1,`">
|
|
13
|
+
`]),this.type==="radial"){if(m)for(g=g.concat(),g.reverse(),h=0,n=g.length;h<n;h++)g[h].offset=1-g[h].offset;var N=Math.min(s.r1,s.r2);if(N>0){var G=Math.max(s.r1,s.r2),z=N/G;for(h=0,n=g.length;h<n;h++)g[h].offset+=z*(1-g[h].offset)}}for(h=0,n=g.length;h<n;h++){var H=g[h];f.push("<stop ",'offset="',H.offset*100+"%",'" style="stop-color:',H.color,typeof H.opacity!="undefined"?";stop-opacity: "+H.opacity:";",`"/>
|
|
14
|
+
`)}return f.push(this.type==="linear"?`</linearGradient>
|
|
15
|
+
`:`</radialGradient>
|
|
16
|
+
`),f.join("")},toLive:function(r){var e,s=u.util.object.clone(this.coords),h,n;if(this.type){for(this.type==="linear"?e=r.createLinearGradient(s.x1,s.y1,s.x2,s.y2):this.type==="radial"&&(e=r.createRadialGradient(s.x1,s.y1,s.r1,s.x2,s.y2,s.r2)),h=0,n=this.colorStops.length;h<n;h++){var l=this.colorStops[h].color,f=this.colorStops[h].opacity,d=this.colorStops[h].offset;typeof f!="undefined"&&(l=new u.Color(l).setAlpha(f).toRgba()),e.addColorStop(d,l)}return e}}}),u.util.object.extend(u.Gradient,{fromElement:function(r,e,s,h){var n=parseFloat(s)/(/%$/.test(s)?100:1);n=n<0?0:n>1?1:n,isNaN(n)&&(n=1);var l=r.getElementsByTagName("stop"),f,d=r.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage",g=r.getAttribute("gradientTransform")||"",m=[],p,_,w=0,D=0,B;for(r.nodeName==="linearGradient"||r.nodeName==="LINEARGRADIENT"?(f="linear",p=i(r)):(f="radial",p=a(r)),_=l.length;_--;)m.push(c(l[_],n));B=u.parseTransformAttribute(g),t(e,p,h,d),d==="pixels"&&(w=-e.left,D=-e.top);var N=new u.Gradient({id:r.getAttribute("id"),type:f,coords:p,colorStops:m,gradientUnits:d,gradientTransform:B,offsetX:w,offsetY:D});return N}});function t(r,e,s,h){var n,l;Object.keys(e).forEach(function(f){n=e[f],n==="Infinity"?l=1:n==="-Infinity"?l=0:(l=parseFloat(e[f],10),typeof n=="string"&&/^(\d+\.\d+)%|(\d+)%$/.test(n)&&(l*=.01,h==="pixels"&&((f==="x1"||f==="x2"||f==="r2")&&(l*=s.viewBoxWidth||s.width),(f==="y1"||f==="y2")&&(l*=s.viewBoxHeight||s.height)))),e[f]=l})}})();(function(){"use strict";var c=u.util.toFixed;u.Pattern=u.util.createClass({repeat:"repeat",offsetX:0,offsetY:0,crossOrigin:"",patternTransform:null,initialize:function(i,a){if(i||(i={}),this.id=u.Object.__uid++,this.setOptions(i),!i.source||i.source&&typeof i.source!="string"){a&&a(this);return}else{var o=this;this.source=u.util.createImage(),u.util.loadImage(i.source,function(t,r){o.source=t,a&&a(o,r)},null,this.crossOrigin)}},toObject:function(i){var a=u.Object.NUM_FRACTION_DIGITS,o,t;return typeof this.source.src=="string"?o=this.source.src:typeof this.source=="object"&&this.source.toDataURL&&(o=this.source.toDataURL()),t={type:"pattern",source:o,repeat:this.repeat,crossOrigin:this.crossOrigin,offsetX:c(this.offsetX,a),offsetY:c(this.offsetY,a),patternTransform:this.patternTransform?this.patternTransform.concat():null},u.util.populateWithProperties(this,t,i),t},toSVG:function(i){var a=typeof this.source=="function"?this.source():this.source,o=a.width/i.width,t=a.height/i.height,r=this.offsetX/i.width,e=this.offsetY/i.height,s="";return(this.repeat==="repeat-x"||this.repeat==="no-repeat")&&(t=1,e&&(t+=Math.abs(e))),(this.repeat==="repeat-y"||this.repeat==="no-repeat")&&(o=1,r&&(o+=Math.abs(r))),a.src?s=a.src:a.toDataURL&&(s=a.toDataURL()),'<pattern id="SVGID_'+this.id+'" x="'+r+'" y="'+e+'" width="'+o+'" height="'+t+`">
|
|
17
|
+
<image x="0" y="0" width="`+a.width+'" height="'+a.height+'" xlink:href="'+s+`"></image>
|
|
18
|
+
</pattern>
|
|
19
|
+
`},setOptions:function(i){for(var a in i)this[a]=i[a]},toLive:function(i){var a=this.source;return!a||typeof a.src!="undefined"&&(!a.complete||a.naturalWidth===0||a.naturalHeight===0)?"":i.createPattern(a,this.repeat)}})})();(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.util.toFixed;if(i.Shadow){i.warn("fabric.Shadow is already defined.");return}i.Shadow=i.util.createClass({color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1,initialize:function(o){typeof o=="string"&&(o=this._parseShadow(o));for(var t in o)this[t]=o[t];this.id=i.Object.__uid++},_parseShadow:function(o){var t=o.trim(),r=i.Shadow.reOffsetsAndBlur.exec(t)||[],e=t.replace(i.Shadow.reOffsetsAndBlur,"")||"rgb(0,0,0)";return{color:e.trim(),offsetX:parseFloat(r[1],10)||0,offsetY:parseFloat(r[2],10)||0,blur:parseFloat(r[3],10)||0}},toString:function(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")},toSVG:function(o){var t=40,r=40,e=i.Object.NUM_FRACTION_DIGITS,s=i.util.rotateVector({x:this.offsetX,y:this.offsetY},i.util.degreesToRadians(-o.angle)),h=20,n=new i.Color(this.color);return o.width&&o.height&&(t=a((Math.abs(s.x)+this.blur)/o.width,e)*100+h,r=a((Math.abs(s.y)+this.blur)/o.height,e)*100+h),o.flipX&&(s.x*=-1),o.flipY&&(s.y*=-1),'<filter id="SVGID_'+this.id+'" y="-'+r+'%" height="'+(100+2*r)+'%" x="-'+t+'%" width="'+(100+2*t)+`%" >
|
|
20
|
+
<feGaussianBlur in="SourceAlpha" stdDeviation="`+a(this.blur?this.blur/2:0,e)+`"></feGaussianBlur>
|
|
21
|
+
<feOffset dx="`+a(s.x,e)+'" dy="'+a(s.y,e)+`" result="oBlur" ></feOffset>
|
|
22
|
+
<feFlood flood-color="`+n.toRgb()+'" flood-opacity="'+n.getAlpha()+`"/>
|
|
23
|
+
<feComposite in2="oBlur" operator="in" />
|
|
24
|
+
<feMerge>
|
|
25
|
+
<feMergeNode></feMergeNode>
|
|
26
|
+
<feMergeNode in="SourceGraphic"></feMergeNode>
|
|
27
|
+
</feMerge>
|
|
28
|
+
</filter>
|
|
29
|
+
`},toObject:function(){if(this.includeDefaultValues)return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling};var o={},t=i.Shadow.prototype;return["color","blur","offsetX","offsetY","affectStroke","nonScaling"].forEach(function(r){this[r]!==t[r]&&(o[r]=this[r])},this),o}}),i.Shadow.reOffsetsAndBlur=/(?:\s|^)(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(\d+(?:\.\d*)?(?:px)?)?(?:\s?|$)(?:$|\s)/})(F);(function(){"use strict";if(u.StaticCanvas){u.warn("fabric.StaticCanvas is already defined.");return}var c=u.util.object.extend,i=u.util.getElementOffset,a=u.util.removeFromArray,o=u.util.toFixed,t=u.util.transformPoint,r=u.util.invertTransform,e=u.util.getNodeCanvas,s=u.util.createCanvasElement,h=new Error("Could not initialize `canvas` element");u.StaticCanvas=u.util.createClass(u.CommonMethods,{initialize:function(n,l){l||(l={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(n,l)},backgroundColor:"",backgroundImage:null,overlayColor:"",overlayImage:null,includeDefaultValues:!0,stateful:!1,renderOnAddRemove:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,imageSmoothingEnabled:!0,viewportTransform:u.iMatrix.concat(),backgroundVpt:!0,overlayVpt:!0,enableRetinaScaling:!0,vptCoords:{},skipOffscreen:!0,clipPath:void 0,_initStatic:function(n,l){var f=this.requestRenderAllBound;this._objects=[],this._createLowerCanvas(n),this._initOptions(l),this.interactive||this._initRetinaScaling(),l.overlayImage&&this.setOverlayImage(l.overlayImage,f),l.backgroundImage&&this.setBackgroundImage(l.backgroundImage,f),l.backgroundColor&&this.setBackgroundColor(l.backgroundColor,f),l.overlayColor&&this.setOverlayColor(l.overlayColor,f),this.calcOffset()},_isRetinaScaling:function(){return u.devicePixelRatio>1&&this.enableRetinaScaling},getRetinaScaling:function(){return this._isRetinaScaling()?Math.max(1,u.devicePixelRatio):1},_initRetinaScaling:function(){if(this._isRetinaScaling()){var n=u.devicePixelRatio;this.__initRetinaScaling(n,this.lowerCanvasEl,this.contextContainer),this.upperCanvasEl&&this.__initRetinaScaling(n,this.upperCanvasEl,this.contextTop)}},__initRetinaScaling:function(n,l,f){l.setAttribute("width",this.width*n),l.setAttribute("height",this.height*n),f.scale(n,n)},calcOffset:function(){return this._offset=i(this.lowerCanvasEl),this},setOverlayImage:function(n,l,f){return this.__setBgOverlayImage("overlayImage",n,l,f)},setBackgroundImage:function(n,l,f){return this.__setBgOverlayImage("backgroundImage",n,l,f)},setOverlayColor:function(n,l){return this.__setBgOverlayColor("overlayColor",n,l)},setBackgroundColor:function(n,l){return this.__setBgOverlayColor("backgroundColor",n,l)},__setBgOverlayImage:function(n,l,f,d){return typeof l=="string"?u.util.loadImage(l,function(g,m){if(g){var p=new u.Image(g,d);this[n]=p,p.canvas=this}f&&f(g,m)},this,d&&d.crossOrigin):(d&&l.setOptions(d),this[n]=l,l&&(l.canvas=this),f&&f(l,!1)),this},__setBgOverlayColor:function(n,l,f){return this[n]=l,this._initGradient(l,n),this._initPattern(l,n,f),this},_createCanvasElement:function(){var n=s();if(!n||(n.style||(n.style={}),typeof n.getContext=="undefined"))throw h;return n},_initOptions:function(n){var l=this.lowerCanvasEl;this._setOptions(n),this.width=this.width||parseInt(l.width,10)||0,this.height=this.height||parseInt(l.height,10)||0,this.lowerCanvasEl.style&&(l.width=this.width,l.height=this.height,l.style.width=this.width+"px",l.style.height=this.height+"px",this.viewportTransform=this.viewportTransform.slice())},_createLowerCanvas:function(n){n&&n.getContext?this.lowerCanvasEl=n:this.lowerCanvasEl=u.util.getById(n)||this._createCanvasElement(),u.util.addClass(this.lowerCanvasEl,"lower-canvas"),this._originalCanvasStyle=this.lowerCanvasEl.style,this.interactive&&this._applyCanvasStyle(this.lowerCanvasEl),this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(n,l){return this.setDimensions({width:n},l)},setHeight:function(n,l){return this.setDimensions({height:n},l)},setDimensions:function(n,l){var f;l=l||{};for(var d in n)f=n[d],l.cssOnly||(this._setBackstoreDimension(d,n[d]),f+="px",this.hasLostContext=!0),l.backstoreOnly||this._setCssDimension(d,f);return this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop),this._initRetinaScaling(),this.calcOffset(),l.cssOnly||this.requestRenderAll(),this},_setBackstoreDimension:function(n,l){return this.lowerCanvasEl[n]=l,this.upperCanvasEl&&(this.upperCanvasEl[n]=l),this.cacheCanvasEl&&(this.cacheCanvasEl[n]=l),this[n]=l,this},_setCssDimension:function(n,l){return this.lowerCanvasEl.style[n]=l,this.upperCanvasEl&&(this.upperCanvasEl.style[n]=l),this.wrapperEl&&(this.wrapperEl.style[n]=l),this},getZoom:function(){return this.viewportTransform[0]},setViewportTransform:function(n){var l=this._activeObject,f=this.backgroundImage,d=this.overlayImage,g,m,p;for(this.viewportTransform=n,m=0,p=this._objects.length;m<p;m++)g=this._objects[m],g.group||g.setCoords(!0);return l&&l.setCoords(),f&&f.setCoords(!0),d&&d.setCoords(!0),this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll(),this},zoomToPoint:function(n,l){var f=n,d=this.viewportTransform.slice(0);n=t(n,r(this.viewportTransform)),d[0]=l,d[3]=l;var g=t(n,d);return d[4]+=f.x-g.x,d[5]+=f.y-g.y,this.setViewportTransform(d)},setZoom:function(n){return this.zoomToPoint(new u.Point(0,0),n),this},absolutePan:function(n){var l=this.viewportTransform.slice(0);return l[4]=-n.x,l[5]=-n.y,this.setViewportTransform(l)},relativePan:function(n){return this.absolutePan(new u.Point(-n.x-this.viewportTransform[4],-n.y-this.viewportTransform[5]))},getElement:function(){return this.lowerCanvasEl},_onObjectAdded:function(n){this.stateful&&n.setupState(),n._set("canvas",this),n.setCoords(),this.fire("object:added",{target:n}),n.fire("added")},_onObjectRemoved:function(n){this.fire("object:removed",{target:n}),n.fire("removed"),delete n.canvas},clearContext:function(n){return n.clearRect(0,0,this.width,this.height),this},getContext:function(){return this.contextContainer},clear:function(){return this.remove.apply(this,this.getObjects()),this.backgroundImage=null,this.overlayImage=null,this.backgroundColor="",this.overlayColor="",this._hasITextHandlers&&(this.off("mouse:up",this._mouseUpITextHandler),this._iTextInstances=null,this._hasITextHandlers=!1),this.clearContext(this.contextContainer),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll(),this},renderAll:function(){var n=this.contextContainer;return this.renderCanvas(n,this._objects),this},renderAndReset:function(){this.isRendering=0,this.renderAll()},requestRenderAll:function(){return this.isRendering||(this.isRendering=u.util.requestAnimFrame(this.renderAndResetBound)),this},calcViewportBoundaries:function(){var n={},l=this.width,f=this.height,d=r(this.viewportTransform);return n.tl=t({x:0,y:0},d),n.br=t({x:l,y:f},d),n.tr=new u.Point(n.br.x,n.tl.y),n.bl=new u.Point(n.tl.x,n.br.y),this.vptCoords=n,n},cancelRequestedRender:function(){this.isRendering&&(u.util.cancelAnimFrame(this.isRendering),this.isRendering=0)},renderCanvas:function(n,l){var f=this.viewportTransform,d=this.clipPath;this.cancelRequestedRender(),this.calcViewportBoundaries(),this.clearContext(n),u.util.setImageSmoothing(n,this.imageSmoothingEnabled),this.fire("before:render",{ctx:n}),this._renderBackground(n),n.save(),n.transform(f[0],f[1],f[2],f[3],f[4],f[5]),this._renderObjects(n,l),n.restore(),!this.controlsAboveOverlay&&this.interactive&&this.drawControls(n),d&&(d.canvas=this,d.shouldCache(),d._transformDone=!0,d.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(n)),this._renderOverlay(n),this.controlsAboveOverlay&&this.interactive&&this.drawControls(n),this.fire("after:render",{ctx:n})},drawClipPathOnCanvas:function(n){var l=this.viewportTransform,f=this.clipPath;n.save(),n.transform(l[0],l[1],l[2],l[3],l[4],l[5]),n.globalCompositeOperation="destination-in",f.transform(n),n.scale(1/f.zoomX,1/f.zoomY),n.drawImage(f._cacheCanvas,-f.cacheTranslationX,-f.cacheTranslationY),n.restore()},_renderObjects:function(n,l){var f,d;for(f=0,d=l.length;f<d;++f)l[f]&&l[f].render(n)},_renderBackgroundOrOverlay:function(n,l){var f=this[l+"Color"],d=this[l+"Image"],g=this.viewportTransform,m=this[l+"Vpt"];if(!(!f&&!d)){if(f){n.save(),n.beginPath(),n.moveTo(0,0),n.lineTo(this.width,0),n.lineTo(this.width,this.height),n.lineTo(0,this.height),n.closePath(),n.fillStyle=f.toLive?f.toLive(n,this):f,m&&n.transform(g[0],g[1],g[2],g[3],g[4],g[5]),n.transform(1,0,0,1,f.offsetX||0,f.offsetY||0);var p=f.gradientTransform||f.patternTransform;p&&n.transform(p[0],p[1],p[2],p[3],p[4],p[5]),n.fill(),n.restore()}d&&(n.save(),m&&n.transform(g[0],g[1],g[2],g[3],g[4],g[5]),d.render(n),n.restore())}},_renderBackground:function(n){this._renderBackgroundOrOverlay(n,"background")},_renderOverlay:function(n){this._renderBackgroundOrOverlay(n,"overlay")},getCenter:function(){return{top:this.height/2,left:this.width/2}},centerObjectH:function(n){return this._centerObject(n,new u.Point(this.getCenter().left,n.getCenterPoint().y))},centerObjectV:function(n){return this._centerObject(n,new u.Point(n.getCenterPoint().x,this.getCenter().top))},centerObject:function(n){var l=this.getCenter();return this._centerObject(n,new u.Point(l.left,l.top))},viewportCenterObject:function(n){var l=this.getVpCenter();return this._centerObject(n,l)},viewportCenterObjectH:function(n){var l=this.getVpCenter();return this._centerObject(n,new u.Point(l.x,n.getCenterPoint().y)),this},viewportCenterObjectV:function(n){var l=this.getVpCenter();return this._centerObject(n,new u.Point(n.getCenterPoint().x,l.y))},getVpCenter:function(){var n=this.getCenter(),l=r(this.viewportTransform);return t({x:n.left,y:n.top},l)},_centerObject:function(n,l){return n.setPositionByOrigin(l,"center","center"),n.setCoords(),this.renderOnAddRemove&&this.requestRenderAll(),this},toDatalessJSON:function(n){return this.toDatalessObject(n)},toObject:function(n){return this._toObjectMethod("toObject",n)},toDatalessObject:function(n){return this._toObjectMethod("toDatalessObject",n)},_toObjectMethod:function(n,l){var f=this.clipPath,d={version:u.version,objects:this._toObjects(n,l)};return f&&!f.excludeFromExport&&(d.clipPath=this._toObject(this.clipPath,n,l)),c(d,this.__serializeBgOverlay(n,l)),u.util.populateWithProperties(this,d,l),d},_toObjects:function(n,l){return this._objects.filter(function(f){return!f.excludeFromExport}).map(function(f){return this._toObject(f,n,l)},this)},_toObject:function(n,l,f){var d;this.includeDefaultValues||(d=n.includeDefaultValues,n.includeDefaultValues=!1);var g=n[l](f);return this.includeDefaultValues||(n.includeDefaultValues=d),g},__serializeBgOverlay:function(n,l){var f={},d=this.backgroundImage,g=this.overlayImage,m=this.backgroundColor,p=this.overlayColor;return m&&m.toObject?m.excludeFromExport||(f.background=m.toObject(l)):m&&(f.background=m),p&&p.toObject?p.excludeFromExport||(f.overlay=p.toObject(l)):p&&(f.overlay=p),d&&!d.excludeFromExport&&(f.backgroundImage=this._toObject(d,n,l)),g&&!g.excludeFromExport&&(f.overlayImage=this._toObject(g,n,l)),f},svgViewportTransformation:!0,toSVG:function(n,l){n||(n={}),n.reviver=l;var f=[];return this._setSVGPreamble(f,n),this._setSVGHeader(f,n),this.clipPath&&f.push('<g clip-path="url(#'+this.clipPath.clipPathId+`)" >
|
|
30
|
+
`),this._setSVGBgOverlayColor(f,"background"),this._setSVGBgOverlayImage(f,"backgroundImage",l),this._setSVGObjects(f,l),this.clipPath&&f.push(`</g>
|
|
31
|
+
`),this._setSVGBgOverlayColor(f,"overlay"),this._setSVGBgOverlayImage(f,"overlayImage",l),f.push("</svg>"),f.join("")},_setSVGPreamble:function(n,l){l.suppressPreamble||n.push('<?xml version="1.0" encoding="',l.encoding||"UTF-8",`" standalone="no" ?>
|
|
32
|
+
`,'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ',`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
33
|
+
`)},_setSVGHeader:function(n,l){var f=l.width||this.width,d=l.height||this.height,g,m='viewBox="0 0 '+this.width+" "+this.height+'" ',p=u.Object.NUM_FRACTION_DIGITS;l.viewBox?m='viewBox="'+l.viewBox.x+" "+l.viewBox.y+" "+l.viewBox.width+" "+l.viewBox.height+'" ':this.svgViewportTransformation&&(g=this.viewportTransform,m='viewBox="'+o(-g[4]/g[0],p)+" "+o(-g[5]/g[3],p)+" "+o(this.width/g[0],p)+" "+o(this.height/g[3],p)+'" '),n.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',f,'" ','height="',d,'" ',m,`xml:space="preserve">
|
|
34
|
+
`,"<desc>Created with Fabric.js ",u.version,`</desc>
|
|
35
|
+
`,`<defs>
|
|
36
|
+
`,this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(l),`</defs>
|
|
37
|
+
`)},createSVGClipPathMarkup:function(n){var l=this.clipPath;return l?(l.clipPathId="CLIPPATH_"+u.Object.__uid++,'<clipPath id="'+l.clipPathId+`" >
|
|
38
|
+
`+this.clipPath.toClipPathSVG(n.reviver)+`</clipPath>
|
|
39
|
+
`):""},createSVGRefElementsMarkup:function(){var n=this,l=["background","overlay"].map(function(f){var d=n[f+"Color"];if(d&&d.toLive){var g=n[f+"Vpt"],m=n.viewportTransform,p={width:n.width/(g?m[0]:1),height:n.height/(g?m[3]:1)};return d.toSVG(p,{additionalTransform:g?u.util.matrixToSVG(m):""})}});return l.join("")},createSVGFontFacesMarkup:function(){var n="",l={},f,d,g,m,p,_,w,D,B,N=u.fontPaths,G=[];for(this._objects.forEach(function H(U){G.push(U),U._objects&&U._objects.forEach(H)}),D=0,B=G.length;D<B;D++)if(f=G[D],d=f.fontFamily,!(f.type.indexOf("text")===-1||l[d]||!N[d])&&(l[d]=!0,!!f.styles)){g=f.styles;for(p in g){m=g[p];for(w in m)_=m[w],d=_.fontFamily,!l[d]&&N[d]&&(l[d]=!0)}}for(var z in l)n+=[` @font-face {
|
|
40
|
+
`," font-family: '",z,`';
|
|
41
|
+
`," src: url('",N[z],`');
|
|
42
|
+
`,` }
|
|
43
|
+
`].join("");return n&&(n=[' <style type="text/css">',`<![CDATA[
|
|
44
|
+
`,n,"]]>",`</style>
|
|
45
|
+
`].join("")),n},_setSVGObjects:function(n,l){var f,d,g,m=this._objects;for(d=0,g=m.length;d<g;d++)f=m[d],!f.excludeFromExport&&this._setSVGObject(n,f,l)},_setSVGObject:function(n,l,f){n.push(l.toSVG(f))},_setSVGBgOverlayImage:function(n,l,f){this[l]&&!this[l].excludeFromExport&&this[l].toSVG&&n.push(this[l].toSVG(f))},_setSVGBgOverlayColor:function(n,l){var f=this[l+"Color"],d=this.viewportTransform,g=this.width,m=this.height;if(f)if(f.toLive){var p=f.repeat,_=u.util.invertTransform(d),w=this[l+"Vpt"],D=w?u.util.matrixToSVG(_):"";n.push('<rect transform="'+D+" translate(",g/2,",",m/2,')"',' x="',f.offsetX-g/2,'" y="',f.offsetY-m/2,'" ','width="',p==="repeat-y"||p==="no-repeat"?f.source.width:g,'" height="',p==="repeat-x"||p==="no-repeat"?f.source.height:m,'" fill="url(#SVGID_'+f.id+')"',`></rect>
|
|
46
|
+
`)}else n.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',f,'"',`></rect>
|
|
47
|
+
`)},sendToBack:function(n){if(!n)return this;var l=this._activeObject,f,d,g;if(n===l&&n.type==="activeSelection")for(g=l._objects,f=g.length;f--;)d=g[f],a(this._objects,d),this._objects.unshift(d);else a(this._objects,n),this._objects.unshift(n);return this.renderOnAddRemove&&this.requestRenderAll(),this},bringToFront:function(n){if(!n)return this;var l=this._activeObject,f,d,g;if(n===l&&n.type==="activeSelection")for(g=l._objects,f=0;f<g.length;f++)d=g[f],a(this._objects,d),this._objects.push(d);else a(this._objects,n),this._objects.push(n);return this.renderOnAddRemove&&this.requestRenderAll(),this},sendBackwards:function(n,l){if(!n)return this;var f=this._activeObject,d,g,m,p,_,w=0;if(n===f&&n.type==="activeSelection")for(_=f._objects,d=0;d<_.length;d++)g=_[d],m=this._objects.indexOf(g),m>0+w&&(p=m-1,a(this._objects,g),this._objects.splice(p,0,g)),w++;else m=this._objects.indexOf(n),m!==0&&(p=this._findNewLowerIndex(n,m,l),a(this._objects,n),this._objects.splice(p,0,n));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewLowerIndex:function(n,l,f){var d,g;if(f)for(d=l,g=l-1;g>=0;--g){var m=n.intersectsWithObject(this._objects[g])||n.isContainedWithinObject(this._objects[g])||this._objects[g].isContainedWithinObject(n);if(m){d=g;break}}else d=l-1;return d},bringForward:function(n,l){if(!n)return this;var f=this._activeObject,d,g,m,p,_,w=0;if(n===f&&n.type==="activeSelection")for(_=f._objects,d=_.length;d--;)g=_[d],m=this._objects.indexOf(g),m<this._objects.length-1-w&&(p=m+1,a(this._objects,g),this._objects.splice(p,0,g)),w++;else m=this._objects.indexOf(n),m!==this._objects.length-1&&(p=this._findNewUpperIndex(n,m,l),a(this._objects,n),this._objects.splice(p,0,n));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewUpperIndex:function(n,l,f){var d,g,m;if(f)for(d=l,g=l+1,m=this._objects.length;g<m;++g){var p=n.intersectsWithObject(this._objects[g])||n.isContainedWithinObject(this._objects[g])||this._objects[g].isContainedWithinObject(n);if(p){d=g;break}}else d=l+1;return d},moveTo:function(n,l){return a(this._objects,n),this._objects.splice(l,0,n),this.renderOnAddRemove&&this.requestRenderAll()},dispose:function(){return this.isRendering&&(u.util.cancelAnimFrame(this.isRendering),this.isRendering=0),this.forEachObject(function(n){n.dispose&&n.dispose()}),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose&&this.backgroundImage.dispose(),this.backgroundImage=null,this.overlayImage&&this.overlayImage.dispose&&this.overlayImage.dispose(),this.overlayImage=null,this._iTextInstances=null,this.contextContainer=null,this.lowerCanvasEl.classList.remove("lower-canvas"),u.util.setStyle(this.lowerCanvasEl,this._originalCanvasStyle),delete this._originalCanvasStyle,this.lowerCanvasEl.setAttribute("width",this.width),this.lowerCanvasEl.setAttribute("height",this.height),u.util.cleanUpJsdomNode(this.lowerCanvasEl),this.lowerCanvasEl=void 0,this},toString:function(){return"#<fabric.Canvas ("+this.complexity()+"): { objects: "+this._objects.length+" }>"}}),c(u.StaticCanvas.prototype,u.Observable),c(u.StaticCanvas.prototype,u.Collection),c(u.StaticCanvas.prototype,u.DataURLExporter),c(u.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',supports:function(n){var l=s();if(!l||!l.getContext)return null;var f=l.getContext("2d");if(!f)return null;switch(n){case"setLineDash":return typeof f.setLineDash!="undefined";default:return null}}}),u.StaticCanvas.prototype.toJSON=u.StaticCanvas.prototype.toObject,u.isLikelyNode&&(u.StaticCanvas.prototype.createPNGStream=function(){var n=e(this.lowerCanvasEl);return n&&n.createPNGStream()},u.StaticCanvas.prototype.createJPEGStream=function(n){var l=e(this.lowerCanvasEl);return l&&l.createJPEGStream(n)})})();u.BaseBrush=u.util.createClass({color:"rgb(0, 0, 0)",width:1,shadow:null,strokeLineCap:"round",strokeLineJoin:"round",strokeMiterLimit:10,strokeDashArray:null,limitedToCanvasSize:!1,_setBrushStyles:function(c){c.strokeStyle=this.color,c.lineWidth=this.width,c.lineCap=this.strokeLineCap,c.miterLimit=this.strokeMiterLimit,c.lineJoin=this.strokeLineJoin,c.setLineDash(this.strokeDashArray||[])},_saveAndTransform:function(c){var i=this.canvas.viewportTransform;c.save(),c.transform(i[0],i[1],i[2],i[3],i[4],i[5])},_setShadow:function(){if(this.shadow){var c=this.canvas,i=this.shadow,a=c.contextTop,o=c.getZoom();c&&c._isRetinaScaling()&&(o*=u.devicePixelRatio),a.shadowColor=i.color,a.shadowBlur=i.blur*o,a.shadowOffsetX=i.offsetX*o,a.shadowOffsetY=i.offsetY*o}},needsFullRender:function(){var c=new u.Color(this.color);return c.getAlpha()<1||!!this.shadow},_resetShadow:function(){var c=this.canvas.contextTop;c.shadowColor="",c.shadowBlur=c.shadowOffsetX=c.shadowOffsetY=0},_isOutSideCanvas:function(c){return c.x<0||c.x>this.canvas.getWidth()||c.y<0||c.y>this.canvas.getHeight()}});(function(){u.PencilBrush=u.util.createClass(u.BaseBrush,{decimate:.4,drawStraightLine:!1,straightLineKey:"shiftKey",initialize:function(c){this.canvas=c,this._points=[]},needsFullRender:function(){return this.callSuper("needsFullRender")||this._hasStraightLine},_drawSegment:function(c,i,a){var o=i.midPointFrom(a);return c.quadraticCurveTo(i.x,i.y,o.x,o.y),o},onMouseDown:function(c,i){this.canvas._isMainEvent(i.e)&&(this.drawStraightLine=i.e[this.straightLineKey],this._prepareForDrawing(c),this._captureDrawingPath(c),this._render())},onMouseMove:function(c,i){if(this.canvas._isMainEvent(i.e)&&(this.drawStraightLine=i.e[this.straightLineKey],!(this.limitedToCanvasSize===!0&&this._isOutSideCanvas(c))&&this._captureDrawingPath(c)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{var a=this._points,o=a.length,t=this.canvas.contextTop;this._saveAndTransform(t),this.oldEnd&&(t.beginPath(),t.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=this._drawSegment(t,a[o-2],a[o-1],!0),t.stroke(),t.restore()}},onMouseUp:function(c){return this.canvas._isMainEvent(c.e)?(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1):!0},_prepareForDrawing:function(c){var i=new u.Point(c.x,c.y);this._reset(),this._addPoint(i),this.canvas.contextTop.moveTo(i.x,i.y)},_addPoint:function(c){return this._points.length>1&&c.eq(this._points[this._points.length-1])?!1:(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(c),!0)},_reset:function(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1},_captureDrawingPath:function(c){var i=new u.Point(c.x,c.y);return this._addPoint(i)},_render:function(c){var i,a,o=this._points[0],t=this._points[1];if(c=c||this.canvas.contextTop,this._saveAndTransform(c),c.beginPath(),this._points.length===2&&o.x===t.x&&o.y===t.y){var r=this.width/1e3;o=new u.Point(o.x,o.y),t=new u.Point(t.x,t.y),o.x-=r,t.x+=r}for(c.moveTo(o.x,o.y),i=1,a=this._points.length;i<a;i++)this._drawSegment(c,o,t),o=this._points[i],t=this._points[i+1];c.lineTo(o.x,o.y),c.stroke(),c.restore()},convertPointsToSVGPath:function(c){var i=this.width/1e3;return u.util.getSmoothPathFromPoints(c,i)},_isEmptySVGPath:function(c){var i=u.util.joinPath(c);return i==="M 0 0 Q 0 0 0 0 L 0 0"},createPath:function(c){var i=new u.Path(c,{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,i.shadow=new u.Shadow(this.shadow)),i},decimatePoints:function(c,i){if(c.length<=2)return c;var a=this.canvas.getZoom(),o=Math.pow(i/a,2),t,r=c.length-1,e=c[0],s=[e],h;for(t=1;t<r-1;t++)h=Math.pow(e.x-c[t].x,2)+Math.pow(e.y-c[t].y,2),h>=o&&(e=c[t],s.push(e));return s.push(c[r]),s},_finalizeAndAddPath:function(){var c=this.canvas.contextTop;c.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));var i=this.convertPointsToSVGPath(this._points);if(this._isEmptySVGPath(i)){this.canvas.requestRenderAll();return}var a=this.createPath(i);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:a}),this.canvas.add(a),this.canvas.requestRenderAll(),a.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:a})}})})();u.CircleBrush=u.util.createClass(u.BaseBrush,{width:10,initialize:function(c){this.canvas=c,this.points=[]},drawDot:function(c){var i=this.addPoint(c),a=this.canvas.contextTop;this._saveAndTransform(a),this.dot(a,i),a.restore()},dot:function(c,i){c.fillStyle=i.fill,c.beginPath(),c.arc(i.x,i.y,i.radius,0,Math.PI*2,!1),c.closePath(),c.fill()},onMouseDown:function(c){this.points.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(c)},_render:function(){var c=this.canvas.contextTop,i,a,o=this.points;for(this._saveAndTransform(c),i=0,a=o.length;i<a;i++)this.dot(c,o[i]);c.restore()},onMouseMove:function(c){this.limitedToCanvasSize===!0&&this._isOutSideCanvas(c)||(this.needsFullRender()?(this.canvas.clearContext(this.canvas.contextTop),this.addPoint(c),this._render()):this.drawDot(c))},onMouseUp:function(){var c=this.canvas.renderOnAddRemove,i,a;this.canvas.renderOnAddRemove=!1;var o=[];for(i=0,a=this.points.length;i<a;i++){var t=this.points[i],r=new u.Circle({radius:t.radius,left:t.x,top:t.y,originX:"center",originY:"center",fill:t.fill});this.shadow&&(r.shadow=new u.Shadow(this.shadow)),o.push(r)}var e=new u.Group(o);e.canvas=this.canvas,this.canvas.fire("before:path:created",{path:e}),this.canvas.add(e),this.canvas.fire("path:created",{path:e}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=c,this.canvas.requestRenderAll()},addPoint:function(c){var i=new u.Point(c.x,c.y),a=u.util.getRandomInt(Math.max(0,this.width-20),this.width+20)/2,o=new u.Color(this.color).setAlpha(u.util.getRandomInt(0,100)/100).toRgba();return i.radius=a,i.fill=o,this.points.push(i),i}});u.SprayBrush=u.util.createClass(u.BaseBrush,{width:10,density:20,dotWidth:1,dotWidthVariance:1,randomOpacity:!1,optimizeOverlapping:!0,initialize:function(c){this.canvas=c,this.sprayChunks=[]},onMouseDown:function(c){this.sprayChunks.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.addSprayChunk(c),this.render(this.sprayChunkPoints)},onMouseMove:function(c){this.limitedToCanvasSize===!0&&this._isOutSideCanvas(c)||(this.addSprayChunk(c),this.render(this.sprayChunkPoints))},onMouseUp:function(){var c=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;for(var i=[],a=0,o=this.sprayChunks.length;a<o;a++)for(var t=this.sprayChunks[a],r=0,e=t.length;r<e;r++){var s=new u.Rect({width:t[r].width,height:t[r].width,left:t[r].x+1,top:t[r].y+1,originX:"center",originY:"center",fill:this.color});i.push(s)}this.optimizeOverlapping&&(i=this._getOptimizedRects(i));var h=new u.Group(i);this.shadow&&h.set("shadow",new u.Shadow(this.shadow)),this.canvas.fire("before:path:created",{path:h}),this.canvas.add(h),this.canvas.fire("path:created",{path:h}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=c,this.canvas.requestRenderAll()},_getOptimizedRects:function(c){var i={},a,o,t;for(o=0,t=c.length;o<t;o++)a=c[o].left+""+c[o].top,i[a]||(i[a]=c[o]);var r=[];for(a in i)r.push(i[a]);return r},render:function(c){var i=this.canvas.contextTop,a,o;for(i.fillStyle=this.color,this._saveAndTransform(i),a=0,o=c.length;a<o;a++){var t=c[a];typeof t.opacity!="undefined"&&(i.globalAlpha=t.opacity),i.fillRect(t.x,t.y,t.width,t.width)}i.restore()},_render:function(){var c=this.canvas.contextTop,i,a;for(c.fillStyle=this.color,this._saveAndTransform(c),i=0,a=this.sprayChunks.length;i<a;i++)this.render(this.sprayChunks[i]);c.restore()},addSprayChunk:function(c){this.sprayChunkPoints=[];var i,a,o,t=this.width/2,r;for(r=0;r<this.density;r++){i=u.util.getRandomInt(c.x-t,c.x+t),a=u.util.getRandomInt(c.y-t,c.y+t),this.dotWidthVariance?o=u.util.getRandomInt(Math.max(1,this.dotWidth-this.dotWidthVariance),this.dotWidth+this.dotWidthVariance):o=this.dotWidth;var e=new u.Point(i,a);e.width=o,this.randomOpacity&&(e.opacity=u.util.getRandomInt(0,100)/100),this.sprayChunkPoints.push(e)}this.sprayChunks.push(this.sprayChunkPoints)}});u.PatternBrush=u.util.createClass(u.PencilBrush,{getPatternSrc:function(){var c=20,i=5,a=u.util.createCanvasElement(),o=a.getContext("2d");return a.width=a.height=c+i,o.fillStyle=this.color,o.beginPath(),o.arc(c/2,c/2,c/2,0,Math.PI*2,!1),o.closePath(),o.fill(),a},getPatternSrcFunction:function(){return String(this.getPatternSrc).replace("this.color",'"'+this.color+'"')},getPattern:function(c){return c.createPattern(this.source||this.getPatternSrc(),"repeat")},_setBrushStyles:function(c){this.callSuper("_setBrushStyles",c),c.strokeStyle=this.getPattern(c)},createPath:function(c){var i=this.callSuper("createPath",c),a=i._getLeftTopCoords().scalarAdd(i.strokeWidth/2);return i.stroke=new u.Pattern({source:this.source||this.getPatternSrcFunction(),offsetX:-a.x,offsetY:-a.y}),i}});(function(){var c=u.util.getPointer,i=u.util.degreesToRadians,a=u.util.isTouchEvent;u.Canvas=u.util.createClass(u.StaticCanvas,{initialize:function(t,r){r||(r={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(t,r),this._initInteractive(),this._createCacheCanvas()},uniformScaling:!0,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",interactive:!0,selection:!0,selectionKey:"shiftKey",altSelectionKey:null,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",containerClass:"canvas-container",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,isDrawingMode:!1,preserveObjectStacking:!1,snapAngle:0,snapThreshold:null,stopContextMenu:!1,fireRightClick:!1,fireMiddleClick:!1,targets:[],enablePointerEvents:!1,_hoveredTarget:null,_hoveredTargets:[],_initInteractive:function(){this._currentTransform=null,this._groupSelector=null,this._initWrapperElement(),this._createUpperCanvas(),this._initEventListeners(),this._initRetinaScaling(),this.freeDrawingBrush=u.PencilBrush&&new u.PencilBrush(this),this.calcOffset()},_chooseObjectsToRender:function(){var t=this.getActiveObjects(),r,e,s;if(t.length>0&&!this.preserveObjectStacking){e=[],s=[];for(var h=0,n=this._objects.length;h<n;h++)r=this._objects[h],t.indexOf(r)===-1?e.push(r):s.push(r);t.length>1&&(this._activeObject._objects=s),e.push.apply(e,s)}else e=this._objects;return e},renderAll:function(){this.contextTopDirty&&!this._groupSelector&&!this.isDrawingMode&&(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1);var t=this.contextContainer;return this.renderCanvas(t,this._chooseObjectsToRender()),this},renderTopLayer:function(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()},renderTop:function(){var t=this.contextTop;return this.clearContext(t),this.renderTopLayer(t),this.fire("after:render"),this},_normalizePointer:function(t,r){var e=t.calcTransformMatrix(),s=u.util.invertTransform(e),h=this.restorePointerVpt(r);return u.util.transformPoint(h,s)},isTargetTransparent:function(t,r,e){if(t.shouldCache()&&t._cacheCanvas&&t!==this._activeObject){var s=this._normalizePointer(t,{x:r,y:e}),h=Math.max(t.cacheTranslationX+s.x*t.zoomX,0),n=Math.max(t.cacheTranslationY+s.y*t.zoomY,0),g=u.util.isTransparent(t._cacheContext,Math.round(h),Math.round(n),this.targetFindTolerance);return g}var l=this.contextCache,f=t.selectionBackgroundColor,d=this.viewportTransform;t.selectionBackgroundColor="",this.clearContext(l),l.save(),l.transform(d[0],d[1],d[2],d[3],d[4],d[5]),t.render(l),l.restore(),t.selectionBackgroundColor=f;var g=u.util.isTransparent(l,r,e,this.targetFindTolerance);return g},_isSelectionKeyPressed:function(t){var r=!1;return Object.prototype.toString.call(this.selectionKey)==="[object Array]"?r=!!this.selectionKey.find(function(e){return t[e]===!0}):r=t[this.selectionKey],r},_shouldClearSelection:function(t,r){var e=this.getActiveObjects(),s=this._activeObject;return!r||r&&s&&e.length>1&&e.indexOf(r)===-1&&s!==r&&!this._isSelectionKeyPressed(t)||r&&!r.evented||r&&!r.selectable&&s&&s!==r},_shouldCenterTransform:function(t,r,e){if(t){var s;return r==="scale"||r==="scaleX"||r==="scaleY"||r==="resizing"?s=this.centeredScaling||t.centeredScaling:r==="rotate"&&(s=this.centeredRotation||t.centeredRotation),s?!e:e}},_getOriginFromCorner:function(t,r){var e={x:t.originX,y:t.originY};return r==="ml"||r==="tl"||r==="bl"?e.x="right":(r==="mr"||r==="tr"||r==="br")&&(e.x="left"),r==="tl"||r==="mt"||r==="tr"?e.y="bottom":(r==="bl"||r==="mb"||r==="br")&&(e.y="top"),e},_getActionFromCorner:function(t,r,e,s){if(!r||!t)return"drag";var h=s.controls[r];return h.getActionName(e,h,s)},_setupCurrentTransform:function(t,r,e){if(r){var s=this.getPointer(t),h=r.__corner,n=r.controls[h],l=e&&h?n.getActionHandler(t,r,n):u.controlsUtils.dragHandler,f=this._getActionFromCorner(e,h,t,r),d=this._getOriginFromCorner(r,h),g=t[this.centeredKey],m={target:r,action:f,actionHandler:l,corner:h,scaleX:r.scaleX,scaleY:r.scaleY,skewX:r.skewX,skewY:r.skewY,offsetX:s.x-r.left,offsetY:s.y-r.top,originX:d.x,originY:d.y,ex:s.x,ey:s.y,lastX:s.x,lastY:s.y,theta:i(r.angle),width:r.width*r.scaleX,shiftKey:t.shiftKey,altKey:g,original:u.util.saveObjectTransform(r)};this._shouldCenterTransform(r,f,g)&&(m.originX="center",m.originY="center"),m.original.originX=d.x,m.original.originY=d.y,this._currentTransform=m,this._beforeTransform(t)}},setCursor:function(t){this.upperCanvasEl.style.cursor=t},_drawSelection:function(t){var r=this._groupSelector,e=new u.Point(r.ex,r.ey),s=u.util.transformPoint(e,this.viewportTransform),h=new u.Point(r.ex+r.left,r.ey+r.top),n=u.util.transformPoint(h,this.viewportTransform),l=Math.min(s.x,n.x),f=Math.min(s.y,n.y),d=Math.max(s.x,n.x),g=Math.max(s.y,n.y),m=this.selectionLineWidth/2;this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(l,f,d-l,g-f)),!(!this.selectionLineWidth||!this.selectionBorderColor)&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,l+=m,f+=m,d-=m,g-=m,u.Object.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(l,f,d-l,g-f))},findTarget:function(t,r){if(!this.skipTargetFind){var e=!0,s=this.getPointer(t,e),h=this._activeObject,n=this.getActiveObjects(),l,f,d=a(t),g=n.length>1&&!r||n.length===1;if(this.targets=[],g&&h._findTargetCorner(s,d)||n.length>1&&!r&&h===this._searchPossibleTargets([h],s))return h;if(n.length===1&&h===this._searchPossibleTargets([h],s))if(this.preserveObjectStacking)l=h,f=this.targets,this.targets=[];else return h;var m=this._searchPossibleTargets(this._objects,s);return t[this.altSelectionKey]&&m&&l&&m!==l&&(m=l,this.targets=f),m}},_checkTarget:function(t,r,e){if(r&&r.visible&&r.evented&&r.containsPoint(t))if((this.perPixelTargetFind||r.perPixelTargetFind)&&!r.isEditing){var s=this.isTargetTransparent(r,e.x,e.y);if(!s)return!0}else return!0},_searchPossibleTargets:function(t,r){for(var e,s=t.length,h;s--;){var n=t[s],l=n.group?this._normalizePointer(n.group,r):r;if(this._checkTarget(l,n,r)){e=t[s],e.subTargetCheck&&e instanceof u.Group&&(h=this._searchPossibleTargets(e._objects,r),h&&this.targets.push(h));break}}return e},restorePointerVpt:function(t){return u.util.transformPoint(t,u.util.invertTransform(this.viewportTransform))},getPointer:function(t,r){if(this._absolutePointer&&!r)return this._absolutePointer;if(this._pointer&&r)return this._pointer;var e=c(t),s=this.upperCanvasEl,h=s.getBoundingClientRect(),n=h.width||0,l=h.height||0,f;(!n||!l)&&("top"in h&&"bottom"in h&&(l=Math.abs(h.top-h.bottom)),"right"in h&&"left"in h&&(n=Math.abs(h.right-h.left))),this.calcOffset(),e.x=e.x-this._offset.left,e.y=e.y-this._offset.top,r||(e=this.restorePointerVpt(e));var d=this.getRetinaScaling();return d!==1&&(e.x/=d,e.y/=d),n===0||l===0?f={width:1,height:1}:f={width:s.width/n,height:s.height/l},{x:e.x*f.width,y:e.y*f.height}},_createUpperCanvas:function(){var t=this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/,""),r=this.lowerCanvasEl,e=this.upperCanvasEl;e?e.className="":(e=this._createCanvasElement(),this.upperCanvasEl=e),u.util.addClass(e,"upper-canvas "+t),this.wrapperEl.appendChild(e),this._copyCanvasStyle(r,e),this._applyCanvasStyle(e),this.contextTop=e.getContext("2d")},_createCacheCanvas:function(){this.cacheCanvasEl=this._createCanvasElement(),this.cacheCanvasEl.setAttribute("width",this.width),this.cacheCanvasEl.setAttribute("height",this.height),this.contextCache=this.cacheCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=u.util.wrapElement(this.lowerCanvasEl,"div",{class:this.containerClass}),u.util.setStyle(this.wrapperEl,{width:this.width+"px",height:this.height+"px",position:"relative"}),u.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(t){var r=this.width||t.width,e=this.height||t.height;u.util.setStyle(t,{position:"absolute",width:r+"px",height:e+"px",left:0,top:0,"touch-action":this.allowTouchScrolling?"manipulation":"none","-ms-touch-action":this.allowTouchScrolling?"manipulation":"none"}),t.width=r,t.height=e,u.util.makeElementUnselectable(t)},_copyCanvasStyle:function(t,r){r.style.cssText=t.style.cssText},getSelectionContext:function(){return this.contextTop},getSelectionElement:function(){return this.upperCanvasEl},getActiveObject:function(){return this._activeObject},getActiveObjects:function(){var t=this._activeObject;return t?t.type==="activeSelection"&&t._objects?t._objects.slice(0):[t]:[]},_onObjectRemoved:function(t){t===this._activeObject&&(this.fire("before:selection:cleared",{target:t}),this._discardActiveObject(),this.fire("selection:cleared",{target:t}),t.fire("deselected")),t===this._hoveredTarget&&(this._hoveredTarget=null,this._hoveredTargets=[]),this.callSuper("_onObjectRemoved",t)},_fireSelectionEvents:function(t,r){var e=!1,s=this.getActiveObjects(),h=[],n=[];t.forEach(function(l){s.indexOf(l)===-1&&(e=!0,l.fire("deselected",{e:r,target:l}),n.push(l))}),s.forEach(function(l){t.indexOf(l)===-1&&(e=!0,l.fire("selected",{e:r,target:l}),h.push(l))}),t.length>0&&s.length>0?e&&this.fire("selection:updated",{e:r,selected:h,deselected:n}):s.length>0?this.fire("selection:created",{e:r,selected:h}):t.length>0&&this.fire("selection:cleared",{e:r,deselected:n})},setActiveObject:function(t,r){var e=this.getActiveObjects();return this._setActiveObject(t,r),this._fireSelectionEvents(e,r),this},_setActiveObject:function(t,r){return this._activeObject===t||!this._discardActiveObject(r,t)||t.onSelect({e:r})?!1:(this._activeObject=t,!0)},_discardActiveObject:function(t,r){var e=this._activeObject;if(e){if(e.onDeselect({e:t,object:r}))return!1;this._activeObject=null}return!0},discardActiveObject:function(t){var r=this.getActiveObjects(),e=this.getActiveObject();return r.length&&this.fire("before:selection:cleared",{target:e,e:t}),this._discardActiveObject(t),this._fireSelectionEvents(r,t),this},dispose:function(){var t=this.wrapperEl;return this.removeListeners(),t.removeChild(this.upperCanvasEl),t.removeChild(this.lowerCanvasEl),this.contextCache=null,this.contextTop=null,["upperCanvasEl","cacheCanvasEl"].forEach(function(r){u.util.cleanUpJsdomNode(this[r]),this[r]=void 0}.bind(this)),t.parentNode&&t.parentNode.replaceChild(this.lowerCanvasEl,this.wrapperEl),delete this.wrapperEl,u.StaticCanvas.prototype.dispose.call(this),this},clear:function(){return this.discardActiveObject(),this.clearContext(this.contextTop),this.callSuper("clear")},drawControls:function(t){var r=this._activeObject;r&&r._renderControls(t)},_toObject:function(t,r,e){var s=this._realizeGroupTransformOnObject(t),h=this.callSuper("_toObject",t,r,e);return this._unwindGroupTransformOnObject(t,s),h},_realizeGroupTransformOnObject:function(t){if(t.group&&t.group.type==="activeSelection"&&this._activeObject===t.group){var r=["angle","flipX","flipY","left","scaleX","scaleY","skewX","skewY","top"],e={};return r.forEach(function(s){e[s]=t[s]}),u.util.addTransformToObject(t,this._activeObject.calcOwnMatrix()),e}else return null},_unwindGroupTransformOnObject:function(t,r){r&&t.set(r)},_setSVGObject:function(t,r,e){var s=this._realizeGroupTransformOnObject(r);this.callSuper("_setSVGObject",t,r,e),this._unwindGroupTransformOnObject(r,s)},setViewportTransform:function(t){this.renderOnAddRemove&&this._activeObject&&this._activeObject.isEditing&&this._activeObject.clearContextTop(),u.StaticCanvas.prototype.setViewportTransform.call(this,t)}});for(var o in u.StaticCanvas)o!=="prototype"&&(u.Canvas[o]=u.StaticCanvas[o])})();(function(){var c=u.util.addListener,i=u.util.removeListener,a=3,o=2,t=1,r={passive:!1};function e(s,h){return s.button&&s.button===h-1}u.util.object.extend(u.Canvas.prototype,{mainTouchId:null,_initEventListeners:function(){this.removeListeners(),this._bindEvents(),this.addOrRemove(c,"add")},_getEventPrefix:function(){return this.enablePointerEvents?"pointer":"mouse"},addOrRemove:function(s,h){var n=this.upperCanvasEl,l=this._getEventPrefix();s(u.window,"resize",this._onResize),s(n,l+"down",this._onMouseDown),s(n,l+"move",this._onMouseMove,r),s(n,l+"out",this._onMouseOut),s(n,l+"enter",this._onMouseEnter),s(n,"wheel",this._onMouseWheel),s(n,"contextmenu",this._onContextMenu),s(n,"dblclick",this._onDoubleClick),s(n,"dragover",this._onDragOver),s(n,"dragenter",this._onDragEnter),s(n,"dragleave",this._onDragLeave),s(n,"drop",this._onDrop),this.enablePointerEvents||s(n,"touchstart",this._onTouchStart,r),typeof eventjs!="undefined"&&h in eventjs&&(eventjs[h](n,"gesture",this._onGesture),eventjs[h](n,"drag",this._onDrag),eventjs[h](n,"orientation",this._onOrientationChange),eventjs[h](n,"shake",this._onShake),eventjs[h](n,"longpress",this._onLongPress))},removeListeners:function(){this.addOrRemove(i,"remove");var s=this._getEventPrefix();i(u.document,s+"up",this._onMouseUp),i(u.document,"touchend",this._onTouchEnd,r),i(u.document,s+"move",this._onMouseMove,r),i(u.document,"touchmove",this._onMouseMove,r)},_bindEvents:function(){this.eventsBound||(this._onMouseDown=this._onMouseDown.bind(this),this._onTouchStart=this._onTouchStart.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onResize=this._onResize.bind(this),this._onGesture=this._onGesture.bind(this),this._onDrag=this._onDrag.bind(this),this._onShake=this._onShake.bind(this),this._onLongPress=this._onLongPress.bind(this),this._onOrientationChange=this._onOrientationChange.bind(this),this._onMouseWheel=this._onMouseWheel.bind(this),this._onMouseOut=this._onMouseOut.bind(this),this._onMouseEnter=this._onMouseEnter.bind(this),this._onContextMenu=this._onContextMenu.bind(this),this._onDoubleClick=this._onDoubleClick.bind(this),this._onDragOver=this._onDragOver.bind(this),this._onDragEnter=this._simpleEventHandler.bind(this,"dragenter"),this._onDragLeave=this._simpleEventHandler.bind(this,"dragleave"),this._onDrop=this._onDrop.bind(this),this.eventsBound=!0)},_onGesture:function(s,h){this.__onTransformGesture&&this.__onTransformGesture(s,h)},_onDrag:function(s,h){this.__onDrag&&this.__onDrag(s,h)},_onMouseWheel:function(s){this.__onMouseWheel(s)},_onMouseOut:function(s){var h=this._hoveredTarget;this.fire("mouse:out",{target:h,e:s}),this._hoveredTarget=null,h&&h.fire("mouseout",{e:s});var n=this;this._hoveredTargets.forEach(function(l){n.fire("mouse:out",{target:h,e:s}),l&&h.fire("mouseout",{e:s})}),this._hoveredTargets=[],this._iTextInstances&&this._iTextInstances.forEach(function(l){l.isEditing&&l.hiddenTextarea.focus()})},_onMouseEnter:function(s){!this._currentTransform&&!this.findTarget(s)&&(this.fire("mouse:over",{target:null,e:s}),this._hoveredTarget=null,this._hoveredTargets=[])},_onOrientationChange:function(s,h){this.__onOrientationChange&&this.__onOrientationChange(s,h)},_onShake:function(s,h){this.__onShake&&this.__onShake(s,h)},_onLongPress:function(s,h){this.__onLongPress&&this.__onLongPress(s,h)},_onDragOver:function(s){s.preventDefault();var h=this._simpleEventHandler("dragover",s);this._fireEnterLeaveEvents(h,s)},_onDrop:function(s){return this._simpleEventHandler("drop:before",s),this._simpleEventHandler("drop",s)},_onContextMenu:function(s){return this.stopContextMenu&&(s.stopPropagation(),s.preventDefault()),!1},_onDoubleClick:function(s){this._cacheTransformEventData(s),this._handleEvent(s,"dblclick"),this._resetTransformEventData(s)},getPointerId:function(s){var h=s.changedTouches;return h?h[0]&&h[0].identifier:this.enablePointerEvents?s.pointerId:-1},_isMainEvent:function(s){return s.isPrimary===!0?!0:s.isPrimary===!1?!1:s.type==="touchend"&&s.touches.length===0?!0:s.changedTouches?s.changedTouches[0].identifier===this.mainTouchId:!0},_onTouchStart:function(s){s.preventDefault(),this.mainTouchId===null&&(this.mainTouchId=this.getPointerId(s)),this.__onMouseDown(s),this._resetTransformEventData();var h=this.upperCanvasEl,n=this._getEventPrefix();c(u.document,"touchend",this._onTouchEnd,r),c(u.document,"touchmove",this._onMouseMove,r),i(h,n+"down",this._onMouseDown)},_onMouseDown:function(s){this.__onMouseDown(s),this._resetTransformEventData();var h=this.upperCanvasEl,n=this._getEventPrefix();i(h,n+"move",this._onMouseMove,r),c(u.document,n+"up",this._onMouseUp),c(u.document,n+"move",this._onMouseMove,r)},_onTouchEnd:function(s){if(!(s.touches.length>0)){this.__onMouseUp(s),this._resetTransformEventData(),this.mainTouchId=null;var h=this._getEventPrefix();i(u.document,"touchend",this._onTouchEnd,r),i(u.document,"touchmove",this._onMouseMove,r);var n=this;this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(function(){c(n.upperCanvasEl,h+"down",n._onMouseDown),n._willAddMouseDown=0},400)}},_onMouseUp:function(s){this.__onMouseUp(s),this._resetTransformEventData();var h=this.upperCanvasEl,n=this._getEventPrefix();this._isMainEvent(s)&&(i(u.document,n+"up",this._onMouseUp),i(u.document,n+"move",this._onMouseMove,r),c(h,n+"move",this._onMouseMove,r))},_onMouseMove:function(s){!this.allowTouchScrolling&&s.preventDefault&&s.preventDefault(),this.__onMouseMove(s)},_onResize:function(){this.calcOffset()},_shouldRender:function(s){var h=this._activeObject;return!!h!=!!s||h&&s&&h!==s?!0:(h&&h.isEditing,!1)},__onMouseUp:function(s){var h,n=this._currentTransform,l=this._groupSelector,f=!1,d=!l||l.left===0&&l.top===0;if(this._cacheTransformEventData(s),h=this._target,this._handleEvent(s,"up:before"),e(s,a)){this.fireRightClick&&this._handleEvent(s,"up",a,d);return}if(e(s,o)){this.fireMiddleClick&&this._handleEvent(s,"up",o,d),this._resetTransformEventData();return}if(this.isDrawingMode&&this._isCurrentlyDrawing){this._onMouseUpInDrawingMode(s);return}if(this._isMainEvent(s)){if(n&&(this._finalizeCurrentTransform(s),f=n.actionPerformed),!d){var g=h===this._activeObject;this._maybeGroupObjects(s),f||(f=this._shouldRender(h)||!g&&h===this._activeObject)}var m,p;if(h){if(m=h._findTargetCorner(this.getPointer(s,!0),u.util.isTouchEvent(s)),h.selectable&&h!==this._activeObject&&h.activeOn==="up")this.setActiveObject(h,s),f=!0;else{var _=h.controls[m],w=_&&_.getMouseUpHandler(s,h,_);w&&(p=this.getPointer(s),w(s,n,p.x,p.y))}h.isMoving=!1}if(n&&(n.target!==h||n.corner!==m)){var D=n.target&&n.target.controls[n.corner],B=D&&D.getMouseUpHandler(s,h,_);p=p||this.getPointer(s),B&&B(s,n,p.x,p.y)}this._setCursorFromEvent(s,h),this._handleEvent(s,"up",t,d),this._groupSelector=null,this._currentTransform=null,h&&(h.__corner=0),f?this.requestRenderAll():d||this.renderTop()}},_simpleEventHandler:function(s,h){var n=this.findTarget(h),l=this.targets,f={e:h,target:n,subTargets:l};if(this.fire(s,f),n&&n.fire(s,f),!l)return n;for(var d=0;d<l.length;d++)l[d].fire(s,f);return n},_handleEvent:function(s,h,n,l){var f=this._target,d=this.targets||[],g={e:s,target:f,subTargets:d,button:n||t,isClick:l||!1,pointer:this._pointer,absolutePointer:this._absolutePointer,transform:this._currentTransform};h==="up"&&(g.currentTarget=this.findTarget(s),g.currentSubTargets=this.targets),this.fire("mouse:"+h,g),f&&f.fire("mouse"+h,g);for(var m=0;m<d.length;m++)d[m].fire("mouse"+h,g)},_finalizeCurrentTransform:function(s){var h=this._currentTransform,n=h.target,l={e:s,target:n,transform:h,action:h.action};n._scaling&&(n._scaling=!1),n.setCoords(),(h.actionPerformed||this.stateful&&n.hasStateChanged())&&this._fire("modified",l)},_onMouseDownInDrawingMode:function(s){this._isCurrentlyDrawing=!0,this.getActiveObject()&&this.discardActiveObject(s).requestRenderAll();var h=this.getPointer(s);this.freeDrawingBrush.onMouseDown(h,{e:s,pointer:h}),this._handleEvent(s,"down")},_onMouseMoveInDrawingMode:function(s){if(this._isCurrentlyDrawing){var h=this.getPointer(s);this.freeDrawingBrush.onMouseMove(h,{e:s,pointer:h})}this.setCursor(this.freeDrawingCursor),this._handleEvent(s,"move")},_onMouseUpInDrawingMode:function(s){var h=this.getPointer(s);this._isCurrentlyDrawing=this.freeDrawingBrush.onMouseUp({e:s,pointer:h}),this._handleEvent(s,"up")},__onMouseDown:function(s){this._cacheTransformEventData(s),this._handleEvent(s,"down:before");var h=this._target;if(e(s,a)){this.fireRightClick&&this._handleEvent(s,"down",a);return}if(e(s,o)){this.fireMiddleClick&&this._handleEvent(s,"down",o);return}if(this.isDrawingMode){this._onMouseDownInDrawingMode(s);return}if(this._isMainEvent(s)&&!this._currentTransform){var n=this._pointer;this._previousPointer=n;var l=this._shouldRender(h),f=this._shouldGroup(s,h);if(this._shouldClearSelection(s,h)?this.discardActiveObject(s):f&&(this._handleGrouping(s,h),h=this._activeObject),this.selection&&(!h||!h.selectable&&!h.isEditing&&h!==this._activeObject)&&(this._groupSelector={ex:this._absolutePointer.x,ey:this._absolutePointer.y,top:0,left:0}),h){var d=h===this._activeObject;h.selectable&&h.activeOn==="down"&&this.setActiveObject(h,s);var g=h._findTargetCorner(this.getPointer(s,!0),u.util.isTouchEvent(s));if(h.__corner=g,h===this._activeObject&&(g||!f)){this._setupCurrentTransform(s,h,d);var m=h.controls[g],n=this.getPointer(s),p=m&&m.getMouseDownHandler(s,h,m);p&&p(s,this._currentTransform,n.x,n.y)}}this._handleEvent(s,"down"),(l||f)&&this.requestRenderAll()}},_resetTransformEventData:function(){this._target=null,this._pointer=null,this._absolutePointer=null},_cacheTransformEventData:function(s){this._resetTransformEventData(),this._pointer=this.getPointer(s,!0),this._absolutePointer=this.restorePointerVpt(this._pointer),this._target=this._currentTransform?this._currentTransform.target:this.findTarget(s)||null},_beforeTransform:function(s){var h=this._currentTransform;this.stateful&&h.target.saveState(),this.fire("before:transform",{e:s,transform:h})},__onMouseMove:function(s){this._handleEvent(s,"move:before"),this._cacheTransformEventData(s);var h,n;if(this.isDrawingMode){this._onMouseMoveInDrawingMode(s);return}if(this._isMainEvent(s)){var l=this._groupSelector;l?(n=this._absolutePointer,l.left=n.x-l.ex,l.top=n.y-l.ey,this.renderTop()):this._currentTransform?this._transformObject(s):(h=this.findTarget(s)||null,this._setCursorFromEvent(s,h),this._fireOverOutEvents(h,s)),this._handleEvent(s,"move"),this._resetTransformEventData()}},_fireOverOutEvents:function(s,h){var n=this._hoveredTarget,l=this._hoveredTargets,f=this.targets,d=Math.max(l.length,f.length);this.fireSyntheticInOutEvents(s,h,{oldTarget:n,evtOut:"mouseout",canvasEvtOut:"mouse:out",evtIn:"mouseover",canvasEvtIn:"mouse:over"});for(var g=0;g<d;g++)this.fireSyntheticInOutEvents(f[g],h,{oldTarget:l[g],evtOut:"mouseout",evtIn:"mouseover"});this._hoveredTarget=s,this._hoveredTargets=this.targets.concat()},_fireEnterLeaveEvents:function(s,h){var n=this._draggedoverTarget,l=this._hoveredTargets,f=this.targets,d=Math.max(l.length,f.length);this.fireSyntheticInOutEvents(s,h,{oldTarget:n,evtOut:"dragleave",evtIn:"dragenter"});for(var g=0;g<d;g++)this.fireSyntheticInOutEvents(f[g],h,{oldTarget:l[g],evtOut:"dragleave",evtIn:"dragenter"});this._draggedoverTarget=s},fireSyntheticInOutEvents:function(s,h,n){var l,f,d=n.oldTarget,g,m,p=d!==s,_=n.canvasEvtIn,w=n.canvasEvtOut;p&&(l={e:h,target:s,previousTarget:d},f={e:h,target:d,nextTarget:s}),m=s&&p,g=d&&p,g&&(w&&this.fire(w,f),d.fire(n.evtOut,f)),m&&(_&&this.fire(_,l),s.fire(n.evtIn,l))},__onMouseWheel:function(s){this._cacheTransformEventData(s),this._handleEvent(s,"wheel"),this._resetTransformEventData()},_transformObject:function(s){var h=this.getPointer(s),n=this._currentTransform;n.reset=!1,n.shiftKey=s.shiftKey,n.altKey=s[this.centeredKey],this._performTransformAction(s,n,h),n.actionPerformed&&this.requestRenderAll()},_performTransformAction:function(s,h,n){var l=n.x,f=n.y,d=h.action,g=!1,m=h.actionHandler;m&&(g=m(s,h,l,f)),d==="drag"&&g&&(h.target.isMoving=!0,this.setCursor(h.target.moveCursor||this.moveCursor)),h.actionPerformed=h.actionPerformed||g},_fire:u.controlsUtils.fireEvent,_setCursorFromEvent:function(s,h){if(!h)return this.setCursor(this.defaultCursor),!1;var n=h.hoverCursor||this.hoverCursor,l=this._activeObject&&this._activeObject.type==="activeSelection"?this._activeObject:null,f=(!l||!l.contains(h))&&h._findTargetCorner(this.getPointer(s,!0));f?this.setCursor(this.getCornerCursor(f,h,s)):(h.subTargetCheck&&this.targets.concat().reverse().map(function(d){n=d.hoverCursor||n}),this.setCursor(n))},getCornerCursor:function(s,h,n){var l=h.controls[s];return l.cursorStyleHandler(n,l,h)}})})();(function(){var c=Math.min,i=Math.max;u.util.object.extend(u.Canvas.prototype,{_shouldGroup:function(a,o){var t=this._activeObject;return t&&this._isSelectionKeyPressed(a)&&o&&o.selectable&&this.selection&&(t!==o||t.type==="activeSelection")&&!o.onSelect({e:a})},_handleGrouping:function(a,o){var t=this._activeObject;t.__corner||o===t&&(o=this.findTarget(a,!0),!o||!o.selectable)||(t&&t.type==="activeSelection"?this._updateActiveSelection(o,a):this._createActiveSelection(o,a))},_updateActiveSelection:function(a,o){var t=this._activeObject,r=t._objects.slice(0);t.contains(a)?(t.removeWithUpdate(a),this._hoveredTarget=a,this._hoveredTargets=this.targets.concat(),t.size()===1&&this._setActiveObject(t.item(0),o)):(t.addWithUpdate(a),this._hoveredTarget=t,this._hoveredTargets=this.targets.concat()),this._fireSelectionEvents(r,o)},_createActiveSelection:function(a,o){var t=this.getActiveObjects(),r=this._createGroup(a);this._hoveredTarget=r,this._setActiveObject(r,o),this._fireSelectionEvents(t,o)},_createGroup:function(a){var o=this._objects,t=o.indexOf(this._activeObject)<o.indexOf(a),r=t?[this._activeObject,a]:[a,this._activeObject];return this._activeObject.isEditing&&this._activeObject.exitEditing(),new u.ActiveSelection(r,{canvas:this})},_groupSelectedObjects:function(a){var o=this._collectObjects(a),t;o.length===1?this.setActiveObject(o[0],a):o.length>1&&(t=new u.ActiveSelection(o.reverse(),{canvas:this}),this.setActiveObject(t,a))},_collectObjects:function(a){for(var o=[],t,r=this._groupSelector.ex,e=this._groupSelector.ey,s=r+this._groupSelector.left,h=e+this._groupSelector.top,n=new u.Point(c(r,s),c(e,h)),l=new u.Point(i(r,s),i(e,h)),f=!this.selectionFullyContained,d=r===s&&e===h,g=this._objects.length;g--&&(t=this._objects[g],!(!(!t||!t.selectable||!t.visible)&&(f&&t.intersectsWithRect(n,l,!0)||t.isContainedWithinRect(n,l,!0)||f&&t.containsPoint(n,null,!0)||f&&t.containsPoint(l,null,!0))&&(o.push(t),d))););return o.length>1&&(o=o.filter(function(m){return!m.onSelect({e:a})})),o},_maybeGroupObjects:function(a){this.selection&&this._groupSelector&&this._groupSelectedObjects(a),this.setCursor(this.defaultCursor),this._groupSelector=null}})})();(function(){u.util.object.extend(u.StaticCanvas.prototype,{toDataURL:function(c){c||(c={});var i=c.format||"png",a=c.quality||1,o=(c.multiplier||1)*(c.enableRetinaScaling?this.getRetinaScaling():1),t=this.toCanvasElement(o,c);return u.util.toDataURL(t,i,a)},toCanvasElement:function(c,i){c=c||1,i=i||{};var a=(i.width||this.width)*c,o=(i.height||this.height)*c,t=this.getZoom(),r=this.width,e=this.height,s=t*c,h=this.viewportTransform,n=(h[4]-(i.left||0))*c,l=(h[5]-(i.top||0))*c,f=this.interactive,d=[s,0,0,s,n,l],g=this.enableRetinaScaling,m=u.util.createCanvasElement(),p=this.contextTop;return m.width=a,m.height=o,this.contextTop=null,this.enableRetinaScaling=!1,this.interactive=!1,this.viewportTransform=d,this.width=a,this.height=o,this.calcViewportBoundaries(),this.renderCanvas(m.getContext("2d"),this._objects),this.viewportTransform=h,this.width=r,this.height=e,this.calcViewportBoundaries(),this.interactive=f,this.enableRetinaScaling=g,this.contextTop=p,m}})})();u.util.object.extend(u.StaticCanvas.prototype,{loadFromJSON:function(c,i,a){if(c){var o=typeof c=="string"?JSON.parse(c):u.util.object.clone(c),t=this,r=o.clipPath,e=this.renderOnAddRemove;return this.renderOnAddRemove=!1,delete o.clipPath,this._enlivenObjects(o.objects,function(s){t.clear(),t._setBgOverlay(o,function(){r?t._enlivenObjects([r],function(h){t.clipPath=h[0],t.__setupCanvas.call(t,o,s,e,i)}):t.__setupCanvas.call(t,o,s,e,i)})},a),this}},__setupCanvas:function(c,i,a,o){var t=this;i.forEach(function(r,e){t.insertAt(r,e)}),this.renderOnAddRemove=a,delete c.objects,delete c.backgroundImage,delete c.overlayImage,delete c.background,delete c.overlay,this._setOptions(c),this.renderAll(),o&&o()},_setBgOverlay:function(c,i){var a={backgroundColor:!1,overlayColor:!1,backgroundImage:!1,overlayImage:!1};if(!c.backgroundImage&&!c.overlayImage&&!c.background&&!c.overlay){i&&i();return}var o=function(){a.backgroundImage&&a.overlayImage&&a.backgroundColor&&a.overlayColor&&i&&i()};this.__setBgOverlay("backgroundImage",c.backgroundImage,a,o),this.__setBgOverlay("overlayImage",c.overlayImage,a,o),this.__setBgOverlay("backgroundColor",c.background,a,o),this.__setBgOverlay("overlayColor",c.overlay,a,o)},__setBgOverlay:function(c,i,a,o){var t=this;if(!i){a[c]=!0,o&&o();return}c==="backgroundImage"||c==="overlayImage"?u.util.enlivenObjects([i],function(r){t[c]=r[0],a[c]=!0,o&&o()}):this["set"+u.util.string.capitalize(c,!0)](i,function(){a[c]=!0,o&&o()})},_enlivenObjects:function(c,i,a){if(!c||c.length===0){i&&i([]);return}u.util.enlivenObjects(c,function(o){i&&i(o)},null,a)},_toDataURL:function(c,i){this.clone(function(a){i(a.toDataURL(c))})},_toDataURLWithMultiplier:function(c,i,a){this.clone(function(o){a(o.toDataURLWithMultiplier(c,i))})},clone:function(c,i){var a=JSON.stringify(this.toJSON(i));this.cloneWithoutData(function(o){o.loadFromJSON(a,function(){c&&c(o)})})},cloneWithoutData:function(c){var i=u.util.createCanvasElement();i.width=this.width,i.height=this.height;var a=new u.Canvas(i);this.backgroundImage?(a.setBackgroundImage(this.backgroundImage.src,function(){a.renderAll(),c&&c(a)}),a.backgroundImageOpacity=this.backgroundImageOpacity,a.backgroundImageStretch=this.backgroundImageStretch):c&&c(a)}});(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.util.object.extend,o=i.util.object.clone,t=i.util.toFixed,r=i.util.string.capitalize,e=i.util.degreesToRadians,s=!i.isLikelyNode,h=2;i.Object||(i.Object=i.util.createClass(i.CommonMethods,{type:"object",originX:"left",originY:"top",top:0,left:0,width:0,height:0,scaleX:1,scaleY:1,flipX:!1,flipY:!1,opacity:1,angle:0,skewX:0,skewY:0,cornerSize:13,touchCornerSize:24,transparentCorners:!0,hoverCursor:null,moveCursor:null,padding:0,borderColor:"rgb(178,204,255)",borderDashArray:null,cornerColor:"rgb(178,204,255)",cornerStrokeColor:null,cornerStyle:"rect",cornerDashArray:null,centeredScaling:!1,centeredRotation:!0,fill:"rgb(0,0,0)",fillRule:"nonzero",globalCompositeOperation:"source-over",backgroundColor:"",selectionBackgroundColor:"",stroke:null,strokeWidth:1,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,shadow:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,minScaleLimit:0,selectable:!0,evented:!0,visible:!0,hasControls:!0,hasBorders:!0,perPixelTargetFind:!1,includeDefaultValues:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,excludeFromExport:!1,objectCaching:s,statefullCache:!1,noScaleCache:!0,strokeUniform:!1,dirty:!0,__corner:0,paintFirst:"fill",activeOn:"down",stateProperties:"top left width height scaleX scaleY flipX flipY originX originY transformMatrix stroke strokeWidth strokeDashArray strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit angle opacity fill globalCompositeOperation shadow visible backgroundColor skewX skewY fillRule paintFirst clipPath strokeUniform".split(" "),cacheProperties:"fill stroke strokeWidth strokeDashArray width height paintFirst strokeUniform strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit backgroundColor clipPath".split(" "),colorProperties:"fill stroke backgroundColor".split(" "),clipPath:void 0,inverted:!1,absolutePositioned:!1,initialize:function(n){n&&this.setOptions(n)},_createCacheCanvas:function(){this._cacheProperties={},this._cacheCanvas=i.util.createCanvasElement(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0},_limitCacheSize:function(n){var l=i.perfLimitSizeTotal,f=n.width,d=n.height,g=i.maxCacheSideLimit,m=i.minCacheSideLimit;if(f<=g&&d<=g&&f*d<=l)return f<m&&(n.width=m),d<m&&(n.height=m),n;var p=f/d,_=i.util.limitDimsByArea(p,l),w=i.util.capValue,D=w(m,_.x,g),B=w(m,_.y,g);return f>D&&(n.zoomX/=f/D,n.width=D,n.capped=!0),d>B&&(n.zoomY/=d/B,n.height=B,n.capped=!0),n},_getCacheCanvasDimensions:function(){var n=this.getTotalObjectScaling(),l=this._getTransformedDimensions(0,0),f=l.x*n.scaleX/this.scaleX,d=l.y*n.scaleY/this.scaleY;return{width:f+h,height:d+h,zoomX:n.scaleX,zoomY:n.scaleY,x:f,y:d}},_updateCacheCanvas:function(){var n=this.canvas;if(this.noScaleCache&&n&&n._currentTransform){var l=n._currentTransform.target,f=n._currentTransform.action;if(this===l&&f.slice&&f.slice(0,5)==="scale")return!1}var d=this._cacheCanvas,g=this._limitCacheSize(this._getCacheCanvasDimensions()),m=i.minCacheSideLimit,p=g.width,_=g.height,w,D,B=g.zoomX,N=g.zoomY,G=p!==this.cacheWidth||_!==this.cacheHeight,z=this.zoomX!==B||this.zoomY!==N,H=G||z,U=0,K=0,Q=!1;if(G){var J=this._cacheCanvas.width,v=this._cacheCanvas.height,b=p>J||_>v,S=(p<J*.9||_<v*.9)&&J>m&&v>m;Q=b||S,b&&!g.capped&&(p>m||_>m)&&(U=p*.1,K=_*.1)}return this instanceof i.Text&&this.path&&(H=!0,Q=!0,U+=this.getHeightOfLine(0)*this.zoomX,K+=this.getHeightOfLine(0)*this.zoomY),H?(Q?(d.width=Math.ceil(p+U),d.height=Math.ceil(_+K)):(this._cacheContext.setTransform(1,0,0,1,0,0),this._cacheContext.clearRect(0,0,d.width,d.height)),w=g.x/2,D=g.y/2,this.cacheTranslationX=Math.round(d.width/2-w)+w,this.cacheTranslationY=Math.round(d.height/2-D)+D,this.cacheWidth=p,this.cacheHeight=_,this._cacheContext.translate(this.cacheTranslationX,this.cacheTranslationY),this._cacheContext.scale(B,N),this.zoomX=B,this.zoomY=N,!0):!1},setOptions:function(n){this._setOptions(n),this._initGradient(n.fill,"fill"),this._initGradient(n.stroke,"stroke"),this._initPattern(n.fill,"fill"),this._initPattern(n.stroke,"stroke")},transform:function(n){var l=this.group&&!this.group._transformDone||this.group&&this.canvas&&n===this.canvas.contextTop,f=this.calcTransformMatrix(!l);n.transform(f[0],f[1],f[2],f[3],f[4],f[5])},toObject:function(n){var l=i.Object.NUM_FRACTION_DIGITS,f={type:this.type,version:i.version,originX:this.originX,originY:this.originY,left:t(this.left,l),top:t(this.top,l),width:t(this.width,l),height:t(this.height,l),fill:this.fill&&this.fill.toObject?this.fill.toObject():this.fill,stroke:this.stroke&&this.stroke.toObject?this.stroke.toObject():this.stroke,strokeWidth:t(this.strokeWidth,l),strokeDashArray:this.strokeDashArray?this.strokeDashArray.concat():this.strokeDashArray,strokeLineCap:this.strokeLineCap,strokeDashOffset:this.strokeDashOffset,strokeLineJoin:this.strokeLineJoin,strokeUniform:this.strokeUniform,strokeMiterLimit:t(this.strokeMiterLimit,l),scaleX:t(this.scaleX,l),scaleY:t(this.scaleY,l),angle:t(this.angle,l),flipX:this.flipX,flipY:this.flipY,opacity:t(this.opacity,l),shadow:this.shadow&&this.shadow.toObject?this.shadow.toObject():this.shadow,visible:this.visible,backgroundColor:this.backgroundColor,fillRule:this.fillRule,paintFirst:this.paintFirst,globalCompositeOperation:this.globalCompositeOperation,skewX:t(this.skewX,l),skewY:t(this.skewY,l)};return this.clipPath&&!this.clipPath.excludeFromExport&&(f.clipPath=this.clipPath.toObject(n),f.clipPath.inverted=this.clipPath.inverted,f.clipPath.absolutePositioned=this.clipPath.absolutePositioned),i.util.populateWithProperties(this,f,n),this.includeDefaultValues||(f=this._removeDefaultValues(f)),f},toDatalessObject:function(n){return this.toObject(n)},_removeDefaultValues:function(n){var l=i.util.getKlass(n.type).prototype,f=l.stateProperties;return f.forEach(function(d){if(!(d==="left"||d==="top")){n[d]===l[d]&&delete n[d];var g=Object.prototype.toString.call(n[d])==="[object Array]"&&Object.prototype.toString.call(l[d])==="[object Array]";g&&n[d].length===0&&l[d].length===0&&delete n[d]}}),n},toString:function(){return"#<fabric."+r(this.type)+">"},getObjectScaling:function(){if(!this.group)return{scaleX:this.scaleX,scaleY:this.scaleY};var n=i.util.qrDecompose(this.calcTransformMatrix());return{scaleX:Math.abs(n.scaleX),scaleY:Math.abs(n.scaleY)}},getTotalObjectScaling:function(){var n=this.getObjectScaling(),l=n.scaleX,f=n.scaleY;if(this.canvas){var d=this.canvas.getZoom(),g=this.canvas.getRetinaScaling();l*=d*g,f*=d*g}return{scaleX:l,scaleY:f}},getObjectOpacity:function(){var n=this.opacity;return this.group&&(n*=this.group.getObjectOpacity()),n},_set:function(n,l){var f=n==="scaleX"||n==="scaleY",d=this[n]!==l,g=!1;return f&&(l=this._constrainScale(l)),n==="scaleX"&&l<0?(this.flipX=!this.flipX,l*=-1):n==="scaleY"&&l<0?(this.flipY=!this.flipY,l*=-1):n==="shadow"&&l&&!(l instanceof i.Shadow)?l=new i.Shadow(l):n==="dirty"&&this.group&&this.group.set("dirty",l),this[n]=l,d&&(g=this.group&&this.group.isOnACache(),this.cacheProperties.indexOf(n)>-1?(this.dirty=!0,g&&this.group.set("dirty",!0)):g&&this.stateProperties.indexOf(n)>-1&&this.group.set("dirty",!0)),this},setOnGroup:function(){},getViewportTransform:function(){return this.canvas&&this.canvas.viewportTransform?this.canvas.viewportTransform:i.iMatrix.concat()},isNotVisible:function(){return this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible},render:function(n){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(n.save(),this._setupCompositeOperation(n),this.drawSelectionBackground(n),this.transform(n),this._setOpacity(n),this._setShadow(n,this),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(n)):(this._removeCacheCanvas(),this.dirty=!1,this.drawObject(n),this.objectCaching&&this.statefullCache&&this.saveState({propertySet:"cacheProperties"})),n.restore())},renderCache:function(n){n=n||{},this._cacheCanvas||this._createCacheCanvas(),this.isCacheDirty()&&(this.statefullCache&&this.saveState({propertySet:"cacheProperties"}),this.drawObject(this._cacheContext,n.forClipping),this.dirty=!1)},_removeCacheCanvas:function(){this._cacheCanvas=null,this.cacheWidth=0,this.cacheHeight=0},hasStroke:function(){return this.stroke&&this.stroke!=="transparent"&&this.strokeWidth!==0},hasFill:function(){return this.fill&&this.fill!=="transparent"},needsItsOwnCache:function(){return!!(this.paintFirst==="stroke"&&this.hasFill()&&this.hasStroke()&&typeof this.shadow=="object"||this.clipPath)},shouldCache:function(){return this.ownCaching=this.needsItsOwnCache()||this.objectCaching&&(!this.group||!this.group.isOnACache()),this.ownCaching},willDrawShadow:function(){return!!this.shadow&&(this.shadow.offsetX!==0||this.shadow.offsetY!==0)},drawClipPathOnCache:function(n,l){if(n.save(),l.inverted?n.globalCompositeOperation="destination-out":n.globalCompositeOperation="destination-in",l.absolutePositioned){var f=i.util.invertTransform(this.calcTransformMatrix());n.transform(f[0],f[1],f[2],f[3],f[4],f[5])}l.transform(n),n.scale(1/l.zoomX,1/l.zoomY),n.drawImage(l._cacheCanvas,-l.cacheTranslationX,-l.cacheTranslationY),n.restore()},drawObject:function(n,l){var f=this.fill,d=this.stroke;l?(this.fill="black",this.stroke="",this._setClippingProperties(n)):this._renderBackground(n),this._render(n),this._drawClipPath(n,this.clipPath),this.fill=f,this.stroke=d},_drawClipPath:function(n,l){l&&(l.canvas=this.canvas,l.shouldCache(),l._transformDone=!0,l.renderCache({forClipping:!0}),this.drawClipPathOnCache(n,l))},drawCacheOnCanvas:function(n){n.scale(1/this.zoomX,1/this.zoomY),n.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)},isCacheDirty:function(n){if(this.isNotVisible())return!1;if(this._cacheCanvas&&!n&&this._updateCacheCanvas())return!0;if(this.dirty||this.clipPath&&this.clipPath.absolutePositioned||this.statefullCache&&this.hasStateChanged("cacheProperties")){if(this._cacheCanvas&&!n){var l=this.cacheWidth/this.zoomX,f=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-l/2,-f/2,l,f)}return!0}return!1},_renderBackground:function(n){if(this.backgroundColor){var l=this._getNonTransformedDimensions();n.fillStyle=this.backgroundColor,n.fillRect(-l.x/2,-l.y/2,l.x,l.y),this._removeShadow(n)}},_setOpacity:function(n){this.group&&!this.group._transformDone?n.globalAlpha=this.getObjectOpacity():n.globalAlpha*=this.opacity},_setStrokeStyles:function(n,l){var f=l.stroke;f&&(n.lineWidth=l.strokeWidth,n.lineCap=l.strokeLineCap,n.lineDashOffset=l.strokeDashOffset,n.lineJoin=l.strokeLineJoin,n.miterLimit=l.strokeMiterLimit,f.toLive?f.gradientUnits==="percentage"||f.gradientTransform||f.patternTransform?this._applyPatternForTransformedGradient(n,f):(n.strokeStyle=f.toLive(n,this),this._applyPatternGradientTransform(n,f)):n.strokeStyle=l.stroke)},_setFillStyles:function(n,l){var f=l.fill;f&&(f.toLive?(n.fillStyle=f.toLive(n,this),this._applyPatternGradientTransform(n,l.fill)):n.fillStyle=f)},_setClippingProperties:function(n){n.globalAlpha=1,n.strokeStyle="transparent",n.fillStyle="#000000"},_setLineDash:function(n,l){!l||l.length===0||(1&l.length&&l.push.apply(l,l),n.setLineDash(l))},_renderControls:function(n,l){var f=this.getViewportTransform(),d=this.calcTransformMatrix(),g,m,p;l=l||{},m=typeof l.hasBorders!="undefined"?l.hasBorders:this.hasBorders,p=typeof l.hasControls!="undefined"?l.hasControls:this.hasControls,d=i.util.multiplyTransformMatrices(f,d),g=i.util.qrDecompose(d),n.save(),n.translate(g.translateX,g.translateY),n.lineWidth=1*this.borderScaleFactor,this.group||(n.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(g.angle-=180),n.rotate(e(this.group?g.angle:this.angle)),l.forActiveSelection||this.group?m&&this.drawBordersInGroup(n,g,l):m&&this.drawBorders(n,l),p&&this.drawControls(n,l),n.restore()},_setShadow:function(n){if(this.shadow){var l=this.shadow,f=this.canvas,d,g=f&&f.viewportTransform[0]||1,m=f&&f.viewportTransform[3]||1;l.nonScaling?d={scaleX:1,scaleY:1}:d=this.getObjectScaling(),f&&f._isRetinaScaling()&&(g*=i.devicePixelRatio,m*=i.devicePixelRatio),n.shadowColor=l.color,n.shadowBlur=l.blur*i.browserShadowBlurConstant*(g+m)*(d.scaleX+d.scaleY)/4,n.shadowOffsetX=l.offsetX*g*d.scaleX,n.shadowOffsetY=l.offsetY*m*d.scaleY}},_removeShadow:function(n){this.shadow&&(n.shadowColor="",n.shadowBlur=n.shadowOffsetX=n.shadowOffsetY=0)},_applyPatternGradientTransform:function(n,l){if(!l||!l.toLive)return{offsetX:0,offsetY:0};var f=l.gradientTransform||l.patternTransform,d=-this.width/2+l.offsetX||0,g=-this.height/2+l.offsetY||0;return l.gradientUnits==="percentage"?n.transform(this.width,0,0,this.height,d,g):n.transform(1,0,0,1,d,g),f&&n.transform(f[0],f[1],f[2],f[3],f[4],f[5]),{offsetX:d,offsetY:g}},_renderPaintInOrder:function(n){this.paintFirst==="stroke"?(this._renderStroke(n),this._renderFill(n)):(this._renderFill(n),this._renderStroke(n))},_render:function(){},_renderFill:function(n){this.fill&&(n.save(),this._setFillStyles(n,this),this.fillRule==="evenodd"?n.fill("evenodd"):n.fill(),n.restore())},_renderStroke:function(n){if(!(!this.stroke||this.strokeWidth===0)){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(n),n.save(),this.strokeUniform&&this.group){var l=this.getObjectScaling();n.scale(1/l.scaleX,1/l.scaleY)}else this.strokeUniform&&n.scale(1/this.scaleX,1/this.scaleY);this._setLineDash(n,this.strokeDashArray),this._setStrokeStyles(n,this),n.stroke(),n.restore()}},_applyPatternForTransformedGradient:function(n,l){var f=this._limitCacheSize(this._getCacheCanvasDimensions()),d=i.util.createCanvasElement(),g,m=this.canvas.getRetinaScaling(),p=f.x/this.scaleX/m,_=f.y/this.scaleY/m;d.width=p,d.height=_,g=d.getContext("2d"),g.beginPath(),g.moveTo(0,0),g.lineTo(p,0),g.lineTo(p,_),g.lineTo(0,_),g.closePath(),g.translate(p/2,_/2),g.scale(f.zoomX/this.scaleX/m,f.zoomY/this.scaleY/m),this._applyPatternGradientTransform(g,l),g.fillStyle=l.toLive(n),g.fill(),n.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),n.scale(m*this.scaleX/f.zoomX,m*this.scaleY/f.zoomY),n.strokeStyle=g.createPattern(d,"no-repeat")},_findCenterFromElement:function(){return{x:this.left+this.width/2,y:this.top+this.height/2}},_assignTransformMatrixProps:function(){if(this.transformMatrix){var n=i.util.qrDecompose(this.transformMatrix);this.flipX=!1,this.flipY=!1,this.set("scaleX",n.scaleX),this.set("scaleY",n.scaleY),this.angle=n.angle,this.skewX=n.skewX,this.skewY=0}},_removeTransformMatrix:function(n){var l=this._findCenterFromElement();this.transformMatrix&&(this._assignTransformMatrixProps(),l=i.util.transformPoint(l,this.transformMatrix)),this.transformMatrix=null,n&&(this.scaleX*=n.scaleX,this.scaleY*=n.scaleY,this.cropX=n.cropX,this.cropY=n.cropY,l.x+=n.offsetLeft,l.y+=n.offsetTop,this.width=n.width,this.height=n.height),this.setPositionByOrigin(l,"center","center")},clone:function(n,l){var f=this.toObject(l);this.constructor.fromObject?this.constructor.fromObject(f,n):i.Object._fromObject("Object",f,n)},cloneAsImage:function(n,l){var f=this.toCanvasElement(l);return n&&n(new i.Image(f)),this},toCanvasElement:function(n){n||(n={});var l=i.util,f=l.saveObjectTransform(this),d=this.group,g=this.shadow,m=Math.abs,p=(n.multiplier||1)*(n.enableRetinaScaling?i.devicePixelRatio:1);delete this.group,n.withoutTransform&&l.resetObjectTransform(this),n.withoutShadow&&(this.shadow=null);var _=i.util.createCanvasElement(),w=this.getBoundingRect(!0,!0),D=this.shadow,B,N={x:0,y:0},G,z,H;D&&(G=D.blur,D.nonScaling?B={scaleX:1,scaleY:1}:B=this.getObjectScaling(),N.x=2*Math.round(m(D.offsetX)+G)*m(B.scaleX),N.y=2*Math.round(m(D.offsetY)+G)*m(B.scaleY)),z=w.width+N.x,H=w.height+N.y,_.width=Math.ceil(z),_.height=Math.ceil(H);var U=new i.StaticCanvas(_,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1});n.format==="jpeg"&&(U.backgroundColor="#fff"),this.setPositionByOrigin(new i.Point(U.width/2,U.height/2),"center","center");var K=this.canvas;U.add(this);var Q=U.toCanvasElement(p||1,n);return this.shadow=g,this.set("canvas",K),d&&(this.group=d),this.set(f).setCoords(),U._objects=[],U.dispose(),U=null,Q},toDataURL:function(n){return n||(n={}),i.util.toDataURL(this.toCanvasElement(n),n.format||"png",n.quality||1)},isType:function(n){return this.type===n},complexity:function(){return 1},toJSON:function(n){return this.toObject(n)},rotate:function(n){var l=(this.originX!=="center"||this.originY!=="center")&&this.centeredRotation;return l&&this._setOriginToCenter(),this.set("angle",n),l&&this._resetOrigin(),this},centerH:function(){return this.canvas&&this.canvas.centerObjectH(this),this},viewportCenterH:function(){return this.canvas&&this.canvas.viewportCenterObjectH(this),this},centerV:function(){return this.canvas&&this.canvas.centerObjectV(this),this},viewportCenterV:function(){return this.canvas&&this.canvas.viewportCenterObjectV(this),this},center:function(){return this.canvas&&this.canvas.centerObject(this),this},viewportCenter:function(){return this.canvas&&this.canvas.viewportCenterObject(this),this},getLocalPointer:function(n,l){l=l||this.canvas.getPointer(n);var f=new i.Point(l.x,l.y),d=this._getLeftTopCoords();return this.angle&&(f=i.util.rotatePoint(f,d,e(-this.angle))),{x:f.x-d.x,y:f.y-d.y}},_setupCompositeOperation:function(n){this.globalCompositeOperation&&(n.globalCompositeOperation=this.globalCompositeOperation)},dispose:function(){i.runningAnimations&&i.runningAnimations.cancelByTarget(this)}}),i.util.createAccessors&&i.util.createAccessors(i.Object),a(i.Object.prototype,i.Observable),i.Object.NUM_FRACTION_DIGITS=2,i.Object.ENLIVEN_PROPS=["clipPath"],i.Object._fromObject=function(n,l,f,d){var g=i[n];l=o(l,!0),i.util.enlivenPatterns([l.fill,l.stroke],function(m){typeof m[0]!="undefined"&&(l.fill=m[0]),typeof m[1]!="undefined"&&(l.stroke=m[1]),i.util.enlivenObjectEnlivables(l,l,function(){var p=d?new g(l[d],l):new g(l);f&&f(p)})})},i.Object.__uid=0)})(F);(function(){var c=u.util.degreesToRadians,i={left:-.5,center:0,right:.5},a={top:-.5,center:0,bottom:.5};u.util.object.extend(u.Object.prototype,{translateToGivenOrigin:function(o,t,r,e,s){var h=o.x,n=o.y,l,f,d;return typeof t=="string"?t=i[t]:t-=.5,typeof e=="string"?e=i[e]:e-=.5,l=e-t,typeof r=="string"?r=a[r]:r-=.5,typeof s=="string"?s=a[s]:s-=.5,f=s-r,(l||f)&&(d=this._getTransformedDimensions(),h=o.x+l*d.x,n=o.y+f*d.y),new u.Point(h,n)},translateToCenterPoint:function(o,t,r){var e=this.translateToGivenOrigin(o,t,r,"center","center");return this.angle?u.util.rotatePoint(e,o,c(this.angle)):e},translateToOriginPoint:function(o,t,r){var e=this.translateToGivenOrigin(o,"center","center",t,r);return this.angle?u.util.rotatePoint(e,o,c(this.angle)):e},getCenterPoint:function(){var o=new u.Point(this.left,this.top);return this.translateToCenterPoint(o,this.originX,this.originY)},getPointByOrigin:function(o,t){var r=this.getCenterPoint();return this.translateToOriginPoint(r,o,t)},toLocalPoint:function(o,t,r){var e=this.getCenterPoint(),s,h;return typeof t!="undefined"&&typeof r!="undefined"?s=this.translateToGivenOrigin(e,"center","center",t,r):s=new u.Point(this.left,this.top),h=new u.Point(o.x,o.y),this.angle&&(h=u.util.rotatePoint(h,e,-c(this.angle))),h.subtractEquals(s)},setPositionByOrigin:function(o,t,r){var e=this.translateToCenterPoint(o,t,r),s=this.translateToOriginPoint(e,this.originX,this.originY);this.set("left",s.x),this.set("top",s.y)},adjustPosition:function(o){var t=c(this.angle),r=this.getScaledWidth(),e=u.util.cos(t)*r,s=u.util.sin(t)*r,h,n;typeof this.originX=="string"?h=i[this.originX]:h=this.originX-.5,typeof o=="string"?n=i[o]:n=o-.5,this.left+=e*(n-h),this.top+=s*(n-h),this.setCoords(),this.originX=o},_setOriginToCenter:function(){this._originalOriginX=this.originX,this._originalOriginY=this.originY;var o=this.getCenterPoint();this.originX="center",this.originY="center",this.left=o.x,this.top=o.y},_resetOrigin:function(){var o=this.translateToOriginPoint(this.getCenterPoint(),this._originalOriginX,this._originalOriginY);this.originX=this._originalOriginX,this.originY=this._originalOriginY,this.left=o.x,this.top=o.y,this._originalOriginX=null,this._originalOriginY=null},_getLeftTopCoords:function(){return this.translateToOriginPoint(this.getCenterPoint(),"left","top")}})})();(function(){function c(r){return[new u.Point(r.tl.x,r.tl.y),new u.Point(r.tr.x,r.tr.y),new u.Point(r.br.x,r.br.y),new u.Point(r.bl.x,r.bl.y)]}var i=u.util,a=i.degreesToRadians,o=i.multiplyTransformMatrices,t=i.transformPoint;i.object.extend(u.Object.prototype,{oCoords:null,aCoords:null,lineCoords:null,ownMatrixCache:null,matrixCache:null,controls:{},_getCoords:function(r,e){return e?r?this.calcACoords():this.calcLineCoords():((!this.aCoords||!this.lineCoords)&&this.setCoords(!0),r?this.aCoords:this.lineCoords)},getCoords:function(r,e){return c(this._getCoords(r,e))},intersectsWithRect:function(r,e,s,h){var n=this.getCoords(s,h),l=u.Intersection.intersectPolygonRectangle(n,r,e);return l.status==="Intersection"},intersectsWithObject:function(r,e,s){var h=u.Intersection.intersectPolygonPolygon(this.getCoords(e,s),r.getCoords(e,s));return h.status==="Intersection"||r.isContainedWithinObject(this,e,s)||this.isContainedWithinObject(r,e,s)},isContainedWithinObject:function(r,e,s){for(var h=this.getCoords(e,s),n=e?r.aCoords:r.lineCoords,l=0,f=r._getImageLines(n);l<4;l++)if(!r.containsPoint(h[l],f))return!1;return!0},isContainedWithinRect:function(r,e,s,h){var n=this.getBoundingRect(s,h);return n.left>=r.x&&n.left+n.width<=e.x&&n.top>=r.y&&n.top+n.height<=e.y},containsPoint:function(r,l,s,h){var n=this._getCoords(s,h),l=l||this._getImageLines(n),f=this._findCrossPoints(r,l);return f!==0&&f%2===1},isOnScreen:function(r){if(!this.canvas)return!1;var e=this.canvas.vptCoords.tl,s=this.canvas.vptCoords.br,h=this.getCoords(!0,r);return h.some(function(n){return n.x<=s.x&&n.x>=e.x&&n.y<=s.y&&n.y>=e.y})||this.intersectsWithRect(e,s,!0,r)?!0:this._containsCenterOfCanvas(e,s,r)},_containsCenterOfCanvas:function(r,e,s){var h={x:(r.x+e.x)/2,y:(r.y+e.y)/2};return!!this.containsPoint(h,null,!0,s)},isPartiallyOnScreen:function(r){if(!this.canvas)return!1;var e=this.canvas.vptCoords.tl,s=this.canvas.vptCoords.br;if(this.intersectsWithRect(e,s,!0,r))return!0;var h=this.getCoords(!0,r).every(function(n){return(n.x>=s.x||n.x<=e.x)&&(n.y>=s.y||n.y<=e.y)});return h&&this._containsCenterOfCanvas(e,s,r)},_getImageLines:function(r){var e={topline:{o:r.tl,d:r.tr},rightline:{o:r.tr,d:r.br},bottomline:{o:r.br,d:r.bl},leftline:{o:r.bl,d:r.tl}};return e},_findCrossPoints:function(r,e){var s,h,n,l,f,d=0,g;for(var m in e)if(g=e[m],!(g.o.y<r.y&&g.d.y<r.y)&&!(g.o.y>=r.y&&g.d.y>=r.y)&&(g.o.x===g.d.x&&g.o.x>=r.x?f=g.o.x:(s=0,h=(g.d.y-g.o.y)/(g.d.x-g.o.x),n=r.y-s*r.x,l=g.o.y-h*g.o.x,f=-(n-l)/(s-h)),f>=r.x&&(d+=1),d===2))break;return d},getBoundingRect:function(r,e){var s=this.getCoords(r,e);return i.makeBoundingBoxFromPoints(s)},getScaledWidth:function(){return this._getTransformedDimensions().x},getScaledHeight:function(){return this._getTransformedDimensions().y},_constrainScale:function(r){return Math.abs(r)<this.minScaleLimit?r<0?-this.minScaleLimit:this.minScaleLimit:r===0?1e-4:r},scale:function(r){return this._set("scaleX",r),this._set("scaleY",r),this.setCoords()},scaleToWidth:function(r,e){var s=this.getBoundingRect(e).width/this.getScaledWidth();return this.scale(r/this.width/s)},scaleToHeight:function(r,e){var s=this.getBoundingRect(e).height/this.getScaledHeight();return this.scale(r/this.height/s)},calcLineCoords:function(){var r=this.getViewportTransform(),e=this.padding,s=a(this.angle),h=i.cos(s),n=i.sin(s),l=h*e,f=n*e,d=l+f,g=l-f,m=this.calcACoords(),p={tl:t(m.tl,r),tr:t(m.tr,r),bl:t(m.bl,r),br:t(m.br,r)};return e&&(p.tl.x-=g,p.tl.y-=d,p.tr.x+=d,p.tr.y-=g,p.bl.x-=d,p.bl.y+=g,p.br.x+=g,p.br.y+=d),p},calcOCoords:function(){var r=this._calcRotateMatrix(),e=this._calcTranslateMatrix(),s=this.getViewportTransform(),h=o(s,e),n=o(h,r),n=o(n,[1/s[0],0,0,1/s[3],0,0]),l=this._calculateCurrentDimensions(),f={};return this.forEachControl(function(d,g,m){f[g]=d.positionHandler(l,n,m)}),f},calcACoords:function(){var r=this._calcRotateMatrix(),e=this._calcTranslateMatrix(),s=o(e,r),h=this._getTransformedDimensions(),n=h.x/2,l=h.y/2;return{tl:t({x:-n,y:-l},s),tr:t({x:n,y:-l},s),bl:t({x:-n,y:l},s),br:t({x:n,y:l},s)}},setCoords:function(r){return this.aCoords=this.calcACoords(),this.lineCoords=this.group?this.aCoords:this.calcLineCoords(),r?this:(this.oCoords=this.calcOCoords(),this._setCornerCoords&&this._setCornerCoords(),this)},_calcRotateMatrix:function(){return i.calcRotateMatrix(this)},_calcTranslateMatrix:function(){var r=this.getCenterPoint();return[1,0,0,1,r.x,r.y]},transformMatrixKey:function(r){var e="_",s="";return!r&&this.group&&(s=this.group.transformMatrixKey(r)+e),s+this.top+e+this.left+e+this.scaleX+e+this.scaleY+e+this.skewX+e+this.skewY+e+this.angle+e+this.originX+e+this.originY+e+this.width+e+this.height+e+this.strokeWidth+this.flipX+this.flipY},calcTransformMatrix:function(r){var e=this.calcOwnMatrix();if(r||!this.group)return e;var s=this.transformMatrixKey(r),h=this.matrixCache||(this.matrixCache={});return h.key===s?h.value:(this.group&&(e=o(this.group.calcTransformMatrix(!1),e)),h.key=s,h.value=e,e)},calcOwnMatrix:function(){var r=this.transformMatrixKey(!0),e=this.ownMatrixCache||(this.ownMatrixCache={});if(e.key===r)return e.value;var s=this._calcTranslateMatrix(),h={angle:this.angle,translateX:s[4],translateY:s[5],scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY};return e.key=r,e.value=i.composeMatrix(h),e.value},_getNonTransformedDimensions:function(){var r=this.strokeWidth,e=this.width+r,s=this.height+r;return{x:e,y:s}},_getTransformedDimensions:function(r,e){typeof r=="undefined"&&(r=this.skewX),typeof e=="undefined"&&(e=this.skewY);var s,h,n,l=r===0&&e===0;if(this.strokeUniform?(h=this.width,n=this.height):(s=this._getNonTransformedDimensions(),h=s.x,n=s.y),l)return this._finalizeDimensions(h*this.scaleX,n*this.scaleY);var f=i.sizeAfterTransform(h,n,{scaleX:this.scaleX,scaleY:this.scaleY,skewX:r,skewY:e});return this._finalizeDimensions(f.x,f.y)},_finalizeDimensions:function(r,e){return this.strokeUniform?{x:r+this.strokeWidth,y:e+this.strokeWidth}:{x:r,y:e}},_calculateCurrentDimensions:function(){var r=this.getViewportTransform(),e=this._getTransformedDimensions(),s=t(e,r,!0);return s.scalarAdd(2*this.padding)}})})();u.util.object.extend(u.Object.prototype,{sendToBack:function(){return this.group?u.StaticCanvas.prototype.sendToBack.call(this.group,this):this.canvas&&this.canvas.sendToBack(this),this},bringToFront:function(){return this.group?u.StaticCanvas.prototype.bringToFront.call(this.group,this):this.canvas&&this.canvas.bringToFront(this),this},sendBackwards:function(c){return this.group?u.StaticCanvas.prototype.sendBackwards.call(this.group,this,c):this.canvas&&this.canvas.sendBackwards(this,c),this},bringForward:function(c){return this.group?u.StaticCanvas.prototype.bringForward.call(this.group,this,c):this.canvas&&this.canvas.bringForward(this,c),this},moveTo:function(c){return this.group&&this.group.type!=="activeSelection"?u.StaticCanvas.prototype.moveTo.call(this.group,this,c):this.canvas&&this.canvas.moveTo(this,c),this}});(function(){function c(a,o){if(o){if(o.toLive)return a+": url(#SVGID_"+o.id+"); ";var t=new u.Color(o),r=a+": "+t.toRgb()+"; ",e=t.getAlpha();return e!==1&&(r+=a+"-opacity: "+e.toString()+"; "),r}else return a+": none; "}var i=u.util.toFixed;u.util.object.extend(u.Object.prototype,{getSvgStyles:function(a){var o=this.fillRule?this.fillRule:"nonzero",t=this.strokeWidth?this.strokeWidth:"0",r=this.strokeDashArray?this.strokeDashArray.join(" "):"none",e=this.strokeDashOffset?this.strokeDashOffset:"0",s=this.strokeLineCap?this.strokeLineCap:"butt",h=this.strokeLineJoin?this.strokeLineJoin:"miter",n=this.strokeMiterLimit?this.strokeMiterLimit:"4",l=typeof this.opacity!="undefined"?this.opacity:"1",f=this.visible?"":" visibility: hidden;",d=a?"":this.getSvgFilter(),g=c("fill",this.fill),m=c("stroke",this.stroke);return[m,"stroke-width: ",t,"; ","stroke-dasharray: ",r,"; ","stroke-linecap: ",s,"; ","stroke-dashoffset: ",e,"; ","stroke-linejoin: ",h,"; ","stroke-miterlimit: ",n,"; ",g,"fill-rule: ",o,"; ","opacity: ",l,";",d,f].join("")},getSvgSpanStyles:function(a,o){var t="; ",e=a.fontFamily?"font-family: "+(a.fontFamily.indexOf("'")===-1&&a.fontFamily.indexOf('"')===-1?"'"+a.fontFamily+"'":a.fontFamily)+t:"",r=a.strokeWidth?"stroke-width: "+a.strokeWidth+t:"",e=e,s=a.fontSize?"font-size: "+a.fontSize+"px"+t:"",h=a.fontStyle?"font-style: "+a.fontStyle+t:"",n=a.fontWeight?"font-weight: "+a.fontWeight+t:"",l=a.fill?c("fill",a.fill):"",f=a.stroke?c("stroke",a.stroke):"",d=this.getSvgTextDecoration(a),g=a.deltaY?"baseline-shift: "+-a.deltaY+"; ":"";return d&&(d="text-decoration: "+d+t),[f,r,e,s,h,n,d,l,g,o?"white-space: pre; ":""].join("")},getSvgTextDecoration:function(a){return["overline","underline","line-through"].filter(function(o){return a[o.replace("-","")]}).join(" ")},getSvgFilter:function(){return this.shadow?"filter: url(#SVGID_"+this.shadow.id+");":""},getSvgCommons:function(){return[this.id?'id="'+this.id+'" ':"",this.clipPath?'clip-path="url(#'+this.clipPath.clipPathId+')" ':""].join("")},getSvgTransform:function(a,o){var t=a?this.calcTransformMatrix():this.calcOwnMatrix(),r='transform="'+u.util.matrixToSVG(t);return r+(o||"")+'" '},_setSVGBg:function(a){if(this.backgroundColor){var o=u.Object.NUM_FRACTION_DIGITS;a.push(" <rect ",this._getFillAttributes(this.backgroundColor),' x="',i(-this.width/2,o),'" y="',i(-this.height/2,o),'" width="',i(this.width,o),'" height="',i(this.height,o),`"></rect>
|
|
48
|
+
`)}},toSVG:function(a){return this._createBaseSVGMarkup(this._toSVG(a),{reviver:a})},toClipPathSVG:function(a){return" "+this._createBaseClipPathSVGMarkup(this._toSVG(a),{reviver:a})},_createBaseClipPathSVGMarkup:function(a,o){o=o||{};var t=o.reviver,r=o.additionalTransform||"",e=[this.getSvgTransform(!0,r),this.getSvgCommons()].join(""),s=a.indexOf("COMMON_PARTS");return a[s]=e,t?t(a.join("")):a.join("")},_createBaseSVGMarkup:function(a,o){o=o||{};var t=o.noStyle,r=o.reviver,e=t?"":'style="'+this.getSvgStyles()+'" ',s=o.withShadow?'style="'+this.getSvgFilter()+'" ':"",h=this.clipPath,n=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",l=h&&h.absolutePositioned,f=this.stroke,d=this.fill,g=this.shadow,m,p=[],_,w=a.indexOf("COMMON_PARTS"),D=o.additionalTransform;return h&&(h.clipPathId="CLIPPATH_"+u.Object.__uid++,_='<clipPath id="'+h.clipPathId+`" >
|
|
49
|
+
`+h.toClipPathSVG(r)+`</clipPath>
|
|
50
|
+
`),l&&p.push("<g ",s,this.getSvgCommons(),` >
|
|
51
|
+
`),p.push("<g ",this.getSvgTransform(!1),l?"":s+this.getSvgCommons(),` >
|
|
52
|
+
`),m=[e,n,t?"":this.addPaintOrder()," ",D?'transform="'+D+'" ':""].join(""),a[w]=m,d&&d.toLive&&p.push(d.toSVG(this)),f&&f.toLive&&p.push(f.toSVG(this)),g&&p.push(g.toSVG(this)),h&&p.push(_),p.push(a.join("")),p.push(`</g>
|
|
53
|
+
`),l&&p.push(`</g>
|
|
54
|
+
`),r?r(p.join("")):p.join("")},addPaintOrder:function(){return this.paintFirst!=="fill"?' paint-order="'+this.paintFirst+'" ':""}})})();(function(){var c=u.util.object.extend,i="stateProperties";function a(t,r,e){var s={},h=!0;e.forEach(function(n){s[n]=t[n]}),c(t[r],s,h)}function o(t,r,e){if(t===r)return!0;if(Array.isArray(t)){if(!Array.isArray(r)||t.length!==r.length)return!1;for(var s=0,h=t.length;s<h;s++)if(!o(t[s],r[s]))return!1;return!0}else if(t&&typeof t=="object"){var n=Object.keys(t),l;if(!r||typeof r!="object"||!e&&n.length!==Object.keys(r).length)return!1;for(var s=0,h=n.length;s<h;s++)if(l=n[s],!(l==="canvas"||l==="group")&&!o(t[l],r[l]))return!1;return!0}}u.util.object.extend(u.Object.prototype,{hasStateChanged:function(t){t=t||i;var r="_"+t;return Object.keys(this[r]).length<this[t].length?!0:!o(this[r],this,!0)},saveState:function(t){var r=t&&t.propertySet||i,e="_"+r;return this[e]?(a(this,e,this[r]),t&&t.stateProperties&&a(this,e,t.stateProperties),this):this.setupState(t)},setupState:function(t){t=t||{};var r=t.propertySet||i;return t.propertySet=r,this["_"+r]={},this.saveState(t),this}})})();(function(){var c=u.util.degreesToRadians;u.util.object.extend(u.Object.prototype,{_findTargetCorner:function(i,a){if(!this.hasControls||this.group||!this.canvas||this.canvas._activeObject!==this)return!1;var o=i.x,t=i.y,r,e,s=Object.keys(this.oCoords),h=s.length-1,n;for(this.__corner=0;h>=0;h--)if(n=s[h],!!this.isControlVisible(n)&&(e=this._getImageLines(a?this.oCoords[n].touchCorner:this.oCoords[n].corner),r=this._findCrossPoints({x:o,y:t},e),r!==0&&r%2===1))return this.__corner=n,n;return!1},forEachControl:function(i){for(var a in this.controls)i(this.controls[a],a,this)},_setCornerCoords:function(){var i=this.oCoords;for(var a in i){var o=this.controls[a];i[a].corner=o.calcCornerCoords(this.angle,this.cornerSize,i[a].x,i[a].y,!1),i[a].touchCorner=o.calcCornerCoords(this.angle,this.touchCornerSize,i[a].x,i[a].y,!0)}},drawSelectionBackground:function(i){if(!this.selectionBackgroundColor||this.canvas&&!this.canvas.interactive||this.canvas&&this.canvas._activeObject!==this)return this;i.save();var a=this.getCenterPoint(),o=this._calculateCurrentDimensions(),t=this.canvas.viewportTransform;return i.translate(a.x,a.y),i.scale(1/t[0],1/t[3]),i.rotate(c(this.angle)),i.fillStyle=this.selectionBackgroundColor,i.fillRect(-o.x/2,-o.y/2,o.x,o.y),i.restore(),this},drawBorders:function(i,a){a=a||{};var o=this._calculateCurrentDimensions(),t=this.borderScaleFactor,r=o.x+t,e=o.y+t,s=typeof a.hasControls!="undefined"?a.hasControls:this.hasControls,h=!1;return i.save(),i.strokeStyle=a.borderColor||this.borderColor,this._setLineDash(i,a.borderDashArray||this.borderDashArray),i.strokeRect(-r/2,-e/2,r,e),s&&(i.beginPath(),this.forEachControl(function(n,l,f){n.withConnection&&n.getVisibility(f,l)&&(h=!0,i.moveTo(n.x*r,n.y*e),i.lineTo(n.x*r+n.offsetX,n.y*e+n.offsetY))}),h&&i.stroke()),i.restore(),this},drawBordersInGroup:function(i,a,o){o=o||{};var t=u.util.sizeAfterTransform(this.width,this.height,a),r=this.strokeWidth,e=this.strokeUniform,s=this.borderScaleFactor,h=t.x+r*(e?this.canvas.getZoom():a.scaleX)+s,n=t.y+r*(e?this.canvas.getZoom():a.scaleY)+s;return i.save(),this._setLineDash(i,o.borderDashArray||this.borderDashArray),i.strokeStyle=o.borderColor||this.borderColor,i.strokeRect(-h/2,-n/2,h,n),i.restore(),this},drawControls:function(i,a){a=a||{},i.save();var o=this.canvas.getRetinaScaling(),t,r;return i.setTransform(o,0,0,o,0,0),i.strokeStyle=i.fillStyle=a.cornerColor||this.cornerColor,this.transparentCorners||(i.strokeStyle=a.cornerStrokeColor||this.cornerStrokeColor),this._setLineDash(i,a.cornerDashArray||this.cornerDashArray),this.setCoords(),this.group&&(t=this.group.calcTransformMatrix()),this.forEachControl(function(e,s,h){r=h.oCoords[s],e.getVisibility(h,s)&&(t&&(r=u.util.transformPoint(r,t)),e.render(i,r.x,r.y,a,h))}),i.restore(),this},isControlVisible:function(i){return this.controls[i]&&this.controls[i].getVisibility(this,i)},setControlVisible:function(i,a){return this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[i]=a,this},setControlsVisibility:function(i){i||(i={});for(var a in i)this.setControlVisible(a,i[a]);return this},onDeselect:function(){},onSelect:function(){}})})();u.util.object.extend(u.StaticCanvas.prototype,{FX_DURATION:500,fxCenterObjectH:function(c,i){i=i||{};var a=function(){},o=i.onComplete||a,t=i.onChange||a,r=this;return u.util.animate({target:this,startValue:c.left,endValue:this.getCenter().left,duration:this.FX_DURATION,onChange:function(e){c.set("left",e),r.requestRenderAll(),t()},onComplete:function(){c.setCoords(),o()}})},fxCenterObjectV:function(c,i){i=i||{};var a=function(){},o=i.onComplete||a,t=i.onChange||a,r=this;return u.util.animate({target:this,startValue:c.top,endValue:this.getCenter().top,duration:this.FX_DURATION,onChange:function(e){c.set("top",e),r.requestRenderAll(),t()},onComplete:function(){c.setCoords(),o()}})},fxRemove:function(c,i){i=i||{};var a=function(){},o=i.onComplete||a,t=i.onChange||a,r=this;return u.util.animate({target:this,startValue:c.opacity,endValue:0,duration:this.FX_DURATION,onChange:function(e){c.set("opacity",e),r.requestRenderAll(),t()},onComplete:function(){r.remove(c),o()}})}});u.util.object.extend(u.Object.prototype,{animate:function(){if(arguments[0]&&typeof arguments[0]=="object"){var c=[],i,a,o=[];for(i in arguments[0])c.push(i);for(var t=0,r=c.length;t<r;t++)i=c[t],a=t!==r-1,o.push(this._animate(i,arguments[0][i],arguments[1],a));return o}else return this._animate.apply(this,arguments)},_animate:function(c,i,a,o){var t=this,r;i=i.toString(),a?a=u.util.object.clone(a):a={},~c.indexOf(".")&&(r=c.split("."));var e=t.colorProperties.indexOf(c)>-1||r&&t.colorProperties.indexOf(r[1])>-1,s=r?this.get(r[0])[r[1]]:this.get(c);"from"in a||(a.from=s),e||(~i.indexOf("=")?i=s+parseFloat(i.replace("=","")):i=parseFloat(i));var h={target:this,startValue:a.from,endValue:i,byValue:a.by,easing:a.easing,duration:a.duration,abort:a.abort&&function(n,l,f){return a.abort.call(t,n,l,f)},onChange:function(n,l,f){r?t[r[0]][r[1]]=n:t.set(c,n),!o&&a.onChange&&a.onChange(n,l,f)},onComplete:function(n,l,f){o||(t.setCoords(),a.onComplete&&a.onComplete(n,l,f))}};return e?u.util.animateColor(h.startValue,h.endValue,h.duration,h):u.util.animate(h)}});(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.util.object.extend,o=i.util.object.clone,t={x1:1,x2:1,y1:1,y2:1};if(i.Line){i.warn("fabric.Line is already defined");return}i.Line=i.util.createClass(i.Object,{type:"line",x1:0,y1:0,x2:0,y2:0,cacheProperties:i.Object.prototype.cacheProperties.concat("x1","x2","y1","y2"),initialize:function(e,s){e||(e=[0,0,0,0]),this.callSuper("initialize",s),this.set("x1",e[0]),this.set("y1",e[1]),this.set("x2",e[2]),this.set("y2",e[3]),this._setWidthHeight(s)},_setWidthHeight:function(e){e||(e={}),this.width=Math.abs(this.x2-this.x1),this.height=Math.abs(this.y2-this.y1),this.left="left"in e?e.left:this._getLeftToOriginX(),this.top="top"in e?e.top:this._getTopToOriginY()},_set:function(e,s){return this.callSuper("_set",e,s),typeof t[e]!="undefined"&&this._setWidthHeight(),this},_getLeftToOriginX:r({origin:"originX",axis1:"x1",axis2:"x2",dimension:"width"},{nearest:"left",center:"center",farthest:"right"}),_getTopToOriginY:r({origin:"originY",axis1:"y1",axis2:"y2",dimension:"height"},{nearest:"top",center:"center",farthest:"bottom"}),_render:function(e){e.beginPath();var s=this.calcLinePoints();e.moveTo(s.x1,s.y1),e.lineTo(s.x2,s.y2),e.lineWidth=this.strokeWidth;var h=e.strokeStyle;e.strokeStyle=this.stroke||e.fillStyle,this.stroke&&this._renderStroke(e),e.strokeStyle=h},_findCenterFromElement:function(){return{x:(this.x1+this.x2)/2,y:(this.y1+this.y2)/2}},toObject:function(e){return a(this.callSuper("toObject",e),this.calcLinePoints())},_getNonTransformedDimensions:function(){var e=this.callSuper("_getNonTransformedDimensions");return this.strokeLineCap==="butt"&&(this.width===0&&(e.y-=this.strokeWidth),this.height===0&&(e.x-=this.strokeWidth)),e},calcLinePoints:function(){var e=this.x1<=this.x2?-1:1,s=this.y1<=this.y2?-1:1,h=e*this.width*.5,n=s*this.height*.5,l=e*this.width*-.5,f=s*this.height*-.5;return{x1:h,x2:l,y1:n,y2:f}},_toSVG:function(){var e=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="',e.x1,'" y1="',e.y1,'" x2="',e.x2,'" y2="',e.y2,`" />
|
|
55
|
+
`]}}),i.Line.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat("x1 y1 x2 y2".split(" ")),i.Line.fromElement=function(e,s,h){h=h||{};var n=i.parseAttributes(e,i.Line.ATTRIBUTE_NAMES),l=[n.x1||0,n.y1||0,n.x2||0,n.y2||0];s(new i.Line(l,a(n,h)))},i.Line.fromObject=function(e,s){function h(l){delete l.points,s&&s(l)}var n=o(e,!0);n.points=[e.x1,e.y1,e.x2,e.y2],i.Object._fromObject("Line",n,h,"points")};function r(e,s){var h=e.origin,n=e.axis1,l=e.axis2,f=e.dimension,d=s.nearest,g=s.center,m=s.farthest;return function(){switch(this.get(h)){case d:return Math.min(this.get(n),this.get(l));case g:return Math.min(this.get(n),this.get(l))+.5*this.get(f);case m:return Math.max(this.get(n),this.get(l))}}}})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.util.degreesToRadians;if(i.Circle){i.warn("fabric.Circle is already defined.");return}i.Circle=i.util.createClass(i.Object,{type:"circle",radius:0,startAngle:0,endAngle:360,cacheProperties:i.Object.prototype.cacheProperties.concat("radius","startAngle","endAngle"),_set:function(t,r){return this.callSuper("_set",t,r),t==="radius"&&this.setRadius(r),this},toObject:function(t){return this.callSuper("toObject",["radius","startAngle","endAngle"].concat(t))},_toSVG:function(){var t,r=0,e=0,s=(this.endAngle-this.startAngle)%360;if(s===0)t=["<circle ","COMMON_PARTS",'cx="'+r+'" cy="'+e+'" ','r="',this.radius,`" />
|
|
56
|
+
`];else{var h=a(this.startAngle),n=a(this.endAngle),l=this.radius,f=i.util.cos(h)*l,d=i.util.sin(h)*l,g=i.util.cos(n)*l,m=i.util.sin(n)*l,p=s>180?"1":"0";t=['<path d="M '+f+" "+d," A "+l+" "+l," 0 ",+p+" 1"," "+g+" "+m,'" ',"COMMON_PARTS",` />
|
|
57
|
+
`]}return t},_render:function(t){t.beginPath(),t.arc(0,0,this.radius,a(this.startAngle),a(this.endAngle),!1),this._renderPaintInOrder(t)},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(t){return this.radius=t,this.set("width",t*2).set("height",t*2)}}),i.Circle.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat("cx cy r".split(" ")),i.Circle.fromElement=function(t,r){var e=i.parseAttributes(t,i.Circle.ATTRIBUTE_NAMES);if(!o(e))throw new Error("value of `r` attribute is required and can not be negative");e.left=(e.left||0)-e.radius,e.top=(e.top||0)-e.radius,r(new i.Circle(e))};function o(t){return"radius"in t&&t.radius>=0}i.Circle.fromObject=function(t,r){i.Object._fromObject("Circle",t,r)}})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={});if(i.Triangle){i.warn("fabric.Triangle is already defined");return}i.Triangle=i.util.createClass(i.Object,{type:"triangle",width:100,height:100,_render:function(a){var o=this.width/2,t=this.height/2;a.beginPath(),a.moveTo(-o,t),a.lineTo(0,-t),a.lineTo(o,t),a.closePath(),this._renderPaintInOrder(a)},_toSVG:function(){var a=this.width/2,o=this.height/2,t=[-a+" "+o,"0 "+-o,a+" "+o].join(",");return["<polygon ","COMMON_PARTS",'points="',t,'" />']}}),i.Triangle.fromObject=function(a,o){return i.Object._fromObject("Triangle",a,o)}})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=Math.PI*2;if(i.Ellipse){i.warn("fabric.Ellipse is already defined.");return}i.Ellipse=i.util.createClass(i.Object,{type:"ellipse",rx:0,ry:0,cacheProperties:i.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(o){this.callSuper("initialize",o),this.set("rx",o&&o.rx||0),this.set("ry",o&&o.ry||0)},_set:function(o,t){switch(this.callSuper("_set",o,t),o){case"rx":this.rx=t,this.set("width",t*2);break;case"ry":this.ry=t,this.set("height",t*2);break}return this},getRx:function(){return this.get("rx")*this.get("scaleX")},getRy:function(){return this.get("ry")*this.get("scaleY")},toObject:function(o){return this.callSuper("toObject",["rx","ry"].concat(o))},_toSVG:function(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" ','rx="',this.rx,'" ry="',this.ry,`" />
|
|
58
|
+
`]},_render:function(o){o.beginPath(),o.save(),o.transform(1,0,0,this.ry/this.rx,0,0),o.arc(0,0,this.rx,0,a,!1),o.restore(),this._renderPaintInOrder(o)}}),i.Ellipse.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat("cx cy rx ry".split(" ")),i.Ellipse.fromElement=function(o,t){var r=i.parseAttributes(o,i.Ellipse.ATTRIBUTE_NAMES);r.left=(r.left||0)-r.rx,r.top=(r.top||0)-r.ry,t(new i.Ellipse(r))},i.Ellipse.fromObject=function(o,t){i.Object._fromObject("Ellipse",o,t)}})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.util.object.extend;if(i.Rect){i.warn("fabric.Rect is already defined");return}i.Rect=i.util.createClass(i.Object,{stateProperties:i.Object.prototype.stateProperties.concat("rx","ry"),type:"rect",rx:0,ry:0,cacheProperties:i.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(o){this.callSuper("initialize",o),this._initRxRy()},_initRxRy:function(){this.rx&&!this.ry?this.ry=this.rx:this.ry&&!this.rx&&(this.rx=this.ry)},_render:function(o){var t=this.rx?Math.min(this.rx,this.width/2):0,r=this.ry?Math.min(this.ry,this.height/2):0,e=this.width,s=this.height,h=-this.width/2,n=-this.height/2,l=t!==0||r!==0,f=1-.5522847498;o.beginPath(),o.moveTo(h+t,n),o.lineTo(h+e-t,n),l&&o.bezierCurveTo(h+e-f*t,n,h+e,n+f*r,h+e,n+r),o.lineTo(h+e,n+s-r),l&&o.bezierCurveTo(h+e,n+s-f*r,h+e-f*t,n+s,h+e-t,n+s),o.lineTo(h+t,n+s),l&&o.bezierCurveTo(h+f*t,n+s,h,n+s-f*r,h,n+s-r),o.lineTo(h,n+r),l&&o.bezierCurveTo(h,n+f*r,h+f*t,n,h+t,n),o.closePath(),this._renderPaintInOrder(o)},toObject:function(o){return this.callSuper("toObject",["rx","ry"].concat(o))},_toSVG:function(){var o=-this.width/2,t=-this.height/2;return["<rect ","COMMON_PARTS",'x="',o,'" y="',t,'" rx="',this.rx,'" ry="',this.ry,'" width="',this.width,'" height="',this.height,`" />
|
|
59
|
+
`]}}),i.Rect.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat("x y rx ry width height".split(" ")),i.Rect.fromElement=function(o,t,r){if(!o)return t(null);r=r||{};var e=i.parseAttributes(o,i.Rect.ATTRIBUTE_NAMES);e.left=e.left||0,e.top=e.top||0,e.height=e.height||0,e.width=e.width||0;var s=new i.Rect(a(r?i.util.object.clone(r):{},e));s.visible=s.visible&&s.width>0&&s.height>0,t(s)},i.Rect.fromObject=function(o,t){return i.Object._fromObject("Rect",o,t)}})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.util.object.extend,o=i.util.array.min,t=i.util.array.max,r=i.util.toFixed,e=i.util.projectStrokeOnPoints;if(i.Polyline){i.warn("fabric.Polyline is already defined");return}i.Polyline=i.util.createClass(i.Object,{type:"polyline",points:null,exactBoundingBox:!1,cacheProperties:i.Object.prototype.cacheProperties.concat("points"),initialize:function(s,h){h=h||{},this.points=s||[],this.callSuper("initialize",h),this._setPositionDimensions(h)},_projectStrokeOnPoints:function(){return e(this.points,this,!0)},_setPositionDimensions:function(s){var h=this._calcDimensions(s),n,l=this.exactBoundingBox?this.strokeWidth:0;this.width=h.width-l,this.height=h.height-l,s.fromSVG||(n=this.translateToGivenOrigin({x:h.left-this.strokeWidth/2+l/2,y:h.top-this.strokeWidth/2+l/2},"left","top",this.originX,this.originY)),typeof s.left=="undefined"&&(this.left=s.fromSVG?h.left:n.x),typeof s.top=="undefined"&&(this.top=s.fromSVG?h.top:n.y),this.pathOffset={x:h.left+this.width/2+l/2,y:h.top+this.height/2+l/2}},_calcDimensions:function(){var s=this.exactBoundingBox?this._projectStrokeOnPoints():this.points,h=o(s,"x")||0,n=o(s,"y")||0,l=t(s,"x")||0,f=t(s,"y")||0,d=l-h,g=f-n;return{left:h,top:n,width:d,height:g}},toObject:function(s){return a(this.callSuper("toObject",s),{points:this.points.concat()})},_toSVG:function(){for(var s=[],h=this.pathOffset.x,n=this.pathOffset.y,l=i.Object.NUM_FRACTION_DIGITS,f=0,d=this.points.length;f<d;f++)s.push(r(this.points[f].x-h,l),",",r(this.points[f].y-n,l)," ");return["<"+this.type+" ","COMMON_PARTS",'points="',s.join(""),`" />
|
|
60
|
+
`]},commonRender:function(s){var h,n=this.points.length,l=this.pathOffset.x,f=this.pathOffset.y;if(!n||isNaN(this.points[n-1].y))return!1;s.beginPath(),s.moveTo(this.points[0].x-l,this.points[0].y-f);for(var d=0;d<n;d++)h=this.points[d],s.lineTo(h.x-l,h.y-f);return!0},_render:function(s){this.commonRender(s)&&this._renderPaintInOrder(s)},complexity:function(){return this.get("points").length}}),i.Polyline.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat(),i.Polyline.fromElementGenerator=function(s){return function(h,n,l){if(!h)return n(null);l||(l={});var f=i.parsePointsAttribute(h.getAttribute("points")),d=i.parseAttributes(h,i[s].ATTRIBUTE_NAMES);d.fromSVG=!0,n(new i[s](f,a(d,l)))}},i.Polyline.fromElement=i.Polyline.fromElementGenerator("Polyline"),i.Polyline.fromObject=function(s,h){return i.Object._fromObject("Polyline",s,h,"points")}})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.util.projectStrokeOnPoints;if(i.Polygon){i.warn("fabric.Polygon is already defined");return}i.Polygon=i.util.createClass(i.Polyline,{type:"polygon",_projectStrokeOnPoints:function(){return a(this.points,this)},_render:function(o){this.commonRender(o)&&(o.closePath(),this._renderPaintInOrder(o))}}),i.Polygon.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat(),i.Polygon.fromElement=i.Polyline.fromElementGenerator("Polygon"),i.Polygon.fromObject=function(o,t){i.Object._fromObject("Polygon",o,t,"points")}})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.util.array.min,o=i.util.array.max,t=i.util.object.extend,r=i.util.object.clone,e=Object.prototype.toString,s=i.util.toFixed;if(i.Path){i.warn("fabric.Path is already defined");return}i.Path=i.util.createClass(i.Object,{type:"path",path:null,cacheProperties:i.Object.prototype.cacheProperties.concat("path","fillRule"),stateProperties:i.Object.prototype.stateProperties.concat("path"),initialize:function(h,n){n=r(n||{}),delete n.path,this.callSuper("initialize",n),this._setPath(h||[],n)},_setPath:function(h,n){var l=e.call(h)==="[object Array]";this.path=i.util.makePathSimpler(l?h:i.util.parsePath(h)),i.Polyline.prototype._setPositionDimensions.call(this,n||{})},_renderPathCommands:function(h){var n,l=0,f=0,d=0,g=0,m=0,p=0,_=-this.pathOffset.x,w=-this.pathOffset.y;h.beginPath();for(var D=0,B=this.path.length;D<B;++D)switch(n=this.path[D],n[0]){case"L":d=n[1],g=n[2],h.lineTo(d+_,g+w);break;case"M":d=n[1],g=n[2],l=d,f=g,h.moveTo(d+_,g+w);break;case"C":d=n[5],g=n[6],m=n[3],p=n[4],h.bezierCurveTo(n[1]+_,n[2]+w,m+_,p+w,d+_,g+w);break;case"Q":h.quadraticCurveTo(n[1]+_,n[2]+w,n[3]+_,n[4]+w),d=n[3],g=n[4],m=n[1],p=n[2];break;case"z":case"Z":d=l,g=f,h.closePath();break}},_render:function(h){this._renderPathCommands(h),this._renderPaintInOrder(h)},toString:function(){return"#<fabric.Path ("+this.complexity()+'): { "top": '+this.top+', "left": '+this.left+" }>"},toObject:function(h){return t(this.callSuper("toObject",h),{path:this.path.map(function(n){return n.slice()})})},toDatalessObject:function(h){var n=this.toObject(["sourcePath"].concat(h));return n.sourcePath&&delete n.path,n},_toSVG:function(){var h=i.util.joinPath(this.path);return["<path ","COMMON_PARTS",'d="',h,'" stroke-linecap="round" ',`/>
|
|
61
|
+
`]},_getOffsetTransform:function(){var h=i.Object.NUM_FRACTION_DIGITS;return" translate("+s(-this.pathOffset.x,h)+", "+s(-this.pathOffset.y,h)+")"},toClipPathSVG:function(h){var n=this._getOffsetTransform();return" "+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:h,additionalTransform:n})},toSVG:function(h){var n=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:h,additionalTransform:n})},complexity:function(){return this.path.length},_calcDimensions:function(){for(var h=[],n=[],l,f=0,d=0,g=0,m=0,p,_=0,w=this.path.length;_<w;++_){switch(l=this.path[_],l[0]){case"L":g=l[1],m=l[2],p=[];break;case"M":g=l[1],m=l[2],f=g,d=m,p=[];break;case"C":p=i.util.getBoundsOfCurve(g,m,l[1],l[2],l[3],l[4],l[5],l[6]),g=l[5],m=l[6];break;case"Q":p=i.util.getBoundsOfCurve(g,m,l[1],l[2],l[1],l[2],l[3],l[4]),g=l[3],m=l[4];break;case"z":case"Z":g=f,m=d;break}p.forEach(function(U){h.push(U.x),n.push(U.y)}),h.push(g),n.push(m)}var D=a(h)||0,B=a(n)||0,N=o(h)||0,G=o(n)||0,z=N-D,H=G-B;return{left:D,top:B,width:z,height:H}}}),i.Path.fromObject=function(h,n){if(typeof h.sourcePath=="string"){var l=h.sourcePath;i.loadSVGFromURL(l,function(f){var d=f[0];d.setOptions(h),n&&n(d)})}else i.Object._fromObject("Path",h,n,"path")},i.Path.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat(["d"]),i.Path.fromElement=function(h,n,l){var f=i.parseAttributes(h,i.Path.ATTRIBUTE_NAMES);f.fromSVG=!0,n(new i.Path(f.d,t(f,l)))}})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.util.array.min,o=i.util.array.max;i.Group||(i.Group=i.util.createClass(i.Object,i.Collection,{type:"group",strokeWidth:0,subTargetCheck:!1,cacheProperties:[],useSetOnGroup:!1,initialize:function(t,r,e){r=r||{},this._objects=[],e&&this.callSuper("initialize",r),this._objects=t||[];for(var s=this._objects.length;s--;)this._objects[s].group=this;if(e)this._updateObjectsACoords();else{var h=r&&r.centerPoint;r.originX!==void 0&&(this.originX=r.originX),r.originY!==void 0&&(this.originY=r.originY),h||this._calcBounds(),this._updateObjectsCoords(h),delete r.centerPoint,this.callSuper("initialize",r)}this.setCoords()},_updateObjectsACoords:function(){for(var t=!0,r=this._objects.length;r--;)this._objects[r].setCoords(t)},_updateObjectsCoords:function(r){for(var r=r||this.getCenterPoint(),e=this._objects.length;e--;)this._updateObjectCoords(this._objects[e],r)},_updateObjectCoords:function(t,r){var e=t.left,s=t.top,h=!0;t.set({left:e-r.x,top:s-r.y}),t.group=this,t.setCoords(h)},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},addWithUpdate:function(t){var r=!!this.group;return this._restoreObjectsState(),i.util.resetObjectTransform(this),t&&(r&&i.util.removeTransformFromObject(t,this.group.calcTransformMatrix()),this._objects.push(t),t.group=this,t._set("canvas",this.canvas)),this._calcBounds(),this._updateObjectsCoords(),this.dirty=!0,r?this.group.addWithUpdate():this.setCoords(),this},removeWithUpdate:function(t){return this._restoreObjectsState(),i.util.resetObjectTransform(this),this.remove(t),this._calcBounds(),this._updateObjectsCoords(),this.setCoords(),this.dirty=!0,this},_onObjectAdded:function(t){this.dirty=!0,t.group=this,t._set("canvas",this.canvas)},_onObjectRemoved:function(t){this.dirty=!0,delete t.group},_set:function(t,r){var e=this._objects.length;if(this.useSetOnGroup)for(;e--;)this._objects[e].setOnGroup(t,r);if(t==="canvas")for(;e--;)this._objects[e]._set(t,r);i.Object.prototype._set.call(this,t,r)},toObject:function(t){var r=this.includeDefaultValues,e=this._objects.filter(function(h){return!h.excludeFromExport}).map(function(h){var n=h.includeDefaultValues;h.includeDefaultValues=r;var l=h.toObject(t);return h.includeDefaultValues=n,l}),s=i.Object.prototype.toObject.call(this,t);return s.objects=e,s},toDatalessObject:function(t){var r,e=this.sourcePath;if(e)r=e;else{var s=this.includeDefaultValues;r=this._objects.map(function(n){var l=n.includeDefaultValues;n.includeDefaultValues=s;var f=n.toDatalessObject(t);return n.includeDefaultValues=l,f})}var h=i.Object.prototype.toDatalessObject.call(this,t);return h.objects=r,h},render:function(t){this._transformDone=!0,this.callSuper("render",t),this._transformDone=!1},shouldCache:function(){var t=i.Object.prototype.shouldCache.call(this);if(t){for(var r=0,e=this._objects.length;r<e;r++)if(this._objects[r].willDrawShadow())return this.ownCaching=!1,!1}return t},willDrawShadow:function(){if(i.Object.prototype.willDrawShadow.call(this))return!0;for(var t=0,r=this._objects.length;t<r;t++)if(this._objects[t].willDrawShadow())return!0;return!1},isOnACache:function(){return this.ownCaching||this.group&&this.group.isOnACache()},drawObject:function(t){for(var r=0,e=this._objects.length;r<e;r++)this._objects[r].render(t);this._drawClipPath(t,this.clipPath)},isCacheDirty:function(t){if(this.callSuper("isCacheDirty",t))return!0;if(!this.statefullCache)return!1;for(var r=0,e=this._objects.length;r<e;r++)if(this._objects[r].isCacheDirty(!0)){if(this._cacheCanvas){var s=this.cacheWidth/this.zoomX,h=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-s/2,-h/2,s,h)}return!0}return!1},_restoreObjectsState:function(){var t=this.calcOwnMatrix();return this._objects.forEach(function(r){i.util.addTransformToObject(r,t),delete r.group,r.setCoords()}),this},destroy:function(){return this._objects.forEach(function(t){t.set("dirty",!0)}),this._restoreObjectsState()},dispose:function(){this.callSuper("dispose"),this.forEachObject(function(t){t.dispose&&t.dispose()}),this._objects=[]},toActiveSelection:function(){if(this.canvas){var t=this._objects,r=this.canvas;this._objects=[];var e=this.toObject();delete e.objects;var s=new i.ActiveSelection([]);return s.set(e),s.type="activeSelection",r.remove(this),t.forEach(function(h){h.group=s,h.dirty=!0,r.add(h)}),s.canvas=r,s._objects=t,r._activeObject=s,s.setCoords(),s}},ungroupOnCanvas:function(){return this._restoreObjectsState()},setObjectsCoords:function(){var t=!0;return this.forEachObject(function(r){r.setCoords(t)}),this},_calcBounds:function(t){for(var r=[],e=[],s,h,n,l=["tr","br","bl","tl"],f=0,d=this._objects.length,g,m=l.length;f<d;++f){for(s=this._objects[f],n=s.calcACoords(),g=0;g<m;g++)h=l[g],r.push(n[h].x),e.push(n[h].y);s.aCoords=n}this._getBounds(r,e,t)},_getBounds:function(t,r,e){var s=new i.Point(a(t),a(r)),h=new i.Point(o(t),o(r)),n=s.y||0,l=s.x||0,f=h.x-s.x||0,d=h.y-s.y||0;this.width=f,this.height=d,e||this.setPositionByOrigin({x:l,y:n},"left","top")},_toSVG:function(t){for(var r=["<g ","COMMON_PARTS",` >
|
|
62
|
+
`],e=0,s=this._objects.length;e<s;e++)r.push(" ",this._objects[e].toSVG(t));return r.push(`</g>
|
|
63
|
+
`),r},getSvgStyles:function(){var t=typeof this.opacity!="undefined"&&this.opacity!==1?"opacity: "+this.opacity+";":"",r=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),r].join("")},toClipPathSVG:function(t){for(var r=[],e=0,s=this._objects.length;e<s;e++)r.push(" ",this._objects[e].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(r,{reviver:t})}}),i.Group.fromObject=function(t,r){var e=t.objects,s=i.util.object.clone(t,!0);if(delete s.objects,typeof e=="string"){i.loadSVGFromURL(e,function(h){var n=i.util.groupSVGElements(h,t,e);n.set(s),r&&r(n)});return}i.util.enlivenObjects(e,function(h){var n=i.util.object.clone(t,!0);delete n.objects,i.util.enlivenObjectEnlivables(t,n,function(){r&&r(new i.Group(h,n,!0))})})})})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={});i.ActiveSelection||(i.ActiveSelection=i.util.createClass(i.Group,{type:"activeSelection",initialize:function(a,o){o=o||{},this._objects=a||[];for(var t=this._objects.length;t--;)this._objects[t].group=this;o.originX&&(this.originX=o.originX),o.originY&&(this.originY=o.originY),this._calcBounds(),this._updateObjectsCoords(),i.Object.prototype.initialize.call(this,o),this.setCoords()},toGroup:function(){var a=this._objects.concat();this._objects=[];var o=i.Object.prototype.toObject.call(this),t=new i.Group([]);if(delete o.type,t.set(o),a.forEach(function(e){e.canvas.remove(e),e.group=t}),t._objects=a,!this.canvas)return t;var r=this.canvas;return r.add(t),r._activeObject=t,t.setCoords(),t},onDeselect:function(){return this.destroy(),!1},toString:function(){return"#<fabric.ActiveSelection: ("+this.complexity()+")>"},shouldCache:function(){return!1},isOnACache:function(){return!1},_renderControls:function(a,o,t){a.save(),a.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,this.callSuper("_renderControls",a,o),t=t||{},typeof t.hasControls=="undefined"&&(t.hasControls=!1),t.forActiveSelection=!0;for(var r=0,e=this._objects.length;r<e;r++)this._objects[r]._renderControls(a,t);a.restore()}}),i.ActiveSelection.fromObject=function(a,o){i.util.enlivenObjects(a.objects,function(t){delete a.objects,o&&o(new i.ActiveSelection(t,a,!0))})})})(F);(function(c){"use strict";var i=u.util.object.extend;if(c.fabric||(c.fabric={}),c.fabric.Image){u.warn("fabric.Image is already defined.");return}u.Image=u.util.createClass(u.Object,{type:"image",strokeWidth:0,srcFromAttribute:!1,_lastScaleX:1,_lastScaleY:1,_filterScalingX:1,_filterScalingY:1,minimumScaleTrigger:.5,stateProperties:u.Object.prototype.stateProperties.concat("cropX","cropY"),cacheProperties:u.Object.prototype.cacheProperties.concat("cropX","cropY"),cacheKey:"",cropX:0,cropY:0,imageSmoothing:!0,initialize:function(a,o){o||(o={}),this.filters=[],this.cacheKey="texture"+u.Object.__uid++,this.callSuper("initialize",o),this._initElement(a,o)},getElement:function(){return this._element||{}},setElement:function(a,o){return this.removeTexture(this.cacheKey),this.removeTexture(this.cacheKey+"_filtered"),this._element=a,this._originalElement=a,this._initConfig(o),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters(),this},removeTexture:function(a){var o=u.filterBackend;o&&o.evictCachesForKey&&o.evictCachesForKey(a)},dispose:function(){this.callSuper("dispose"),this.removeTexture(this.cacheKey),this.removeTexture(this.cacheKey+"_filtered"),this._cacheContext=void 0,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach(function(a){u.util.cleanUpJsdomNode(this[a]),this[a]=void 0}.bind(this))},getCrossOrigin:function(){return this._originalElement&&(this._originalElement.crossOrigin||null)},getOriginalSize:function(){var a=this.getElement();return{width:a.naturalWidth||a.width,height:a.naturalHeight||a.height}},_stroke:function(a){if(!(!this.stroke||this.strokeWidth===0)){var o=this.width/2,t=this.height/2;a.beginPath(),a.moveTo(-o,-t),a.lineTo(o,-t),a.lineTo(o,t),a.lineTo(-o,t),a.lineTo(-o,-t),a.closePath()}},toObject:function(a){var o=[];this.filters.forEach(function(r){r&&o.push(r.toObject())});var t=i(this.callSuper("toObject",["cropX","cropY"].concat(a)),{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:o});return this.resizeFilter&&(t.resizeFilter=this.resizeFilter.toObject()),t},hasCrop:function(){return this.cropX||this.cropY||this.width<this._element.width||this.height<this._element.height},_toSVG:function(){var a=[],o=[],t,r=this._element,e=-this.width/2,s=-this.height/2,h="",n="";if(!r)return[];if(this.hasCrop()){var l=u.Object.__uid++;a.push('<clipPath id="imageCrop_'+l+`">
|
|
64
|
+
`,' <rect x="'+e+'" y="'+s+'" width="'+this.width+'" height="'+this.height+`" />
|
|
65
|
+
`,`</clipPath>
|
|
66
|
+
`),h=' clip-path="url(#imageCrop_'+l+')" '}if(this.imageSmoothing||(n='" image-rendering="optimizeSpeed'),o.push(" <image ","COMMON_PARTS",'xlink:href="',this.getSvgSrc(!0),'" x="',e-this.cropX,'" y="',s-this.cropY,'" width="',r.width||r.naturalWidth,'" height="',r.height||r.height,n,'"',h,`></image>
|
|
67
|
+
`),this.stroke||this.strokeDashArray){var f=this.fill;this.fill=null,t=[" <rect ",'x="',e,'" y="',s,'" width="',this.width,'" height="',this.height,'" style="',this.getSvgStyles(),`"/>
|
|
68
|
+
`],this.fill=f}return this.paintFirst!=="fill"?a=a.concat(t,o):a=a.concat(o,t),a},getSrc:function(a){var o=a?this._element:this._originalElement;return o?o.toDataURL?o.toDataURL():this.srcFromAttribute?o.getAttribute("src"):o.src:this.src||""},setSrc:function(a,o,t){return u.util.loadImage(a,function(r,e){this.setElement(r,t),this._setWidthHeight(),o&&o(this,e)},this,t&&t.crossOrigin),this},toString:function(){return'#<fabric.Image: { src: "'+this.getSrc()+'" }>'},applyResizeFilters:function(){var a=this.resizeFilter,o=this.minimumScaleTrigger,t=this.getTotalObjectScaling(),r=t.scaleX,e=t.scaleY,s=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!a||r>o&&e>o){this._element=s,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=r,this._lastScaleY=e;return}u.filterBackend||(u.filterBackend=u.initFilterBackend());var h=u.util.createCanvasElement(),n=this._filteredEl?this.cacheKey+"_filtered":this.cacheKey,l=s.width,f=s.height;h.width=l,h.height=f,this._element=h,this._lastScaleX=a.scaleX=r,this._lastScaleY=a.scaleY=e,u.filterBackend.applyFilters([a],s,l,f,this._element,n),this._filterScalingX=h.width/this._originalElement.width,this._filterScalingY=h.height/this._originalElement.height},applyFilters:function(a){if(a=a||this.filters||[],a=a.filter(function(s){return s&&!s.isNeutralState()}),this.set("dirty",!0),this.removeTexture(this.cacheKey+"_filtered"),a.length===0)return this._element=this._originalElement,this._filteredEl=null,this._filterScalingX=1,this._filterScalingY=1,this;var o=this._originalElement,t=o.naturalWidth||o.width,r=o.naturalHeight||o.height;if(this._element===this._originalElement){var e=u.util.createCanvasElement();e.width=t,e.height=r,this._element=e,this._filteredEl=e}else this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,t,r),this._lastScaleX=1,this._lastScaleY=1;return u.filterBackend||(u.filterBackend=u.initFilterBackend()),u.filterBackend.applyFilters(a,this._originalElement,t,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),this},_render:function(a){u.util.setImageSmoothing(a,this.imageSmoothing),this.isMoving!==!0&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(a),this._renderPaintInOrder(a)},drawCacheOnCanvas:function(a){u.util.setImageSmoothing(a,this.imageSmoothing),u.Object.prototype.drawCacheOnCanvas.call(this,a)},shouldCache:function(){return this.needsItsOwnCache()},_renderFill:function(a){var o=this._element;if(o){var t=this._filterScalingX,r=this._filterScalingY,e=this.width,s=this.height,h=Math.min,n=Math.max,l=n(this.cropX,0),f=n(this.cropY,0),d=o.naturalWidth||o.width,g=o.naturalHeight||o.height,m=l*t,p=f*r,_=h(e*t,d-m),w=h(s*r,g-p),D=-e/2,B=-s/2,N=h(e,d/t-l),G=h(s,g/r-f);o&&a.drawImage(o,m,p,_,w,D,B,N,G)}},_needsResize:function(){var a=this.getTotalObjectScaling();return a.scaleX!==this._lastScaleX||a.scaleY!==this._lastScaleY},_resetWidthHeight:function(){this.set(this.getOriginalSize())},_initElement:function(a,o){this.setElement(u.util.getById(a),o),u.util.addClass(this.getElement(),u.Image.CSS_CANVAS)},_initConfig:function(a){a||(a={}),this.setOptions(a),this._setWidthHeight(a)},_initFilters:function(a,o){a&&a.length?u.util.enlivenObjects(a,function(t){o&&o(t)},"fabric.Image.filters"):o&&o()},_setWidthHeight:function(a){a||(a={});var o=this.getElement();this.width=a.width||o.naturalWidth||o.width||0,this.height=a.height||o.naturalHeight||o.height||0},parsePreserveAspectRatioAttribute:function(){var a=u.util.parsePreserveAspectRatioAttribute(this.preserveAspectRatio||""),o=this._element.width,t=this._element.height,r=1,e=1,s=0,h=0,n=0,l=0,f,d=this.width,g=this.height,m={width:d,height:g};return a&&(a.alignX!=="none"||a.alignY!=="none")?(a.meetOrSlice==="meet"&&(r=e=u.util.findScaleToFit(this._element,m),f=(d-o*r)/2,a.alignX==="Min"&&(s=-f),a.alignX==="Max"&&(s=f),f=(g-t*e)/2,a.alignY==="Min"&&(h=-f),a.alignY==="Max"&&(h=f)),a.meetOrSlice==="slice"&&(r=e=u.util.findScaleToCover(this._element,m),f=o-d/r,a.alignX==="Mid"&&(n=f/2),a.alignX==="Max"&&(n=f),f=t-g/e,a.alignY==="Mid"&&(l=f/2),a.alignY==="Max"&&(l=f),o=d/r,t=g/e)):(r=d/o,e=g/t),{width:o,height:t,scaleX:r,scaleY:e,offsetLeft:s,offsetTop:h,cropX:n,cropY:l}}}),u.Image.CSS_CANVAS="canvas-img",u.Image.prototype.getSvgSrc=u.Image.prototype.getSrc,u.Image.fromObject=function(a,o){var t=u.util.object.clone(a);u.util.loadImage(t.src,function(r,e){if(e){o&&o(null,!0);return}u.Image.prototype._initFilters.call(t,t.filters,function(s){t.filters=s||[],u.Image.prototype._initFilters.call(t,[t.resizeFilter],function(h){t.resizeFilter=h[0],u.util.enlivenObjectEnlivables(t,t,function(){var n=new u.Image(r,t);o(n,!1)})})})},null,t.crossOrigin)},u.Image.fromURL=function(a,o,t){u.util.loadImage(a,function(r,e){o&&o(new u.Image(r,t),e)},null,t&&t.crossOrigin)},u.Image.ATTRIBUTE_NAMES=u.SHARED_ATTRIBUTES.concat("x y width height preserveAspectRatio xlink:href crossOrigin image-rendering".split(" ")),u.Image.fromElement=function(a,o,t){var r=u.parseAttributes(a,u.Image.ATTRIBUTE_NAMES);u.Image.fromURL(r["xlink:href"],o,i(t?u.util.object.clone(t):{},r))}})(F);u.util.object.extend(u.Object.prototype,{_getAngleValueForStraighten:function(){var c=this.angle%360;return c>0?Math.round((c-1)/90)*90:Math.round(c/90)*90},straighten:function(){return this.rotate(this._getAngleValueForStraighten())},fxStraighten:function(c){c=c||{};var i=function(){},a=c.onComplete||i,o=c.onChange||i,t=this;return u.util.animate({target:this,startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(r){t.rotate(r),o()},onComplete:function(){t.setCoords(),a()}})}});u.util.object.extend(u.StaticCanvas.prototype,{straightenObject:function(c){return c.straighten(),this.requestRenderAll(),this},fxStraightenObject:function(c){return c.fxStraighten({onChange:this.requestRenderAllBound})}});(function(){"use strict";function c(a,o){var t="precision "+o+` float;
|
|
69
|
+
void main(){}`,r=a.createShader(a.FRAGMENT_SHADER);return a.shaderSource(r,t),a.compileShader(r),!!a.getShaderParameter(r,a.COMPILE_STATUS)}u.isWebglSupported=function(a){if(u.isLikelyNode)return!1;a=a||u.WebglFilterBackend.prototype.tileSize;var o=document.createElement("canvas"),t=o.getContext("webgl")||o.getContext("experimental-webgl"),r=!1;if(t){u.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),r=u.maxTextureSize>=a;for(var e=["highp","mediump","lowp"],s=0;s<3;s++)if(c(t,e[s])){u.webGlPrecision=e[s];break}}return this.isSupported=r,r},u.WebglFilterBackend=i;function i(a){a&&a.tileSize&&(this.tileSize=a.tileSize),this.setupGLContext(this.tileSize,this.tileSize),this.captureGPUInfo()}i.prototype={tileSize:2048,resources:{},setupGLContext:function(a,o){this.dispose(),this.createWebGLCanvas(a,o),this.aPosition=new Float32Array([0,0,0,1,1,0,1,1]),this.chooseFastestCopyGLTo2DMethod(a,o)},chooseFastestCopyGLTo2DMethod:function(a,o){var t=typeof window.performance!="undefined",r;try{new ImageData(1,1),r=!0}catch(m){r=!1}var e=typeof ArrayBuffer!="undefined",s=typeof Uint8ClampedArray!="undefined";if(t&&r&&e&&s){var h=u.util.createCanvasElement(),n=new ArrayBuffer(a*o*4);if(u.forceGLPutImageData){this.imageBuffer=n,this.copyGLTo2D=Dt;return}var l={imageBuffer:n,destinationWidth:a,destinationHeight:o,targetCanvas:h},f,d,g;h.width=a,h.height=o,f=window.performance.now(),kt.call(l,this.gl,l),d=window.performance.now()-f,f=window.performance.now(),Dt.call(l,this.gl,l),g=window.performance.now()-f,d>g?(this.imageBuffer=n,this.copyGLTo2D=Dt):this.copyGLTo2D=kt}},createWebGLCanvas:function(a,o){var t=u.util.createCanvasElement();t.width=a,t.height=o;var r={alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1},e=t.getContext("webgl",r);e||(e=t.getContext("experimental-webgl",r)),e&&(e.clearColor(0,0,0,0),this.canvas=t,this.gl=e)},applyFilters:function(a,o,t,r,e,s){var h=this.gl,n;s&&(n=this.getCachedTexture(s,o));var l={originalWidth:o.width||o.originalWidth,originalHeight:o.height||o.originalHeight,sourceWidth:t,sourceHeight:r,destinationWidth:t,destinationHeight:r,context:h,sourceTexture:this.createTexture(h,t,r,!n&&o),targetTexture:this.createTexture(h,t,r),originalTexture:n||this.createTexture(h,t,r,!n&&o),passes:a.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:e},f=h.createFramebuffer();return h.bindFramebuffer(h.FRAMEBUFFER,f),a.forEach(function(d){d&&d.applyTo(l)}),ge(l),this.copyGLTo2D(h,l),h.bindTexture(h.TEXTURE_2D,null),h.deleteTexture(l.sourceTexture),h.deleteTexture(l.targetTexture),h.deleteFramebuffer(f),e.getContext("2d").setTransform(1,0,0,1,0,0),l},dispose:function(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()},clearWebGLCaches:function(){this.programCache={},this.textureCache={}},createTexture:function(a,o,t,r){var e=a.createTexture();return a.bindTexture(a.TEXTURE_2D,e),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),r?a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,r):a.texImage2D(a.TEXTURE_2D,0,a.RGBA,o,t,0,a.RGBA,a.UNSIGNED_BYTE,null),e},getCachedTexture:function(a,o){if(this.textureCache[a])return this.textureCache[a];var t=this.createTexture(this.gl,o.width,o.height,o);return this.textureCache[a]=t,t},evictCachesForKey:function(a){this.textureCache[a]&&(this.gl.deleteTexture(this.textureCache[a]),delete this.textureCache[a])},copyGLTo2D:kt,captureGPUInfo:function(){if(this.gpuInfo)return this.gpuInfo;var a=this.gl,o={renderer:"",vendor:""};if(!a)return o;var t=a.getExtension("WEBGL_debug_renderer_info");if(t){var r=a.getParameter(t.UNMASKED_RENDERER_WEBGL),e=a.getParameter(t.UNMASKED_VENDOR_WEBGL);r&&(o.renderer=r.toLowerCase()),e&&(o.vendor=e.toLowerCase())}return this.gpuInfo=o,o}}})();function ge(c){var i=c.targetCanvas,a=i.width,o=i.height,t=c.destinationWidth,r=c.destinationHeight;(a!==t||o!==r)&&(i.width=t,i.height=r)}function kt(c,i){var a=c.canvas,o=i.targetCanvas,t=o.getContext("2d");t.translate(0,o.height),t.scale(1,-1);var r=a.height-o.height;t.drawImage(a,0,r,o.width,o.height,0,0,o.width,o.height)}function Dt(c,i){var a=i.targetCanvas,o=a.getContext("2d"),t=i.destinationWidth,r=i.destinationHeight,e=t*r*4,s=new Uint8Array(this.imageBuffer,0,e),h=new Uint8ClampedArray(this.imageBuffer,0,e);c.readPixels(0,0,t,r,c.RGBA,c.UNSIGNED_BYTE,s);var n=new ImageData(h,t,r);o.putImageData(n,0,0)}(function(){"use strict";var c=function(){};u.Canvas2dFilterBackend=i;function i(){}i.prototype={evictCachesForKey:c,dispose:c,clearWebGLCaches:c,resources:{},applyFilters:function(a,o,t,r,e){var s=e.getContext("2d");s.drawImage(o,0,0,t,r);var h=s.getImageData(0,0,t,r),n=s.getImageData(0,0,t,r),l={sourceWidth:t,sourceHeight:r,imageData:h,originalEl:o,originalImageData:n,canvasEl:e,ctx:s,filterBackend:this};return a.forEach(function(f){f.applyTo(l)}),(l.imageData.width!==t||l.imageData.height!==r)&&(e.width=l.imageData.width,e.height=l.imageData.height),s.putImageData(l.imageData,0,0),l}}})();u.Image=u.Image||{};u.Image.filters=u.Image.filters||{};u.Image.filters.BaseFilter=u.util.createClass({type:"BaseFilter",vertexSource:`attribute vec2 aPosition;
|
|
70
|
+
varying vec2 vTexCoord;
|
|
71
|
+
void main() {
|
|
72
|
+
vTexCoord = aPosition;
|
|
73
|
+
gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
|
|
74
|
+
}`,fragmentSource:`precision highp float;
|
|
75
|
+
varying vec2 vTexCoord;
|
|
76
|
+
uniform sampler2D uTexture;
|
|
77
|
+
void main() {
|
|
78
|
+
gl_FragColor = texture2D(uTexture, vTexCoord);
|
|
79
|
+
}`,initialize:function(c){c&&this.setOptions(c)},setOptions:function(c){for(var i in c)this[i]=c[i]},createProgram:function(c,i,a){i=i||this.fragmentSource,a=a||this.vertexSource,u.webGlPrecision!=="highp"&&(i=i.replace(/precision highp float/g,"precision "+u.webGlPrecision+" float"));var o=c.createShader(c.VERTEX_SHADER);if(c.shaderSource(o,a),c.compileShader(o),!c.getShaderParameter(o,c.COMPILE_STATUS))throw new Error("Vertex shader compile error for "+this.type+": "+c.getShaderInfoLog(o));var t=c.createShader(c.FRAGMENT_SHADER);if(c.shaderSource(t,i),c.compileShader(t),!c.getShaderParameter(t,c.COMPILE_STATUS))throw new Error("Fragment shader compile error for "+this.type+": "+c.getShaderInfoLog(t));var r=c.createProgram();if(c.attachShader(r,o),c.attachShader(r,t),c.linkProgram(r),!c.getProgramParameter(r,c.LINK_STATUS))throw new Error('Shader link error for "${this.type}" '+c.getProgramInfoLog(r));var e=this.getAttributeLocations(c,r),s=this.getUniformLocations(c,r)||{};return s.uStepW=c.getUniformLocation(r,"uStepW"),s.uStepH=c.getUniformLocation(r,"uStepH"),{program:r,attributeLocations:e,uniformLocations:s}},getAttributeLocations:function(c,i){return{aPosition:c.getAttribLocation(i,"aPosition")}},getUniformLocations:function(){return{}},sendAttributeData:function(c,i,a){var o=i.aPosition,t=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,t),c.enableVertexAttribArray(o),c.vertexAttribPointer(o,2,c.FLOAT,!1,0,0),c.bufferData(c.ARRAY_BUFFER,a,c.STATIC_DRAW)},_setupFrameBuffer:function(c){var i=c.context,a,o;c.passes>1?(a=c.destinationWidth,o=c.destinationHeight,(c.sourceWidth!==a||c.sourceHeight!==o)&&(i.deleteTexture(c.targetTexture),c.targetTexture=c.filterBackend.createTexture(i,a,o)),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,c.targetTexture,0)):(i.bindFramebuffer(i.FRAMEBUFFER,null),i.finish())},_swapTextures:function(c){c.passes--,c.pass++;var i=c.targetTexture;c.targetTexture=c.sourceTexture,c.sourceTexture=i},isNeutralState:function(){var c=this.mainParameter,i=u.Image.filters[this.type].prototype;if(c)if(Array.isArray(i[c])){for(var a=i[c].length;a--;)if(this[c][a]!==i[c][a])return!1;return!0}else return i[c]===this[c];else return!1},applyTo:function(c){c.webgl?(this._setupFrameBuffer(c),this.applyToWebGL(c),this._swapTextures(c)):this.applyTo2d(c)},retrieveShader:function(c){return c.programCache.hasOwnProperty(this.type)||(c.programCache[this.type]=this.createProgram(c.context)),c.programCache[this.type]},applyToWebGL:function(c){var i=c.context,a=this.retrieveShader(c);c.pass===0&&c.originalTexture?i.bindTexture(i.TEXTURE_2D,c.originalTexture):i.bindTexture(i.TEXTURE_2D,c.sourceTexture),i.useProgram(a.program),this.sendAttributeData(i,a.attributeLocations,c.aPosition),i.uniform1f(a.uniformLocations.uStepW,1/c.sourceWidth),i.uniform1f(a.uniformLocations.uStepH,1/c.sourceHeight),this.sendUniformData(i,a.uniformLocations),i.viewport(0,0,c.destinationWidth,c.destinationHeight),i.drawArrays(i.TRIANGLE_STRIP,0,4)},bindAdditionalTexture:function(c,i,a){c.activeTexture(a),c.bindTexture(c.TEXTURE_2D,i),c.activeTexture(c.TEXTURE0)},unbindAdditionalTexture:function(c,i){c.activeTexture(i),c.bindTexture(c.TEXTURE_2D,null),c.activeTexture(c.TEXTURE0)},getMainParameter:function(){return this[this.mainParameter]},setMainParameter:function(c){this[this.mainParameter]=c},sendUniformData:function(){},createHelpLayer:function(c){if(!c.helpLayer){var i=document.createElement("canvas");i.width=c.sourceWidth,i.height=c.sourceHeight,c.helpLayer=i}},toObject:function(){var c={type:this.type},i=this.mainParameter;return i&&(c[i]=this[i]),c},toJSON:function(){return this.toObject()}});u.Image.filters.BaseFilter.fromObject=function(c,i){var a=new u.Image.filters[c.type](c);return i&&i(a),a};(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.Image.filters,o=i.util.createClass;a.ColorMatrix=o(a.BaseFilter,{type:"ColorMatrix",fragmentSource:`precision highp float;
|
|
80
|
+
uniform sampler2D uTexture;
|
|
81
|
+
varying vec2 vTexCoord;
|
|
82
|
+
uniform mat4 uColorMatrix;
|
|
83
|
+
uniform vec4 uConstants;
|
|
84
|
+
void main() {
|
|
85
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
86
|
+
color *= uColorMatrix;
|
|
87
|
+
color += uConstants;
|
|
88
|
+
gl_FragColor = color;
|
|
89
|
+
}`,matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],mainParameter:"matrix",colorsOnly:!0,initialize:function(t){this.callSuper("initialize",t),this.matrix=this.matrix.slice(0)},applyTo2d:function(t){var r=t.imageData,e=r.data,s=e.length,h=this.matrix,n,l,f,d,g,m=this.colorsOnly;for(g=0;g<s;g+=4)n=e[g],l=e[g+1],f=e[g+2],m?(e[g]=n*h[0]+l*h[1]+f*h[2]+h[4]*255,e[g+1]=n*h[5]+l*h[6]+f*h[7]+h[9]*255,e[g+2]=n*h[10]+l*h[11]+f*h[12]+h[14]*255):(d=e[g+3],e[g]=n*h[0]+l*h[1]+f*h[2]+d*h[3]+h[4]*255,e[g+1]=n*h[5]+l*h[6]+f*h[7]+d*h[8]+h[9]*255,e[g+2]=n*h[10]+l*h[11]+f*h[12]+d*h[13]+h[14]*255,e[g+3]=n*h[15]+l*h[16]+f*h[17]+d*h[18]+h[19]*255)},getUniformLocations:function(t,r){return{uColorMatrix:t.getUniformLocation(r,"uColorMatrix"),uConstants:t.getUniformLocation(r,"uConstants")}},sendUniformData:function(t,r){var e=this.matrix,s=[e[0],e[1],e[2],e[3],e[5],e[6],e[7],e[8],e[10],e[11],e[12],e[13],e[15],e[16],e[17],e[18]],h=[e[4],e[9],e[14],e[19]];t.uniformMatrix4fv(r.uColorMatrix,!1,s),t.uniform4fv(r.uConstants,h)}}),i.Image.filters.ColorMatrix.fromObject=i.Image.filters.BaseFilter.fromObject})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.Image.filters,o=i.util.createClass;a.Brightness=o(a.BaseFilter,{type:"Brightness",fragmentSource:`precision highp float;
|
|
90
|
+
uniform sampler2D uTexture;
|
|
91
|
+
uniform float uBrightness;
|
|
92
|
+
varying vec2 vTexCoord;
|
|
93
|
+
void main() {
|
|
94
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
95
|
+
color.rgb += uBrightness;
|
|
96
|
+
gl_FragColor = color;
|
|
97
|
+
}`,brightness:0,mainParameter:"brightness",applyTo2d:function(t){if(this.brightness!==0){var r=t.imageData,e=r.data,s,h=e.length,n=Math.round(this.brightness*255);for(s=0;s<h;s+=4)e[s]=e[s]+n,e[s+1]=e[s+1]+n,e[s+2]=e[s+2]+n}},getUniformLocations:function(t,r){return{uBrightness:t.getUniformLocation(r,"uBrightness")}},sendUniformData:function(t,r){t.uniform1f(r.uBrightness,this.brightness)}}),i.Image.filters.Brightness.fromObject=i.Image.filters.BaseFilter.fromObject})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.util.object.extend,o=i.Image.filters,t=i.util.createClass;o.Convolute=t(o.BaseFilter,{type:"Convolute",opaque:!1,matrix:[0,0,0,0,1,0,0,0,0],fragmentSource:{Convolute_3_1:`precision highp float;
|
|
98
|
+
uniform sampler2D uTexture;
|
|
99
|
+
uniform float uMatrix[9];
|
|
100
|
+
uniform float uStepW;
|
|
101
|
+
uniform float uStepH;
|
|
102
|
+
varying vec2 vTexCoord;
|
|
103
|
+
void main() {
|
|
104
|
+
vec4 color = vec4(0, 0, 0, 0);
|
|
105
|
+
for (float h = 0.0; h < 3.0; h+=1.0) {
|
|
106
|
+
for (float w = 0.0; w < 3.0; w+=1.0) {
|
|
107
|
+
vec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));
|
|
108
|
+
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
gl_FragColor = color;
|
|
112
|
+
}`,Convolute_3_0:`precision highp float;
|
|
113
|
+
uniform sampler2D uTexture;
|
|
114
|
+
uniform float uMatrix[9];
|
|
115
|
+
uniform float uStepW;
|
|
116
|
+
uniform float uStepH;
|
|
117
|
+
varying vec2 vTexCoord;
|
|
118
|
+
void main() {
|
|
119
|
+
vec4 color = vec4(0, 0, 0, 1);
|
|
120
|
+
for (float h = 0.0; h < 3.0; h+=1.0) {
|
|
121
|
+
for (float w = 0.0; w < 3.0; w+=1.0) {
|
|
122
|
+
vec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));
|
|
123
|
+
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
float alpha = texture2D(uTexture, vTexCoord).a;
|
|
127
|
+
gl_FragColor = color;
|
|
128
|
+
gl_FragColor.a = alpha;
|
|
129
|
+
}`,Convolute_5_1:`precision highp float;
|
|
130
|
+
uniform sampler2D uTexture;
|
|
131
|
+
uniform float uMatrix[25];
|
|
132
|
+
uniform float uStepW;
|
|
133
|
+
uniform float uStepH;
|
|
134
|
+
varying vec2 vTexCoord;
|
|
135
|
+
void main() {
|
|
136
|
+
vec4 color = vec4(0, 0, 0, 0);
|
|
137
|
+
for (float h = 0.0; h < 5.0; h+=1.0) {
|
|
138
|
+
for (float w = 0.0; w < 5.0; w+=1.0) {
|
|
139
|
+
vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));
|
|
140
|
+
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
gl_FragColor = color;
|
|
144
|
+
}`,Convolute_5_0:`precision highp float;
|
|
145
|
+
uniform sampler2D uTexture;
|
|
146
|
+
uniform float uMatrix[25];
|
|
147
|
+
uniform float uStepW;
|
|
148
|
+
uniform float uStepH;
|
|
149
|
+
varying vec2 vTexCoord;
|
|
150
|
+
void main() {
|
|
151
|
+
vec4 color = vec4(0, 0, 0, 1);
|
|
152
|
+
for (float h = 0.0; h < 5.0; h+=1.0) {
|
|
153
|
+
for (float w = 0.0; w < 5.0; w+=1.0) {
|
|
154
|
+
vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));
|
|
155
|
+
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
float alpha = texture2D(uTexture, vTexCoord).a;
|
|
159
|
+
gl_FragColor = color;
|
|
160
|
+
gl_FragColor.a = alpha;
|
|
161
|
+
}`,Convolute_7_1:`precision highp float;
|
|
162
|
+
uniform sampler2D uTexture;
|
|
163
|
+
uniform float uMatrix[49];
|
|
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 < 7.0; h+=1.0) {
|
|
170
|
+
for (float w = 0.0; w < 7.0; w+=1.0) {
|
|
171
|
+
vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));
|
|
172
|
+
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
gl_FragColor = color;
|
|
176
|
+
}`,Convolute_7_0:`precision highp float;
|
|
177
|
+
uniform sampler2D uTexture;
|
|
178
|
+
uniform float uMatrix[49];
|
|
179
|
+
uniform float uStepW;
|
|
180
|
+
uniform float uStepH;
|
|
181
|
+
varying vec2 vTexCoord;
|
|
182
|
+
void main() {
|
|
183
|
+
vec4 color = vec4(0, 0, 0, 1);
|
|
184
|
+
for (float h = 0.0; h < 7.0; h+=1.0) {
|
|
185
|
+
for (float w = 0.0; w < 7.0; w+=1.0) {
|
|
186
|
+
vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));
|
|
187
|
+
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
float alpha = texture2D(uTexture, vTexCoord).a;
|
|
191
|
+
gl_FragColor = color;
|
|
192
|
+
gl_FragColor.a = alpha;
|
|
193
|
+
}`,Convolute_9_1:`precision highp float;
|
|
194
|
+
uniform sampler2D uTexture;
|
|
195
|
+
uniform float uMatrix[81];
|
|
196
|
+
uniform float uStepW;
|
|
197
|
+
uniform float uStepH;
|
|
198
|
+
varying vec2 vTexCoord;
|
|
199
|
+
void main() {
|
|
200
|
+
vec4 color = vec4(0, 0, 0, 0);
|
|
201
|
+
for (float h = 0.0; h < 9.0; h+=1.0) {
|
|
202
|
+
for (float w = 0.0; w < 9.0; w+=1.0) {
|
|
203
|
+
vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));
|
|
204
|
+
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
gl_FragColor = color;
|
|
208
|
+
}`,Convolute_9_0:`precision highp float;
|
|
209
|
+
uniform sampler2D uTexture;
|
|
210
|
+
uniform float uMatrix[81];
|
|
211
|
+
uniform float uStepW;
|
|
212
|
+
uniform float uStepH;
|
|
213
|
+
varying vec2 vTexCoord;
|
|
214
|
+
void main() {
|
|
215
|
+
vec4 color = vec4(0, 0, 0, 1);
|
|
216
|
+
for (float h = 0.0; h < 9.0; h+=1.0) {
|
|
217
|
+
for (float w = 0.0; w < 9.0; w+=1.0) {
|
|
218
|
+
vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));
|
|
219
|
+
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
float alpha = texture2D(uTexture, vTexCoord).a;
|
|
223
|
+
gl_FragColor = color;
|
|
224
|
+
gl_FragColor.a = alpha;
|
|
225
|
+
}`},retrieveShader:function(r){var e=Math.sqrt(this.matrix.length),s=this.type+"_"+e+"_"+(this.opaque?1:0),h=this.fragmentSource[s];return r.programCache.hasOwnProperty(s)||(r.programCache[s]=this.createProgram(r.context,h)),r.programCache[s]},applyTo2d:function(r){var e=r.imageData,s=e.data,h=this.matrix,n=Math.round(Math.sqrt(h.length)),l=Math.floor(n/2),f=e.width,d=e.height,g=r.ctx.createImageData(f,d),m=g.data,p=this.opaque?1:0,_,w,D,B,N,G,z,H,U,K,Q,J,v;for(Q=0;Q<d;Q++)for(K=0;K<f;K++){for(N=(Q*f+K)*4,_=0,w=0,D=0,B=0,v=0;v<n;v++)for(J=0;J<n;J++)z=Q+v-l,G=K+J-l,!(z<0||z>=d||G<0||G>=f)&&(H=(z*f+G)*4,U=h[v*n+J],_+=s[H]*U,w+=s[H+1]*U,D+=s[H+2]*U,p||(B+=s[H+3]*U));m[N]=_,m[N+1]=w,m[N+2]=D,p?m[N+3]=s[N+3]:m[N+3]=B}r.imageData=g},getUniformLocations:function(r,e){return{uMatrix:r.getUniformLocation(e,"uMatrix"),uOpaque:r.getUniformLocation(e,"uOpaque"),uHalfSize:r.getUniformLocation(e,"uHalfSize"),uSize:r.getUniformLocation(e,"uSize")}},sendUniformData:function(r,e){r.uniform1fv(e.uMatrix,this.matrix)},toObject:function(){return a(this.callSuper("toObject"),{opaque:this.opaque,matrix:this.matrix})}}),i.Image.filters.Convolute.fromObject=i.Image.filters.BaseFilter.fromObject})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.Image.filters,o=i.util.createClass;a.Grayscale=o(a.BaseFilter,{type:"Grayscale",fragmentSource:{average:`precision highp float;
|
|
226
|
+
uniform sampler2D uTexture;
|
|
227
|
+
varying vec2 vTexCoord;
|
|
228
|
+
void main() {
|
|
229
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
230
|
+
float average = (color.r + color.b + color.g) / 3.0;
|
|
231
|
+
gl_FragColor = vec4(average, average, average, color.a);
|
|
232
|
+
}`,lightness:`precision highp float;
|
|
233
|
+
uniform sampler2D uTexture;
|
|
234
|
+
uniform int uMode;
|
|
235
|
+
varying vec2 vTexCoord;
|
|
236
|
+
void main() {
|
|
237
|
+
vec4 col = texture2D(uTexture, vTexCoord);
|
|
238
|
+
float average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;
|
|
239
|
+
gl_FragColor = vec4(average, average, average, col.a);
|
|
240
|
+
}`,luminosity:`precision highp float;
|
|
241
|
+
uniform sampler2D uTexture;
|
|
242
|
+
uniform int uMode;
|
|
243
|
+
varying vec2 vTexCoord;
|
|
244
|
+
void main() {
|
|
245
|
+
vec4 col = texture2D(uTexture, vTexCoord);
|
|
246
|
+
float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;
|
|
247
|
+
gl_FragColor = vec4(average, average, average, col.a);
|
|
248
|
+
}`},mode:"average",mainParameter:"mode",applyTo2d:function(t){var r=t.imageData,e=r.data,s,h=e.length,n,l=this.mode;for(s=0;s<h;s+=4)l==="average"?n=(e[s]+e[s+1]+e[s+2])/3:l==="lightness"?n=(Math.min(e[s],e[s+1],e[s+2])+Math.max(e[s],e[s+1],e[s+2]))/2:l==="luminosity"&&(n=.21*e[s]+.72*e[s+1]+.07*e[s+2]),e[s]=n,e[s+1]=n,e[s+2]=n},retrieveShader:function(t){var r=this.type+"_"+this.mode;if(!t.programCache.hasOwnProperty(r)){var e=this.fragmentSource[this.mode];t.programCache[r]=this.createProgram(t.context,e)}return t.programCache[r]},getUniformLocations:function(t,r){return{uMode:t.getUniformLocation(r,"uMode")}},sendUniformData:function(t,r){var e=1;t.uniform1i(r.uMode,e)},isNeutralState:function(){return!1}}),i.Image.filters.Grayscale.fromObject=i.Image.filters.BaseFilter.fromObject})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.Image.filters,o=i.util.createClass;a.Invert=o(a.BaseFilter,{type:"Invert",fragmentSource:`precision highp float;
|
|
249
|
+
uniform sampler2D uTexture;
|
|
250
|
+
uniform int uInvert;
|
|
251
|
+
varying vec2 vTexCoord;
|
|
252
|
+
void main() {
|
|
253
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
254
|
+
if (uInvert == 1) {
|
|
255
|
+
gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);
|
|
256
|
+
} else {
|
|
257
|
+
gl_FragColor = color;
|
|
258
|
+
}
|
|
259
|
+
}`,invert:!0,mainParameter:"invert",applyTo2d:function(t){var r=t.imageData,e=r.data,s,h=e.length;for(s=0;s<h;s+=4)e[s]=255-e[s],e[s+1]=255-e[s+1],e[s+2]=255-e[s+2]},isNeutralState:function(){return!this.invert},getUniformLocations:function(t,r){return{uInvert:t.getUniformLocation(r,"uInvert")}},sendUniformData:function(t,r){t.uniform1i(r.uInvert,this.invert)}}),i.Image.filters.Invert.fromObject=i.Image.filters.BaseFilter.fromObject})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.util.object.extend,o=i.Image.filters,t=i.util.createClass;o.Noise=t(o.BaseFilter,{type:"Noise",fragmentSource:`precision highp float;
|
|
260
|
+
uniform sampler2D uTexture;
|
|
261
|
+
uniform float uStepH;
|
|
262
|
+
uniform float uNoise;
|
|
263
|
+
uniform float uSeed;
|
|
264
|
+
varying vec2 vTexCoord;
|
|
265
|
+
float rand(vec2 co, float seed, float vScale) {
|
|
266
|
+
return fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);
|
|
267
|
+
}
|
|
268
|
+
void main() {
|
|
269
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
270
|
+
color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;
|
|
271
|
+
gl_FragColor = color;
|
|
272
|
+
}`,mainParameter:"noise",noise:0,applyTo2d:function(r){if(this.noise!==0){var e=r.imageData,s=e.data,h,n=s.length,l=this.noise,f;for(h=0,n=s.length;h<n;h+=4)f=(.5-Math.random())*l,s[h]+=f,s[h+1]+=f,s[h+2]+=f}},getUniformLocations:function(r,e){return{uNoise:r.getUniformLocation(e,"uNoise"),uSeed:r.getUniformLocation(e,"uSeed")}},sendUniformData:function(r,e){r.uniform1f(e.uNoise,this.noise/255),r.uniform1f(e.uSeed,Math.random())},toObject:function(){return a(this.callSuper("toObject"),{noise:this.noise})}}),i.Image.filters.Noise.fromObject=i.Image.filters.BaseFilter.fromObject})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.Image.filters,o=i.util.createClass;a.Pixelate=o(a.BaseFilter,{type:"Pixelate",blocksize:4,mainParameter:"blocksize",fragmentSource:`precision highp float;
|
|
273
|
+
uniform sampler2D uTexture;
|
|
274
|
+
uniform float uBlocksize;
|
|
275
|
+
uniform float uStepW;
|
|
276
|
+
uniform float uStepH;
|
|
277
|
+
varying vec2 vTexCoord;
|
|
278
|
+
void main() {
|
|
279
|
+
float blockW = uBlocksize * uStepW;
|
|
280
|
+
float blockH = uBlocksize * uStepW;
|
|
281
|
+
int posX = int(vTexCoord.x / blockW);
|
|
282
|
+
int posY = int(vTexCoord.y / blockH);
|
|
283
|
+
float fposX = float(posX);
|
|
284
|
+
float fposY = float(posY);
|
|
285
|
+
vec2 squareCoords = vec2(fposX * blockW, fposY * blockH);
|
|
286
|
+
vec4 color = texture2D(uTexture, squareCoords);
|
|
287
|
+
gl_FragColor = color;
|
|
288
|
+
}`,applyTo2d:function(t){var r=t.imageData,e=r.data,s=r.height,h=r.width,n,l,f,d,g,m,p,_,w,D,B;for(l=0;l<s;l+=this.blocksize)for(f=0;f<h;f+=this.blocksize)for(n=l*4*h+f*4,d=e[n],g=e[n+1],m=e[n+2],p=e[n+3],D=Math.min(l+this.blocksize,s),B=Math.min(f+this.blocksize,h),_=l;_<D;_++)for(w=f;w<B;w++)n=_*4*h+w*4,e[n]=d,e[n+1]=g,e[n+2]=m,e[n+3]=p},isNeutralState:function(){return this.blocksize===1},getUniformLocations:function(t,r){return{uBlocksize:t.getUniformLocation(r,"uBlocksize"),uStepW:t.getUniformLocation(r,"uStepW"),uStepH:t.getUniformLocation(r,"uStepH")}},sendUniformData:function(t,r){t.uniform1f(r.uBlocksize,this.blocksize)}}),i.Image.filters.Pixelate.fromObject=i.Image.filters.BaseFilter.fromObject})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.util.object.extend,o=i.Image.filters,t=i.util.createClass;o.RemoveColor=t(o.BaseFilter,{type:"RemoveColor",color:"#FFFFFF",fragmentSource:`precision highp float;
|
|
289
|
+
uniform sampler2D uTexture;
|
|
290
|
+
uniform vec4 uLow;
|
|
291
|
+
uniform vec4 uHigh;
|
|
292
|
+
varying vec2 vTexCoord;
|
|
293
|
+
void main() {
|
|
294
|
+
gl_FragColor = texture2D(uTexture, vTexCoord);
|
|
295
|
+
if(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {
|
|
296
|
+
gl_FragColor.a = 0.0;
|
|
297
|
+
}
|
|
298
|
+
}`,distance:.02,useAlpha:!1,applyTo2d:function(r){var e=r.imageData,s=e.data,h,n=this.distance*255,l,f,d,g=new i.Color(this.color).getSource(),m=[g[0]-n,g[1]-n,g[2]-n],p=[g[0]+n,g[1]+n,g[2]+n];for(h=0;h<s.length;h+=4)l=s[h],f=s[h+1],d=s[h+2],l>m[0]&&f>m[1]&&d>m[2]&&l<p[0]&&f<p[1]&&d<p[2]&&(s[h+3]=0)},getUniformLocations:function(r,e){return{uLow:r.getUniformLocation(e,"uLow"),uHigh:r.getUniformLocation(e,"uHigh")}},sendUniformData:function(r,e){var s=new i.Color(this.color).getSource(),h=parseFloat(this.distance),n=[0+s[0]/255-h,0+s[1]/255-h,0+s[2]/255-h,1],l=[s[0]/255+h,s[1]/255+h,s[2]/255+h,1];r.uniform4fv(e.uLow,n),r.uniform4fv(e.uHigh,l)},toObject:function(){return a(this.callSuper("toObject"),{color:this.color,distance:this.distance})}}),i.Image.filters.RemoveColor.fromObject=i.Image.filters.BaseFilter.fromObject})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.Image.filters,o=i.util.createClass,t={Brownie:[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0],Vintage:[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0],Kodachrome:[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0],Technicolor:[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0],Polaroid:[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0],Sepia:[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0],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]};for(var r in t)a[r]=o(a.ColorMatrix,{type:r,matrix:t[r],mainParameter:!1,colorsOnly:!0}),i.Image.filters[r].fromObject=i.Image.filters.BaseFilter.fromObject})(F);(function(c){"use strict";var i=c.fabric,a=i.Image.filters,o=i.util.createClass;a.BlendColor=o(a.BaseFilter,{type:"BlendColor",color:"#F95C63",mode:"multiply",alpha:1,fragmentSource:{multiply:`gl_FragColor.rgb *= uColor.rgb;
|
|
299
|
+
`,screen:`gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);
|
|
300
|
+
`,add:`gl_FragColor.rgb += uColor.rgb;
|
|
301
|
+
`,diff:`gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);
|
|
302
|
+
`,subtract:`gl_FragColor.rgb -= uColor.rgb;
|
|
303
|
+
`,lighten:`gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);
|
|
304
|
+
`,darken:`gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);
|
|
305
|
+
`,exclusion:`gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);
|
|
306
|
+
`,overlay:`if (uColor.r < 0.5) {
|
|
307
|
+
gl_FragColor.r *= 2.0 * uColor.r;
|
|
308
|
+
} else {
|
|
309
|
+
gl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);
|
|
310
|
+
}
|
|
311
|
+
if (uColor.g < 0.5) {
|
|
312
|
+
gl_FragColor.g *= 2.0 * uColor.g;
|
|
313
|
+
} else {
|
|
314
|
+
gl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);
|
|
315
|
+
}
|
|
316
|
+
if (uColor.b < 0.5) {
|
|
317
|
+
gl_FragColor.b *= 2.0 * uColor.b;
|
|
318
|
+
} else {
|
|
319
|
+
gl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);
|
|
320
|
+
}
|
|
321
|
+
`,tint:`gl_FragColor.rgb *= (1.0 - uColor.a);
|
|
322
|
+
gl_FragColor.rgb += uColor.rgb;
|
|
323
|
+
`},buildSource:function(t){return`precision highp float;
|
|
324
|
+
uniform sampler2D uTexture;
|
|
325
|
+
uniform vec4 uColor;
|
|
326
|
+
varying vec2 vTexCoord;
|
|
327
|
+
void main() {
|
|
328
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
329
|
+
gl_FragColor = color;
|
|
330
|
+
if (color.a > 0.0) {
|
|
331
|
+
`+this.fragmentSource[t]+`}
|
|
332
|
+
}`},retrieveShader:function(t){var r=this.type+"_"+this.mode,e;return t.programCache.hasOwnProperty(r)||(e=this.buildSource(this.mode),t.programCache[r]=this.createProgram(t.context,e)),t.programCache[r]},applyTo2d:function(t){var r=t.imageData,e=r.data,s=e.length,h,n,l,f,d,g,m,p=1-this.alpha;m=new i.Color(this.color).getSource(),h=m[0]*this.alpha,n=m[1]*this.alpha,l=m[2]*this.alpha;for(var _=0;_<s;_+=4)switch(f=e[_],d=e[_+1],g=e[_+2],this.mode){case"multiply":e[_]=f*h/255,e[_+1]=d*n/255,e[_+2]=g*l/255;break;case"screen":e[_]=255-(255-f)*(255-h)/255,e[_+1]=255-(255-d)*(255-n)/255,e[_+2]=255-(255-g)*(255-l)/255;break;case"add":e[_]=f+h,e[_+1]=d+n,e[_+2]=g+l;break;case"diff":case"difference":e[_]=Math.abs(f-h),e[_+1]=Math.abs(d-n),e[_+2]=Math.abs(g-l);break;case"subtract":e[_]=f-h,e[_+1]=d-n,e[_+2]=g-l;break;case"darken":e[_]=Math.min(f,h),e[_+1]=Math.min(d,n),e[_+2]=Math.min(g,l);break;case"lighten":e[_]=Math.max(f,h),e[_+1]=Math.max(d,n),e[_+2]=Math.max(g,l);break;case"overlay":e[_]=h<128?2*f*h/255:255-2*(255-f)*(255-h)/255,e[_+1]=n<128?2*d*n/255:255-2*(255-d)*(255-n)/255,e[_+2]=l<128?2*g*l/255:255-2*(255-g)*(255-l)/255;break;case"exclusion":e[_]=h+f-2*h*f/255,e[_+1]=n+d-2*n*d/255,e[_+2]=l+g-2*l*g/255;break;case"tint":e[_]=h+f*p,e[_+1]=n+d*p,e[_+2]=l+g*p}},getUniformLocations:function(t,r){return{uColor:t.getUniformLocation(r,"uColor")}},sendUniformData:function(t,r){var e=new i.Color(this.color).getSource();e[0]=this.alpha*e[0]/255,e[1]=this.alpha*e[1]/255,e[2]=this.alpha*e[2]/255,e[3]=this.alpha,t.uniform4fv(r.uColor,e)},toObject:function(){return{type:this.type,color:this.color,mode:this.mode,alpha:this.alpha}}}),i.Image.filters.BlendColor.fromObject=i.Image.filters.BaseFilter.fromObject})(F);(function(c){"use strict";var i=c.fabric,a=i.Image.filters,o=i.util.createClass;a.BlendImage=o(a.BaseFilter,{type:"BlendImage",image:null,mode:"multiply",alpha:1,vertexSource:`attribute vec2 aPosition;
|
|
333
|
+
varying vec2 vTexCoord;
|
|
334
|
+
varying vec2 vTexCoord2;
|
|
335
|
+
uniform mat3 uTransformMatrix;
|
|
336
|
+
void main() {
|
|
337
|
+
vTexCoord = aPosition;
|
|
338
|
+
vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;
|
|
339
|
+
gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
|
|
340
|
+
}`,fragmentSource:{multiply:`precision highp float;
|
|
341
|
+
uniform sampler2D uTexture;
|
|
342
|
+
uniform sampler2D uImage;
|
|
343
|
+
uniform vec4 uColor;
|
|
344
|
+
varying vec2 vTexCoord;
|
|
345
|
+
varying vec2 vTexCoord2;
|
|
346
|
+
void main() {
|
|
347
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
348
|
+
vec4 color2 = texture2D(uImage, vTexCoord2);
|
|
349
|
+
color.rgba *= color2.rgba;
|
|
350
|
+
gl_FragColor = color;
|
|
351
|
+
}`,mask:`precision highp float;
|
|
352
|
+
uniform sampler2D uTexture;
|
|
353
|
+
uniform sampler2D uImage;
|
|
354
|
+
uniform vec4 uColor;
|
|
355
|
+
varying vec2 vTexCoord;
|
|
356
|
+
varying vec2 vTexCoord2;
|
|
357
|
+
void main() {
|
|
358
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
359
|
+
vec4 color2 = texture2D(uImage, vTexCoord2);
|
|
360
|
+
color.a = color2.a;
|
|
361
|
+
gl_FragColor = color;
|
|
362
|
+
}`},retrieveShader:function(t){var r=this.type+"_"+this.mode,e=this.fragmentSource[this.mode];return t.programCache.hasOwnProperty(r)||(t.programCache[r]=this.createProgram(t.context,e)),t.programCache[r]},applyToWebGL:function(t){var r=t.context,e=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(r,e,r.TEXTURE1),this.callSuper("applyToWebGL",t),this.unbindAdditionalTexture(r,r.TEXTURE1)},createTexture:function(t,r){return t.getCachedTexture(r.cacheKey,r._element)},calculateMatrix:function(){var t=this.image,r=t._element.width,e=t._element.height;return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/r,-t.top/e,1]},applyTo2d:function(t){var r=t.imageData,e=t.filterBackend.resources,s=r.data,h=s.length,n=r.width,l=r.height,f,d,g,m,p,_,w,D,B,N,G=this.image,z;e.blendImage||(e.blendImage=i.util.createCanvasElement()),B=e.blendImage,N=B.getContext("2d"),B.width!==n||B.height!==l?(B.width=n,B.height=l):N.clearRect(0,0,n,l),N.setTransform(G.scaleX,0,0,G.scaleY,G.left,G.top),N.drawImage(G._element,0,0,n,l),z=N.getImageData(0,0,n,l).data;for(var H=0;H<h;H+=4)switch(p=s[H],_=s[H+1],w=s[H+2],D=s[H+3],f=z[H],d=z[H+1],g=z[H+2],m=z[H+3],this.mode){case"multiply":s[H]=p*f/255,s[H+1]=_*d/255,s[H+2]=w*g/255,s[H+3]=D*m/255;break;case"mask":s[H+3]=m;break}},getUniformLocations:function(t,r){return{uTransformMatrix:t.getUniformLocation(r,"uTransformMatrix"),uImage:t.getUniformLocation(r,"uImage")}},sendUniformData:function(t,r){var e=this.calculateMatrix();t.uniform1i(r.uImage,1),t.uniformMatrix3fv(r.uTransformMatrix,!1,e)},toObject:function(){return{type:this.type,image:this.image&&this.image.toObject(),mode:this.mode,alpha:this.alpha}}}),i.Image.filters.BlendImage.fromObject=function(t,r){i.Image.fromObject(t.image,function(e){var s=i.util.object.clone(t);s.image=e,r(new i.Image.filters.BlendImage(s))})}})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=Math.pow,o=Math.floor,t=Math.sqrt,r=Math.abs,e=Math.round,s=Math.sin,h=Math.ceil,n=i.Image.filters,l=i.util.createClass;n.Resize=l(n.BaseFilter,{type:"Resize",resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3,getUniformLocations:function(f,d){return{uDelta:f.getUniformLocation(d,"uDelta"),uTaps:f.getUniformLocation(d,"uTaps")}},sendUniformData:function(f,d){f.uniform2fv(d.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),f.uniform1fv(d.uTaps,this.taps)},retrieveShader:function(f){var d=this.getFilterWindow(),g=this.type+"_"+d;if(!f.programCache.hasOwnProperty(g)){var m=this.generateShader(d);f.programCache[g]=this.createProgram(f.context,m)}return f.programCache[g]},getFilterWindow:function(){var f=this.tempScale;return Math.ceil(this.lanczosLobes/f)},getTaps:function(){for(var f=this.lanczosCreate(this.lanczosLobes),d=this.tempScale,g=this.getFilterWindow(),m=new Array(g),p=1;p<=g;p++)m[p-1]=f(p*d);return m},generateShader:function(m){for(var d=new Array(m),g=this.fragmentSourceTOP,m,p=1;p<=m;p++)d[p-1]=p+".0 * uDelta";return g+="uniform float uTaps["+m+`];
|
|
363
|
+
`,g+=`void main() {
|
|
364
|
+
`,g+=` vec4 color = texture2D(uTexture, vTexCoord);
|
|
365
|
+
`,g+=` float sum = 1.0;
|
|
366
|
+
`,d.forEach(function(_,w){g+=" color += texture2D(uTexture, vTexCoord + "+_+") * uTaps["+w+`];
|
|
367
|
+
`,g+=" color += texture2D(uTexture, vTexCoord - "+_+") * uTaps["+w+`];
|
|
368
|
+
`,g+=" sum += 2.0 * uTaps["+w+`];
|
|
369
|
+
`}),g+=` gl_FragColor = color / sum;
|
|
370
|
+
`,g+="}",g},fragmentSourceTOP:`precision highp float;
|
|
371
|
+
uniform sampler2D uTexture;
|
|
372
|
+
uniform vec2 uDelta;
|
|
373
|
+
varying vec2 vTexCoord;
|
|
374
|
+
`,applyTo:function(f){f.webgl?(f.passes++,this.width=f.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=f.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),f.destinationWidth=this.dW,this._setupFrameBuffer(f),this.applyToWebGL(f),this._swapTextures(f),f.sourceWidth=f.destinationWidth,this.height=f.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),f.destinationHeight=this.dH,this._setupFrameBuffer(f),this.applyToWebGL(f),this._swapTextures(f),f.sourceHeight=f.destinationHeight):this.applyTo2d(f)},isNeutralState:function(){return this.scaleX===1&&this.scaleY===1},lanczosCreate:function(f){return function(d){if(d>=f||d<=-f)return 0;if(d<11920929e-14&&d>-11920929e-14)return 1;d*=Math.PI;var g=d/f;return s(d)/d*s(g)/g}},applyTo2d:function(f){var d=f.imageData,g=this.scaleX,m=this.scaleY;this.rcpScaleX=1/g,this.rcpScaleY=1/m;var p=d.width,_=d.height,w=e(p*g),D=e(_*m),B;this.resizeType==="sliceHack"?B=this.sliceByTwo(f,p,_,w,D):this.resizeType==="hermite"?B=this.hermiteFastResize(f,p,_,w,D):this.resizeType==="bilinear"?B=this.bilinearFiltering(f,p,_,w,D):this.resizeType==="lanczos"&&(B=this.lanczosResize(f,p,_,w,D)),f.imageData=B},sliceByTwo:function(f,d,g,m,p){var _=f.imageData,w=.5,D=!1,B=!1,N=d*w,G=g*w,z=i.filterBackend.resources,H,U,K=0,Q=0,J=d,v=0;for(z.sliceByTwo||(z.sliceByTwo=document.createElement("canvas")),H=z.sliceByTwo,(H.width<d*1.5||H.height<g)&&(H.width=d*1.5,H.height=g),U=H.getContext("2d"),U.clearRect(0,0,d*1.5,g),U.putImageData(_,0,0),m=o(m),p=o(p);!D||!B;)d=N,g=G,m<o(N*w)?N=o(N*w):(N=m,D=!0),p<o(G*w)?G=o(G*w):(G=p,B=!0),U.drawImage(H,K,Q,d,g,J,v,N,G),K=J,Q=v,v+=G;return U.getImageData(K,Q,m,p)},lanczosResize:function(f,d,g,m,p){function _(S){var C,P,x,y,T,E,L,k,W,Y,V;for(v.x=(S+.5)*G,b.x=o(v.x),C=0;C<p;C++){for(v.y=(C+.5)*z,b.y=o(v.y),T=0,E=0,L=0,k=0,W=0,P=b.x-K;P<=b.x+K;P++)if(!(P<0||P>=d)){Y=o(1e3*r(P-v.x)),J[Y]||(J[Y]={});for(var M=b.y-Q;M<=b.y+Q;M++)M<0||M>=g||(V=o(1e3*r(M-v.y)),J[Y][V]||(J[Y][V]=N(t(a(Y*H,2)+a(V*U,2))/1e3)),x=J[Y][V],x>0&&(y=(M*d+P)*4,T+=x,E+=x*w[y],L+=x*w[y+1],k+=x*w[y+2],W+=x*w[y+3]))}y=(C*m+S)*4,B[y]=E/T,B[y+1]=L/T,B[y+2]=k/T,B[y+3]=W/T}return++S<m?_(S):D}var w=f.imageData.data,D=f.ctx.createImageData(m,p),B=D.data,N=this.lanczosCreate(this.lanczosLobes),G=this.rcpScaleX,z=this.rcpScaleY,H=2/this.rcpScaleX,U=2/this.rcpScaleY,K=h(G*this.lanczosLobes/2),Q=h(z*this.lanczosLobes/2),J={},v={},b={};return _(0)},bilinearFiltering:function(f,d,g,m,p){var _,w,D,B,N,G,z,H,U,K,Q,J,v=0,b,S=this.rcpScaleX,C=this.rcpScaleY,P=4*(d-1),x=f.imageData,y=x.data,T=f.ctx.createImageData(m,p),E=T.data;for(z=0;z<p;z++)for(H=0;H<m;H++)for(N=o(S*H),G=o(C*z),U=S*H-N,K=C*z-G,b=4*(G*d+N),Q=0;Q<4;Q++)_=y[b+Q],w=y[b+4+Q],D=y[b+P+Q],B=y[b+P+4+Q],J=_*(1-U)*(1-K)+w*U*(1-K)+D*K*(1-U)+B*U*K,E[v++]=J;return T},hermiteFastResize:function(f,d,g,m,p){for(var _=this.rcpScaleX,w=this.rcpScaleY,D=h(_/2),B=h(w/2),N=f.imageData,G=N.data,z=f.ctx.createImageData(m,p),H=z.data,U=0;U<p;U++)for(var K=0;K<m;K++){for(var Q=(K+U*m)*4,J=0,v=0,b=0,S=0,C=0,P=0,x=0,y=(U+.5)*w,T=o(U*w);T<(U+1)*w;T++)for(var E=r(y-(T+.5))/B,L=(K+.5)*_,k=E*E,W=o(K*_);W<(K+1)*_;W++){var Y=r(L-(W+.5))/D,V=t(k+Y*Y);V>1&&V<-1||(J=2*V*V*V-3*V*V+1,J>0&&(Y=4*(W+T*d),x+=J*G[Y+3],b+=J,G[Y+3]<255&&(J=J*G[Y+3]/250),S+=J*G[Y],C+=J*G[Y+1],P+=J*G[Y+2],v+=J))}H[Q]=S/v,H[Q+1]=C/v,H[Q+2]=P/v,H[Q+3]=x/b}return z},toObject:function(){return{type:this.type,scaleX:this.scaleX,scaleY:this.scaleY,resizeType:this.resizeType,lanczosLobes:this.lanczosLobes}}}),i.Image.filters.Resize.fromObject=i.Image.filters.BaseFilter.fromObject})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.Image.filters,o=i.util.createClass;a.Contrast=o(a.BaseFilter,{type:"Contrast",fragmentSource:`precision highp float;
|
|
375
|
+
uniform sampler2D uTexture;
|
|
376
|
+
uniform float uContrast;
|
|
377
|
+
varying vec2 vTexCoord;
|
|
378
|
+
void main() {
|
|
379
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
380
|
+
float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));
|
|
381
|
+
color.rgb = contrastF * (color.rgb - 0.5) + 0.5;
|
|
382
|
+
gl_FragColor = color;
|
|
383
|
+
}`,contrast:0,mainParameter:"contrast",applyTo2d:function(t){if(this.contrast!==0){var r=t.imageData,e,h,s=r.data,h=s.length,n=Math.floor(this.contrast*255),l=259*(n+255)/(255*(259-n));for(e=0;e<h;e+=4)s[e]=l*(s[e]-128)+128,s[e+1]=l*(s[e+1]-128)+128,s[e+2]=l*(s[e+2]-128)+128}},getUniformLocations:function(t,r){return{uContrast:t.getUniformLocation(r,"uContrast")}},sendUniformData:function(t,r){t.uniform1f(r.uContrast,this.contrast)}}),i.Image.filters.Contrast.fromObject=i.Image.filters.BaseFilter.fromObject})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.Image.filters,o=i.util.createClass;a.Saturation=o(a.BaseFilter,{type:"Saturation",fragmentSource:`precision highp float;
|
|
384
|
+
uniform sampler2D uTexture;
|
|
385
|
+
uniform float uSaturation;
|
|
386
|
+
varying vec2 vTexCoord;
|
|
387
|
+
void main() {
|
|
388
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
389
|
+
float rgMax = max(color.r, color.g);
|
|
390
|
+
float rgbMax = max(rgMax, color.b);
|
|
391
|
+
color.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;
|
|
392
|
+
color.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;
|
|
393
|
+
color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;
|
|
394
|
+
gl_FragColor = color;
|
|
395
|
+
}`,saturation:0,mainParameter:"saturation",applyTo2d:function(t){if(this.saturation!==0){var r=t.imageData,e=r.data,s=e.length,h=-this.saturation,n,l;for(n=0;n<s;n+=4)l=Math.max(e[n],e[n+1],e[n+2]),e[n]+=l!==e[n]?(l-e[n])*h:0,e[n+1]+=l!==e[n+1]?(l-e[n+1])*h:0,e[n+2]+=l!==e[n+2]?(l-e[n+2])*h:0}},getUniformLocations:function(t,r){return{uSaturation:t.getUniformLocation(r,"uSaturation")}},sendUniformData:function(t,r){t.uniform1f(r.uSaturation,-this.saturation)}}),i.Image.filters.Saturation.fromObject=i.Image.filters.BaseFilter.fromObject})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.Image.filters,o=i.util.createClass;a.Vibrance=o(a.BaseFilter,{type:"Vibrance",fragmentSource:`precision highp float;
|
|
396
|
+
uniform sampler2D uTexture;
|
|
397
|
+
uniform float uVibrance;
|
|
398
|
+
varying vec2 vTexCoord;
|
|
399
|
+
void main() {
|
|
400
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
401
|
+
float max = max(color.r, max(color.g, color.b));
|
|
402
|
+
float avg = (color.r + color.g + color.b) / 3.0;
|
|
403
|
+
float amt = (abs(max - avg) * 2.0) * uVibrance;
|
|
404
|
+
color.r += max != color.r ? (max - color.r) * amt : 0.00;
|
|
405
|
+
color.g += max != color.g ? (max - color.g) * amt : 0.00;
|
|
406
|
+
color.b += max != color.b ? (max - color.b) * amt : 0.00;
|
|
407
|
+
gl_FragColor = color;
|
|
408
|
+
}`,vibrance:0,mainParameter:"vibrance",applyTo2d:function(t){if(this.vibrance!==0){var r=t.imageData,e=r.data,s=e.length,h=-this.vibrance,n,l,f,d;for(n=0;n<s;n+=4)l=Math.max(e[n],e[n+1],e[n+2]),f=(e[n]+e[n+1]+e[n+2])/3,d=Math.abs(l-f)*2/255*h,e[n]+=l!==e[n]?(l-e[n])*d:0,e[n+1]+=l!==e[n+1]?(l-e[n+1])*d:0,e[n+2]+=l!==e[n+2]?(l-e[n+2])*d:0}},getUniformLocations:function(t,r){return{uVibrance:t.getUniformLocation(r,"uVibrance")}},sendUniformData:function(t,r){t.uniform1f(r.uVibrance,-this.vibrance)}}),i.Image.filters.Vibrance.fromObject=i.Image.filters.BaseFilter.fromObject})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.Image.filters,o=i.util.createClass;a.Blur=o(a.BaseFilter,{type:"Blur",fragmentSource:`precision highp float;
|
|
409
|
+
uniform sampler2D uTexture;
|
|
410
|
+
uniform vec2 uDelta;
|
|
411
|
+
varying vec2 vTexCoord;
|
|
412
|
+
const float nSamples = 15.0;
|
|
413
|
+
vec3 v3offset = vec3(12.9898, 78.233, 151.7182);
|
|
414
|
+
float random(vec3 scale) {
|
|
415
|
+
return fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);
|
|
416
|
+
}
|
|
417
|
+
void main() {
|
|
418
|
+
vec4 color = vec4(0.0);
|
|
419
|
+
float total = 0.0;
|
|
420
|
+
float offset = random(v3offset);
|
|
421
|
+
for (float t = -nSamples; t <= nSamples; t++) {
|
|
422
|
+
float percent = (t + offset - 0.5) / nSamples;
|
|
423
|
+
float weight = 1.0 - abs(percent);
|
|
424
|
+
color += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;
|
|
425
|
+
total += weight;
|
|
426
|
+
}
|
|
427
|
+
gl_FragColor = color / total;
|
|
428
|
+
}`,blur:0,mainParameter:"blur",applyTo:function(t){t.webgl?(this.aspectRatio=t.sourceWidth/t.sourceHeight,t.passes++,this._setupFrameBuffer(t),this.horizontal=!0,this.applyToWebGL(t),this._swapTextures(t),this._setupFrameBuffer(t),this.horizontal=!1,this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)},applyTo2d:function(t){t.imageData=this.simpleBlur(t)},simpleBlur:function(t){var r=t.filterBackend.resources,e,s,h=t.imageData.width,n=t.imageData.height;r.blurLayer1||(r.blurLayer1=i.util.createCanvasElement(),r.blurLayer2=i.util.createCanvasElement()),e=r.blurLayer1,s=r.blurLayer2,(e.width!==h||e.height!==n)&&(s.width=e.width=h,s.height=e.height=n);var l=e.getContext("2d"),f=s.getContext("2d"),d=15,g,m,p,_,w=this.blur*.06*.5;for(l.putImageData(t.imageData,0,0),f.clearRect(0,0,h,n),_=-d;_<=d;_++)g=(Math.random()-.5)/4,m=_/d,p=w*m*h+g,f.globalAlpha=1-Math.abs(m),f.drawImage(e,p,g),l.drawImage(s,0,0),f.globalAlpha=1,f.clearRect(0,0,s.width,s.height);for(_=-d;_<=d;_++)g=(Math.random()-.5)/4,m=_/d,p=w*m*n+g,f.globalAlpha=1-Math.abs(m),f.drawImage(e,g,p),l.drawImage(s,0,0),f.globalAlpha=1,f.clearRect(0,0,s.width,s.height);t.ctx.drawImage(e,0,0);var D=t.ctx.getImageData(0,0,e.width,e.height);return l.globalAlpha=1,l.clearRect(0,0,e.width,e.height),D},getUniformLocations:function(t,r){return{delta:t.getUniformLocation(r,"uDelta")}},sendUniformData:function(t,r){var e=this.chooseRightDelta();t.uniform2fv(r.delta,e)},chooseRightDelta:function(){var t=1,r=[0,0],e;return this.horizontal?this.aspectRatio>1&&(t=1/this.aspectRatio):this.aspectRatio<1&&(t=this.aspectRatio),e=t*this.blur*.12,this.horizontal?r[0]=e:r[1]=e,r}}),a.Blur.fromObject=i.Image.filters.BaseFilter.fromObject})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.Image.filters,o=i.util.createClass;a.Gamma=o(a.BaseFilter,{type:"Gamma",fragmentSource:`precision highp float;
|
|
429
|
+
uniform sampler2D uTexture;
|
|
430
|
+
uniform vec3 uGamma;
|
|
431
|
+
varying vec2 vTexCoord;
|
|
432
|
+
void main() {
|
|
433
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
434
|
+
vec3 correction = (1.0 / uGamma);
|
|
435
|
+
color.r = pow(color.r, correction.r);
|
|
436
|
+
color.g = pow(color.g, correction.g);
|
|
437
|
+
color.b = pow(color.b, correction.b);
|
|
438
|
+
gl_FragColor = color;
|
|
439
|
+
gl_FragColor.rgb *= color.a;
|
|
440
|
+
}`,gamma:[1,1,1],mainParameter:"gamma",initialize:function(t){this.gamma=[1,1,1],a.BaseFilter.prototype.initialize.call(this,t)},applyTo2d:function(t){var r=t.imageData,e=r.data,s=this.gamma,h=e.length,n=1/s[0],l=1/s[1],f=1/s[2],d;for(this.rVals||(this.rVals=new Uint8Array(256),this.gVals=new Uint8Array(256),this.bVals=new Uint8Array(256)),d=0,h=256;d<h;d++)this.rVals[d]=Math.pow(d/255,n)*255,this.gVals[d]=Math.pow(d/255,l)*255,this.bVals[d]=Math.pow(d/255,f)*255;for(d=0,h=e.length;d<h;d+=4)e[d]=this.rVals[e[d]],e[d+1]=this.gVals[e[d+1]],e[d+2]=this.bVals[e[d+2]]},getUniformLocations:function(t,r){return{uGamma:t.getUniformLocation(r,"uGamma")}},sendUniformData:function(t,r){t.uniform3fv(r.uGamma,this.gamma)}}),i.Image.filters.Gamma.fromObject=i.Image.filters.BaseFilter.fromObject})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.Image.filters,o=i.util.createClass;a.Composed=o(a.BaseFilter,{type:"Composed",subFilters:[],initialize:function(t){this.callSuper("initialize",t),this.subFilters=this.subFilters.slice(0)},applyTo:function(t){t.passes+=this.subFilters.length-1,this.subFilters.forEach(function(r){r.applyTo(t)})},toObject:function(){return i.util.object.extend(this.callSuper("toObject"),{subFilters:this.subFilters.map(function(t){return t.toObject()})})},isNeutralState:function(){return!this.subFilters.some(function(t){return!t.isNeutralState()})}}),i.Image.filters.Composed.fromObject=function(t,r){var e=t.subFilters||[],s=e.map(function(n){return new i.Image.filters[n.type](n)}),h=new i.Image.filters.Composed({subFilters:s});return r&&r(h),h}})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.Image.filters,o=i.util.createClass;a.HueRotation=o(a.ColorMatrix,{type:"HueRotation",rotation:0,mainParameter:"rotation",calculateMatrix:function(){var t=this.rotation*Math.PI,r=i.util.cos(t),e=i.util.sin(t),s=1/3,h=Math.sqrt(s)*e,n=1-r;this.matrix=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],this.matrix[0]=r+n/3,this.matrix[1]=s*n-h,this.matrix[2]=s*n+h,this.matrix[5]=s*n+h,this.matrix[6]=r+s*n,this.matrix[7]=s*n-h,this.matrix[10]=s*n-h,this.matrix[11]=s*n+h,this.matrix[12]=r+s*n},isNeutralState:function(t){return this.calculateMatrix(),a.BaseFilter.prototype.isNeutralState.call(this,t)},applyTo:function(t){this.calculateMatrix(),a.BaseFilter.prototype.applyTo.call(this,t)}}),i.Image.filters.HueRotation.fromObject=i.Image.filters.BaseFilter.fromObject})(F);(function(c){"use strict";var i=c.fabric||(c.fabric={}),a=i.util.object.clone;if(i.Text){i.warn("fabric.Text is already defined");return}var o="fontFamily fontWeight fontSize text underline overline linethrough textAlign fontStyle lineHeight textBackgroundColor charSpacing styles direction path pathStartOffset pathSide pathAlign".split(" ");i.Text=i.util.createClass(i.Object,{_dimensionAffectingProps:["fontSize","fontWeight","fontFamily","fontStyle","lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],_reNewline:/\r?\n/,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,type:"text",fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:"left",fontStyle:"normal",lineHeight:1.16,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},textBackgroundColor:"",stateProperties:i.Object.prototype.stateProperties.concat(o),cacheProperties:i.Object.prototype.cacheProperties.concat(o),stroke:null,shadow:null,path:null,pathStartOffset:0,pathSide:"left",pathAlign:"baseline",_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.315,overline:-.88},_fontSizeMult:1.13,charSpacing:0,styles:null,_measuringContext:null,deltaY:0,direction:"ltr",_styleProperties:["stroke","strokeWidth","fill","fontFamily","fontSize","fontWeight","fontStyle","underline","overline","linethrough","deltaY","textBackgroundColor"],__charBounds:[],CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2,initialize:function(t,r){this.styles=r?r.styles||{}:{},this.text=t,this.__skipDimension=!0,this.callSuper("initialize",r),this.path&&this.setPathInfo(),this.__skipDimension=!1,this.initDimensions(),this.setCoords(),this.setupState({propertySet:"_dimensionAffectingProps"})},setPathInfo:function(){var t=this.path;t&&(t.segmentsInfo=i.util.getPathSegmentsInfo(t.path))},getMeasuringContext:function(){return i._measuringContext||(i._measuringContext=this.canvas&&this.canvas.contextCache||i.util.createCanvasElement().getContext("2d")),i._measuringContext},_splitText:function(){var t=this._splitTextIntoLines(this.text);return this.textLines=t.lines,this._textLines=t.graphemeLines,this._unwrappedTextLines=t._unwrappedLines,this._text=t.graphemeText,t},initDimensions:function(){this.__skipDimension||(this._splitText(),this._clearCache(),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.indexOf("justify")!==-1&&this.enlargeSpaces(),this.saveState({propertySet:"_dimensionAffectingProps"}))},enlargeSpaces:function(){for(var t,r,e,s,h,n,l,f=0,d=this._textLines.length;f<d;f++)if(!(this.textAlign!=="justify"&&(f===d-1||this.isEndOfWrapping(f)))&&(s=0,h=this._textLines[f],r=this.getLineWidth(f),r<this.width&&(l=this.textLines[f].match(this._reSpacesAndTabs)))){e=l.length,t=(this.width-r)/e;for(var g=0,m=h.length;g<=m;g++)n=this.__charBounds[f][g],this._reSpaceAndTab.test(h[g])?(n.width+=t,n.kernedWidth+=t,n.left+=s,s+=t):n.left+=s}},isEndOfWrapping:function(t){return t===this._textLines.length-1},missingNewlineOffset:function(){return 1},toString:function(){return"#<fabric.Text ("+this.complexity()+'): { "text": "'+this.text+'", "fontFamily": "'+this.fontFamily+'" }>'},_getCacheCanvasDimensions:function(){var t=this.callSuper("_getCacheCanvasDimensions"),r=this.fontSize;return t.width+=r*t.zoomX,t.height+=r*t.zoomY,t},_render:function(t){var r=this.path;r&&!r.isNotVisible()&&r._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")},_renderText:function(t){this.paintFirst==="stroke"?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))},_setTextStyles:function(t,r,e){if(t.textBaseline="alphabetical",this.path)switch(this.pathAlign){case"center":t.textBaseline="middle";break;case"ascender":t.textBaseline="top";break;case"descender":t.textBaseline="bottom";break}t.font=this._getFontDeclaration(r,e)},calcTextWidth:function(){for(var t=this.getLineWidth(0),r=1,e=this._textLines.length;r<e;r++){var s=this.getLineWidth(r);s>t&&(t=s)}return t},_renderTextLine:function(t,r,e,s,h,n){this._renderChars(t,r,e,s,h,n)},_renderTextLinesBackground:function(t){if(!(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))){for(var r,e,s=t.fillStyle,h,n,l=this._getLeftOffset(),f=this._getTopOffset(),d=0,g=0,m,p,_=this.path,w,D=0,B=this._textLines.length;D<B;D++){if(r=this.getHeightOfLine(D),!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",D)){f+=r;continue}h=this._textLines[D],e=this._getLineLeftOffset(D),g=0,d=0,n=this.getValueOfPropertyAt(D,0,"textBackgroundColor");for(var N=0,G=h.length;N<G;N++)m=this.__charBounds[D][N],p=this.getValueOfPropertyAt(D,N,"textBackgroundColor"),_?(t.save(),t.translate(m.renderLeft,m.renderTop),t.rotate(m.angle),t.fillStyle=p,p&&t.fillRect(-m.width/2,-r/this.lineHeight*(1-this._fontSizeFraction),m.width,r/this.lineHeight),t.restore()):p!==n?(w=l+e+d,this.direction==="rtl"&&(w=this.width-w-g),t.fillStyle=n,n&&t.fillRect(w,f,g,r/this.lineHeight),d=m.left,g=m.width,n=p):g+=m.kernedWidth;p&&!_&&(w=l+e+d,this.direction==="rtl"&&(w=this.width-w-g),t.fillStyle=p,t.fillRect(w,f,g,r/this.lineHeight)),f+=r}t.fillStyle=s,this._removeShadow(t)}},getFontCache:function(t){var r=t.fontFamily.toLowerCase();i.charWidthsCache[r]||(i.charWidthsCache[r]={});var e=i.charWidthsCache[r],s=t.fontStyle.toLowerCase()+"_"+(t.fontWeight+"").toLowerCase();return e[s]||(e[s]={}),e[s]},_measureChar:function(t,r,e,s){var h=this.getFontCache(r),n=this._getFontDeclaration(r),l=this._getFontDeclaration(s),f=e+t,d=n===l,g,m,p,_=r.fontSize/this.CACHE_FONT_SIZE,w;if(e&&h[e]!==void 0&&(p=h[e]),h[t]!==void 0&&(w=g=h[t]),d&&h[f]!==void 0&&(m=h[f],w=m-p),g===void 0||p===void 0||m===void 0){var D=this.getMeasuringContext();this._setTextStyles(D,r,!0)}return g===void 0&&(w=g=D.measureText(t).width,h[t]=g),p===void 0&&d&&e&&(p=D.measureText(e).width,h[e]=p),d&&m===void 0&&(m=D.measureText(f).width,h[f]=m,w=m-p),{width:g*_,kernedWidth:w*_}},getHeightOfChar:function(t,r){return this.getValueOfPropertyAt(t,r,"fontSize")},measureLine:function(t){var r=this._measureLine(t);return this.charSpacing!==0&&(r.width-=this._getWidthOfCharSpacing()),r.width<0&&(r.width=0),r},_measureLine:function(t){var r=0,e,s,h=this._textLines[t],n,l,f=0,d=new Array(h.length),g=0,m,p,_=this.path,w=this.pathSide==="right";for(this.__charBounds[t]=d,e=0;e<h.length;e++)s=h[e],l=this._getGraphemeBox(s,t,e,n),d[e]=l,r+=l.kernedWidth,n=s;if(d[e]={left:l?l.left+l.width:0,width:0,kernedWidth:0,height:this.fontSize},_){switch(p=_.segmentsInfo[_.segmentsInfo.length-1].length,m=i.util.getPointOnPath(_.path,0,_.segmentsInfo),m.x+=_.pathOffset.x,m.y+=_.pathOffset.y,this.textAlign){case"left":g=w?p-r:0;break;case"center":g=(p-r)/2;break;case"right":g=w?0:p-r;break}for(g+=this.pathStartOffset*(w?-1:1),e=w?h.length-1:0;w?e>=0:e<h.length;w?e--:e++)l=d[e],g>p?g%=p:g<0&&(g+=p),this._setGraphemeOnPath(g,l,m),g+=l.kernedWidth}return{width:r,numOfSpaces:f}},_setGraphemeOnPath:function(t,r,e){var s=t+r.kernedWidth/2,h=this.path,n=i.util.getPointOnPath(h.path,s,h.segmentsInfo);r.renderLeft=n.x-e.x,r.renderTop=n.y-e.y,r.angle=n.angle+(this.pathSide==="right"?Math.PI:0)},_getGraphemeBox:function(t,r,e,s,h){var n=this.getCompleteStyleDeclaration(r,e),l=s?this.getCompleteStyleDeclaration(r,e-1):{},f=this._measureChar(t,n,s,l),d=f.kernedWidth,g=f.width,m;this.charSpacing!==0&&(m=this._getWidthOfCharSpacing(),g+=m,d+=m);var p={width:g,left:0,height:n.fontSize,kernedWidth:d,deltaY:n.deltaY};if(e>0&&!h){var _=this.__charBounds[r][e-1];p.left=_.left+_.width+f.kernedWidth-f.width}return p},getHeightOfLine:function(t){if(this.__lineHeights[t])return this.__lineHeights[t];for(var r=this._textLines[t],e=this.getHeightOfChar(t,0),s=1,h=r.length;s<h;s++)e=Math.max(this.getHeightOfChar(t,s),e);return this.__lineHeights[t]=e*this.lineHeight*this._fontSizeMult},calcTextHeight:function(){for(var t,r=0,e=0,s=this._textLines.length;e<s;e++)t=this.getHeightOfLine(e),r+=e===s-1?t/this.lineHeight:t;return r},_getLeftOffset:function(){return this.direction==="ltr"?-this.width/2:this.width/2},_getTopOffset:function(){return-this.height/2},_renderTextCommon:function(t,r){t.save();for(var e=0,s=this._getLeftOffset(),h=this._getTopOffset(),n=0,l=this._textLines.length;n<l;n++){var f=this.getHeightOfLine(n),d=f/this.lineHeight,g=this._getLineLeftOffset(n);this._renderTextLine(r,t,this._textLines[n],s+g,h+e+d,n),e+=f}t.restore()},_renderTextFill:function(t){!this.fill&&!this.styleHas("fill")||this._renderTextCommon(t,"fillText")},_renderTextStroke:function(t){(!this.stroke||this.strokeWidth===0)&&this.isEmptyStyles()||(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())},_renderChars:function(t,r,e,s,h,n){var l=this.getHeightOfLine(n),f=this.textAlign.indexOf("justify")!==-1,d,g,m="",p,_=0,w,D=this.path,B=!f&&this.charSpacing===0&&this.isEmptyStyles(n)&&!D,N=this.direction==="ltr",G=this.direction==="ltr"?1:-1,z,H=r.canvas.getAttribute("dir");if(r.save(),H!==this.direction&&(r.canvas.setAttribute("dir",N?"ltr":"rtl"),r.direction=N?"ltr":"rtl",r.textAlign=N?"left":"right"),h-=l*this._fontSizeFraction/this.lineHeight,B){this._renderChar(t,r,n,0,e.join(""),s,h,l),r.restore();return}for(var U=0,K=e.length-1;U<=K;U++)w=U===K||this.charSpacing||D,m+=e[U],p=this.__charBounds[n][U],_===0?(s+=G*(p.kernedWidth-p.width),_+=p.width):_+=p.kernedWidth,f&&!w&&this._reSpaceAndTab.test(e[U])&&(w=!0),w||(d=d||this.getCompleteStyleDeclaration(n,U),g=this.getCompleteStyleDeclaration(n,U+1),w=this._hasStyleChanged(d,g)),w&&(D?(r.save(),r.translate(p.renderLeft,p.renderTop),r.rotate(p.angle),this._renderChar(t,r,n,U,m,-_/2,0,l),r.restore()):(z=s,this._renderChar(t,r,n,U,m,z,h,l)),m="",d=g,s+=G*_,_=0);r.restore()},_applyPatternGradientTransformText:function(t){var r=i.util.createCanvasElement(),e,s=this.width+this.strokeWidth,h=this.height+this.strokeWidth;return r.width=s,r.height=h,e=r.getContext("2d"),e.beginPath(),e.moveTo(0,0),e.lineTo(s,0),e.lineTo(s,h),e.lineTo(0,h),e.closePath(),e.translate(s/2,h/2),e.fillStyle=t.toLive(e),this._applyPatternGradientTransform(e,t),e.fill(),e.createPattern(r,"no-repeat")},handleFiller:function(t,r,e){var s,h;return e.toLive?e.gradientUnits==="percentage"||e.gradientTransform||e.patternTransform?(s=-this.width/2,h=-this.height/2,t.translate(s,h),t[r]=this._applyPatternGradientTransformText(e),{offsetX:s,offsetY:h}):(t[r]=e.toLive(t,this),this._applyPatternGradientTransform(t,e)):(t[r]=e,{offsetX:0,offsetY:0})},_setStrokeStyles:function(t,r){return t.lineWidth=r.strokeWidth,t.lineCap=this.strokeLineCap,t.lineDashOffset=this.strokeDashOffset,t.lineJoin=this.strokeLineJoin,t.miterLimit=this.strokeMiterLimit,this.handleFiller(t,"strokeStyle",r.stroke)},_setFillStyles:function(t,r){return this.handleFiller(t,"fillStyle",r.fill)},_renderChar:function(t,r,e,s,h,n,l){var f=this._getStyleDeclaration(e,s),d=this.getCompleteStyleDeclaration(e,s),g=t==="fillText"&&d.fill,m=t==="strokeText"&&d.stroke&&d.strokeWidth,p,_;!m&&!g||(r.save(),g&&(p=this._setFillStyles(r,d)),m&&(_=this._setStrokeStyles(r,d)),r.font=this._getFontDeclaration(d),f&&f.textBackgroundColor&&this._removeShadow(r),f&&f.deltaY&&(l+=f.deltaY),g&&r.fillText(h,n-p.offsetX,l-p.offsetY),m&&r.strokeText(h,n-_.offsetX,l-_.offsetY),r.restore())},setSuperscript:function(t,r){return this._setScript(t,r,this.superscript)},setSubscript:function(t,r){return this._setScript(t,r,this.subscript)},_setScript:function(t,r,e){var s=this.get2DCursorLocation(t,!0),h=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"fontSize"),n=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"deltaY"),l={fontSize:h*e.size,deltaY:n+h*e.baseline};return this.setSelectionStyles(l,t,r),this},_hasStyleChanged:function(t,r){return t.fill!==r.fill||t.stroke!==r.stroke||t.strokeWidth!==r.strokeWidth||t.fontSize!==r.fontSize||t.fontFamily!==r.fontFamily||t.fontWeight!==r.fontWeight||t.fontStyle!==r.fontStyle||t.deltaY!==r.deltaY},_hasStyleChangedForSvg:function(t,r){return this._hasStyleChanged(t,r)||t.overline!==r.overline||t.underline!==r.underline||t.linethrough!==r.linethrough},_getLineLeftOffset:function(t){var r=this.getLineWidth(t),e=this.width-r,s=this.textAlign,h=this.direction,l,n=0,l=this.isEndOfWrapping(t);return s==="justify"||s==="justify-center"&&!l||s==="justify-right"&&!l||s==="justify-left"&&!l?0:(s==="center"&&(n=e/2),s==="right"&&(n=e),s==="justify-center"&&(n=e/2),s==="justify-right"&&(n=e),h==="rtl"&&(n-=e),n)},_clearCache:function(){this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]},_shouldClearDimensionCache:function(){var t=this._forceClearCache;return t||(t=this.hasStateChanged("_dimensionAffectingProps")),t&&(this.dirty=!0,this._forceClearCache=!1),t},getLineWidth:function(t){if(this.__lineWidths[t]!==void 0)return this.__lineWidths[t];var r=this.measureLine(t),e=r.width;return this.__lineWidths[t]=e,e},_getWidthOfCharSpacing:function(){return this.charSpacing!==0?this.fontSize*this.charSpacing/1e3:0},getValueOfPropertyAt:function(t,r,e){var s=this._getStyleDeclaration(t,r);return s&&typeof s[e]!="undefined"?s[e]:this[e]},_renderTextDecoration:function(t,r){if(!(!this[r]&&!this.styleHas(r))){for(var e,s,h,n,l,f,d,g,m=this._getLeftOffset(),p=this._getTopOffset(),_,w,D,B,N,G,z,H,U=this.path,K=this._getWidthOfCharSpacing(),Q=this.offsets[r],J=0,v=this._textLines.length;J<v;J++){if(e=this.getHeightOfLine(J),!this[r]&&!this.styleHas(r,J)){p+=e;continue}d=this._textLines[J],G=e/this.lineHeight,n=this._getLineLeftOffset(J),w=0,D=0,g=this.getValueOfPropertyAt(J,0,r),H=this.getValueOfPropertyAt(J,0,"fill"),_=p+G*(1-this._fontSizeFraction),s=this.getHeightOfChar(J,0),l=this.getValueOfPropertyAt(J,0,"deltaY");for(var b=0,S=d.length;b<S;b++)if(B=this.__charBounds[J][b],N=this.getValueOfPropertyAt(J,b,r),z=this.getValueOfPropertyAt(J,b,"fill"),h=this.getHeightOfChar(J,b),f=this.getValueOfPropertyAt(J,b,"deltaY"),U&&N&&z)t.save(),t.fillStyle=H,t.translate(B.renderLeft,B.renderTop),t.rotate(B.angle),t.fillRect(-B.kernedWidth/2,Q*h+f,B.kernedWidth,this.fontSize/15),t.restore();else if((N!==g||z!==H||h!==s||f!==l)&&D>0){var C=m+n+w;this.direction==="rtl"&&(C=this.width-C-D),g&&H&&(t.fillStyle=H,t.fillRect(C,_+Q*s+l,D,this.fontSize/15)),w=B.left,D=B.width,g=N,H=z,s=h,l=f}else D+=B.kernedWidth;var C=m+n+w;this.direction==="rtl"&&(C=this.width-C-D),t.fillStyle=z,N&&z&&t.fillRect(C,_+Q*s+l,D-K,this.fontSize/15),p+=e}this._removeShadow(t)}},_getFontDeclaration:function(t,r){var e=t||this,s=this.fontFamily,h=i.Text.genericFonts.indexOf(s.toLowerCase())>-1,n=s===void 0||s.indexOf("'")>-1||s.indexOf(",")>-1||s.indexOf('"')>-1||h?e.fontFamily:'"'+e.fontFamily+'"';return[i.isLikelyNode?e.fontWeight:e.fontStyle,i.isLikelyNode?e.fontStyle:e.fontWeight,r?this.CACHE_FONT_SIZE+"px":e.fontSize+"px",n].join(" ")},render:function(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._shouldClearDimensionCache()&&this.initDimensions(),this.callSuper("render",t)))},_splitTextIntoLines:function(t){for(var r=t.split(this._reNewline),e=new Array(r.length),s=[`
|
|
441
|
+
`],h=[],n=0;n<r.length;n++)e[n]=i.util.string.graphemeSplit(r[n]),h=h.concat(e[n],s);return h.pop(),{_unwrappedLines:e,lines:r,graphemeText:h,graphemeLines:e}},toObject:function(t){var r=o.concat(t),e=this.callSuper("toObject",r);return e.styles=a(this.styles,!0),e.path&&(e.path=this.path.toObject()),e},set:function(t,r){this.callSuper("set",t,r);var e=!1,s=!1;if(typeof t=="object")for(var h in t)h==="path"&&this.setPathInfo(),e=e||this._dimensionAffectingProps.indexOf(h)!==-1,s=s||h==="path";else e=this._dimensionAffectingProps.indexOf(t)!==-1,s=t==="path";return s&&this.setPathInfo(),e&&(this.initDimensions(),this.setCoords()),this},complexity:function(){return 1}}),i.Text.ATTRIBUTE_NAMES=i.SHARED_ATTRIBUTES.concat("x y dx dy font-family font-style font-weight font-size letter-spacing text-decoration text-anchor".split(" ")),i.Text.DEFAULT_SVG_FONT_SIZE=16,i.Text.fromElement=function(t,r,e){if(!t)return r(null);var s=i.parseAttributes(t,i.Text.ATTRIBUTE_NAMES),h=s.textAnchor||"left";if(e=i.util.object.extend(e?a(e):{},s),e.top=e.top||0,e.left=e.left||0,s.textDecoration){var n=s.textDecoration;n.indexOf("underline")!==-1&&(e.underline=!0),n.indexOf("overline")!==-1&&(e.overline=!0),n.indexOf("line-through")!==-1&&(e.linethrough=!0),delete e.textDecoration}"dx"in s&&(e.left+=s.dx),"dy"in s&&(e.top+=s.dy),"fontSize"in e||(e.fontSize=i.Text.DEFAULT_SVG_FONT_SIZE);var l="";"textContent"in t?l=t.textContent:"firstChild"in t&&t.firstChild!==null&&"data"in t.firstChild&&t.firstChild.data!==null&&(l=t.firstChild.data),l=l.replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," ");var f=e.strokeWidth;e.strokeWidth=0;var d=new i.Text(l,e),g=d.getScaledHeight()/d.height,m=(d.height+d.strokeWidth)*d.lineHeight-d.height,p=m*g,_=d.getScaledHeight()+p,w=0;h==="center"&&(w=d.getScaledWidth()/2),h==="right"&&(w=d.getScaledWidth()),d.set({left:d.left-w,top:d.top-(_-d.fontSize*(.07+d._fontSizeFraction))/d.lineHeight,strokeWidth:typeof f!="undefined"?f:1}),r(d)},i.Text.fromObject=function(t,r){var e=a(t),s=t.path;return delete e.path,i.Object._fromObject("Text",e,function(h){s?i.Object._fromObject("Path",s,function(n){h.set("path",n),r(h)},"path"):r(h)},"text")},i.Text.genericFonts=["sans-serif","serif","cursive","fantasy","monospace"],i.util.createAccessors&&i.util.createAccessors(i.Text)})(F);(function(){u.util.object.extend(u.Text.prototype,{isEmptyStyles:function(c){if(!this.styles||typeof c!="undefined"&&!this.styles[c])return!0;var i=typeof c=="undefined"?this.styles:{line:this.styles[c]};for(var a in i)for(var o in i[a])for(var t in i[a][o])return!1;return!0},styleHas:function(c,i){if(!this.styles||!c||c===""||typeof i!="undefined"&&!this.styles[i])return!1;var a=typeof i=="undefined"?this.styles:{0:this.styles[i]};for(var o in a)for(var t in a[o])if(typeof a[o][t][c]!="undefined")return!0;return!1},cleanStyle:function(c){if(!this.styles||!c||c==="")return!1;var i=this.styles,a=0,o,t,r=!0,e=0,s;for(var h in i){o=0;for(var n in i[h]){var s=i[h][n],l=s.hasOwnProperty(c);a++,l?(t?s[c]!==t&&(r=!1):t=s[c],s[c]===this[c]&&delete s[c]):r=!1,Object.keys(s).length!==0?o++:delete i[h][n]}o===0&&delete i[h]}for(var f=0;f<this._textLines.length;f++)e+=this._textLines[f].length;r&&a===e&&(this[c]=t,this.removeStyle(c))},removeStyle:function(c){if(!(!this.styles||!c||c==="")){var i=this.styles,a,o,t;for(o in i){a=i[o];for(t in a)delete a[t][c],Object.keys(a[t]).length===0&&delete a[t];Object.keys(a).length===0&&delete i[o]}}},_extendStyles:function(c,i){var a=this.get2DCursorLocation(c);this._getLineStyle(a.lineIndex)||this._setLineStyle(a.lineIndex),this._getStyleDeclaration(a.lineIndex,a.charIndex)||this._setStyleDeclaration(a.lineIndex,a.charIndex,{}),u.util.object.extend(this._getStyleDeclaration(a.lineIndex,a.charIndex),i)},get2DCursorLocation:function(c,i){typeof c=="undefined"&&(c=this.selectionStart);for(var a=i?this._unwrappedTextLines:this._textLines,o=a.length,t=0;t<o;t++){if(c<=a[t].length)return{lineIndex:t,charIndex:c};c-=a[t].length+this.missingNewlineOffset(t)}return{lineIndex:t-1,charIndex:a[t-1].length<c?a[t-1].length:c}},getSelectionStyles:function(c,i,a){typeof c=="undefined"&&(c=this.selectionStart||0),typeof i=="undefined"&&(i=this.selectionEnd||c);for(var o=[],t=c;t<i;t++)o.push(this.getStyleAtPosition(t,a));return o},getStyleAtPosition:function(c,i){var a=this.get2DCursorLocation(c),o=i?this.getCompleteStyleDeclaration(a.lineIndex,a.charIndex):this._getStyleDeclaration(a.lineIndex,a.charIndex);return o||{}},setSelectionStyles:function(c,i,a){typeof i=="undefined"&&(i=this.selectionStart||0),typeof a=="undefined"&&(a=this.selectionEnd||i);for(var o=i;o<a;o++)this._extendStyles(o,c);return this._forceClearCache=!0,this},_getStyleDeclaration:function(c,i){var a=this.styles&&this.styles[c];return a?a[i]:null},getCompleteStyleDeclaration:function(c,i){for(var a=this._getStyleDeclaration(c,i)||{},o={},t,r=0;r<this._styleProperties.length;r++)t=this._styleProperties[r],o[t]=typeof a[t]=="undefined"?this[t]:a[t];return o},_setStyleDeclaration:function(c,i,a){this.styles[c][i]=a},_deleteStyleDeclaration:function(c,i){delete this.styles[c][i]},_getLineStyle:function(c){return!!this.styles[c]},_setLineStyle:function(c){this.styles[c]={}},_deleteLineStyle:function(c){delete this.styles[c]}})})();(function(){function c(i){i.textDecoration&&(i.textDecoration.indexOf("underline")>-1&&(i.underline=!0),i.textDecoration.indexOf("line-through")>-1&&(i.linethrough=!0),i.textDecoration.indexOf("overline")>-1&&(i.overline=!0),delete i.textDecoration)}u.IText=u.util.createClass(u.Text,u.Observable,{type:"i-text",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,_reSpace:/\s|\n/,_currentCursorOpacity:0,_selectionDirection:null,_abortCursorAnimation:!1,__widthOfSpace:[],inCompositionMode:!1,initialize:function(i,a){this.callSuper("initialize",i,a),this.initBehavior()},setSelectionStart:function(i){i=Math.max(i,0),this._updateAndFire("selectionStart",i)},setSelectionEnd:function(i){i=Math.min(i,this.text.length),this._updateAndFire("selectionEnd",i)},_updateAndFire:function(i,a){this[i]!==a&&(this._fireSelectionChanged(),this[i]=a),this._updateTextarea()},_fireSelectionChanged:function(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},initDimensions:function(){this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this.callSuper("initDimensions")},render:function(i){this.clearContextTop(),this.callSuper("render",i),this.cursorOffsetCache={},this.renderCursorOrSelection()},_render:function(i){this.callSuper("_render",i)},clearContextTop:function(i){if(!(!this.isEditing||!this.canvas||!this.canvas.contextTop)){var a=this.canvas.contextTop,o=this.canvas.viewportTransform;a.save(),a.transform(o[0],o[1],o[2],o[3],o[4],o[5]),this.transform(a),this._clearTextArea(a),i||a.restore()}},renderCursorOrSelection:function(){if(!(!this.isEditing||!this.canvas||!this.canvas.contextTop)){var i=this._getCursorBoundaries(),a=this.canvas.contextTop;this.clearContextTop(!0),this.selectionStart===this.selectionEnd?this.renderCursor(i,a):this.renderSelection(i,a),a.restore()}},_clearTextArea:function(i){var a=this.width+4,o=this.height+4;i.clearRect(-a/2,-o/2,a,o)},_getCursorBoundaries:function(i){typeof i=="undefined"&&(i=this.selectionStart);var a=this._getLeftOffset(),o=this._getTopOffset(),t=this._getCursorBoundariesOffsets(i);return{left:a,top:o,leftOffset:t.left,topOffset:t.top}},_getCursorBoundariesOffsets:function(i){if(this.cursorOffsetCache&&"top"in this.cursorOffsetCache)return this.cursorOffsetCache;var a,o,t,r=0,e=0,s,h=this.get2DCursorLocation(i);t=h.charIndex,o=h.lineIndex;for(var n=0;n<o;n++)r+=this.getHeightOfLine(n);a=this._getLineLeftOffset(o);var l=this.__charBounds[o][t];return l&&(e=l.left),this.charSpacing!==0&&t===this._textLines[o].length&&(e-=this._getWidthOfCharSpacing()),s={top:r,left:a+(e>0?e:0)},this.direction==="rtl"&&(s.left*=-1),this.cursorOffsetCache=s,this.cursorOffsetCache},renderCursor:function(i,a){var o=this.get2DCursorLocation(),t=o.lineIndex,r=o.charIndex>0?o.charIndex-1:0,e=this.getValueOfPropertyAt(t,r,"fontSize"),s=this.scaleX*this.canvas.getZoom(),h=this.cursorWidth/s,n=i.topOffset,l=this.getValueOfPropertyAt(t,r,"deltaY");n+=(1-this._fontSizeFraction)*this.getHeightOfLine(t)/this.lineHeight-e*(1-this._fontSizeFraction),this.inCompositionMode&&this.renderSelection(i,a),a.fillStyle=this.cursorColor||this.getValueOfPropertyAt(t,r,"fill"),a.globalAlpha=this.__isMousedown?1:this._currentCursorOpacity,a.fillRect(i.left+i.leftOffset-h/2,n+i.top+l,h,e)},renderSelection:function(i,a){for(var o=this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,t=this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd,r=this.textAlign.indexOf("justify")!==-1,e=this.get2DCursorLocation(o),s=this.get2DCursorLocation(t),h=e.lineIndex,n=s.lineIndex,l=e.charIndex<0?0:e.charIndex,f=s.charIndex<0?0:s.charIndex,d=h;d<=n;d++){var g=this._getLineLeftOffset(d)||0,m=this.getHeightOfLine(d),p=0,_=0,w=0;if(d===h&&(_=this.__charBounds[h][l].left),d>=h&&d<n)w=r&&!this.isEndOfWrapping(d)?this.width:this.getLineWidth(d)||5;else if(d===n)if(f===0)w=this.__charBounds[n][f].left;else{var D=this._getWidthOfCharSpacing();w=this.__charBounds[n][f-1].left+this.__charBounds[n][f-1].width-D}p=m,(this.lineHeight<1||d===n&&this.lineHeight>1)&&(m/=this.lineHeight);var B=i.left+g+_,N=w-_,G=m,z=0;this.inCompositionMode?(a.fillStyle=this.compositionColor||"black",G=1,z=m):a.fillStyle=this.selectionColor,this.direction==="rtl"&&(B=this.width-B-N),a.fillRect(B,i.top+i.topOffset+z,N,G),i.topOffset+=p}},getCurrentCharFontSize:function(){var i=this._getCurrentCharIndex();return this.getValueOfPropertyAt(i.l,i.c,"fontSize")},getCurrentCharColor:function(){var i=this._getCurrentCharIndex();return this.getValueOfPropertyAt(i.l,i.c,"fill")},_getCurrentCharIndex:function(){var i=this.get2DCursorLocation(this.selectionStart,!0),a=i.charIndex>0?i.charIndex-1:0;return{l:i.lineIndex,c:a}}}),u.IText.fromObject=function(i,a){if(c(i),i.styles)for(var o in i.styles)for(var t in i.styles[o])c(i.styles[o][t]);u.Object._fromObject("IText",i,a,"text")}})();(function(){var c=u.util.object.clone;u.util.object.extend(u.IText.prototype,{initBehavior:function(){this.initAddedHandler(),this.initRemovedHandler(),this.initCursorSelectionHandlers(),this.initDoubleClickSimulation(),this.mouseMoveHandler=this.mouseMoveHandler.bind(this)},onDeselect:function(){this.isEditing&&this.exitEditing(),this.selected=!1},initAddedHandler:function(){var i=this;this.on("added",function(){var a=i.canvas;a&&(a._hasITextHandlers||(a._hasITextHandlers=!0,i._initCanvasHandlers(a)),a._iTextInstances=a._iTextInstances||[],a._iTextInstances.push(i))})},initRemovedHandler:function(){var i=this;this.on("removed",function(){var a=i.canvas;a&&(a._iTextInstances=a._iTextInstances||[],u.util.removeFromArray(a._iTextInstances,i),a._iTextInstances.length===0&&(a._hasITextHandlers=!1,i._removeCanvasHandlers(a)))})},_initCanvasHandlers:function(i){i._mouseUpITextHandler=function(){i._iTextInstances&&i._iTextInstances.forEach(function(a){a.__isMousedown=!1})},i.on("mouse:up",i._mouseUpITextHandler)},_removeCanvasHandlers:function(i){i.off("mouse:up",i._mouseUpITextHandler)},_tick:function(){this._currentTickState=this._animateCursor(this,1,this.cursorDuration,"_onTickComplete")},_animateCursor:function(i,a,o,t){var r;return r={isAborted:!1,abort:function(){this.isAborted=!0}},i.animate("_currentCursorOpacity",a,{duration:o,onComplete:function(){r.isAborted||i[t]()},onChange:function(){i.canvas&&i.selectionStart===i.selectionEnd&&i.renderCursorOrSelection()},abort:function(){return r.isAborted}}),r},_onTickComplete:function(){var i=this;this._cursorTimeout1&&clearTimeout(this._cursorTimeout1),this._cursorTimeout1=setTimeout(function(){i._currentTickCompleteState=i._animateCursor(i,0,this.cursorDuration/2,"_tick")},100)},initDelayedCursor:function(i){var a=this,o=i?0:this.cursorDelay;this.abortCursorAnimation(),this._currentCursorOpacity=1,this._cursorTimeout2=setTimeout(function(){a._tick()},o)},abortCursorAnimation:function(){var i=this._currentTickState||this._currentTickCompleteState,a=this.canvas;this._currentTickState&&this._currentTickState.abort(),this._currentTickCompleteState&&this._currentTickCompleteState.abort(),clearTimeout(this._cursorTimeout1),clearTimeout(this._cursorTimeout2),this._currentCursorOpacity=0,i&&a&&a.clearContext(a.contextTop||a.contextContainer)},selectAll:function(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this},getSelectedText:function(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")},findWordBoundaryLeft:function(i){var a=0,o=i-1;if(this._reSpace.test(this._text[o]))for(;this._reSpace.test(this._text[o]);)a++,o--;for(;/\S/.test(this._text[o])&&o>-1;)a++,o--;return i-a},findWordBoundaryRight:function(i){var a=0,o=i;if(this._reSpace.test(this._text[o]))for(;this._reSpace.test(this._text[o]);)a++,o++;for(;/\S/.test(this._text[o])&&o<this._text.length;)a++,o++;return i+a},findLineBoundaryLeft:function(i){for(var a=0,o=i-1;!/\n/.test(this._text[o])&&o>-1;)a++,o--;return i-a},findLineBoundaryRight:function(i){for(var a=0,o=i;!/\n/.test(this._text[o])&&o<this._text.length;)a++,o++;return i+a},searchWordBoundary:function(i,a){for(var o=this._text,t=this._reSpace.test(o[i])?i-1:i,r=o[t],e=u.reNonWord;!e.test(r)&&t>0&&t<o.length;)t+=a,r=o[t];return e.test(r)&&(t+=a===1?0:1),t},selectWord:function(i){i=i||this.selectionStart;var a=this.searchWordBoundary(i,-1),o=this.searchWordBoundary(i,1);this.selectionStart=a,this.selectionEnd=o,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()},selectLine:function(i){i=i||this.selectionStart;var a=this.findLineBoundaryLeft(i),o=this.findLineBoundaryRight(i);return this.selectionStart=a,this.selectionEnd=o,this._fireSelectionChanged(),this._updateTextarea(),this},enterEditing:function(i){if(!(this.isEditing||!this.editable))return this.canvas&&(this.canvas.calcOffset(),this.exitEditingOnOthers(this.canvas)),this.isEditing=!0,this.initHiddenTextarea(i),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick(),this.fire("editing:entered"),this._fireSelectionChanged(),this.canvas?(this.canvas.fire("text:editing:entered",{target:this}),this.initMouseMoveHandler(),this.canvas.requestRenderAll(),this):this},exitEditingOnOthers:function(i){i._iTextInstances&&i._iTextInstances.forEach(function(a){a.selected=!1,a.isEditing&&a.exitEditing()})},initMouseMoveHandler:function(){this.canvas.on("mouse:move",this.mouseMoveHandler)},mouseMoveHandler:function(i){if(!(!this.__isMousedown||!this.isEditing)){var a=this.getSelectionStartFromPointer(i.e),o=this.selectionStart,t=this.selectionEnd;(a!==this.__selectionStartOnMouseDown||o===t)&&(o===a||t===a)||(a>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=a):(this.selectionStart=a,this.selectionEnd=this.__selectionStartOnMouseDown),(this.selectionStart!==o||this.selectionEnd!==t)&&(this.restartCursorIfNeeded(),this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}},_setEditingProps:function(){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:function(i,a,o){var t=o.slice(0,i),r=u.util.string.graphemeSplit(t).length;if(i===a)return{selectionStart:r,selectionEnd:r};var e=o.slice(i,a),s=u.util.string.graphemeSplit(e).length;return{selectionStart:r,selectionEnd:r+s}},fromGraphemeToStringSelection:function(i,a,o){var t=o.slice(0,i),r=t.join("").length;if(i===a)return{selectionStart:r,selectionEnd:r};var e=o.slice(i,a),s=e.join("").length;return{selectionStart:r,selectionEnd:r+s}},_updateTextarea:function(){if(this.cursorOffsetCache={},!!this.hiddenTextarea){if(!this.inCompositionMode){var i=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=i.selectionStart,this.hiddenTextarea.selectionEnd=i.selectionEnd}this.updateTextareaPosition()}},updateFromTextArea:function(){if(this.hiddenTextarea){this.cursorOffsetCache={},this.text=this.hiddenTextarea.value,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords());var i=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value);this.selectionEnd=this.selectionStart=i.selectionEnd,this.inCompositionMode||(this.selectionStart=i.selectionStart),this.updateTextareaPosition()}},updateTextareaPosition:function(){if(this.selectionStart===this.selectionEnd){var i=this._calcTextareaPosition();this.hiddenTextarea.style.left=i.left,this.hiddenTextarea.style.top=i.top}},_calcTextareaPosition:function(){if(!this.canvas)return{x:1,y:1};var i=this.inCompositionMode?this.compositionStart:this.selectionStart,a=this._getCursorBoundaries(i),o=this.get2DCursorLocation(i),t=o.lineIndex,r=o.charIndex,e=this.getValueOfPropertyAt(t,r,"fontSize")*this.lineHeight,s=a.leftOffset,h=this.calcTransformMatrix(),n={x:a.left+s,y:a.top+a.topOffset+e},l=this.canvas.getRetinaScaling(),f=this.canvas.upperCanvasEl,d=f.width/l,g=f.height/l,m=d-e,p=g-e,_=f.clientWidth/d,w=f.clientHeight/g;return n=u.util.transformPoint(n,h),n=u.util.transformPoint(n,this.canvas.viewportTransform),n.x*=_,n.y*=w,n.x<0&&(n.x=0),n.x>m&&(n.x=m),n.y<0&&(n.y=0),n.y>p&&(n.y=p),n.x+=this.canvas._offset.left,n.y+=this.canvas._offset.top,{left:n.x+"px",top:n.y+"px",fontSize:e+"px",charHeight:e}},_saveEditingProps:function(){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:function(){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.moveCursor=this._savedProps.moveCursor))},exitEditing:function(){var i=this._textBeforeEdit!==this.text,a=this.hiddenTextarea;return this.selected=!1,this.isEditing=!1,this.selectionEnd=this.selectionStart,a&&(a.blur&&a.blur(),a.parentNode&&a.parentNode.removeChild(a)),this.hiddenTextarea=null,this.abortCursorAnimation(),this._restoreEditingProps(),this._currentCursorOpacity=0,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this.fire("editing:exited"),i&&this.fire("modified"),this.canvas&&(this.canvas.off("mouse:move",this.mouseMoveHandler),this.canvas.fire("text:editing:exited",{target:this}),i&&this.canvas.fire("object:modified",{target:this})),this},_removeExtraneousStyles:function(){for(var i in this.styles)this._textLines[i]||delete this.styles[i]},removeStyleFromTo:function(i,a){var o=this.get2DCursorLocation(i,!0),t=this.get2DCursorLocation(a,!0),r=o.lineIndex,e=o.charIndex,s=t.lineIndex,h=t.charIndex,n,l;if(r!==s){if(this.styles[r])for(n=e;n<this._unwrappedTextLines[r].length;n++)delete this.styles[r][n];if(this.styles[s])for(n=h;n<this._unwrappedTextLines[s].length;n++)l=this.styles[s][n],l&&(this.styles[r]||(this.styles[r]={}),this.styles[r][e+n-h]=l);for(n=r+1;n<=s;n++)delete this.styles[n];this.shiftLineStyles(s,r-s)}else if(this.styles[r]){l=this.styles[r];var f=h-e,d,g;for(n=e;n<h;n++)delete l[n];for(g in this.styles[r])d=parseInt(g,10),d>=h&&(l[d-f]=l[g],delete l[g])}},shiftLineStyles:function(i,a){var o=c(this.styles);for(var t in this.styles){var r=parseInt(t,10);r>i&&(this.styles[r+a]=o[r],o[r-a]||delete this.styles[r])}},restartCursorIfNeeded:function(){(!this._currentTickState||this._currentTickState.isAborted||!this._currentTickCompleteState||this._currentTickCompleteState.isAborted)&&this.initDelayedCursor()},insertNewlineStyleObject:function(i,a,o,t){var r,e={},s=!1,h=this._unwrappedTextLines[i].length===a;o||(o=1),this.shiftLineStyles(i,o),this.styles[i]&&(r=this.styles[i][a===0?a:a-1]);for(var n in this.styles[i]){var l=parseInt(n,10);l>=a&&(s=!0,e[l-a]=this.styles[i][n],h&&a===0||delete this.styles[i][n])}var f=!1;for(s&&!h&&(this.styles[i+o]=e,f=!0),f&&o--;o>0;)t&&t[o-1]?this.styles[i+o]={0:c(t[o-1])}:r?this.styles[i+o]={0:c(r)}:delete this.styles[i+o],o--;this._forceClearCache=!0},insertCharStyleObject:function(i,a,o,t){this.styles||(this.styles={});var r=this.styles[i],e=r?c(r):{};o||(o=1);for(var s in e){var h=parseInt(s,10);h>=a&&(r[h+o]=e[h],e[h-o]||delete r[h])}if(this._forceClearCache=!0,t){for(;o--;)Object.keys(t[o]).length&&(this.styles[i]||(this.styles[i]={}),this.styles[i][a+o]=c(t[o]));return}if(r)for(var n=r[a?a-1:1];n&&o--;)this.styles[i][a+o]=c(n)},insertNewStyleBlock:function(i,a,o){for(var t=this.get2DCursorLocation(a,!0),r=[0],e=0,s=0;s<i.length;s++)i[s]===`
|
|
442
|
+
`?(e++,r[e]=0):r[e]++;r[0]>0&&(this.insertCharStyleObject(t.lineIndex,t.charIndex,r[0],o),o=o&&o.slice(r[0]+1)),e&&this.insertNewlineStyleObject(t.lineIndex,t.charIndex+r[0],e);for(var s=1;s<e;s++)r[s]>0?this.insertCharStyleObject(t.lineIndex+s,0,r[s],o):o&&this.styles[t.lineIndex+s]&&o[0]&&(this.styles[t.lineIndex+s][0]=o[0]),o=o&&o.slice(r[s]+1);r[s]>0&&this.insertCharStyleObject(t.lineIndex+s,0,r[s],o)},setSelectionStartEndWithShift:function(i,a,o){o<=i?(a===i?this._selectionDirection="left":this._selectionDirection==="right"&&(this._selectionDirection="left",this.selectionEnd=i),this.selectionStart=o):o>i&&o<a?this._selectionDirection==="right"?this.selectionEnd=o:this.selectionStart=o:(a===i?this._selectionDirection="right":this._selectionDirection==="left"&&(this._selectionDirection="right",this.selectionStart=a),this.selectionEnd=o)},setSelectionInBoundaries:function(){var i=this.text.length;this.selectionStart>i?this.selectionStart=i:this.selectionStart<0&&(this.selectionStart=0),this.selectionEnd>i?this.selectionEnd=i:this.selectionEnd<0&&(this.selectionEnd=0)}})})();u.util.object.extend(u.IText.prototype,{initDoubleClickSimulation:function(){this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown)},onMouseDown:function(c){if(this.canvas){this.__newClickTime=+new Date;var i=c.pointer;this.isTripleClick(i)&&(this.fire("tripleclick",c),this._stopEvent(c.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=i,this.__lastIsEditing=this.isEditing,this.__lastSelected=this.selected}},isTripleClick:function(c){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===c.x&&this.__lastPointer.y===c.y},_stopEvent:function(c){c.preventDefault&&c.preventDefault(),c.stopPropagation&&c.stopPropagation()},initCursorSelectionHandlers:function(){this.initMousedownHandler(),this.initMouseupHandler(),this.initClicks()},doubleClickHandler:function(c){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(c.e))},tripleClickHandler:function(c){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(c.e))},initClicks:function(){this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler)},_mouseDownHandler:function(c){!this.canvas||!this.editable||c.e.button&&c.e.button!==1||(this.__isMousedown=!0,this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(c.e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()))},_mouseDownHandlerBefore:function(c){!this.canvas||!this.editable||c.e.button&&c.e.button!==1||(this.selected=this===this.canvas._activeObject)},initMousedownHandler:function(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore)},initMouseupHandler:function(){this.on("mouseup",this.mouseUpHandler)},mouseUpHandler:function(c){if(this.__isMousedown=!1,!(!this.editable||this.group||c.transform&&c.transform.actionPerformed||c.e.button&&c.e.button!==1)){if(this.canvas){var i=this.canvas._activeObject;if(i&&i!==this)return}this.__lastSelected&&!this.__corner?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(c.e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0}},setCursorByClick:function(c){var i=this.getSelectionStartFromPointer(c),a=this.selectionStart,o=this.selectionEnd;c.shiftKey?this.setSelectionStartEndWithShift(a,o,i):(this.selectionStart=i,this.selectionEnd=i),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())},getSelectionStartFromPointer:function(c){for(var i=this.getLocalPointer(c),a=0,o=0,t=0,r=0,e=0,s,h,n=0,l=this._textLines.length;n<l&&t<=i.y;n++)t+=this.getHeightOfLine(n)*this.scaleY,e=n,n>0&&(r+=this._textLines[n-1].length+this.missingNewlineOffset(n-1));s=this._getLineLeftOffset(e),o=s*this.scaleX,h=this._textLines[e],this.direction==="rtl"&&(i.x=this.width*this.scaleX-i.x+o);for(var f=0,d=h.length;f<d&&(a=o,o+=this.__charBounds[e][f].kernedWidth*this.scaleX,o<=i.x);f++)r++;return this._getNewSelectionStartFromOffset(i,a,o,r,d)},_getNewSelectionStartFromOffset:function(c,i,a,o,t){var r=c.x-i,e=a-c.x,s=e>r||e<0?0:1,h=o+s;return this.flipX&&(h=t-h),h>this._text.length&&(h=this._text.length),h}});u.util.object.extend(u.IText.prototype,{initHiddenTextarea:function(){this.hiddenTextarea=u.document.createElement("textarea"),this.hiddenTextarea.setAttribute("autocapitalize","off"),this.hiddenTextarea.setAttribute("autocorrect","off"),this.hiddenTextarea.setAttribute("autocomplete","off"),this.hiddenTextarea.setAttribute("spellcheck","false"),this.hiddenTextarea.setAttribute("data-fabric-hiddentextarea",""),this.hiddenTextarea.setAttribute("wrap","off");var c=this._calcTextareaPosition();this.hiddenTextarea.style.cssText="position: absolute; top: "+c.top+"; left: "+c.left+"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding\uFF70top: "+c.fontSize+";",this.hiddenTextareaContainer?this.hiddenTextareaContainer.appendChild(this.hiddenTextarea):u.document.body.appendChild(this.hiddenTextarea),u.util.addListener(this.hiddenTextarea,"keydown",this.onKeyDown.bind(this)),u.util.addListener(this.hiddenTextarea,"keyup",this.onKeyUp.bind(this)),u.util.addListener(this.hiddenTextarea,"input",this.onInput.bind(this)),u.util.addListener(this.hiddenTextarea,"copy",this.copy.bind(this)),u.util.addListener(this.hiddenTextarea,"cut",this.copy.bind(this)),u.util.addListener(this.hiddenTextarea,"paste",this.paste.bind(this)),u.util.addListener(this.hiddenTextarea,"compositionstart",this.onCompositionStart.bind(this)),u.util.addListener(this.hiddenTextarea,"compositionupdate",this.onCompositionUpdate.bind(this)),u.util.addListener(this.hiddenTextarea,"compositionend",this.onCompositionEnd.bind(this)),!this._clickHandlerInitialized&&this.canvas&&(u.util.addListener(this.canvas.upperCanvasEl,"click",this.onClick.bind(this)),this._clickHandlerInitialized=!0)},keysMap:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorRight",36:"moveCursorLeft",37:"moveCursorLeft",38:"moveCursorUp",39:"moveCursorRight",40:"moveCursorDown"},keysMapRtl:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorLeft",36:"moveCursorRight",37:"moveCursorRight",38:"moveCursorUp",39:"moveCursorLeft",40:"moveCursorDown"},ctrlKeysMapUp:{67:"copy",88:"cut"},ctrlKeysMapDown:{65:"selectAll"},onClick:function(){this.hiddenTextarea&&this.hiddenTextarea.focus()},onKeyDown:function(c){if(this.isEditing){var i=this.direction==="rtl"?this.keysMapRtl:this.keysMap;if(c.keyCode in i)this[i[c.keyCode]](c);else if(c.keyCode in this.ctrlKeysMapDown&&(c.ctrlKey||c.metaKey))this[this.ctrlKeysMapDown[c.keyCode]](c);else return;c.stopImmediatePropagation(),c.preventDefault(),c.keyCode>=33&&c.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}},onKeyUp:function(c){if(!this.isEditing||this._copyDone||this.inCompositionMode){this._copyDone=!1;return}if(c.keyCode in this.ctrlKeysMapUp&&(c.ctrlKey||c.metaKey))this[this.ctrlKeysMapUp[c.keyCode]](c);else return;c.stopImmediatePropagation(),c.preventDefault(),this.canvas&&this.canvas.requestRenderAll()},onInput:function(c){var i=this.fromPaste;if(this.fromPaste=!1,c&&c.stopPropagation(),!!this.isEditing){var a=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,o=this._text.length,t=a.length,r,e,s=t-o,h=this.selectionStart,n=this.selectionEnd,l=h!==n,f,d,g;if(this.hiddenTextarea.value===""){this.styles={},this.updateFromTextArea(),this.fire("changed"),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll());return}var m=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),p=h>m.selectionStart;l?(r=this._text.slice(h,n),s+=n-h):t<o&&(p?r=this._text.slice(n+s,n):r=this._text.slice(h,h-s)),e=a.slice(m.selectionEnd-s,m.selectionEnd),r&&r.length&&(e.length&&(f=this.getSelectionStyles(h,h+1,!1),f=e.map(function(){return f[0]})),l?(d=h,g=n):p?(d=n-r.length,g=n):(d=n,g=n+r.length),this.removeStyleFromTo(d,g)),e.length&&(i&&e.join("")===u.copiedText&&!u.disableStyleCopyPaste&&(f=u.copiedTextStyle),this.insertNewStyleBlock(e,h,f)),this.updateFromTextArea(),this.fire("changed"),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())}},onCompositionStart:function(){this.inCompositionMode=!0},onCompositionEnd:function(){this.inCompositionMode=!1},onCompositionUpdate:function(c){this.compositionStart=c.target.selectionStart,this.compositionEnd=c.target.selectionEnd,this.updateTextareaPosition()},copy:function(){this.selectionStart!==this.selectionEnd&&(u.copiedText=this.getSelectedText(),u.disableStyleCopyPaste?u.copiedTextStyle=null:u.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0)},paste:function(){this.fromPaste=!0},_getClipboardData:function(c){return c&&c.clipboardData||u.window.clipboardData},_getWidthBeforeCursor:function(c,i){var a=this._getLineLeftOffset(c),o;return i>0&&(o=this.__charBounds[c][i-1],a+=o.left+o.width),a},getDownCursorOffset:function(c,i){var a=this._getSelectionForOffset(c,i),o=this.get2DCursorLocation(a),t=o.lineIndex;if(t===this._textLines.length-1||c.metaKey||c.keyCode===34)return this._text.length-a;var r=o.charIndex,e=this._getWidthBeforeCursor(t,r),s=this._getIndexOnLine(t+1,e),h=this._textLines[t].slice(r);return h.length+s+1+this.missingNewlineOffset(t)},_getSelectionForOffset:function(c,i){return c.shiftKey&&this.selectionStart!==this.selectionEnd&&i?this.selectionEnd:this.selectionStart},getUpCursorOffset:function(c,i){var a=this._getSelectionForOffset(c,i),o=this.get2DCursorLocation(a),t=o.lineIndex;if(t===0||c.metaKey||c.keyCode===33)return-a;var r=o.charIndex,e=this._getWidthBeforeCursor(t,r),s=this._getIndexOnLine(t-1,e),h=this._textLines[t].slice(0,r),n=this.missingNewlineOffset(t-1);return-this._textLines[t-1].length+s-h.length+(1-n)},_getIndexOnLine:function(c,i){for(var a=this._textLines[c],o=this._getLineLeftOffset(c),t=o,r=0,e,s,h=0,n=a.length;h<n;h++)if(e=this.__charBounds[c][h].width,t+=e,t>i){s=!0;var l=t-e,f=t,d=Math.abs(l-i),g=Math.abs(f-i);r=g<d?h:h-1;break}return s||(r=a.length-1),r},moveCursorDown:function(c){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",c)},moveCursorUp:function(c){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown("Up",c)},_moveCursorUpOrDown:function(c,i){var a="get"+c+"CursorOffset",o=this[a](i,this._selectionDirection==="right");i.shiftKey?this.moveCursorWithShift(o):this.moveCursorWithoutShift(o),o!==0&&(this.setSelectionInBoundaries(),this.abortCursorAnimation(),this._currentCursorOpacity=1,this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorWithShift:function(c){var i=this._selectionDirection==="left"?this.selectionStart+c:this.selectionEnd+c;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,i),c!==0},moveCursorWithoutShift:function(c){return c<0?(this.selectionStart+=c,this.selectionEnd=this.selectionStart):(this.selectionEnd+=c,this.selectionStart=this.selectionEnd),c!==0},moveCursorLeft:function(c){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight("Left",c)},_move:function(c,i,a){var o;if(c.altKey)o=this["findWordBoundary"+a](this[i]);else if(c.metaKey||c.keyCode===35||c.keyCode===36)o=this["findLineBoundary"+a](this[i]);else return this[i]+=a==="Left"?-1:1,!0;if(typeof o!==void 0&&this[i]!==o)return this[i]=o,!0},_moveLeft:function(c,i){return this._move(c,i,"Left")},_moveRight:function(c,i){return this._move(c,i,"Right")},moveCursorLeftWithoutShift:function(c){var i=!0;return this._selectionDirection="left",this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(i=this._moveLeft(c,"selectionStart")),this.selectionEnd=this.selectionStart,i},moveCursorLeftWithShift:function(c){if(this._selectionDirection==="right"&&this.selectionStart!==this.selectionEnd)return this._moveLeft(c,"selectionEnd");if(this.selectionStart!==0)return this._selectionDirection="left",this._moveLeft(c,"selectionStart")},moveCursorRight:function(c){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",c)},_moveCursorLeftOrRight:function(c,i){var a="moveCursor"+c+"With";this._currentCursorOpacity=1,i.shiftKey?a+="Shift":a+="outShift",this[a](i)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorRightWithShift:function(c){if(this._selectionDirection==="left"&&this.selectionStart!==this.selectionEnd)return this._moveRight(c,"selectionStart");if(this.selectionEnd!==this._text.length)return this._selectionDirection="right",this._moveRight(c,"selectionEnd")},moveCursorRightWithoutShift:function(c){var i=!0;return this._selectionDirection="right",this.selectionStart===this.selectionEnd?(i=this._moveRight(c,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,i},removeChars:function(c,i){typeof i=="undefined"&&(i=c+1),this.removeStyleFromTo(c,i),this._text.splice(c,i-c),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()},insertChars:function(c,i,a,o){typeof o=="undefined"&&(o=a),o>a&&this.removeStyleFromTo(a,o);var t=u.util.string.graphemeSplit(c);this.insertNewStyleBlock(t,a,i),this._text=[].concat(this._text.slice(0,a),t,this._text.slice(o)),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()}});(function(){var c=u.util.toFixed,i=/ +/g;u.util.object.extend(u.Text.prototype,{_toSVG:function(){var a=this._getSVGLeftTopOffsets(),o=this._getSVGTextAndBg(a.textTop,a.textLeft);return this._wrapSVGTextAndBg(o)},toSVG:function(a){return this._createBaseSVGMarkup(this._toSVG(),{reviver:a,noStyle:!0,withShadow:!0})},_getSVGLeftTopOffsets:function(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}},_wrapSVGTextAndBg:function(a){var o=!0,t=this.getSvgTextDecoration(this);return[a.textBgRects.join(""),' <text xml:space="preserve" ',this.fontFamily?'font-family="'+this.fontFamily.replace(/"/g,"'")+'" ':"",this.fontSize?'font-size="'+this.fontSize+'" ':"",this.fontStyle?'font-style="'+this.fontStyle+'" ':"",this.fontWeight?'font-weight="'+this.fontWeight+'" ':"",t?'text-decoration="'+t+'" ':"",'style="',this.getSvgStyles(o),'"',this.addPaintOrder()," >",a.textSpans.join(""),`</text>
|
|
443
|
+
`]},_getSVGTextAndBg:function(a,o){var t=[],r=[],e=a,s;this._setSVGBg(r);for(var h=0,n=this._textLines.length;h<n;h++)s=this._getLineLeftOffset(h),(this.textBackgroundColor||this.styleHas("textBackgroundColor",h))&&this._setSVGTextLineBg(r,h,o+s,e),this._setSVGTextLineText(t,h,o+s,e),e+=this.getHeightOfLine(h);return{textSpans:t,textBgRects:r}},_createTextCharSpan:function(a,o,t,r){var e=a!==a.trim()||a.match(i),s=this.getSvgSpanStyles(o,e),h=s?'style="'+s+'"':"",n=o.deltaY,l="",f=u.Object.NUM_FRACTION_DIGITS;return n&&(l=' dy="'+c(n,f)+'" '),['<tspan x="',c(t,f),'" y="',c(r,f),'" ',l,h,">",u.util.string.escapeXml(a),"</tspan>"].join("")},_setSVGTextLineText:function(a,o,t,r){var e=this.getHeightOfLine(o),s=this.textAlign.indexOf("justify")!==-1,h,n,l="",f,d,g=0,m=this._textLines[o],p;r+=e*(1-this._fontSizeFraction)/this.lineHeight;for(var _=0,w=m.length-1;_<=w;_++)p=_===w||this.charSpacing,l+=m[_],f=this.__charBounds[o][_],g===0?(t+=f.kernedWidth-f.width,g+=f.width):g+=f.kernedWidth,s&&!p&&this._reSpaceAndTab.test(m[_])&&(p=!0),p||(h=h||this.getCompleteStyleDeclaration(o,_),n=this.getCompleteStyleDeclaration(o,_+1),p=this._hasStyleChangedForSvg(h,n)),p&&(d=this._getStyleDeclaration(o,_)||{},a.push(this._createTextCharSpan(l,d,t,r)),l="",h=n,t+=g,g=0)},_pushTextBgRect:function(a,o,t,r,e,s){var h=u.Object.NUM_FRACTION_DIGITS;a.push(" <rect ",this._getFillAttributes(o),' x="',c(t,h),'" y="',c(r,h),'" width="',c(e,h),'" height="',c(s,h),`"></rect>
|
|
444
|
+
`)},_setSVGTextLineBg:function(a,o,t,r){for(var e=this._textLines[o],s=this.getHeightOfLine(o)/this.lineHeight,h=0,n=0,l,f,d=this.getValueOfPropertyAt(o,0,"textBackgroundColor"),g=0,m=e.length;g<m;g++)l=this.__charBounds[o][g],f=this.getValueOfPropertyAt(o,g,"textBackgroundColor"),f!==d?(d&&this._pushTextBgRect(a,d,t+n,r,h,s),n=l.left,h=l.width,d=f):h+=l.kernedWidth;f&&this._pushTextBgRect(a,f,t+n,r,h,s)},_getFillAttributes:function(a){var o=a&&typeof a=="string"?new u.Color(a):"";return!o||!o.getSource()||o.getAlpha()===1?'fill="'+a+'"':'opacity="'+o.getAlpha()+'" fill="'+o.setAlpha(1).toRgb()+'"'},_getSVGLineTopOffset:function(a){for(var o=0,t=0,r=0;r<a;r++)o+=this.getHeightOfLine(r);return t=this.getHeightOfLine(r),{lineTop:o,offset:(this._fontSizeMult-this._fontSizeFraction)*t/(this.lineHeight*this._fontSizeMult)}},getSvgStyles:function(a){var o=u.Object.prototype.getSvgStyles.call(this,a);return o+" white-space: pre;"}})})();(function(c){"use strict";var i=c.fabric||(c.fabric={});i.Textbox=i.util.createClass(i.IText,i.Observable,{type:"textbox",minWidth:20,dynamicMinWidth:2,__cachedLines:null,lockScalingFlip:!0,noScaleCache:!1,_dimensionAffectingProps:i.Text.prototype._dimensionAffectingProps.concat("width"),_wordJoiners:/[ \t\r]/,splitByGrapheme:!1,initDimensions:function(){this.__skipDimension||(this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),this.textAlign.indexOf("justify")!==-1&&this.enlargeSpaces(),this.height=this.calcTextHeight(),this.saveState({propertySet:"_dimensionAffectingProps"}))},_generateStyleMap:function(a){for(var o=0,t=0,r=0,e={},s=0;s<a.graphemeLines.length;s++)a.graphemeText[r]===`
|
|
445
|
+
`&&s>0?(t=0,r++,o++):!this.splitByGrapheme&&this._reSpaceAndTab.test(a.graphemeText[r])&&s>0&&(t++,r++),e[s]={line:o,offset:t},r+=a.graphemeLines[s].length,t+=a.graphemeLines[s].length;return e},styleHas:function(a,o){if(this._styleMap&&!this.isWrapping){var t=this._styleMap[o];t&&(o=t.line)}return i.Text.prototype.styleHas.call(this,a,o)},isEmptyStyles:function(a){if(!this.styles)return!0;var o=0,t=a+1,r,e,s=!1,h=this._styleMap[a],n=this._styleMap[a+1];h&&(a=h.line,o=h.offset),n&&(t=n.line,s=t===a,r=n.offset),e=typeof a=="undefined"?this.styles:{line:this.styles[a]};for(var l in e)for(var f in e[l])if(f>=o&&(!s||f<r))for(var d in e[l][f])return!1;return!0},_getStyleDeclaration:function(a,o){if(this._styleMap&&!this.isWrapping){var t=this._styleMap[a];if(!t)return null;a=t.line,o=t.offset+o}return this.callSuper("_getStyleDeclaration",a,o)},_setStyleDeclaration:function(a,o,t){var r=this._styleMap[a];a=r.line,o=r.offset+o,this.styles[a][o]=t},_deleteStyleDeclaration:function(a,o){var t=this._styleMap[a];a=t.line,o=t.offset+o,delete this.styles[a][o]},_getLineStyle:function(a){var o=this._styleMap[a];return!!this.styles[o.line]},_setLineStyle:function(a){var o=this._styleMap[a];this.styles[o.line]={}},_wrapText:function(a,o){var t=[],r;for(this.isWrapping=!0,r=0;r<a.length;r++)t=t.concat(this._wrapLine(a[r],r,o));return this.isWrapping=!1,t},_measureWord:function(a,o,t){var r=0,e,s=!0;t=t||0;for(var h=0,n=a.length;h<n;h++){var l=this._getGraphemeBox(a[h],o,h+t,e,s);r+=l.kernedWidth,e=a[h]}return r},_wrapLine:function(a,o,t,B){var e=0,s=this.splitByGrapheme,h=[],n=[],l=s?i.util.string.graphemeSplit(a):a.split(this._wordJoiners),f="",d=0,g=s?"":" ",m=0,p=0,_=0,w=!0,D=this._getWidthOfCharSpacing(),B=B||0;l.length===0&&l.push([]),t-=B;for(var N=0;N<l.length;N++)f=s?l[N]:i.util.string.graphemeSplit(l[N]),m=this._measureWord(f,o,d),d+=f.length,e+=p+m-D,e>t&&!w?(h.push(n),n=[],e=m,w=!0):e+=D,!w&&!s&&n.push(g),n=n.concat(f),p=s?0:this._measureWord([g],o,d),d++,w=!1,m>_&&(_=m);return N&&h.push(n),_+B>this.dynamicMinWidth&&(this.dynamicMinWidth=_-D+B),h},isEndOfWrapping:function(a){return!this._styleMap[a+1]||this._styleMap[a+1].line!==this._styleMap[a].line},missingNewlineOffset:function(a){return this.splitByGrapheme?this.isEndOfWrapping(a)?1:0:1},_splitTextIntoLines:function(a){for(var o=i.Text.prototype._splitTextIntoLines.call(this,a),t=this._wrapText(o.lines,this.width),r=new Array(t.length),e=0;e<t.length;e++)r[e]=t[e].join("");return o.lines=r,o.graphemeLines=t,o},getMinWidth:function(){return Math.max(this.minWidth,this.dynamicMinWidth)},_removeExtraneousStyles:function(){var a={};for(var o in this._styleMap)this._textLines[o]&&(a[this._styleMap[o].line]=1);for(var o in this.styles)a[o]||delete this.styles[o]},toObject:function(a){return this.callSuper("toObject",["minWidth","splitByGrapheme"].concat(a))}}),i.Textbox.fromObject=function(a,o){return i.Object._fromObject("Textbox",a,o,"text")}})(F);(function(){var c=u.controlsUtils,i=c.scaleSkewCursorStyleHandler,a=c.scaleCursorStyleHandler,o=c.scalingEqually,t=c.scalingYOrSkewingX,r=c.scalingXOrSkewingY,e=c.scaleOrSkewActionName,s=u.Object.prototype.controls;if(s.ml=new u.Control({x:-.5,y:0,cursorStyleHandler:i,actionHandler:r,getActionName:e}),s.mr=new u.Control({x:.5,y:0,cursorStyleHandler:i,actionHandler:r,getActionName:e}),s.mb=new u.Control({x:0,y:.5,cursorStyleHandler:i,actionHandler:t,getActionName:e}),s.mt=new u.Control({x:0,y:-.5,cursorStyleHandler:i,actionHandler:t,getActionName:e}),s.tl=new u.Control({x:-.5,y:-.5,cursorStyleHandler:a,actionHandler:o}),s.tr=new u.Control({x:.5,y:-.5,cursorStyleHandler:a,actionHandler:o}),s.bl=new u.Control({x:-.5,y:.5,cursorStyleHandler:a,actionHandler:o}),s.br=new u.Control({x:.5,y:.5,cursorStyleHandler:a,actionHandler:o}),s.mtr=new u.Control({x:0,y:-.5,actionHandler:c.rotationWithSnapping,cursorStyleHandler:c.rotationStyleHandler,offsetY:-40,withConnection:!0,actionName:"rotate"}),u.Textbox){var h=u.Textbox.prototype.controls={};h.mtr=s.mtr,h.tr=s.tr,h.br=s.br,h.tl=s.tl,h.bl=s.bl,h.mt=s.mt,h.mb=s.mb,h.mr=new u.Control({x:.5,y:0,actionHandler:c.changeWidth,cursorStyleHandler:i,actionName:"resizing"}),h.ml=new u.Control({x:-.5,y:0,actionHandler:c.changeWidth,cursorStyleHandler:i,actionName:"resizing"})}})()});var re=Et(vt());var ht=Et(vt());var yt=class{constructor(i,a=!1){this.detectedElement=i;this.includeColorDes=a}escapeString(i){return i.replace(/["\\\n\r\u2028\u2029]/g,a=>`\\${a}`)}getCodeString(){let{name:i,text:a,colors:o}=this.detectedElement;return[`element().special("${this.escapeString(i)}")`,a&&`.withText("${this.escapeString(a)}")`,this.includeColorDes&&(o==null?void 0:o[0])&&`.colored("${this.escapeString(o[0])}")`].filter(Boolean).join("")}};var Bt=Et(vt());function Mt(c,i="1",a=100){return o=>new Promise(t=>{o.animate("opacity",i,{duration:a,onChange:c.renderAll.bind(c),onComplete:()=>t(o)})})}var Wt=c=>new Promise(i=>Bt.fabric.loadSVGFromURL(c,a=>i(a[0]))),Xt=(c,i)=>a=>{let o=c.getPointer(i.e);a.left=o.x+20,a.top=o.y-26/2;let t=Math.round(25/c.getZoom()),r=Math.round(t*a.width/a.height);return a.fill="#0E9F6E",a.scaleToWidth(r,!0),a.scaleToHeight(t,!0),a.opacity=0,a},Yt=c=>i=>{c.remove(i)},zt=c=>i=>(c.add(i),i);var me=`
|
|
446
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
|
447
|
+
<!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->
|
|
448
|
+
<path
|
|
449
|
+
d="M256 0c17.7 0 32 14.3 32 32V42.4c93.7 13.9 167.7 88 181.6 181.6H480c17.7 0 32 14.3 32 32s-14.3 32-32 32H469.6c-13.9 93.7-88 167.7-181.6 181.6V480c0 17.7-14.3 32-32 32s-32-14.3-32-32V469.6C130.3 455.7 56.3 381.7 42.4 288H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H42.4C56.3 130.3 130.3 56.3 224 42.4V32c0-17.7 14.3-32 32-32zM107.4 288c12.5 58.3 58.4 104.1 116.6 116.6V384c0-17.7 14.3-32 32-32s32 14.3 32 32v20.6c58.3-12.5 104.1-58.4 116.6-116.6H384c-17.7 0-32-14.3-32-32s14.3-32 32-32h20.6C392.1 165.7 346.3 119.9 288 107.4V128c0 17.7-14.3 32-32 32s-32-14.3-32-32V107.4C165.7 119.9 119.9 165.7 107.4 224H128c17.7 0 32 14.3 32 32s-14.3 32-32 32H107.4zM256 224a32 32 0 1 1 0 64 32 32 0 1 1 0-64z" />
|
|
450
|
+
</svg>
|
|
451
|
+
`,Ht="svg",pe="rect",Nt="tooltip",_t=class c{constructor(i=new ht.fabric.Canvas("canvas",{fireRightClick:!0,stopContextMenu:!0}),a){at(this,"canvas");at(this,"canvasWrapper");at(this,"currentMousePoint");this.canvas=i,this.canvasWrapper=a,this.canvas.selection=!1,this.registerMouseEvents()}registerMouseEvents(){let i=this;this.canvas.on("mouse:move",a=>i.onMouseMove(a)),this.canvas.on("mouse:over",a=>i.onMouseOver(a)),this.canvas.on("mouse:out",a=>i.onMouseOut(a)),this.canvas.on("mouse:up",a=>i.onMouseUp(a))}destroy(){this.canvas.off("mouse:move"),this.canvas.off("mouse:over"),this.canvas.off("mouse:out"),this.canvas.off("mouse:up"),this.canvas.dispose(),this.canvas=void 0}onMouseMove(i){this.currentMousePoint=this.canvas.getPointer(i.e)}isRect(i){var a,o;return((o=(a=i.target)==null?void 0:a.data)==null?void 0:o.type)===pe}isSvg(i){var a,o;return((o=(a=i.target)==null?void 0:a.data)==null?void 0:o.type)===Ht}drawClipboardCheck(i){return gt(this,null,function*(){let a="PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzODQgNTEyIj48IS0tIEZvbnQgQXdlc29tZSBGcmVlIDUuMTUuMiBieSBAZm9udGF3ZXNvbWUgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbSBMaWNlbnNlIC0gaHR0cHM6Ly9mb250YXdlc29tZS5jb20vbGljZW5zZS9mcmVlIChJY29uczogQ0MgQlkgNC4wLCBGb250czogU0lMIE9GTCAxLjEsIENvZGU6IE1JVCBMaWNlbnNlKSAtLT48cGF0aCBkPSJNMzM2IDY0aC04MGMwLTM1LjMtMjguNy02NC02NC02NHMtNjQgMjguNy02NCA2NEg0OEMyMS41IDY0IDAgODUuNSAwIDExMnYzNTJjMCAyNi41IDIxLjUgNDggNDggNDhoMjg4YzI2LjUgMCA0OC0yMS41IDQ4LTQ4VjExMmMwLTI2LjUtMjEuNS00OC00OC00OHpNMTkyIDQwYzEzLjMgMCAyNCAxMC43IDI0IDI0cy0xMC43IDI0LTI0IDI0LTI0LTEwLjctMjQtMjQgMTAuNy0yNCAyNC0yNHptMTIxLjIgMjMxLjhsLTE0MyAxNDEuOGMtNC43IDQuNy0xMi4zIDQuNi0xNy0uMWwtODIuNi04My4zYy00LjctNC43LTQuNi0xMi4zLjEtMTdMOTkuMSAyODVjNC43LTQuNyAxMi4zLTQuNiAxNyAuMWw0NiA0Ni40IDEwNi0xMDUuMmM0LjctNC43IDEyLjMtNC42IDE3IC4xbDI4LjIgMjguNGM0LjcgNC44IDQuNiAxMi4zLS4xIDE3eiIvPjwvc3ZnPg==";try{let o=yield Wt("data:image/svg+xml;base64,"+a);zt(this.canvas)(o),Xt(this.canvas,i)(o),yield Mt(this.canvas,"1")(o),yield new Promise(t=>setTimeout(t,200)),yield Mt(this.canvas,"0")(o),Yt(this.canvas)(o)}catch(o){console.error("Error drawing clipboard check:",o)}})}copyToClipboard(i){navigator.clipboard.writeText(i).then()}onMouseUp(i){var a;if(this.isRect(i)){let o=(a=i.target)==null?void 0:a.data.detectedObject,r=new yt(o).getCodeString();this.copyToClipboard(r),this.drawClipboardCheck(i);return}}onMouseOut(i){var a,o,t;if(this.isRect(i)&&((a=i.target)==null||a.set("stroke","red")),this.isSvg(i)&&((o=i.target)==null||o.set("fill","red")),this.isRect(i)||this.isSvg(i)){let r=this.findObjectByTypeAndIndex(Nt,(t=i.target)==null?void 0:t.data.index);this.canvas.remove(r),this.canvas.renderAll();return}}rightBottomCorner(){return{x:ht.fabric.util.invertTransform(this.canvas.viewportTransform)[4]+this.canvas.width/this.canvas.getZoom(),y:ht.fabric.util.invertTransform(this.canvas.viewportTransform)[5]+this.canvas.height/this.canvas.getZoom()}}onMouseOver(i){var a,o,t,r,e,s;this.isRect(i)&&(this.currentMousePoint=this.canvas.getPointer(i.e),(a=i.target)==null||a.set("stroke","green"),this.drawDetectedElementTooltip((o=i.target)==null?void 0:o.data.index,(t=i.target)==null?void 0:t.data.detectedObject),this.canvas.renderAll()),this.isSvg(i)&&(this.currentMousePoint=this.canvas.getPointer(i.e),(r=i.target)==null||r.set("fill","green"),this.drawActionTooltip((e=i.target)==null?void 0:e.data.index,(s=i.target)==null?void 0:s.data.action),this.canvas.renderAll())}findObjectByTypeAndIndex(i,a){return this.canvas.getObjects().find(o=>{var t,r;return((t=o.data)==null?void 0:t.index)===a&&((r=o.data)==null?void 0:r.type)===i})}static imageStrToFabricImage(i){return new Promise((a,o)=>{ht.fabric.Image.fromURL(i,t=>{if(t.getElement()===void 0){o(t);return}a(t)})})}setCanvasSizeToImageSize(i){let a=this.canvasWrapper.clientWidth;this.canvas.setWidth(a),this.canvas.setHeight(a*i.height/i.width),this.canvas.setZoom(a/i.width)}drawImage(i,a){return gt(this,null,function*(){try{let o=yield c.imageStrToFabricImage(i);if(this.canvas===void 0)return;this.setCanvasSizeToImageSize(o),o.lockMovementX=!0,o.lockMovementY=!0,o.lockScalingX=!0,o.lockScalingY=!0,o.hasControls=!1,o.selectable=!1,o.hoverCursor="default",a&&this.canvas.add(o)}catch(o){console.error("Error drawing image:",o)}})}placeObjectAroundPoint(i,a){return i.left=a.x-i.width/2,i.left<=0&&(i.left=0),i.left+i.width>this.rightBottomCorner().x&&(i.left=this.rightBottomCorner().x-i.width),i.top=a.y+20/this.canvas.getZoom(),i.top+i.height>this.rightBottomCorner().y&&(i.top=a.y-i.height-10),i}placeObjectAroundMouse(i){return this.placeObjectAroundPoint(i,this.currentMousePoint)}buildTooltip(i,a){let o=new ht.fabric.Text(i,{fontFamily:"Source Sans Pro",fontSize:Math.round(16/this.canvas.getZoom()),originX:"center",originY:"center",fill:"white",lockMovementX:!0,lockMovementY:!0,lockScalingX:!0,lockScalingY:!0,lockRotation:!0,hasControls:!1}),t=new ht.fabric.Rect({fill:"rgba(0,0,0, 0.9)",originX:"center",originY:"center",rx:1,ry:1,stroke:"black",strokeWidth:1,strokeUniform:!0,width:o.getScaledWidth()+4,height:o.getScaledHeight()+4});return new ht.fabric.Group([t,o],{data:{type:Nt,index:a},visible:!0,lockMovementX:!0,lockMovementY:!0,lockScalingX:!0,lockScalingY:!0,lockRotation:!0,hasControls:!1})}drawActionTooltip(i,a){let o={Index:i.toString(),Position:`(x: ${a.position.x}, y: ${a.position.y})`,"Input Event":a.inputEvent};a.text&&(o.Text=a.text);let t=Object.entries(o).map(([e,s])=>`${e}: ${s}`).join(`
|
|
452
|
+
`),r=this.buildTooltip(t,i);this.placeObjectAroundMouse(r),this.canvas.add(r)}drawDetectedElementTooltip(i,a){let o=a.name.replace(/_/g," ");a.hasText()&&(o+=": "+a.text),a.hasSimilarityScore()&&(o+=`, match result: ${a.similarityScore}%`),a.hasColors()&&(o+=", colors: "+a.colors.join(", "));let t=this.buildTooltip(o,i);this.placeObjectAroundMouse(t),this.canvas.add(t)}drawDetectedElementRect(i,a){let o=new ht.fabric.Rect({data:{index:i,type:"rect",detectedObject:a},top:a.bbox.ymin,left:a.bbox.xmin,width:a.bbox.width,height:a.bbox.height,stroke:"red",strokeWidth:1,strokeUniform:!0,fill:"rgba(0,0,0,0)",lockMovementX:!0,lockMovementY:!0,lockScalingX:!0,lockScalingY:!0,lockRotation:!0,hasControls:!1,hoverCursor:a.hasText()?"pointer":"default"});this.canvas.add(o)}drawActionSvg(i,a){ht.fabric.loadSVGFromString(me,(o,t)=>{let r=ht.fabric.util.groupSVGElements(o,t),s=this.canvas.width/100/r.width;r.scale(s);let h=a.position,n=r.width*s,l=r.height*s;r.set({data:{index:i,type:Ht,action:a},left:h.x-n/2,top:h.y-l/2,fill:"red",lockMovementX:!0,lockMovementY:!0,lockScalingX:!0,lockScalingY:!0,lockRotation:!0,hasControls:!1,hoverCursor:"pointer"}),this.canvas.add(r)})}resizeCanvas(){if(this.canvas===void 0)return;let i=this.canvasWrapper.clientWidth,a=this.canvas.getWidth()/this.canvas.getHeight(),o=i,t=o/this.canvas.getWidth(),r=this.canvas.getZoom()*t;this.canvas.setDimensions({width:o,height:o/a}),this.canvas.setViewportTransform([r,0,0,r,0,0])}};var xt=class{constructor(i,a,o,t){this.xmin=i;this.ymin=a;this.xmax=o;this.ymax=t}get width(){return this.xmax-this.xmin}get height(){return this.ymax-this.ymin}get size(){return this.width*this.height}};var Ct=class c{constructor(i,a,o,t,r=0){this.name=i;this.text=a;this.bbox=o;this.colors=t;this.similarityScore=r}hasText(){return this.text.length>0}hasColors(){var i;return((i=this.colors)==null?void 0:i.join("").length)>0}hasSimilarityScore(){return this.similarityScore>0}isIcon(){return this.name==="icon"}static fromJson(i){return new c(i.name,i.text,new xt(i.bndbox.xmin,i.bndbox.ymin,i.bndbox.xmax,i.bndbox.ymax),i.colors,i.similarityScore)}};var ve=typeof global=="object"&&global&&global.Object===Object&&global,Ut=ve;var ye=typeof self=="object"&&self&&self.Object===Object&&self,_e=Ut||ye||Function("return this")(),bt=_e;var xe=bt.Symbol,ut=xe;var Gt=Object.prototype,Ce=Gt.hasOwnProperty,be=Gt.toString,mt=ut?ut.toStringTag:void 0;function Se(c){var i=Ce.call(c,mt),a=c[mt];try{c[mt]=void 0;var o=!0}catch(r){}var t=be.call(c);return o&&(i?c[mt]=a:delete c[mt]),t}var Vt=Se;var we=Object.prototype,Te=we.toString;function Oe(c){return Te.call(c)}var qt=Oe;var Ee="[object Null]",Pe="[object Undefined]",Kt=ut?ut.toStringTag:void 0;function ke(c){return c==null?c===void 0?Pe:Ee:Kt&&Kt in Object(c)?Vt(c):qt(c)}var Jt=ke;function De(c){return c!=null&&typeof c=="object"}var Qt=De;var Me="[object Symbol]";function Ae(c){return typeof c=="symbol"||Qt(c)&&Jt(c)==Me}var Zt=Ae;var Fe=/\s/;function Le(c){for(var i=c.length;i--&&Fe.test(c.charAt(i)););return i}var $t=Le;var Ie=/^\s+/;function je(c){return c&&c.slice(0,$t(c)+1).replace(Ie,"")}var te=je;function Re(c){var i=typeof c;return c!=null&&(i=="object"||i=="function")}var ft=Re;var ee=NaN,Be=/^[-+]0x[0-9a-f]+$/i,We=/^0b[01]+$/i,Xe=/^0o[0-7]+$/i,Ye=parseInt;function ze(c){if(typeof c=="number")return c;if(Zt(c))return ee;if(ft(c)){var i=typeof c.valueOf=="function"?c.valueOf():c;c=ft(i)?i+"":i}if(typeof c!="string")return c===0?c:+c;c=te(c);var a=We.test(c);return a||Xe.test(c)?Ye(c.slice(2),a?2:8):Be.test(c)?ee:+c}var At=ze;var He=function(){return bt.Date.now()},St=He;var Ne="Expected a function",Ue=Math.max,Ge=Math.min;function Ve(c,i,a){var o,t,r,e,s,h,n=0,l=!1,f=!1,d=!0;if(typeof c!="function")throw new TypeError(Ne);i=At(i)||0,ft(a)&&(l=!!a.leading,f="maxWait"in a,r=f?Ue(At(a.maxWait)||0,i):r,d="trailing"in a?!!a.trailing:d);function g(z){var H=o,U=t;return o=t=void 0,n=z,e=c.apply(U,H),e}function m(z){return n=z,s=setTimeout(w,i),l?g(z):e}function p(z){var H=z-h,U=z-n,K=i-H;return f?Ge(K,r-U):K}function _(z){var H=z-h,U=z-n;return h===void 0||H>=i||H<0||f&&U>=r}function w(){var z=St();if(_(z))return D(z);s=setTimeout(w,p(z))}function D(z){return s=void 0,d&&o?g(z):(o=t=void 0,e)}function B(){s!==void 0&&clearTimeout(s),n=0,o=h=t=s=void 0}function N(){return s===void 0?e:D(St())}function G(){var z=St(),H=_(z);if(o=arguments,t=this,h=z,H){if(s===void 0)return m(h);if(f)return clearTimeout(s),s=setTimeout(w,i),g(h)}return s===void 0&&(s=setTimeout(w,i)),e}return G.cancel=B,G.flush=N,G}var ie=Ve;var qe="Expected a function";function Ke(c,i,a){var o=!0,t=!0;if(typeof c!="function")throw new TypeError(qe);return ft(a)&&(o="leading"in a?!!a.leading:o,t="trailing"in a?!!a.trailing:t),ie(c,i,{leading:o,maxWait:i,trailing:t})}var wt=Ke;var Tt=class extends HTMLElement{constructor(){super();at(this,"imagestr","");at(this,"shouldrenderimage",!0);at(this,"detectedobjects",[]);at(this,"actions",[]);at(this,"canvas");at(this,"canvasElement");at(this,"canvasWrapper");at(this,"resizeObserver");at(this,"previousWidth",0);at(this,"previousHeight",0);at(this,"startDrawingThrottled",wt(()=>{this.startDrawing()},150));this.attachShadow({mode:"open"})}connectedCallback(){this.render()}disconnectedCallback(){this.destroyCanvas()}render(){this.shadowRoot.innerHTML=`
|
|
453
|
+
<div id="canvas-wrapper">
|
|
454
|
+
<canvas id='canvas'></canvas>
|
|
455
|
+
</div>
|
|
456
|
+
`,this.canvasWrapper=this.shadowRoot.getElementById("canvas-wrapper"),this.canvasElement=this.shadowRoot.getElementById("canvas"),this.resizeObserver=new ResizeObserver(wt(()=>{this.previousWidth===this.canvasWrapper.clientWidth&&this.previousHeight===this.canvasWrapper.clientHeight||(this.previousWidth=this.canvasWrapper.clientWidth,this.previousHeight=this.canvasWrapper.clientHeight,this.startDrawing())},150)),this.resizeObserver.observe(this.canvasWrapper),this.startDrawingThrottled()}startDrawing(){!this.isConnected||!this.canvasWrapper||!this.canvasElement||this.imagestr!==""&&(this.canvas&&this.destroyCanvas(),this.initCanvas(),this.renderCanvas())}initCanvas(){try{this.canvas=new _t(new re.fabric.Canvas(this.canvasElement,{fireRightClick:!0,stopContextMenu:!0}),this.canvasWrapper)}catch(a){console.error("Error initializing canvas:",a)}}destroyCanvas(){var a;(a=this.canvas)==null||a.destroy()}renderCanvas(){return gt(this,null,function*(){var a;try{yield(a=this.canvas)==null?void 0:a.drawImage(this.imagestr,this.shouldrenderimage),this.drawRects(),this.drawActions()}catch(o){console.error("Error rendering canvas:",o)}})}drawActions(){this.actions.forEach((a,o)=>{var t;try{(t=this.canvas)==null||t.drawActionSvg(o,a)}catch(r){console.error(`Error drawing action ${o}:`,r)}})}drawRects(){Array.from(this.detectedobjects).sort((o,t)=>t.bbox.size-o.bbox.size).forEach((o,t)=>{var r;try{(r=this.canvas)==null||r.drawDetectedElementRect(t,o)}catch(e){console.error(`Error drawing rect ${t}:`,e)}})}attributeChangedCallback(a,o,t){if(o!==t){switch(a){case"imagestr":this.imagestr=t!=null?t:"";break;case"shouldrenderimage":this.shouldrenderimage=t==="true";break;case"detectedobjects":this.detectedobjects=t?JSON.parse(t).map(Ct.fromJson):[];break;case"actions":this.actions=t?JSON.parse(t):[];break}this.startDrawingThrottled()}}};at(Tt,"observedAttributes",["imagestr","shouldrenderimage","detectedobjects","actions"]);customElements.define("bounding-box-renderer",Tt);})();
|
|
457
|
+
/*! Bundled license information:
|
|
458
|
+
|
|
459
|
+
fabric-pure-browser/dist/fabric.js:
|
|
460
|
+
(*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) *)
|
|
15
461
|
|
|
16
|
-
|
|
462
|
+
lodash-es/lodash.js:
|
|
463
|
+
(**
|
|
464
|
+
* @license
|
|
465
|
+
* Lodash (Custom Build) <https://lodash.com/>
|
|
466
|
+
* Build: `lodash modularize exports="es" -o ./`
|
|
467
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
468
|
+
* Released under MIT license <https://lodash.com/license>
|
|
469
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
470
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
471
|
+
*)
|
|
472
|
+
*/
|
|
473
|
+
//# sourceMappingURL=bounding-box-renderer.js.map
|
|
474
|
+
</script>
|
|
475
|
+
</body>
|
|
476
|
+
</html>
|