kritzel-stencil 0.3.32 → 0.3.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/cjs/index.cjs.js +1 -1
  2. package/dist/cjs/kritzel-active-users_45.cjs.entry.js +3122 -8
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{schema.constants-DItwOm2z.js → schema.constants-D7Z8ELAd.js} +5 -2
  5. package/dist/cjs/stencil.cjs.js +1 -1
  6. package/dist/collection/classes/managers/anchor.manager.js +3 -2
  7. package/dist/collection/components/shared/kritzel-pill-tabs/kritzel-pill-tabs.css +10 -0
  8. package/dist/collection/components/ui/kritzel-share-dialog/kritzel-share-dialog.css +17 -0
  9. package/dist/collection/components/ui/kritzel-share-dialog/kritzel-share-dialog.js +44 -3
  10. package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js +1 -1
  11. package/dist/collection/components/ui/kritzel-zoom-panel/kritzel-zoom-panel.js +1 -1
  12. package/dist/collection/constants/version.js +1 -1
  13. package/dist/collection/themes/dark-theme.js +1 -0
  14. package/dist/collection/themes/light-theme.js +1 -0
  15. package/dist/components/index.js +1 -1
  16. package/dist/components/kritzel-awareness-cursors.js +1 -1
  17. package/dist/components/kritzel-color-palette.js +1 -1
  18. package/dist/components/kritzel-color.js +1 -1
  19. package/dist/components/kritzel-controls.js +1 -1
  20. package/dist/components/kritzel-editor.js +1 -1
  21. package/dist/components/kritzel-engine.js +1 -1
  22. package/dist/components/kritzel-export.js +1 -1
  23. package/dist/components/kritzel-pill-tabs.js +1 -1
  24. package/dist/components/kritzel-settings.js +1 -1
  25. package/dist/components/kritzel-share-dialog.js +1 -1
  26. package/dist/components/kritzel-stroke-size.js +1 -1
  27. package/dist/components/kritzel-tool-config.js +1 -1
  28. package/dist/components/kritzel-utility-panel.js +1 -1
  29. package/dist/components/kritzel-zoom-panel.js +1 -1
  30. package/dist/components/{p-DfIknZRl.js → p-2Swq9rEm.js} +1 -1
  31. package/dist/components/{p-C1jg5IQi.js → p-7ZnANv7C.js} +1 -1
  32. package/dist/components/{p-NwN6r0N0.js → p-8p1DKytO.js} +1 -1
  33. package/dist/components/p-BFTU3MAI.js +1 -0
  34. package/dist/components/{p-COhjyuRa.js → p-BUc0GFPj.js} +1 -1
  35. package/dist/components/{p-Dl3MwBL1.js → p-BVu03tNB.js} +1 -1
  36. package/dist/components/{p-C4-Som48.js → p-BcB97x3U.js} +1 -1
  37. package/dist/components/{p-14NPx-_P.js → p-BeHVCJ7n.js} +1 -1
  38. package/dist/components/p-BmyTdQGy.js +1 -0
  39. package/dist/components/{p-BmX2Vb4Z.js → p-BoA6RXEA.js} +1 -1
  40. package/dist/components/{p-vf28uSsc.js → p-CfS-5J9k.js} +1 -1
  41. package/dist/components/p-D09kgc5Q.js +1 -0
  42. package/dist/components/p-DJVRW9So.js +1 -0
  43. package/dist/components/{p-y5T0_Wvi.js → p-DYLBjStF.js} +1 -1
  44. package/dist/components/{p-FjazwgrY.js → p-DZ8yfhhf.js} +1 -1
  45. package/dist/components/p-vLVZEJXX.js +9 -0
  46. package/dist/components/{p-CO0eEzos.js → p-wl9BhN6s.js} +1 -1
  47. package/dist/esm/index.js +2 -2
  48. package/dist/esm/kritzel-active-users_45.entry.js +3122 -8
  49. package/dist/esm/loader.js +1 -1
  50. package/dist/esm/{schema.constants-CH2FWTVr.js → schema.constants-CDQonV1J.js} +5 -2
  51. package/dist/esm/stencil.js +1 -1
  52. package/dist/stencil/index.esm.js +1 -1
  53. package/dist/stencil/p-3289cc4e.entry.js +9 -0
  54. package/dist/stencil/p-CDQonV1J.js +1 -0
  55. package/dist/stencil/stencil.esm.js +1 -1
  56. package/dist/types/components/ui/kritzel-share-dialog/kritzel-share-dialog.d.ts +4 -0
  57. package/dist/types/constants/version.d.ts +1 -1
  58. package/dist/types/interfaces/theme.interface.d.ts +1 -0
  59. package/package.json +6 -4
  60. package/dist/components/p-BG6hOSrm.js +0 -1
  61. package/dist/components/p-Ckpa5tHF.js +0 -1
  62. package/dist/components/p-CpzicliK.js +0 -1
  63. package/dist/components/p-DK2ZByiU.js +0 -9
  64. package/dist/stencil/p-CH2FWTVr.js +0 -1
  65. package/dist/stencil/p-be38d770.entry.js +0 -9
@@ -1,11 +1,15 @@
1
1
  import { r as registerInstance, h, H as Host, c as createEvent, g as getElement } from './index-Dhio9uis.js';
2
- import { c as KritzelPath, e as KritzelLine, R as KritzelColorHelper, T as KritzelDevicesHelper, q as KritzelSelectionTool, n as KritzelTextTool, U as KritzelMouseButton, V as KritzelHTMLHelper, X as DEFAULT_STROKE_SIZES, Y as DEFAULT_COLOR_PALETTE, S as ShapeType, D as DEFAULT_BRUSH_CONFIG, j as KritzelBrushTool, l as KritzelEraserTool, z as DEFAULT_LINE_TOOL_CONFIG, k as KritzelLineTool, o as KritzelShapeTool, y as DEFAULT_TEXT_CONFIG, m as KritzelImageTool, L as KritzelAlignment, B as DEFAULT_ASSET_STORAGE_CONFIG, Z as ObjectHelper, _ as ThemeHelper, E as darkTheme, C as lightTheme, $ as KritzelSelectionGroup, a0 as KritzelSelectionBox, a1 as KritzelIconRegistry, a2 as KritzelKeyboardHelper, a3 as KritzelBaseHandler, s as KritzelWorkspace, f as KritzelGroup, h as KritzelCustomElement, d as KritzelImage, g as KritzelShape, b as KritzelText, M as runMigrations, Q as CURRENT_WORKSPACE_SCHEMA_VERSION, O as WORKSPACE_MIGRATIONS, a4 as KritzelClassHelper, P as CURRENT_APP_STATE_SCHEMA_VERSION, N as APP_STATE_MIGRATIONS, p as KritzelCursorHelper, a5 as imageCompression, t as KritzelAnchorManager, u as KritzelThemeManager, v as KritzelLocalizationManager, w as KritzelLicenseManager, r as KritzelAssetResolver, a6 as KritzelEventHelper, W as WORKSPACE_EXPORT_VERSION } from './schema.constants-CH2FWTVr.js';
2
+ import { c as KritzelPath, e as KritzelLine, R as KritzelColorHelper, T as KritzelDevicesHelper, q as KritzelSelectionTool, n as KritzelTextTool, U as KritzelMouseButton, V as KritzelHTMLHelper, X as DEFAULT_STROKE_SIZES, Y as DEFAULT_COLOR_PALETTE, S as ShapeType, D as DEFAULT_BRUSH_CONFIG, j as KritzelBrushTool, l as KritzelEraserTool, z as DEFAULT_LINE_TOOL_CONFIG, k as KritzelLineTool, o as KritzelShapeTool, y as DEFAULT_TEXT_CONFIG, m as KritzelImageTool, L as KritzelAlignment, B as DEFAULT_ASSET_STORAGE_CONFIG, Z as ObjectHelper, _ as ThemeHelper, E as darkTheme, C as lightTheme, $ as KritzelSelectionGroup, a0 as KritzelSelectionBox, a1 as KritzelIconRegistry, a2 as KritzelKeyboardHelper, a3 as KritzelBaseHandler, s as KritzelWorkspace, f as KritzelGroup, h as KritzelCustomElement, d as KritzelImage, g as KritzelShape, b as KritzelText, M as runMigrations, Q as CURRENT_WORKSPACE_SCHEMA_VERSION, O as WORKSPACE_MIGRATIONS, a4 as KritzelClassHelper, P as CURRENT_APP_STATE_SCHEMA_VERSION, N as APP_STATE_MIGRATIONS, p as KritzelCursorHelper, a5 as imageCompression, t as KritzelAnchorManager, u as KritzelThemeManager, v as KritzelLocalizationManager, w as KritzelLicenseManager, r as KritzelAssetResolver, a6 as KritzelEventHelper, W as WORKSPACE_EXPORT_VERSION } from './schema.constants-CDQonV1J.js';
3
3
  import * as Y from 'yjs';
4
4
  import 'y-indexeddb';
5
5
  import 'y-websocket';
6
6
 
7
7
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
8
8
 
9
+ function getDefaultExportFromCjs (x) {
10
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
11
+ }
12
+
9
13
  const kritzelActiveUsersCss = () => `:host{display:inline-flex;align-items:center}.avatars{display:flex;align-items:center}.avatar-wrapper{position:relative;transition:margin-left 200ms ease}.avatar-wrapper kritzel-avatar{border-radius:50%;box-shadow:0 0 0 2px var(--kritzel-active-users-avatar-border-color, #ffffff)}.avatars:hover .avatar-wrapper{margin-left:-6px !important}.avatar-tooltip{position:absolute;top:100%;left:50%;transform:translateX(-50%);margin-top:12px;padding:4px 8px;background-color:var(--kritzel-active-users-tooltip-background, #333333);color:var(--kritzel-active-users-tooltip-color, #ffffff);font-family:sans-serif;font-size:12px;font-weight:500;border-radius:4px;white-space:nowrap;width:max-content;pointer-events:none;opacity:0;transition:opacity 150ms ease}.avatar-wrapper:hover .avatar-tooltip,.overflow-count:hover .avatar-tooltip{opacity:1}.overflow-count{position:relative;margin-left:8px;font-family:sans-serif;font-size:var(--kritzel-active-users-overflow-font-size, 14px);font-weight:500;color:var(--kritzel-active-users-overflow-color, #666666);white-space:nowrap;cursor:default}.overflow-count .avatar-tooltip{white-space:nowrap;text-align:left;margin-top:20px}`;
10
14
 
11
15
  const KritzelActiveUsers = class {
@@ -31021,7 +31025,7 @@ const KritzelOpacitySlider = class {
31021
31025
  };
31022
31026
  KritzelOpacitySlider.style = kritzelOpacitySliderCss();
31023
31027
 
31024
- const kritzelPillTabsCss = () => `:host{display:block}.pill-tabs-container{display:inline-flex;align-items:center;gap:4px;padding:4px;border-radius:var(--kritzel-pill-tabs-border-radius, 10px);background:var(--kritzel-pill-tabs-background, #f0f0f0);box-sizing:border-box}.pill-tab{display:flex;align-items:center;justify-content:center;gap:6px;padding:8px 16px;border:none;border-radius:var(--kritzel-pill-tabs-tab-border-radius, 8px);background:var(--kritzel-pill-tabs-tab-background, transparent);color:var(--kritzel-pill-tabs-tab-text-color, #666666);font-family:inherit;font-size:14px;font-weight:500;cursor:var(--kritzel-global-pointer-cursor, pointer);transition:background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;white-space:nowrap}.pill-tab:hover:not(.selected){background:var(--kritzel-pill-tabs-tab-background-hover, rgba(0, 0, 0, 0.05))}.pill-tab.selected{background:var(--kritzel-pill-tabs-tab-background-selected, #ffffff);color:var(--kritzel-pill-tabs-tab-text-color-selected, #000000);box-shadow:var(--kritzel-pill-tabs-tab-shadow-selected, 0 1px 3px rgba(0, 0, 0, 0.1))}.pill-tab:focus{outline:none}.pill-tab:focus-visible{box-shadow:0 0 0 2px var(--kritzel-global-focus-ring-color, rgba(0, 122, 255, 0.3))}.pill-tab-label{line-height:1}.pill-tab kritzel-icon{flex-shrink:0}`;
31028
+ const kritzelPillTabsCss = () => `:host{display:block;max-width:100%}.pill-tabs-container{display:inline-flex;align-items:center;gap:4px;padding:4px;max-width:100%;border-radius:var(--kritzel-pill-tabs-border-radius, 10px);background:var(--kritzel-pill-tabs-background, #f0f0f0);box-sizing:border-box}.pill-tab{display:flex;align-items:center;justify-content:center;gap:6px;min-width:0;max-width:100%;padding:8px 16px;border:none;border-radius:var(--kritzel-pill-tabs-tab-border-radius, 8px);background:var(--kritzel-pill-tabs-tab-background, transparent);color:var(--kritzel-pill-tabs-tab-text-color, #666666);font-family:inherit;font-size:14px;font-weight:500;cursor:var(--kritzel-global-pointer-cursor, pointer);transition:background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;white-space:nowrap}.pill-tab:hover:not(.selected){background:var(--kritzel-pill-tabs-tab-background-hover, rgba(0, 0, 0, 0.05))}.pill-tab.selected{background:var(--kritzel-pill-tabs-tab-background-selected, #ffffff);color:var(--kritzel-pill-tabs-tab-text-color-selected, #000000);box-shadow:var(--kritzel-pill-tabs-tab-shadow-selected, 0 1px 3px rgba(0, 0, 0, 0.1))}.pill-tab:focus{outline:none}.pill-tab:focus-visible{box-shadow:0 0 0 2px var(--kritzel-global-focus-ring-color, rgba(0, 122, 255, 0.3))}.pill-tab-label{display:block;min-width:0;max-width:var(--kritzel-pill-tabs-tab-label-max-width, 10rem);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1}.pill-tab kritzel-icon{flex-shrink:0}`;
31025
31029
 
31026
31030
  const KritzelPillTabs = class {
31027
31031
  constructor(hostRef) {
@@ -31380,7 +31384,7 @@ const KritzelPortal = class {
31380
31384
  * This file is auto-generated by the version bump scripts.
31381
31385
  * Do not modify manually.
31382
31386
  */
31383
- const KRITZEL_VERSION = '0.3.32';
31387
+ const KRITZEL_VERSION = '0.3.34';
31384
31388
 
31385
31389
  const kritzelSettingsCss = () => `:host{display:contents}kritzel-dialog{--kritzel-dialog-body-padding:0;--kritzel-dialog-width-large:800px;--kritzel-dialog-height-large:500px}.footer-button{padding:8px 16px;border-radius:6px;cursor:pointer;font-size:14px}.cancel-button{border:1px solid #ebebeb;background:#fff;color:inherit}.cancel-button:hover{background:#f5f5f5}.settings-content{padding:0}.settings-content h3{margin:0 0 16px 0;font-size:18px;font-weight:600;color:var(--kritzel-settings-content-heading-color, #333333)}.settings-content p{margin:0;font-size:14px;color:var(--kritzel-settings-content-text-color, #666666);line-height:1.5}.settings-group{display:flex;flex-direction:column;gap:24px}.settings-item{display:flex;flex-direction:column;gap:8px}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:16px}.settings-label{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.settings-description{font-size:12px;color:var(--kritzel-settings-description-color, #888888);margin:0;line-height:1.4}.shortcuts-list{display:flex;flex-direction:column;gap:24px}.shortcuts-category{display:flex;flex-direction:column;gap:8px}.shortcuts-category-title{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.shortcuts-group{display:flex;flex-direction:column;gap:4px}.shortcut-item{display:flex;justify-content:space-between;align-items:center;padding:6px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-item-bg, rgba(0, 0, 0, 0.02))}.shortcut-label{font-size:14px;color:var(--kritzel-settings-content-text-color, #666666)}.shortcut-key{font-family:monospace;font-size:12px;padding:2px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-key-bg, #f0f0f0);color:var(--kritzel-settings-shortcut-key-color, #333333);border:1px solid var(--kritzel-settings-shortcut-key-border, #ddd)}`;
31386
31390
 
@@ -31649,7 +31653,3078 @@ const KritzelShapeFill = class {
31649
31653
  };
31650
31654
  KritzelShapeFill.style = kritzelShapeFillCss();
31651
31655
 
31652
- const kritzelShareDialogCss = () => `:host{display:contents}kritzel-dialog{--kritzel-dialog-width-small:420px}.share-content{display:flex;flex-direction:column;gap:20px}.share-section{display:flex;flex-direction:column;gap:8px}.share-section-revoke{padding-top:12px;border-top:1px solid var(--kritzel-share-dialog-border-color, #e5e5e5)}.share-row{display:flex;align-items:center;justify-content:space-between;gap:16px}.share-label-group{display:flex;flex-direction:column;gap:8px;flex:1}.share-label{font-size:14px;font-weight:600;color:var(--kritzel-share-dialog-label-color, #333333);margin:0}.share-description{font-size:12px;color:var(--kritzel-share-dialog-description-color, #666666);margin:0;line-height:1.4}.share-url-container{display:flex;align-items:center;gap:8px;background:var(--kritzel-share-dialog-input-background, #f5f5f5);border:1px solid var(--kritzel-share-dialog-input-border-color, #e0e0e0);border-radius:6px;padding:4px 4px 4px 12px}.share-url-input{flex:1;border:none;background:transparent;font-size:13px;color:var(--kritzel-share-dialog-input-text-color, #333333);outline:none;min-width:0;padding:8px 0}.share-url-input:focus{outline:none}.share-url-input::selection{background:var(--kritzel-share-dialog-selection-color, #cce5ff)}.copy-button{display:flex;align-items:center;justify-content:center;width:36px;height:36px;border:none;border-radius:4px;background:var(--kritzel-share-dialog-copy-button-background, #ffffff);color:var(--kritzel-share-dialog-copy-button-color, #666666);cursor:pointer;transition:all 0.15s ease;flex-shrink:0}.copy-button:hover{background:var(--kritzel-share-dialog-copy-button-hover-background, #e8e8e8);color:var(--kritzel-share-dialog-copy-button-hover-color, #333333)}.copy-button.copy-success{background:var(--kritzel-share-dialog-copy-success-background, #d4edda);color:var(--kritzel-share-dialog-copy-success-color, #28a745)}.revoke-button{align-self:flex-start;padding:8px 16px;border:1px solid var(--kritzel-share-dialog-revoke-button-border-color, #dc3545);border-radius:6px;background:transparent;color:var(--kritzel-share-dialog-revoke-button-color, #dc3545);font-size:13px;font-weight:500;cursor:pointer;transition:all 0.15s ease}.revoke-button:hover{background:var(--kritzel-share-dialog-revoke-button-hover-background, #dc3545);color:var(--kritzel-share-dialog-revoke-button-hover-color, #ffffff)}kritzel-dropdown{--kritzel-dropdown-trigger-padding:8px 12px;--kritzel-dropdown-trigger-font-size:13px}`;
31656
+ var browser = {};
31657
+
31658
+ var canPromise;
31659
+ var hasRequiredCanPromise;
31660
+
31661
+ function requireCanPromise () {
31662
+ if (hasRequiredCanPromise) return canPromise;
31663
+ hasRequiredCanPromise = 1;
31664
+ // can-promise has a crash in some versions of react native that dont have
31665
+ // standard global objects
31666
+ // https://github.com/soldair/node-qrcode/issues/157
31667
+
31668
+ canPromise = function () {
31669
+ return typeof Promise === 'function' && Promise.prototype && Promise.prototype.then
31670
+ };
31671
+ return canPromise;
31672
+ }
31673
+
31674
+ var qrcode = {};
31675
+
31676
+ var utils$1 = {};
31677
+
31678
+ var hasRequiredUtils$1;
31679
+
31680
+ function requireUtils$1 () {
31681
+ if (hasRequiredUtils$1) return utils$1;
31682
+ hasRequiredUtils$1 = 1;
31683
+ let toSJISFunction;
31684
+ const CODEWORDS_COUNT = [
31685
+ 0, // Not used
31686
+ 26, 44, 70, 100, 134, 172, 196, 242, 292, 346,
31687
+ 404, 466, 532, 581, 655, 733, 815, 901, 991, 1085,
31688
+ 1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051, 2185,
31689
+ 2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706
31690
+ ];
31691
+
31692
+ /**
31693
+ * Returns the QR Code size for the specified version
31694
+ *
31695
+ * @param {Number} version QR Code version
31696
+ * @return {Number} size of QR code
31697
+ */
31698
+ utils$1.getSymbolSize = function getSymbolSize (version) {
31699
+ if (!version) throw new Error('"version" cannot be null or undefined')
31700
+ if (version < 1 || version > 40) throw new Error('"version" should be in range from 1 to 40')
31701
+ return version * 4 + 17
31702
+ };
31703
+
31704
+ /**
31705
+ * Returns the total number of codewords used to store data and EC information.
31706
+ *
31707
+ * @param {Number} version QR Code version
31708
+ * @return {Number} Data length in bits
31709
+ */
31710
+ utils$1.getSymbolTotalCodewords = function getSymbolTotalCodewords (version) {
31711
+ return CODEWORDS_COUNT[version]
31712
+ };
31713
+
31714
+ /**
31715
+ * Encode data with Bose-Chaudhuri-Hocquenghem
31716
+ *
31717
+ * @param {Number} data Value to encode
31718
+ * @return {Number} Encoded value
31719
+ */
31720
+ utils$1.getBCHDigit = function (data) {
31721
+ let digit = 0;
31722
+
31723
+ while (data !== 0) {
31724
+ digit++;
31725
+ data >>>= 1;
31726
+ }
31727
+
31728
+ return digit
31729
+ };
31730
+
31731
+ utils$1.setToSJISFunction = function setToSJISFunction (f) {
31732
+ if (typeof f !== 'function') {
31733
+ throw new Error('"toSJISFunc" is not a valid function.')
31734
+ }
31735
+
31736
+ toSJISFunction = f;
31737
+ };
31738
+
31739
+ utils$1.isKanjiModeEnabled = function () {
31740
+ return typeof toSJISFunction !== 'undefined'
31741
+ };
31742
+
31743
+ utils$1.toSJIS = function toSJIS (kanji) {
31744
+ return toSJISFunction(kanji)
31745
+ };
31746
+ return utils$1;
31747
+ }
31748
+
31749
+ var errorCorrectionLevel = {};
31750
+
31751
+ var hasRequiredErrorCorrectionLevel;
31752
+
31753
+ function requireErrorCorrectionLevel () {
31754
+ if (hasRequiredErrorCorrectionLevel) return errorCorrectionLevel;
31755
+ hasRequiredErrorCorrectionLevel = 1;
31756
+ (function (exports) {
31757
+ exports.L = { bit: 1 };
31758
+ exports.M = { bit: 0 };
31759
+ exports.Q = { bit: 3 };
31760
+ exports.H = { bit: 2 };
31761
+
31762
+ function fromString (string) {
31763
+ if (typeof string !== 'string') {
31764
+ throw new Error('Param is not a string')
31765
+ }
31766
+
31767
+ const lcStr = string.toLowerCase();
31768
+
31769
+ switch (lcStr) {
31770
+ case 'l':
31771
+ case 'low':
31772
+ return exports.L
31773
+
31774
+ case 'm':
31775
+ case 'medium':
31776
+ return exports.M
31777
+
31778
+ case 'q':
31779
+ case 'quartile':
31780
+ return exports.Q
31781
+
31782
+ case 'h':
31783
+ case 'high':
31784
+ return exports.H
31785
+
31786
+ default:
31787
+ throw new Error('Unknown EC Level: ' + string)
31788
+ }
31789
+ }
31790
+
31791
+ exports.isValid = function isValid (level) {
31792
+ return level && typeof level.bit !== 'undefined' &&
31793
+ level.bit >= 0 && level.bit < 4
31794
+ };
31795
+
31796
+ exports.from = function from (value, defaultValue) {
31797
+ if (exports.isValid(value)) {
31798
+ return value
31799
+ }
31800
+
31801
+ try {
31802
+ return fromString(value)
31803
+ } catch (e) {
31804
+ return defaultValue
31805
+ }
31806
+ };
31807
+ } (errorCorrectionLevel));
31808
+ return errorCorrectionLevel;
31809
+ }
31810
+
31811
+ var bitBuffer;
31812
+ var hasRequiredBitBuffer;
31813
+
31814
+ function requireBitBuffer () {
31815
+ if (hasRequiredBitBuffer) return bitBuffer;
31816
+ hasRequiredBitBuffer = 1;
31817
+ function BitBuffer () {
31818
+ this.buffer = [];
31819
+ this.length = 0;
31820
+ }
31821
+
31822
+ BitBuffer.prototype = {
31823
+
31824
+ get: function (index) {
31825
+ const bufIndex = Math.floor(index / 8);
31826
+ return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1) === 1
31827
+ },
31828
+
31829
+ put: function (num, length) {
31830
+ for (let i = 0; i < length; i++) {
31831
+ this.putBit(((num >>> (length - i - 1)) & 1) === 1);
31832
+ }
31833
+ },
31834
+
31835
+ getLengthInBits: function () {
31836
+ return this.length
31837
+ },
31838
+
31839
+ putBit: function (bit) {
31840
+ const bufIndex = Math.floor(this.length / 8);
31841
+ if (this.buffer.length <= bufIndex) {
31842
+ this.buffer.push(0);
31843
+ }
31844
+
31845
+ if (bit) {
31846
+ this.buffer[bufIndex] |= (0x80 >>> (this.length % 8));
31847
+ }
31848
+
31849
+ this.length++;
31850
+ }
31851
+ };
31852
+
31853
+ bitBuffer = BitBuffer;
31854
+ return bitBuffer;
31855
+ }
31856
+
31857
+ /**
31858
+ * Helper class to handle QR Code symbol modules
31859
+ *
31860
+ * @param {Number} size Symbol size
31861
+ */
31862
+
31863
+ var bitMatrix;
31864
+ var hasRequiredBitMatrix;
31865
+
31866
+ function requireBitMatrix () {
31867
+ if (hasRequiredBitMatrix) return bitMatrix;
31868
+ hasRequiredBitMatrix = 1;
31869
+ function BitMatrix (size) {
31870
+ if (!size || size < 1) {
31871
+ throw new Error('BitMatrix size must be defined and greater than 0')
31872
+ }
31873
+
31874
+ this.size = size;
31875
+ this.data = new Uint8Array(size * size);
31876
+ this.reservedBit = new Uint8Array(size * size);
31877
+ }
31878
+
31879
+ /**
31880
+ * Set bit value at specified location
31881
+ * If reserved flag is set, this bit will be ignored during masking process
31882
+ *
31883
+ * @param {Number} row
31884
+ * @param {Number} col
31885
+ * @param {Boolean} value
31886
+ * @param {Boolean} reserved
31887
+ */
31888
+ BitMatrix.prototype.set = function (row, col, value, reserved) {
31889
+ const index = row * this.size + col;
31890
+ this.data[index] = value;
31891
+ if (reserved) this.reservedBit[index] = true;
31892
+ };
31893
+
31894
+ /**
31895
+ * Returns bit value at specified location
31896
+ *
31897
+ * @param {Number} row
31898
+ * @param {Number} col
31899
+ * @return {Boolean}
31900
+ */
31901
+ BitMatrix.prototype.get = function (row, col) {
31902
+ return this.data[row * this.size + col]
31903
+ };
31904
+
31905
+ /**
31906
+ * Applies xor operator at specified location
31907
+ * (used during masking process)
31908
+ *
31909
+ * @param {Number} row
31910
+ * @param {Number} col
31911
+ * @param {Boolean} value
31912
+ */
31913
+ BitMatrix.prototype.xor = function (row, col, value) {
31914
+ this.data[row * this.size + col] ^= value;
31915
+ };
31916
+
31917
+ /**
31918
+ * Check if bit at specified location is reserved
31919
+ *
31920
+ * @param {Number} row
31921
+ * @param {Number} col
31922
+ * @return {Boolean}
31923
+ */
31924
+ BitMatrix.prototype.isReserved = function (row, col) {
31925
+ return this.reservedBit[row * this.size + col]
31926
+ };
31927
+
31928
+ bitMatrix = BitMatrix;
31929
+ return bitMatrix;
31930
+ }
31931
+
31932
+ var alignmentPattern = {};
31933
+
31934
+ /**
31935
+ * Alignment pattern are fixed reference pattern in defined positions
31936
+ * in a matrix symbology, which enables the decode software to re-synchronise
31937
+ * the coordinate mapping of the image modules in the event of moderate amounts
31938
+ * of distortion of the image.
31939
+ *
31940
+ * Alignment patterns are present only in QR Code symbols of version 2 or larger
31941
+ * and their number depends on the symbol version.
31942
+ */
31943
+
31944
+ var hasRequiredAlignmentPattern;
31945
+
31946
+ function requireAlignmentPattern () {
31947
+ if (hasRequiredAlignmentPattern) return alignmentPattern;
31948
+ hasRequiredAlignmentPattern = 1;
31949
+ (function (exports) {
31950
+ const getSymbolSize = requireUtils$1().getSymbolSize;
31951
+
31952
+ /**
31953
+ * Calculate the row/column coordinates of the center module of each alignment pattern
31954
+ * for the specified QR Code version.
31955
+ *
31956
+ * The alignment patterns are positioned symmetrically on either side of the diagonal
31957
+ * running from the top left corner of the symbol to the bottom right corner.
31958
+ *
31959
+ * Since positions are simmetrical only half of the coordinates are returned.
31960
+ * Each item of the array will represent in turn the x and y coordinate.
31961
+ * @see {@link getPositions}
31962
+ *
31963
+ * @param {Number} version QR Code version
31964
+ * @return {Array} Array of coordinate
31965
+ */
31966
+ exports.getRowColCoords = function getRowColCoords (version) {
31967
+ if (version === 1) return []
31968
+
31969
+ const posCount = Math.floor(version / 7) + 2;
31970
+ const size = getSymbolSize(version);
31971
+ const intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2;
31972
+ const positions = [size - 7]; // Last coord is always (size - 7)
31973
+
31974
+ for (let i = 1; i < posCount - 1; i++) {
31975
+ positions[i] = positions[i - 1] - intervals;
31976
+ }
31977
+
31978
+ positions.push(6); // First coord is always 6
31979
+
31980
+ return positions.reverse()
31981
+ };
31982
+
31983
+ /**
31984
+ * Returns an array containing the positions of each alignment pattern.
31985
+ * Each array's element represent the center point of the pattern as (x, y) coordinates
31986
+ *
31987
+ * Coordinates are calculated expanding the row/column coordinates returned by {@link getRowColCoords}
31988
+ * and filtering out the items that overlaps with finder pattern
31989
+ *
31990
+ * @example
31991
+ * For a Version 7 symbol {@link getRowColCoords} returns values 6, 22 and 38.
31992
+ * The alignment patterns, therefore, are to be centered on (row, column)
31993
+ * positions (6,22), (22,6), (22,22), (22,38), (38,22), (38,38).
31994
+ * Note that the coordinates (6,6), (6,38), (38,6) are occupied by finder patterns
31995
+ * and are not therefore used for alignment patterns.
31996
+ *
31997
+ * let pos = getPositions(7)
31998
+ * // [[6,22], [22,6], [22,22], [22,38], [38,22], [38,38]]
31999
+ *
32000
+ * @param {Number} version QR Code version
32001
+ * @return {Array} Array of coordinates
32002
+ */
32003
+ exports.getPositions = function getPositions (version) {
32004
+ const coords = [];
32005
+ const pos = exports.getRowColCoords(version);
32006
+ const posLength = pos.length;
32007
+
32008
+ for (let i = 0; i < posLength; i++) {
32009
+ for (let j = 0; j < posLength; j++) {
32010
+ // Skip if position is occupied by finder patterns
32011
+ if ((i === 0 && j === 0) || // top-left
32012
+ (i === 0 && j === posLength - 1) || // bottom-left
32013
+ (i === posLength - 1 && j === 0)) { // top-right
32014
+ continue
32015
+ }
32016
+
32017
+ coords.push([pos[i], pos[j]]);
32018
+ }
32019
+ }
32020
+
32021
+ return coords
32022
+ };
32023
+ } (alignmentPattern));
32024
+ return alignmentPattern;
32025
+ }
32026
+
32027
+ var finderPattern = {};
32028
+
32029
+ var hasRequiredFinderPattern;
32030
+
32031
+ function requireFinderPattern () {
32032
+ if (hasRequiredFinderPattern) return finderPattern;
32033
+ hasRequiredFinderPattern = 1;
32034
+ const getSymbolSize = requireUtils$1().getSymbolSize;
32035
+ const FINDER_PATTERN_SIZE = 7;
32036
+
32037
+ /**
32038
+ * Returns an array containing the positions of each finder pattern.
32039
+ * Each array's element represent the top-left point of the pattern as (x, y) coordinates
32040
+ *
32041
+ * @param {Number} version QR Code version
32042
+ * @return {Array} Array of coordinates
32043
+ */
32044
+ finderPattern.getPositions = function getPositions (version) {
32045
+ const size = getSymbolSize(version);
32046
+
32047
+ return [
32048
+ // top-left
32049
+ [0, 0],
32050
+ // top-right
32051
+ [size - FINDER_PATTERN_SIZE, 0],
32052
+ // bottom-left
32053
+ [0, size - FINDER_PATTERN_SIZE]
32054
+ ]
32055
+ };
32056
+ return finderPattern;
32057
+ }
32058
+
32059
+ var maskPattern = {};
32060
+
32061
+ /**
32062
+ * Data mask pattern reference
32063
+ * @type {Object}
32064
+ */
32065
+
32066
+ var hasRequiredMaskPattern;
32067
+
32068
+ function requireMaskPattern () {
32069
+ if (hasRequiredMaskPattern) return maskPattern;
32070
+ hasRequiredMaskPattern = 1;
32071
+ (function (exports) {
32072
+ exports.Patterns = {
32073
+ PATTERN000: 0,
32074
+ PATTERN001: 1,
32075
+ PATTERN010: 2,
32076
+ PATTERN011: 3,
32077
+ PATTERN100: 4,
32078
+ PATTERN101: 5,
32079
+ PATTERN110: 6,
32080
+ PATTERN111: 7
32081
+ };
32082
+
32083
+ /**
32084
+ * Weighted penalty scores for the undesirable features
32085
+ * @type {Object}
32086
+ */
32087
+ const PenaltyScores = {
32088
+ N1: 3,
32089
+ N2: 3,
32090
+ N3: 40,
32091
+ N4: 10
32092
+ };
32093
+
32094
+ /**
32095
+ * Check if mask pattern value is valid
32096
+ *
32097
+ * @param {Number} mask Mask pattern
32098
+ * @return {Boolean} true if valid, false otherwise
32099
+ */
32100
+ exports.isValid = function isValid (mask) {
32101
+ return mask != null && mask !== '' && !isNaN(mask) && mask >= 0 && mask <= 7
32102
+ };
32103
+
32104
+ /**
32105
+ * Returns mask pattern from a value.
32106
+ * If value is not valid, returns undefined
32107
+ *
32108
+ * @param {Number|String} value Mask pattern value
32109
+ * @return {Number} Valid mask pattern or undefined
32110
+ */
32111
+ exports.from = function from (value) {
32112
+ return exports.isValid(value) ? parseInt(value, 10) : undefined
32113
+ };
32114
+
32115
+ /**
32116
+ * Find adjacent modules in row/column with the same color
32117
+ * and assign a penalty value.
32118
+ *
32119
+ * Points: N1 + i
32120
+ * i is the amount by which the number of adjacent modules of the same color exceeds 5
32121
+ */
32122
+ exports.getPenaltyN1 = function getPenaltyN1 (data) {
32123
+ const size = data.size;
32124
+ let points = 0;
32125
+ let sameCountCol = 0;
32126
+ let sameCountRow = 0;
32127
+ let lastCol = null;
32128
+ let lastRow = null;
32129
+
32130
+ for (let row = 0; row < size; row++) {
32131
+ sameCountCol = sameCountRow = 0;
32132
+ lastCol = lastRow = null;
32133
+
32134
+ for (let col = 0; col < size; col++) {
32135
+ let module = data.get(row, col);
32136
+ if (module === lastCol) {
32137
+ sameCountCol++;
32138
+ } else {
32139
+ if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
32140
+ lastCol = module;
32141
+ sameCountCol = 1;
32142
+ }
32143
+
32144
+ module = data.get(col, row);
32145
+ if (module === lastRow) {
32146
+ sameCountRow++;
32147
+ } else {
32148
+ if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
32149
+ lastRow = module;
32150
+ sameCountRow = 1;
32151
+ }
32152
+ }
32153
+
32154
+ if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
32155
+ if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
32156
+ }
32157
+
32158
+ return points
32159
+ };
32160
+
32161
+ /**
32162
+ * Find 2x2 blocks with the same color and assign a penalty value
32163
+ *
32164
+ * Points: N2 * (m - 1) * (n - 1)
32165
+ */
32166
+ exports.getPenaltyN2 = function getPenaltyN2 (data) {
32167
+ const size = data.size;
32168
+ let points = 0;
32169
+
32170
+ for (let row = 0; row < size - 1; row++) {
32171
+ for (let col = 0; col < size - 1; col++) {
32172
+ const last = data.get(row, col) +
32173
+ data.get(row, col + 1) +
32174
+ data.get(row + 1, col) +
32175
+ data.get(row + 1, col + 1);
32176
+
32177
+ if (last === 4 || last === 0) points++;
32178
+ }
32179
+ }
32180
+
32181
+ return points * PenaltyScores.N2
32182
+ };
32183
+
32184
+ /**
32185
+ * Find 1:1:3:1:1 ratio (dark:light:dark:light:dark) pattern in row/column,
32186
+ * preceded or followed by light area 4 modules wide
32187
+ *
32188
+ * Points: N3 * number of pattern found
32189
+ */
32190
+ exports.getPenaltyN3 = function getPenaltyN3 (data) {
32191
+ const size = data.size;
32192
+ let points = 0;
32193
+ let bitsCol = 0;
32194
+ let bitsRow = 0;
32195
+
32196
+ for (let row = 0; row < size; row++) {
32197
+ bitsCol = bitsRow = 0;
32198
+ for (let col = 0; col < size; col++) {
32199
+ bitsCol = ((bitsCol << 1) & 0x7FF) | data.get(row, col);
32200
+ if (col >= 10 && (bitsCol === 0x5D0 || bitsCol === 0x05D)) points++;
32201
+
32202
+ bitsRow = ((bitsRow << 1) & 0x7FF) | data.get(col, row);
32203
+ if (col >= 10 && (bitsRow === 0x5D0 || bitsRow === 0x05D)) points++;
32204
+ }
32205
+ }
32206
+
32207
+ return points * PenaltyScores.N3
32208
+ };
32209
+
32210
+ /**
32211
+ * Calculate proportion of dark modules in entire symbol
32212
+ *
32213
+ * Points: N4 * k
32214
+ *
32215
+ * k is the rating of the deviation of the proportion of dark modules
32216
+ * in the symbol from 50% in steps of 5%
32217
+ */
32218
+ exports.getPenaltyN4 = function getPenaltyN4 (data) {
32219
+ let darkCount = 0;
32220
+ const modulesCount = data.data.length;
32221
+
32222
+ for (let i = 0; i < modulesCount; i++) darkCount += data.data[i];
32223
+
32224
+ const k = Math.abs(Math.ceil((darkCount * 100 / modulesCount) / 5) - 10);
32225
+
32226
+ return k * PenaltyScores.N4
32227
+ };
32228
+
32229
+ /**
32230
+ * Return mask value at given position
32231
+ *
32232
+ * @param {Number} maskPattern Pattern reference value
32233
+ * @param {Number} i Row
32234
+ * @param {Number} j Column
32235
+ * @return {Boolean} Mask value
32236
+ */
32237
+ function getMaskAt (maskPattern, i, j) {
32238
+ switch (maskPattern) {
32239
+ case exports.Patterns.PATTERN000: return (i + j) % 2 === 0
32240
+ case exports.Patterns.PATTERN001: return i % 2 === 0
32241
+ case exports.Patterns.PATTERN010: return j % 3 === 0
32242
+ case exports.Patterns.PATTERN011: return (i + j) % 3 === 0
32243
+ case exports.Patterns.PATTERN100: return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0
32244
+ case exports.Patterns.PATTERN101: return (i * j) % 2 + (i * j) % 3 === 0
32245
+ case exports.Patterns.PATTERN110: return ((i * j) % 2 + (i * j) % 3) % 2 === 0
32246
+ case exports.Patterns.PATTERN111: return ((i * j) % 3 + (i + j) % 2) % 2 === 0
32247
+
32248
+ default: throw new Error('bad maskPattern:' + maskPattern)
32249
+ }
32250
+ }
32251
+
32252
+ /**
32253
+ * Apply a mask pattern to a BitMatrix
32254
+ *
32255
+ * @param {Number} pattern Pattern reference number
32256
+ * @param {BitMatrix} data BitMatrix data
32257
+ */
32258
+ exports.applyMask = function applyMask (pattern, data) {
32259
+ const size = data.size;
32260
+
32261
+ for (let col = 0; col < size; col++) {
32262
+ for (let row = 0; row < size; row++) {
32263
+ if (data.isReserved(row, col)) continue
32264
+ data.xor(row, col, getMaskAt(pattern, row, col));
32265
+ }
32266
+ }
32267
+ };
32268
+
32269
+ /**
32270
+ * Returns the best mask pattern for data
32271
+ *
32272
+ * @param {BitMatrix} data
32273
+ * @return {Number} Mask pattern reference number
32274
+ */
32275
+ exports.getBestMask = function getBestMask (data, setupFormatFunc) {
32276
+ const numPatterns = Object.keys(exports.Patterns).length;
32277
+ let bestPattern = 0;
32278
+ let lowerPenalty = Infinity;
32279
+
32280
+ for (let p = 0; p < numPatterns; p++) {
32281
+ setupFormatFunc(p);
32282
+ exports.applyMask(p, data);
32283
+
32284
+ // Calculate penalty
32285
+ const penalty =
32286
+ exports.getPenaltyN1(data) +
32287
+ exports.getPenaltyN2(data) +
32288
+ exports.getPenaltyN3(data) +
32289
+ exports.getPenaltyN4(data);
32290
+
32291
+ // Undo previously applied mask
32292
+ exports.applyMask(p, data);
32293
+
32294
+ if (penalty < lowerPenalty) {
32295
+ lowerPenalty = penalty;
32296
+ bestPattern = p;
32297
+ }
32298
+ }
32299
+
32300
+ return bestPattern
32301
+ };
32302
+ } (maskPattern));
32303
+ return maskPattern;
32304
+ }
32305
+
32306
+ var errorCorrectionCode = {};
32307
+
32308
+ var hasRequiredErrorCorrectionCode;
32309
+
32310
+ function requireErrorCorrectionCode () {
32311
+ if (hasRequiredErrorCorrectionCode) return errorCorrectionCode;
32312
+ hasRequiredErrorCorrectionCode = 1;
32313
+ const ECLevel = requireErrorCorrectionLevel();
32314
+
32315
+ const EC_BLOCKS_TABLE = [
32316
+ // L M Q H
32317
+ 1, 1, 1, 1,
32318
+ 1, 1, 1, 1,
32319
+ 1, 1, 2, 2,
32320
+ 1, 2, 2, 4,
32321
+ 1, 2, 4, 4,
32322
+ 2, 4, 4, 4,
32323
+ 2, 4, 6, 5,
32324
+ 2, 4, 6, 6,
32325
+ 2, 5, 8, 8,
32326
+ 4, 5, 8, 8,
32327
+ 4, 5, 8, 11,
32328
+ 4, 8, 10, 11,
32329
+ 4, 9, 12, 16,
32330
+ 4, 9, 16, 16,
32331
+ 6, 10, 12, 18,
32332
+ 6, 10, 17, 16,
32333
+ 6, 11, 16, 19,
32334
+ 6, 13, 18, 21,
32335
+ 7, 14, 21, 25,
32336
+ 8, 16, 20, 25,
32337
+ 8, 17, 23, 25,
32338
+ 9, 17, 23, 34,
32339
+ 9, 18, 25, 30,
32340
+ 10, 20, 27, 32,
32341
+ 12, 21, 29, 35,
32342
+ 12, 23, 34, 37,
32343
+ 12, 25, 34, 40,
32344
+ 13, 26, 35, 42,
32345
+ 14, 28, 38, 45,
32346
+ 15, 29, 40, 48,
32347
+ 16, 31, 43, 51,
32348
+ 17, 33, 45, 54,
32349
+ 18, 35, 48, 57,
32350
+ 19, 37, 51, 60,
32351
+ 19, 38, 53, 63,
32352
+ 20, 40, 56, 66,
32353
+ 21, 43, 59, 70,
32354
+ 22, 45, 62, 74,
32355
+ 24, 47, 65, 77,
32356
+ 25, 49, 68, 81
32357
+ ];
32358
+
32359
+ const EC_CODEWORDS_TABLE = [
32360
+ // L M Q H
32361
+ 7, 10, 13, 17,
32362
+ 10, 16, 22, 28,
32363
+ 15, 26, 36, 44,
32364
+ 20, 36, 52, 64,
32365
+ 26, 48, 72, 88,
32366
+ 36, 64, 96, 112,
32367
+ 40, 72, 108, 130,
32368
+ 48, 88, 132, 156,
32369
+ 60, 110, 160, 192,
32370
+ 72, 130, 192, 224,
32371
+ 80, 150, 224, 264,
32372
+ 96, 176, 260, 308,
32373
+ 104, 198, 288, 352,
32374
+ 120, 216, 320, 384,
32375
+ 132, 240, 360, 432,
32376
+ 144, 280, 408, 480,
32377
+ 168, 308, 448, 532,
32378
+ 180, 338, 504, 588,
32379
+ 196, 364, 546, 650,
32380
+ 224, 416, 600, 700,
32381
+ 224, 442, 644, 750,
32382
+ 252, 476, 690, 816,
32383
+ 270, 504, 750, 900,
32384
+ 300, 560, 810, 960,
32385
+ 312, 588, 870, 1050,
32386
+ 336, 644, 952, 1110,
32387
+ 360, 700, 1020, 1200,
32388
+ 390, 728, 1050, 1260,
32389
+ 420, 784, 1140, 1350,
32390
+ 450, 812, 1200, 1440,
32391
+ 480, 868, 1290, 1530,
32392
+ 510, 924, 1350, 1620,
32393
+ 540, 980, 1440, 1710,
32394
+ 570, 1036, 1530, 1800,
32395
+ 570, 1064, 1590, 1890,
32396
+ 600, 1120, 1680, 1980,
32397
+ 630, 1204, 1770, 2100,
32398
+ 660, 1260, 1860, 2220,
32399
+ 720, 1316, 1950, 2310,
32400
+ 750, 1372, 2040, 2430
32401
+ ];
32402
+
32403
+ /**
32404
+ * Returns the number of error correction block that the QR Code should contain
32405
+ * for the specified version and error correction level.
32406
+ *
32407
+ * @param {Number} version QR Code version
32408
+ * @param {Number} errorCorrectionLevel Error correction level
32409
+ * @return {Number} Number of error correction blocks
32410
+ */
32411
+ errorCorrectionCode.getBlocksCount = function getBlocksCount (version, errorCorrectionLevel) {
32412
+ switch (errorCorrectionLevel) {
32413
+ case ECLevel.L:
32414
+ return EC_BLOCKS_TABLE[(version - 1) * 4 + 0]
32415
+ case ECLevel.M:
32416
+ return EC_BLOCKS_TABLE[(version - 1) * 4 + 1]
32417
+ case ECLevel.Q:
32418
+ return EC_BLOCKS_TABLE[(version - 1) * 4 + 2]
32419
+ case ECLevel.H:
32420
+ return EC_BLOCKS_TABLE[(version - 1) * 4 + 3]
32421
+ default:
32422
+ return undefined
32423
+ }
32424
+ };
32425
+
32426
+ /**
32427
+ * Returns the number of error correction codewords to use for the specified
32428
+ * version and error correction level.
32429
+ *
32430
+ * @param {Number} version QR Code version
32431
+ * @param {Number} errorCorrectionLevel Error correction level
32432
+ * @return {Number} Number of error correction codewords
32433
+ */
32434
+ errorCorrectionCode.getTotalCodewordsCount = function getTotalCodewordsCount (version, errorCorrectionLevel) {
32435
+ switch (errorCorrectionLevel) {
32436
+ case ECLevel.L:
32437
+ return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0]
32438
+ case ECLevel.M:
32439
+ return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1]
32440
+ case ECLevel.Q:
32441
+ return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2]
32442
+ case ECLevel.H:
32443
+ return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3]
32444
+ default:
32445
+ return undefined
32446
+ }
32447
+ };
32448
+ return errorCorrectionCode;
32449
+ }
32450
+
32451
+ var polynomial = {};
32452
+
32453
+ var galoisField = {};
32454
+
32455
+ var hasRequiredGaloisField;
32456
+
32457
+ function requireGaloisField () {
32458
+ if (hasRequiredGaloisField) return galoisField;
32459
+ hasRequiredGaloisField = 1;
32460
+ const EXP_TABLE = new Uint8Array(512);
32461
+ const LOG_TABLE = new Uint8Array(256)
32462
+ /**
32463
+ * Precompute the log and anti-log tables for faster computation later
32464
+ *
32465
+ * For each possible value in the galois field 2^8, we will pre-compute
32466
+ * the logarithm and anti-logarithm (exponential) of this value
32467
+ *
32468
+ * ref {@link https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders#Introduction_to_mathematical_fields}
32469
+ */
32470
+ ;(function initTables () {
32471
+ let x = 1;
32472
+ for (let i = 0; i < 255; i++) {
32473
+ EXP_TABLE[i] = x;
32474
+ LOG_TABLE[x] = i;
32475
+
32476
+ x <<= 1; // multiply by 2
32477
+
32478
+ // The QR code specification says to use byte-wise modulo 100011101 arithmetic.
32479
+ // This means that when a number is 256 or larger, it should be XORed with 0x11D.
32480
+ if (x & 0x100) { // similar to x >= 256, but a lot faster (because 0x100 == 256)
32481
+ x ^= 0x11D;
32482
+ }
32483
+ }
32484
+
32485
+ // Optimization: double the size of the anti-log table so that we don't need to mod 255 to
32486
+ // stay inside the bounds (because we will mainly use this table for the multiplication of
32487
+ // two GF numbers, no more).
32488
+ // @see {@link mul}
32489
+ for (let i = 255; i < 512; i++) {
32490
+ EXP_TABLE[i] = EXP_TABLE[i - 255];
32491
+ }
32492
+ }());
32493
+
32494
+ /**
32495
+ * Returns log value of n inside Galois Field
32496
+ *
32497
+ * @param {Number} n
32498
+ * @return {Number}
32499
+ */
32500
+ galoisField.log = function log (n) {
32501
+ if (n < 1) throw new Error('log(' + n + ')')
32502
+ return LOG_TABLE[n]
32503
+ };
32504
+
32505
+ /**
32506
+ * Returns anti-log value of n inside Galois Field
32507
+ *
32508
+ * @param {Number} n
32509
+ * @return {Number}
32510
+ */
32511
+ galoisField.exp = function exp (n) {
32512
+ return EXP_TABLE[n]
32513
+ };
32514
+
32515
+ /**
32516
+ * Multiplies two number inside Galois Field
32517
+ *
32518
+ * @param {Number} x
32519
+ * @param {Number} y
32520
+ * @return {Number}
32521
+ */
32522
+ galoisField.mul = function mul (x, y) {
32523
+ if (x === 0 || y === 0) return 0
32524
+
32525
+ // should be EXP_TABLE[(LOG_TABLE[x] + LOG_TABLE[y]) % 255] if EXP_TABLE wasn't oversized
32526
+ // @see {@link initTables}
32527
+ return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]]
32528
+ };
32529
+ return galoisField;
32530
+ }
32531
+
32532
+ var hasRequiredPolynomial;
32533
+
32534
+ function requirePolynomial () {
32535
+ if (hasRequiredPolynomial) return polynomial;
32536
+ hasRequiredPolynomial = 1;
32537
+ (function (exports) {
32538
+ const GF = requireGaloisField();
32539
+
32540
+ /**
32541
+ * Multiplies two polynomials inside Galois Field
32542
+ *
32543
+ * @param {Uint8Array} p1 Polynomial
32544
+ * @param {Uint8Array} p2 Polynomial
32545
+ * @return {Uint8Array} Product of p1 and p2
32546
+ */
32547
+ exports.mul = function mul (p1, p2) {
32548
+ const coeff = new Uint8Array(p1.length + p2.length - 1);
32549
+
32550
+ for (let i = 0; i < p1.length; i++) {
32551
+ for (let j = 0; j < p2.length; j++) {
32552
+ coeff[i + j] ^= GF.mul(p1[i], p2[j]);
32553
+ }
32554
+ }
32555
+
32556
+ return coeff
32557
+ };
32558
+
32559
+ /**
32560
+ * Calculate the remainder of polynomials division
32561
+ *
32562
+ * @param {Uint8Array} divident Polynomial
32563
+ * @param {Uint8Array} divisor Polynomial
32564
+ * @return {Uint8Array} Remainder
32565
+ */
32566
+ exports.mod = function mod (divident, divisor) {
32567
+ let result = new Uint8Array(divident);
32568
+
32569
+ while ((result.length - divisor.length) >= 0) {
32570
+ const coeff = result[0];
32571
+
32572
+ for (let i = 0; i < divisor.length; i++) {
32573
+ result[i] ^= GF.mul(divisor[i], coeff);
32574
+ }
32575
+
32576
+ // remove all zeros from buffer head
32577
+ let offset = 0;
32578
+ while (offset < result.length && result[offset] === 0) offset++;
32579
+ result = result.slice(offset);
32580
+ }
32581
+
32582
+ return result
32583
+ };
32584
+
32585
+ /**
32586
+ * Generate an irreducible generator polynomial of specified degree
32587
+ * (used by Reed-Solomon encoder)
32588
+ *
32589
+ * @param {Number} degree Degree of the generator polynomial
32590
+ * @return {Uint8Array} Buffer containing polynomial coefficients
32591
+ */
32592
+ exports.generateECPolynomial = function generateECPolynomial (degree) {
32593
+ let poly = new Uint8Array([1]);
32594
+ for (let i = 0; i < degree; i++) {
32595
+ poly = exports.mul(poly, new Uint8Array([1, GF.exp(i)]));
32596
+ }
32597
+
32598
+ return poly
32599
+ };
32600
+ } (polynomial));
32601
+ return polynomial;
32602
+ }
32603
+
32604
+ var reedSolomonEncoder;
32605
+ var hasRequiredReedSolomonEncoder;
32606
+
32607
+ function requireReedSolomonEncoder () {
32608
+ if (hasRequiredReedSolomonEncoder) return reedSolomonEncoder;
32609
+ hasRequiredReedSolomonEncoder = 1;
32610
+ const Polynomial = requirePolynomial();
32611
+
32612
+ function ReedSolomonEncoder (degree) {
32613
+ this.genPoly = undefined;
32614
+ this.degree = degree;
32615
+
32616
+ if (this.degree) this.initialize(this.degree);
32617
+ }
32618
+
32619
+ /**
32620
+ * Initialize the encoder.
32621
+ * The input param should correspond to the number of error correction codewords.
32622
+ *
32623
+ * @param {Number} degree
32624
+ */
32625
+ ReedSolomonEncoder.prototype.initialize = function initialize (degree) {
32626
+ // create an irreducible generator polynomial
32627
+ this.degree = degree;
32628
+ this.genPoly = Polynomial.generateECPolynomial(this.degree);
32629
+ };
32630
+
32631
+ /**
32632
+ * Encodes a chunk of data
32633
+ *
32634
+ * @param {Uint8Array} data Buffer containing input data
32635
+ * @return {Uint8Array} Buffer containing encoded data
32636
+ */
32637
+ ReedSolomonEncoder.prototype.encode = function encode (data) {
32638
+ if (!this.genPoly) {
32639
+ throw new Error('Encoder not initialized')
32640
+ }
32641
+
32642
+ // Calculate EC for this data block
32643
+ // extends data size to data+genPoly size
32644
+ const paddedData = new Uint8Array(data.length + this.degree);
32645
+ paddedData.set(data);
32646
+
32647
+ // The error correction codewords are the remainder after dividing the data codewords
32648
+ // by a generator polynomial
32649
+ const remainder = Polynomial.mod(paddedData, this.genPoly);
32650
+
32651
+ // return EC data blocks (last n byte, where n is the degree of genPoly)
32652
+ // If coefficients number in remainder are less than genPoly degree,
32653
+ // pad with 0s to the left to reach the needed number of coefficients
32654
+ const start = this.degree - remainder.length;
32655
+ if (start > 0) {
32656
+ const buff = new Uint8Array(this.degree);
32657
+ buff.set(remainder, start);
32658
+
32659
+ return buff
32660
+ }
32661
+
32662
+ return remainder
32663
+ };
32664
+
32665
+ reedSolomonEncoder = ReedSolomonEncoder;
32666
+ return reedSolomonEncoder;
32667
+ }
32668
+
32669
+ var version = {};
32670
+
32671
+ var mode = {};
32672
+
32673
+ var versionCheck = {};
32674
+
32675
+ /**
32676
+ * Check if QR Code version is valid
32677
+ *
32678
+ * @param {Number} version QR Code version
32679
+ * @return {Boolean} true if valid version, false otherwise
32680
+ */
32681
+
32682
+ var hasRequiredVersionCheck;
32683
+
32684
+ function requireVersionCheck () {
32685
+ if (hasRequiredVersionCheck) return versionCheck;
32686
+ hasRequiredVersionCheck = 1;
32687
+ versionCheck.isValid = function isValid (version) {
32688
+ return !isNaN(version) && version >= 1 && version <= 40
32689
+ };
32690
+ return versionCheck;
32691
+ }
32692
+
32693
+ var regex = {};
32694
+
32695
+ var hasRequiredRegex;
32696
+
32697
+ function requireRegex () {
32698
+ if (hasRequiredRegex) return regex;
32699
+ hasRequiredRegex = 1;
32700
+ const numeric = '[0-9]+';
32701
+ const alphanumeric = '[A-Z $%*+\\-./:]+';
32702
+ let kanji = '(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|' +
32703
+ '[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|' +
32704
+ '[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|' +
32705
+ '[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+';
32706
+ kanji = kanji.replace(/u/g, '\\u');
32707
+
32708
+ const byte = '(?:(?![A-Z0-9 $%*+\\-./:]|' + kanji + ')(?:.|[\r\n]))+';
32709
+
32710
+ regex.KANJI = new RegExp(kanji, 'g');
32711
+ regex.BYTE_KANJI = new RegExp('[^A-Z0-9 $%*+\\-./:]+', 'g');
32712
+ regex.BYTE = new RegExp(byte, 'g');
32713
+ regex.NUMERIC = new RegExp(numeric, 'g');
32714
+ regex.ALPHANUMERIC = new RegExp(alphanumeric, 'g');
32715
+
32716
+ const TEST_KANJI = new RegExp('^' + kanji + '$');
32717
+ const TEST_NUMERIC = new RegExp('^' + numeric + '$');
32718
+ const TEST_ALPHANUMERIC = new RegExp('^[A-Z0-9 $%*+\\-./:]+$');
32719
+
32720
+ regex.testKanji = function testKanji (str) {
32721
+ return TEST_KANJI.test(str)
32722
+ };
32723
+
32724
+ regex.testNumeric = function testNumeric (str) {
32725
+ return TEST_NUMERIC.test(str)
32726
+ };
32727
+
32728
+ regex.testAlphanumeric = function testAlphanumeric (str) {
32729
+ return TEST_ALPHANUMERIC.test(str)
32730
+ };
32731
+ return regex;
32732
+ }
32733
+
32734
+ var hasRequiredMode;
32735
+
32736
+ function requireMode () {
32737
+ if (hasRequiredMode) return mode;
32738
+ hasRequiredMode = 1;
32739
+ (function (exports) {
32740
+ const VersionCheck = requireVersionCheck();
32741
+ const Regex = requireRegex();
32742
+
32743
+ /**
32744
+ * Numeric mode encodes data from the decimal digit set (0 - 9)
32745
+ * (byte values 30HEX to 39HEX).
32746
+ * Normally, 3 data characters are represented by 10 bits.
32747
+ *
32748
+ * @type {Object}
32749
+ */
32750
+ exports.NUMERIC = {
32751
+ id: 'Numeric',
32752
+ bit: 1 << 0,
32753
+ ccBits: [10, 12, 14]
32754
+ };
32755
+
32756
+ /**
32757
+ * Alphanumeric mode encodes data from a set of 45 characters,
32758
+ * i.e. 10 numeric digits (0 - 9),
32759
+ * 26 alphabetic characters (A - Z),
32760
+ * and 9 symbols (SP, $, %, *, +, -, ., /, :).
32761
+ * Normally, two input characters are represented by 11 bits.
32762
+ *
32763
+ * @type {Object}
32764
+ */
32765
+ exports.ALPHANUMERIC = {
32766
+ id: 'Alphanumeric',
32767
+ bit: 1 << 1,
32768
+ ccBits: [9, 11, 13]
32769
+ };
32770
+
32771
+ /**
32772
+ * In byte mode, data is encoded at 8 bits per character.
32773
+ *
32774
+ * @type {Object}
32775
+ */
32776
+ exports.BYTE = {
32777
+ id: 'Byte',
32778
+ bit: 1 << 2,
32779
+ ccBits: [8, 16, 16]
32780
+ };
32781
+
32782
+ /**
32783
+ * The Kanji mode efficiently encodes Kanji characters in accordance with
32784
+ * the Shift JIS system based on JIS X 0208.
32785
+ * The Shift JIS values are shifted from the JIS X 0208 values.
32786
+ * JIS X 0208 gives details of the shift coded representation.
32787
+ * Each two-byte character value is compacted to a 13-bit binary codeword.
32788
+ *
32789
+ * @type {Object}
32790
+ */
32791
+ exports.KANJI = {
32792
+ id: 'Kanji',
32793
+ bit: 1 << 3,
32794
+ ccBits: [8, 10, 12]
32795
+ };
32796
+
32797
+ /**
32798
+ * Mixed mode will contain a sequences of data in a combination of any of
32799
+ * the modes described above
32800
+ *
32801
+ * @type {Object}
32802
+ */
32803
+ exports.MIXED = {
32804
+ bit: -1
32805
+ };
32806
+
32807
+ /**
32808
+ * Returns the number of bits needed to store the data length
32809
+ * according to QR Code specifications.
32810
+ *
32811
+ * @param {Mode} mode Data mode
32812
+ * @param {Number} version QR Code version
32813
+ * @return {Number} Number of bits
32814
+ */
32815
+ exports.getCharCountIndicator = function getCharCountIndicator (mode, version) {
32816
+ if (!mode.ccBits) throw new Error('Invalid mode: ' + mode)
32817
+
32818
+ if (!VersionCheck.isValid(version)) {
32819
+ throw new Error('Invalid version: ' + version)
32820
+ }
32821
+
32822
+ if (version >= 1 && version < 10) return mode.ccBits[0]
32823
+ else if (version < 27) return mode.ccBits[1]
32824
+ return mode.ccBits[2]
32825
+ };
32826
+
32827
+ /**
32828
+ * Returns the most efficient mode to store the specified data
32829
+ *
32830
+ * @param {String} dataStr Input data string
32831
+ * @return {Mode} Best mode
32832
+ */
32833
+ exports.getBestModeForData = function getBestModeForData (dataStr) {
32834
+ if (Regex.testNumeric(dataStr)) return exports.NUMERIC
32835
+ else if (Regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC
32836
+ else if (Regex.testKanji(dataStr)) return exports.KANJI
32837
+ else return exports.BYTE
32838
+ };
32839
+
32840
+ /**
32841
+ * Return mode name as string
32842
+ *
32843
+ * @param {Mode} mode Mode object
32844
+ * @returns {String} Mode name
32845
+ */
32846
+ exports.toString = function toString (mode) {
32847
+ if (mode && mode.id) return mode.id
32848
+ throw new Error('Invalid mode')
32849
+ };
32850
+
32851
+ /**
32852
+ * Check if input param is a valid mode object
32853
+ *
32854
+ * @param {Mode} mode Mode object
32855
+ * @returns {Boolean} True if valid mode, false otherwise
32856
+ */
32857
+ exports.isValid = function isValid (mode) {
32858
+ return mode && mode.bit && mode.ccBits
32859
+ };
32860
+
32861
+ /**
32862
+ * Get mode object from its name
32863
+ *
32864
+ * @param {String} string Mode name
32865
+ * @returns {Mode} Mode object
32866
+ */
32867
+ function fromString (string) {
32868
+ if (typeof string !== 'string') {
32869
+ throw new Error('Param is not a string')
32870
+ }
32871
+
32872
+ const lcStr = string.toLowerCase();
32873
+
32874
+ switch (lcStr) {
32875
+ case 'numeric':
32876
+ return exports.NUMERIC
32877
+ case 'alphanumeric':
32878
+ return exports.ALPHANUMERIC
32879
+ case 'kanji':
32880
+ return exports.KANJI
32881
+ case 'byte':
32882
+ return exports.BYTE
32883
+ default:
32884
+ throw new Error('Unknown mode: ' + string)
32885
+ }
32886
+ }
32887
+
32888
+ /**
32889
+ * Returns mode from a value.
32890
+ * If value is not a valid mode, returns defaultValue
32891
+ *
32892
+ * @param {Mode|String} value Encoding mode
32893
+ * @param {Mode} defaultValue Fallback value
32894
+ * @return {Mode} Encoding mode
32895
+ */
32896
+ exports.from = function from (value, defaultValue) {
32897
+ if (exports.isValid(value)) {
32898
+ return value
32899
+ }
32900
+
32901
+ try {
32902
+ return fromString(value)
32903
+ } catch (e) {
32904
+ return defaultValue
32905
+ }
32906
+ };
32907
+ } (mode));
32908
+ return mode;
32909
+ }
32910
+
32911
+ var hasRequiredVersion;
32912
+
32913
+ function requireVersion () {
32914
+ if (hasRequiredVersion) return version;
32915
+ hasRequiredVersion = 1;
32916
+ (function (exports) {
32917
+ const Utils = requireUtils$1();
32918
+ const ECCode = requireErrorCorrectionCode();
32919
+ const ECLevel = requireErrorCorrectionLevel();
32920
+ const Mode = requireMode();
32921
+ const VersionCheck = requireVersionCheck();
32922
+
32923
+ // Generator polynomial used to encode version information
32924
+ const G18 = (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0);
32925
+ const G18_BCH = Utils.getBCHDigit(G18);
32926
+
32927
+ function getBestVersionForDataLength (mode, length, errorCorrectionLevel) {
32928
+ for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {
32929
+ if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) {
32930
+ return currentVersion
32931
+ }
32932
+ }
32933
+
32934
+ return undefined
32935
+ }
32936
+
32937
+ function getReservedBitsCount (mode, version) {
32938
+ // Character count indicator + mode indicator bits
32939
+ return Mode.getCharCountIndicator(mode, version) + 4
32940
+ }
32941
+
32942
+ function getTotalBitsFromDataArray (segments, version) {
32943
+ let totalBits = 0;
32944
+
32945
+ segments.forEach(function (data) {
32946
+ const reservedBits = getReservedBitsCount(data.mode, version);
32947
+ totalBits += reservedBits + data.getBitsLength();
32948
+ });
32949
+
32950
+ return totalBits
32951
+ }
32952
+
32953
+ function getBestVersionForMixedData (segments, errorCorrectionLevel) {
32954
+ for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {
32955
+ const length = getTotalBitsFromDataArray(segments, currentVersion);
32956
+ if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) {
32957
+ return currentVersion
32958
+ }
32959
+ }
32960
+
32961
+ return undefined
32962
+ }
32963
+
32964
+ /**
32965
+ * Returns version number from a value.
32966
+ * If value is not a valid version, returns defaultValue
32967
+ *
32968
+ * @param {Number|String} value QR Code version
32969
+ * @param {Number} defaultValue Fallback value
32970
+ * @return {Number} QR Code version number
32971
+ */
32972
+ exports.from = function from (value, defaultValue) {
32973
+ if (VersionCheck.isValid(value)) {
32974
+ return parseInt(value, 10)
32975
+ }
32976
+
32977
+ return defaultValue
32978
+ };
32979
+
32980
+ /**
32981
+ * Returns how much data can be stored with the specified QR code version
32982
+ * and error correction level
32983
+ *
32984
+ * @param {Number} version QR Code version (1-40)
32985
+ * @param {Number} errorCorrectionLevel Error correction level
32986
+ * @param {Mode} mode Data mode
32987
+ * @return {Number} Quantity of storable data
32988
+ */
32989
+ exports.getCapacity = function getCapacity (version, errorCorrectionLevel, mode) {
32990
+ if (!VersionCheck.isValid(version)) {
32991
+ throw new Error('Invalid QR Code version')
32992
+ }
32993
+
32994
+ // Use Byte mode as default
32995
+ if (typeof mode === 'undefined') mode = Mode.BYTE;
32996
+
32997
+ // Total codewords for this QR code version (Data + Error correction)
32998
+ const totalCodewords = Utils.getSymbolTotalCodewords(version);
32999
+
33000
+ // Total number of error correction codewords
33001
+ const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
33002
+
33003
+ // Total number of data codewords
33004
+ const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
33005
+
33006
+ if (mode === Mode.MIXED) return dataTotalCodewordsBits
33007
+
33008
+ const usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version);
33009
+
33010
+ // Return max number of storable codewords
33011
+ switch (mode) {
33012
+ case Mode.NUMERIC:
33013
+ return Math.floor((usableBits / 10) * 3)
33014
+
33015
+ case Mode.ALPHANUMERIC:
33016
+ return Math.floor((usableBits / 11) * 2)
33017
+
33018
+ case Mode.KANJI:
33019
+ return Math.floor(usableBits / 13)
33020
+
33021
+ case Mode.BYTE:
33022
+ default:
33023
+ return Math.floor(usableBits / 8)
33024
+ }
33025
+ };
33026
+
33027
+ /**
33028
+ * Returns the minimum version needed to contain the amount of data
33029
+ *
33030
+ * @param {Segment} data Segment of data
33031
+ * @param {Number} [errorCorrectionLevel=H] Error correction level
33032
+ * @param {Mode} mode Data mode
33033
+ * @return {Number} QR Code version
33034
+ */
33035
+ exports.getBestVersionForData = function getBestVersionForData (data, errorCorrectionLevel) {
33036
+ let seg;
33037
+
33038
+ const ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M);
33039
+
33040
+ if (Array.isArray(data)) {
33041
+ if (data.length > 1) {
33042
+ return getBestVersionForMixedData(data, ecl)
33043
+ }
33044
+
33045
+ if (data.length === 0) {
33046
+ return 1
33047
+ }
33048
+
33049
+ seg = data[0];
33050
+ } else {
33051
+ seg = data;
33052
+ }
33053
+
33054
+ return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl)
33055
+ };
33056
+
33057
+ /**
33058
+ * Returns version information with relative error correction bits
33059
+ *
33060
+ * The version information is included in QR Code symbols of version 7 or larger.
33061
+ * It consists of an 18-bit sequence containing 6 data bits,
33062
+ * with 12 error correction bits calculated using the (18, 6) Golay code.
33063
+ *
33064
+ * @param {Number} version QR Code version
33065
+ * @return {Number} Encoded version info bits
33066
+ */
33067
+ exports.getEncodedBits = function getEncodedBits (version) {
33068
+ if (!VersionCheck.isValid(version) || version < 7) {
33069
+ throw new Error('Invalid QR Code version')
33070
+ }
33071
+
33072
+ let d = version << 12;
33073
+
33074
+ while (Utils.getBCHDigit(d) - G18_BCH >= 0) {
33075
+ d ^= (G18 << (Utils.getBCHDigit(d) - G18_BCH));
33076
+ }
33077
+
33078
+ return (version << 12) | d
33079
+ };
33080
+ } (version));
33081
+ return version;
33082
+ }
33083
+
33084
+ var formatInfo = {};
33085
+
33086
+ var hasRequiredFormatInfo;
33087
+
33088
+ function requireFormatInfo () {
33089
+ if (hasRequiredFormatInfo) return formatInfo;
33090
+ hasRequiredFormatInfo = 1;
33091
+ const Utils = requireUtils$1();
33092
+
33093
+ const G15 = (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0);
33094
+ const G15_MASK = (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1);
33095
+ const G15_BCH = Utils.getBCHDigit(G15);
33096
+
33097
+ /**
33098
+ * Returns format information with relative error correction bits
33099
+ *
33100
+ * The format information is a 15-bit sequence containing 5 data bits,
33101
+ * with 10 error correction bits calculated using the (15, 5) BCH code.
33102
+ *
33103
+ * @param {Number} errorCorrectionLevel Error correction level
33104
+ * @param {Number} mask Mask pattern
33105
+ * @return {Number} Encoded format information bits
33106
+ */
33107
+ formatInfo.getEncodedBits = function getEncodedBits (errorCorrectionLevel, mask) {
33108
+ const data = ((errorCorrectionLevel.bit << 3) | mask);
33109
+ let d = data << 10;
33110
+
33111
+ while (Utils.getBCHDigit(d) - G15_BCH >= 0) {
33112
+ d ^= (G15 << (Utils.getBCHDigit(d) - G15_BCH));
33113
+ }
33114
+
33115
+ // xor final data with mask pattern in order to ensure that
33116
+ // no combination of Error Correction Level and data mask pattern
33117
+ // will result in an all-zero data string
33118
+ return ((data << 10) | d) ^ G15_MASK
33119
+ };
33120
+ return formatInfo;
33121
+ }
33122
+
33123
+ var segments = {};
33124
+
33125
+ var numericData;
33126
+ var hasRequiredNumericData;
33127
+
33128
+ function requireNumericData () {
33129
+ if (hasRequiredNumericData) return numericData;
33130
+ hasRequiredNumericData = 1;
33131
+ const Mode = requireMode();
33132
+
33133
+ function NumericData (data) {
33134
+ this.mode = Mode.NUMERIC;
33135
+ this.data = data.toString();
33136
+ }
33137
+
33138
+ NumericData.getBitsLength = function getBitsLength (length) {
33139
+ return 10 * Math.floor(length / 3) + ((length % 3) ? ((length % 3) * 3 + 1) : 0)
33140
+ };
33141
+
33142
+ NumericData.prototype.getLength = function getLength () {
33143
+ return this.data.length
33144
+ };
33145
+
33146
+ NumericData.prototype.getBitsLength = function getBitsLength () {
33147
+ return NumericData.getBitsLength(this.data.length)
33148
+ };
33149
+
33150
+ NumericData.prototype.write = function write (bitBuffer) {
33151
+ let i, group, value;
33152
+
33153
+ // The input data string is divided into groups of three digits,
33154
+ // and each group is converted to its 10-bit binary equivalent.
33155
+ for (i = 0; i + 3 <= this.data.length; i += 3) {
33156
+ group = this.data.substr(i, 3);
33157
+ value = parseInt(group, 10);
33158
+
33159
+ bitBuffer.put(value, 10);
33160
+ }
33161
+
33162
+ // If the number of input digits is not an exact multiple of three,
33163
+ // the final one or two digits are converted to 4 or 7 bits respectively.
33164
+ const remainingNum = this.data.length - i;
33165
+ if (remainingNum > 0) {
33166
+ group = this.data.substr(i);
33167
+ value = parseInt(group, 10);
33168
+
33169
+ bitBuffer.put(value, remainingNum * 3 + 1);
33170
+ }
33171
+ };
33172
+
33173
+ numericData = NumericData;
33174
+ return numericData;
33175
+ }
33176
+
33177
+ var alphanumericData;
33178
+ var hasRequiredAlphanumericData;
33179
+
33180
+ function requireAlphanumericData () {
33181
+ if (hasRequiredAlphanumericData) return alphanumericData;
33182
+ hasRequiredAlphanumericData = 1;
33183
+ const Mode = requireMode();
33184
+
33185
+ /**
33186
+ * Array of characters available in alphanumeric mode
33187
+ *
33188
+ * As per QR Code specification, to each character
33189
+ * is assigned a value from 0 to 44 which in this case coincides
33190
+ * with the array index
33191
+ *
33192
+ * @type {Array}
33193
+ */
33194
+ const ALPHA_NUM_CHARS = [
33195
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
33196
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
33197
+ 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
33198
+ ' ', '$', '%', '*', '+', '-', '.', '/', ':'
33199
+ ];
33200
+
33201
+ function AlphanumericData (data) {
33202
+ this.mode = Mode.ALPHANUMERIC;
33203
+ this.data = data;
33204
+ }
33205
+
33206
+ AlphanumericData.getBitsLength = function getBitsLength (length) {
33207
+ return 11 * Math.floor(length / 2) + 6 * (length % 2)
33208
+ };
33209
+
33210
+ AlphanumericData.prototype.getLength = function getLength () {
33211
+ return this.data.length
33212
+ };
33213
+
33214
+ AlphanumericData.prototype.getBitsLength = function getBitsLength () {
33215
+ return AlphanumericData.getBitsLength(this.data.length)
33216
+ };
33217
+
33218
+ AlphanumericData.prototype.write = function write (bitBuffer) {
33219
+ let i;
33220
+
33221
+ // Input data characters are divided into groups of two characters
33222
+ // and encoded as 11-bit binary codes.
33223
+ for (i = 0; i + 2 <= this.data.length; i += 2) {
33224
+ // The character value of the first character is multiplied by 45
33225
+ let value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45;
33226
+
33227
+ // The character value of the second digit is added to the product
33228
+ value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1]);
33229
+
33230
+ // The sum is then stored as 11-bit binary number
33231
+ bitBuffer.put(value, 11);
33232
+ }
33233
+
33234
+ // If the number of input data characters is not a multiple of two,
33235
+ // the character value of the final character is encoded as a 6-bit binary number.
33236
+ if (this.data.length % 2) {
33237
+ bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6);
33238
+ }
33239
+ };
33240
+
33241
+ alphanumericData = AlphanumericData;
33242
+ return alphanumericData;
33243
+ }
33244
+
33245
+ var byteData;
33246
+ var hasRequiredByteData;
33247
+
33248
+ function requireByteData () {
33249
+ if (hasRequiredByteData) return byteData;
33250
+ hasRequiredByteData = 1;
33251
+ const Mode = requireMode();
33252
+
33253
+ function ByteData (data) {
33254
+ this.mode = Mode.BYTE;
33255
+ if (typeof (data) === 'string') {
33256
+ this.data = new TextEncoder().encode(data);
33257
+ } else {
33258
+ this.data = new Uint8Array(data);
33259
+ }
33260
+ }
33261
+
33262
+ ByteData.getBitsLength = function getBitsLength (length) {
33263
+ return length * 8
33264
+ };
33265
+
33266
+ ByteData.prototype.getLength = function getLength () {
33267
+ return this.data.length
33268
+ };
33269
+
33270
+ ByteData.prototype.getBitsLength = function getBitsLength () {
33271
+ return ByteData.getBitsLength(this.data.length)
33272
+ };
33273
+
33274
+ ByteData.prototype.write = function (bitBuffer) {
33275
+ for (let i = 0, l = this.data.length; i < l; i++) {
33276
+ bitBuffer.put(this.data[i], 8);
33277
+ }
33278
+ };
33279
+
33280
+ byteData = ByteData;
33281
+ return byteData;
33282
+ }
33283
+
33284
+ var kanjiData;
33285
+ var hasRequiredKanjiData;
33286
+
33287
+ function requireKanjiData () {
33288
+ if (hasRequiredKanjiData) return kanjiData;
33289
+ hasRequiredKanjiData = 1;
33290
+ const Mode = requireMode();
33291
+ const Utils = requireUtils$1();
33292
+
33293
+ function KanjiData (data) {
33294
+ this.mode = Mode.KANJI;
33295
+ this.data = data;
33296
+ }
33297
+
33298
+ KanjiData.getBitsLength = function getBitsLength (length) {
33299
+ return length * 13
33300
+ };
33301
+
33302
+ KanjiData.prototype.getLength = function getLength () {
33303
+ return this.data.length
33304
+ };
33305
+
33306
+ KanjiData.prototype.getBitsLength = function getBitsLength () {
33307
+ return KanjiData.getBitsLength(this.data.length)
33308
+ };
33309
+
33310
+ KanjiData.prototype.write = function (bitBuffer) {
33311
+ let i;
33312
+
33313
+ // In the Shift JIS system, Kanji characters are represented by a two byte combination.
33314
+ // These byte values are shifted from the JIS X 0208 values.
33315
+ // JIS X 0208 gives details of the shift coded representation.
33316
+ for (i = 0; i < this.data.length; i++) {
33317
+ let value = Utils.toSJIS(this.data[i]);
33318
+
33319
+ // For characters with Shift JIS values from 0x8140 to 0x9FFC:
33320
+ if (value >= 0x8140 && value <= 0x9FFC) {
33321
+ // Subtract 0x8140 from Shift JIS value
33322
+ value -= 0x8140;
33323
+
33324
+ // For characters with Shift JIS values from 0xE040 to 0xEBBF
33325
+ } else if (value >= 0xE040 && value <= 0xEBBF) {
33326
+ // Subtract 0xC140 from Shift JIS value
33327
+ value -= 0xC140;
33328
+ } else {
33329
+ throw new Error(
33330
+ 'Invalid SJIS character: ' + this.data[i] + '\n' +
33331
+ 'Make sure your charset is UTF-8')
33332
+ }
33333
+
33334
+ // Multiply most significant byte of result by 0xC0
33335
+ // and add least significant byte to product
33336
+ value = (((value >>> 8) & 0xff) * 0xC0) + (value & 0xff);
33337
+
33338
+ // Convert result to a 13-bit binary string
33339
+ bitBuffer.put(value, 13);
33340
+ }
33341
+ };
33342
+
33343
+ kanjiData = KanjiData;
33344
+ return kanjiData;
33345
+ }
33346
+
33347
+ var dijkstra = {exports: {}};
33348
+
33349
+ var hasRequiredDijkstra;
33350
+
33351
+ function requireDijkstra () {
33352
+ if (hasRequiredDijkstra) return dijkstra.exports;
33353
+ hasRequiredDijkstra = 1;
33354
+ (function (module) {
33355
+
33356
+ /******************************************************************************
33357
+ * Created 2008-08-19.
33358
+ *
33359
+ * Dijkstra path-finding functions. Adapted from the Dijkstar Python project.
33360
+ *
33361
+ * Copyright (C) 2008
33362
+ * Wyatt Baldwin <self@wyattbaldwin.com>
33363
+ * All rights reserved
33364
+ *
33365
+ * Licensed under the MIT license.
33366
+ *
33367
+ * http://www.opensource.org/licenses/mit-license.php
33368
+ *
33369
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33370
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33371
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33372
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33373
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33374
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
33375
+ * THE SOFTWARE.
33376
+ *****************************************************************************/
33377
+ var dijkstra = {
33378
+ single_source_shortest_paths: function(graph, s, d) {
33379
+ // Predecessor map for each node that has been encountered.
33380
+ // node ID => predecessor node ID
33381
+ var predecessors = {};
33382
+
33383
+ // Costs of shortest paths from s to all nodes encountered.
33384
+ // node ID => cost
33385
+ var costs = {};
33386
+ costs[s] = 0;
33387
+
33388
+ // Costs of shortest paths from s to all nodes encountered; differs from
33389
+ // `costs` in that it provides easy access to the node that currently has
33390
+ // the known shortest path from s.
33391
+ // XXX: Do we actually need both `costs` and `open`?
33392
+ var open = dijkstra.PriorityQueue.make();
33393
+ open.push(s, 0);
33394
+
33395
+ var closest,
33396
+ u, v,
33397
+ cost_of_s_to_u,
33398
+ adjacent_nodes,
33399
+ cost_of_e,
33400
+ cost_of_s_to_u_plus_cost_of_e,
33401
+ cost_of_s_to_v,
33402
+ first_visit;
33403
+ while (!open.empty()) {
33404
+ // In the nodes remaining in graph that have a known cost from s,
33405
+ // find the node, u, that currently has the shortest path from s.
33406
+ closest = open.pop();
33407
+ u = closest.value;
33408
+ cost_of_s_to_u = closest.cost;
33409
+
33410
+ // Get nodes adjacent to u...
33411
+ adjacent_nodes = graph[u] || {};
33412
+
33413
+ // ...and explore the edges that connect u to those nodes, updating
33414
+ // the cost of the shortest paths to any or all of those nodes as
33415
+ // necessary. v is the node across the current edge from u.
33416
+ for (v in adjacent_nodes) {
33417
+ if (adjacent_nodes.hasOwnProperty(v)) {
33418
+ // Get the cost of the edge running from u to v.
33419
+ cost_of_e = adjacent_nodes[v];
33420
+
33421
+ // Cost of s to u plus the cost of u to v across e--this is *a*
33422
+ // cost from s to v that may or may not be less than the current
33423
+ // known cost to v.
33424
+ cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;
33425
+
33426
+ // If we haven't visited v yet OR if the current known cost from s to
33427
+ // v is greater than the new cost we just found (cost of s to u plus
33428
+ // cost of u to v across e), update v's cost in the cost list and
33429
+ // update v's predecessor in the predecessor list (it's now u).
33430
+ cost_of_s_to_v = costs[v];
33431
+ first_visit = (typeof costs[v] === 'undefined');
33432
+ if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {
33433
+ costs[v] = cost_of_s_to_u_plus_cost_of_e;
33434
+ open.push(v, cost_of_s_to_u_plus_cost_of_e);
33435
+ predecessors[v] = u;
33436
+ }
33437
+ }
33438
+ }
33439
+ }
33440
+
33441
+ if (typeof d !== 'undefined' && typeof costs[d] === 'undefined') {
33442
+ var msg = ['Could not find a path from ', s, ' to ', d, '.'].join('');
33443
+ throw new Error(msg);
33444
+ }
33445
+
33446
+ return predecessors;
33447
+ },
33448
+
33449
+ extract_shortest_path_from_predecessor_list: function(predecessors, d) {
33450
+ var nodes = [];
33451
+ var u = d;
33452
+ while (u) {
33453
+ nodes.push(u);
33454
+ u = predecessors[u];
33455
+ }
33456
+ nodes.reverse();
33457
+ return nodes;
33458
+ },
33459
+
33460
+ find_path: function(graph, s, d) {
33461
+ var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
33462
+ return dijkstra.extract_shortest_path_from_predecessor_list(
33463
+ predecessors, d);
33464
+ },
33465
+
33466
+ /**
33467
+ * A very naive priority queue implementation.
33468
+ */
33469
+ PriorityQueue: {
33470
+ make: function (opts) {
33471
+ var T = dijkstra.PriorityQueue,
33472
+ t = {},
33473
+ key;
33474
+ opts = opts || {};
33475
+ for (key in T) {
33476
+ if (T.hasOwnProperty(key)) {
33477
+ t[key] = T[key];
33478
+ }
33479
+ }
33480
+ t.queue = [];
33481
+ t.sorter = opts.sorter || T.default_sorter;
33482
+ return t;
33483
+ },
33484
+
33485
+ default_sorter: function (a, b) {
33486
+ return a.cost - b.cost;
33487
+ },
33488
+
33489
+ /**
33490
+ * Add a new item to the queue and ensure the highest priority element
33491
+ * is at the front of the queue.
33492
+ */
33493
+ push: function (value, cost) {
33494
+ var item = {value: value, cost: cost};
33495
+ this.queue.push(item);
33496
+ this.queue.sort(this.sorter);
33497
+ },
33498
+
33499
+ /**
33500
+ * Return the highest priority element in the queue.
33501
+ */
33502
+ pop: function () {
33503
+ return this.queue.shift();
33504
+ },
33505
+
33506
+ empty: function () {
33507
+ return this.queue.length === 0;
33508
+ }
33509
+ }
33510
+ };
33511
+
33512
+
33513
+ // node.js module exports
33514
+ {
33515
+ module.exports = dijkstra;
33516
+ }
33517
+ } (dijkstra));
33518
+ return dijkstra.exports;
33519
+ }
33520
+
33521
+ var hasRequiredSegments;
33522
+
33523
+ function requireSegments () {
33524
+ if (hasRequiredSegments) return segments;
33525
+ hasRequiredSegments = 1;
33526
+ (function (exports) {
33527
+ const Mode = requireMode();
33528
+ const NumericData = requireNumericData();
33529
+ const AlphanumericData = requireAlphanumericData();
33530
+ const ByteData = requireByteData();
33531
+ const KanjiData = requireKanjiData();
33532
+ const Regex = requireRegex();
33533
+ const Utils = requireUtils$1();
33534
+ const dijkstra = requireDijkstra();
33535
+
33536
+ /**
33537
+ * Returns UTF8 byte length
33538
+ *
33539
+ * @param {String} str Input string
33540
+ * @return {Number} Number of byte
33541
+ */
33542
+ function getStringByteLength (str) {
33543
+ return unescape(encodeURIComponent(str)).length
33544
+ }
33545
+
33546
+ /**
33547
+ * Get a list of segments of the specified mode
33548
+ * from a string
33549
+ *
33550
+ * @param {Mode} mode Segment mode
33551
+ * @param {String} str String to process
33552
+ * @return {Array} Array of object with segments data
33553
+ */
33554
+ function getSegments (regex, mode, str) {
33555
+ const segments = [];
33556
+ let result;
33557
+
33558
+ while ((result = regex.exec(str)) !== null) {
33559
+ segments.push({
33560
+ data: result[0],
33561
+ index: result.index,
33562
+ mode: mode,
33563
+ length: result[0].length
33564
+ });
33565
+ }
33566
+
33567
+ return segments
33568
+ }
33569
+
33570
+ /**
33571
+ * Extracts a series of segments with the appropriate
33572
+ * modes from a string
33573
+ *
33574
+ * @param {String} dataStr Input string
33575
+ * @return {Array} Array of object with segments data
33576
+ */
33577
+ function getSegmentsFromString (dataStr) {
33578
+ const numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr);
33579
+ const alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr);
33580
+ let byteSegs;
33581
+ let kanjiSegs;
33582
+
33583
+ if (Utils.isKanjiModeEnabled()) {
33584
+ byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr);
33585
+ kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr);
33586
+ } else {
33587
+ byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr);
33588
+ kanjiSegs = [];
33589
+ }
33590
+
33591
+ const segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs);
33592
+
33593
+ return segs
33594
+ .sort(function (s1, s2) {
33595
+ return s1.index - s2.index
33596
+ })
33597
+ .map(function (obj) {
33598
+ return {
33599
+ data: obj.data,
33600
+ mode: obj.mode,
33601
+ length: obj.length
33602
+ }
33603
+ })
33604
+ }
33605
+
33606
+ /**
33607
+ * Returns how many bits are needed to encode a string of
33608
+ * specified length with the specified mode
33609
+ *
33610
+ * @param {Number} length String length
33611
+ * @param {Mode} mode Segment mode
33612
+ * @return {Number} Bit length
33613
+ */
33614
+ function getSegmentBitsLength (length, mode) {
33615
+ switch (mode) {
33616
+ case Mode.NUMERIC:
33617
+ return NumericData.getBitsLength(length)
33618
+ case Mode.ALPHANUMERIC:
33619
+ return AlphanumericData.getBitsLength(length)
33620
+ case Mode.KANJI:
33621
+ return KanjiData.getBitsLength(length)
33622
+ case Mode.BYTE:
33623
+ return ByteData.getBitsLength(length)
33624
+ }
33625
+ }
33626
+
33627
+ /**
33628
+ * Merges adjacent segments which have the same mode
33629
+ *
33630
+ * @param {Array} segs Array of object with segments data
33631
+ * @return {Array} Array of object with segments data
33632
+ */
33633
+ function mergeSegments (segs) {
33634
+ return segs.reduce(function (acc, curr) {
33635
+ const prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null;
33636
+ if (prevSeg && prevSeg.mode === curr.mode) {
33637
+ acc[acc.length - 1].data += curr.data;
33638
+ return acc
33639
+ }
33640
+
33641
+ acc.push(curr);
33642
+ return acc
33643
+ }, [])
33644
+ }
33645
+
33646
+ /**
33647
+ * Generates a list of all possible nodes combination which
33648
+ * will be used to build a segments graph.
33649
+ *
33650
+ * Nodes are divided by groups. Each group will contain a list of all the modes
33651
+ * in which is possible to encode the given text.
33652
+ *
33653
+ * For example the text '12345' can be encoded as Numeric, Alphanumeric or Byte.
33654
+ * The group for '12345' will contain then 3 objects, one for each
33655
+ * possible encoding mode.
33656
+ *
33657
+ * Each node represents a possible segment.
33658
+ *
33659
+ * @param {Array} segs Array of object with segments data
33660
+ * @return {Array} Array of object with segments data
33661
+ */
33662
+ function buildNodes (segs) {
33663
+ const nodes = [];
33664
+ for (let i = 0; i < segs.length; i++) {
33665
+ const seg = segs[i];
33666
+
33667
+ switch (seg.mode) {
33668
+ case Mode.NUMERIC:
33669
+ nodes.push([seg,
33670
+ { data: seg.data, mode: Mode.ALPHANUMERIC, length: seg.length },
33671
+ { data: seg.data, mode: Mode.BYTE, length: seg.length }
33672
+ ]);
33673
+ break
33674
+ case Mode.ALPHANUMERIC:
33675
+ nodes.push([seg,
33676
+ { data: seg.data, mode: Mode.BYTE, length: seg.length }
33677
+ ]);
33678
+ break
33679
+ case Mode.KANJI:
33680
+ nodes.push([seg,
33681
+ { data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
33682
+ ]);
33683
+ break
33684
+ case Mode.BYTE:
33685
+ nodes.push([
33686
+ { data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
33687
+ ]);
33688
+ }
33689
+ }
33690
+
33691
+ return nodes
33692
+ }
33693
+
33694
+ /**
33695
+ * Builds a graph from a list of nodes.
33696
+ * All segments in each node group will be connected with all the segments of
33697
+ * the next group and so on.
33698
+ *
33699
+ * At each connection will be assigned a weight depending on the
33700
+ * segment's byte length.
33701
+ *
33702
+ * @param {Array} nodes Array of object with segments data
33703
+ * @param {Number} version QR Code version
33704
+ * @return {Object} Graph of all possible segments
33705
+ */
33706
+ function buildGraph (nodes, version) {
33707
+ const table = {};
33708
+ const graph = { start: {} };
33709
+ let prevNodeIds = ['start'];
33710
+
33711
+ for (let i = 0; i < nodes.length; i++) {
33712
+ const nodeGroup = nodes[i];
33713
+ const currentNodeIds = [];
33714
+
33715
+ for (let j = 0; j < nodeGroup.length; j++) {
33716
+ const node = nodeGroup[j];
33717
+ const key = '' + i + j;
33718
+
33719
+ currentNodeIds.push(key);
33720
+ table[key] = { node: node, lastCount: 0 };
33721
+ graph[key] = {};
33722
+
33723
+ for (let n = 0; n < prevNodeIds.length; n++) {
33724
+ const prevNodeId = prevNodeIds[n];
33725
+
33726
+ if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {
33727
+ graph[prevNodeId][key] =
33728
+ getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) -
33729
+ getSegmentBitsLength(table[prevNodeId].lastCount, node.mode);
33730
+
33731
+ table[prevNodeId].lastCount += node.length;
33732
+ } else {
33733
+ if (table[prevNodeId]) table[prevNodeId].lastCount = node.length;
33734
+
33735
+ graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) +
33736
+ 4 + Mode.getCharCountIndicator(node.mode, version); // switch cost
33737
+ }
33738
+ }
33739
+ }
33740
+
33741
+ prevNodeIds = currentNodeIds;
33742
+ }
33743
+
33744
+ for (let n = 0; n < prevNodeIds.length; n++) {
33745
+ graph[prevNodeIds[n]].end = 0;
33746
+ }
33747
+
33748
+ return { map: graph, table: table }
33749
+ }
33750
+
33751
+ /**
33752
+ * Builds a segment from a specified data and mode.
33753
+ * If a mode is not specified, the more suitable will be used.
33754
+ *
33755
+ * @param {String} data Input data
33756
+ * @param {Mode | String} modesHint Data mode
33757
+ * @return {Segment} Segment
33758
+ */
33759
+ function buildSingleSegment (data, modesHint) {
33760
+ let mode;
33761
+ const bestMode = Mode.getBestModeForData(data);
33762
+
33763
+ mode = Mode.from(modesHint, bestMode);
33764
+
33765
+ // Make sure data can be encoded
33766
+ if (mode !== Mode.BYTE && mode.bit < bestMode.bit) {
33767
+ throw new Error('"' + data + '"' +
33768
+ ' cannot be encoded with mode ' + Mode.toString(mode) +
33769
+ '.\n Suggested mode is: ' + Mode.toString(bestMode))
33770
+ }
33771
+
33772
+ // Use Mode.BYTE if Kanji support is disabled
33773
+ if (mode === Mode.KANJI && !Utils.isKanjiModeEnabled()) {
33774
+ mode = Mode.BYTE;
33775
+ }
33776
+
33777
+ switch (mode) {
33778
+ case Mode.NUMERIC:
33779
+ return new NumericData(data)
33780
+
33781
+ case Mode.ALPHANUMERIC:
33782
+ return new AlphanumericData(data)
33783
+
33784
+ case Mode.KANJI:
33785
+ return new KanjiData(data)
33786
+
33787
+ case Mode.BYTE:
33788
+ return new ByteData(data)
33789
+ }
33790
+ }
33791
+
33792
+ /**
33793
+ * Builds a list of segments from an array.
33794
+ * Array can contain Strings or Objects with segment's info.
33795
+ *
33796
+ * For each item which is a string, will be generated a segment with the given
33797
+ * string and the more appropriate encoding mode.
33798
+ *
33799
+ * For each item which is an object, will be generated a segment with the given
33800
+ * data and mode.
33801
+ * Objects must contain at least the property "data".
33802
+ * If property "mode" is not present, the more suitable mode will be used.
33803
+ *
33804
+ * @param {Array} array Array of objects with segments data
33805
+ * @return {Array} Array of Segments
33806
+ */
33807
+ exports.fromArray = function fromArray (array) {
33808
+ return array.reduce(function (acc, seg) {
33809
+ if (typeof seg === 'string') {
33810
+ acc.push(buildSingleSegment(seg, null));
33811
+ } else if (seg.data) {
33812
+ acc.push(buildSingleSegment(seg.data, seg.mode));
33813
+ }
33814
+
33815
+ return acc
33816
+ }, [])
33817
+ };
33818
+
33819
+ /**
33820
+ * Builds an optimized sequence of segments from a string,
33821
+ * which will produce the shortest possible bitstream.
33822
+ *
33823
+ * @param {String} data Input string
33824
+ * @param {Number} version QR Code version
33825
+ * @return {Array} Array of segments
33826
+ */
33827
+ exports.fromString = function fromString (data, version) {
33828
+ const segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled());
33829
+
33830
+ const nodes = buildNodes(segs);
33831
+ const graph = buildGraph(nodes, version);
33832
+ const path = dijkstra.find_path(graph.map, 'start', 'end');
33833
+
33834
+ const optimizedSegs = [];
33835
+ for (let i = 1; i < path.length - 1; i++) {
33836
+ optimizedSegs.push(graph.table[path[i]].node);
33837
+ }
33838
+
33839
+ return exports.fromArray(mergeSegments(optimizedSegs))
33840
+ };
33841
+
33842
+ /**
33843
+ * Splits a string in various segments with the modes which
33844
+ * best represent their content.
33845
+ * The produced segments are far from being optimized.
33846
+ * The output of this function is only used to estimate a QR Code version
33847
+ * which may contain the data.
33848
+ *
33849
+ * @param {string} data Input string
33850
+ * @return {Array} Array of segments
33851
+ */
33852
+ exports.rawSplit = function rawSplit (data) {
33853
+ return exports.fromArray(
33854
+ getSegmentsFromString(data, Utils.isKanjiModeEnabled())
33855
+ )
33856
+ };
33857
+ } (segments));
33858
+ return segments;
33859
+ }
33860
+
33861
+ var hasRequiredQrcode;
33862
+
33863
+ function requireQrcode () {
33864
+ if (hasRequiredQrcode) return qrcode;
33865
+ hasRequiredQrcode = 1;
33866
+ const Utils = requireUtils$1();
33867
+ const ECLevel = requireErrorCorrectionLevel();
33868
+ const BitBuffer = requireBitBuffer();
33869
+ const BitMatrix = requireBitMatrix();
33870
+ const AlignmentPattern = requireAlignmentPattern();
33871
+ const FinderPattern = requireFinderPattern();
33872
+ const MaskPattern = requireMaskPattern();
33873
+ const ECCode = requireErrorCorrectionCode();
33874
+ const ReedSolomonEncoder = requireReedSolomonEncoder();
33875
+ const Version = requireVersion();
33876
+ const FormatInfo = requireFormatInfo();
33877
+ const Mode = requireMode();
33878
+ const Segments = requireSegments();
33879
+
33880
+ /**
33881
+ * QRCode for JavaScript
33882
+ *
33883
+ * modified by Ryan Day for nodejs support
33884
+ * Copyright (c) 2011 Ryan Day
33885
+ *
33886
+ * Licensed under the MIT license:
33887
+ * http://www.opensource.org/licenses/mit-license.php
33888
+ *
33889
+ //---------------------------------------------------------------------
33890
+ // QRCode for JavaScript
33891
+ //
33892
+ // Copyright (c) 2009 Kazuhiko Arase
33893
+ //
33894
+ // URL: http://www.d-project.com/
33895
+ //
33896
+ // Licensed under the MIT license:
33897
+ // http://www.opensource.org/licenses/mit-license.php
33898
+ //
33899
+ // The word "QR Code" is registered trademark of
33900
+ // DENSO WAVE INCORPORATED
33901
+ // http://www.denso-wave.com/qrcode/faqpatent-e.html
33902
+ //
33903
+ //---------------------------------------------------------------------
33904
+ */
33905
+
33906
+ /**
33907
+ * Add finder patterns bits to matrix
33908
+ *
33909
+ * @param {BitMatrix} matrix Modules matrix
33910
+ * @param {Number} version QR Code version
33911
+ */
33912
+ function setupFinderPattern (matrix, version) {
33913
+ const size = matrix.size;
33914
+ const pos = FinderPattern.getPositions(version);
33915
+
33916
+ for (let i = 0; i < pos.length; i++) {
33917
+ const row = pos[i][0];
33918
+ const col = pos[i][1];
33919
+
33920
+ for (let r = -1; r <= 7; r++) {
33921
+ if (row + r <= -1 || size <= row + r) continue
33922
+
33923
+ for (let c = -1; c <= 7; c++) {
33924
+ if (col + c <= -1 || size <= col + c) continue
33925
+
33926
+ if ((r >= 0 && r <= 6 && (c === 0 || c === 6)) ||
33927
+ (c >= 0 && c <= 6 && (r === 0 || r === 6)) ||
33928
+ (r >= 2 && r <= 4 && c >= 2 && c <= 4)) {
33929
+ matrix.set(row + r, col + c, true, true);
33930
+ } else {
33931
+ matrix.set(row + r, col + c, false, true);
33932
+ }
33933
+ }
33934
+ }
33935
+ }
33936
+ }
33937
+
33938
+ /**
33939
+ * Add timing pattern bits to matrix
33940
+ *
33941
+ * Note: this function must be called before {@link setupAlignmentPattern}
33942
+ *
33943
+ * @param {BitMatrix} matrix Modules matrix
33944
+ */
33945
+ function setupTimingPattern (matrix) {
33946
+ const size = matrix.size;
33947
+
33948
+ for (let r = 8; r < size - 8; r++) {
33949
+ const value = r % 2 === 0;
33950
+ matrix.set(r, 6, value, true);
33951
+ matrix.set(6, r, value, true);
33952
+ }
33953
+ }
33954
+
33955
+ /**
33956
+ * Add alignment patterns bits to matrix
33957
+ *
33958
+ * Note: this function must be called after {@link setupTimingPattern}
33959
+ *
33960
+ * @param {BitMatrix} matrix Modules matrix
33961
+ * @param {Number} version QR Code version
33962
+ */
33963
+ function setupAlignmentPattern (matrix, version) {
33964
+ const pos = AlignmentPattern.getPositions(version);
33965
+
33966
+ for (let i = 0; i < pos.length; i++) {
33967
+ const row = pos[i][0];
33968
+ const col = pos[i][1];
33969
+
33970
+ for (let r = -2; r <= 2; r++) {
33971
+ for (let c = -2; c <= 2; c++) {
33972
+ if (r === -2 || r === 2 || c === -2 || c === 2 ||
33973
+ (r === 0 && c === 0)) {
33974
+ matrix.set(row + r, col + c, true, true);
33975
+ } else {
33976
+ matrix.set(row + r, col + c, false, true);
33977
+ }
33978
+ }
33979
+ }
33980
+ }
33981
+ }
33982
+
33983
+ /**
33984
+ * Add version info bits to matrix
33985
+ *
33986
+ * @param {BitMatrix} matrix Modules matrix
33987
+ * @param {Number} version QR Code version
33988
+ */
33989
+ function setupVersionInfo (matrix, version) {
33990
+ const size = matrix.size;
33991
+ const bits = Version.getEncodedBits(version);
33992
+ let row, col, mod;
33993
+
33994
+ for (let i = 0; i < 18; i++) {
33995
+ row = Math.floor(i / 3);
33996
+ col = i % 3 + size - 8 - 3;
33997
+ mod = ((bits >> i) & 1) === 1;
33998
+
33999
+ matrix.set(row, col, mod, true);
34000
+ matrix.set(col, row, mod, true);
34001
+ }
34002
+ }
34003
+
34004
+ /**
34005
+ * Add format info bits to matrix
34006
+ *
34007
+ * @param {BitMatrix} matrix Modules matrix
34008
+ * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
34009
+ * @param {Number} maskPattern Mask pattern reference value
34010
+ */
34011
+ function setupFormatInfo (matrix, errorCorrectionLevel, maskPattern) {
34012
+ const size = matrix.size;
34013
+ const bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern);
34014
+ let i, mod;
34015
+
34016
+ for (i = 0; i < 15; i++) {
34017
+ mod = ((bits >> i) & 1) === 1;
34018
+
34019
+ // vertical
34020
+ if (i < 6) {
34021
+ matrix.set(i, 8, mod, true);
34022
+ } else if (i < 8) {
34023
+ matrix.set(i + 1, 8, mod, true);
34024
+ } else {
34025
+ matrix.set(size - 15 + i, 8, mod, true);
34026
+ }
34027
+
34028
+ // horizontal
34029
+ if (i < 8) {
34030
+ matrix.set(8, size - i - 1, mod, true);
34031
+ } else if (i < 9) {
34032
+ matrix.set(8, 15 - i - 1 + 1, mod, true);
34033
+ } else {
34034
+ matrix.set(8, 15 - i - 1, mod, true);
34035
+ }
34036
+ }
34037
+
34038
+ // fixed module
34039
+ matrix.set(size - 8, 8, 1, true);
34040
+ }
34041
+
34042
+ /**
34043
+ * Add encoded data bits to matrix
34044
+ *
34045
+ * @param {BitMatrix} matrix Modules matrix
34046
+ * @param {Uint8Array} data Data codewords
34047
+ */
34048
+ function setupData (matrix, data) {
34049
+ const size = matrix.size;
34050
+ let inc = -1;
34051
+ let row = size - 1;
34052
+ let bitIndex = 7;
34053
+ let byteIndex = 0;
34054
+
34055
+ for (let col = size - 1; col > 0; col -= 2) {
34056
+ if (col === 6) col--;
34057
+
34058
+ while (true) {
34059
+ for (let c = 0; c < 2; c++) {
34060
+ if (!matrix.isReserved(row, col - c)) {
34061
+ let dark = false;
34062
+
34063
+ if (byteIndex < data.length) {
34064
+ dark = (((data[byteIndex] >>> bitIndex) & 1) === 1);
34065
+ }
34066
+
34067
+ matrix.set(row, col - c, dark);
34068
+ bitIndex--;
34069
+
34070
+ if (bitIndex === -1) {
34071
+ byteIndex++;
34072
+ bitIndex = 7;
34073
+ }
34074
+ }
34075
+ }
34076
+
34077
+ row += inc;
34078
+
34079
+ if (row < 0 || size <= row) {
34080
+ row -= inc;
34081
+ inc = -inc;
34082
+ break
34083
+ }
34084
+ }
34085
+ }
34086
+ }
34087
+
34088
+ /**
34089
+ * Create encoded codewords from data input
34090
+ *
34091
+ * @param {Number} version QR Code version
34092
+ * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
34093
+ * @param {ByteData} data Data input
34094
+ * @return {Uint8Array} Buffer containing encoded codewords
34095
+ */
34096
+ function createData (version, errorCorrectionLevel, segments) {
34097
+ // Prepare data buffer
34098
+ const buffer = new BitBuffer();
34099
+
34100
+ segments.forEach(function (data) {
34101
+ // prefix data with mode indicator (4 bits)
34102
+ buffer.put(data.mode.bit, 4);
34103
+
34104
+ // Prefix data with character count indicator.
34105
+ // The character count indicator is a string of bits that represents the
34106
+ // number of characters that are being encoded.
34107
+ // The character count indicator must be placed after the mode indicator
34108
+ // and must be a certain number of bits long, depending on the QR version
34109
+ // and data mode
34110
+ // @see {@link Mode.getCharCountIndicator}.
34111
+ buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version));
34112
+
34113
+ // add binary data sequence to buffer
34114
+ data.write(buffer);
34115
+ });
34116
+
34117
+ // Calculate required number of bits
34118
+ const totalCodewords = Utils.getSymbolTotalCodewords(version);
34119
+ const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
34120
+ const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
34121
+
34122
+ // Add a terminator.
34123
+ // If the bit string is shorter than the total number of required bits,
34124
+ // a terminator of up to four 0s must be added to the right side of the string.
34125
+ // If the bit string is more than four bits shorter than the required number of bits,
34126
+ // add four 0s to the end.
34127
+ if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) {
34128
+ buffer.put(0, 4);
34129
+ }
34130
+
34131
+ // If the bit string is fewer than four bits shorter, add only the number of 0s that
34132
+ // are needed to reach the required number of bits.
34133
+
34134
+ // After adding the terminator, if the number of bits in the string is not a multiple of 8,
34135
+ // pad the string on the right with 0s to make the string's length a multiple of 8.
34136
+ while (buffer.getLengthInBits() % 8 !== 0) {
34137
+ buffer.putBit(0);
34138
+ }
34139
+
34140
+ // Add pad bytes if the string is still shorter than the total number of required bits.
34141
+ // Extend the buffer to fill the data capacity of the symbol corresponding to
34142
+ // the Version and Error Correction Level by adding the Pad Codewords 11101100 (0xEC)
34143
+ // and 00010001 (0x11) alternately.
34144
+ const remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8;
34145
+ for (let i = 0; i < remainingByte; i++) {
34146
+ buffer.put(i % 2 ? 0x11 : 0xEC, 8);
34147
+ }
34148
+
34149
+ return createCodewords(buffer, version, errorCorrectionLevel)
34150
+ }
34151
+
34152
+ /**
34153
+ * Encode input data with Reed-Solomon and return codewords with
34154
+ * relative error correction bits
34155
+ *
34156
+ * @param {BitBuffer} bitBuffer Data to encode
34157
+ * @param {Number} version QR Code version
34158
+ * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
34159
+ * @return {Uint8Array} Buffer containing encoded codewords
34160
+ */
34161
+ function createCodewords (bitBuffer, version, errorCorrectionLevel) {
34162
+ // Total codewords for this QR code version (Data + Error correction)
34163
+ const totalCodewords = Utils.getSymbolTotalCodewords(version);
34164
+
34165
+ // Total number of error correction codewords
34166
+ const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
34167
+
34168
+ // Total number of data codewords
34169
+ const dataTotalCodewords = totalCodewords - ecTotalCodewords;
34170
+
34171
+ // Total number of blocks
34172
+ const ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel);
34173
+
34174
+ // Calculate how many blocks each group should contain
34175
+ const blocksInGroup2 = totalCodewords % ecTotalBlocks;
34176
+ const blocksInGroup1 = ecTotalBlocks - blocksInGroup2;
34177
+
34178
+ const totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks);
34179
+
34180
+ const dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks);
34181
+ const dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1;
34182
+
34183
+ // Number of EC codewords is the same for both groups
34184
+ const ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1;
34185
+
34186
+ // Initialize a Reed-Solomon encoder with a generator polynomial of degree ecCount
34187
+ const rs = new ReedSolomonEncoder(ecCount);
34188
+
34189
+ let offset = 0;
34190
+ const dcData = new Array(ecTotalBlocks);
34191
+ const ecData = new Array(ecTotalBlocks);
34192
+ let maxDataSize = 0;
34193
+ const buffer = new Uint8Array(bitBuffer.buffer);
34194
+
34195
+ // Divide the buffer into the required number of blocks
34196
+ for (let b = 0; b < ecTotalBlocks; b++) {
34197
+ const dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2;
34198
+
34199
+ // extract a block of data from buffer
34200
+ dcData[b] = buffer.slice(offset, offset + dataSize);
34201
+
34202
+ // Calculate EC codewords for this data block
34203
+ ecData[b] = rs.encode(dcData[b]);
34204
+
34205
+ offset += dataSize;
34206
+ maxDataSize = Math.max(maxDataSize, dataSize);
34207
+ }
34208
+
34209
+ // Create final data
34210
+ // Interleave the data and error correction codewords from each block
34211
+ const data = new Uint8Array(totalCodewords);
34212
+ let index = 0;
34213
+ let i, r;
34214
+
34215
+ // Add data codewords
34216
+ for (i = 0; i < maxDataSize; i++) {
34217
+ for (r = 0; r < ecTotalBlocks; r++) {
34218
+ if (i < dcData[r].length) {
34219
+ data[index++] = dcData[r][i];
34220
+ }
34221
+ }
34222
+ }
34223
+
34224
+ // Apped EC codewords
34225
+ for (i = 0; i < ecCount; i++) {
34226
+ for (r = 0; r < ecTotalBlocks; r++) {
34227
+ data[index++] = ecData[r][i];
34228
+ }
34229
+ }
34230
+
34231
+ return data
34232
+ }
34233
+
34234
+ /**
34235
+ * Build QR Code symbol
34236
+ *
34237
+ * @param {String} data Input string
34238
+ * @param {Number} version QR Code version
34239
+ * @param {ErrorCorretionLevel} errorCorrectionLevel Error level
34240
+ * @param {MaskPattern} maskPattern Mask pattern
34241
+ * @return {Object} Object containing symbol data
34242
+ */
34243
+ function createSymbol (data, version, errorCorrectionLevel, maskPattern) {
34244
+ let segments;
34245
+
34246
+ if (Array.isArray(data)) {
34247
+ segments = Segments.fromArray(data);
34248
+ } else if (typeof data === 'string') {
34249
+ let estimatedVersion = version;
34250
+
34251
+ if (!estimatedVersion) {
34252
+ const rawSegments = Segments.rawSplit(data);
34253
+
34254
+ // Estimate best version that can contain raw splitted segments
34255
+ estimatedVersion = Version.getBestVersionForData(rawSegments, errorCorrectionLevel);
34256
+ }
34257
+
34258
+ // Build optimized segments
34259
+ // If estimated version is undefined, try with the highest version
34260
+ segments = Segments.fromString(data, estimatedVersion || 40);
34261
+ } else {
34262
+ throw new Error('Invalid data')
34263
+ }
34264
+
34265
+ // Get the min version that can contain data
34266
+ const bestVersion = Version.getBestVersionForData(segments, errorCorrectionLevel);
34267
+
34268
+ // If no version is found, data cannot be stored
34269
+ if (!bestVersion) {
34270
+ throw new Error('The amount of data is too big to be stored in a QR Code')
34271
+ }
34272
+
34273
+ // If not specified, use min version as default
34274
+ if (!version) {
34275
+ version = bestVersion;
34276
+
34277
+ // Check if the specified version can contain the data
34278
+ } else if (version < bestVersion) {
34279
+ throw new Error('\n' +
34280
+ 'The chosen QR Code version cannot contain this amount of data.\n' +
34281
+ 'Minimum version required to store current data is: ' + bestVersion + '.\n'
34282
+ )
34283
+ }
34284
+
34285
+ const dataBits = createData(version, errorCorrectionLevel, segments);
34286
+
34287
+ // Allocate matrix buffer
34288
+ const moduleCount = Utils.getSymbolSize(version);
34289
+ const modules = new BitMatrix(moduleCount);
34290
+
34291
+ // Add function modules
34292
+ setupFinderPattern(modules, version);
34293
+ setupTimingPattern(modules);
34294
+ setupAlignmentPattern(modules, version);
34295
+
34296
+ // Add temporary dummy bits for format info just to set them as reserved.
34297
+ // This is needed to prevent these bits from being masked by {@link MaskPattern.applyMask}
34298
+ // since the masking operation must be performed only on the encoding region.
34299
+ // These blocks will be replaced with correct values later in code.
34300
+ setupFormatInfo(modules, errorCorrectionLevel, 0);
34301
+
34302
+ if (version >= 7) {
34303
+ setupVersionInfo(modules, version);
34304
+ }
34305
+
34306
+ // Add data codewords
34307
+ setupData(modules, dataBits);
34308
+
34309
+ if (isNaN(maskPattern)) {
34310
+ // Find best mask pattern
34311
+ maskPattern = MaskPattern.getBestMask(modules,
34312
+ setupFormatInfo.bind(null, modules, errorCorrectionLevel));
34313
+ }
34314
+
34315
+ // Apply mask pattern
34316
+ MaskPattern.applyMask(maskPattern, modules);
34317
+
34318
+ // Replace format info bits with correct values
34319
+ setupFormatInfo(modules, errorCorrectionLevel, maskPattern);
34320
+
34321
+ return {
34322
+ modules: modules,
34323
+ version: version,
34324
+ errorCorrectionLevel: errorCorrectionLevel,
34325
+ maskPattern: maskPattern,
34326
+ segments: segments
34327
+ }
34328
+ }
34329
+
34330
+ /**
34331
+ * QR Code
34332
+ *
34333
+ * @param {String | Array} data Input data
34334
+ * @param {Object} options Optional configurations
34335
+ * @param {Number} options.version QR Code version
34336
+ * @param {String} options.errorCorrectionLevel Error correction level
34337
+ * @param {Function} options.toSJISFunc Helper func to convert utf8 to sjis
34338
+ */
34339
+ qrcode.create = function create (data, options) {
34340
+ if (typeof data === 'undefined' || data === '') {
34341
+ throw new Error('No input text')
34342
+ }
34343
+
34344
+ let errorCorrectionLevel = ECLevel.M;
34345
+ let version;
34346
+ let mask;
34347
+
34348
+ if (typeof options !== 'undefined') {
34349
+ // Use higher error correction level as default
34350
+ errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M);
34351
+ version = Version.from(options.version);
34352
+ mask = MaskPattern.from(options.maskPattern);
34353
+
34354
+ if (options.toSJISFunc) {
34355
+ Utils.setToSJISFunction(options.toSJISFunc);
34356
+ }
34357
+ }
34358
+
34359
+ return createSymbol(data, version, errorCorrectionLevel, mask)
34360
+ };
34361
+ return qrcode;
34362
+ }
34363
+
34364
+ var canvas = {};
34365
+
34366
+ var utils = {};
34367
+
34368
+ var hasRequiredUtils;
34369
+
34370
+ function requireUtils () {
34371
+ if (hasRequiredUtils) return utils;
34372
+ hasRequiredUtils = 1;
34373
+ (function (exports) {
34374
+ function hex2rgba (hex) {
34375
+ if (typeof hex === 'number') {
34376
+ hex = hex.toString();
34377
+ }
34378
+
34379
+ if (typeof hex !== 'string') {
34380
+ throw new Error('Color should be defined as hex string')
34381
+ }
34382
+
34383
+ let hexCode = hex.slice().replace('#', '').split('');
34384
+ if (hexCode.length < 3 || hexCode.length === 5 || hexCode.length > 8) {
34385
+ throw new Error('Invalid hex color: ' + hex)
34386
+ }
34387
+
34388
+ // Convert from short to long form (fff -> ffffff)
34389
+ if (hexCode.length === 3 || hexCode.length === 4) {
34390
+ hexCode = Array.prototype.concat.apply([], hexCode.map(function (c) {
34391
+ return [c, c]
34392
+ }));
34393
+ }
34394
+
34395
+ // Add default alpha value
34396
+ if (hexCode.length === 6) hexCode.push('F', 'F');
34397
+
34398
+ const hexValue = parseInt(hexCode.join(''), 16);
34399
+
34400
+ return {
34401
+ r: (hexValue >> 24) & 255,
34402
+ g: (hexValue >> 16) & 255,
34403
+ b: (hexValue >> 8) & 255,
34404
+ a: hexValue & 255,
34405
+ hex: '#' + hexCode.slice(0, 6).join('')
34406
+ }
34407
+ }
34408
+
34409
+ exports.getOptions = function getOptions (options) {
34410
+ if (!options) options = {};
34411
+ if (!options.color) options.color = {};
34412
+
34413
+ const margin = typeof options.margin === 'undefined' ||
34414
+ options.margin === null ||
34415
+ options.margin < 0
34416
+ ? 4
34417
+ : options.margin;
34418
+
34419
+ const width = options.width && options.width >= 21 ? options.width : undefined;
34420
+ const scale = options.scale || 4;
34421
+
34422
+ return {
34423
+ width: width,
34424
+ scale: width ? 4 : scale,
34425
+ margin: margin,
34426
+ color: {
34427
+ dark: hex2rgba(options.color.dark || '#000000ff'),
34428
+ light: hex2rgba(options.color.light || '#ffffffff')
34429
+ },
34430
+ type: options.type,
34431
+ rendererOpts: options.rendererOpts || {}
34432
+ }
34433
+ };
34434
+
34435
+ exports.getScale = function getScale (qrSize, opts) {
34436
+ return opts.width && opts.width >= qrSize + opts.margin * 2
34437
+ ? opts.width / (qrSize + opts.margin * 2)
34438
+ : opts.scale
34439
+ };
34440
+
34441
+ exports.getImageWidth = function getImageWidth (qrSize, opts) {
34442
+ const scale = exports.getScale(qrSize, opts);
34443
+ return Math.floor((qrSize + opts.margin * 2) * scale)
34444
+ };
34445
+
34446
+ exports.qrToImageData = function qrToImageData (imgData, qr, opts) {
34447
+ const size = qr.modules.size;
34448
+ const data = qr.modules.data;
34449
+ const scale = exports.getScale(size, opts);
34450
+ const symbolSize = Math.floor((size + opts.margin * 2) * scale);
34451
+ const scaledMargin = opts.margin * scale;
34452
+ const palette = [opts.color.light, opts.color.dark];
34453
+
34454
+ for (let i = 0; i < symbolSize; i++) {
34455
+ for (let j = 0; j < symbolSize; j++) {
34456
+ let posDst = (i * symbolSize + j) * 4;
34457
+ let pxColor = opts.color.light;
34458
+
34459
+ if (i >= scaledMargin && j >= scaledMargin &&
34460
+ i < symbolSize - scaledMargin && j < symbolSize - scaledMargin) {
34461
+ const iSrc = Math.floor((i - scaledMargin) / scale);
34462
+ const jSrc = Math.floor((j - scaledMargin) / scale);
34463
+ pxColor = palette[data[iSrc * size + jSrc] ? 1 : 0];
34464
+ }
34465
+
34466
+ imgData[posDst++] = pxColor.r;
34467
+ imgData[posDst++] = pxColor.g;
34468
+ imgData[posDst++] = pxColor.b;
34469
+ imgData[posDst] = pxColor.a;
34470
+ }
34471
+ }
34472
+ };
34473
+ } (utils));
34474
+ return utils;
34475
+ }
34476
+
34477
+ var hasRequiredCanvas;
34478
+
34479
+ function requireCanvas () {
34480
+ if (hasRequiredCanvas) return canvas;
34481
+ hasRequiredCanvas = 1;
34482
+ (function (exports) {
34483
+ const Utils = requireUtils();
34484
+
34485
+ function clearCanvas (ctx, canvas, size) {
34486
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
34487
+
34488
+ if (!canvas.style) canvas.style = {};
34489
+ canvas.height = size;
34490
+ canvas.width = size;
34491
+ canvas.style.height = size + 'px';
34492
+ canvas.style.width = size + 'px';
34493
+ }
34494
+
34495
+ function getCanvasElement () {
34496
+ try {
34497
+ return document.createElement('canvas')
34498
+ } catch (e) {
34499
+ throw new Error('You need to specify a canvas element')
34500
+ }
34501
+ }
34502
+
34503
+ exports.render = function render (qrData, canvas, options) {
34504
+ let opts = options;
34505
+ let canvasEl = canvas;
34506
+
34507
+ if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {
34508
+ opts = canvas;
34509
+ canvas = undefined;
34510
+ }
34511
+
34512
+ if (!canvas) {
34513
+ canvasEl = getCanvasElement();
34514
+ }
34515
+
34516
+ opts = Utils.getOptions(opts);
34517
+ const size = Utils.getImageWidth(qrData.modules.size, opts);
34518
+
34519
+ const ctx = canvasEl.getContext('2d');
34520
+ const image = ctx.createImageData(size, size);
34521
+ Utils.qrToImageData(image.data, qrData, opts);
34522
+
34523
+ clearCanvas(ctx, canvasEl, size);
34524
+ ctx.putImageData(image, 0, 0);
34525
+
34526
+ return canvasEl
34527
+ };
34528
+
34529
+ exports.renderToDataURL = function renderToDataURL (qrData, canvas, options) {
34530
+ let opts = options;
34531
+
34532
+ if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {
34533
+ opts = canvas;
34534
+ canvas = undefined;
34535
+ }
34536
+
34537
+ if (!opts) opts = {};
34538
+
34539
+ const canvasEl = exports.render(qrData, canvas, opts);
34540
+
34541
+ const type = opts.type || 'image/png';
34542
+ const rendererOpts = opts.rendererOpts || {};
34543
+
34544
+ return canvasEl.toDataURL(type, rendererOpts.quality)
34545
+ };
34546
+ } (canvas));
34547
+ return canvas;
34548
+ }
34549
+
34550
+ var svgTag = {};
34551
+
34552
+ var hasRequiredSvgTag;
34553
+
34554
+ function requireSvgTag () {
34555
+ if (hasRequiredSvgTag) return svgTag;
34556
+ hasRequiredSvgTag = 1;
34557
+ const Utils = requireUtils();
34558
+
34559
+ function getColorAttrib (color, attrib) {
34560
+ const alpha = color.a / 255;
34561
+ const str = attrib + '="' + color.hex + '"';
34562
+
34563
+ return alpha < 1
34564
+ ? str + ' ' + attrib + '-opacity="' + alpha.toFixed(2).slice(1) + '"'
34565
+ : str
34566
+ }
34567
+
34568
+ function svgCmd (cmd, x, y) {
34569
+ let str = cmd + x;
34570
+ if (typeof y !== 'undefined') str += ' ' + y;
34571
+
34572
+ return str
34573
+ }
34574
+
34575
+ function qrToPath (data, size, margin) {
34576
+ let path = '';
34577
+ let moveBy = 0;
34578
+ let newRow = false;
34579
+ let lineLength = 0;
34580
+
34581
+ for (let i = 0; i < data.length; i++) {
34582
+ const col = Math.floor(i % size);
34583
+ const row = Math.floor(i / size);
34584
+
34585
+ if (!col && !newRow) newRow = true;
34586
+
34587
+ if (data[i]) {
34588
+ lineLength++;
34589
+
34590
+ if (!(i > 0 && col > 0 && data[i - 1])) {
34591
+ path += newRow
34592
+ ? svgCmd('M', col + margin, 0.5 + row + margin)
34593
+ : svgCmd('m', moveBy, 0);
34594
+
34595
+ moveBy = 0;
34596
+ newRow = false;
34597
+ }
34598
+
34599
+ if (!(col + 1 < size && data[i + 1])) {
34600
+ path += svgCmd('h', lineLength);
34601
+ lineLength = 0;
34602
+ }
34603
+ } else {
34604
+ moveBy++;
34605
+ }
34606
+ }
34607
+
34608
+ return path
34609
+ }
34610
+
34611
+ svgTag.render = function render (qrData, options, cb) {
34612
+ const opts = Utils.getOptions(options);
34613
+ const size = qrData.modules.size;
34614
+ const data = qrData.modules.data;
34615
+ const qrcodesize = size + opts.margin * 2;
34616
+
34617
+ const bg = !opts.color.light.a
34618
+ ? ''
34619
+ : '<path ' + getColorAttrib(opts.color.light, 'fill') +
34620
+ ' d="M0 0h' + qrcodesize + 'v' + qrcodesize + 'H0z"/>';
34621
+
34622
+ const path =
34623
+ '<path ' + getColorAttrib(opts.color.dark, 'stroke') +
34624
+ ' d="' + qrToPath(data, size, opts.margin) + '"/>';
34625
+
34626
+ const viewBox = 'viewBox="' + '0 0 ' + qrcodesize + ' ' + qrcodesize + '"';
34627
+
34628
+ const width = !opts.width ? '' : 'width="' + opts.width + '" height="' + opts.width + '" ';
34629
+
34630
+ const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path + '</svg>\n';
34631
+
34632
+ if (typeof cb === 'function') {
34633
+ cb(null, svgTag);
34634
+ }
34635
+
34636
+ return svgTag
34637
+ };
34638
+ return svgTag;
34639
+ }
34640
+
34641
+ var hasRequiredBrowser;
34642
+
34643
+ function requireBrowser () {
34644
+ if (hasRequiredBrowser) return browser;
34645
+ hasRequiredBrowser = 1;
34646
+ const canPromise = requireCanPromise();
34647
+
34648
+ const QRCode = requireQrcode();
34649
+ const CanvasRenderer = requireCanvas();
34650
+ const SvgRenderer = requireSvgTag();
34651
+
34652
+ function renderCanvas (renderFunc, canvas, text, opts, cb) {
34653
+ const args = [].slice.call(arguments, 1);
34654
+ const argsNum = args.length;
34655
+ const isLastArgCb = typeof args[argsNum - 1] === 'function';
34656
+
34657
+ if (!isLastArgCb && !canPromise()) {
34658
+ throw new Error('Callback required as last argument')
34659
+ }
34660
+
34661
+ if (isLastArgCb) {
34662
+ if (argsNum < 2) {
34663
+ throw new Error('Too few arguments provided')
34664
+ }
34665
+
34666
+ if (argsNum === 2) {
34667
+ cb = text;
34668
+ text = canvas;
34669
+ canvas = opts = undefined;
34670
+ } else if (argsNum === 3) {
34671
+ if (canvas.getContext && typeof cb === 'undefined') {
34672
+ cb = opts;
34673
+ opts = undefined;
34674
+ } else {
34675
+ cb = opts;
34676
+ opts = text;
34677
+ text = canvas;
34678
+ canvas = undefined;
34679
+ }
34680
+ }
34681
+ } else {
34682
+ if (argsNum < 1) {
34683
+ throw new Error('Too few arguments provided')
34684
+ }
34685
+
34686
+ if (argsNum === 1) {
34687
+ text = canvas;
34688
+ canvas = opts = undefined;
34689
+ } else if (argsNum === 2 && !canvas.getContext) {
34690
+ opts = text;
34691
+ text = canvas;
34692
+ canvas = undefined;
34693
+ }
34694
+
34695
+ return new Promise(function (resolve, reject) {
34696
+ try {
34697
+ const data = QRCode.create(text, opts);
34698
+ resolve(renderFunc(data, canvas, opts));
34699
+ } catch (e) {
34700
+ reject(e);
34701
+ }
34702
+ })
34703
+ }
34704
+
34705
+ try {
34706
+ const data = QRCode.create(text, opts);
34707
+ cb(null, renderFunc(data, canvas, opts));
34708
+ } catch (e) {
34709
+ cb(e);
34710
+ }
34711
+ }
34712
+
34713
+ browser.create = QRCode.create;
34714
+ browser.toCanvas = renderCanvas.bind(null, CanvasRenderer.render);
34715
+ browser.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL);
34716
+
34717
+ // only svg for now.
34718
+ browser.toString = renderCanvas.bind(null, function (data, _, opts) {
34719
+ return SvgRenderer.render(data, opts)
34720
+ });
34721
+ return browser;
34722
+ }
34723
+
34724
+ var browserExports = requireBrowser();
34725
+ var QRCode = /*@__PURE__*/getDefaultExportFromCjs(browserExports);
34726
+
34727
+ const kritzelShareDialogCss = () => `:host{display:contents}kritzel-dialog{--kritzel-dialog-width-small:420px}.share-content{display:flex;flex-direction:column;gap:20px}.share-section{display:flex;flex-direction:column;gap:8px}.share-section-revoke{padding-top:12px;border-top:1px solid var(--kritzel-share-dialog-border-color, #e5e5e5)}.share-row{display:flex;align-items:center;justify-content:space-between;gap:16px}.share-label-group{display:flex;flex-direction:column;gap:8px;flex:1}.share-label{font-size:14px;font-weight:600;color:var(--kritzel-share-dialog-label-color, #333333);margin:0}.share-description{font-size:12px;color:var(--kritzel-share-dialog-description-color, #666666);margin:0;line-height:1.4}.share-url-container{display:flex;align-items:center;gap:8px;background:var(--kritzel-share-dialog-input-background, #f5f5f5);border:1px solid var(--kritzel-share-dialog-input-border-color, #e0e0e0);border-radius:6px;padding:4px 4px 4px 12px}.share-qr-container{display:flex;justify-content:center;margin-top:16px;margin-bottom:16px}.share-qr-image{width:180px;height:180px;border-radius:8px;border:1px solid var(--kritzel-share-dialog-qr-border-color, #e0e0e0);background:var(--kritzel-share-dialog-qr-background, #ffffff);padding:8px;box-sizing:border-box}.share-url-input{flex:1;border:none;background:transparent;font-size:13px;color:var(--kritzel-share-dialog-input-text-color, #333333);outline:none;min-width:0;padding:8px 0}.share-url-input:focus{outline:none}.share-url-input::selection{background:var(--kritzel-share-dialog-selection-color, #cce5ff)}.copy-button{display:flex;align-items:center;justify-content:center;width:36px;height:36px;border:none;border-radius:4px;background:var(--kritzel-share-dialog-copy-button-background, #ffffff);color:var(--kritzel-share-dialog-copy-button-color, #666666);cursor:pointer;transition:all 0.15s ease;flex-shrink:0}.copy-button:hover{background:var(--kritzel-share-dialog-copy-button-hover-background, #e8e8e8);color:var(--kritzel-share-dialog-copy-button-hover-color, #333333)}.copy-button.copy-success{background:var(--kritzel-share-dialog-copy-success-background, #d4edda);color:var(--kritzel-share-dialog-copy-success-color, #28a745)}.revoke-button{align-self:flex-start;padding:8px 16px;border:1px solid var(--kritzel-share-dialog-revoke-button-border-color, #dc3545);border-radius:6px;background:transparent;color:var(--kritzel-share-dialog-revoke-button-color, #dc3545);font-size:13px;font-weight:500;cursor:pointer;transition:all 0.15s ease}.revoke-button:hover{background:var(--kritzel-share-dialog-revoke-button-hover-background, #dc3545);color:var(--kritzel-share-dialog-revoke-button-hover-color, #ffffff)}kritzel-dropdown{--kritzel-dropdown-trigger-padding:8px 12px;--kritzel-dropdown-trigger-font-size:13px}`;
31653
34728
 
31654
34729
  const KritzelShareDialog = class {
31655
34730
  constructor(hostRef) {
@@ -31670,10 +34745,16 @@ const KritzelShareDialog = class {
31670
34745
  terms = {};
31671
34746
  onIsPublicChange(newValue) {
31672
34747
  this.internalIsPublic = newValue;
34748
+ void this.updateQrCodeDataUrl();
34749
+ }
34750
+ onWorkspaceIdChange() {
34751
+ void this.updateQrCodeDataUrl();
31673
34752
  }
31674
34753
  isDialogOpen = false;
31675
34754
  internalIsPublic = false;
31676
34755
  copySuccess = false;
34756
+ qrCodeDataUrl = '';
34757
+ qrCodeUpdateSequence = 0;
31677
34758
  /**
31678
34759
  * Emitted when the user toggles the public sharing state.
31679
34760
  */
@@ -31688,6 +34769,7 @@ const KritzelShareDialog = class {
31688
34769
  async open() {
31689
34770
  this.internalIsPublic = this.isPublic;
31690
34771
  this.isDialogOpen = true;
34772
+ await this.updateQrCodeDataUrl();
31691
34773
  }
31692
34774
  /**
31693
34775
  * Closes the share dialog.
@@ -31699,8 +34781,37 @@ const KritzelShareDialog = class {
31699
34781
  const enabled = event.detail;
31700
34782
  // Update local state optimistically for immediate UI feedback
31701
34783
  this.internalIsPublic = enabled;
34784
+ void this.updateQrCodeDataUrl();
31702
34785
  this.toggleIsPublic.emit(enabled);
31703
34786
  };
34787
+ async updateQrCodeDataUrl() {
34788
+ if (!this.internalIsPublic) {
34789
+ this.qrCodeDataUrl = '';
34790
+ return;
34791
+ }
34792
+ const shareUrl = this.getShareUrl();
34793
+ if (!shareUrl) {
34794
+ this.qrCodeDataUrl = '';
34795
+ return;
34796
+ }
34797
+ const sequence = ++this.qrCodeUpdateSequence;
34798
+ try {
34799
+ const dataUrl = await QRCode.toDataURL(shareUrl, {
34800
+ margin: 1,
34801
+ width: 180,
34802
+ });
34803
+ if (sequence !== this.qrCodeUpdateSequence) {
34804
+ return;
34805
+ }
34806
+ this.qrCodeDataUrl = dataUrl;
34807
+ }
34808
+ catch {
34809
+ if (sequence !== this.qrCodeUpdateSequence) {
34810
+ return;
34811
+ }
34812
+ this.qrCodeDataUrl = '';
34813
+ }
34814
+ }
31704
34815
  getShareUrl() {
31705
34816
  if (!this.workspaceId)
31706
34817
  return '';
@@ -31738,13 +34849,16 @@ const KritzelShareDialog = class {
31738
34849
  this.dialogClosed.emit();
31739
34850
  };
31740
34851
  render() {
31741
- return (h(Host, { key: '031cf5d1ab48f2791454d4c7348352295359d225' }, h("kritzel-dialog", { key: 'cdce63c86ca329a97d1f1787adcb2b92bbfa40f9', dialogTitle: this.terms['share.dialogTitle'] ?? 'Share Workspace', size: "small", isOpen: this.isDialogOpen, onDialogClose: this.closeDialog, contained: true }, h("div", { key: 'dbb62b3cb175358955b11f6c2d74b0b0eecf212e', class: "share-content" }, h("div", { key: '8dc0eaea9644b60ff33812dac20def226fa14232', class: "share-section" }, h("div", { key: 'd3cfbf05c28a01681b1223edb6f0b73998ccfd08', class: "share-row" }, h("div", { key: '2400f062f92dd918341391cf71086c2676f7fc66', class: "share-label-group" }, h("label", { key: 'ab01691b9f53f59f92116a2994b6e3551d347c7b', class: "share-label" }, this.terms['share.linkSharing.label'] ?? 'Link sharing'), h("p", { key: 'fd830ad21e32e4fc5d8ba97d5cea7ef8da15fba4', class: "share-description" }, this.internalIsPublic
34852
+ return (h(Host, { key: '11d8762a3edf2c0563b70b863edbbb413ee8255e' }, h("kritzel-dialog", { key: 'f54de9dc8cc3e88ab0efd13e52bc78f9b84f2efa', dialogTitle: this.terms['share.dialogTitle'] ?? 'Share Workspace', size: "small", isOpen: this.isDialogOpen, onDialogClose: this.closeDialog, contained: true }, h("div", { key: '6a81278ab1d8e5ad10f2139232bc3baf039f03a8', class: "share-content" }, h("div", { key: '6c94cce83aec9f3777936c6e845e698b1013f240', class: "share-section" }, h("div", { key: '051672c0abbd0999889ef570a733921384c35076', class: "share-row" }, h("div", { key: '3200e9d96cd859ffc231a86895186cc0d0cc9f66', class: "share-label-group" }, h("label", { key: '14c3ed49917864fe92b7d1fdd6b2ee33526cbe30', class: "share-label" }, this.terms['share.linkSharing.label'] ?? 'Link sharing'), h("p", { key: 'b96763875cfda2a638df12857e14c06ac6b1945c', class: "share-description" }, this.internalIsPublic
31742
34853
  ? (this.terms['share.linkSharing.enabledDescription'] ?? 'Anyone with the link can access this workspace.')
31743
- : (this.terms['share.linkSharing.disabledDescription'] ?? 'Link sharing is disabled. Only you can access this workspace.'))), h("kritzel-slide-toggle", { key: '6f1a71ba524b34753ccd5437eab00bfcbeffdd79', checked: this.internalIsPublic, onCheckedChange: this.handleToggleChange, label: this.terms['share.linkSharing.toggleLabel'] ?? 'Enable link sharing' }))), this.internalIsPublic && (h("div", { key: '298680e1afdf0094c5393aa95c4983a0a8dd5e18', class: "share-section" }, h("div", { key: '546645a748cf9a42df0c8163f2478ef31445273a', class: "share-url-container" }, h("input", { key: '9d5b93d762d1cd899f3fc8041380bae603a4919c', type: "text", class: "share-url-input", value: this.getShareUrl(), readOnly: true, onClick: (e) => e.target.select() }), h("button", { key: '747a7ca4a25827de6934b7df30cabc2db4583e1b', class: { 'copy-button': true, 'copy-success': this.copySuccess }, onClick: this.handleCopyUrl, title: this.copySuccess ? (this.terms['share.copyLink.copied'] ?? 'Copied!') : (this.terms['share.copyLink.title'] ?? 'Copy link') }, h("kritzel-icon", { key: '096ca9a0527796462769dc9d42dd81d8f97f2865', name: this.copySuccess ? 'check' : 'copy', size: 18 })))))))));
34854
+ : (this.terms['share.linkSharing.disabledDescription'] ?? 'Link sharing is disabled. Only you can access this workspace.'))), h("kritzel-slide-toggle", { key: '4a476a3d323ee0932ca26bc59893eaf42fffc5af', checked: this.internalIsPublic, onCheckedChange: this.handleToggleChange, label: this.terms['share.linkSharing.toggleLabel'] ?? 'Enable link sharing' }))), this.internalIsPublic && (h("div", { key: 'c7da6b5d2dfaf0679e1d2a337f7a266a37d4792c', class: "share-section" }, h("div", { key: '2c8591b80e5742a6b1851feef438097c62d7a1b8', class: "share-url-container" }, h("input", { key: '4af045aa7ceb8e4878946c41da0362a58ec7c84d', type: "text", class: "share-url-input", value: this.getShareUrl(), readOnly: true, onClick: (e) => e.target.select() }), h("button", { key: '46123f1fdf1b4f4b56fd20d19d4c73ba27b32481', class: { 'copy-button': true, 'copy-success': this.copySuccess }, onClick: this.handleCopyUrl, title: this.copySuccess ? (this.terms['share.copyLink.copied'] ?? 'Copied!') : (this.terms['share.copyLink.title'] ?? 'Copy link') }, h("kritzel-icon", { key: '43f8574de6559ef62894b4e8e5bc9949474d2e20', name: this.copySuccess ? 'check' : 'copy', size: 18 }))), this.qrCodeDataUrl && (h("div", { key: 'dab1b497586b5a603c8de0f0e9d2637dc5b37971', class: "share-qr-container" }, h("img", { key: '3ea38e75688daa158c90aa337a91f58b758722c0', class: "share-qr-image", src: this.qrCodeDataUrl, alt: "QR code for share link" })))))))));
31744
34855
  }
31745
34856
  static get watchers() { return {
31746
34857
  "isPublic": [{
31747
34858
  "onIsPublicChange": 0
34859
+ }],
34860
+ "workspaceId": [{
34861
+ "onWorkspaceIdChange": 0
31748
34862
  }]
31749
34863
  }; }
31750
34864
  };
@@ -32328,7 +35442,7 @@ const KritzelUtilityPanel = class {
32328
35442
  this.redo.emit();
32329
35443
  }
32330
35444
  render() {
32331
- return (h(Host, { key: '22f3826d57b4d8f0e476951a860bde3dbc6c7200' }, h("button", { key: 'c3259c5e924b3cf74920dc4676ec8a682c3273e8', class: "utility-button", "data-testid": "utility-undo", disabled: !this.undoState?.canUndo, onClick: event => this.handleUndo(event), "aria-label": this.terms['utility.undo'] ?? 'Undo' }, h("kritzel-icon", { key: 'ab4e9da6b60d9fa470fd8f5002f2acd5a758a8ba', name: "undo" })), h("button", { key: 'd17e25e78831b5ee13596cc2639cfbb5bd75a1cb', class: "utility-button", "data-testid": "utility-redo", disabled: !this.undoState?.canRedo, onClick: event => this.handleRedo(event), "aria-label": this.terms['utility.redo'] ?? 'Redo' }, h("kritzel-icon", { key: '7ae8cec39ffab1303d76315ab85ac575b886b233', name: "redo" })), h("div", { key: 'f54e0262f133ad0eed0bbf853b67edd6c2f5e87f', class: "utility-separator" }), h("button", { key: '162d6e85965338b5700e661595dc6da6131ebccf', class: "utility-button", "data-testid": "utility-delete", onClick: () => this.delete.emit(), "aria-label": this.terms['utility.delete'] ?? 'Delete selected items' }, h("kritzel-icon", { key: 'dc00247ed45f09b86ad9314395f56e70d1122a4b', name: "delete" }))));
35445
+ return (h(Host, { key: '40aeb81be7e767bf6565dd691d17b5dd283d997b' }, h("button", { key: '80bb960bf04d5e0bea09960e3bc5e0d999a8cb84', class: "utility-button", "data-testid": "utility-undo", disabled: !this.undoState?.canUndo, onClick: event => this.handleUndo(event), "aria-label": this.terms['utility.undo'] ?? 'Undo' }, h("kritzel-icon", { key: '7ab3d89a60f247cfb040fa1ff77aed7a4e616a0a', name: "undo" })), h("button", { key: 'fb5b7ee68a7488192bc053808f338fca72a22d79', class: "utility-button", "data-testid": "utility-redo", disabled: !this.undoState?.canRedo, onClick: event => this.handleRedo(event), "aria-label": this.terms['utility.redo'] ?? 'Redo' }, h("kritzel-icon", { key: '4da4fe3a445a9ae03981af51e73291c3f6b0fbbb', name: "redo" })), h("div", { key: '6144f7c81f06c6b1215230394e62df2120e5853a', class: "utility-separator" }), h("button", { key: '92839ee1dfb039a2f669326adce8d623dafe1aed', class: "utility-button", "data-testid": "utility-delete", onClick: () => this.delete.emit(), "aria-label": this.terms['utility.delete'] ?? 'Delete selected items' }, h("kritzel-icon", { key: '4071b04d37ddd033545ba92d2cedb164e6e96fdd', name: "delete" }))));
32332
35446
  }
32333
35447
  };
32334
35448
  KritzelUtilityPanel.style = kritzelUtilityPanelCss();
@@ -32537,7 +35651,7 @@ const KritzelZoomPanel = class {
32537
35651
  return Number.isFinite(this.zoomPercent) ? Math.max(1, Math.round(this.zoomPercent)) : 100;
32538
35652
  }
32539
35653
  render() {
32540
- return (h(Host, { key: '00d5c674581d4efa40da3a2ad5cbdd8295406590' }, h("div", { key: 'c7a4158f57b8062f37ee69f7b198442ec357d746', class: { panel: true, visible: this.visible } }, h("button", { key: 'e20344f5e522d481185a9dab7afdb2668cf44408', class: "zoom-button", type: "button", "aria-label": this.terms['zoom.zoomOut'] ?? 'Zoom out', disabled: this.disabled, onClick: this.handleZoomOut }, h("kritzel-icon", { key: '4fc1eeb78669894b0939a96c5e6945cea5056ac1', name: "minus" })), h("span", { key: 'ed26096e2ca76fe91b50d73ea6c9481996d01590', class: "zoom-level", "aria-live": "polite" }, this.normalizedZoomPercent, "%"), h("button", { key: '42609c6e8558b7d9e9e348b864639ead6c4cc9bb', class: "zoom-button", type: "button", "aria-label": this.terms['zoom.zoomIn'] ?? 'Zoom in', disabled: this.disabled, onClick: this.handleZoomIn }, h("kritzel-icon", { key: '3a321afb57f532ef867bae73751314f3fd355214', name: "plus" })))));
35654
+ return (h(Host, { key: '1535c002e9e93788c82c244b865ee2d78f850781' }, h("div", { key: '6f91dd43e5e871aa570b46c249b76b27cb392668', class: { panel: true, visible: this.visible } }, h("button", { key: '48eeff98207ee571b4d8636afaf951827181f7b4', class: "zoom-button", type: "button", "aria-label": this.terms['zoom.zoomOut'] ?? 'Zoom out', disabled: this.disabled, onClick: this.handleZoomOut }, h("kritzel-icon", { key: '8f8fb4adf11ad79d670ae0aa58944df0078373f7', name: "minus" })), h("span", { key: '382b1017593a3df8b902711380b211253aaf08d8', class: "zoom-level", "aria-live": "polite" }, this.normalizedZoomPercent, "%"), h("button", { key: '322aac46173ad6d0a2a74f3c45acd1e5936d5b6a', class: "zoom-button", type: "button", "aria-label": this.terms['zoom.zoomIn'] ?? 'Zoom in', disabled: this.disabled, onClick: this.handleZoomIn }, h("kritzel-icon", { key: '00ef24238db19388021ca1757b4e981339ce066a', name: "plus" })))));
32541
35655
  }
32542
35656
  };
32543
35657
  KritzelZoomPanel.style = kritzelZoomPanelCss();