diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 4f2a8076a..000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,23 +0,0 @@ -module.exports = { - parser: "@typescript-eslint/parser", - extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"], - env: { - browser: true, - commonjs: true, - es6: true, - node: true, - jasmine: true - }, - plugins: ["@typescript-eslint", "jasmine"], - globals: { - Atomics: "readonly", - SharedArrayBuffer: "readonly" - }, - parserOptions: { - ecmaVersion: 2018, - sourceType: "module" - }, - rules: { - "@typescript-eslint/no-var-requires": "off" - } -}; diff --git a/.prettierrc b/.prettierrc index 0967ef424..1f5e5d140 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1 +1,4 @@ -{} +{ + "arrowParens": "avoid", + "trailingComma": "none" +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6d7f52ebf..3bc311a9d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -91,7 +91,20 @@ Conventions: transpiled `.ts` files under their `.js` URL. - Only erasable TypeScript syntax is allowed (`erasableSyntaxOnly`): no enums, namespaces or parameter properties. Type-stripping must never change - runtime behavior. + runtime behavior. Class fields must use the `declare` modifier (type-only); + a bare initialized field would require babel's class-properties transform, + which changes own-property layout and is deliberately not enabled. +- Explicit `any` and `@ts-ignore` are banned repo-wide, enforced by + `npm run lint-no-any` (oxlint) in the lint script. Use `unknown` plus + narrowing; a documented `as unknown as T` is the escape hatch of last + resort at genuine dynamic boundaries. +- The internal type system lives in `src/types.ts`. Plugin modules declare + the members they add via `declare module "../types.js"` interface + augmentation inside their own file. +- Specs are TypeScript too, type-checked by `test/tsconfig.json` (part of + `npm run typecheck`). Spec globals are ambient-declared in + `test/globals.d.ts`; the Node run strips types via `@babel/register` + (see `test/deployment/node/registerTypeScript.js`). - `src/libs/fflate.js`, `src/libs/fast-png.js`, `src/license.js` and `src/polyfills.js` intentionally stay JavaScript. - `src/libs/WebPDecoder.ts` and `src/libs/ttffont.ts` are vendored/generated diff --git a/cli.js b/cli.js index ed4926652..550ac9ac3 100644 --- a/cli.js +++ b/cli.js @@ -7,7 +7,7 @@ function uniq(a) { var prims = { boolean: {}, number: {}, string: {} }, objs = []; - return a.filter(function(item) { + return a.filter(function (item) { var type = typeof item; if (type in prims) if (Object.prototype.hasOwnProperty.call(prims[type], item)) { diff --git a/examples/MathJax/MathJax_Main.js b/examples/MathJax/MathJax_Main.js index 0b97a185f..afcba5d47 100644 --- a/examples/MathJax/MathJax_Main.js +++ b/examples/MathJax/MathJax_Main.js @@ -1,7 +1,7 @@ -(function(jsPDFAPI) { +(function (jsPDFAPI) { var font = "AAEAAAANAIAAAwBQRkZUTVp2x1gAAL5AAAAAHEdERUYBUgAGAAC+IAAAACBPUy8yRbxaFQAAAVgAAABgY21hcLEo/ekAAAZMAAAESmdhc3D//wADAAC+GAAAAAhnbHlmDBpxfgAADOQAAKMMaGVhZP5M8JUAAADcAAAANmhoZWEJeAZPAAABFAAAACRobXR4ws0lHQAAAbgAAASUbG9jYdO3/PwAAAqYAAACTG1heHABbACvAAABOAAAACBuYW1lqQQjYAAAr/AAAAZdcG9zdOvw8tsAALZQAAAHxgABAAAAAQAAib+cQV8PPPUACwPoAAAAAM1Q1p4AAAAAzVDWnv2B/vAHCwOEAAAACAACAAAAAAAAAAEAAASP/igAWgdD/YH/vgcLAAEAAAAAAAAAAAAAAAAAAAElAAEAAAElAKwABQAAAAAAAgAAAAEAAQAAAEAAAAAAAAAAAgGsAZAABQAAAooCvAAAAIwCigK8AAAB4AAxAQIAAAAAAAAAAAAAAACAAADvEADs7QAAAAAAAAAAUGZFZABAACDv/wMg/zgAWgOEARAgAACPXgMAAAG6AqgAAAAgAAEA+gAyAAAAAAFNAAAA+gAAARYATgH0ACIDQQA4AfQANwNBADgDCgAqARYATgGFAF4BhQA3AfQAQAMKADgBFgBOAU0ACwEWAE4B9AA4AfQAJwH0AFMB9AAyAfQAKgH0ABwB9AAyAfQAKgH0ADcB9AArAfQAKgEWAE4BFgBOAwoAUwMKADgDCgBTAdgANwMKADgC7gAgAsQAHALSADgC/AAbAqkAGQKNABkDEQA4Au4AGQFpABUCAgAZAwoAGQJxABkDlQAdAu4AGQMKADgCqQAbAwoAOALgABsCLAA3AtIAJALuABkC7gATBAQAEgLuABcC7gALAmMANwEWAHYB9AA4ARYAFgH0AHAB9AAAAfQAagH0ACICLAAUAbwAIgIsACIBvAAcATIAGgH0AB0CLAAZARYAGgEy/8kCEAAUARYAGgNBABkCLAAZAfQAHAIsABQCEAAhAYgAFAGKACEBhQASAiwAGQIQABMC0gASAhAACwIQABMBvAAcAfQAQQEWAHcB9ABBAfQAUwD6AAAB9ABfApsAOAH0AEUB9ACTAwoAOAH0AMwDCgCTAwoAOAEWABoBMv/JAfQAcAH0AHIB9ABFAfQAzAH0AGoB9ABcAfQAvgH0AJMB9ABTAAD+dgAA/tgAAP58AAD+XwAA/lEAAP5oAAD+ygAA/msAAP6fAAD+hgAA/n4AAP2BAnEAGQNBAC4DCgA4ArYAIAKbACoC7gAZAtIANwMKADcC0gA4AwoANwLSACwB9AAAA+cAAAFNAAAA+gAAAKcAAACnAAAAUwAAAfQAAAPoAAABFgBAARYATgH0AIAB9AAiAbwANwG8ADcElABOARMAHgAA/ikCHAAqAtIANwGhAAcCfABDAtIAKAJjADcD6AA3AfQAEQPoADgB9AARA+gANwH0ABED6AAdA+gANwPoADcD6AAdA+gANwRmADcEZgA3A+gANwPoADcD6AA4A+gAOAPoADcD6AA4AmMAHwPoADgCYwAfA+gAIgJjAB8CLAAAAhMAKgIsADgB9AAnA0EALgKbAFQCmwBUApsAUwMKAFQDCgA4AfQAOAH0ADgB9ABAAfQANwH0ADcDQQBIAwoAOAPoADcC0gA3ARYAdwH0AIQCmwA3ApsANwKbADcCmwA3AaEANwMKADcBFgA3AwoANwPoADcDCgA3AwoANwMKADgDCgA4AwoAOAMKAFMDCgBTA+gAOAPoADcDCgBUAwoAUwMKAFQDCgBTAwoAVAMKAFMCmwA3AwoAVAMKAEACmwA9ApsAPQMKADgDCgA4AwoAOAMKADgDCgA4AmMANwJjADcDCgA3AwoANwNjAHcB9AAMARYATgH0AAMDhAAaARYATgSUAE4FAgCFAbwArgG8ABUBvACuAbwAFQPoADcD6AA3AZwANwGcADgDeQA7AfQAGgN5ADsB9AAaA+gAOAMKADcDCgA3AwoANwMKABwBhQA3AYUAQQGFADcBhQBuAYUANwGcAK0BnAA4BkkANwZmAFQHQwA3BkkAOAZmADgHQgA4BmYANwLuABwDCgBUAwoAUwEsAAABLAAAAGQAAAAAAAMAAAADAAAAHAABAAAAAANEAAMAAQAAABwABAMoAAAAxgCAAAYARgB+AKAAqACsALEAtADXAPcBMQI3AscCywLaAtwDBAMIAwwDOAOUA5gDmwOeA6ADowOmA6kgBiAKIBQgGSAdICEgJiAyINchDyERIRMhGCEcITUhmSGmIaohvSHBIcwh1SIAIgMiBSIJIgsiEyIaIh4iICIjIiUiKyI8IkAiQyJFIkgiTSJQImEiZSJrInsigyKHIo4imSKlIqgixiLIIu8i8SMLIyMjsSWzJbklvSXDJe8mYyZvJ+kn7yf6J/wqPyqw7////wAAACAAoACoAKwArwC0ANcA9wExAjcCxgLJAtgC3AMAAwYDCgM4A5MDmAObA54DoAOjA6UDqCACIAkgEyAYIBwgICAmIDIg1yEPIREhEyEYIRwhNSGQIaYhqSG8IcAhzCHQIgAiAiIFIgciCyISIhUiHSIgIiMiJSInIjwiQCJDIkUiSCJNIlAiYCJkImoieiKCIoYijiKRIqIiqCLEIsgi7iLxIwgjIiOwJbMluSW9JcMl7yZgJm0n6CfuJ/Un/Co/Kq/v/f///+P/wv+7/7j/tv+0/5L/c/86/jX9p/2m/Zr9mf12/XX9dP1J/O/87Pzq/Oj85/zl/OT84+CL4InggeB+4HzgeuB24Gvfx9+Q34/fjt+K34ffb98V3wnfB9723vTe6t7n3r3evN673rreud6z3rLesN6v3q3erN6r3pvemN6W3pXek96P3o3eft583njeat5k3mLeXN5a3lLeUN413jTeD94O3fjd4t1W21XbUNtN20jbHdqt2qTZLNko2SPZItbg1nERJQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBgAAAQAAAAAAAAABAgAAAAIAAAAAAAAAAAAAAAAAAAABAAADBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyAhIiMkJSYnKCkqKywtLi8wMTIzNDU2Nzg5Ojs8PT4/QEFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaW1xdXl9gYQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJpmAAAAAAAAAAAAaGPeAADOZ+DhAAC+AAAA1gAAjAAAAABkzADbAAAAnGIAAAAAAJSVmJmWl2oAAAAAAAAAAACbAAAAAAAAAAAAAAAAAAAAAAAAAABrbXVlcnN0AAAAbgAAAAAAEgASABIAEgBEAJYBHAGwAk4C7AMYAz4DaAPMA/IEGgQmBDwEXASoBNwFMAWoBeQGRgaoBvIHZgfOB/IIKghWCIAIrAkYCbgKDAqCCuALNAugC/wMegzcDRwNeg38DkQOsg8AD0wPpBA2EMYRPhGYEewSNBKqEyoTghPIE9oT+BQKFCoUNhRUFMQVJhVuFcgWEBZgFwQXeBfCGBYYlhjaGYAZ9BoyGqIbABtkG9AcBhxkHKgdFB2UHfIePh6oHr4fFh9GH0YfcB+KH5gfziACICIgaiCkINohGiE6IVQhYiGCIaAhyiHkIhoiSiJoIogiqCLYIuYjEiMsI1gjjiO+I9gj+CQ8JGQkwiUSJWIlqCX+JmQm7id2KAAoACgAKAAoACgAKAAoACgMKBgoRihyKMIpFClyKhoqTipuKqQrNivsLFos4C2+Lmouqi74LzQviC/sMHww0DEmMX4x2jIsMnwyyDLyMxwzRDNoM7Q0CjRgNK41BDWMNhQ2Sja6NuI3aDeQN9Y4PjiOOKA41Dj0ORI5eDmoOcQ6ADpmOto7CDseO1g7iDu4O/Q8MjyIPNI9DD1cPcg+VD60Pu4/Nj9mP6g/5kBGQTZBdEG2QfxCREKYQuxDUEOEQ7RD2EP+RF5ErEUERVJFtkXURfJGEEYuRmJGkkaoRvhHQEdyR6ZH3Ef8SBpIOkhcSJJIykkKSVRJgkm4SeZKFEpsSshLREuOTARMQEx6TQZNME1WTZhN3E4aTlZOvk8aT25P8lBEULxRClFaUWpRelGGAAIAMgAAAMgCFQADAAcAADMRMxEnMxEjMpZkMjICFf3rMgGxAAIATgABAMcCzAAPAB0AABM0NjMyFhUUAgcGIyInJgITHgEVFAcGIyInJjU0Nk4jGRglKAECERICASg/GSAbDRMUDRsjApUVIiEWB/5DAwgIAwG9/esCHxskDwkJDyQcIAAAAAACACIBewF0ArYAGwA3AAATNDYzMhcWFRQHBgcGIiY1NDc2NzQjBgcGIyImNzQ2MzIXFhUUBwYHBiImNTQ3Njc0IwYHBiMiJiIhGhgVHhwUHQ8GFAxBBAEDBA0QGSPMIRoYFR4cFB0PBhQMQQQBAwQNEBkjAnoZIxMiPj02KR0PEwMEDEJZDAICByMaGSMTIj49NikdDxMDBAxCWQwCAgcjAAAAAAIAOP8+AwkCtgBXAGEAABM0NzM3Njc2MzIXFAcGFQczNzY3NjMyFhUUBwYVBzMWFRQHBisBDwEUMzIXFhUUByMHBgcGIyImNTQ3NjU3IwcGBwYjIiY1NDc2NTcjJjU0NzM/ATQrASYFNCsBDwEUOwE3OA7zKikEBAwSAigpAb0qKQQGCgYNJykBsg8KBl5fFBV0cgYKD/MqKQQGCgYNJykBvSopBAYKBg0nKQGyDhC8FBVzchAB215fFBVeXxQBWw0HnZsGCRIElpQFAp2bBgkJBwqSlAUCBw0MBQNMTQEDBgsNB52bBgkKBwqSkgYCnZsGCQoHCpKSBgIHDQ8FTE0BBQYBTE0BTAAAAAADADf/yAG8Au4ATwBeAGgAADcUBisBFRYXFh8BESciLgEnJicmNTQ2NzY3MzUzFRcWFxYXFAcOASMiJjU0NjM3NSYvARUXFhceARUUBgcGKwEVIzUjJicmJzQ3Njc2MzIWEzQjIgcOARUUFhceARczFyYjIh0BPgE0JqIeFwYFBx9NBAQBBQkDWCoUPjAVJwIuDVItHAMBBB0TFx8eFwQdWAQPKRopMEo5GwoDLgZeJh8DAQgfBwkVHkECBBMjLjMqAwYCAjsJAwEsPTO7FiADDwo8CAEBFQECAgEUVCorPlwXCwguLgENOys5EQUTFh8XFh8BAkQLAfoDCxIcYDVHahUKLy4SOi5AEgUfCAMiAUx2Bw07KCc/DAECAXoDhIQLSWBFAAAAAAQAOP/IAwgC7gA3AEkAWgBuAAABFhUUBwYjIicmNTQ2NzYzMhcWFxYyNzY3PgUzMhYHAAcGIyImNTQ3NhM+ASMGIyInLgEvASYjIgcOARQWFxY7ATI3NjU0EzQ2NzYzMhcWFRQHBiMiJyYTJiMiBw4BFRQXFhcWOwEyNzY1NAE/DSclNh8jUEo3DAUnH0dWBjoHXTkCBQIDAwUDCQwB/f0IBAYIDQMB3GpxATc9Q0IDBgJMExoUERMMDRQSFAQTEy/QSjcMBjMnJyclNh8jUL0TGhQRFAoFCyUGCwQTEy8CgSE8WDk4Fjd8T3AJAh8/DQEBD0oCCAIEAQEOCvz7BQQMCAQFAwFInqgZHgEDATUTExZAdkIUEhMvYWL+DE9vCQI3OlhZOTgWNwENExMXOUBDGDcQAhMvYmEAAAADACr/6gLXAswASgBcAG4AABMmNTQ3NjMyFx4BFRQHBg8BFh8BNzY/ATU0JisBNTMWMzI3MxUjBgcOAgcGBwYXHgEXFjMyNjc1MxUOASMmLwEHBiMiJjU0NzY3EyYjIgYVFB8BNzY3NDY1NCcmAxQWMzI3NjUmJy4BLwIHDgHDJzQpNQ8JISoRG0YNJ2cNCCVFEycZBQkSalINBg9OGgEIDwZILgcBAiIHLiomOAMoBU9AU00MC09YTGoaB1GfAwcjJhcECFMKAQMJ0TgsQD4IAwMdThoPChEdGAFbZVxTNCkDCUszHiM2SQ1hgBAKMXYgCBETLgMDLgUkAQ0ZCnw6CQECIQYmNSQICTtLAz0JCUBcQSwmC1ABcgE9LktHDwlXNwIJAw4RPf4IP00uBQIDBBtpLh4SER01AAAAAQBOAXsA1AK2ABsAABM0NjMyFxYUBwYHBiMiJjU0NzY3NCMGBwYjIiZOIhoYFR0bFB0PAwQTDEEEAQMEDRAZJAJ6GSMTIX40KR0PEwMEDEJZDAICByMAAAEAXv8GAU0C7gAVAAAFFCsBJyYRNDc2PwEzMhYVFAcGEBcWAU0SDRy0HS5pHA0MBgubmwvxCRikATh6ZZ1gGAYDBAuk/ZCkCwAAAAABADf/BgEmAu4AGAAAEzcyOwEXFhEUBwYPASMiJjU2NzYQJyYnNDwEBQUMHLQdLmkcDAwHAQqbmwoBAu0BGKT+yHtjnmAYBAgBDKECdKEMAQgAAAABAEABQAGzAu4AQQAAEyImNTQ/AicmJyY1NDc2FxYfATQmNT4BMzIWFwc3Njc2FxYVFAcGDwEfARYVFAcGJyYvAR8BDgEjIiYnNwcGBwZkDxULRUJCQgQKFg4LBTg5DgETDQ8UAQ45OAULDhYKBEJCQkULFg4LBTg5BwcBEw4PEwEOOTgFBgGZFw8OCSIeIB4ECBAWCwYGAykqB4MMCxIRDJYqKQMGBgsWEAgEHiAeIgkOExAGBgMpKktLCxEQDJYqKQMDAAAAAAEAOP+uAtICRwAVAAA2NDchNTc2MzIXESEWFAchEQYiJxEhOA4BKwEKCQ0HASoPD/7WBxoH/tXtGgeWlg0P/tYIGAj+1g4OASoAAAABAE7/PgDSAHkAGAAANjQ2MzIWFRQHBgcGIiY1NDc2NzUiBwYjIk4hGiYjAg47DggSCj4GAQUNDhojMiRAMRMQWUAOEgQFCj9bDAMGAAAAAAEACwCzARUA/AADAAA3NSEVCwEKs0lJAAEATgAAAMcAeAAKAAA3NDYyFhUUBiMiJk4iNCMkGBojPBoiIxgaIyQAAAAAAQA4/wYBvALuAA8AABciJjU0ADc2Mx4BBxQABwZLBwwBXAMFDQgMAf6lBQf6DAcKA70ECgEMBwX8RQoKAAAAAAIAJ//qAcwCmgAUADEAABM2MzIXFhcWFRQHBgcGIyInJjU0NiUmIgcOAQcUBhUUFx4BFxYzMjc+ATc2NTQmNS4BYDhhSTcbEyUrHDYqK3M1KxkBAR1UHhYQAgECBBAWGyopGxYQBAIBAhACSVEyGipTkZtSOhoVaVKbXXk/ICAXQlEGQhZgJkY9Fh4eFj1GJmAWQgZRQgAAAQBTAAABqwKaACEAACEmIyIHIzUzMjc2NxEiBwYHIzUzNjc2NzYyFxETFjsCFQGgEY6MEQwaOhEIEAIGLjkTE1Q4Eg0CFAcBDzIhGgMDLgMBCwIFAxIBLgMjCg0DBv7V/tQPLgAAAAABADIAAAHBApoAOQAAEyImNTQ2MzIWFxYVFAcGBwYPARcyNzY3Njc1MxUOAQcVITU0NzY3Njc2NTQmIyIHBgcGFDMyFhUUBm4cIG1MVnENAiMcVSRAO0ydCgQGBAooARkC/o0CAVNtH0NFPjokAgQDBRkfIQGtJBpIZ11LEg86MypJHz04AQUBFAs5AwMDsQMDExQDAV55J1tMQlk0BAcFAiQYGSMAAAABACr/6gHJApkAVAAAEyImNTQ2NzMyFxYXFhcWFRQGDwEUHgEXFhUUBw4BIyImJyY0NjMyFhUUBg8BFjMyNzY9ATQnJi8CJjU0NjMyNz4BNTQnJiMiBw4BDwEWFx4BFRQGfxsfWjsPIwkhIkIRA0k3AxMnElITGG1DQmYSCiUaHCQaFgc2RjccEUAPLioDAgYCHB4sLiMVGjImBAoDAwMEFBshAc8iGzlNBwEFECE9ChE7XRQCAQUPDDVXKSYzQzgvFTgjJBsXIgUCLTUhRBRfIAYBAQIDDQwGBQZXPUEWDhsCCQQEAQECIhYYIQAAAAACABwAAAHXAqUAIwAnAAAhJiMiByM1MzY3Njc2PQEhNTc2NzY7ARcRMxUjFRQWFxYXMxUnEQMXAc4Oc3gOCR8rCggEAf79l5kCAhMSBlxcAQUIMR2y220DAy4BBAIIAjQyLufoAQIG/jQuMykOBQcBLtMBTv6zAQABADL/6gHBApoASAAANzIWFRQGKwEXHgEzMjc2NTQnJiMiBw4BIyInJjU0JjU0MzYzFxYzMjc2MzIdAQYjIi8BFTYzMhceARUUBiMiJyYnJic0JjU0NmsYISIVBwMPPipHHxMbGiZOKAQHCxECAgEGAgISQURHQQgFCFF8HxkKOTwTFkNVf10/LBMOHggBINYhGRcgBSAqPCVbZyQhRAcDBgSrHlILOAIGGhwEEg1hBgKsLgURdk9bhCMMFSQ1Aw0DHCAAAgAq/+oByAKaAC4AQwAAASYnIgcGFRc3NjMyFx4BFxYdARQHBgcGBwYjIicmJyY1NDY3NjMyFhUUBiImNTQXJiMiBwYVFBceATMyNz4BPQI0JgF1FihGLy8BCClGLiMYMA8VBQwyKzUQGBMPSiw7TEQ2PzpHHTAdAxwsJRcxDAowITMbDwgIAlkWAzxBiQQNPBMONR4xOhIXFDs0LQsEAw5CXZ9soi0mPjYZHhwZLegkFzFtWSIeKiYVOjcQEDk6AAAAAAEAN//qAeUCpAAyAAATNj8BNDsBFRQeATsBFQcOAgcGBwYHFAYdAQ4BIyImNTQ3Njc2PwEjIgcGBwYHBgcVIzcBEBAUFB5Lg3lEDyYUAjQKBAEBBB8SGB0ED04UQC5drgkEBwYEAgEoAcoCa2sCBAoOBCddFTMcA1GIKUcOHQkJERghHQ8qh4ggWT8GAhQUGxECAwADACv/6gHJApoAJAA3AEwAADc0NycmJyYnJjU0Nz4BMzIWFxYVFAcGDwEXHgEXFhUUBiMiJyYBNCYnJiMiBwYVFBcWHwE+ATc2ARQWMzI2NzY1NCcmJy4BLwEHBgcGK4ESFQYrDAIQFlU3RGQMAQIPTAwODh0BS3dZezoZAUg4KAcaNSQZJAU7OgEYBjb++FY5KUMRESMISw4hCQgMPxQIm21HDQ0HJToJFisdLTdHOAYSFghCMAgJChQBPFlRc1okAZkrPAgBJBcgKxkFJSYBDwYr/to7TSIbGh0rIQgxCRUGBQYpOxoAAgAq/+oByAKaADMASAAANxQGDwEUFhcWMzI3Njc2PQEHBiMiJy4BNTQ2NzY/AToBFjMyFxYXFhUUBw4BIyImNDMyFhMmIyIHDgEVFBceATsBPgE1NCcuAa0VEQQOBBciEwcwIScFKUpQOB0ZHyY0SAMDBAkDFQhRLis8I2M2P001Fx1lChImGxUNBQUxJgQ2MQgFJ2AVHAMBAQkBCgIMMjiKBwhERSRENDpKJjQHAQECElVXi4xhOD87cBwB9gIbFj1KRCgmLwVnSk4iHS4AAAIATgAAAMcBrgAKABUAABM0NjIWFRQGIyImETQ2MhYVFAYjIiZOIjQjJBgaIyI0IyQYGiMBchoiIxgaIyT+4hoiIxgaIyQAAAIATv8+AMoBrgAKACMAABM0NjIWFRQGIyImEDQ2MzIVFAcGBwYiJicmNzY3PgIjBgciTiI0IyQYGiMhGkEEDjYJBhICAQstCgEDAgETBBwBchoiIxgaIyT+yDQjcRwUUUAJEAQEDTg/BhQQAwEAAAABAFP/2AK2AhwAGAAABRQGIiQvASY1NDcAMzIWFRQHBg0CBBcWArYJDv7aj5AHCAI9DgcJBwH+8/72AQoBDQEHEwYPikRFBQoLBQESDwYIBgGAfn6AAQYAAgA4AIUC0gFvAAoAFwAAEzQ3IRYVFAcFISYVNDchHgMVFAchJjgOAn0PDv7C/sIQEAJ8AQcDAw/9gw4BWw0HBw0LCAEFsw8FAQUDBwQNBwcAAAAAAQBT/9gCtgIcABgAABI0NjMyBB8BFhQHBg0BIyY1NDc2JTcnJCdUCQYHASaQjwcHAv7e/uAGEgMEASD4+P7gBAIBDg2KREUFFAUCiYgCEgUGBYh2dogFAAIANwABAaACwQA+AEwAABIiJjU0NzY3MjY7ATIXFhUUBwYHBhUUBgcGIyInJjU+ATc2Nz4BPQE0JyYjIgcOBQ8BFx4DFxYVFBMeARUUBwYjIicmNTQ2hC4fPCctAhIFBIUoDzdeFAUCBAMLEAMBAQ8UFh0SChIZMDglAQMEAwQCAQEDAwoLCwMHPhkgGw0TFA0bIwICHRdIIxoFAU8cHz8qQ1wYJhwMAgEFAiw8QCkqIBMfJA0rEhQcAQMDBAMDAQEBAQMFCwYMDxf+WQIfGyQPCQkPJBwgAAIAOP/1AtICwQBcAHAAAAEUDgIjIicuAS8BBgcGIyInJicmNTQ3Njc2MzIfATMyFxYXFhUUFxYzMjc2NTQnJicmIyIHDgEVFBceARcWMzI2PwEzFhUUBwYjIicuAScmNTQ2NzYzMhceARcWJSYjIgcOARUUFxYzMjc2PwE1JyYC0gkWMCNFGgEBAQEFBy5CEwaBIgclLlcGE1g3AxgZAgQBAQUIEg8KJiMwWjw9PDxNXw0XfVYUIT2QMQc7BlN5fk1ETGYMAbJ/CBFMRExmDAL+ywsPCgMuNiMiLwsMNCEGBiEBXTBHRCQyAQQBAQUGLgEegRwhTjRJEQFTBgEBCQ50jw0TBxqGYEpfLB0dJpdnMy5TeRAEIBcDBgQJICwiJpJhCiGSxwwBIiaSYBagAwELakNTMjQDDjgKzAo4AAAAAgAgAAACzQLMADMAOAAAISYjIgcjNTM2NzYaATc2OwEWFxYbARYXFhczFSMmIyIHIzUzMjU0LwEjBwYVFBceATsBFRMLARQzAP8SYVkMBw9IFAFoZwEDEAkUBAJqbQMECzQeCQ9wgQ8KDUYYGOkUFAMGJxYFt2ZlZQMDLgMnAwE1ATMBCAEGAv7D/r0GBAoBLgMDLhICSEc7OwYFBA0RLgD/AS7+0wEAAwAcAAACiwKrACQAPABOAAATLgEnIzUzFhcWFxYXFhUUBg8BHgEXFhUUBw4BBwYHIzUzPgE3ATQmJyoBJiIGIiMGBwYdATM/ATY/AT4BEzQmLwEjFRQXFhcWOwEyNz4BgwoTKSHJyQ02IjoXDFJCCkZlDQECDWJFDdbWISkTCgF8NSoBGSckJxoCDQMDU1QKAwcGJzIaPC9lZAECAgZeMSoSKzMCbgoEAS4BAgkUITMbHDNVEAMITjwGEhcIO1QKAgEuAQQKAcQvRAgBAQEHBH19AQIBAgIORf7rOVALAYmLAgUCBQYOSgAAAAABADj/6wKaAsEAPwAAARcVDgEHBiMiJy4BJyY1NDc+ATc2MzIWMzIXFh8BNzY3MjYzMhcRByMmJy4BJyYjIgcGFRQXHgEzMjY3NjU0NwKUBgVsVR0kJRpwmRIBARGacCATAgwDGApJNg0eGwQBBgMHBgYiBgEJTjgTH2hGTyYfc0dJbAwFBgEBBg9aihYHBhaofAkiIQp6qRcGAQINNQwnJQQBBv7oBgYLUngTB0ZPp3lGO0RpRxkTBwYAAAIAGwAAAsQCqwAaADYAABMuAScjNTMeARceARcWFAcOAQcGByM1Mz4BNwEqASYiBiIjBgcGERAXFhcWMzI2NzY1NCcmJyaCChMpIcmrKBZihQ4CAg6ObA3JySEpEwoBCQIXIhwiFgINAwMBAgoIV0FLJE4HEE0sAm4KBAEuAQEFFaZuFC4Ub6ESAgEuAQQKAj8BAQEHBP7o/uYDCQICFB1BskQkbDQdAAEAGQAAAowCqABKAAATLgEnIzUhFRcWHQEjNSYnLgEnJiMiBwYHBh0BMzY3PgE3NTMRIzUuAScmJyMVFBcWFxY7ATI3PgE3Njc2NzUzFQYCBxUhNTM+ATeAChMpIQI8Dg4oAQIMQ1IKOmQICQMBNkEPHBQCKCgCFBwPQTYBAQMGLjNaDjpBEQ4JBAEoAScC/bchKRMKAmsKBAEuBHRzAQQEAxJeRQUBAgEKAnp5AQUIKSoU/ugUKikIBQGGhwIFAgUBBy0uJTwZAgMDA/77AwMuAQQKAAAAAAEAGQAAAmICqABBAAATLgEnIzUhFRcWHQEjNSYnLgEnJisBIgcGBwYdATM+Azc1MxEjNS4DJyMVFx4BFxY7ARUjJiMiByM1Mz4BN4AKEykhAi0ODigHAgkvMhpfMCsGAwEBNComIQsCKCgCCyEmKjQBCBAcCyUbDBqMfxMLISkTCgJrCgQBLgR0cwEEBDEIOTwKBQUCBQKBfwEEFCUiFf7oFSIlFAQBgIAIBQEBLgMDLgEECgAAAAABADj/6gLfAsEAWQAAARYzMjYzMj4BOwEVKwEiBwYdAQYjIicmLwEGBwYjIicuAScmNTQ3PgE3NjMyFjMyFxYfATc2NzI2MzIXEQcjJicuAScmIyIHBhUUFxYzMjY3Nj0BJicmKwE1AcEYiAolCgsgEAIIDgokBwIGAwQOFhENE0AwMiUdcJkSAQERmnAgEwIMAxgKSTYNHhsEAQYDBwYGIgYBCU44Ex9oRk9LSG8vRwoDEAgROhoBEQMBAQEuDARnZgYKDxEMIBwQBxaofAkiIQp6qRcGAQINNQwnJQQBBv7oBgYLUngTB0ZPrpxOTSoiCjI0CwEDLgAAAAABABkAAALUAqsARQAAEy4BJyM1MxYyNzMVIw4BDwEVITUuAScjNTMWMjczFSMOAQcRHgEXMxUjJiIHIzUzPgE3ESEVFx4BFzMVIyYiByM1Mz4BN4AKEykhCxH+EQshKRUHAQEdChMpIQsR/hELISkVBwcVKSELEf4RCyEpEwr+4wEHFSkhCxH+EQshKRMKAm4KBAEuAwMuAQQKenr0CgQBLgMDLgEECv3PCgQBLgMDLgEECgEPh4gKBAEuAwMuAQQKAAAAAQAVAAABUwKrACkAACEmIAcjNTMyNzY3NhEQJyYnJisBNTMWIDczFSMiBwYHBhEQFxYXFjsBFQFIEP74EAsWJxsMBQICBQwbJxYLEAEIEAsWJxsMBQICBQwbJxYDAy4DAwgDARcBFgMIAwMuAwMuAwMIA/7q/ukDCAMDLgAAAAABABn/6gHRAqsARQAANzIWFRQGBwYXFhcWMzI3PgE3PAI2NDU8AiY8AT0BJicmKwE1MxYzMjYyPgE7ARUjIgcGBwYQBw4BIyImIy4BJyY1NDZZGyQdFQMCBRceHw4JHScFAQEGExI9HAwXjwooFiESAggQGxUIBAEBCnBHBhkDNkgIASSxIx4YIAQBAgYODgMJOikBHzI8TCIZNS4sIhoIBwoDAy4DAQEBLgMDCAL+Fgg/UgIJPiwFCh8kAAEAGQAAAuACqwBfAAATLgEnIzUzFjI3MxUrASIHBhUXNzY3Njc0JyImKwE1MxYzMjYzMj4BOwEVIwYHDgEUEhcWFxYXMxUjIi4BIiYjIgcjNTMyNTQnAw4CDwEVFBcWFzMVIyYiByM1Mz4BN4AKEykhCxH+EQsWGDYCAQGSkgICAhwCBwEEChFyCBwHCBYMAQYOSywFstsGCg4SKhUIAg8fFCQJehULCC4DsAkTGAYuAwg7IQsR/hELISkTCgJuCgQBLgMDLhECnJuOjwQDCBYHAS4DAQEBLgQkBawC/rcJDwgKAS4BAQEDLhoGBgELCBIXBi1fXgQLAS4DAy4BBAoAAAAAAQAZAAACRgKrAC8AABMuAScjNTMWMzI3MxUjIgcOAQcDEBcWFxYzMjc+ATc0PgE0OwEVBgIHFSE1Mz4BN4AKEykhCxKAlBIMGyULHBAIAQEBAwZGRxo7OAsDAxQUAhgC/e8hKRMKAm4KBAEuAwMuAQEFCP7o/ugDBQIFBhFOSQUZFAIFA/7/AwUuAQQKAAAAAQAdAAADdwKrAEwAABMuAScjNTMyHwEWGwISNzY3NjsBFSMOAQcRHgEXMxUjJiIHIzUzPgE3ETwCNScCBwYiJyYLARUGHAEVExYXMxUjJiMiByM1MzY/AYQKEykhamkEBQFoaGhoAgEDBGlqISkVBwcVKSELEPgQCyEpEwoB6QQEIAQBdXQBAQxJEQkNZmgNCBFEDwMCbgoEAS4DBQH+7P7uARIBFAECAwMuAQQK/c8KBAEuAwMuAQQKAR5NSmATE/2WBwYGAgEzATQSElpGSP7yJAQuAwMuBB4GAAEAGQAAAtQCqwA0AAAhJiMiByM1MzY/AREjJisBNTMXHgEfAREmJyM1MxYzMjczFSMGBwMRByMiJyYAJxETFhczFQEJDWZoDQgRRA8DBAo+G88DAqtVVRNDEQgSY2YNCRFJDAEHDg8DBv5wBQEMSREDAy4EHgYCJAMuAwH7fX0BpCQDLgMDLgQj/tj+2AYDBgJMCP78/v0kBC4AAAIAOP/qAtICwQAZADAAAAEUBiMiJy4BJyY1NDc2NzY3NjMyFxYXFhcWAyYjIgcOAQcGFRQXFjMyNzY3NjU0JyYC0sSKGhdqmRMFUh8WS2AJEW1aFh5CDwL/KSYoJTVFCgVnMT8WBkQ0QgUVAVWX1AQRoXEZKodqJBA+CQFIESNSdBIBGhISGmtLHDnTUikBDkBYpzkcmQAAAgAbAAACcAKrACYAPAAAEy4BJyM1MzIXHgEXFhUUBw4BBwYHIxUUFxYXMxUjJiIHIzUzPgE3AS4BKwEiBiIjBgcGHQEzMjc+ATU0JoIKEykhu8AHTXcNAgIMYD8WZV4DCDshCxH+EQshKRMKAVgaNzwaDBkSAQ4DA0dNBkM3DQJuCgQBLgEGWkMIFhUIOVMNBQF4dwQLAS4DAy4BBAoCHxYLAQEHBI2NAQZCSS8zAAADADj/PwLYAsEANgBXAGUAAAUiJjU0NzY3Njc2NzYzMhcWFxYXFhQHBgcGBwYVFhcWMzI2NzYzMhcHFAYHBiMiJyYnJjUHDgEnNDYzMhcWHwE2NzY1NCcmJyYjIgcGBwYVFBcWMyc0NSY3FBYzMjc2NTQnJiMiBgGEisIBDkMfFktgCRFtWhYeQg8CAg5GKjoNDQUdLSYyAwEJBQcBNSsGEykZHA4PDAwwbjUlERclGwYMGEY1NloHDUE2ERJCaxgEAQMlGhUhGxsLFDcVGxbUlyEJcFYkED4JAUgRI1J0EjASdlQxIQYBGggyJyINBRJHYQoCGRo7PA8DAwhaJTIJEzkMCBpVoo9UVQ0BLQ4WWJ3EVhIDAgIHDhUcCgkDChMwHwAAAgAb/+oC3AKrAFAAZAAAEy4BJyM1MxYXFhcWFxYXFhUUBgcOAQ8BFhcWFx4BFx4BFxY7ATI3Njc0NjMyFhUUBgcGIyYnLgEnLgEvAiMVFx4BFzMVIyYjIgcjNTM+ATcBLgEjIgYjBgcGHQEzMjY3PgE1NIIKEykhr7oTAwotI18OAVU6AgUCAgMISBEBFAEHFREEDQUNCxQDBw0MCCMZEBqVFwIBBgkpGgpCQgEHFSkhCxB+fxALISkTCgFoCldZDyYBDQMDOktIGxELAm4KBAEuAQMBAgkTMFMFCzhUEwEBAQEDAyhCBHwEJCIGAgsUKAsHBQokOwsGBmoLfBUbJwgCAYODCgQBLgMDLgEECgHePCYBAQcEhIQNGxEqKCAAAQA3/+oB9ALBAFUAADcWFRQWMzI3PgE1NCYnJicmJy4BNTQ2NzYzMhcWFzc+AT8BMjYzMhcVByMiJicmJyYjIgYVFBYXHgEXHgEVFAYHBiMiLgMHDgIVBiMiJzU0NzYzWQZzXwwELDctIzgSSwI6TD4uKChPMQ8TFQULBAMBBgMHBgYSCwQDEVQlJjRDIh8KmAg5SVpJCholPyYcDAEEFhICCAcGAQIS4wYHWWUBCUgxK0cMDgUSARRlQzxeFxQiChMfBxAFBAEG7QYGEX4pEEM1IjkQBCYEFmlHUnEPAg4SEwwBBR8ZAQEGdXcCBQAAAQAkAAACrQKlAD0AABM+AT0BIRUeAR0BIzUmJyYnJicmKwEiBgcGGQEWFxY7ARUjJiAHIzUzMjc2NxEQJy4BKwEiBwYHBgcGBxUjJAESAmMBEigBAgcZESYVOBsXCwMBCBEkNh4NFf66FQ0eNiQRCAEDCxcbLworGSAIAgEoAbsC4AIGBgLgAgYGBBRhHRULBQMJAv7r/uwLAwMuAwMuAwMLARQBFQIJAwEHFRtrFAQGAAAAAQAZ/+oC1AKrADkAABMuAScjNTMWMjczFSMOAQ8BFBcWFxYzMjc+ATc2PQEmJyM1MxYyNzMVIwYPAQYHFAcOASMiJyYnJieAChMpIQsR/hELISkVBwEECSMtQBEQPE4LBBNDEQkN0A0JEUkMAQEDAhF8VUE8cBYBAQJuCgQBLgMDLgEECszgGUElKwMLUUAXzLwkAy4DAy4EI8fNDgEIUHEfOn0J0wAAAQAT/+oC2gKrADIAABMuAScjNTMWMzI3MxUjBgcGFRQSMzc2NTQmKwE1MxYzMjczFSMiBxQCBwYrAiInJgMCcgsSJR0JDm54FgsVLgsEtAFWVSoZBQkRYlYLBgdKFuEBAw8JCQ4DAnN1AmwLBQEuAwMuAQoDAwL+FOjmCRMVLgMDLikB/aABCAgCATsBOgAAAQAS/+oD8QKrAFIAAAEWMzI3MxUjBgcGBwYKAQcGIyInJi8BBwYHBiMmJyYCJyYnJisBNTMWMzI3MxUjIgcGFRQfATc2NScmJyYnIzUzFjMyNzMVIyIVExI1NCcmJyM1AxgSaE0MBg0wFggDA2JgAgUREgMCTk9PTgIEFBEEAcoDBgsOJhEJKlV2DwsNLhAKTEs/QQ8JBAouHAgOankVCg1Hl44CEDkLAqsDAy4DFggGB/7O/tQCBQcC9Pbz9QQHAQYBAngECgEELgICLggDBgTr7cPNAi8cBAsBLgMDLhL+JwGyFAIEHAMuAAABABcAAALWAqsAXwAAISYjIgcjNTM2Nz4BNTQCJyYrAjUzFjMyNzMVIyIGBxQWMzI2NTYnJicjNTMWMzI3MxUjBgcGBwYVFBIXHgEXMxUjJiMiByM1MzI2NTQmLwEHDgMHBgcGFRQWFzMVAQ4NdGIMCBFZIASfsgMSNg4UCQ9vfBYLBREqAncCAWgGDQ8fCAkNdGIMCBFSIgNGQs0DCBwnHwkPb3sXCwYRKkglJQMCCg8WD0IBASAWCAMDLgMnBvQBAgEWAw8uAwMuCwUDu6EBCw0RAy4DAy4DIwNpZwEC/sADCQYBLgMDLgsHA3I5OQMCDhcjF2QDAQcOFgIuAAAAAQALAAAC4gKrAEAAACEmIyIHIzUzNjc2PQEnJicmKwI1MxYzMjczFSMGBxQfATc2NTY1NCcjNTMWMzI3MxUjBgcGDwEVFBcWFxY7ARUCBhCAfhALITsIA2doAw4wFRQJEHB8FgsSMANVVkxOAi4JCQtiRSQHD1MbAV9cAgMODy8WAwMuAQsEaWqtrgMOLgMDLgEPApCPgIMBAwkdBC4CAi4ELQGgmmhpBAgDAy4AAAABADcAAAIwAqsALQAAEzQ2NSEWFRQHBgAGMjM2Nz4BNzY3NTMVBgIdASMvASY9ATYaATUiBwYHBhUUI0ULAdUGAQL+jAIcOVkJQUQNBgcoARDx8QMDBL24kA1eKCAUAbsJzBsGDQ8BA/2uAgEBCTg5G0kJCAL++wMIAQIFDQ4IASwBJQEBBjk0TAIAAAEAdv8GAP8C7gAHAAAXETMVIxEzFXaJYWH6A+go/GgoAAAAAAEAOP8GAbwC7gAOAAATNDYzMhcWABQGIyInJgA4DAcKBwQBXAwICgcD/qQC2wcMCgf8Qw4MCgQDvQAAAAEAFv8GAJ8C7gAHAAATNTMRIzUzERaJiWECxij8GCgDmAAAAAEAcAITAYMCtgAPAAATNxcWFQcmLwEHDgEPAQYncIkIghoENjU3DRsHCAINAjCGCHwCHQIwLi8LGAcGAhAAAAABAAD/wgHz/+cAAwAAFTUhFQHzPiUlAAABAGoB+QEnArsADwAAEzQ2MzIXHgEVFA8BJyYnJmobERALA3MND0dLAQ4CjxEbCwOVAwENDjo+AQ4AAAACACL/9QHtAcAAPwBPAAASIiY1NDc+ATMyFhceARUUFhcWMzI3Nj0BMxUGBw4BIyImJzUOAQcGIyImJyY1NDc2NzY3MzU0Jy4BIyIVFhUUFzQjIgcGBwYVFBYzMjY3NosuHggNTjhCYQ8FAQEFBg4NBgYoAQIJMCEZJwcDEgQxQTRSDggnFyJEag4GCjIlQxaUAQMCiSYLMCMoOQkCATEgFg4SGx48MA4jYWIhCQ4ODCskJygHHCUjGQQDFQQpLCQTEy8nFw8fBhYiECEmCA8dFqI6AQlIFBkiLjAjBwAAAAIAFP/1AgoCtgAuAEMAABM+AjsBFRQzNjc2MzIXHgEVFAcOASMiLwEHDgIPAiMRECcuAScjNTQzNz4BEyYjIg8BFRcWFxYzMjc2NzY1NCcmYhEoFAEDAQMDN1ISD0dfAg1zVU03BwoCBwUBBRQUAQMXIRICCgom+xgHRioGBR4vDRJAJQgIDAwVArABAwKXmAIDLgMOeVgTEFFvOwcSAw0JAgkBASoBLQQTDQIXFwEBAv7jAzoI8QcwDQQ2CxYjQEolPwABACL/9QGfAcAAMAAAACImNTQ3NiYnJiMiBwYVFBcWMzI3Njc+ATsBFhUUBwYjIicmJyY0NzY3NjMyFxYVFAF1Lh4PBQEJGhczHS8fKUUZEyoQAgYNDgYZMlsyLWMUAQEMRjxJgRYDATEfFhcPBQIBBCAvblIvPQoVOQgEBgMTKEgXM3cGNAdeOzBECQ4XAAACACL/9QIXArYALQA9AAATMhc1NCcuAScjNTQzNz4BNz4COwEREBceARczFSIGByM1BwYjIicmJyY1NDYXJiMiBw4BFRQXFjMyNj8B9Eo6AQMXIRICCgomEhEoFAEDAQMXIRIClQQHCDlJRjY+DgF81y1EMSYZESofLyNAEwQBujFmaAQTDQIXFwEBAgEBAwL+0P7OAxQNAi4KATcHMC83WQgbYYJkPyQaRj5vKSEmIQYAAAACABz/9QGfAcAAJAAvAAAlFAchFRQXFjMyNzY3PgEzMhUUBw4BIyInLgEnJjU0Njc2MzIWByYnJiciBwYHFTMBnwf+5hQkWCsdFAsDBg0UAxNTPBMZOVoTDGxPBApbX1IJQQcONCEUBs71BwcPSiZKIBQgCwYKBAk0QwULUjokJVx/CgFrQm0XAwEwIDkHAAABABoAAAF0AsEAOQAAISYjIgcjNTMyNzY3Nj0BIzUzNT8BPgE3MjYzHgEVFAYiJjU0NyMmBw4BBwYHFTMVIxUUFxYXFhczFQEREm1iDggQHBUIBAFHRwECEFI9AREFIzAcLhwSBAkNGCcKBgFvbAEECAorHwMDLgMDCAKioS5CQwo3RAcBAioiFxwcFxIWAgIEKR4US0IuoKICCAIEAS4AAwAd/zIB5QHFAEoAWgBzAAABNjMyFhUUBiMiJyY3NDc1BgcGBwYVFhcWFRQHBiMiJwYVFBceARcWFxYXFhUUBwYHBiMiJyYnJjU0NzY/ASY1NDcmNTQ3PgEzMhcHFBYzMjY3NjQnJiMiBgcGEy4BKwEiBw4BFRQXHgEXFjMyNz4BNzY1NAFJLDgYIBQQIAUCBQEEBRgUCAICIRsvYDAzCxoJET9UGD0jJwIOPjtTUj0+DgIfDxELJB0sGxVMLzMssCIuICgFAwMMQh0qBQPpFjczHUMNFBcDCDglEiEgEiU5BwIBmSwgGRAUHg4HAQIBAQEEEAUCAgMpMCknRRwUEiMRBgEBAQUJICc7EgYxHh8fHjEGDykdDwgGHzUuJyw3KicfJhp8NjghGxBEET0hHBH+ow8IBgkmFQsJFycHBAQIJxcFDSIAAAEAGQAAAh4CtgBaAAA3FjsCFSMmIgcjNTsBMjc1PAI2PAE1PAEmPAE1LgEnIzU0Mzc+ATc+AjsBETYzMhcWFRQXFhcWOwEVIyYiByM1OwEyNTY1JicuASMiBwYHHAEGFRwBFhQVvAgnDhAIDcYNCBAOJwgBAQMXIRICCgomEhEoFAEDPlJ7DAEBBAgVHBAIDcYNCBAINQEBAQcfIC0iIwYBATwOLgMDLg4ICRwmMTM7GyVTQjcgARMNAhcXAQECAQEDAv65S3EHhIACCAMDLgMDLhACiIcIIB0iIzUBIzYYDyEaFQcAAAACABoAAAD/Ap0ADQAyAAATHgEVFAcGIyInJjU0NhMmIyIHIzUzMjc2NzY1NCcmKwE1NDM3PgE3PgI7AREeARczFYMZIBsNExQNGyOPC11bEggQHBUIBAEECDMLAgoKJBIRJhQBAwUOHBcCnQIfGyQPCQkPJBwg/WMDAy4DAwgCj5YKFBcXAQECAQEDAv6ECgUBLgAAAv/J/zMA2gKdAA0AOQAAEx4BFRQHBiMiJyY1NDYDFjMyNzY3NhAnLgEnIzU0MzcyPgI3PgI7AREOAQcOASMiJjU0NjIWFRSgGSAbDRMUDRsjaR4GDAkqCAIBBBoiFAIEBBASGQwSKRUBBAEBBQ9SOC1EHi4fAp0CHxskDwkJDyQcIPzABQMPSQwBnAYUCwEXFwEBAQEBAQMC/v7cLw8uPS8pFx4fFxkAAQAUAAAB/wK2AGMAADczMjc1PAE2PAI1PAImNDUuAScjNTQzNz4BNz4COwEVFzc2NzY1NCcjNTMWMzI2Mj4BOwEVIwYHBhUUFhceATsBFSMmIyIHIzUzNjU0Jy4BIwcVFBcWFxY7ARUjJiIHIzUkDicIAQEDFyESAgoKJhIRKBQBAwE8PAQGFQUJDWoHFwwTCgEFDUUvSn8HDiMfCwYMS2INCAcYBANeATQBBAgVHBAIC8QLCC4OCAkcJjEzOxslU0I3IAETDQIXFwEBAgEBAwLn5jY2BgkIEgMuAwEBAS4FJz8EAbkJEw4uAwMuAhEHBwWKLjg6AggDAy4DAy4AAAEAGgAAAQcCtgAxAAA3MzI3NTwBNjwCNTwCJjQ1LgEnIzU0Mzc+ATc+AjsBERAXFhcWOwEVIyYjIgcjNSoOJwgBAQMXIRICCgomEhEoFAEDAQQIFRwQCBJcYg0ILg4ICRwmMTM7GyVTQjcgARMNAhcXAQECAQEDAv7F/sMCCAMDLgMDLgAAAAABABkAAAMzAboAhAAANxY7AhUjJiIHIzU7ATI3NTwBNjQ1NCY9AS4BJyM1NDM3PgE3PgI7ARUUMzc2MxYfATY3NjMyFxYVFBcWFxY7ARUjJiIHIzU7ATI1NjUmJy4BIyIHBgcUBhQVHAIWHQEWOwIVIyYiByM1OwEyNTY1JicuASMiBwYHHAEGFRwBFhQVvAgnDhAIDcYNCBAOJwgBAQMXIRICCgolEhEmFAEDAQE2Y2EWAhgDM0R9DAEBBAgVHBAIDcYNCBAINQEBAQcfIC0iIwYBAQgnDhAIDcYNCBAINQEBAQcfIC0iIwYBATwOLgMDLg4ICRwjKxQfRxcXEw0CFxcBAQIBAQMCKCYBTQNJBR4DMHEHhIACCAMDLgMDLhACiIcIIB0iIzUBIzYYDyEaFQcGDi4DAy4QAoiHCCAdIiM1ASM2GA8hGhUHAAEAGQAAAh4BugBZAAA3FjsCFSMmIgcjNTsBMjc1PAE2NDU0Jj0BLgEnIzU0Mzc+ATc+AjsBFRQzNzYzFhcWFRQXFhcWOwEVIyYiByM1OwEyNTY1JicuASMiBwYHHAEGFRwBFhQVvAgnDhAIDcYNCBAOJwgBAQMXIRICCgolEhEmFAEDAQE2Y3MMAQEECBUcEAgNxg0IEAg1AQEBBx8gLSIjBgEBPA4uAwMuDggJHCMrFB9HFxcTDQIXFwEBAgEBAwIoJgFNBG0HhIACCAMDLgMDLhACiIcIIB0iIzUBIzYYDyEaFQcAAAACABz/9gHXAcAAFAAnAAA3NDY3NjMyFxYVFAcOAQcGIyInLgETJiMiBwYHBhUUFxYzMj0BNCcmHHRREAlXQEYFDFk/Fx0eF0te8AULHhs4CwITIEl6BRHWW4MKAkBGYxQbP10QBgYTeQESAQwcURIuXyg9oyBBF08AAAAAAgAU/z4CCgG6AEQAUwAAFzMyNzU8ATY8AjU8AiY0NS4BJyM1NDM3PgE3PgI7ARUXNzYzMhceARUUBw4BBwYjIi8BFRQXFhcWOwEVIyYiByM1ATQmJyImIyIHFRYzMjc2JA4nCAEBAxchEgIKCiYSESgUAQMBCD1NFgpGXgIKTT0eIEQ0CAEECBUcEAgNxg0IAZQ9LAIJA0c0KUcqIjaUDggHGSIsLTUYIko6MR0BEw0CFxcBAQIBAQMCGhoHLAIOelcTEEFeFwosB1VXAggDAy4DAy4BbkVqCAFB70glOAACACH/PgIXAboALAA/AAAlBiMiJicmPQE+ATc2MzIXFh8BMj8BMxEQFxYXFjsBFSMmIgcjNTMyNzY3NjUTJiciJiMGBwYVFBYXFjMyNzY3AXU8TThaGSAEQzQqJh4HQykGARAQJQEECBUcEAgNxg0IEBwVCAQBAx5EAwwCPCkdOCsGEQ8GRSExPDwsOEUGRGcaFAENNwgnJ/7i/uACCAMDLgMDLgMDCAJbAVVZDAECQzFGQmsMAgEQSgAAAAEAFAAAAWwBugBKAAA3MzI3NTQ2PAE1PAE1Jy4BJyM1NDM3PgE3PgI7ARU+ATMyFxYVFAYiJjU0NzY1JgcGBwYHFQYVHAEWFB0BFhcWFzMVIyYjIgcjNSQOJwgBAQMXIRICCgokEhAmFAEDEy4mHBQnHiodCAICFRAIKAYBAQQICisfCRJtYg4ILg4ICRwjKxQfRxcXEw0CFxcBAQIBAQMCRSAkCxQlFh0cFhELBAECBggHJlgnJxwNHRYSBgUIAgQBLgMDLgAAAQAh//UBZwHAAEoAABMiFRQXHgEXFhcWFxYVFAcGIyInDwEGDwEjIic1NDY3NjMyFhcWFxYzMjU0JyYnJicmJyYnJjU0NzYXMh8BNzY3MzIXFQcjJjU0Jr5cAgksLjkVPxIBDidsPCwICQYGCwgHBgEEAg4NBQMIEiM+YRIQGhEfOBRCCwGNBBQoHg8JDQkIBwYGHAY4AZ5BDQQYFQkKDB5FBhInHkokBwkGBQoGT0EUAgEEDCYfM04dEhMIBAcLCh8+BAtzDgICDwgHCwYGhAYGBi40AAAAAQAS//YBTQJnACQAABM1MxUzFSMVHgEXFjMyNzY9ATMVFAcOASMiJicmPQEjNTM2NzaNKIeHAQEGDiMsCgEoBQs1KzZABQFPCSUaLgJYD7gukH0hDydHCCYjIy4UKDI7MweNiSUDHTAAAAAAAQAZ//UCHgG6AEIAABM+AjsBFRYXFhcWMzI3Njc0NjwCNScuAScjNTI2NzMVFBceARczFSIGByM1BgcGIyImJyYnLgEnJisBNTQzNz4BaREoFQEDAQEECxQoHBM6CgEBAxchEgKVBAcBAxchEgKSBAcqJxMiQEYKAQEBAQUKMgsCCwomAbQBAwK1uAYVCg4JHFEBIDEsMRAQEw0CLgoBsrQDFA0CLgoBRTMKBy80B4JtGggQFxcBAQIAAAABABP/9QH8Aa8ALQAAARY7ATI3MxUjBgcGAgcGIyInAicuAicjNTMWMzI3MxUjBgcUHwE3NTQmKwE1AVIFKyQ5GAULOBICgwIFFBMFjAEEDwwYGAYKV18PCA4nAzMzWxoQBAGvAgIuAyUE/q4FCQkBaQUKCAIBLgMDLgEOBISE7wgQFC4AAAAAAQAS//UCvwGvAE0AAAEiFRQSFzc2NTQmJyM1MxYzMjczFSMiBiMGDwEGBwYjIicmLwEOAQcGIyInAy4BJyM1MxYzMjczFSMGFRQfATcnJicmJyM1MxYzMjczFQHEMFoCKSodFAgHDVJEBgUGAQsDLxA8OQEEEhMEATAuFEIJBRITBIIHEBsWBgtRWg8IDiYsLEoGCQMJIhQGCkpdDQcBgRAI/wAFd3oGERMCLgMDLgEHK62jAQgHAYiGNMMYBwgBcwsFAS4DAy4CDwGAftcRGgQJAS4DAy4AAQALAAACBAGvAF8AADMmIyIHIzUzNjc2PwEnJicmJyInIzUzFjsBMjczFQYVFBYXNzY3NjU0Jy4BKwE1MxYzMjczFSMiBw4BBw4BDwEXFhcWOwEVIyYjIgcjNTMyNjU0LwEOAQcGFRQWMzIdAckPVEoLBg5HIQQvLjo7AgkSBh4cByRDLDUGCCQ/CBkbAQQMAgcBBQcNVkwJBgcxIA8WGAcdAhA+QQIPOxEGClZcEgkDCxYoKQE9AwQPCgIDAy4FIQQ+PE5RAgkDAi4CAi4FCwNYCCIjAwcJEAcBAy4DAy4RBxYfCiYDFVVYAg8uAwMuCwYCNzcBUgQHCAsQFxcAAAEAE/80AfwBrwBEAAAWMhYVFAYHBhcWMzI3PgE/AS8BJisCNTMWMzI3MxUjIhUUFh8BND8BNTQmKwE1MxYzMjczFSMGBw4CBwYHBiMiJjU0MCocEAsEBAcNDw4eJBMRSEsHLQkPBwtVXhEICS8zGRkuLBgSAwYJTDcaBQs4EwJUXg8nNgUQKTVCHRUOGgQCAgQGDDgzK7e7Dy4DAy4RDoA5OQFycgkQEy4CAi4FIwLZ6xY8DAExJxcAAAAAAQAcAAABkQGvADEAABM0Njc1IRYVFA8BDgEPARcyNzY3Nj8BNDsBFRQGBxUjLwEmNTQ3NgA3IwYHBgcGBxUjKgoBAVQGARERQyCDMD4YKxQVBwIUFBABr68DAwECAQUCOkMRGQ4YBygBBwKbAwgGCgwBGBdcK7MBAwgaHFAQAQYBvAEGAQIFCQ0BAgFlBAEFBg8XUAkAAAABAEH/BgGyAu4ASAAABRQHIyImJyYnNDUmJyY1LgEjIiY0NjMyNjc+ATc2NzY3Njc2NzI2OwEWFRQHBiMGBwYHBhUUBw4BDwEXHgEXFhUUFx4BFzIXFgGyBhJMbQ0CAQEEAQxEKQsGBgspRAwEAQEBAggYGjYlEAIXBhQGAwIOOCUUBgUBBTsqDg4qOwUBBQpEKQ4CA+cNBjM2B4oVIFkLAQEfLQYaBi0fDBp2iQcgFRoQCAEBBgwNAwMDHQ8TDYeCBic4DQUFDTcoBoKHDRwkAgMDAAEAd/8HAJ8C7gAJAAAWIicREzYzMhcRmBoHAQoJDQf5DgHmAeYND/w2AAAAAQBB/wYBsgLuADoAABM0NjsBMhYXFhIXHgEzMhYUBiMiBgcOAQcGBwYHBisBIiY1NDYzMjY3Nj8BNjcmJyYvAiYnLgEjIiZBBAoJUGoOAwEBCkYsCwYGCydFCwUBAQECCBg2cQsIBQQIMUcKAQEBFGQhETcNAgEBAQpHMQgEAtsNBjYzCf7xCCQ0BhoGLB4NG3WKByAVNAcNCwYqIAWJiFQbCwkhMQqIiQUgKQYAAAABAFMA1wGgAT4AHQAAEzYzMhcWMzI/AR8BFAcGBwYjIicmIyIPAS8BND4BjhYXFS0rGCMaBw4OFCETDhEXKywYIxoHDg4YHQEwDhISHQcMCwEYJwkHEhIdBwwLARwgAAACAF8CKgGUAp0ACwAaAAATNDYzMhYVFAYjJyY3NDY3MjYzMhYVFAYjIiZfIRkYISEZGSDCGxMBCAIXIyMXFiMCZBYjIxYXIwYRIhQhBAEiFxgiIAABADgAWQJjAWQADQAAEjQ3IRYXFQYjIi8BNSE4DgIOBwgNBwoJAf4LAUMaBwMK8Q0Na2sAAQBFAiABrgJOAAMAABM1IRVFAWkCIC4uAAAAAAIAkwIeAWACywARACIAABM+ATMyFxYVFAcGIyImJyY1NBcyNjU0JyYjIiYjIgYVFBcWlAg0JEwaBgYaRyc2CAFnJRofBRgFDQEZFgsMAocdJzcNEhMNNyYeBA4PQBMeKQgBARcbHQoLAAAAAAEAOAAAAtICmgAfAAASNDchNTQ3NjMyFx4BHQEhFhQHIREhFhQHISY0NyERITgOASsCBwoHCAUBASoPD/7WASoPD/2DDg4BK/7VAUAaB5WVBAsGBSV2kwcaB/7vCBgIBxoHAREAAAAAAQDMAfkBiQK7ABAAAAEyFhUUBwYPAScmMzQ+ATc2AV0QHA4BS0cPDgEzNgQSArsaERAOAT46Dg4BQ0cGFQAAAAEAkwAJAnYB6wAvAAAlFAYjIiYvAQcGBwYjIiY1NDc2PwEnJicmNTQ2MzIXFh8BNz4BMzIWFRQGDwEXHgECdgwJBSJNaGlqAwYCCAwCA2doaGcDAgwIAgYDamloTSIFCQwEaGhoaAQdCAwgTWhpaAICDAgCBgZnaGhnBgYCCAwCAmhpaE0gDAgECGhpaWgIAAMAOP/cAtECGQANABUAIwAAATQ2MzIXFhUUBiMiJyYENDchFhQHIRc0NjMyFxYVFAYjIicmAT4mHjQRAyYgMRID/voOAnwPD/2E+CYeNBEDJiAxEgMB0h8oMQgOICYwCNcaBwgYCMQfKDEIDiAmMAgAAAAAAQAaAAAA/wG6ACQAADMmIyIHIzUzMjc2NzY1NCcmKwE1NDM3PgE3PgI7AREeARczFfcLXVsSCBAcFQgEAQQIMwsCCgokEhEmFAEDBQ4cFwMDLgMDCAKPlgoUFxcBAQIBAQMC/oQKBQEuAAAAAf/J/zMA2gG6ACsAABcWMzI3Njc2ECcuAScjNTQzNzI+Ajc+AjsBEQ4BBw4BIyImNTQ2MhYVFBweBgwJKggCAQQaIhQCBAQQEhkMEikVAQQBAQUPUjgtRB4uH6MFAw9JDAGcBhQLARcXAQEBAQEBAwL+/twvDy49LykXHh8XGQABAHACEwGDArYADwAAEzcXFhUHJi8BBw4BDwEGJ3CJCIIaBDY1Nw0bBwgCDQIwhgh8Ah0CMC4vCxgHBgIQAAAAAQByAgEBgQKEAAwAABM/ATIXFjM3NjMXDwFyDQkCNzcCODcCFkNFAmMTDiAfHyAhMTEAAAEARQIgAa4CTgADAAATNSEVRQFpAiAuLgAAAAABAMwB+QGJArsAEAAAATIWFRQHBg8BJyYzND4BNzYBXRAcDgFLRw8OATM2BBICuxoREA4BPjoODgFDRwYVAAAAAQBqAfkBJwK7AA8AABM0NjMyFx4BFRQPAScmJyZqGxEQCwNzDQ9HSwEOAo8RGwsDlQMBDQ46PgEOAAAAAQBcAgMBlwK2ABoAABMeATMyNjc2PQEzFQ4BBwYjIicuASc1MxUUFoIIQC4iOhAOJQQ8LhQbHBQuPAQlAQKjLj4kIR4XBQs5WBAHBxBYOQsFAQoAAQC+AiUBNQKdAA0AABMeARUUBwYjIicmNTQ2/BkgGw0TFA0bIwKdAh8bJA8JCQ8kHCAAAAIAkwIeAWACywARACIAABM+ATMyFxYVFAcGIyImJyY1NBcyNjU0JyYjIiYjIgYVFBcWlAg0JEwaBgYaRyc2CAFnJRofBRgFDQEZFgsMAocdJzcNEhMNNyYeBA4PQBMeKQgBARcbHQoLAAAAAAEAUwI1AaACnAAdAAATNjMyFxYzMj8BHwEUBwYHBiMiJyYjIg8BLwE0PgGOFhcVLSsYIxoHDg4UIRMOERcrLBgjGgcODhgdAo4OEhIdBwwLARgnCQcSEh0HDAsBHCAAAAH+dgH5/zMCuwAPAAABNDYzMhceARUUDwEnJicm/nYbERALA3MND0dLAQ4CjxEbCwOVAwENDjo+AQ4AAAH+2AH5/5UCuwAQAAADMhYVFAcGDwEnJjM0PgE3NpcQHA4BS0cPDgEzNgQSArsaERAOAT46Dg4BQ0cGFQAAAAAB/nwCE/+PArYADwAAATcXFhUHJi8BBw4BDwEGJ/58iQiCGgQ2NTcNGwcIAg0CMIYIfAIdAjAuLwsYBwYCEAAAAf5fAjX/rAKcAB0AAAE2MzIXFjMyPwEfARQHBgcGIyInJiMiDwEvATQ+Af6aFhcVLSsYIxoHDg4UIRMOERcrLBgjGgcODhgdAo4OEhIdBwwLARgnCQcSEh0HDAsBHCAAAf5RAiD/ugJOAAMAAAE1IRX+UQFpAiAuLgAAAAH+aAID/6MCtgAaAAABHgEzMjY3Nj0BMxUOAQcGIyInLgEnNTMVFBb+jghALiI6EA4lBDwuFBscFC48BCUBAqMuPiQhHhcFCzlYEAcHEFg5CwUBCgAAAAAB/soCJf9BAp0ADQAAAx4BFRQHBiMiJyY1NDb4GSAbDRMUDRsjAp0CHxskDwkJDyQcIAAAAv5rAir/oAKdAAsAGgAAATQ2MzIWFRQGIycmNzQ2NzI2MzIWFRQGIyIm/mshGRghIRkZIMIbEwEIAhcjIxcWIwJkFiMjFhcjBhEiFCEEASIXGCIgAAAAAAL+nwIe/2wCywARACIAAAE+ATMyFxYVFAcGIyImJyY1NBcyNjU0JyYjIiYjIgYVFBcW/qAINCRMGgYGGkcnNggBZyUaHwUYBQ0BGRYLDAKHHSc3DRITDTcmHgQOD0ATHikIAQEXGx0KCwAAAAL+hgH+/7ACvQAOAB0AAAEyFhUUBw4BIyY1NDY3NjMyFhUUBw4BIyY1NDY3Nv7cEhwEAlsBIi8EC74SHAQCWwEiLwQLAr0aEQkIBH8RAQKIChkaEQkIBH8RAQKIChkAAAH+fgIB/40ChAAMAAABPwEyFxYzNzYzFw8B/n4NCQI3NwI4NwIWQ0UCYxMOIB8fICExMQAB/YH/Kf90AswAEAAABSI1NDc2ADc2MzIWFRQABwb9lRQFDQG7AgQMCAz+MAQE1xIHBxoDXgIJDAgF/HsCAwAAAQAZAAACRgKoAC0AABMuAScjNSEVFxYdASM1NC4BJy4BIyIHBgcGERMeARcWOwEVIyYjIgcjNTM+ATeAChMpIQIRDg4oAgEBDU9wUQgKAgEBCBAcCyUbDBqMfxMLISkTCgJrCgQBLgR0cwEEBAEIDARnPgICCQP+6f7qCAUBAS4DAy4BBAoAAAIALgAAAxICzAAPABUAADMmNTQANzY7ATIXFgAVFAcBJwMXMzQzBQFTAwQPCRcFAwFTBf7ue/f29wIFAgK4BAcHBP1IAgUCAVj8/ggBAgAAAwA4/+oC0gLBABkAMwA/AAABFAYjIicuAScmNTQ3Njc2NzYzMhcWFxYXFgEmIyIGIwYHBhUUFx4BFxYzMjY3NjU0Jy4BAzUzFTM1MxUjNSMVAtLEihoXapkTBVIfFktgCRFtWhYeQg8C/tAMFgQMAls2NQgNTjkgIDNcHjEbFVr5KPsoKPsBVZfUBBGhcRkqh2okED4JAUgRI1J0EgEsAwEOV0+UQSdNaxcMOTJThWFMO1X+d58iIp8iIgABACAAAAKVAswANwAAATY7ATIWFxYaAR4EMhYyOwEVIyYjIgcjNTMyNSYCDwEGFRQXHgE7ARUjJiMiByM1MzY3NhIBQAYNCQ4HAwJjZAQEBAgECwYQBBsID2p4FgsNSAGSAUZFAgYnGAUIEWJRCwYNQw8BwALECAIGAv7B/r4GBQMCAgEuAwMuEwUB1gHf3QsDBA0SLgMDLgUoAQJnAAAAAwAqAAACcAKlABMAHwA2AAATNzQgFRcUIjU0JicmIAcOARUUIhc1MxUhNTMVIzUhFQMnMzIVFBceARcWMzI3PgE3NjU0OwEHLwgCLAgoCAcO/k4OBwgoXCgBNCgo/syBCBQUBwMGCh3ExRwKBgMHFBQIAf2nAQGnAQITOQMFBQM5EwL4uTMzuTMz/vy0Ai0cDAYBAwMBBgwcLQK0AAAAAAEAGQAAAtQCqAAuAAATLgEnIzUhFSMOAQcRHgEXMxUjJiIHIzUzPgE3ESEREx4BFzMVIyYiByM1Mz4BN4AKEykhArshKRUHBxUpIQsR/hELISkTCv7jAQcVKSELEf4RCyEpEwoCawoEAS4uAQQK/dIKBAEuAwMuAQQKAj3+4v7hCgQBLgMDLgEECgAAAQA3AAACmgKrADgAACUOAQcVISImJzUmPwE+AT8BAyc0NzYpARUUFh0BIzUuAScmKwEXHgEfARYHAzI3PgE3Njc0Njc1MwKaAhkB/uHcSQEDAxAQQB17+QEFAwEgAR8cKA4/VSeDaWgYNg0OBAP1/RU9PhgmCwEBKPcD7QMEAQQBBgUTEkghjAFZDhMEAgQB5gEEBGBRCQSPIUwTEgcE/ugBAxIYKFwDCAIDAAEANwAAAtICwQBJAAATIyImNTQ2MzIeAh8BNjc2NzYzMhceARUUBiMiJzQmNTQmIyIHBgcGHQEeARcWOwEVIyYgByM1MzI3PgE3NTQnJicmIyIGFRQGTgULB1A7LkooGwQEAQIZNy9BHxohMAcQEwMBNSM0HzIMAQgQHAslGwwT/tYTDBslCxwOCwQSZgYSIzUKAhgFCkFZMENEGBgBDnI3Lw0RTi4LBAUBBQEeJiI0fxKjoQgFAQEuAwMuAQEFCJSuILYSASYeCAQAAAMAOAAAApkCqwBJAFQAXwAAISYgByM1MzI3PgE3NSMmJyYnJicmNTQ3Njc2NzY3MzUuAycmKwE1MxYgNzMVIyIHDgEHFRceARcWFRQHDgEPARUeARcWOwEVARQWFzMRIyIHDgEXPgE1NCYnJicjEQIOEv7aEgwbJQscDgsCAQ9IPlYRAQERVj5IDwECBgUMDw8LJRsMEgEmEgwbJQscEAgOTXsZDw8Ze00OCBAcCyUb/pBERQUDChQ4NfVFQzw9DgEFAwMuAQEFCFkBAggiMEoGExIGSjAiCAIBWQUDBAEBAS4DAy4BAQUIWQIKRjEcICIbMUYKAlkIBQEBLgFWRkoKATMGDkbZC0hHQ0cMAgH+zQAAAAEANwAAAtICqwBgAAATIiY0Nz4BMzIXFhcWFxYXFh8BMj0BLgMnJisBNTMWIDczFSMiBw4BDwEUMzI3Njc2NzY3NjsBFxUGIwYHBgcGBwYPARUXHgEXFjsBFSMmIAcjNTMyNz4BNzUmJyYnJkUJBQEDDSMrByMMCgEDNhsfCQEGBQwPDwslGwwSASYSDBslCxwQCAEBBRZbBQEKDCMHLCwHCAYXCw0BAw0tlA0BCBAcCyUbDBL+2hIMGyULHA4L2AcBDQsB/QYWAwQCAgkqGDp/NhoJA9fXBQMEAQEBLgMDLgEBBQjX1wstozoYKgkCBhkGAxgZMzsoghgCLS0IBQEBLgMDLgEBBQhaHOMzGRgAAQAsAAACpQLAAGAAACUUByM1Ji8BNTMXFBcWFxYXFhczNSYnJicmJyY1NDc+ATc2OwEyFxYXFhUUBwYHBgcGBxUzNjc2NzY3NjU3MxUHBgcVIyImJyY1NDc2NzY3NjU0JyYjIgcGFRQXFhcWFxYBDge6AQ8RKAEEBwgEAw02LAURECdAEAoIFo5fBgkPjVo5EggKEEAnEBEFLDYNBAMHCAQBKBEPAVxKFwICCQgfIAoHZyoqZjYfBgogHwgJFA0HAgFWVgIFBQ4tDwUCBQEDECUfPWc2JSAeG0ttCAFNMkIbHiAlNmc9HyUQAwEFAgUPLQ4FBQJWVgECAQUECh0yKF9hNyobjTQUVTFOIiQ3YV8oMQAAAQAAAPgB8wEdAAMAAD0BIRUB8/glJQAAAQAAAPgD5wEdAAMAAD0BIRUD5/glJQAAAQBAAXsAxgK2ABwAABMUBiMiJyY1NDc2NzYzMhYVFAcGBxQzNjc2MzIWxiIZJhUQAgwtHwYDEwxBBAEDBA0QGiIBuBkkJx8tEw5MOSITAwQMQlkMAgIHIgAAAAABAE4BewDUArYAGwAAEzQ2MzIXFhQHBgcGIyImNTQ3Njc0IwYHBiMiJk4iGhgVHRsUHQ8DBBMMQQQBAwQNEBkkAnoZIxMhfjQpHQ8TAwQMQlkMAgIHIwAAAgCAAXsB0gK2ABoANgAAEzIWFAcGBxQzNjc2MzIWFAYjIicmNTQ3Njc2FhQGIyInJjU0NzY3NjMyFhUUBwYHFDM2NzYzMt8EEgxBBAEDBA0QGiMjGSYVDwEMLR/5IxkmFQ8BDC0fBgMTDEEEAQMEDRAaArYUBgxCWQwCAgcjMiQnHS8aB0w5IuUyJCcdLxoHTDkiEwMEDEJZDAICBwAAAAIAIgF7AXQCtgAbADcAABM0NjMyFxYVFAcGBwYiJjU0NzY3NCMGBwYjIiY3NDYzMhcWFRQHBgcGIiY1NDc2NzQjBgcGIyImIiEaGBUeHBQdDwYUDEEEAQMEDRAZI8whGhgVHhwUHQ8GFAxBBAEDBA0QGSMCehkjEyI+PTYpHQ8TAwQMQlkMAgIHIxoZIxMiPj02KR0PEwMEDEJZDAICByMAAAAAAQA3/ygBhQLBAEEAABM2MzIeARcHFAcGBxU2NzYzMhYUBiMiJyYrARUWFxYVFAcOASImJyY1NDc2NzUjIgcGIyImNTQ2MzIXFhcnJicmNbYNGwwQBwYBCwoBERkqFhIZGBMYKCIFAwUFDRIDBhwGAxINBQUDBSIoGBIZGBMWKhsQAQEKCwKjHgoJCxQkSEAdBQMIDBckFw0JByMcPje7zioGBirOuzc+HCMHCQ0XEhEYDAkCBR1ASCQAAAACADf/MwGFAsEARQCAAAATNDIVFAcGFRQzMj4BNzYzMhYVFA4BByMiJy4CIwYVFBcWFRQGIiY1NDc2NTQjIg4BBwYrASY1NDYzMhceAjM2NTQnJhE0MhUUBwYHFTMyNzYzMhYUBiMiJyYrARUWFxYVFAYiJjU0NzY3NSMiBwYjIiY1NDYzMhcWOwE1JicmtVILDAECChUILRITGAgJChEZJQgVCgIBDAsWJhYLDAECChUIJRgRHBgTEi0IFQoCAQwLUgwHBAMFIigYEhkYExgoIgUDBAcMFiYWDAcEAwUiKBgSGRgTGCgiBQMEBwwCki8vHDc9EQEDBQINFhMLEAcGCwIFAwECDD83HRYZGRYdNzwRAQMFAgsOGhMWDQIFAwECDT83/lQvLx07KBoHCQ0XJBcNCQcaKDsdFhkZFh07KBoHCQ0XEhEYDQkHGig7AAADAE4AAARFAHgACgAWACEAADc0NjIWFRQGIyImJTQ2MzIWFRQGIyImJTQ2MhYVFAYjIiZOIjQjJBgaIwG/IxkaIyQYGiMBvyI0IyQYGiM8GiIjGBojJBgaIiMYGiMkGBoiIxgaIyQAAAEAHgArAQYCMAARAAATMhYVFAcGAgYjIicmNTQSNzbGGiYCAa0EAwcQGm8FDgIwJBcFCgf+UAQFCQQHAcIKIAAB/ikCBP/jAsoAIgAAAzQ2MzIXFhcWFxYVFAYHBgcOAyMiJjU0NyMnJjU0NyEmewsJBwUFBQofCwYLKyACBwMGBAcNL6urDQ0BZxgCtggMBQQPJRQHCwkGBhYpAgkCAgsJEygBCQoHDSYAAAABACr/8wIyArcAawAANxM0JiMiJyY1NDc+AT8BNTQnJiMiJjU0Njc2NzYzMhUUBgcUMzIXFhUUDwEjBw4CFRQ3NjMyFhcWFRQHBhUUMzI3Nj8BOwEyFRQHBgcGIyImJyY1NDc2NTQjIgcOAQcGBw4CBwYHBiMiJip8ChsmBQwEBhAmLBIJFg8JCwIDTUYOEhMDTk0JDgkJsA8ECQULMz4tQQsHMhcOFRMTDwkWEwwLJ0oMCx41CgQRMygcIBMtCwYgCBEJAQoGERYRGBoB+AQBBAkOCAcKAwIDBBACAgQHBikEBAMHCwJNCAUGCQ4LCwZDDyMSAQQJJSQeFxMzjUATDhgTKxYIChpgFgMgGQgZFDOKMzEQCS4XB4AdQyUDDgMQFQAAAgA3//YCtQLBADcAhAAAEzQ2MzIXFhceATMyNjU0NjsBMh4BFRQHBiMiJyYnJicmIyIHDgEHBhUUFx4BMzIWFRQGIyImJyYFIiY1LgEjIgcGFRQXFhcWFxYVBgcGBwYjIicuAycmJyImNTQ3MzI2MzIWMx4CFx4BFz4BNzY1NCcmJyYnJj0BNDc2MzIWFxQGIzd5VE5LNjsQDgsfMQkOCQYFAwcZYCwoKjg0GxUYHBQqOggBDhRWMwkFBQpMeRAEAmQNBwIvIA0EIBMHJiELBgENJV0JPTwKFjMhOQk4MAoGBQgHFwoOJgEdOBshKyodJzkLBgQIJiwLCEciJzNKBAcKAftSdDQlSxMKEhQIAwEGBgwNMBQURTwNCgcNQywHFSAjKDYHCwwHWUURpQQLGSECD0AZFwkhGxoQFRsbRxABAgUbGS0HKgMGCxECAQEEHxgeKR0KCS8gEBMPCBUiIxgRDghFIRE0KwsFAAIAB//sAY0CwQA4AEwAACUyFhQHBiMiJyYnNA4BIyInJjQ2PwE1NDY1NDc2NzY3MjYzMhcWFRQHBg8CBhUUFx4BMzI3PgITNCYjIgYjBgcGBwYVFD4BNzY3NgFdBBARVT1YFQIBHiEDBQoGCikhARcmTTAvAgcCLwwCAh2sHQIEAgUVFSYuCRsSDgoOAgYBGB8fLBIPFAdrGwVoEwoQT4YOAQEdHwwICAonIAYBCwM6WZ5zSgoBLQgZGg6nuyAPLBMOFiUhJwcZEAISEhABCUJGr0YEARAZCYOJFgACAEP/KAJxAcUATQBfAAAlFAcUFjMyNzY3NjU0JiMiBw4BBwYVFhcWFRQGBwYjIjU0PwEmNTQ2NzYzMhUUBwYjBgcOARUUMzc+ATc2MzIXFhUUBwYHBiMiJic0MzIBFBYzMjc+ATU0Jy4BIwcGBwYBahYfFionJhcQIiEWIUF5LhdQCwtJMQQISyUGHV48CAQMBgIJFxoVHgcJKHRENDMdFllWLTMZHSgvAiYY/v8RFwoFFSEFAUMCBBMJAm0VDBUdKSdZPyAlLgcPZU4oAmQUGRo6bAgBYk5oESU4Wq8MAggNDAQDKR1lJyYPRnEaFQgjcGpaKxEJLSc7/wAcGwILPCANDANYCjw7CgAAAgAo/+oCywLMAIwAoAAANyImNTQ2MhYVFDMyPgI3NCcmJyYnJjU0NzYyFxYXNzY3MjYzMhcWEhUUBw4BBxcUFhUUBhUUHwE3NjMyFhcWBxQGBwYjIicuATU0NjU0Ji8BNSMVBgcGBwYjIiYnJgcGJyY1NDc1NDYzMhc2Mx4BFxQGDwEUFxYyNzY1NCcmJyYjIgYVFBceARcWFQYTFhcVMzc2PwEyJicuAS8BBwYHBnIcHwgYCBILDwYBAQIHJSIJAjMYTCUhFyJJfAMTBA0CAo0CBYsUAQsCIAggIwMGGAMCAlYDAQ42IBYdAgUDA20BCRExIigrPw8BBAgLCBEUBAgEDQIDDwEFCAcNIU4IBQIGAxcsHiQgGxwGAQSGEQJRUSMsGQEgHA4gCAgMPyMq8y8gCQUECioPIRgXIwgbKicdCBFHIxIZGSgiOgkBAgH+9QIDAgVJBwYLxgsGEAUoJAchIw8DBQQBTQIBFg83HwURBgJlMjEHOlUmXTQiNykCAgIKCQQIBgQEFA4DAg8CBQUDBAUXL1Enx7AgKgxIMyEXIR4tHggakgE/PUorAQwZDT02GT0ODgIOGBgAAQA3AAACKwK2AHgAADc+ATU0JyYnJjU0NzY3NicmJyYnJjU0NzYzMhUWFxYBFz4BNzUnJicmNTQ3NjMyFxYXHgQXHgIVFAcOAQciJicmJyYjBgcOAQcGFRQeARcWFRQHBiMiNSYnLgIvAQcGFRQXFhceARUUBgcGIyImJyY1NDc2TCIeBwcTGAYMMAsBEDAgBwEECw8JBCQIAQoEAx8BCRkGEwQLDwcCAygFBgkDDgUTCg4EAw8FBwUBAQsLAgEBAhwCAh4tDQ0RCAYIBCQDcIcaBQEdAQYfHxIsIQU3Kg8CAQMCJQIMExISECMsIxQePlQSAhA4Jx8FDh0PJQ0xLAv+4AQYtxEKBxYKFyQUFCUKDTwICgkDDQQQCh8UEhYNFwIGCxQREgcJDKkRFAEHITMXGRwvFwkNMSwDe5McBQQ6bhAEFyQjKBAdIwUBAQQCDQsDAwAAAAABADf/9QOwAf8AKAAAABQHIRcWFxYVFCMiJicmJy4BJyYnNDc+ATc+BTMyFRQHBg8BIQOwD/0EA2cgBhUMBwICAhJlRw8DEkdlEgECAQMECAYVBh5pAwL8AQYYCANPexYDCwUKBwpJchwGBQ0EHHJJAwwECAMCCwMWd1MDAAAAAAEAEf8/AeMCtgA0AAATIjU8AT4BNDYyNjc+ATc2NzYzMhcUHgEVHgEXHgEyFhQeARQVFCMiJyYvAREGIicRBwYHBhsKAQIFAgcCKk4YLwsBDAgCAQIRbEsCBwIFAgEKBgl0QQcHGgcHLk4yAZ4TBAUEAwICAgELMiA6RxAKAQYHAk5zEwECAgIDBAUEFAMgYQr9Ig4OAt4KRiYXAAEAOP/1A7AB/wAmAAA2NDchJicmJzQmNTQzMhYXFhceARcWFAcOAQcGBw4BIyI1NDc2NyE4DgL9RycZCAEUDAcCAwgWZkQJCURmFgcEAgcMFQYfbP0D7RoHNUswLwIEAQsFCRQVQ2kXAxADF2lDFRMKBQsDFn1QAAEAEf8+AeMCtgA3AAAlMhUcAQ4BFAYiBgcOAQcUDgEVBiMiJy4BJyYnLgEiJjQuATQ1NDMyFxYfAREQNzYzFhcRNzY3NgHZCgECBQIHAktsEQIBAggMAQg2JTA3AgcCBQIBCgYJdEEHAgYNDAcHLk8wVhMEBQQDAgICARNzTgIHBgEKEDFeGyYOAQICAgMEBQQUAyBhCgFvAW8ECwEO/SIKRiYXAAAAAAEAN//1A7AB/wBCAAABPgEzMhUUBwYPASEmJyY1NDMyFhcWFx4BFxYUBw4BBwYHDgEjIjU0NzY3IRcWFxYVFCMiJicmJy4BJyYnNDc+ATc2AQsDBgwVBh5pAwKeayAGFQwHAgMIFmZECQlEZhYHBAIHDBUGH2z9YgNnIAYVDAcCAgISZUcPAxJHZRIBAfEKBAsDFndTA1B9FgMLBQkUFUNpFwMQAxdpQxUTCgULAxZ9UANPexYDCwUKBwpJchwGBQ0EHHJJBgAAAQAR/vAB4wMEAGUAABMiNTwBPgE0NjI2Nz4BNzY3Njc2MzIXFB4BFR4BFx4BMhYUHgEUFRQjIicmLwERNzY3NjMyFRwBDgEUBiIGBw4BBxQOARUGIyInJicuAScmJy4BIiY0LgE0NTQzMhcWHwERBwYHBhsKAQIFAgcCKk4YLAwDBAMECQIBAhFtSgIHAgUCAQoGCXRBBwcuTzAXCgECBQIHAktsEQIBAgkEAwQDCTUjMDcCBwIFAgEKBgl0QQcHLk4yAewTBAUEAwICAgELMiA3QRIEAwoBBgcCTnQSAQICAgMEBQQUAyBhCv0CCkYmFxMEBQQDAgICARNzTgIHBgEKAwQTLlkZJg4BAgICAwQFBBQDIGEKAv4KRiYXAAAAAQAd/z0DsALQADgAABMiJjQ3NjU0JyY1NDYXFjMyNzY3NjMyFhUUBwYHBiMiJyIWFwAXFhUUBiMiJyYBLgEvARYdARQHBjQDFAkwGwQIBEBJIBFEOA0EAxQRRVMUECQXAo3+AYwBAQwIAgYE/nVN5C4tBTgLAUwUBg5PXkU5CgIFBwEgAwsjCRQDBwsrCwIFjv7+dAQCBAgNAgIBi03jLS0LHhBnWREAAQA3/z0DygLQADgAAAE0NjIXFhcWMzI3NjMyFxQHBhUUFxYUBiMiJyY9ATQ3Bw4BBwAHBiMiJjU0NzYBEjYjBiMiJyYnJgJGFAYOOEUPIT0+CwUIAgQbMAkUAwcLNwQuLeRN/nUEBgIIDAECAYv+jQEXJRAUU0URArkDFAkkCgMaBgkDCzlFXk8OBhQRV2kaGActLeNN/nUCAg0IBAIEAYwA/40FAgsrCwAAAAEAN/8kA8oCtwA7AAATNDYzMhcWAR4ENSYnJjU0NzYzMhYUBwYVFBcWFQYjIicmIyIHBgcGIiY1NDc2NzYzMhcyJicAJyY3CwkCBgQBizKST1QlAQIBNwsHAxQJMBsEAggFCz49IQ9FOA4GFBFFUxQQJRcBjf7+dQIBAqMIDAIC/nUykU9UJAEBDwoeaVcRFAYOT15FOQsDCQYaAwokCRQDBwsrCwIFjv4BjAQCAAAAAQAd/yQDsAK3AD4AADY0NjMyFxYVFAcGBxQ+AzcANzYzMhYVFAcGAQ4BMzYzMhcWFxYVFAYjIicmJyYjIgcGDwEGJjU0NzY1NCcdFAMHCzgCAgElVE+SMgGIBwYCCAwBAf50/o0CFyQQFFNFERQDBA04RBEgQTkEBgUECAQbMI4GFBFZZxQUDwEBJFRPkTIBigMCDQgEAgT+dP+NBQILKwsHAxQJIwsDGgICAgEHBQIKOUVeTwAAAAEAN//1A7AB/wA3AAATNjMyFx4BHQEhJicmJzQmNTQzMhYXFhceARcWFAcOAQcGBw4BIyI1NDc2NyEVFAYHBiInLgE1NDkGDAgGBQEC5EcnGQgBFAwHAgMIFmZECQlEZhYHBAIHDBUGH2z9HAEFBhAGBQEBqQwGBRQ9SzVLMC8CBAELBQkUFUNpFwMQAxdpQxUTCgULAxZ9UEs9FAUGBgUmiqsAAQA3//UELgH/ADUAAAAUBiMhFxYXFhUUIyImJyYnLgEnJic0Nz4BNz4FMzIVFAcGDwEhNjc2NTQmJyY1NDMyBC5UOf0EA2cgBhUMBwICAhJlRw8DEkdlEgECAQMECAYVBh5pAwL8PBoPOyoaGjkBjWRDA097FgMLBQoHCklyHAYFDQQcckkDDAQIAwILAxZ3UwMFIBIWIigDAhIUAAAAAAEAN//1BC4B/wAzAAA3IiY0NjMyFRQHBgcGFRQWFyEmJyYnNCY1NDMyFhcWFx4BFxYUBw4BBwYHDgEjIjU0NzY3xDlUVTkZGjwaDzsqAv1HJxkIARQMBwIDCBZmRAkJRGYWBwQCBwwVBh9s5kNkQxQSAgUgEhYiKAM1SzAvAgQBCwUJFBVDaRcDEAMXaUMVEwoFCwMWfVAAAQA3AOYDsAH/ABcAADcmJzQ2NzY3Njc2OwEyFxYHBg8BIRYUBz4GAQQKiDwFBAMGBRACAwYwaAMDDQ8P5gYICAYHUZMQAQEGBBGDUAMIGAgAAAAAAQA3//UDsAEOABcAABM2NyEWFAchHgEXFhcWBwYjIiYnJicuATcBBgNjDw/88wUfB0wkBgMCEAwGBT+FCgQBAAgGCBgIBRsHTmERBAYEDpRQBwYAAQA4AOYDsAH/ABYAAAE0MzIWFxYXFhceARQHISY0NyEuAScmArMUDAYFPHYUAQgDB/ydDg4DDjNSFwUB9AsFDY1MDAEFBRAHBxoHJnI+DQABADj/9QOwAQ4AFAAANjQ3IRYVFAcGBw4BIyInJjc+ATchOA4DYwcLizwFBgwQAgMGF1Iz/PLtGgcHBw4EVZIOBAYEET9xJgACADf/9QOwAp8AFgAuAAABNDMyFhcWFxYzHgEUByEmNDchLgEnJgE2NyEWFAchHgEXFhcWBwYjIiYnJicuAQKzFAwGBTx2FAEIAwf8nQ4OAw4zUhcF/YQBBgNjDw/88wUfB0wkBgMCEAwGBT+FCgQClAsFDY1MDQUFEAcHGgcmcj4N/m8IBggYCAUbB05hEQQGBA6UUAcGAAEAOP/oA7ACDQA3AAAlFAchFxYXFhUUIyImJyYnJicuATQ2Nz4BNzY3MxYVFAcGDwEhFhUUBwUhBwYHFhcWHwEhHgMDsA/9nQozIwUUCwcESo8qLgoGBgpmnS4OBAYSBSMzCgJjDw7+uP64CihNBAY3NAoCkAEHAwOZDQcKNkUMBAgDCZJGFQwDBQoFAxqDXAwBAQkDDEU2CgcNCwgBCB4nAwIYKAgBBQMHAAABAB//PgJDArYANwAAFwYiJwMRBwYHBiMiJzU0Njc+ATc2NzYzMhceARceAR0BBiMiJyYvAQMRBiMiJxEnJicGBwYPAQPkCxIKAQw2Pw0GAgcEC1iDGwMDBAMIBRuDWAsEBwIGDUA0DAEJDA4FCSoaAgIaJQkBsw8NATIBMQsyHwgHDQwGBiuhYwsEAhFjoSsGBgwNBwggMQv+z/7ODRECjAw2PQQFOTAM/rgAAQA4/+gDsAINADEAAAE0MzIWFxYXFhcWFAcOAQcOASMiNTQ3Nj8BISY1NDchNzY3JicmLwEhJjU0NyEnJicmAkQQDgYGUKUgHBERZp0uBAYMFAUjMwr9nQ4QAo0KKE0EBjc0Cv1zEA4CYwozIwUCAgsDCp9FDgcFEAUahFsJAwgEDEU2CgcNDwUIHicDAhgoCAUPDQcKNkUKAAAAAQAf/z4CQwK2ADUAAAEyFxETNzY3NjMyFxUUBgcOAQcGIicuAScuAT0BNjMyFxYfARETNjMyFxETFxYXNjc2PwERNgGRDAkBDDRADQYCBwQLWYEcBRAFHIFZCwQHAgYNPzYMAQoJCgoBCSkaAgIaJgkHArYN/s7+zwsxIAgHDQwGBiydZhERZp0sBgYMDQcIHzILATEBMg0O/rj+uQ02PAQFOTEMAo0PAAAAAAIAIv/nA8YCDgBLAFwAAAE2MzIVFAcGDwEUMzI1JicmJyY1NDMeAhcWFxYXFhQHBgcGBw4CByI1NDc2PwE0IyIVFhcWFxYVFCMuAicmJyYnJjQ3Njc2NzYFJyEGDwEXFh8BITc2PwEnJgE0DAMRBBwuB/X0AwQuHAUWBwYEBESFIRQLCxQhiz4EBAYHFgUcLgf09QMELhwFFgcGBAREhSEUCgoUIYpABgHnCf3JIz0KCjUiCQI3CSI1Cgo1AgwCDAcIQzgIAQEEBDhDDAQKAQIGCZZGEwYEEAQGE0yQCQYCAQoEDEM4CAEBBAQ4QwwECgECBgmWRhMGBBAEBhNMkg3LCCMkBgYgHwgIHyAGBiAAAgAf/vACQwMEAEYAWAAAAT4DMzIXHgEXFhcVFAcGJyYnBxEXNjc2FxYdAQYHBgcGBwYHBiInJicmJyYnJic1NDc2FxYfAREHBgcGJyY9ATY3Njc2FyYnBgcGDwERFxYXNjc2PwERASICAwIFAwgHHoVSDAIHBRE+QQEBP0ARBQcCDD03GR8yFwcQBxcyGh05PAwCBwUSRTMHBzNFEgUHAgw8OV13GC0DAh8hCAgYLQMCHyEIAvMDCAMDEVKGIQcCDRICAQcaNpb+1JY0HAcBAhINAgcZLhUiPT0SEj09HRovGAcCDRICAQceLQUCWAUtHgcBAhINAgcYL1ZBGUgEBDYjCf1aCRlIBAQ2IwkCpgACAAD/6gIsArYAGgAfAAARNDYzMhcWHwEhNz4CNTYzFhUUAAcGIicmAAE0IBUTDAgKBQMsLAEwKwoXDQUOEv78AwUUBQP+/QGd/vCIAqEIDQcDdXRzGzsgAQkCEgT9VgMHBwQCp/7+AQH+nQACACr/6gI2AssANwBNAAATIiY1NDc+ATc2OwEyFx4BFRQHBgcGIyImJyYnJjU0NzY3Njc2MzIXFhc3NjU0JyYjIgYHFhUUBhc0JyYjIgcGBwYHBhUUMzI3Njc2NzbKExkED0kzGQcMIQZTYxY0WlFiNUYbFgcCBhdLREITFx4UQhEDFE8bHCZAEykly1EFCz4xFAoUFhJkDAZNLxMTEgH8FRIKDTZJDQUBD4tnO1K1UkslKSAjCRsgGGdEPg0EBxdEC1M2cyMLJBwHIRslymkQAS4WEiJXSCFfAQ1NIT05AAEAOAAAAfQCtgAWAAASNDchFhcRBg8BIyY0NyERISY0NyERITgOAaEKAwIL0NEODgGG/ogODgF4/noClRoHCAf9aAUJAQcaBwEfBxoHAR8AAwAn/7IBzAMEADMARwBaAAAXIiY1ND8BJyYnJjU0NzY3NjMyHwE+AT8BNjMyFhUUDwEXFhcWFRQHBgcGIyInJhUHBgcGEyYjIgcOARUUFhUWFxM+AT8BNCcDFjMyNz4BNzQ2PQE0JyYnBxQDhAcOCwsIHBQmHhoqMkArIAUECgMDBgoHDgsLDBkRKCYTHjZFJCIMCQsGBIoMEjIlGA4BBBlTEywLChhxGisoIhwWAwETAwcBVE4LBwgiJwgbLFaekFNHISkSAgwiCgoKCwcIIicMGidXpZ5WKx4xDwQBHSYEAwLyAzAigXAVPgeHMwEeQJkjJAIN/Y0aHx1bYwc+FTCINQwLAwL+4wAAAAIALv/fAxICqwANABQAABM0NyEWFRQABwYiJyYABTQgFRYSMy4FAtoF/q0DBS4FA/6tAov+CAL5AQKkBAMDBAL9SAQHBwQCuE4BAQX+AQAAAQBU/9gCRwIcAC4AADc0NjcyNjI7ARYVFA8BBgcOAQcGHQEhFhQHIRUUFx4BFxYXMxYVFAcjIicuAScmVKFzASA0GGMPDWhvGktqEgYBvA8P/kQGEmtJG29oDQ9hbRhcixIF+neeDAEHDQoJAQEFE2FFGA0CCBgIAg0YRGQQBgEJCw0HBA9+VxcAAAADAFT/KQJHAswANgA9AEcAABciNTQ/ASYnJjU0NjcyNjIzNzYzMhYVFAczFhUUDwIzFhQHIwcWFxYXMxYVFAcjIicmJwYHBhM3IxUUFxY/AQYHDgEHBh0BaBQFa1YVBaFzAR0vF1cEDAgMTj8PDVZ2yg8P3mMkLRtvaA0PYW0YNjdvAwRnV7EGFql3VxhLahIG1xIHB9FBZRcjd54MAacJDAgDmQcNCgkB5ggYCL8XCQYBCQsNBwQIINYCAwEVqAINGE2c5gEFE2FFGA0CAAAAAQBT/9gCRgIcADMAABM0NzMyFx4BFxYUBw4BBwYrASY1NDczNjc2NzY3Njc2PQEhJjQ3ITU0JyYnJicmJyYvASZTD2FtGFyLEgUFE5pkB2ZhDw1obxogIBUXRRYG/kQODgG8BhZFFxUjHBtvaA0CCA0HBA5+VxhGF12CCAEHDQsJAQUIDgsQNlIYDQIHGgcCDRhSNhALDwYGAQEJAAAAAAEAVADmArYBDgAHAAA2NDchFhQHIVQOAkUPD/277RoHCBgIAAEAOP9aAtIB9AAfAAASNDchFhQHIREhFhQHIRUUBgcGIyInJj0BISY0NyERITgOAn0PD/7WASoPD/7WAQUGCAwGAv7VDg4BK/7VAdMaBwgYCP7vBxoHk3YlBQYLBJWVBxoHAREAAAAAAQA4/wYBvALuAA8AABciJjU0ADc2Mx4BBxQABwZLBwwBXAMFDQgMAf6lBQf6DAcKA70ECgEMBwX8RQoKAAAAAAEAOP8GAbwC7gAOAAATNDYzMhcWABQGIyInJgA4DAcKBwQBXAwICgcD/qQC2wcMCgf8Qw4MCgQDvQAAAAEAQAAjAbMB0QBHAAATJjU0NzI2Mx4BFRQGFTc2NzYzMhYUBw4BBx8BFhUUBiMiJyYvARYVFAYjIiY1NDY1BwYHBiMiJjQ3PgI3JyY1NDYzMhcWF+UNGAEIAg0TDTo4BQYGDRUKBX4FQkYJEg8IBAU4Og0TDg8TDTo4BQYGDRUKASVFHYgJEg8IBAU4AR6GEBMJAQEQDBF/BiopAwMYGgoDPQEfIwkODxUCAykqhhANDw8NEX8GKikDAxgaCgERIg5BCQ4PFQIDKQAAAAIANwA3AbwBvAAOAB4AACUUBiMiJyY1NDc2MzIXFicmIyIHBhUUFxYzMjc2NTQBvHROVDk2NjlTVDk2ayc1LSZCQigwLyhC+VFxPDhQTzY8PDgxGhowT1AwGhowUE8AAAEANwA3AbwBvAAOAAAlFAYjIicmNTQ3NjMyFxYBvHROVDk2NjlTVDk2+VFxPDhQTzY8PDgAAAAAAQBI/zgDVQMgACQAADciJjU0Nz4BNzYzMhcWHwEyGgE3NjMyFxULAQYjIicmLwEHDgFfBBMBAoMBAgMHBQpOVQHOzwMIDBAD6esEDwkDAmBgEA8hshAGAwEEZAECChStuQGqAbAFDhIG/h3+GgcDAtLSCwwYAAAAAgA4//UC0gG6ADAARAAANzQ2MzIXFhc3PgEzMhcVIyYjIgcGBwYXFhcWFxYzMjczFQYjIicmJyYnBwYjIicuATcUFjMyNzY3NicmJyYnJiMiBw4BOGRSZVQPGAcrbDsIIwQIEBIKUz4eBAkyLiwZGxUCAxoSR0IjLwMCB1Z+IiExPyVEOxUIVjweBAkyPD0ODgsELjvYWYlkEyYMSUgFJwICDmMuBBRIQBYNAjMGNBpHBQMMkQ8YckdJbQIQYS4EFEhVDAIBCmEAAAAAAwA3//UDsAG6ACkAOABLAAATNjMyFxYfATc2NzYzMhceAR0BDgEHBiMiJyYvAQcGBwYjIicuAT0BPgEBMjY1NCYjIgcGBxcWFxYBIgYVFBYXFjMyNzY3JyYnJicmiDRCVk8mJA4HRVIrJyEeOkwDLCIzRVZNJiQOB0VSKychHjpMAywCl0BOUEI3MTs3HyAITv41QUw6LRYWNDQ6Nx8gCEY8DAGOLD0fLxMKYyEQCxd2TAc2XRssPR8vEwpjIRALF3ZMBzZd/sBlQUpqICZZKCkKYAFJZEI8Yw4IISZZKCkKVAoCAAAAAAEANwAAApoCtgAZAAAzJjU0NzYBADYzMhYVFAcOAgcBBSEWFRQHRxACCgEXAR4MAwgLAwFGiUH+8gEKAQsNDwkLAgYPAT4BSQQLCQYFAVCeSv7LAQkLDQcAAAAAAQB3/wcAnwLuAAkAABYiJxETNjMyFxGYGgcBCgkNB/kOAeYB5g0P/DYAAAACAIT/BgFvAu4AEAAiAAATNjMyFxYQBwYjIi8BLgEREDc2MzIfAR4BEAYPAQYjIicmEIUFDwsGAgIGDAgGAQQBxQcKBwgBBAEBBAEGCAwGAgLgDgsE/DYECwYBAnwBbwHhCAsGAQJ8/SJ7AwEGCwQDygAAAAEAN//qAmMCVgAaAAABNjMyFxYaARUGIyIuAicLARQHBiMiJzQaAQE+BwgLBAGDgwISBQYFAgPt7QEIDBICg4MCTwcHAf7d/tcGEgEHAwcCFP3sAQEQEgYBKQEjAAAAAAEAN//qAmMCVgAaAAATPgEzMh4CFxsBNDc2MzIXFAoBBwYiJyYKATcBCwgFBgUCA+3tAQgMEgKDgwEFFAUBg4MCRAcLAQcDB/3sAhQBARASBv7X/t0BBwcBASMBKQAAAAEAN//qAmMCVgAnAAAWIic1NDU2NzY1Njc+ATMyFhcWFxYdAQYjIicDJicuASMiBwYHBh0BWBoHAQQBCR8meUhShCEbBAEHDQoJAgofH2o6f0ciBgEVDs8fMYYOAgEnJCoyPDMpKQbNyQ8NAZ4vISInSiUuBcvIAAEAN//qAmMCVgAoAAABMhcVFBUGBwYVBgcOASMiJicmJyY1NzYzMhcVHwEeATMyNzY3Nj0BNgJPCwkBBAEJHyV9Rk6GIhoFAQEJCgsJAQIOh1V/RyIGAQcCVg/PHzGGDgIBJyQrMT0yJi4HzMkNDc/OCkNNSiUuBcvIDwABADf/KAHYAswAOAAAFzQ2MhYVFAYPARQWFxY3Njc2NzY3Njc2NzYzMhcWFRQGIiY1NDY/ATQmJyYHBgcGBwYHBgcGByImNxwoHBYRBgkDDQ8OCg8RDREYFRxJBQksFw0cKBwWEQYJAw0QEgsJEBgxEiIbJCcscRYbHBQSGgMCAgoBCggGGCKvhnGiX4UPAS0dHRYbHBQSGgMCAgoBCgkJKyKX/fJaJxsDPAAAAQA3AIUC0gFvADIAADciNTQ3PgE3NjMyFx4CFxYXFjMyNz4BNTQ2MzIVFAcOAQcGKwEiJyYnJicmIyIHDgJFDgEITjsKCxMMGjYgHjYYKicsIhsjCQUOBAg1JR4cCBwWLkw2GConLCImGQKFIQsHSmIJAgMGHhobLw4ZGRNFJAwRIRIUMk8SDwgQQy8OGRkfTiwAAAEAN/+tAN4CRwAlAAATNDMyFhUUBwYHBgcGFRQXFhcWFRQjIiY1NDc2NzY3NjU0JyYnJjccQkkECispCQQqFBYbIT9HBAorKQkEKhQVHAI5DmNJGBEvTU0pGg1RKhQBAgwOZ0YYES5OSyoaDVEqFAECAAAAAgA3ACQC0gHQACoANAAAADIVFAYHBisBIicmJyYnJisBIgcGBwYjIjU0NjczMhYXFhcWFxY7ATI2NwE0NyEWFRQHISYCthxCNRQTCiIfJkVAIh8eBDcqJQICDA5URAoiKR0WNEAiHx4ENk4E/YIQAnoQD/2DDgHQIEBdEQcNDzUxDgwoJjEeIUhjCQ0QDCgxDgxINv6HDwUHDQwIBwAAAAMANwAWAtICTQAyAD0ASgAAEyI1NDc+ATc2MzIXHgIXFhcWMzI3PgE1NDYzMhUUBw4BBwYrASInJicmJyYjIgcOAgc0NyEWFRQHBSEmFTQ3IR4DFRQHISZFDgEITjsKCxMMGjYgHjYYKicsIhsjCQUOBAg1JR4cCBwWLkw2GConLCImGQIYDgJ9Dw7+wv7CEBACfAEHAwMP/YMOAWMhCwdKYgkCAwYeGhsvDhkZE0UkDBEhEhQyTxIPCBBDLw4ZGR9OLHcNBwgMCwgBBbMPBQEFAwcEDAgHAAIANwA3AtIB4wAwAGEAAAAyFRQGBwYjIicmJyYnJicmIyIHBgcGIyI1NDc+ATc2MzI2MzIXFh8BFhcWMzI3NjcBIjU0Nz4BNzYzMjYzMhcWHwEWFxYzMjc2NzQyFRQHDgEjIicmJyYnJicmIyIHBgcGArYcPjMbGyElH0YjDi0oBxMyJzEDAgwOBAk5KxQRAgwEKzIaMzIsKQYTMicuBv2PDgQJOSsUEQIMBCsyGjMyLCkGEzInLgYcBAxXQCElH0YjDi0oBxMyJzEDAgHjHzlREAkOCy4VChkJARkfNB0eDBYsQA0IARgOICAZCQEZHTb+cR4MFixADQgBGA4gIBkJARkdNh0gEBA4Sg4LLhUKGQkBGR80HQACADcAEALSAeQAJQBBAAATNDYzMhcWFxYzMjc2NzYyFhUUDgMHBgcGIyInJicuBRM2MzIXFhcWFRQGIicmJyYjIgcGBwYiJjU0NzY3CwgJC3qIDBkXDod6DBALAQMCBwJaXkg+P0heWgIFAwMBAcdFOkhGXloPCxAMeocOFxkMi3cMEAsPWgHQBw0KYxECAhFjCgwIAwUEAgcBSB8XFx9IAgQCBAME/tQWFh9IDQkIDApjEQICEmIKDAgJDUgAAAADADgAhQLSAp4ACgAXACMAABM0NyEWFRQHBSEmFTQ3IR4DFRQHISYBNDYzMhYVFAYjIiY4DgJ9Dw7+wv7CEBACfAEHAwMP/YMOAREjGRojJBgaIwFbDQcHDQsIAQWzDwUBBQMHBA0HBwHWGiIjGBojJAAAAAEAOP8pAtICzAAuAAAXIjU0NxMjJjU0NyE3ISY1NDchEjc2MzIWFRQDMxYVFAcFByEeAxUUByECBwafFAWi7A4QAP9P/rIQDgFkqwUEDAgMp+wPDv7/UAFRAQcDAw/+nLAFBNcSBwcBPAcNDwWaBQ8NBwFPBQkMCAT+uwcNCwgBmgEFAwcEDQf+qQIDAAAAAAMAOAAkAtIB0AAJABEAGwAAEzQ3IRYVFAchJhQ0NyEWFAchBzQ3IRYVFAchJjgOAn0PEP2GEA4CfQ8P/YMOEAJ6EA/9gw4BvA0HCAwNBwXAGgcIGAiuDwUHDQwIBwAAAAIAU/92ArYCfAAbACUAAAEyFhUUBwYNARcEFxYVFAcjJSQnJjU2NzYANzYBNDchFhUUByEmAqIIDAcB/vP+9vgBIAQDEgb+4P7eAgcBDAgCLAUE/bcPAkMQD/27DgJ8DgcIBgGAfnaIBQYFEgKIiQIFDAsGBAEHAgL9DgsJBw0MCAcAAAIAU/92ArYCfAAZACMAABM0NjMyDAEXFhQHBg0BIyY1NDc2JTclJCcmEzQ3IRYVFAchJlMKBggBJQEeAQcHAv7e/uAGEgMEASD4/vb+8wEHAQ8CQxAP/bsOAmgGDomJAQUUBQKJiAISBQYFiHZ+gAEH/SoLCQcNDAgHAAACADj/vQOwAjgAHAA5AAAEFAYjIicmLAEnJjQ3NgA/ARYzFhUUBwYNAgQXBBQGIyInJiwBJyY0NzYAPwEWMxYVFAcGDQIEFwJ/DAgFCQn+6/7+AgMDAwIkBQQDAw4GAf7+/v8BAQECAQE3DAgFCQn+6/7+AgMDAwIkBQQDAw4GAf7+/v8BAQECASgQCwQFl44EBA4EBQErAgEBBQ4IBgKNjY2NAgYQCwQFl44EBA4EBQErAgEBBQ4IBgKNjY2NAgACADf/vQOwAjcAVQCrAAATNDYzMhcWABcWFRQHBgQPAQYjIiY0NzI+AT8BMzczPwEzNzM3Mz8BMzczNzM/ATM3MzczPwEzNzM3Mz8BMzczNzM/ATM3MzczNzM/ATM3Mz8CACcmJTQ2MzIXFgAXFhUUBwYEDwEGIyImNDcyPgE/ATM3Mz8BMzczNzM/ATM3MzczPwEzNzM3Mz8BMzczNzM/ATM3MzczPwEzNzM3MzczPwEzNzM/AgAnJjcLCAYJDgIRBAMEAv7viIcKBgcLBgFCgj4BAQEBAQEBAgEBAQEBAQEBAQEBAQEBAQEBAQEBAgEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQECxv3/AQcBMQsIBgkOAhEEAwQC/u+HiAoGBwsGAUKCPgEBAQEBAQECAQEBAQEBAQEBAQEBAQEBAQEBAQECAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQLG/f8BBwIjBw0FB/7fBQYFBgUEl0lJBQwQBiVHIgEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBbgEXAwYIBw0FB/7fBQYFBgUElklKBQwQBiVHIgEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBbgEXAwYAAAABAFT/1wK2AhsAJQAABRQjIicmJyYnIicmNDc2MzY3Njc2Nz4BMxYVBgcGBxYXFhcWFxYCthQQBRCXe+InBAoKBCdDTfBVJwgCCQwSCC9OvEEiFid4IAcRGBiFPDEEAgcWBwIBBxhnLz0PDAMVTzhdJg8LBxE8bRgAAAAAAQBT/9cCtgIbACkAAAEyFhUUBwYjBgcGBwYjIjU2NzY3JicmJyYnJjU0MzIXFhcWFxYXFhcyNgKiCAwLBCeVYPkWBRAUCC9OvEEiGiJ4IQgSBAYKAggnVfFLRAoWAQ4LCgsHAgMUNKsYGE84XSYPCwkPO24iDxYDBRM9L2cYBwEBAAAAAQBU/9gCtgIcAC4AADc0Njc6ATY6ATsBFhUUDwEGBwYHDgEHBhUUFx4BFxYXHgEXMxYVFAcjIicuAScmVKFzARMfJzIYmw8Nn6gRAQdRbg0BAQpMNyEdFCSKnw0PmZ0HZZkTBfp3ngwBBw0KCQEBAwEBFG1QCBsaCD9hHA8GBQEBCQsNBwEKgF0XAAABAFP/2AK1AhwALQAAEzQ3MzIXHgEXFhQHDgEHBisBJjU0NzM2NzY3Njc+ATc2NTQnLgEnJicuAS8BJlMPmZ0HZZkTBQUTmmQInJkPDZ+oEQEHICA3SwoCAgpLNyMcFCSKnw0CCA0HAQp/XRhGF12CCAEHDQsJAQMBAQgOHGI+EBITED5hHA8GBQEBAQkAAAACAFT/dgK2AnwALgA2AAATNDY3OgE2OgE7ARYVFA8BBgcGBw4BBwYVFBceARcWFx4BFzMWFRQHIyInLgEnJhI0NyEWFAchVKFzARMfJzIYmw8Nn6gRAQdRbg0BAQpMNyEdFCSKnw0PmZ0HZZkTBRQOAjEPD/3PAVp3ngwBBw0KCQEBAwEBFG1QCBsaCD9hHA8GBQEBCQsNBwEKgF0X/kYaBwgYCAAAAAACAFP/dgK1AnwALQA1AAATNDczMhceARcWFAcOAQcGKwEmNTQ3MzY3Njc2Nz4BNzY1NCcuAScmJy4BLwEmEjQ3IRYUByFTD5mdB2WZEwUFE5pkCJyZDw2fqBEBByAgN0sKAgIKSzcjHBQkip8NAQ4CMQ8P/c8CaA0HAQp/XRhGF12CCAEHDQsJAQMBAQgOHGI+EBITED5hHA8GBQEBAQn9HxoHCBgIAAACADf/6gJjAlYAKABGAAABMhcVFBUGBwYVBgcOASMiJicmJyY1NzYzMhcVHwEeATMyNzY3Nj0BNgU2MzIXHgEdATMWFAcjFRQHBiInJj0BIyY0NzM1NAJPCwkBBAEJHyV9Rk6GIhoFAQEJCgsJAQIOh1V/RyIGAQf++QcLCQYEAaIQEKICBBwEAqIQEKICVg/PHzGGDgIBJyQrMT0yJi4HzMkNDc/OCkNNSiUuBcvID2oLBgUVQVEJFglRUQQMDARRUQkWCVFSAAIAVP92AsoCfAASABwAACUUByEmJwMRNj8BIRYUByERIRYFNDchFhUUByEmAsoP/bIFCQEFBgUCTQ8P/csCNBD9ihACVhAP/acOTAwIAgsBEwEUCwIDCBgI/gwHzw8FBw0MCAcAAAAAAgBA/3YCtgJ8ABAAGgAAEjQ3IRYXEQYHISY1NDchESEDNDchFhUUByEmQA4CTgcICAf9sg4QAjP9yw4PAlcQD/2nDgJbGgcDCv3WCgMHDQ8FAfT9NgsJBw0MCAcAAAAAAQA9AAACXQJWABIAADcGByInERM2NyEWFxEGByInESFlBwsMCgEHBwIECgMHCwwK/jAPDgEQAR0BHAkECAf9yA4BEAIeAAAAAQA9AAACXQJWABMAAAAyFxEGBwUhJi8BERM2MzIXESERAjwaBwIL/v/+/gsCAwEKCQ0HAdACVg/9yAUJAQUGBQEdARwND/3hAh8AAAUAOP+tAtICRwAXACAAKQAyADsAABM2MzIXFhUUBwYHBgcGIyInJicmNTQ3NgURIwYHDgEHFSUuAScmKwERIQERIRUeARcWMwE1IREzMjc+AZdngo1lYAIPTzxOMDJRSC4oXwEPASkFKSxMYwgCSQuQYw4BAwEQ/sj+7wuQYw4CATv+8AMBDmOQAeViYmeEFg50UzoZDyQYJmaFHQd0hAEQAhIehVEICGqPDQL+8P7IARAIao8NAgEICP7wAg2PAAMAOP+tAtICRwAXACQAMQAAEzYzMhcWFRQHBgcGBwYjIicmJyY1NDc2BS4BJyYjIgcOAQcVIRU1IRUeARcWMzI3PgGXZ4KNZWACD088TjAyUUguKF8BDwJhC5BjEB4cF1yDCwJJ/bcLkmYHGhsHZpIB5WJiZ4QWDnRTOhkPJBgmZoUdB3R8ao8NAgUTi2UIMAgIa48NAQENjwAAAAUAOP+tAtICRwAXACMAKQAvADYAABM2MzIXFhUUBwYHBgcGIyInJicmNTQ3NiUmIyIHBgcXPwEuAQUGFRQXNxc2NTQnBwMyPwEnBxaXZ4KNZWACD088TjAyUUguKF8BDwHsS2wcF1UxwWBhAwr+bkhIwPtISMAeblAEwsBHAeViYmeEFg50UzoZDyQYJmaFHQd0UzkFETHBYWACCShQcHFPwMBQcHFPwP7cRAPBwUcAAwA4/60C0gJHABcAJgAwAAATNjMyFxYVFAcGBwYHBiMiJyYnJjU0NzYlJiMiBw4BFRQXFjMBLgEDMjY1NCcBFhcWl2eCjWVgAg9PPE4wMlFILihfAQ8B7EtsHBdiiTETBAGfAwq1e6tI/mIBJEUB5WJiZ4QWDnRTOhkPJBgmZoUdB3RTOQUUm29ZSh4BnQIJ/fSpe29R/mMBGysAAwA4/60C0gJHABcAMQBBAAATNjMyFxYVFAcGBwYHBiMiJyYnJjU0NzYlJiMiBwYHBhUUFx4BFxYyNzY3NjU0JyYnJgM0NjcyNjMeARUUBiMiJyaXZ4KNZWACD088TjAyUUguKF8BDwFjEB4cF2hDQBkccEYcPhtoQ0AJEzZE3SYaAQwEISkrIjIVBwHlYmJnhBYOdFM6GQ8kGCZmhR0HdIoCBRVTT2g/OEBaDgUFFVNPaCQkSjlJ/uweLAQBBCohIiwtDgAAAAABADcAAAIrArYADwAANwYHIicRNjMWFxEhFhQHIV8HCwwKCgwLBwG9Dw/+Qw8OARAClhABDv7IBxoHAAABADcAAAIrArYADwAAJQYHIicRISY0NyERNjMWFwIrBwsMCv5EEBABvAoMCwcPDgEQATcJFgkBNxABDgABADcAAALTApwADgAAJQYHIicRISY0NyEWFAchAZkHCwwK/tYQEAJ9Dw/+1Q8OARACZAkWCQgYCAAAAAABADcAAALTApwADgAAJBQHISY0NyERNjMWFxEhAtMP/YMQEAEqCgwLBwErIBgICRYJAmQQAQ79mwAAAAABAHf/BwMrAu4AIQAAFiInERM2MzIXESEWFRQHBSEiNCMVMjQzIR4DFRQHIRGYGgcBCgkNBwJ9Dw7+wv7CAQEBAQJ8AQcDAw/9g/kOAeYB5g0P/pAHDQsIAQGcAQEFAwcEDQf+kAAAAAIADAAMAegB6AAXABsAABM2MzIXHgIUDgEHBiMiJy4BJyY0Nz4BFycHF/IDBQYCBN4EBN4EAgYFAwXcAwICAtzLvb29AeYCAgLeCAgI3gICAgLcBgMKAwXc6b29vQAAAAEATgC+AMcBNgAKAAA3NDYyFhUUBiMiJk4iNCMkGBoj+hoiIxgaIyQAAAAAAQADABAB8QHmADcAABM0Njc0MzYzMhceARU3NjsBMhUUBwYPARceAR8BFCMiIy8BDwEiIyI1Nz4BPwEnJicmNTQ7ATIX0h4BBAQCBwIBHWJgAwEJPxIMWS4LFwYGDAECAoyMAgIBDAYGFwsuWVoCAQkBA2ABGgLCAgQCBwG+BhEPDAUfCQYtWBQuDAwMAY6OAQwMDC4UWC0tBAEBDA8AAAMAGv/7A2kB+QAGACQAKwAAJBAiBBQEHwEGIyInJQcGIyInJiMmJxE2NzI3NjMyHwElNjMyFwUlIhAzNiQDQQL+qAFXAikHDAMG/nS90QgCAQIBBgUFBgECAQII0b0BjAYCDQf+M/6nAQECAVcyAZDHAsYBKA8C5W94AQICCwHeCwICAXhv5QIP8Mj+cAHGAAMATv/iAMcDhAAKABUAIAAANzQ2MhYVFAYjIiYRNDYyFhUUBiMiJhE0NjIWFRQGIyImTiI0IyQYGiMiNCMkGBojIjQjJBgaIx4aIiMYGiMkAbIaIiMYGiMkAagaIiMYGiMkAAADAE4AvgRFATYACgAWACEAADc0NjIWFRQGIyImJTQ2MzIWFRQGIyImJTQ2MhYVFAYjIiZOIjQjJBgaIwG/IxkaIyQYGiMBvyI0IyQYGiP6GiIjGBojJBgaIiMYGiMkGBoiIxgaIyQAAAMAhQBkBHwDNAALABYAIgAAEzQ2MzIWFRQGIyImATQ2MhYVFAYjIiYBNDYzMhYVFAYjIiaFIxkaIyQYGiMBvyI0IyQYGiMBvyMZGiMkGBojAvgaIiMYGiMk/uwaIiMYGiMk/uwaIiMYGiMkAAEArv8GAaYC7gARAAAXBgciJxE2PwEzMhcWFAcGKwHWBwsMCgUGBWxsBAwMBGBg6w4BEAPICwIDAgYYBgIAAAABABX/BgENAu4AEAAABQYHIicRIyInJjQ3NjsBFhcBDQcLDApgYAMNDQNubQoD6w4BEAOwAgYYBgIIBwABAK7/BgGmAu4AEQAAExYXETMyFxYUBwYrASYvARE2xAsHYGAEDAwEbGwLAgMKAu4BDvxPAgYYBgIFBgUDyBAAAQAV/wYBDQLuABIAABMWFxEGDwEiJicmNTQ3NjsBETb7CwcCC21YGwUGDQNgYAoC7gEO/DYFCQEBBQYIDAYCA7AQAAABADcAegOwAYQAIQAANyY1NDc2NzY3MxYXFhcWFRQGIyYnJicmJyYjIAcOBEsUCitIhaUwe3RpQAoLCQwIAQEuP32o/vOGAQYCBQR6BQ4IDUI3YwYFQD1gDQgHDAMLAgFAK1K9AggCBAEAAAABADcAhgOwAXoAIgAAADIWFRQHDgEHBgcGIyInJicuAScmNTQ2MzIXFhcWMzI3NjcDkhIMAQQ5F2aOM0BBMo9mFzkEAQoJDAo+a2qBgGprPgF6DAgFAgs9FFYdCgodVhQ9CwIFCAwPUS4rKy5RAAAAAQA3/wwBZQLoACgAAAEXFRQHBgcGEAcWFRQHBgcGBysBIiY1ND0BNDc2NzYQNyY1NDc+AT8BAWIDCFgTAwEBAQQhLk0JBQYCB1oRAwEBAQVUQAcC6AMJDQQ8dBX++wcKdIMFPzdMJgMHAgEIBQM+chUBBQcKdIMFTXQkAwAAAAABADj/DAFlAugANwAANxYdARwCFgYWFBUWFxYdAQcjJicmJyY1NDY1JjU8AiY2JjQ1JicmPQI0OwIWFxYdARQGFO4BAQEBEF0IAxRYLRgDAQEBAQEBEF0HBQgJTi0mAf0CHGgYKxoWDAkEAoE/BA0JAy1ZMDIGZSdyAgh8GCoaFgwJBAKAQAMFCAUIJktHRHQjNx4AAgA7AAADPALMABEAGAAAJRQHISY1NDc2ADc2MzIXFhsBCwEiABUhNAM8Dv0dEAMDAWkCBAwHBAS5uNqmAf62ApYUDQcJCwQGBwKbAwkEAv6q/qsBQAEy/ZwBAgACABr/+wHZAfkAGAAfAAATNjcyNzYzMhcWFxYVFAcGBwYjIicmIyYnLQEiEDM2JBoFBgECAQII0cwHAgQKx9EIAgECAQYFAYL+pwEBAgFXAekLAgIBeHcHAgcIAwh0eAECAgvvyP5wAcYAAAACADv/KQM8AfQAEQAXAAABFh0BAwIHBiInJgoBJyY1NDcFIRQAMgADLg64ugMEDgQErrcIBRACvP1qAUoCAUoB9AcNBv6q/qoCAwMCAUIBVQ0MAgsJKAH9nAJkAAIAGv/7AdkB+QASABkAACUGIyInIi4BJyY0NzYkNzYzMhcCECIEFAQXAdkHDAMGAcvKBAkJBQGQBQYCDQcoAv6oAVcCCg8CdnQDBRYFA+cDAg/+SAGQxwLGAQAAAgA4/ykDsALLAB0AOAAAATYzMhceARcWFRQHDgEHBiMiJy4BJyYnJjU0Nz4BATQmJyYjIgcOAQcGFRQXHgEXFjMyNzY3Njc2AWxCPVQ8fKYRAhgmp3AvOCscV5kzQg8BFyOVAoHQmQkpLyl1phUFDBiAW0dOFhCla00PAgK1FhYq0Y8WG0tKc6EcDAUPY0thfQsmTkdqmv5np+4TAQseuHwjKTkxYpomHgIShWCDFAABADf/fgLTAtcAQAAAJRQGIyImJyY9ASMVFBcWFRQHBiInJjU0NzY9ASMVFAcGKwEiJyYnJic0Nz4BNzY3PgEzMh4EFxYXFhcWFxYC00FENEYHAjIXBQsEQgQLBRcyGSVCCg8TIRImAwUNVktSMgYHCgQFBAQBBAEyUlgmLQcBzGd6KSIIBAQIS0wSBQkHAgIHCgURTEsIBB4XIgYOHDpsIxpEbkJMgg4JAgIGAgoBgkxNOUJEBgAAAgA3/98C0wLMACsAUwAAEzIWFzY3NjMyFxYVFAYVBgcGBw4BBwYHBiMiLgEnLgEnJicmJzQmNTQ2NzYXBhUUFxYXHgEXNjc2NzY3Njc2NTQnJiMiBwYHBiMiJicmJyYrAQci3jhWGR0NN0U4JUsBCm4YSCQmFAgGBAUHCQQDFCYkSBhuCgExLR8SZyolcSclGgMCDxcRKlAqRiIkOTYrKAkEDwsJAwonKT0JBAQCzD8wLgw1HDiOBhMCcXsaRiQ5LhYCAQcICi45JEYae3ECEwZObBcRKhOkTEVAbiQyLwQFHx4YJ002XVteMi0pKDkYCw44KCgBAAACADf/XgLTAtcAGgAsAAABNDYzMhcWFxYUBwYHBiInJi8BJjQ3Njc2NzYXJwYHBg8BFxYfATY3Nj8BJyYBcgwGCwd7tA4OtXoEGgR2pRkJCR0ihWENGAUDAm6XEhKXbgUDAm6XEhKXAsoECQr3pg0SDan0CQntnRgHFAcaJI27GDwJBAXOlBERlM4JBAXOlBERlAAAAQAc/34C7gLWAFIAACUOASMiJyYnJjU0Njc2MzIXHgEfATcmJyY1NDc+ATc2MzIXFhcWFAcGDwEXNz4BNzYzMhceARUUBw4BIyImJzUjFRQXFhUUBwYiJyY1NDc2PQEjAT8ERy82LjMQAjwuEhcxIgIEAgEVIQgiAgxPPQYQKh9SEwICDTcFFQECBAIiNB4YKTEWFU0zMEMFMhcFCwRCBAsFFzI/Jy4mKVQQEUZmDwciAgQBAS0hDDNBGgk+VwkBEShmCzALSi8FLQEBBAIiDhRgQDQsLDgsKQcIS0wSBQkHAgIHCgURTEsIAAACADf/6gFMAu4AFwAkAAATMhcRNzYzMhYXFhUUBwYPASMiJwMQNzYTNCMiBgcOAR0BNjc2TAsICSk3M0ULAQEWzRANDQYBAQSxNhkwCQUBSykaAu4G/soGG0IyBhgaCZqPCwYBegF7Agf+VF8WEQgqg6NLWzwAAAACAEH/IQFEAt4AGQAjAAATNjMyFxE3PgE3NjIXEQYjIic1Bw4BBwYiJzc2NzI1NCMPAkENEAUFDA05FmkCCRAOBQUODTUYZwYGJ7IBAQE1WiQC0Q0H/uUFBRcJKQb9JQ0HywUGFQkqBmdHAaemFiQOAAAAAAIAN/8hAU0C0wBgAGQAACUyFxUHBg8BFRQGBwYnLgE9AQcVDgEjIicuATU0IyIGIyIvATQ2NzY/ATU0IyIGIyIvATQ2NzY/ATU0Njc2Fx4BHQE3NT8BPgEzFzIzHgEVFDMyNjMyFxUHBg8BFRQzMjYHEQcRAUQCBwMCEA8ECw0HBAF+AxgDAQIFAgEDEwQDBQECBQcJDQEDEwQDBQECBQcJDQQLDQcEAX4BAgEUBQIBAQUCAQMTBAIHAwIQDwEDEz9+XwVUAgMFBkREBgQGAwIRM0AvigMKAQIRND8HBSgiDAMDAwWnpgcFKCIMAwMDBWZnBgQGAwIZTmIvaGcCAwgBAhhPYgcFVAIDBQanpgcXAU4v/rIAAAABAG7/BgFNAu4AFwAABQ4BIyInJgI0Ejc2PwEyMzIXFAcGFBcWAU0BCwgKBwO3twMDBwMDARICWltbWugHCwoHAd4KAd4HBQQBEgXu7QTt7gAAAAABADf/BgEWAu4AFQAAEz4BMzIXFhIUAgcGIyImJzQ3NjQnJjcBCwgKBwO3twMHCggLAVpbW1oC3AcLCgf+Igr+IgcKCwcF7u0E7e4AAQCt/wwBZQLoACwAAAUHIyYnJicmNTQ2NSY1NDc+AT8BMxcVFAcGBw4BFBUWFRwCFgYWFBUWFxYVAWUDFFgtGAMBAQEBBVRABxQDCFgTAgIBAQEBEF0I8QMtWTAyBmUncwEKdIMFTXQkAwMJDQQ8dA+EhggIexgrGhYMCQQCgT8EDQAAAQA4/wwA8ALoADAAABM1NDsCFhcWHQEUBhQVFhUUBwYHBgcrASImNTQ3Njc2NzUmNTwCJjYmNDUmJyY1OAUICU4tJgECAQQhLk0JBQcCCFkRAwEBAQEBEF0HAtsFCCZLR0R0JTgcAxBwgwU/N0wmBAkMBD1zFYmDCHwYKhoWDAkEAoBAAwUAAAEAN//1BfUB/wAoAAATIRYUByEXFhcWFRQjIiYnJicuAScmJzQ3PgE3PgUzMhUUBwYHpQVBDw/6vwNnIAYVDAcCAgISZUcPAxJHZRIBAgEDBAgGFQYeaQEOCBgIA097FgMLBQoHCklyHAYFDQQcckkDDAQIAwILAxZ3UwABAFT/9QYRAf8AJgAANjQ3ISYnJic0JjU0MzIWFxYXHgEXFhQHDgEHBgcOASMiNTQ3NjchVA4FQkcnGQgBFAwHAgMIFmZECQlEZhYHBAIHDBUGH2z6vu0aBzVLMC8CBAELBQkUFUNpFwMQAxdpQxUTCgULAxZ9UAABADf/9QcLAf8ARwAAEyEmJyYnNCY1NDMyFhcWFx4BFxYUBw4BBwYHDgEjIjU0NzY3IRcWFxYVFCMiJicmJy4BJyYnNDc+ATc+BTMyFRQHBgelBflHJxkIARQMBwIDCBZmRAkJRGYWBwQCBwwVBh9s+gcDZyAGFQwHAgICEmVHDwMSR2USAQIBAwQIBhUGHmkBDjVLMC8CBAELBQkUFUNpFwMQAxdpQxUTCgULAxZ9UANPexYDCwUKBwpJchwGBQ0EHHJJAwwECAMCCwMWd1MAAQA4/+gGEQINADsAACUhHgMVFAchFxYXFhUUIyImJyYnJicuATQ2Nz4BNzY3MxYVFAcGDwEhFhUUBwUhIicFIQcGBxYXFhcBEgTxAQcDAw/7PAozIwUUCwcESo8qLgoGBgpmnS4OBAYSBSMzCgTEDw7+wv7CAQL+1v64CihNBAY3NK0BBQMHBA0HCjZFDAQIAwmSRhUMAwUKBQMag1wMAQEJAwxFNgoHDQsIAQEBCB4nAwIYKAAAAAEAOP/oBi4CDQA2AAABNDMyFhcWFxYXFhQHDgEHDgEjIjU0NzY/ASEmNTQ3ITc2NyYnJi8BISciIwUhJjU0NyEnJicmBMIQDgYGUKUgHBERZp0uBAYMFAUjMwr7Hw4QBQsKKE0EBjc0Cv1zAQEB/sP+whAOBOEKMyMFAgILAwqfRQ4HBRAFGoRbCQMIBAxFNgoHDQ8FCB4nAwIYKAgBAQUPDQcKNkUKAAIAOP/oBwoCDQA/AFYAAAE0MzIWFxYXFhcWFAcOAQcOASMiNTQ3Nj8BIRcWFxYVFCMiJicmJyYnLgE0Njc+ATc2NzMWFRQHBg8BIScmJyYBITc2NyYnJi8BISciIwUhBwYHFhcWFwWeEA4GBlClIBwREWadLgQGDBQFIzMK+zsKMyMFFAsHBEqPKi4KBgYKZp0uDgQGEgUjMwoExQozIwX7dAUdCihNBAY3NAr9cwEBAf67/rgKKE0EBjc0AgILAwqfRQ4HBRAFGoRbCQMIBAxFNgoKNkUMBAgDCZJGFQwDBQoFAxqDXAwBAQkDDEU2Cgo2RQr+rwgeJwMCGCgIAQEIHicDAhgoAAEAN//1BhEB/wA3AAATNjMyFx4BHQEhJicmJzQmNTQzMhYXFhceARcWFAcOAQcGBw4BIyI1NDc2NyEVFAYHBiInLgE1NDkGDAgGBQEFRUcnGQgBFAwHAgMIFmZECQlEZhYHBAIHDBUGH2z6uwEFBhAGBQEBqQwGBRQ9SzVLMC8CBAELBQkUFUNpFwMQAxdpQxUTCgULAxZ9UEs9FAUGBgUmiqsAAQAcAAAC0QKrAFgAAAEVFAYrASIHBhEQFxY7ATIXFhUUBwYhICcmNTQ3NjsBMjc2ERAnJisBIicmNTQ2MxYzMjYzMhYdARQGKwEiBwYZASERECcmKwEiJj0CNDYzMhYyNjMyFhUC0QgUFSsJAQEJKxUYAgIGAv6t/q4CBgICGBUrCQICCSsVGAICBhAlXxlYFA0ECBQVKwkCASMCCSsVFAgGDBBVQlUQDAYClAYMBQsD/uf+5gMLBgMOEgQBAQQSDgMGCwYBFwEWBgsGAw4RBgIBCA4GDAULBv7i/uABIAEeBgsFDAYICQUBAQUJAAAAAgBU/3YCtgJ8ACgAMAAAJRQjIiYnJicmJyYnIicmNDc2MzY3Njc2Nz4BMxYVBgcGBxYXFhcWFxYENDchFhQHIQK2FAsIAggnVfBNQycECgoEJ0NN8FUnCAIJDBIIL068QSIWJ3ggB/2gDgJFDw/9u1AXChA9L2cYBwECBxYHAgEHGGcvPQ8MAxVPOF0mDwsHETxtGOoaBwgYCAAAAgBT/3YCtgJ8ACoAMgAAATIWFRQHBiMEBwYHDgEjIjU2NzY3JicmJyYnJjU0MzIXFhcWFxYXFhcyNgA0NyEWFAchAqIIDAsEJ/7me2APAggLFAgvTrxBIhoieCEIEgQGCgIIJ1XxS0QKFv20DgJFDw/9uwFvCwoLBwIGSzpoEAoXTzhdJg8LCQ87biIPFgMFEz0vZxgHAQH+DhoHCBgIAAIAAAAAASwAZAADAAcAADE1MxUzNTMVZGRkZGRkZAAAAgAAAAABLABkAAMABwAAMTUzFTM1MxVkZGRkZGRkAAABAAAAAABkAGQAAwAAMTUzFWRkZAAAAAAAABYBDgABAAAAAAAAACwAWgABAAAAAAABAAwAoQABAAAAAAACAAcAvgABAAAAAAADACQBEAABAAAAAAAEABQBXwABAAAAAAAFAAsBjAABAAAAAAAGABQBwgABAAAAAAANAPcDxwABAAAAAAAOABoE9QABAAAAAAAQAAwFKgABAAAAAAARAAcFRwADAAEECQAAAFgAAAADAAEECQABABgAhwADAAEECQACAA4ArgADAAEECQADAEgAxgADAAEECQAEACgBNQADAAEECQAFABYBdAADAAEECQAGACgBmAADAAEECQANAe4B1wADAAEECQAOADQEvwADAAEECQAQABgFEAADAAEECQARAA4FNwBDAG8AcAB5AHIAaQBnAGgAdAAgACgAYwApACAAMgAwADAAOQAtADIAMAAxADAAIABEAGUAcwBpAGcAbgAgAFMAYwBpAGUAbgBjAGUALAAgAEkAbgBjAC4AAENvcHlyaWdodCAoYykgMjAwOS0yMDEwIERlc2lnbiBTY2llbmNlLCBJbmMuAABNAGEAdABoAEoAYQB4AF8ATQBhAGkAbgAATWF0aEpheF9NYWluAABSAGUAZwB1AGwAYQByAABSZWd1bGFyAABGAG8AbgB0AEYAbwByAGcAZQAgADIALgAwACAAOgAgAE0AYQB0AGgASgBhAHgAXwBNAGEAaQBuAC0AUgBlAGcAdQBsAGEAcgAARm9udEZvcmdlIDIuMCA6IE1hdGhKYXhfTWFpbi1SZWd1bGFyAABNAGEAdABoAEoAYQB4AF8ATQBhAGkAbgAtAFIAZQBnAHUAbABhAHIAAE1hdGhKYXhfTWFpbi1SZWd1bGFyAABWAGUAcgBzAGkAbwBuACAAMQAuADEAAFZlcnNpb24gMS4xAABNAGEAdABoAEoAYQB4AF8ATQBhAGkAbgAtAFIAZQBnAHUAbABhAHIAAE1hdGhKYXhfTWFpbi1SZWd1bGFyAABDAG8AcAB5AHIAaQBnAGgAdAAgACgAYwApACAAMgAwADAAOQAtADIAMAAxADAALAAgAEQAZQBzAGkAZwBuACAAUwBjAGkAZQBuAGMAZQAsACAASQBuAGMALgAgACgAPAB3AHcAdwAuAG0AYQB0AGgAagBhAHgALgBvAHIAZwA+ACkALAAKAHcAaQB0AGgAIABSAGUAcwBlAHIAdgBlAGQAIABGAG8AbgB0ACAATgBhAG0AZQAgAE0AYQB0AGgASgBhAHgAXwBNAGEAaQBuAC4ACgAKAFQAaABpAHMAIABGAG8AbgB0ACAAUwBvAGYAdAB3AGEAcgBlACAAaQBzACAAbABpAGMAZQBuAHMAZQBkACAAdQBuAGQAZQByACAAdABoAGUAIABTAEkATAAgAE8AcABlAG4AIABGAG8AbgB0ACAATABpAGMAZQBuAHMAZQAsACAAVgBlAHIAcwBpAG8AbgAgADEALgAxAC4ACgBUAGgAaQBzACAAbABpAGMAZQBuAHMAZQAgAGEAdgBhAGkAbABhAGIAbABlACAAdwBpAHQAaAAgAGEAIABGAEEAUQAgAGEAdAA6AAoAaAB0AHQAcAA6AC8ALwBzAGMAcgBpAHAAdABzAC4AcwBpAGwALgBvAHIAZwAvAE8ARgBMAABDb3B5cmlnaHQgKGMpIDIwMDktMjAxMCwgRGVzaWduIFNjaWVuY2UsIEluYy4gKDx3d3cubWF0aGpheC5vcmc+KSwKd2l0aCBSZXNlcnZlZCBGb250IE5hbWUgTWF0aEpheF9NYWluLgoKVGhpcyBGb250IFNvZnR3YXJlIGlzIGxpY2Vuc2VkIHVuZGVyIHRoZSBTSUwgT3BlbiBGb250IExpY2Vuc2UsIFZlcnNpb24gMS4xLgpUaGlzIGxpY2Vuc2UgYXZhaWxhYmxlIHdpdGggYSBGQVEgYXQ6Cmh0dHA6Ly9zY3JpcHRzLnNpbC5vcmcvT0ZMAABoAHQAdABwADoALwAvAHMAYwByAGkAcAB0AHMALgBzAGkAbAAuAG8AcgBnAC8ATwBGAEwAAGh0dHA6Ly9zY3JpcHRzLnNpbC5vcmcvT0ZMAABNAGEAdABoAEoAYQB4AF8ATQBhAGkAbgAATWF0aEpheF9NYWluAABSAGUAZwB1AGwAYQByAABSZWd1bGFyAAAAAAACAAAAAAAA/4MAMgAAAAAAAAAAAAAAAAAAAAAAAAAAASUAAAABAAIAAwAEAAUABgAHAAgACQAKAAsADAANAA4ADwAQABEAEgATABQAFQAWABcAGAAZABoAGwAcAB0AHgAfACAAIQAiACMAJAAlACYAJwAoACkAKgArACwALQAuAC8AMAAxADIAMwA0ADUANgA3ADgAOQA6ADsAPAA9AD4APwBAAEEAQgBDAEQARQBGAEcASABJAEoASwBMAE0ATgBPAFAAUQBSAFMAVABVAFYAVwBYAFkAWgBbAFwAXQBeAF8AYABhAQIAjgCkANoAgwCTAI0A8AC4ANcBAwDYAOEBBAEFAQYA2wDcAN0A2QEHAQgBCQEKAQsBDAENAQ4BDwEQAREBEgETAKgBFAEVARYBFwEYARkBGgEbAJ8BHAEdAR4BHwEgASEBIgCyALMAtgC3ALQAtQCCAMIAqwEjASQBJQEmAScBKAEpASoBKwEsAS0BLgEvATABMQEyATMBNAE1ATYBNwE4ATkBOgE7ATwBPQE+AT8BQAFBAUIBQwCYAUQBRQFGAUcBSAFJAO8BSgFLAUwBTQFOAU8ApQFQAJIBUQFSAVMBVAFVAVYBVwCcAVgBWQFaAVsApwFcAV0AjwFeAJQAlQFfAWABYQFiAWMBZAFlAWYBZwFoAWkBagFrAWwBbQFuAW8BcAFxAXIBcwF0AXUBdgF3AXgBeQF6AXsBfAF9AX4BfwGAAYEBggGDAYQBhQGGAYcBiAGJAYoBiwGMAY0BjgGPAZABkQGSAZMBlAGVAZYBlwGYAZkBmgGbAZwBnQGeAZ8BoAGhB3VuaTAwQTAHdW5pMDIzNwd1bmkwMkM5B3VuaTAyQ0EHdW5pMDJDQglncmF2ZWNvbWIJYWN1dGVjb21iB3VuaTAzMDIJdGlsZGVjb21iB3VuaTAzMDQHdW5pMDMwNgd1bmkwMzA3B3VuaTAzMDgHdW5pMDMwQQd1bmkwMzBCB3VuaTAzMEMHdW5pMDMzOAVHYW1tYQVUaGV0YQZMYW1iZGECWGkCUGkFU2lnbWEHVXBzaWxvbgNQaGkDUHNpB3VuaTIwMDIHdW5pMjAwMwd1bmkyMDA0B3VuaTIwMDUHdW5pMjAwNgd1bmkyMDA5B3VuaTIwMEEGbWludXRlB3VuaTIwRDcHdW5pMjEwRghJZnJha3R1cglhZmlpNjEyODkLd2VpZXJzdHJhc3MIUmZyYWt0dXIFYWxlcGgJYXJyb3dsZWZ0B2Fycm93dXAKYXJyb3dyaWdodAlhcnJvd2Rvd24JYXJyb3dib3RoCWFycm93dXBkbgd1bmkyMTk2B3VuaTIxOTcHdW5pMjE5OAd1bmkyMTk5B3VuaTIxQTYHdW5pMjFBOQd1bmkyMUFBB3VuaTIxQkMHdW5pMjFCRAd1bmkyMUMwB3VuaTIxQzEHdW5pMjFDQwxhcnJvd2RibGxlZnQKYXJyb3dkYmx1cA1hcnJvd2RibHJpZ2h0DGFycm93ZGJsZG93bgxhcnJvd2RibGJvdGgHdW5pMjFENQl1bml2ZXJzYWwLZXhpc3RlbnRpYWwIZW1wdHlzZXQIZ3JhZGllbnQHZWxlbWVudApub3RlbGVtZW50CHN1Y2h0aGF0B3VuaTIyMTMHdW5pMjIxNQd1bmkyMjE2DGFzdGVyaXNrbWF0aAd1bmkyMjE4B3VuaTIyMTkMcHJvcG9ydGlvbmFsBWFuZ2xlB3VuaTIyMjMHdW5pMjIyNQpsb2dpY2FsYW5kCWxvZ2ljYWxvcgxpbnRlcnNlY3Rpb24FdW5pb24Hc2ltaWxhcgd1bmkyMjQwB3VuaTIyNDMJY29uZ3J1ZW50B3VuaTIyNEQHdW5pMjI1MAtlcXVpdmFsZW5jZQd1bmkyMjZBB3VuaTIyNkIHdW5pMjI3QQd1bmkyMjdCDHByb3BlcnN1YnNldA5wcm9wZXJzdXBlcnNldAxyZWZsZXhzdWJzZXQOcmVmbGV4c3VwZXJzZXQHdW5pMjI4RQd1bmkyMjkxB3VuaTIyOTIHdW5pMjI5Mwd1bmkyMjk0CmNpcmNsZXBsdXMHdW5pMjI5Ng5jaXJjbGVtdWx0aXBseQd1bmkyMjk4B3VuaTIyOTkHdW5pMjJBMgd1bmkyMkEzB3VuaTIyQTQNcGVycGVuZGljdWxhcgd1bmkyMkE4B3VuaTIyQzQHZG90bWF0aAd1bmkyMkM2B3VuaTIyQzgHdW5pMjJFRQd1bmkyMkVGB3VuaTIyRjEHdW5pMjMwOAd1bmkyMzA5B3VuaTIzMEEHdW5pMjMwQgd1bmkyMzIyB3VuaTIzMjMHdW5pMjNCMAd1bmkyM0IxB3VuaTI1QjMHdW5pMjVCOQd1bmkyNUJEB3VuaTI1QzMHdW5pMjVFRgVzcGFkZQd1bmkyNjYxB3VuaTI2NjIEY2x1Ygd1bmkyNjZEB3VuaTI2NkUHdW5pMjY2Rgd1bmkyN0U4B3VuaTI3RTkHdW5pMjdFRQd1bmkyN0VGB3VuaTI3RjUHdW5pMjdGNgd1bmkyN0Y3B3VuaTI3RjgHdW5pMjdGOQd1bmkyN0ZBB3VuaTI3RkMHdW5pMkEzRgd1bmkyQUFGB3VuaTJBQjAHdW5pRUZGRAd1bmlFRkZFB3VuaUVGRkYAAAAAAAH//wACAAEAAAAOAAAAGAAAAAAAAgABAAMBJAABAAQAAAACAAAAAAABAAAAAMmJbzEAAAAAxvkyTwAAAADJ9CXX"; - var callAddFont = function() { + var callAddFont = function () { this.addFileToVFS("mathjax_main-normal.ttf", font); this.addFont("mathjax_main-normal.ttf", "mathjax_main", "normal"); }; diff --git a/examples/MathJax/MathJax_Math-italic.js b/examples/MathJax/MathJax_Math-italic.js index d7308731e..57641d660 100644 --- a/examples/MathJax/MathJax_Math-italic.js +++ b/examples/MathJax/MathJax_Math-italic.js @@ -1,7 +1,7 @@ -(function(jsPDFAPI) { +(function (jsPDFAPI) { var font = "AAEAAAANAIAAAwBQRkZUTVp2x1wAAGTMAAAAHEdERUYAkwAGAABkrAAAACBPUy8yRYZZLgAAAVgAAABgY21hcAm5h6sAAANQAAAB0mdhc3D//wADAABkpAAAAAhnbHlm67Ny7QAABfQAAFaAaGVhZP23CUYAAADcAAAANmhoZWEIKQHVAAABFAAAACRobXR45VIM9gAAAbgAAAGYbG9jYYXicTQAAAUkAAAAzm1heHAAqwCnAAABOAAAACBuYW1ldv3PkwAAXHQAAAZOcG9zdCRbvc0AAGLEAAAB3QABAAAAAQAAanzVFV8PPPUACwPoAAAAAM1Q4zcAAAAAzVDjN//Z/yYEGwLNAAIACAACAAAAAAAAAAEAAAPY/l4AWgPK/9n/RgQbAAEAAAAAAAAAAAAAAAAAAABmAAEAAABmAKQAAwAAAAAAAgAAAAEAAQAAAEAAAAAAAAAAAgG8AZAABQAAAooCvAAAAIwCigK8AAAB4AAxAQIAAAAAAAAAAAAAAACAAADvEADs7QAAAAAAAAAAUGZFZAABACDv/wMg/zgAWgLNANogAACPXgMAAAG5AqgAAAAgAAEA+gAyAAAAAAFNAAAA+gAAAwoAiwLuACMC9wAjAssAMgM8ACEC4gAfAoMAHwMSADIDPwAfAbgAGgIrADkDUQAfAqkAIAPKACMDIwAfAvsAMgKCACEDFwAyAvcAIQJlADQCSAAVAqsAPAJHADQDsAAzAzwAGgJFAB4CqwA6AhEAIQGtACgBsQAiAggAIQHSACcB6gA3Ad0ACgJAADABWQAVAZz/9AIJADABKgAmA24AFQJYABUB5QAiAff/2QG+ACEBwwAVAdUANQFpABMCPAAVAeUAFQLMABUCPAAjAeoAFQHRACMA+gAAAmcAHwNBADAC+wAyArYAIwLmADUDPwAfAwwAOgJHABwCmwAYAmQAFQMEAFACgAAiAjYAFwIGAAsBvAAkAdIAGwG2ACwB8QAVAdUAIwFiADACQAAxAkcALwJbABcB7gAtAbYAFQHlACICOgATAgUAFwFrAB8COwAfAbUAEgIcABUCjgAyAnIAGQKLABUCbgAPAk8AFQJUACsDPAATAgUAQwGWACgCvAAAASwAAABkAAAAAAADAAAAAwAAABwAAQAAAAAAzAADAAEAAAAcAAQAsAAAACgAIAAEAAgAIAAvAFoAegCgA5QDmAObA54DoAOjA6YDqQPJA9ED1gPxA/Xv////AAAAIAAvAEEAYQCgA5MDmAObA54DoAOjA6UDqAOxA9ED1QPxA/Xv/f///+P/1f/E/77/mfyn/KT8ovyg/J/8nfyc/Jv8lPyN/Ir8cPxtEGYAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEGAAABAAAAAAAAAAECAAAAAgAAAAAAAAAAAAAAAAAAAAEAAAMAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eAAAAAAAAHyAhIiMkJSYnKCkqKywtLi8wMTIzNDU2NzgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFQAAABEAAAAAAAAAAAAAAAAOQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASABIAEgASADIApgE2AaICEAKuA0QD4gS+BSIFcgY2BrAHWgfYCCQIqAk0CewKagrwC3IL3gyUDUYNyA4mDpgPAA9WD9gQMhCaEQQRcBHUEjwSyhMgE74ULhRuFQwVeBXQFj4WnBcWF3IX/hiGGRgZlBmUGfoaNBq+GyIb0hxgHM4dTh34HqofRB/CIDAghCDwIU4hyiIoInwivCMwI3Qj4CQoJLwk/CVYJaQl/CZCJoYm7CdiJ9AoWCjOKVwp4CpgKsorFCskKzQrQAAAAAIAMgAAAMgCFQADAAcAADMRMxEnMxEjMpZkMjICFf3rMgGxAAEAi/8pAn4CzAAQAAAXIjU0NzYANzYzMhYVFAAHBp8UBQ0BuwIEDAgM/jAEBNcSBwcaA14CCQwIBfx7AgMAAAACACMAAALWAswAQwBNAAAzJjQ2PwEzNjc2ADc+ATsBFhUTEhcWMzIeARUUBw4BIyImIyIHIy4BNzY/ATM2NycjBwYHBhUUFzIVFAcOASMiJiMiBwE0AicHBg8BFzIqBwcCBA5GIAYBXwIFCRIRBhwcAgU8CwkFAwMFCxJTGV4dDAYBAwQCBBQ2CgzuIiQBBC4TAwMGChFKE0cUAdIZARsQL1pnZwcIGgIDAy8GAlcDCQMJAf69/r0DCwEEBQIMDwcCAgYFEA0DAwIPljo8BQgHGQQKBQkOCAICAQQLASIBKxtQmAEAAAAAAwAjAAAC9AKrADkATwBiAAABNC4DKgEmIiMiJicmNzY3NjMgFxYXFhUUBw4BDwEeARUUBwYHBiMiJyY1NDc2NzY7ATI3Njc2EgU0JicmJyIGKwEGBwYPATMyNz4BNzYDNCYnJiMiBxQGDwEUFhcyNz4BASACBAQIBgoHDAQYCgICAwUEAYEBAw5FJygTFmE1CkJRQk1qB8zIAwQCBQUECwYbIQ4FA4oBaSMdB1UULA0NDgQBIR9RUQwpSRQVNi8kBk12ASMREhhFWQdBZQJ0AQMBAgEBAgUDDxICAQIKJiYzIyEoQQsDCUo3SD9KCQECAwUHBxMCAQMDCQQCJEUiMAgCAQEBBgJ/fgIHMyQm/uksOgUBAQKORkYEAQEBB2YAAQAy/+oC+ALBAEoAAAE0JiMiBwYHBgcGFRQXFjMyNz4BNz4BMzIVFAcOAQcGIyImJyY1NDc+ATc2MzIXFhceAjMyNz4CPwEzMhUUBwYVDgErAS4BNzYCi0lENT5sPTcOAUwwRiYtO2ASBAUNFQIYkFojI2eMEwdLLYRQOzEkBjwpAgwJAQMYBxAQAg8GDiAkAgYPEAUBAgIB4VNfGS5tYYMIFXIyIhEYbkENBAgCCFmOFQl2Wx0keHFFahoSAQooAhAMGgYQEQIPBwSFiwEFAwUDEBQAAAAAAgAhAAADIwKrADEASwAAATQuAyoBJiIjIicmNzY3NjMeARceARUUBwYHBg8CIyInNSY1NDc+ATMyNzY3NhIFNCYnKgEmIgYiIwYHBgIVFBYzMjc2Nz4CAR8CBAQIBgoHDAQiAwEDBQQCxacoFE9eDBxZZYEOwm9ZAQIDBAgTGyEOBQOKAaBORgIYIx4jGAENBQKOF0FRCl9BJC4oAnQBAwECAQEHAw4TAgEBAQUSgmEyMHFcaBUCAQUBBAECDBAFAwMJBAIkkEpWBwEBAQgE/cgDBAEBD0EkYJ4AAAEAHwAAAvwCqABvAAABNDY1NCYnJiMGBwYHDgEVFjsBMjY3Njc+BTMyHgMXBwYHBiInJjc2NTQnJisBDgEVFBYXMjY3PgE3PgEyFxYVBgcGISImJzUmNTQ3PgEzMjc2NzYSNTQjJicjLgE3NjchFhUUBgcGKwEmAroGHSUheFUEBwMBPRcZCUE5EAYJAQEBAgUHBgUGBAEDASEhAwMaAwYFBxQSUDQGPxdEXj0dMUEmCgYXAwZpBQP+5dhIAQIDBAgTGyEOBQKLBAgtHwYBAwQGAioHGgECEgwHAcIKPAgsLgkHAQEDBwPwAgERJAsgAwkDBAEBAQIBBQGEhQIDAwMVGhMdCAgV/wIEAQEFChBQWxYEAgQH/gUCAQQBBAECDBAFAwMJBQIoBAcDAgYFDhIDBwQF1wIHBgAAAAABAB8AAALtAqgAagAANyIGIyInJjU0Nz4BMzI3Njc2EjU0IyYnIy4BNzY3IRYVFAYHBisBJjU0PgE1NjU0Jy4BIwYHBgcGDwEzNjc2NzY3PgE0PgIyOwEWFRQCBwYrAS4BNzY1NCcmKwEHBhQXFjsBHgEHBgcjJrkcWRQMAwIDBAgTGyEOBQKLBAgtHwYBAwQGAhsHGgECEgwHAQEELhU4VlAECAIBISA3PAYhDxUOAQICAwUGBQwHPwICEgwGAgQHGRJCNyAgBgxHGQYBAwQGESkCAQUEAQIMEAUDAwkFAigEBwMCBgUOEgMHBAXXAgcGBAIFCgUdHUgTCQQBAQMGAYKBAQEGDxI2AwgDBQECBQUD/wAEBwUHDhwUHgcGf3wMAgYGBRANBgIAAAABADL/6gL4AsEAdAAABSImNTQ3PgE3NjMyFxYXHgIzMjc+Aj8BMzIVFAcGFQ4BKwEuATc2NTQmIyIHDgEHBhUUFxYXMzI2Nz4BNTQmJyMuATc2NzMWMzI2MzIVFAcOBSMiBwYPAQ4BBw4IIyInLgEnNAYHDgEBQnaaSy2EUDsxJAY8KQIMCQEDGAcQEAIPBg4gJAIGDxAFAQICSUQ1PmR3EgIUL3wGNloRAxgbLiUGAQMEBhEoZBpIDw4CAQIBAwQIBhQVCAMEAw8GAwYEBQMDAgMCAgMDCR8FBAQhbBaVfXhxRWoaEgEKKAIQDBoGEBECDwcEhYsBBQMFAxAUGFNfGSrDiRIVOSpbBy4kCF8FCAQBBgQRDQYCAQgDDAMJAwUBAQMDCA0NORYMGhESCwsHBQIDBSMKAQMDHyYAAQAfAAADeAKrAKMAAAEyFhQHBgcjKgEGIiMGBwYHBgIVFDMWFzMeAQcGByMmIyIGIyI1NDY3Njc2OwEyNzY3NhI1NCsBBwYVFBcWFzMeAQcGByMmIyIGIyI1NDc2NzY7ATI3Njc2EjU0LgMqASYiIyImJyY3Njc2MxYzMjYzMhcWBwYHIyoBBiIjBgcGBwYHDgEPARQ7ATc0NzY1NC4CIiYiIyI1NDc2MzIWMzI2A2cLBgIFBQICBggKBDUIBAMDiwQILh8FAQMEBg8lYRlVFBECAQUFBAsGGyEOBQNCkZEhIgMHMB8FAQMEBg8lYRlVFBEDBQUECwYbIQ4FA4oCBAQIBgoHDAQYCgICAwQFAg8pXxhVEw0CAgMFBQICBggKBDUIBAMDHQcQBASRkQEfHAMGBwwJDwUkBgMOElUhIFMCqgQMCBEDAQEGAgUF/dMDBwMCBwMRDQYCAQgBCwMTAgEDAwkFAQYDAYeGBQYBAwIHAxENBgIBCQIMEwIBAwMJBAIkDwEDAQIBAQIFAw8RAwECAQYDDxEDAQEGAgUEdxpADw8CAwN4cwgCBAIBAQoVCQUCAgAAAAABABoAAAH4AqsARAAANyI1NDc2NzY7ATI3Mjc+ATc2NxI1JjUmKwEuATc2NzYzFjsBMjczFhQHBgcGIyIHBgcGAg8BFBcWFzMeAQcGByMmIyIGKxEDBQUDDAY9DwEBBQwrDAZGAgo9FAYCBAMEAw5ISjdACQoHAwMEAxQfIQ0GA0giIgcKLSAFAQMEBhAlZBlbAQkCDBMCAQcBAiqvLRoBGAIEAQYFBw0PBAICAgcICg8EAgMDBwT+5oyLCAEDAQcDEQ0GAgEAAAEAOf/qAnkCqwA2AAABNCsBLgE3NjczFjMyNjMyFxYVFAcOASsBIgcGBwYHDgEjIiY1NDYzMhcUBgcGFBcWMzI2NzYSAb9dGQYCBAQGESlpG04QCwECAwQHDwksBgQ6PwEVfE89TSkiLQUhGggHGjEmSRAEdwJxDAUHDw0GAgEFBAECDBAFDg3q+AE9WD0xIzMsHSgFAgMHHUMwDAHcAAABAB8AAAN5AqsAjAAAATQuAyoBJiIjIicmNzY3NjMWMzI2MzIVFAcGBwYjBgcGBwMyADc2NTQnIjU0Njc2MzIWMzI3NhYVFAYHBiMGDwEOAQcXHgEXFhcWFxYXMx4BBwYHIyYjIgcjLgE3Njc2MzI1NC8BDwIGFRQXFhczFhUUBwYjIiYjIgYjIicmNTQ3PgEzMjc2NzYSAR0CBAQIBgoHDAQiAwEDBQQCDylfGFUTEQMFBAQcNggEA1EBAW8EDhkQBwEDDhBLGDYUDwkHAQMQSz0MAsoBCQkmEEsFAgMOJRUFAQMEBgsoN3cSCgYBAwMEAwoyOzpERBcXAwcwHwYHBQsRVyEgUxANAwIDBAgTGyEOBQOKAnQBAwECAQEHAw4SAwECAQgFCRQBAgEGAgX+wgEgBA4JDwILAhkCBQICAQMIBBkBBQUuCAGeARYWWiixBgICCgEHAxENBgMDBgUQDAQDGQWMijU1XVwFBgEDAgkCEA4FAgEFBAECDBAFAwMJBAIkAAAAAAEAIAAAAocCqwBTAAABNC4DKgEmIiMiJicmNzY3NjMWMzI2MzI+ATsBHgEHBgcjBgcOAQcOAQ8BFBYXMjY3PgE3Njc2OwEWFA4BBwYHBiAnJjU0NzY3NjsBMjc2NzYSAR0CBAQIBgoHDAQYCgICAwUEAww2SQ40DA8rFwMMBgEDBAUmRQwHDjwQJAkJEjJLPyYoMRgHBAUMDQYpLgMDAgP+AgMEAgUFBAsGGyEOBQOKAnQBAwECAQECBQMPEwEBAwEBAQYFEA4FAQgEMe9BkyQkBAEBChYXTUAUCAMJBHJ/CgYBAgIDBQcHEwIBAwMJBAIkAAABACMAAAQbAqsAdAAAISImIyIHBicmNTQ2NzYzNjc2EjU0IyIjJiciJjQ+ATMyFhcWGwE3PgE3Ejc+AT8BMzIXFhUUBhUGIwYHBgcGAhUUFxYXMxYVFAcGIyImIyIGIyInJjc+ATMyNzY3NhoBNQsBBiInJgsCAhUWOwEeAQcGBwYBCw5FG0gRGAMGBwECFEgRBIMDAQEKKhsKBwZjTxkDASQkFxhRL68CAQUBBmBgAwQGBCE2CAQDA4sDBzAfBgcFCxFUIB9RDw0DAgMECBMbIQ4FAkhGwsUJHgMCJydEQwZCCgYCBAQEBAIBAQICBwIZAgYEJAYCDQwEAwEDEBcEAQQE/ur+6SUkgUsBFwIBBAECAgMFAxkCBgEGAgUF/dQDBwEDAgkCEA4FAgEFAxAQBQMDCQQBHQEYAf7L/scJBwQBMgEz/vL+9gkhBQgOEAIBAAAAAQAfAAADeAKrAFYAADciNTQ2NzYzNjc2GwEmJyImJyY3Njc2MzIWHwEeARc3NjU0JyInJjc+ATQ+AjIzMhYzMjYzMhUUBgcGIwYHAwYjIicmCwICFRY7AR4BBwYHIyYjIgYuDwcBAhVEFARDRAI1HgsBAgMFBAJfTRcCNTVsATY1QBUCAgMBAgICAgQDDkkbGkMNDwcBAhRHEpUCEw4DA35/QUEGQgoGAgQEBg0fTRRFAQkDGgEGAyQGAQ8BEAECAgUDDxICAQEFfX3+BdXTDhoFBwMNAwgEBAICAwIKBBkBBQMl/bIHAgMBLAEr/vz/AAkhBQcPDQYCAQAAAgAy/+oC5ALAABcAMAAAATMyFx4BFRQHBgcGIyInJjU0NzY3Njc2BTQmJyYjIgcGBwYHDgEVFBYXFjMyNzY3NgHLESYKYnZXOVFpamtHTAESYhwgbwErRT0NEhUQPjcXIC5AOTMaFz07dzcdAsABDpBuh3lSM0RESnwjColzIBxc2UxiDAMECy0SJTu5WkhkEQgmTrJfAAACACEAAALvAqsAQgBbAAABNC4DKgEmIiMiJjQ+ATMWFx4BFxYVFAcGBwYHBgcjBwYUFxYXMxYVFAcGIyImIyIGIyInJjU0Nz4BMzI3Njc2EgU0JicmJyIGIiMGBw4CBxQzNjc2NzY3NgEfAgQECAYKBwwEGwoHBr++DTtPDAECDDRFbQdiXx4eAwcwHwYHBQsRVyEgUxANAwIDBAgTGyEOBQOKAWYsKQdJESQWAQ0FAiMiAVFUCEMkGxIKAnQBAwECAQEDEBcEAQIKPzMGFBkIOTNEEgEBd3QOAQMCCQIQDgUCAQUEAQIMEAUDAwkEAiQ7JiMIAQEBAQgGjoYBAgEBCiYbRikAAAADADL/PgLkAsAANABQAGEAAAU0Nj0BBwYjIicmNTQ3Njc2NzY3MzIXHgEVFAYPARUUHgEXHgEzMjY3NjMyFxQHBgcGIyImAzIWFzc+ATc2NTQnJiMiBw4BBwYVFBcWMzU0NhcyNycmJyYjIiYjIgcOARUUAY8DDy4makdMARJiHCBveREmCmJ2pnERAgEBCRwfJj4JBgcJAgcpRhkZLiQ0JC8FDU1fDwFEJzQwMlp4DwE2GAVHBy4sAQQhDAcDBgEECRQeUAszBwQEC0RKfCMKiXMgHFwLAQ6QbobpNAgFAQUHAyceLyAOCQYXeSMLOwEiNDAJNbx4CiF1Mh4ZLNGCCx5oNRUILUCJFQo3CwIBAwYjFiIAAAAAAgAh/+sC8wKrAGwAgwAAATQuAyoBJiIjIiYnJjc2NzYzFhcWFxYVFAcGBwYjFxYVFAcGFRQWMzI3Njc+ATMyFRQHBgcGIyInJic0PgM3NjU0Jy4BJyMHBhUUFxYXMx4BBwYHIyYjIgYjIjU0NzY3NjsBMjc2NzYSBS4BIyIGIiMGBwYCFRQzNjc2Nz4BNTQBHwIEBAgGCgcMBBgKAgIDBQQCrKwOWy8lBBd8LAYHQwUFDhgOBCYQBQYMFBgeKAgVaB8JAQECAggCDysPFD1FICEDBzAfBQEDBAYPJF8YVhQRAwUFBAsGGyEOBQOKAUcVRD8MGhMBDQUBQkVOGkEjEBYCdAEDAQIBAQIFAw8SAgEBAg0xKDEKFFk3EQUmSAw0MB8jHQIPNA4GDBInLAsCPxAYCw0QCBoKORAyGAcCAYKEAgcBAwIHAxENBgIBCQIMEwIBAwMJBAIkCxYNAQEIA/77AgEBBgswF0seHwAAAAABADT/6gKFAsEAWQAAATQmIyIGFRQWFx4BMxYXFhUUBwYHBgcGIyIvAQcOASMiNTQ3NjsBHgEHBhUeATMyNz4BNzY1NCcuAScuATU0Njc2NzY7ATIXMj4BNzI2MzIUDgEjIjU0NzQ2AilFQTdlHxkDhQEPFzwIBQ8+hAwWYzcKHBwGBw06AhINBQECBQRXSwoOL0sKAjQGhAMsNTkoM0gEBwtoKgEYHQUBBgINOQYNFAEDAghESlo+HywIAiMEECtVGh4bHHscAjcLHx8ECAPoBgUDDxkaQUACC04zCBdAFwEjAg1LNDJrHSwLAUAaIQUBDuUGCQYEBSEAAAABABUAAALAAqUAXwAAISImIyIHIy4BNzY3MzI3Njc2Mz4BNzY3EjU0KwEiBwYHBgcOASsBIiY1NDc2NzY3ITIdARcUFRQGBxQHBiMiLgInNDc2NTQuAyciBgcGAhUUFxYXMhYXFgcGDwEiAZ8bfSOBIw8GAQMEBhw8FREIAQEFCiMRC0YdH0MVKxYbIAcGCwMNBh4WDwYHAdSGASMBBAINBgcCBAEDCQwPJxwgLhkFAYwNDj0iDQIBAwQFAgMCAgYFEA0GAwEFAQMji0QrARMGBQYJGh5cFggGAgZaRSkTBwUBAQIBBtgBAwICAQEFAQcUNhkXHhAIAgEDBgH90wQHAgQBAgUDDhIDAQAAAQA8/+oC/wKrAF0AADcUFjMyNj8BNjU0JyInJjc+ATQ+AjIzMhYzMjYzMhUUBgcGIwYHBgcGBw4BIyImJyY1NDc+AjU0JyImJyY3Njc2MxYzMjYzMhcWBwYHIyoBBiIjBgcGBw4CBwaYPThSfRkzL0AVAgIDAQICAgIEAw9KGxpEDQ8HAQMTRxICMCkJHp5hUW4LAQICMzE5GAoCAgMEBQIPKV8YVRMNAgIDBQUCAgYICgQ1CAQDATY3AgKMNz1qS8nACBoFBwMNAwgEBAICAwIKBBkBBQMlBbypHlmKXEoGERcSCc3GCAcCAgUDDxEDAQIBBgMPEQMBAQYCBQLP4RQOAAABADT/6gMBAqsASQAAEyY1NDY3MxYzMjczHgEHBgcjBiMGBxQSFzc+ATc2NTQnIjU0Nz4BMzIWMzI3MxYVFAcGIwYHDgEHBgcADwIiJyY1JgMCJyYrATsHCgMLKj92FQoGAQMEBRUWCB0DOgFJSZICBS0TAwMGChFLEkUSBwcJAw42IAIJAQME/pAGBRISAwQDJCYBBi0LAn0HBAgYAwMDBgUQDgUCBQoC/g0BdXXuBAoFFwUKBQkOCAICBwQSDgMDHQIKAQYE/asDAwECAgMGAToBPgMLAAABADP/6gQYAqsAgQAAEyY1NDczFjMyNjMyPgE7AR4BBwYHIwYHBgcUEhcTJyYnJiciJyY3Njc2FxYzMjYzMhUUBgcGIwYHBhcUEhU3PgU3PgE1NCYjIjU0Nz4FMzIWMzI3MhUUBgcGIyIHBgcDAgcGIyInJgI1BwYHDgIHBiMiJzQCJy4BJzoHDQwqOgosCw0lFAIKBgEDBAUVHRMPAiEB6wIDBwYkHAICAwUEAxwiPR1PEBEGAQIYNAoDASACAgkOFRojFYEEJxYOAgEBAQIEBgUSSxFCEw4IAgMHPyIHAamoAQYSDwQDIQwWah9LJAEGFBMCLAECEB8CfQcEFg0DAQEBBgUQDgUBBQYFB/4qBwGeJSoDBAEHAw0UAgEBAgIHBBsBBgINAwQM/jsMAwMPFyQuPiTjDAMQEQoDCgMIBAQCAQECCwYYAgMvCwH+2P7YAQcFAwHnBxIlujeEPwEKBwMCeQEJBQEAAAAAAQAaAAADVAKrAIAAADMiNTQ3PgE3Njc+AScCJyYnIy4BNzY3MxYzMjYzMhYVFAcGIwYPARc3Njc+AScmJyInIiY3NjczFjMyNzMWFRQGByMGBwYHBgcGDwEUHgEXFhcyFRQHBiMiJiMiBiMiJyY3PgE3Njc2NSIvASIGBwYVFBcyFjMyFRQHDgEjIiYjIioQAwQGEFYxCtQBbQUJNhwGAQMEBg4iVxZUFAoGBwIPJg4CTTUvGxYKAQMVBQgJCAQEBgwXYVcMCAcJAxBNMQkCAgMEVlc/QgQKMyMHAw0PTB8eUhANAwIDBAYMEhQRAS4vAbsBCB0BCgEMAwMGDBNQFE4LBAwOBAEDMQrpAQEWBQsBBgUQDQYCAQMGGAcFBAwBwjszHxcQCA8GAggTDQYDAwcECBgDAygJAQMCBF9gAZ+kBAkBCAsVBQEBBQMQDwUBAQcIAnV2zwIIChMGAQoGCw0FAQABAB4AAQL7AqsAXQAAADI2MzIVFAYHBiMGBwYPAgYVFDMyFhUUBwYjIiYiBiMiNTQ2NzYzPgE3Nj8BAy4BJyI1NDc2NzYzFjMyNzMeAQcGByMiFRQSFzc+Azc2NzY1NCciNTQ3PgEzMgJ5MDoLDQcBAhNILQmDgRobRBEJBgMOElRAUhARBgECIycZBQMaGXsJEyMkAwQFAgwwPXoTCgYBAwQGDDhkAQMEEBomGGsHCSARAgMFCw4CqAMKAxoBBgUtCZqXaGsFCwMHFQkFAQEHBBsBBgEGCgVnZwFdCQQBCgIMEgMBAwMGBRANBg0F/uMBAwQTHSwdfQoNCRADCgIMDwcAAAEAOgAAAtMCqwA+AAA3NDc0ADcnIiMGBw4BBw4DFQcGIyInNz4CNTY3NjsBFhUUBwAPATM2Nz4BNzY3PgE7ATIVFAIHBiMiJyY6BgISAgoLP1oITFYYAQICAQEDEBEDIAgRCQMCA+fnBQb98AEDWV8ISVUcBwkIBwkEFVIFA+7tAgMIDwwBAlUCAgEBClJKAwYFBAECBQpsGjgeAQYBAgUDAhj9rQIDAQEJREkQHhkKCwT++gMCAgMAAAAAAgAh//YB+gG5ADcATgAAJTIeARUUBwYHBgcGIyInJhUmBwYHBgcGIyInJjU0Nz4BNzYzMhc2MzIWFRQCFRQzNjc2NzY3NjMFFBYzMjc+ATc+ATU0JyYjIgYHBgcUBgHnCQYEAxYgDRMIED8ZBQEDAgIwLwYTQiseAQdFMDpAMigQHg0USxwJCxUUBgQCCP6THx4dIQwpBAIzCxYpKD0QHQwBmQEEBAMMVCANCAIxDQEBAgICLQoBNyxEEAZAdSQtMR4QDA3+2RIqAQgUTBQBAS8kLBgILAgEzggMFitELE9VAxAAAgAo//UBpgK2ACwARgAAEzI2MzIUBw4BDwEUNzY3NjIXHgEVFAYjIicmNTQ3ND8BNiYjIiMiJyY3Njc2EzQjIgYjBgcGDwEUBgcGFRQXFjMyNz4BNzZZAY8BDCIIEwUEBiIqDBoMND6dXB0aTgYyMwIRFAcEFQMGBQQDA/o9AgkBNC4CAwMjAgYYEBghIhkfERICqwsShiJIEhMDBhwKAgIMVEBwsw0jcR0cAczMDgcDBRMOAgP+mlABCz0CBAQBjQofGTAYECAXQ0dIAAAAAAEAIv/1Aa0BugA6AAAlMhYVFAcGBwYjIicmNTQ3PgE3NjMyFxYVFAYjIiY1NDY3NjM3NC4BIyIHBgcOAQcGFRQXFjMyNzY3NgGWBBMfPl8WEWsqExMdg0oGDSMeOCYdExYUEAgDAQseFB4bFRYaIBALGhcnDxBePAl5EwQJHDgOAlglLS4wS2kIAQsYNB8nFRMRIAcFAQIHCA4JFhpIQy8cLhcYAg5FCgAAAAACACH/9gILArYASQBaAAABPgIzMhUUAgYVFDM2NzY3Njc2OwEyFRQHBgcGBwYjIicmFSYHBgcGBwYjIicmNTQ3Njc2MzIXFjU+ATc0JyYnIy4BNzYzMj4BAyYjIgYHBgcUBhUUFjMyPwEBtg8mEwEMkwIcCQsVFAYEAggEEwMWIA0TCBA/GQUBAwICMC8GE0IrHkQ+TBUUNx0FATUBBgsdFQYBAwUIARMjRRY1KD0QHQwBHx41OggCsAEDAggH/bEKCioBCBRMFAEBCAQMVCANCAIxDQEBAgICLQoBNyxEXVtMEwYqBgIE0wUMBAQBBgQREwIC/pdPRCxPVQMQBCQsSAsAAAIAJ//1Aa0BugAsAD0AACUyFhUUBwYjIicmJyY1NDc+ATc2OwEyFhcWFRQHBgcGByIHFAcGFRQWMzI3NicmIyIHBgcGFRQzMjc+ATc2AZYEEx9SbzcmFhIhCBWDXAEPAyo7CQECFVgxVSUBAgsqKnBJCR4GPiMlMRgLFCEcOzoTB3kTBAkcSBsMGzI/JiVObgoBJSAEDhIHRxYNAQIBDDEfLzdVCug0FB0+HgMBAgUYHA8AAAEAN/8zAiYCwQBKAAAXFjMyNz4CNzUjIicmNzY3PgEzMjU0Njc2NzYzHgEVFAYjIjU0PwEmIyIHDgIHFDMyFhUUBw4BKwEHBgcGBwYiJjU0NjMyFRQHdhsCFxEKMSoBLy8DBwUEAQINKDASAxUqKCskMSQbLCMJEgwdCQcTDAE3LRIHAg8uOBclCSI5JUgwJBssI6IGKhv94wEDAgQSDwEFAQECYApfJSECKCEdKColEQUGJh1iRQECAgYLFQUBer8olzYgKCEeKSolEQAAAAACAAr/MwHgAboANgBJAAAlDgEjIiY1NDc2NzYzMhc2NzYzMhYVFAIHDgEjIicmNTQ2MzIWFRQOAg8BMxYzMjc+ATc2NzYTLgIjIgYjBgcGBwYVFDMyPwEBNw87H0FLHS5WLikuKQICDhwNFHIDE3dKcxUFJBwSGAUICAMCAQoyJhYXKAgGCg1JCA8gFwIJASofHBkRPjk1CCsNHltFPzpgKxYwAgMXEAwP/joFNkcsCQ8aKBYSChILCQMCAwwLLRgTKzABJRocFwEKKiViRCBPRgoAAAEAMP/1AisCtgBLAAAFIiY1NDc2NzY1NCMiBwYPAgYHBiMiJjU0GwE0JyYnIy4BNzYzMjYzMhUUBwYVFDc2MzIWFRQHBgcGFR4BMzI2Nz4BMxYXFAcGBwYBnicyCi8NAzESCEMzByIgBQ0fDBdJSgYLHRUGAQMFCAGPAQwkJgc7RzdCAwkuEgEICxwxDgMGDRMBBBAjIgovJRAceUQPFzsCDlINh4IMGw8MDgEiASgMBAQBBgQREwsJC4yUAwIHNjY0Fw8zfjEWDgo9MwsEAwUBDjsmKwAAAAIAFf/1AS4ClQALAEcAABM0NjMyFhUUBiMiJgMiJjU0NzQ2NTY1NCsBIgcGBxQOAioBKwEmNDc2NzYzMhYVFAcGDwEGFRQzMjc2Nz4BMzIeARUUBw4BuCYZEhkoGBIYFycwAlwFEQIYFiAPAgECBQQGDgYDGjIbHyg0BQEtLQURDgssGQMFDgkHBAMTRwJYFyYYEhYoGP2wLicRBgLzAhAUGBchPQEFAQIGBgtWIhUuJw0RAnl5FgoZBhVUDAQBBAUECTlUAAAAAv/0/zQBkwKVAAsASAAAATQ2MzIWFxQGIyImBzQjIgcOAQcOARQGIisBJjc2NzY3MjYzFhceAR0BBwYHDgEHBiMiJjU0NjMyFhUUBxYzMjY/AT4DNTQBKSYaERcCJBsSGAoaCwwbMxEBBAYFBw4IBh4wIiMBDgUYFBoZMTMDEE0vGRgnMCgZExcgBQkiOQ4LCx8gFgJUGicVERsnFcodBAk6KgMIAQIIDUgmGwUBAQkQIyEQx8gIK0MNBiIhHCYWEyQTATokKit7fmEIBwAAAAEAMP/1AfcCtgBmAAATMjYzMhUUBwYVNjc2NzY3NjMyFhUUBiMiJjU0Nj8BJiMiBwYHBgcWFxYXFhUUBhUUMzI3Njc2MzIXFgcGBwYjIiY1NDY1NCcmJyYrAQ4CBw4BIyImNTQSPwE2JiMiIyInJjc2NzaJAY8BDDIyEwoSJTwYKCQeIyIfExkiFwcMDCIuEycdJy8RMBAJCxsSDxkUAhIOAgYFGyoZGC43BgYNJCENAg0XCwQFGg8MF0okJQIRFAcEFQMGBQQDAwKrCwgHysYHCgkNJDwPGyghJC0WEhkjAwIMIg8nHSELBhMhEhUNPAgoDxlPCAIEEVsgEjcuCSYIDQwZDgsxXC4MDRMPDAoBLJGRDgcDBRMOAgMAAQAm//UBCgK2ADoAABciJjU0NxM+AjU2JjQuBCoBIyInJjc2Nz4BMzIVFAIHFAYVFBcWNjc2NzY3NjsBFhcUBgcGBwaJLTYBQQ4gEQECBAMGBAkFCgMYBAEDBQQDjwMMkgIBDgQQBBwWBgQCCAQSARAHHCwKCzMtDAUBAjqDQgEDBgQDAgEBAQcDDhMCAQsIC/2+DgINAx0IAgECEFYUAQEFBAc3EEEKAgAAAAEAFf/1A1kBugB0AAAXIiY0NzY1NjU0IyIHBgcUDgIqASsBJjU0NzY3NjMyFxYVFDM3NjMyHwE3Njc2MzIWFRQHBgcGFR4BMzI2Nz4BMxYXFAcGBwYjIicmNTQ3Njc2NTQjIgcGDwIGBwYjIi8BJjU0PwE2NTQjIgcGDwIGBwZsDhQmJwMZCQsYGAIBAgUEBg4GDhQYGB0/GQsBCz1QYRQBCCUxHyA3QgMJLhIBCAscMQ4DBg0TAQQaRBIZJhsYDiwMAzESCEYxByEhBQ0eGAgBAiIkAzESCEYxByEhBQ0LDxqXmgcPDCQHE1wBBQECBgMNJToXGC0TCQILQFIDCiwUCzY0Fw8zfjAXDgo9MwsEAwUBDl0mCRgcHxMldT0PFzsCD1QMhoMKGxQDBAILhJIPFzsCD1QMhoMKGwABABX/9QJEAboAUAAAFyImNBI3NjU0IyIHBgcGFQYrASY1NDc2NzYzMhcWFRQzNzYzMhYVFAcGBwYVFDMyNjc2MxYXFAcGBwYjIicmNTQ3Njc2NTQjIgcGDwIGBwZsDhRMAgEYFxMLCgYCEQ4GBR4+CAk7GgsBCz5NN0IDCi0SESIxDQISEwEEGkQSGSYbGA4sDAMxEghGMQchIQUNCw8aASwNBRInJRUqFAEGBgMEEXYOAi0TCQILQDY0Fw85djAXGkgvCAMFAQ5dJgkYHB8TJXU9Dxc7Ag9UDIaDChsAAAIAIv/1AdwBuQAVACgAAAEzMhceARUUBw4BIiYnJjU0Nz4BNzYDFBYzMjc2NzY3NjU0IyIHBgcGAR8OIAg/SB8liYxWCgEDCTwoRF0vJhISSSQWDgFSPzAhFRQBuQELWkc7O0hZUEEGEBoQM2EiNf7HKzMGGFY2UQYZYTooTEkAAv/Z/z4B8QG6AFQAbwAAEyY1NDc2NzYzMhc3Njc2MhceARUUBw4BBwYjIicuAS8BDgEVFB4DMhY6ATsBHgEHDgEjIiYjIgcjJjQ2PwEzNjc2Ejc2NTQjIgcGBxQOAioBIyU0IyIGIwYHBg8BFA4BBwYVFhcWMzI2NzY3Nh0GDRMaGB1LFQotMAwaDDQ+ExliOhYaFhELGQYHASoBAwMFBQgGCgQZBQEDAwYKEEkSRhMIBwcCBBQiBQN1AgEZDAgYGAIBAgUEBgFwPQIJATQuAgMDBw8GGgcGFicgNhISExIBFgYDCCc6GhhACSoLAgIMU0AvN0JjEgYGBRQHCAGsAQIDAgEBAQcEEAwHAgIHCBoCAwELBgHSDgUJKQcTXAEFAQIvUAELPQIEBAEbPBZqBBgLKS0kIk5IAAAAAAIAIf8+AcwBugA5AEoAAAUiBiMiNTQ2NT4BMzI3PgE3NAcGBwYjIicmNTQ3PgE3NjMyFzY3NjMyFRQDAhUUFzI7AR4BBwYHIyYTJiMiBgcGBxQGFRQWMzI/AQEGFEUQDwMEBxAwCggoAQcjKAYTQiseAQdFMDpAOSMYCCIMCkVHIgcEGQUBAwQGDR8NFjUoPRAdDAEfHjU6CMABCAIKAxAGBwWnAQEEHAoBNyxEEAZAdSQtNBgFGAgJ/uz+5AQIAQcDEQ0GAgIGT0QsT1UDEAQkLEgLAAAAAAEAFf/1Aa4BugA9AAAXIiY0EjU0IyIHBgcUDgIqASsBJjU0NzY3NjMyFxYXHgE3Njc2MzIWFRQGIyImNTQ3JiMiBwYHDgEHBgcGbA4UUBoLCBgYAgECBQQGDgYNExoYHScZFgcCAgclMAYUJS4jHRMZOBYOFRMhHgoKHSIFDQsPGgE+EicHE1wBBQECBgMIJzoaGBMREgYBCCkKASokICsWEjEPDQoQMBAidIwJGwAAAQA1//YBowG6AE8AADcyFhUUBgcGIw4BFxYXFjMyNzY1NCcmJy4FJyY1NDc2MzIXFhUUBiMiJjU0NzYzMjU0LgEjIgYVFBcWFxYXFhcWFxQHBiMiJyY1NDZ2ExcTEA0BAgMBAw8dL0wfDyEJKQUVBw0HCQYpKS5SYRQCHhkQFB4IAQISIxMnNg8KKS4OLxACARExh2scByWgFhIRIAgFAQEBBQgPMRkVIBAGCAEFAQQDBQQdNTgtNEQFDhwjEhAhDwQBAwwLLCMSDgkJCgcVMQYUIiVmPg8UHyoAAAEAE//1AUoCcgBBAAATJjU0Njc+ATsBNzY3NjMeARUUBg8BFDsBFhUUByMHBgcGFRQzMjc2NzY3PgEzMhUUBw4BBwYjIiYnJj0BNzY3NCMaBwcBAg8rNRMVAwwiDRMTCgoyMwcNayQlAQEbBwUyKQoIAgYMFAQLMRklKiQzCQIjIwEzAYEHAwQZAQUBUFEGHAEQDQdRJiUCBwQWDZGVCAUKKgEJRxAVBgMIAgogQRMcJR4IExKMjQECAAAAAQAV//UCJwG6AFYAAAEyFhUDBhUUMzY3Njc2MzIeARUUBwYHBiMiJwYHBiMiJyYnJjQ3Njc2NTQmKwEiBwYHFA4CKgErASY0NzY3NjMyFhUUBwYHBhUUFjMyNzY3Njc+ATc2Ac8OE0wBHBcQCw8CEgkGBAMeOAgQQhkGBjI0LCIpCgECBycWBQkFFxUgEQIBAgUEBg4GAxQqIyUqMhIpCAEYICoiFAUCJB4MCBEBrw8O/sIFCyoDIxc6CAEEBAMMdhMCOAUGLhIYMwcwDStoOxcOCxUgQAEFAQIGBgtFKCAvJRQvbjUIDyYoJBQMBJR4KQgPAAEAFf/1AdMBuwBBAAAXIiY1NDc2PwE2NTQjIgcGBxQOAioBKwEmNDc2NzYzMhYVFAcUBwYHFBcWMzI3Njc2NTQnJjU0NjMyFhUUBwYHBvFASwIJJhAGEwcJMxoCAQIFBAYOBgMYMhsjJzIDDy4DBQ0yGxU+KQgnDSUXGBoUEx0/C0E/EhAwYzASEBkDEmEBBQECBgYMTycVLCQRCQclfTUbESsQKZQcEiwjDA8XJS0fI1BNOYEAAAABABX/9QKyAbsAZQAAATIWFRQGBwYVFBYXFjMyNzY3NjU0JyY1NDYzMhYzFhUUBwYHBgcGIyImJw4BIyImNTQ3Njc2NTQmKwEiBwYHFA4CKgErASY0NzY3Njc2MzIWFRQHBgcVFBYzMj8BNTY3ND4BNzYBwQ4UOwICCw8SF0cqFwgBJBAmFwEEAioTFBIxUwYNLUQOFi0kQ1ECBicWBQkFFxUgEQIBAgUEBg4GAwoJJToGESkwEiwEJiQrIQUCARwgBA0Brw8ODeYRCxgdHQsMejwyBQoyHg0TFyMBCz8gU0wvfBABHxwdHkA/GwkoaTsXDgsVIEABBQECBgYLHhJLDwIvJBQvdjENKC09CRcdBQF2fQcbAAAAAQAj//UCCgG6AGMAABMmNTY3Njc2MzIWFzY3NjMyFhUUBiMiJjU0NzQnJiMiBwYHDgEHBhUUFjMyNjc+ATMyFRQHBgcGIyInBgcGIyInJjU0NjMyFRQHDgIjBxQXFjMyNz4CNzY1NCYjIgYHDgEjOgYEGy9HDgcjOw0NAyUwKTMjHRMYMgsKEw0GJhIDNAIDHBcqRAwDBg0TAhE1LzRGJB0tCRE6GAokHCsjAgYEAQMPDA4kGgkdGgMFGhctQg0CBQ4BFgYFGypHCwIkGxEEKi8iHyoWEi4RAQYGAhAyCM8NDw8YHEcrCgMIAQo+LiU/LQ8CKREXHioqJREBAwIBAwYFLRBpbwobDBgcRS0JAwABABX/MwHwAboAZwAAATIWFAIHDgEHBiMiJyY1NDc2MzIVFAcOAiMHFhcWOwEyNz4BNzY1Bw4BBwYjIiYnJjQ3Njc2NTQmKwEiBwYHFA4CKgErASY0NzY3NjMyFhUGBxQHBgcGFRQWMzI+ATc0PgE3Njc2Ac4OFGIHEEcvNi9MGwoTFRcsIwIGBAEDAxIQEAgRCSZEEgsGBhoNFBMzQgoBAgcnFgUJBRcVIBECAQIFBAYOBgMVKiIlKjICAQ8pCAEYIBcpFRAKEwkmBA0Brw8a/nYTMVMYGjAOGiITEyolEQEDAgEGBwYCC1A4IQYEBA4FBTAtBzANK2g7Fw4LFSBAAQUBAgYGC0YnIC4pEwIGJW80CA8mKBgXFAEnTiOWBxsAAAAAAQAj//UB1AG6AFcAABcmNTQ3Njc2NzY3NiMiJyYjIgYHBgciNTQ3PgE3NjMyHgEXFjMyNzY3NjM2OwEWFRQHBgcGBwYPARcyFxYzMjY3PgEzMhUUBw4BBwYjIiYnJicmIyIHBiMpBgYQJCplTRsMBQwpLBMdKAUOBRUDDTwkDAUPGg0OHxYJBREbBwMDCw0GCRQcLWFQHQwPFiMzEyg/CQQGDBQCD081BgsRHBkVCggOLCMFEQsGAwQJHiswXEYcEAsLEw8IAQgFCSc4BgIMCw4eAggtCwEGAgQQICE1V0cgDAEJDSceCQQKAQg0UQsBDhcVBQU8CAABAB8AAQLRAqgARgAANyI1NDc2NzY7ATI3Njc2EjU0IyYnIy4BNzY3IRYVFAYHBisBLgE3NjU0JicmIwYHBgcGAhUUFxYzMhcWFRQGBwYjIiYjIgYxEgMFBQQLBhshDgUCiwQILR8GAQMEBgH/BxoBAhIMBgEBBR8rG1lHBAcDAYwGDEYZAgYHAQIRFGAkI1cBCQIMEwIBAwMJBQIoBAcDAgYEEQ0GBwQF1wIHBQYRKxcwKAgEAQEDBwP90wIGAgYCAgcCGQIFAQEAAAACADAAAAMUAswAFQAgAAABNzIzMhcWFRYSFQYPASEgJjU0ADc2EwMHBgIUIDUnLgECPggHBhEEBQGmAgEE/pP+lAQCAgUFGz1gX74B+AcIIgLLAQICAwL9SAMDAgMEAgMCugQB/pIBAICB/v8CAiAfiwAAAAMAMv/qAuQCwAAXADQAYAAAATMyFx4BFRQHBgcGIyInJjU0NzY3Njc2BTQmJyImIgYjDgEHBgcGFRQWFxYzMjc+ATc2NzYHND8BNCsBBwYHBiMiJic0Njc2MzIVFA8BFDsBNzY3NjMyFhcUBwYHBisBIgHLESYKYnZXOVFpamtHTAESYhwgbwEuSUUCDQgNAkiEKzAOAUU/CBcYCT5xKD0QAoICA4ODAwQDAw0MBQMhBAMNFAIDg4MDBAMDDQwFAxERBQIECBQCwAEOkG6HeVIzRERKfCMKiXMgHFzjVWoKAQEIaVVhdQogUmQMAgIKWENpiRKpAgsKAQ4PAgMCBwSHAwMKAgsKAQ4PAgMCBwdARAQCAAEAIwAAAp4CzABFAAAzIiYjIgcGJicmNTQ3NjMyNzYANTYzMhcWGgEXFjMWFzMWFRQHIyYjIgYjIjU0Njc2MzI3Jy4BLwEiAAcGFRQXMhUUBw4B8A5EFz0MEQcCAQcDCkAgAgFZBxURBgEUFAEDAQgjGQcNDR9TFVQUEAYBAhE5Dw8EBwICAf8AAgIvEwMDBQIBAQIFAQMPDgYwAwJjAQcGAf6+/roEBQUBBwQWDQIBBwQbAQYS8jt6HyD+NwUECBoECgUJDwcAAwA1AAADCQKlACkAUwB/AAATNDchMhcVFhUUBw4BDwEGKwEmNT4BNSYjJiMiBwYHDgMiKwEmNTQ2EyIuAic3Njc2OwEWFRQPARQ7ATc+ATsBFhUUBgcGIyInJj8BIQcGBwYDJjU0Njc2OwEWFRQOAQcGFRQeATI7AjI2NzU+Ajc2OwEWFRQGBwYHBiHeBwGpeQEBDQMIAgICEgwHAgcBBx3E6gYJDgEDAQYIBwwHKAkGBwIEARQVAwMNDQcFBJmaBQUGCxAHKAECEQ0DBQYF/s0GAwMCuAceAQQQDAcCAQEHAxMiIpVnZCgDBg4LAgMNDActAgEDA/7sApwCBwUBAQMFRA8pCgkHBwYHNwQEAwYILwMOAgYFBQKH/nMBAQUBVlICAwUFAhMTARcVBwUFAqADBgMEGBQVEgYG/voHBAOXBAcHBgEIDAQhEQMDAgMFAQsqHgICBQUClwYCAwIAAAEAHwAAA3cCqABkAAA3IjU0NzY3NjsBMjc2NzYSNTQjJicjLgE3NjchIBcWFRQHBgcGKwEiBwYHBgIVFDMWFzMeAQcGByMmIyIGIyI1NDY3Njc2OwEyNzY3NhoBNzQrAQYCFRQXFhczHgEHBgcjJiMiBjARAwUFBAsGGyEOBQKLBAgtHwYBAwQGAVIBUwMEAgUFBAsGGyEOBQKLBAguHwUBAwQGDyVhGVUUEQIBBQUECwYbIQ4FA0hFAZGRCYYDBzAfBQEDBAYPJWEZVQEJAgwTAgEDAwkFAigEBwMCBgQRDQYCAwUHBxMCAQMDCQX92AQHAwIHAxENBgIBCAELAxMCAQMDCQYBHQEXAQIh/eUDBwEDAgcDEQ0GAgEAAQA6AAADJgKrAEkAAAE0NjU0Jy4BJyYnIxYSHQEGFQcOAQ8BBjIzMjc2NzY3PgE7ATIVFAYHBiMGIyEmNDc+Aj8BNi4BJyY3Njc2KQEWFxQGBwYjIiYC4wQJDSopHYyCBYYBFBRPJJoBKzC2FlwkNCYGBgoDFVYBAhsh5f7lBwUBJ1cgmwFMUgIBAgUEAwEcARwDBBsBBA8MCAHHCisIJhgbFgUEAQr+5QMCAgESEkchiwECBxwpWxIHCwHmAwQBBwgFASROHYwBoqoHBAwSAwIDBgfZAgUFAAAAAAEAHAAAArwCwQBbAAATIi4BNTQ3NjMyFxYVFAcVMj4BNzY3NjMyFx4BFAcGByI1NDY1NCYjIgcGBwIVFBcWOwEeAQcGByMmIyIGIyImNTQ3PgEzMjc2PwE+Azc2NTQnJiMiBgcOASMtCAYDGjtdMxs8AgEIFAlAVCEjEwohKgcFEhUBLB84LUcmSwYMRxkGAQMEBhEpcx1oFwsGBgEJFUQSCAcICBcYEwIHCxc+Jj8KAwkLAhcBAwUULWAYLnklBAERKBJwIQwCCTlSCwcBCQIMBBwfLUST/t0KBgIGBgUQDQYCAQMGFQkEAgYCCB8fW19QDikpNRk5KB8KBQAAAAADABgAAAKCAqsAXQBsAHUAAAE0KwEuATc2NzMWOwEyNzMeAQcGByMGBw4BBw4BDwEXMhYzHgEVFAcOAQ8BIgcGFBcWOwEeAQcGByMmIyIGIyImNTQ3PgEzMjc2NzY/AScmJyYnJjU0Nz4CPwI2AzcjIgcGBwYVFBcWFzM0EwM3Njc2NTQmAWRZGAYCBAQGD05XPUcKDAYBAwQFJkUMBwUJAgUBAgICBgJQeg8ZhFQyBAEVBgxHGQYBAwQGESlxHGUXCwYGAQkVRBIIBwQICxAsIGsOAgIJX3xAEQsKRSYBEhhPIyYkHi0IqU0KXCwxPQJwDQUHDw0GAgIGBRAOBQEIBA0jChUGBgEBCVVAHh41VREIBFAMAgYGBRANBgIBAwYVCQQCBgIIDCErAgYMKU8MCQoMNFgyCAItKf7rmQcUNjlCMxkVBgIBMv7LAgw2O08wLgAAAQAVAAACtAKrAH8AADcmNTQ3NjU0JyY1NDczMhcWHQEUBwYVFhcWPwE+ATc2NCcmKwEuATc2NzMWOwEyNzMeAQcGByMGBw4BDwEyNzY3Njc2NzY3NjsBMhcUFxQHBhUOASMiBwYHDgEHBiMiDgEVFBcWOwEeAQcGByMmIyIGIyImNTQ3PgEzMjc2PwE22KgLBh4OCygqBCkKCwM4GgMHBxsNNQ8nIxgGAgQEBg9QVD5ICgsGAQMEBSZFDAcNKzUBDC8nORsHCB0yBSogDAMBAQEDBQYYFRcPGHlZIwoDAhYGDEcZBgEDBAYRKXEcZRcLBgYBCRVEEggHCwyXGZknMRcSLwQCCQ8LAQg9CxkmMChVHA4DHBxtNNQMAwMFBw8NBgICBgUQDgUBCAUvrNQEDiY7ZxsUTQsBBwECAQQDAwoGGhs5XH4WCAJWAwYCBgYFEA0GAgEDBhUJBAIGAggsKwAAAAABAFAAAAMSAsAAawAAATQmIyIHBgcGFRQXFhUUBwYHDgErAS8BNTQ3PgE3NjIXFhUWFRYXMh4BOwE1NCcmJyYnJic0Nz4BNzY3NjMyFx4BFRQHBgcGBwYVFjMyNjM+ATc2NzY3NjIXFhUUBgcGKwEuATc2NzY3Njc2AqVQQ0tGXxMBBwgEBQUCFkhYBAMCAgIFAxUEBQEBDQEPHQoxBAYfHQgBAgUJOiZASjs4Z0YpLzgXTUEcExMUDCMBEwsFCxkEAwMXAwZKAgNZWQYBBAsaETAoGjMCDUJNM0aTDCguRVIkFSYoCgUBAwQLBEw6DgIBAQMrFhQEAgEBAgwYJVFMKgkeIBotWB40FxMrG1IwSFUkWEooHAQBAQIECQ82CgECAgQGAZ4BAgUIDygzJk1DMmAAAAIAIv/1AlsBugA6AFYAAAEyFRQHBg8BFxYXFjM+ATc+ATMyFRQHDgErASIvAQcOAyMiJicmNTQ3PgE3MjYzMhYXFhcVNjc+AQEUFjMyNzY3PgE/ASc0JjUuBSMiBwYHBgJGFQQdSQsBAw8DBg4YBQIGDBQGCyoaB0QXAwsKKTFCH0dXCgEDD5BbAw8EQlcQBgExGgQF/kAuKRogODUHDQQEAQEBAQcMFSEWRTQZERQBiQgDDW9hDhhRDgICEw0HAwkGDBYfSAcICBgXEVBBBhAaEFqPCgFJQR0mHUpcDgX+7yszCA4oBQsEBAkJIxEmKj0hIg9JJUBJAAAAAAIAF/8+Aj0CwQAlAEsAABcmNTQSNzY3Njc2NzI2MzIWFRQGBxcWFRQGBwYjIi4DDwEGIwEyFzc2NzY1NCcmIyIHDgEHBgIHBhUUFjMyNjc1NCcGIyI1NDc2HQafBBswGhYtOAIPBD9PODANM45hChseMRoSBwFAAhIBNyYkBjUPAgEOPhUPNFgaBUIBATsyWmYFIyorTwMOwgYCAwJ6DlQ8Ig8mCAFLPDFdIA0zUGeODwIQFxcOAf0GAnEMBSdhCRgSBTMEDm9TEP76CQUQOEGPaAY6Iw4fBwccAAABAAv/KAIfAbkAOQAAJRAjIgYHBiMGIyI1NDc+ATczMhceARcWFRQzNzY3Njc2OwEWFRQHBgcGBwYHBgcGIyI1NDc2PwI2AVyYMFEQAgICDhQFFmI6DBsGMD4WDgEMJTMVAQIODQYSUTUGAggSGRQEBREBCSwGAQFkAP81KgkCCQMRQVoIAQtWWDwZBBtfZicBAQYDASafmRENRUhoCQMcCgY+jhMSCgACACT/9gHDAs0ANgBHAAABFAYjIicmJyYnJiMiBwYVFBceARUUBwYHBisBIicuASc0NzY3NjcuAScmJyY1NDY3NjMeARcWARQWMzI3PgE1NC4BJwcGBwYBwxsVCwQOFSEUBAgeDwhjIyArJzodGwcqIiYvAQUTWyg9AggDJQYBLyUIDxFmDBL+rTAsGxUaJg8MFApcIxQClhMfAgUSHAUBFQsLLHksSDdiVEsfDhITTDIcGWVLHxUEEQdONQULKTcKAgEWBAj92C84FRppNSI+HioEIH1EAAABABv/6gGsAcQAQQAANxQzMjc2MxYVFAcOASMiJy4BNTQ3Nj8BJyY1NDc+ATczMhcWFAYjIicmIyIHBhUUFx4BNzYzMh4CFRQHBiInBwZEhXIhAwsOBBZgQDYlICggDRkKCBcVGmA4D0UuFxgNCQ0kMlUxIREJBgkfMhITFwoVEV4iCkBwSTwGAg8HCCwzFA44JyssERUHCRkfIhojMAUfDxwWCRshFB8TEQkCAw4BBg0LFgoJDQcrAAAAAAEALP80AdcCwABUAAABNjMyFRQHBhUUFhU2Mzc+ATc2NzMyHgIVBgcGByImJwcOAQcGFRQXFh8BFhcWFRQHBgcGIyInLgEnJjc2MzIXHgEzPgE1NCcuAScmNTQ3PgE/ASYBKAIaEgEFAgECAgIHAgYYBxMWGg0CCRI4HxcMCThlFhJKCDxCMBADDxowCBIbFg8jAwUGBwsFBhgfGg4ZJQV4FV8OF4pKCQYCgz0QBgMZFQUOAwEBAQEBAgECBQ8LDggRAQYMBiaRTDk0XSIEFBcTMQwQGiAxDwIIBBQFCAsJAw8LAh0UIxIDKAsufDI3XbwsBREAAAAAAQAV/ygB9wG6AEIAABciJjQSNTQjIgcGBxQOAioBKwEmNTQ3Njc2MzIXFhUUMzc2MzIWFRQHBgcGBwYjIiYnND8BNjU0IyIHBg8CBgcGbA4UUBoLCBgYAgECBQQGDgYNExoYHT8ZCwELPk03QgMEOToEDSAOEgE7PgMxEghGMQchIQUNCw8aAT4SJwcTXAEFAQIGAwgnOhoYLRMJAgtANjQXDxjd6wcbEQ0J6voPFzsCD1QMhoMKGwAAAAADACP/9gHOAsEAGgApADYAAAEyNjMWFxYVFAcGBw4BBwYrASInJjU0NzY3Nhc0IyIHBgcGFRYzNzY3Ngc3IwcGFRQXFjMyNzYBPwEOBTYeJwINOCJbLB8XBywdNQolcj1+NSEjMiMUMTBhBQ0OMAXDAR8YCxIoLC8CwAEFLDtmGxCFdEdqFg4fOHswNch/Q4FmKz91PwsBAQVJSdcRB3w9RBoMQUUAAAABADD/9gFMAboAKwAAJTIWFRQHBgcGKwEiJyY1NDc2NzY3NjMyFhUUBwYHBhUUFjsBMjc2Nz4CMgE5DQYYIDcnJQYoGxgKIisKAg0eEBMJKiULBQoGOzEZCgMBBgWZAggUJTIbExgaIhAcWKkjBRsSDgYjo2MfFhALMxweCAQFAAEAMf/1AioBugBSAAAlNC4CIw8BBgcGIyImNBI3NjMeARUUDwEWNjc+ATc2MzIVFAYjIiY1NDcHBg8CMzIXFhcWFAcGFRQWMzI3Njc+ATMyHgEVFAcGBwYjIiY1NDYBUyU2LBEHGRoDDR4OFF4EDCINExEQAR4MDHEaLSQtJBsTGQIKHTU+DQUCFIMVAwUGCw8QEBkTAwYNCQYEAhUlGyQuNAaSFyAPBgFjZAYbDxoBdwkcARANC0BDARAHCVsOGSgZJxcSBAgFDy0xCQIORAoaFB4UFhMOGUgMBAEEBAEKTyUbNi4JJwABAC//9AIsArYAKgAAEzQ3MxYXFhIXFhcWFRQHIyYnJi8BBw4BBwYHBiMiNTQ3PgE/ATQCJyYjIqYRE1oYAc4BEAwEBkQZCQMuLQ4NRBd5AgwSJAgFjUVEZAQUHxECogwIAy8D/cQCMA0EBAMGDhEEgH0PEE4bjAEMIA4MB4lCQgEBFgstAAAAAQAX/ygCRAG6AEoAAAEyFhUDBhUUMzY3Njc2NzY7ATIeARUUBwYHBgcGIyInJjUHDgMjIicHDgEHBiMiJic0Ejc2Mx4BFRQGBwYVFDMyNzY/AjY3NgHrDhRMARwJCxUUBgQCCAQJBgQDFiANEwgQPxkFBgYYHSoVNCkYFQgIEBIOFAGTAwwiDRM+AgJDERIuIgUkJAQNAa8PDv7CBQsqAQgUTBQBAQEEBAMMVCANCAIxCgIGBhITDRdhUhsIDhENCgJIBhwBDw0M9A8LGFEGETYHj44JGwAAAQAt//4CEgG6ADAAABMyNjMyFRQPATM3PgE3PgE3NjMyFhUUBw4BBwYjIiYjJjU0PwE2JiMiKwEuATc2NzZKAY8BDC4wAwIDBwNkoB4NJg0VBSjklxkKAxABBissAhEUBwQVBgEDAwQDAa8LCAa7vgEBAwEnvW0wEQ4IFITSJAcDBAYCr7AOBwYEEQ4CAwAAAQAV/zMBuwLAAGkAAAUiJjU0MzIXFhcWNzY1NCcuAScmJyY1NDc2NzY/ASciLgEnJjU0Nj8BJjU0MzIVFAcGFRQXFTM2MzIXFhUGBwYHIiYnDgEVFBceATc2MzIeAhUOAiMiLwEGBwYVFBcWFx4BFxYVFAcGAREfVhQHBiMnFAkVEgK5AUIRAwEJKh0rCQMBBAcCJlpGDAMcEgEFAQYbEkULAwIJEjgeFhAmOQoECAE3GREXGQwBHSMeLhoNRR0JAg0pA8ADKSEhzRwSEwMUBAMFChoUCQJIAR8+DBcNBTY5Jx4GAwQGAiY1PWcZBQwNSBAGAxcVCwQEAxUFBw4IEQEHDRNeMB8VBwoBCgIGDgsREgQIAydLGBIOCCIUAU0BFTArIyEAAAACACL/9QHcAbkAFQAoAAABMzIXHgEVFAcOASImJyY1NDc+ATc2AxQWMzI3Njc2NzY1NCMiBwYHBgEfDiAIP0gfJYmMVgoBAwk8KERdLyYSEkkkFg4BUj8wIRUUAbkBC1pHOztIWVBBBhAaEDNhIjX+xyszBhhWNlEGGWE6KExJAAEAE//1Aj0BrwA/AAAlFAYjIiYnJjU0NzY3NjUjBxQOAQcGIyInJj0BNzY/ASMiBgcGBw4BIyI1NDc2NzYzMhcWFRQHBisBBwYVFBcWAa8dFQ8LBhMBBxgFYgEnLggMHxcJAg1LIgggKB8WGBIFBgwTCkVCB9qgBBQgBj9AAwwfByURHggMLEMkDEViFAIEA5moDRwRBQsLHJ5zGAYQDxoIAwoEEGkKAgEHFR8LAhFIL1lIEgAAAAACABf/KAH+AboAHwAwAAAXIic0Ejc2NzY3MjYzMhceARUUBgcGKwEiJicHDgEHBgA0JiMiBgcGDwEeATMyNzY3OiECZQMQJ0ZZAgwEFgw1QHpYFA4LIyYWGxkICBABXCIhI0YVDhgRCCwgJiQmFdgeCgGUBjc0Vg4BAwxWQVmpFwUYG3BhGggOAfVKLjsuH2NEIykkI0gAAAEAH/+VAZUBugA8AAAXMjY1NCcuAScmJyY1NDc+ATc2MzIXFhUUBiMmJyYjIgYHBhUUFx4BFx4CFxYVFAYHBiMiJjU0NjMyFxbgERYSAooCOwwBAxB+URUYMCEWDgwHCyAhSHMKASsCmAQBBQUBFzMjBxEVLw0HBggWRxcSFg4BTgEiRQQOGQ1LaA4EEQsOCw8BBxdXNwQKNB4CVQIBBQQCGSEoQAkCDg0IDAMIAAAAAgAf//UCPAGvABwALQAAFyImNTQ3PgE3Njc2OwEWFRQHBisBFxYVFAcGBwYTNCMiBwYHBhUUFjMyNzY3NrhFVBkaVjQYHgGLihQfBjs8BRJVOEkXn1U9KScVCCsnNi0pFgsLWkQ1OThUFAoDAQwSHwoCCiYvcFU4EAUBIVArKWAlGCoxLytZLwAAAAABABL/8wIFAa8ALQAAEyI9ATY1PgE3Njc2MzIXFhUUBgcGIhUOAgcOASMiPQE3PgE/ATQjIgcGBw4BJxUBCTMUIx4GoqAFFBMNBrQBHyACBRsPITILGwcGLjEFNyYFBgEcCgEBARNBERsEAgIFFg0aAwICAaKoBQ8SIQqiJFgUFQEBCDYIAwAAAQAV//YCCwG7AEgAAAE0NjMyFhUUBwYHBgcGKwEiJyY1NDc2NzY1NCYrASIHBgcUDgIqASsBJjQ3Njc2MzIWFQYHFAcGFRQWMzI3PgE3NjU0JyYnJgGdJhYYGhMPFT5ZERIOkxABAwgkFgUJBRcVIBECAQIFBAYOBgMZNBshKTACAQ8vLysVFStMFQgeDgQEAYAXJCwgJUs7K38eBnIEDRcMLWA7Fw4LFSBAAQUBAgYGC1QkFC4oEwIGJX8uLDAIEWxJGxIrHAwIBwAAAgAy/yYCagG6ADsATgAAATIWFRQHBgcGBwYjIhUHDgEHBgcGIy4BNTQ3NicmJy4BNTQ3NjczMhUUBwYHBgcUFxYXFjM/ATY3Njc2FzQmIyIGBwYPARYzMjc2NzY3NgH2ODwCEUxKWR0gGgcGEAMFFQsODhE3AQMDBENYBR1BDRUIMBkJAQURQyQSAg0bFy82Ln8wKDFWHA4OCQ4GWEwZEi8MAgG6Tj4TEGVOSBQGAiQjVAwYCQYCEQ4NqgEBAQEUYEgUHH9CCAQKOF0cFhkPNxwRASlWN2ssJqQrMFBHIkstAjASEi85BwAAAAABABn/NAJYAboASwAAEyI1NDc2MzIXHgMfATI2NzYzMhUUBwYPARcWFxYzMjY3PgEyFxYHDgEHBisBIicmLwEOAQcGIyImNTQ3Nj8BJyYnJicmIgcGBwZEFAgcQEwiDBkUEAUFA98GBgMSAgJ6eQkhJyIWDhoGAwgVAwgDBSITEA8LUh8dKQkE3gUEBgcLAwF6eQcmJBkRBw4HFgwBAV8KBBI7KhE5OjYREfYDAhEHAwWFhCB8T0MYEgoCAQQLFCYICC8uiSEG8QMDCwYFBQSFhB2KRzELBQMKIgcAAQAV/zMCegK2AGEAABMyFhUUBwYXFhcWFxY7ARMSNzYzMhUUAwIUMzI3PgE3NjU0JyYnJjU0NjMyFhUUBwYHBgcGKwEHBhUGKwEmNTQ2NSYjJjU0NzY3NjU0JisBIgcGBxQOAioBKwEmNDc2NzahKDESLgEDGBUWEg0BUlQBAw0UUVIGFRJAbxQHHg4EBCYVGRoIDgcbQVlfChcYAhINBi4HB58BByUWBQkFFxUgEQIBAgUEBg4GAxk0GwG5MCMUL30nKhgSBggBSwFLAQIHCf6+/rgCBRN3QxoQKhwMCAcJGCMtIBcoQRJPQVddXgEGBgIFtAMBFX4OByRlOxcOCxUgQAEFAQIGBgtUJBQAAAABAA//9QJcAbsAUAAAATQ2MzIVFAcGBwYHBiMiJyYHBgcGIyInJicmNTQ3Njc2NzYXFgcGBwYHBhUUFjMyNzY/ATU2NzY3NjMyFRQHBg8BFBcWMzI3Njc2NTQnJicmAe8mFjECChw4WhIXUB4BBi41FBAVFi8QBAsVNA4KDAwOAQEQRgsBKigMBjAkCAEKChsHCR8DChUGCxkxJyMyFgchEAEBAYAXJE8LEkxQmh0HTQIHNwwFCBZCGB4sL2NOFgUHBQgPCBZhTgYPMzwBCCwIEycqLA0DJAoMLCwQBRAmHyxPFxUvHhAJAwAAAAIAFf/1AjMCwQBXAGYAABMOARUUMzI3Njc2PwEnIiYnJicmNTQ3Njc2MzIXHgEVFAcOATsBHgYVFAYHIi8BDgEHBiMiNTQ3PgE1NCMiBwYHFA4CKgErASY1NDc2NzYzMhY3NCMiBw4BFRQXFh8BMzbpAjNDHRwXGBwZFwICBgI9HjsvKDIECxELMCwNAgIBAwIKCAoEBAEHBAoVCxRvOCgqjQQCMBoLCBgYAgECBQQGDgYNExoYHyw35zMZHBkfAgxnDgEcAVgXwB9IHRctNVRZAQIBGRkwRUc5LgoBAw9uTTo5DAsBAgICAQMDAwcTAQUDXbQlG3QMHAy8FScHE1wBBQECBgMIJzoaGDWvaBcWRCEHDEYqBHQAAAAAAwAr/zMCQwK2ADkARgBZAAABNjsCFhUUBw4BDwEUHgEXFhcWFRQGBwYrAQcGBwYjIjU0PwE0IyImJy4BJyY1NDc+ATc2MzI/ATYBFBYXMxMiBwYHBgcGJTQmJyYrAQ8BFDM3MjM2NzY3NgGZBAgIDQYeBw8EBBMtGU0UBZVqHBEEGBgCAw0UFhcIAg4FPVMNBRkbZT41HwUBHh/+4T41B10CCGc2Eg8PAXo5Lw4BAy4wAQEBASobcBoFArAGBgIHdBw+DxABAQsLJk4SGFmZFgZfYAICBwVaXAEDAQtHNBEaMTE0UhURBHp3/eg2QAUBeQIQUhwnLlsyPggCu7wCAQUOMo0bAAAAAgAT//YDNwGvADgAWgAABSImNTQmBwYHBiMiJyY1NDc2PwEjIgcGBw4BIyI1NDc2NzYhIBcWFRQHBiMiFRYXFhUUBwYHBgcGEzQnIQcGBwYVFDMyNz4BNz4BOwEWHQEOAhUGFRQzMjc2Agg2NwMERGIJFxEFRg4VMgYVKBcjGQUGDBMKRUIHAWkBCwQUFgsYEgEBBAgiWCEqCK0H/jgFPRMHPyYlLkkQAwMODgYBAQENTkI4OgpHOwgBB28TAgEVYi41SEQJCxEjCAMKBBBpCgIBBxUZDQYBBgcUGx4fiEgaCgIBMiAeB01NHBlSFhxsQQcCBgICAgQHAzsnbElPAAIAQ/8+Af4BugA4AEoAABciJjU0Njc2NzY3MjYzMhceARUUBgcGIyInJiMHDgEHBhUUFx4BMzIXFhUUBw4BKwEmNTYmKwEiBhI0JiMiBgcGBwYVFBYzMjc2N81GRCwQECdGWQIMBBYMNUCGYAYVUScEAQICBQEGCQwuOXgTCwIDBg4NBgEICgoSSMciISNGFQoRECcgJSYmFa4qOC3XMjc0Vg4BAwxWQV6wDwFKCQoKHAcpFRsKDQgUCxUMDAwEBgUJBQUBy0ouOy4YO0EkKDIkI0gAAQAo//UBfgGvADIAADcGFRQXFjMyNzY3NjMyFxYHBgcGIyInLgE1NDc+ATc2OwEWFQYHBiMiBwYPATMWFRQHI4oKLxchDw0gJwoDCAQFAwYnKismJDM+LyFpPgIoJg8CEgIjJgRgIQSxDRS22SEpSB0QAwYaBw8PAwoREw4TWT9YPCw7BQEHDxIFAQELYAwJChMIAAIAAAAAArwAZAADAAcAADE1MxUhNTMVZAH0ZGRkZGQAAgAAAAABLABkAAMABwAAMTUzFTM1MxVkZGRkZGRkAAABAAAAAABkAGQAAwAAMTUzFWRkZAAAAAAAABYBDgABAAAAAAAAACwAWgABAAAAAAABAAwAoQABAAAAAAACAAYAvAABAAAAAAADACMBCwABAAAAAAAEABMBVwABAAAAAAAFAAsBgwABAAAAAAAGABMBtwABAAAAAAANAPcDuwABAAAAAAAOABoE6QABAAAAAAAQAAwFHgABAAAAAAARAAYFOQADAAEECQAAAFgAAAADAAEECQABABgAhwADAAEECQACAAwArgADAAEECQADAEYAwwADAAEECQAEACYBLwADAAEECQAFABYBawADAAEECQAGACYBjwADAAEECQANAe4BywADAAEECQAOADQEswADAAEECQAQABgFBAADAAEECQARAAwFKwBDAG8AcAB5AHIAaQBnAGgAdAAgACgAYwApACAAMgAwADAAOQAtADIAMAAxADAAIABEAGUAcwBpAGcAbgAgAFMAYwBpAGUAbgBjAGUALAAgAEkAbgBjAC4AAENvcHlyaWdodCAoYykgMjAwOS0yMDEwIERlc2lnbiBTY2llbmNlLCBJbmMuAABNAGEAdABoAEoAYQB4AF8ATQBhAHQAaAAATWF0aEpheF9NYXRoAABJAHQAYQBsAGkAYwAASXRhbGljAABGAG8AbgB0AEYAbwByAGcAZQAgADIALgAwACAAOgAgAE0AYQB0AGgASgBhAHgAXwBNAGEAdABoAC0ASQB0AGEAbABpAGMAAEZvbnRGb3JnZSAyLjAgOiBNYXRoSmF4X01hdGgtSXRhbGljAABNAGEAdABoAEoAYQB4AF8ATQBhAHQAaAAtAEkAdABhAGwAaQBjAABNYXRoSmF4X01hdGgtSXRhbGljAABWAGUAcgBzAGkAbwBuACAAMQAuADEAAFZlcnNpb24gMS4xAABNAGEAdABoAEoAYQB4AF8ATQBhAHQAaAAtAEkAdABhAGwAaQBjAABNYXRoSmF4X01hdGgtSXRhbGljAABDAG8AcAB5AHIAaQBnAGgAdAAgACgAYwApACAAMgAwADAAOQAtADIAMAAxADAALAAgAEQAZQBzAGkAZwBuACAAUwBjAGkAZQBuAGMAZQAsACAASQBuAGMALgAgACgAPAB3AHcAdwAuAG0AYQB0AGgAagBhAHgALgBvAHIAZwA+ACkALAAKAHcAaQB0AGgAIABSAGUAcwBlAHIAdgBlAGQAIABGAG8AbgB0ACAATgBhAG0AZQAgAE0AYQB0AGgASgBhAHgAXwBNAGEAdABoAC4ACgAKAFQAaABpAHMAIABGAG8AbgB0ACAAUwBvAGYAdAB3AGEAcgBlACAAaQBzACAAbABpAGMAZQBuAHMAZQBkACAAdQBuAGQAZQByACAAdABoAGUAIABTAEkATAAgAE8AcABlAG4AIABGAG8AbgB0ACAATABpAGMAZQBuAHMAZQAsACAAVgBlAHIAcwBpAG8AbgAgADEALgAxAC4ACgBUAGgAaQBzACAAbABpAGMAZQBuAHMAZQAgAGEAdgBhAGkAbABhAGIAbABlACAAdwBpAHQAaAAgAGEAIABGAEEAUQAgAGEAdAA6AAoAaAB0AHQAcAA6AC8ALwBzAGMAcgBpAHAAdABzAC4AcwBpAGwALgBvAHIAZwAvAE8ARgBMAABDb3B5cmlnaHQgKGMpIDIwMDktMjAxMCwgRGVzaWduIFNjaWVuY2UsIEluYy4gKDx3d3cubWF0aGpheC5vcmc+KSwKd2l0aCBSZXNlcnZlZCBGb250IE5hbWUgTWF0aEpheF9NYXRoLgoKVGhpcyBGb250IFNvZnR3YXJlIGlzIGxpY2Vuc2VkIHVuZGVyIHRoZSBTSUwgT3BlbiBGb250IExpY2Vuc2UsIFZlcnNpb24gMS4xLgpUaGlzIGxpY2Vuc2UgYXZhaWxhYmxlIHdpdGggYSBGQVEgYXQ6Cmh0dHA6Ly9zY3JpcHRzLnNpbC5vcmcvT0ZMAABoAHQAdABwADoALwAvAHMAYwByAGkAcAB0AHMALgBzAGkAbAAuAG8AcgBnAC8ATwBGAEwAAGh0dHA6Ly9zY3JpcHRzLnNpbC5vcmcvT0ZMAABNAGEAdABoAEoAYQB4AF8ATQBhAHQAaAAATWF0aEpheF9NYXRoAABJAHQAYQBsAGkAYwAASXRhbGljAAAAAAIAAAAAAAD/gwAyAAAAAAAAAAAAAAAAAAAAAAAAAAAAZgAAAAEAAgADABIAJAAlACYAJwAoACkAKgArACwALQAuAC8AMAAxADIAMwA0ADUANgA3ADgAOQA6ADsAPAA9AEQARQBGAEcASABJAEoASwBMAE0ATgBPAFAAUQBSAFMAVABVAFYAVwBYAFkAWgBbAFwAXQECAQMAqAEEAQUBBgEHAQgBCQEKAQsAnwEMAQ0BDgEPARABEQESARMBFAEVARYAlwEXARgBGQCbARoBGwEcAR0BHgEfASABIQEiASMBJAElASYBJwEoASkBKgd1bmkwMEEwBUdhbW1hBVRoZXRhBkxhbWJkYQJYaQJQaQVTaWdtYQdVcHNpbG9uA1BoaQNQc2kFYWxwaGEEYmV0YQVnYW1tYQVkZWx0YQdlcHNpbG9uBHpldGEDZXRhBXRoZXRhBGlvdGEFa2FwcGEGbGFtYmRhAm51AnhpB29taWNyb24DcmhvBnNpZ21hMQVzaWdtYQN0YXUHdXBzaWxvbgNwaGkDY2hpA3BzaQVvbWVnYQZ0aGV0YTEEcGhpMQZvbWVnYTEHdW5pMDNGMQd1bmkwM0Y1B3VuaUVGRkQHdW5pRUZGRQd1bmlFRkZGAAAAAAAAAf//AAIAAQAAAA4AAAAYAAAAAAACAAEAAwBlAAEABAAAAAIAAAAAAAEAAAAAyYlvMQAAAADG+TJPAAAAAMn0Jds="; - var callAddFont = function() { + var callAddFont = function () { this.addFileToVFS("MathJax_Math-italic-normal.ttf", font); this.addFont( "MathJax_Math-italic-normal.ttf", diff --git a/examples/js/ace.js b/examples/js/ace.js index bd0559384..c8120fbb3 100644 --- a/examples/js/ace.js +++ b/examples/js/ace.js @@ -1,19 +1,19 @@ -(function() { +((function () { function o(n) { var i = e; n && (e[n] || (e[n] = {}), (i = e[n])); if (!i.define || !i.define.packaged) - (t.original = i.define), (i.define = t), (i.define.packaged = !0); + ((t.original = i.define), (i.define = t), (i.define.packaged = !0)); if (!i.require || !i.require.packaged) - (r.original = i.require), (i.require = r), (i.require.packaged = !0); + ((r.original = i.require), (i.require = r), (i.require.packaged = !0)); } var ACE_NAMESPACE = "", - e = (function() { + e = (function () { return this; })(); !e && typeof window != "undefined" && (e = window); if (!ACE_NAMESPACE && typeof requirejs != "undefined") return; - var t = function(e, n, r) { + var t = function (e, n, r) { if (typeof e != "string") { t.original ? t.original.apply(this, arguments) @@ -21,14 +21,14 @@ console.trace()); return; } - arguments.length == 2 && (r = n), - t.modules[e] || ((t.payloads[e] = r), (t.modules[e] = null)); + (arguments.length == 2 && (r = n), + t.modules[e] || ((t.payloads[e] = r), (t.modules[e] = null))); }; - (t.modules = {}), (t.payloads = {}); - var n = function(e, t, n) { + ((t.modules = {}), (t.payloads = {})); + var n = function (e, t, n) { if (typeof t == "string") { var i = s(e, t); - if (i != undefined) return n && n(), i; + if (i != undefined) return (n && n(), i); } else if (Object.prototype.toString.call(t) === "[object Array]") { var o = []; for (var u = 0, a = t.length; u < a; ++u) { @@ -39,22 +39,19 @@ return (n && n.apply(null, o)) || !0; } }, - r = function(e, t) { + r = function (e, t) { var i = n("", e, t); return i == undefined && r.original ? r.original.apply(this, arguments) : i; }, - i = function(e, t) { + i = function (e, t) { if (t.indexOf("!") !== -1) { var n = t.split("!"); return i(e, n[0]) + "!" + i(e, n[1]); } if (t.charAt(0) == ".") { - var r = e - .split("/") - .slice(0, -1) - .join("/"); + var r = e.split("/").slice(0, -1).join("/"); t = r + "/" + t; while (t.indexOf(".") !== -1 && s != t) { var s = t; @@ -63,7 +60,7 @@ } return t; }, - s = function(e, r) { + s = function (e, r) { r = i(e, r); var s = t.modules[r]; if (!s) { @@ -71,11 +68,11 @@ if (typeof s == "function") { var o = {}, u = { id: r, uri: "", exports: o, packaged: !0 }, - a = function(e, t) { + a = function (e, t) { return n(r, e, t); }, f = s(a, o, u); - (o = f || u.exports), (t.modules[r] = o), delete t.payloads[r]; + ((o = f || u.exports), (t.modules[r] = o), delete t.payloads[r]); } s = t.modules[r] = o || s; } @@ -83,568 +80,583 @@ }; o(ACE_NAMESPACE); })(), - define("ace/lib/regexp", ["require", "exports", "module"], function(e, t, n) { - "use strict"; - function o(e) { - return ( - (e.global ? "g" : "") + - (e.ignoreCase ? "i" : "") + - (e.multiline ? "m" : "") + - (e.extended ? "x" : "") + - (e.sticky ? "y" : "") - ); - } - function u(e, t, n) { - if (Array.prototype.indexOf) return e.indexOf(t, n); - for (var r = n || 0; r < e.length; r++) if (e[r] === t) return r; - return -1; - } - var r = { - exec: RegExp.prototype.exec, - test: RegExp.prototype.test, - match: String.prototype.match, - replace: String.prototype.replace, - split: String.prototype.split - }, - i = r.exec.call(/()??/, "")[1] === undefined, - s = (function() { - var e = /^/g; - return r.test.call(e, ""), !e.lastIndex; - })(); - if (s && i) return; - (RegExp.prototype.exec = function(e) { - var t = r.exec.apply(this, arguments), - n, - a; - if (typeof e == "string" && t) { - !i && - t.length > 1 && - u(t, "") > -1 && - ((a = RegExp(this.source, r.replace.call(o(this), "g", ""))), - r.replace.call(e.slice(t.index), a, function() { - for (var e = 1; e < arguments.length - 2; e++) - arguments[e] === undefined && (t[e] = undefined); - })); - if (this._xregexp && this._xregexp.captureNames) - for (var f = 1; f < t.length; f++) - (n = this._xregexp.captureNames[f - 1]), n && (t[n] = t[f]); - !s && - this.global && - !t[0].length && - this.lastIndex > t.index && - this.lastIndex--; + define( + "ace/lib/regexp", + ["require", "exports", "module"], + function (e, t, n) { + "use strict"; + function o(e) { + return ( + (e.global ? "g" : "") + + (e.ignoreCase ? "i" : "") + + (e.multiline ? "m" : "") + + (e.extended ? "x" : "") + + (e.sticky ? "y" : "") + ); } - return t; - }), - s || - (RegExp.prototype.test = function(e) { - var t = r.exec.call(this, e); - return ( - t && - this.global && - !t[0].length && - this.lastIndex > t.index && - this.lastIndex--, - !!t - ); - }); - }), - define("ace/lib/es5-shim", ["require", "exports", "module"], function( - e, - t, - n - ) { - function r() {} - function w(e) { - try { - return Object.defineProperty(e, "sentinel", {}), "sentinel" in e; - } catch (t) {} - } - function H(e) { - return ( - (e = +e), - e !== e - ? (e = 0) - : e !== 0 && - e !== 1 / 0 && - e !== -1 / 0 && - (e = (e > 0 || -1) * Math.floor(Math.abs(e))), - e - ); - } - function B(e) { - var t = typeof e; - return ( - e === null || - t === "undefined" || - t === "boolean" || - t === "number" || - t === "string" - ); + function u(e, t, n) { + if (Array.prototype.indexOf) return e.indexOf(t, n); + for (var r = n || 0; r < e.length; r++) if (e[r] === t) return r; + return -1; + } + var r = { + exec: RegExp.prototype.exec, + test: RegExp.prototype.test, + match: String.prototype.match, + replace: String.prototype.replace, + split: String.prototype.split + }, + i = r.exec.call(/()??/, "")[1] === undefined, + s = (function () { + var e = /^/g; + return (r.test.call(e, ""), !e.lastIndex); + })(); + if (s && i) return; + ((RegExp.prototype.exec = function (e) { + var t = r.exec.apply(this, arguments), + n, + a; + if (typeof e == "string" && t) { + !i && + t.length > 1 && + u(t, "") > -1 && + ((a = RegExp(this.source, r.replace.call(o(this), "g", ""))), + r.replace.call(e.slice(t.index), a, function () { + for (var e = 1; e < arguments.length - 2; e++) + arguments[e] === undefined && (t[e] = undefined); + })); + if (this._xregexp && this._xregexp.captureNames) + for (var f = 1; f < t.length; f++) + ((n = this._xregexp.captureNames[f - 1]), n && (t[n] = t[f])); + !s && + this.global && + !t[0].length && + this.lastIndex > t.index && + this.lastIndex--; + } + return t; + }), + s || + (RegExp.prototype.test = function (e) { + var t = r.exec.call(this, e); + return ( + t && + this.global && + !t[0].length && + this.lastIndex > t.index && + this.lastIndex--, + !!t + ); + })); } - function j(e) { - var t, n, r; - if (B(e)) return e; - n = e.valueOf; - if (typeof n == "function") { - t = n.call(e); - if (B(t)) return t; + ), + define( + "ace/lib/es5-shim", + ["require", "exports", "module"], + function (e, t, n) { + function r() {} + function w(e) { + try { + return (Object.defineProperty(e, "sentinel", {}), "sentinel" in e); + } catch (t) {} } - r = e.toString; - if (typeof r == "function") { - t = r.call(e); - if (B(t)) return t; + function H(e) { + return ( + (e = +e), + e !== e + ? (e = 0) + : e !== 0 && + e !== 1 / 0 && + e !== -1 / 0 && + (e = (e > 0 || -1) * Math.floor(Math.abs(e))), + e + ); } - throw new TypeError(); - } - Function.prototype.bind || - (Function.prototype.bind = function(t) { - var n = this; - if (typeof n != "function") - throw new TypeError( - "Function.prototype.bind called on incompatible " + n - ); - var i = u.call(arguments, 1), - s = function() { - if (this instanceof s) { - var e = n.apply(this, i.concat(u.call(arguments))); - return Object(e) === e ? e : this; - } - return n.apply(t, i.concat(u.call(arguments))); - }; + function B(e) { + var t = typeof e; return ( - n.prototype && - ((r.prototype = n.prototype), - (s.prototype = new r()), - (r.prototype = null)), - s + e === null || + t === "undefined" || + t === "boolean" || + t === "number" || + t === "string" ); - }); - var i = Function.prototype.call, - s = Array.prototype, - o = Object.prototype, - u = s.slice, - a = i.bind(o.toString), - f = i.bind(o.hasOwnProperty), - l, - c, - h, - p, - d; - if ((d = f(o, "__defineGetter__"))) - (l = i.bind(o.__defineGetter__)), - (c = i.bind(o.__defineSetter__)), - (h = i.bind(o.__lookupGetter__)), - (p = i.bind(o.__lookupSetter__)); - if ([1, 2].splice(0).length != 2) - if ( - !(function() { - function e(e) { - var t = new Array(e + 2); - return (t[0] = t[1] = 0), t; - } - var t = [], - n; - t.splice.apply(t, e(20)), - t.splice.apply(t, e(26)), - (n = t.length), - t.splice(5, 0, "XXX"), - n + 1 == t.length; - if (n + 1 == t.length) return !0; - })() - ) - Array.prototype.splice = function(e, t) { - var n = this.length; - e > 0 - ? e > n && (e = n) - : e == void 0 - ? (e = 0) - : e < 0 && (e = Math.max(n + e, 0)), - e + t < n || (t = n - e); - var r = this.slice(e, e + t), - i = u.call(arguments, 2), - s = i.length; - if (e === n) s && this.push.apply(this, i); - else { - var o = Math.min(t, n - e), - a = e + o, - f = a + s - o, - l = n - a, - c = n - o; - if (f < a) for (var h = 0; h < l; ++h) this[f + h] = this[a + h]; - else if (f > a) for (h = l; h--; ) this[f + h] = this[a + h]; - if (s && e === c) (this.length = c), this.push.apply(this, i); - else { - this.length = c + s; - for (h = 0; h < s; ++h) this[e + h] = i[h]; - } - } - return r; - }; - else { - var v = Array.prototype.splice; - Array.prototype.splice = function(e, t) { - return arguments.length - ? v.apply( - this, - [ - e === void 0 ? 0 : e, - t === void 0 ? this.length - e : t - ].concat(u.call(arguments, 2)) - ) - : []; - }; } - Array.isArray || - (Array.isArray = function(t) { - return a(t) == "[object Array]"; - }); - var m = Object("a"), - g = m[0] != "a" || !(0 in m); - Array.prototype.forEach || - (Array.prototype.forEach = function(t) { - var n = F(this), - r = g && a(this) == "[object String]" ? this.split("") : n, - i = arguments[1], - s = -1, - o = r.length >>> 0; - if (a(t) != "[object Function]") throw new TypeError(); - while (++s < o) s in r && t.call(i, r[s], s, n); - }), - Array.prototype.map || - (Array.prototype.map = function(t) { - var n = F(this), - r = g && a(this) == "[object String]" ? this.split("") : n, - i = r.length >>> 0, - s = Array(i), - o = arguments[1]; - if (a(t) != "[object Function]") - throw new TypeError(t + " is not a function"); - for (var u = 0; u < i; u++) u in r && (s[u] = t.call(o, r[u], u, n)); - return s; - }), - Array.prototype.filter || - (Array.prototype.filter = function(t) { - var n = F(this), - r = g && a(this) == "[object String]" ? this.split("") : n, - i = r.length >>> 0, - s = [], - o, - u = arguments[1]; - if (a(t) != "[object Function]") - throw new TypeError(t + " is not a function"); - for (var f = 0; f < i; f++) - f in r && ((o = r[f]), t.call(u, o, f, n) && s.push(o)); - return s; - }), - Array.prototype.every || - (Array.prototype.every = function(t) { - var n = F(this), - r = g && a(this) == "[object String]" ? this.split("") : n, - i = r.length >>> 0, - s = arguments[1]; - if (a(t) != "[object Function]") - throw new TypeError(t + " is not a function"); - for (var o = 0; o < i; o++) - if (o in r && !t.call(s, r[o], o, n)) return !1; - return !0; - }), - Array.prototype.some || - (Array.prototype.some = function(t) { - var n = F(this), - r = g && a(this) == "[object String]" ? this.split("") : n, - i = r.length >>> 0, - s = arguments[1]; - if (a(t) != "[object Function]") - throw new TypeError(t + " is not a function"); - for (var o = 0; o < i; o++) - if (o in r && t.call(s, r[o], o, n)) return !0; - return !1; - }), - Array.prototype.reduce || - (Array.prototype.reduce = function(t) { - var n = F(this), - r = g && a(this) == "[object String]" ? this.split("") : n, - i = r.length >>> 0; - if (a(t) != "[object Function]") - throw new TypeError(t + " is not a function"); - if (!i && arguments.length == 1) - throw new TypeError("reduce of empty array with no initial value"); - var s = 0, - o; - if (arguments.length >= 2) o = arguments[1]; - else - do { - if (s in r) { - o = r[s++]; - break; - } - if (++s >= i) - throw new TypeError( - "reduce of empty array with no initial value" - ); - } while (!0); - for (; s < i; s++) s in r && (o = t.call(void 0, o, r[s], s, n)); - return o; - }), - Array.prototype.reduceRight || - (Array.prototype.reduceRight = function(t) { - var n = F(this), - r = g && a(this) == "[object String]" ? this.split("") : n, - i = r.length >>> 0; - if (a(t) != "[object Function]") - throw new TypeError(t + " is not a function"); - if (!i && arguments.length == 1) + function j(e) { + var t, n, r; + if (B(e)) return e; + n = e.valueOf; + if (typeof n == "function") { + t = n.call(e); + if (B(t)) return t; + } + r = e.toString; + if (typeof r == "function") { + t = r.call(e); + if (B(t)) return t; + } + throw new TypeError(); + } + Function.prototype.bind || + (Function.prototype.bind = function (t) { + var n = this; + if (typeof n != "function") throw new TypeError( - "reduceRight of empty array with no initial value" + "Function.prototype.bind called on incompatible " + n ); - var s, - o = i - 1; - if (arguments.length >= 2) s = arguments[1]; - else - do { - if (o in r) { - s = r[o--]; - break; + var i = u.call(arguments, 1), + s = function () { + if (this instanceof s) { + var e = n.apply(this, i.concat(u.call(arguments))); + return Object(e) === e ? e : this; } - if (--o < 0) - throw new TypeError( - "reduceRight of empty array with no initial value" - ); - } while (!0); - do o in this && (s = t.call(void 0, s, r[o], o, n)); - while (o--); - return s; + return n.apply(t, i.concat(u.call(arguments))); + }; + return ( + n.prototype && + ((r.prototype = n.prototype), + (s.prototype = new r()), + (r.prototype = null)), + s + ); }); - if (!Array.prototype.indexOf || [0, 1].indexOf(1, 2) != -1) - Array.prototype.indexOf = function(t) { - var n = g && a(this) == "[object String]" ? this.split("") : F(this), - r = n.length >>> 0; - if (!r) return -1; - var i = 0; - arguments.length > 1 && (i = H(arguments[1])), - (i = i >= 0 ? i : Math.max(0, r + i)); - for (; i < r; i++) if (i in n && n[i] === t) return i; - return -1; - }; - if (!Array.prototype.lastIndexOf || [0, 1].lastIndexOf(0, -3) != -1) - Array.prototype.lastIndexOf = function(t) { - var n = g && a(this) == "[object String]" ? this.split("") : F(this), - r = n.length >>> 0; - if (!r) return -1; - var i = r - 1; - arguments.length > 1 && (i = Math.min(i, H(arguments[1]))), - (i = i >= 0 ? i : r - Math.abs(i)); - for (; i >= 0; i--) if (i in n && t === n[i]) return i; - return -1; - }; - Object.getPrototypeOf || - (Object.getPrototypeOf = function(t) { - return t.__proto__ || (t.constructor ? t.constructor.prototype : o); - }); - if (!Object.getOwnPropertyDescriptor) { - var y = "Object.getOwnPropertyDescriptor called on a non-object: "; - Object.getOwnPropertyDescriptor = function(t, n) { - if ((typeof t != "object" && typeof t != "function") || t === null) - throw new TypeError(y + t); - if (!f(t, n)) return; - var r, i, s; - r = { enumerable: !0, configurable: !0 }; - if (d) { - var u = t.__proto__; - t.__proto__ = o; - var i = h(t, n), - s = p(t, n); - t.__proto__ = u; - if (i || s) return i && (r.get = i), s && (r.set = s), r; + var i = Function.prototype.call, + s = Array.prototype, + o = Object.prototype, + u = s.slice, + a = i.bind(o.toString), + f = i.bind(o.hasOwnProperty), + l, + c, + h, + p, + d; + if ((d = f(o, "__defineGetter__"))) + ((l = i.bind(o.__defineGetter__)), + (c = i.bind(o.__defineSetter__)), + (h = i.bind(o.__lookupGetter__)), + (p = i.bind(o.__lookupSetter__))); + if ([1, 2].splice(0).length != 2) + if ( + !(function () { + function e(e) { + var t = new Array(e + 2); + return ((t[0] = t[1] = 0), t); + } + var t = [], + n; + (t.splice.apply(t, e(20)), + t.splice.apply(t, e(26)), + (n = t.length), + t.splice(5, 0, "XXX"), + n + 1 == t.length); + if (n + 1 == t.length) return !0; + })() + ) + Array.prototype.splice = function (e, t) { + var n = this.length; + (e > 0 + ? e > n && (e = n) + : e == void 0 + ? (e = 0) + : e < 0 && (e = Math.max(n + e, 0)), + e + t < n || (t = n - e)); + var r = this.slice(e, e + t), + i = u.call(arguments, 2), + s = i.length; + if (e === n) s && this.push.apply(this, i); + else { + var o = Math.min(t, n - e), + a = e + o, + f = a + s - o, + l = n - a, + c = n - o; + if (f < a) for (var h = 0; h < l; ++h) this[f + h] = this[a + h]; + else if (f > a) for (h = l; h--;) this[f + h] = this[a + h]; + if (s && e === c) ((this.length = c), this.push.apply(this, i)); + else { + this.length = c + s; + for (h = 0; h < s; ++h) this[e + h] = i[h]; + } + } + return r; + }; + else { + var v = Array.prototype.splice; + Array.prototype.splice = function (e, t) { + return arguments.length + ? v.apply( + this, + [ + e === void 0 ? 0 : e, + t === void 0 ? this.length - e : t + ].concat(u.call(arguments, 2)) + ) + : []; + }; } - return (r.value = t[n]), r; - }; - } - Object.getOwnPropertyNames || - (Object.getOwnPropertyNames = function(t) { - return Object.keys(t); - }); - if (!Object.create) { - var b; - Object.prototype.__proto__ === null - ? (b = function() { - return { __proto__: null }; - }) - : (b = function() { - var e = {}; - for (var t in e) e[t] = null; - return ( - (e.constructor = e.hasOwnProperty = e.propertyIsEnumerable = e.isPrototypeOf = e.toLocaleString = e.toString = e.valueOf = e.__proto__ = null), - e - ); + Array.isArray || + (Array.isArray = function (t) { + return a(t) == "[object Array]"; + }); + var m = Object("a"), + g = m[0] != "a" || !(0 in m); + (Array.prototype.forEach || + (Array.prototype.forEach = function (t) { + var n = F(this), + r = g && a(this) == "[object String]" ? this.split("") : n, + i = arguments[1], + s = -1, + o = r.length >>> 0; + if (a(t) != "[object Function]") throw new TypeError(); + while (++s < o) s in r && t.call(i, r[s], s, n); + }), + Array.prototype.map || + (Array.prototype.map = function (t) { + var n = F(this), + r = g && a(this) == "[object String]" ? this.split("") : n, + i = r.length >>> 0, + s = Array(i), + o = arguments[1]; + if (a(t) != "[object Function]") + throw new TypeError(t + " is not a function"); + for (var u = 0; u < i; u++) + u in r && (s[u] = t.call(o, r[u], u, n)); + return s; }), - (Object.create = function(t, n) { - var r; - if (t === null) r = b(); - else { - if (typeof t != "object") + Array.prototype.filter || + (Array.prototype.filter = function (t) { + var n = F(this), + r = g && a(this) == "[object String]" ? this.split("") : n, + i = r.length >>> 0, + s = [], + o, + u = arguments[1]; + if (a(t) != "[object Function]") + throw new TypeError(t + " is not a function"); + for (var f = 0; f < i; f++) + f in r && ((o = r[f]), t.call(u, o, f, n) && s.push(o)); + return s; + }), + Array.prototype.every || + (Array.prototype.every = function (t) { + var n = F(this), + r = g && a(this) == "[object String]" ? this.split("") : n, + i = r.length >>> 0, + s = arguments[1]; + if (a(t) != "[object Function]") + throw new TypeError(t + " is not a function"); + for (var o = 0; o < i; o++) + if (o in r && !t.call(s, r[o], o, n)) return !1; + return !0; + }), + Array.prototype.some || + (Array.prototype.some = function (t) { + var n = F(this), + r = g && a(this) == "[object String]" ? this.split("") : n, + i = r.length >>> 0, + s = arguments[1]; + if (a(t) != "[object Function]") + throw new TypeError(t + " is not a function"); + for (var o = 0; o < i; o++) + if (o in r && t.call(s, r[o], o, n)) return !0; + return !1; + }), + Array.prototype.reduce || + (Array.prototype.reduce = function (t) { + var n = F(this), + r = g && a(this) == "[object String]" ? this.split("") : n, + i = r.length >>> 0; + if (a(t) != "[object Function]") + throw new TypeError(t + " is not a function"); + if (!i && arguments.length == 1) throw new TypeError( - "typeof prototype[" + typeof t + "] != 'object'" + "reduce of empty array with no initial value" ); - var i = function() {}; - (i.prototype = t), (r = new i()), (r.__proto__ = t); - } - return n !== void 0 && Object.defineProperties(r, n), r; + var s = 0, + o; + if (arguments.length >= 2) o = arguments[1]; + else + do { + if (s in r) { + o = r[s++]; + break; + } + if (++s >= i) + throw new TypeError( + "reduce of empty array with no initial value" + ); + } while (!0); + for (; s < i; s++) s in r && (o = t.call(void 0, o, r[s], s, n)); + return o; + }), + Array.prototype.reduceRight || + (Array.prototype.reduceRight = function (t) { + var n = F(this), + r = g && a(this) == "[object String]" ? this.split("") : n, + i = r.length >>> 0; + if (a(t) != "[object Function]") + throw new TypeError(t + " is not a function"); + if (!i && arguments.length == 1) + throw new TypeError( + "reduceRight of empty array with no initial value" + ); + var s, + o = i - 1; + if (arguments.length >= 2) s = arguments[1]; + else + do { + if (o in r) { + s = r[o--]; + break; + } + if (--o < 0) + throw new TypeError( + "reduceRight of empty array with no initial value" + ); + } while (!0); + do o in this && (s = t.call(void 0, s, r[o], o, n)); + while (o--); + return s; + })); + if (!Array.prototype.indexOf || [0, 1].indexOf(1, 2) != -1) + Array.prototype.indexOf = function (t) { + var n = g && a(this) == "[object String]" ? this.split("") : F(this), + r = n.length >>> 0; + if (!r) return -1; + var i = 0; + (arguments.length > 1 && (i = H(arguments[1])), + (i = i >= 0 ? i : Math.max(0, r + i))); + for (; i < r; i++) if (i in n && n[i] === t) return i; + return -1; + }; + if (!Array.prototype.lastIndexOf || [0, 1].lastIndexOf(0, -3) != -1) + Array.prototype.lastIndexOf = function (t) { + var n = g && a(this) == "[object String]" ? this.split("") : F(this), + r = n.length >>> 0; + if (!r) return -1; + var i = r - 1; + (arguments.length > 1 && (i = Math.min(i, H(arguments[1]))), + (i = i >= 0 ? i : r - Math.abs(i))); + for (; i >= 0; i--) if (i in n && t === n[i]) return i; + return -1; + }; + Object.getPrototypeOf || + (Object.getPrototypeOf = function (t) { + return t.__proto__ || (t.constructor ? t.constructor.prototype : o); }); - } - if (Object.defineProperty) { - var E = w({}), - S = typeof document == "undefined" || w(document.createElement("div")); - if (!E || !S) var x = Object.defineProperty; - } - if (!Object.defineProperty || x) { - var T = "Property description must be an object: ", - N = "Object.defineProperty called on non-object: ", - C = "getters & setters can not be defined on this javascript engine"; - Object.defineProperty = function(t, n, r) { - if ((typeof t != "object" && typeof t != "function") || t === null) - throw new TypeError(N + t); - if ((typeof r != "object" && typeof r != "function") || r === null) - throw new TypeError(T + r); - if (x) - try { - return x.call(Object, t, n, r); - } catch (i) {} - if (f(r, "value")) - if (d && (h(t, n) || p(t, n))) { - var s = t.__proto__; - (t.__proto__ = o), delete t[n], (t[n] = r.value), (t.__proto__ = s); - } else t[n] = r.value; - else { - if (!d) throw new TypeError(C); - f(r, "get") && l(t, n, r.get), f(r, "set") && c(t, n, r.set); - } - return t; - }; - } - Object.defineProperties || - (Object.defineProperties = function(t, n) { - for (var r in n) f(n, r) && Object.defineProperty(t, r, n[r]); - return t; - }), - Object.seal || - (Object.seal = function(t) { - return t; - }), - Object.freeze || - (Object.freeze = function(t) { - return t; + if (!Object.getOwnPropertyDescriptor) { + var y = "Object.getOwnPropertyDescriptor called on a non-object: "; + Object.getOwnPropertyDescriptor = function (t, n) { + if ((typeof t != "object" && typeof t != "function") || t === null) + throw new TypeError(y + t); + if (!f(t, n)) return; + var r, i, s; + r = { enumerable: !0, configurable: !0 }; + if (d) { + var u = t.__proto__; + t.__proto__ = o; + var i = h(t, n), + s = p(t, n); + t.__proto__ = u; + if (i || s) return (i && (r.get = i), s && (r.set = s), r); + } + return ((r.value = t[n]), r); + }; + } + Object.getOwnPropertyNames || + (Object.getOwnPropertyNames = function (t) { + return Object.keys(t); }); - try { - Object.freeze(function() {}); - } catch (k) { - Object.freeze = (function(t) { - return function(n) { - return typeof n == "function" ? n : t(n); + if (!Object.create) { + var b; + (Object.prototype.__proto__ === null + ? (b = function () { + return { __proto__: null }; + }) + : (b = function () { + var e = {}; + for (var t in e) e[t] = null; + return ( + (e.constructor = + e.hasOwnProperty = + e.propertyIsEnumerable = + e.isPrototypeOf = + e.toLocaleString = + e.toString = + e.valueOf = + e.__proto__ = + null), + e + ); + }), + (Object.create = function (t, n) { + var r; + if (t === null) r = b(); + else { + if (typeof t != "object") + throw new TypeError( + "typeof prototype[" + typeof t + "] != 'object'" + ); + var i = function () {}; + ((i.prototype = t), (r = new i()), (r.__proto__ = t)); + } + return (n !== void 0 && Object.defineProperties(r, n), r); + })); + } + if (Object.defineProperty) { + var E = w({}), + S = + typeof document == "undefined" || w(document.createElement("div")); + if (!E || !S) var x = Object.defineProperty; + } + if (!Object.defineProperty || x) { + var T = "Property description must be an object: ", + N = "Object.defineProperty called on non-object: ", + C = "getters & setters can not be defined on this javascript engine"; + Object.defineProperty = function (t, n, r) { + if ((typeof t != "object" && typeof t != "function") || t === null) + throw new TypeError(N + t); + if ((typeof r != "object" && typeof r != "function") || r === null) + throw new TypeError(T + r); + if (x) + try { + return x.call(Object, t, n, r); + } catch (i) {} + if (f(r, "value")) + if (d && (h(t, n) || p(t, n))) { + var s = t.__proto__; + ((t.__proto__ = o), + delete t[n], + (t[n] = r.value), + (t.__proto__ = s)); + } else t[n] = r.value; + else { + if (!d) throw new TypeError(C); + (f(r, "get") && l(t, n, r.get), f(r, "set") && c(t, n, r.set)); + } + return t; }; - })(Object.freeze); - } - Object.preventExtensions || - (Object.preventExtensions = function(t) { - return t; - }), - Object.isSealed || - (Object.isSealed = function(t) { - return !1; + } + (Object.defineProperties || + (Object.defineProperties = function (t, n) { + for (var r in n) f(n, r) && Object.defineProperty(t, r, n[r]); + return t; }), - Object.isFrozen || - (Object.isFrozen = function(t) { - return !1; + Object.seal || + (Object.seal = function (t) { + return t; + }), + Object.freeze || + (Object.freeze = function (t) { + return t; + })); + try { + Object.freeze(function () {}); + } catch (k) { + Object.freeze = (function (t) { + return function (n) { + return typeof n == "function" ? n : t(n); + }; + })(Object.freeze); + } + (Object.preventExtensions || + (Object.preventExtensions = function (t) { + return t; }), - Object.isExtensible || - (Object.isExtensible = function(t) { - if (Object(t) === t) throw new TypeError(); - var n = ""; - while (f(t, n)) n += "?"; - t[n] = !0; - var r = f(t, n); - return delete t[n], r; + Object.isSealed || + (Object.isSealed = function (t) { + return !1; + }), + Object.isFrozen || + (Object.isFrozen = function (t) { + return !1; + }), + Object.isExtensible || + (Object.isExtensible = function (t) { + if (Object(t) === t) throw new TypeError(); + var n = ""; + while (f(t, n)) n += "?"; + t[n] = !0; + var r = f(t, n); + return (delete t[n], r); + })); + if (!Object.keys) { + var L = !0, + A = [ + "toString", + "toLocaleString", + "valueOf", + "hasOwnProperty", + "isPrototypeOf", + "propertyIsEnumerable", + "constructor" + ], + O = A.length; + for (var M in { toString: null }) L = !1; + Object.keys = function I(e) { + if ((typeof e != "object" && typeof e != "function") || e === null) + throw new TypeError("Object.keys called on a non-object"); + var I = []; + for (var t in e) f(e, t) && I.push(t); + if (L) + for (var n = 0, r = O; n < r; n++) { + var i = A[n]; + f(e, i) && I.push(i); + } + return I; + }; + } + Date.now || + (Date.now = function () { + return new Date().getTime(); }); - if (!Object.keys) { - var L = !0, - A = [ - "toString", - "toLocaleString", - "valueOf", - "hasOwnProperty", - "isPrototypeOf", - "propertyIsEnumerable", - "constructor" - ], - O = A.length; - for (var M in { toString: null }) L = !1; - Object.keys = function I(e) { - if ((typeof e != "object" && typeof e != "function") || e === null) - throw new TypeError("Object.keys called on a non-object"); - var I = []; - for (var t in e) f(e, t) && I.push(t); - if (L) - for (var n = 0, r = O; n < r; n++) { - var i = A[n]; - f(e, i) && I.push(i); - } - return I; + var _ = + " \n \f\r \u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029\ufeff"; + if (!String.prototype.trim || _.trim()) { + _ = "[" + _ + "]"; + var D = new RegExp("^" + _ + _ + "*"), + P = new RegExp(_ + _ + "*$"); + String.prototype.trim = function () { + return String(this).replace(D, "").replace(P, ""); + }; + } + var F = function (e) { + if (e == null) throw new TypeError("can't convert " + e + " to object"); + return Object(e); }; } - Date.now || - (Date.now = function() { - return new Date().getTime(); - }); - var _ = - " \n \f\r \u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029\ufeff"; - if (!String.prototype.trim || _.trim()) { - _ = "[" + _ + "]"; - var D = new RegExp("^" + _ + _ + "*"), - P = new RegExp(_ + _ + "*$"); - String.prototype.trim = function() { - return String(this) - .replace(D, "") - .replace(P, ""); - }; + ), + define( + "ace/lib/fixoldbrowsers", + ["require", "exports", "module", "ace/lib/regexp", "ace/lib/es5-shim"], + function (e, t, n) { + "use strict"; + (e("./regexp"), e("./es5-shim")); } - var F = function(e) { - if (e == null) throw new TypeError("can't convert " + e + " to object"); - return Object(e); - }; - }), - define("ace/lib/fixoldbrowsers", [ - "require", - "exports", - "module", - "ace/lib/regexp", - "ace/lib/es5-shim" - ], function(e, t, n) { - "use strict"; - e("./regexp"), e("./es5-shim"); - }), - define("ace/lib/dom", ["require", "exports", "module"], function(e, t, n) { + ), + define("ace/lib/dom", ["require", "exports", "module"], function (e, t, n) { "use strict"; var r = "http://www.w3.org/1999/xhtml"; - (t.getDocumentHead = function(e) { + ((t.getDocumentHead = function (e) { return ( e || (e = document), e.head || e.getElementsByTagName("head")[0] || e.documentElement ); }), - (t.createElement = function(e, t) { + (t.createElement = function (e, t) { return document.createElementNS ? document.createElementNS(t || r, e) : document.createElement(e); }), - (t.hasCssClass = function(e, t) { + (t.hasCssClass = function (e, t) { var n = (e.className + "").split(/\s+/g); return n.indexOf(t) !== -1; }), - (t.addCssClass = function(e, n) { + (t.addCssClass = function (e, n) { t.hasCssClass(e, n) || (e.className += " " + n); }), - (t.removeCssClass = function(e, t) { + (t.removeCssClass = function (e, t) { var n = e.className.split(/\s+/g); for (;;) { var r = n.indexOf(t); @@ -653,20 +665,20 @@ } e.className = n.join(" "); }), - (t.toggleCssClass = function(e, t) { + (t.toggleCssClass = function (e, t) { var n = e.className.split(/\s+/g), r = !0; for (;;) { var i = n.indexOf(t); if (i == -1) break; - (r = !1), n.splice(i, 1); + ((r = !1), n.splice(i, 1)); } - return r && n.push(t), (e.className = n.join(" ")), r; + return (r && n.push(t), (e.className = n.join(" ")), r); }), - (t.setCssClass = function(e, n, r) { + (t.setCssClass = function (e, n, r) { r ? t.addCssClass(e, n) : t.removeCssClass(e, n); }), - (t.hasCssString = function(e, t) { + (t.hasCssString = function (e, t) { var n = 0, r; t = t || document; @@ -676,11 +688,11 @@ while (n < r.length) if (r[n++].id === e) return !0; return !1; }), - (t.importCssString = function(n, r, i) { + (t.importCssString = function (n, r, i) { i = i || document; if (r && t.hasCssString(r, i)) return null; var s; - r && (n += "\n/*# sourceURL=ace/css/" + r + " */"), + (r && (n += "\n/*# sourceURL=ace/css/" + r + " */"), i.createStyleSheet ? ((s = i.createStyleSheet()), (s.cssText = n), @@ -688,105 +700,105 @@ : ((s = t.createElement("style")), s.appendChild(i.createTextNode(n)), r && (s.id = r), - t.getDocumentHead(i).appendChild(s)); + t.getDocumentHead(i).appendChild(s))); }), - (t.importCssStylsheet = function(e, n) { + (t.importCssStylsheet = function (e, n) { if (n.createStyleSheet) n.createStyleSheet(e); else { var r = t.createElement("link"); - (r.rel = "stylesheet"), + ((r.rel = "stylesheet"), (r.href = e), - t.getDocumentHead(n).appendChild(r); + t.getDocumentHead(n).appendChild(r)); } }), - (t.getInnerWidth = function(e) { + (t.getInnerWidth = function (e) { return ( parseInt(t.computedStyle(e, "paddingLeft"), 10) + parseInt(t.computedStyle(e, "paddingRight"), 10) + e.clientWidth ); }), - (t.getInnerHeight = function(e) { + (t.getInnerHeight = function (e) { return ( parseInt(t.computedStyle(e, "paddingTop"), 10) + parseInt(t.computedStyle(e, "paddingBottom"), 10) + e.clientHeight ); }), - (t.scrollbarWidth = function(e) { + (t.scrollbarWidth = function (e) { var n = t.createElement("ace_inner"); - (n.style.width = "100%"), + ((n.style.width = "100%"), (n.style.minWidth = "0px"), (n.style.height = "200px"), - (n.style.display = "block"); + (n.style.display = "block")); var r = t.createElement("ace_outer"), i = r.style; - (i.position = "absolute"), + ((i.position = "absolute"), (i.left = "-10000px"), (i.overflow = "hidden"), (i.width = "200px"), (i.minWidth = "0px"), (i.height = "150px"), (i.display = "block"), - r.appendChild(n); + r.appendChild(n)); var s = e.documentElement; s.appendChild(r); var o = n.offsetWidth; i.overflow = "scroll"; var u = n.offsetWidth; - return o == u && (u = r.clientWidth), s.removeChild(r), o - u; - }); + return (o == u && (u = r.clientWidth), s.removeChild(r), o - u); + })); if (typeof document == "undefined") { - t.importCssString = function() {}; + t.importCssString = function () {}; return; } - window.pageYOffset !== undefined - ? ((t.getPageScrollTop = function() { + (window.pageYOffset !== undefined + ? ((t.getPageScrollTop = function () { return window.pageYOffset; }), - (t.getPageScrollLeft = function() { + (t.getPageScrollLeft = function () { return window.pageXOffset; })) - : ((t.getPageScrollTop = function() { + : ((t.getPageScrollTop = function () { return document.body.scrollTop; }), - (t.getPageScrollLeft = function() { + (t.getPageScrollLeft = function () { return document.body.scrollLeft; })), window.getComputedStyle - ? (t.computedStyle = function(e, t) { + ? (t.computedStyle = function (e, t) { return t ? (window.getComputedStyle(e, "") || {})[t] || "" : window.getComputedStyle(e, "") || {}; }) - : (t.computedStyle = function(e, t) { + : (t.computedStyle = function (e, t) { return t ? e.currentStyle[t] : e.currentStyle; }), - (t.setInnerHtml = function(e, t) { + (t.setInnerHtml = function (e, t) { var n = e.cloneNode(!1); - return (n.innerHTML = t), e.parentNode.replaceChild(n, e), n; + return ((n.innerHTML = t), e.parentNode.replaceChild(n, e), n); }), "textContent" in document.documentElement - ? ((t.setInnerText = function(e, t) { + ? ((t.setInnerText = function (e, t) { e.textContent = t; }), - (t.getInnerText = function(e) { + (t.getInnerText = function (e) { return e.textContent; })) - : ((t.setInnerText = function(e, t) { + : ((t.setInnerText = function (e, t) { e.innerText = t; }), - (t.getInnerText = function(e) { + (t.getInnerText = function (e) { return e.innerText; })), - (t.getParentWindow = function(e) { + (t.getParentWindow = function (e) { return e.defaultView || e.parentWindow; - }); + })); }), - define("ace/lib/oop", ["require", "exports", "module"], function(e, t, n) { + define("ace/lib/oop", ["require", "exports", "module"], function (e, t, n) { "use strict"; - (t.inherits = function(e, t) { - (e.super_ = t), + ((t.inherits = function (e, t) { + ((e.super_ = t), (e.prototype = Object.create(t.prototype, { constructor: { value: e, @@ -794,498 +806,501 @@ writable: !0, configurable: !0 } - })); + }))); }), - (t.mixin = function(e, t) { + (t.mixin = function (e, t) { for (var n in t) e[n] = t[n]; return e; }), - (t.implement = function(e, n) { + (t.implement = function (e, n) { t.mixin(e, n); - }); - }), - define("ace/lib/keys", [ - "require", - "exports", - "module", - "ace/lib/fixoldbrowsers", - "ace/lib/oop" - ], function(e, t, n) { - "use strict"; - e("./fixoldbrowsers"); - var r = e("./oop"), - i = (function() { - var e = { - MODIFIER_KEYS: { 16: "Shift", 17: "Ctrl", 18: "Alt", 224: "Meta" }, - KEY_MODS: { - ctrl: 1, - alt: 2, - option: 2, - shift: 4, - super: 8, - meta: 8, - command: 8, - cmd: 8 - }, - FUNCTION_KEYS: { - 8: "Backspace", - 9: "Tab", - 13: "Return", - 19: "Pause", - 27: "Esc", - 32: "Space", - 33: "PageUp", - 34: "PageDown", - 35: "End", - 36: "Home", - 37: "Left", - 38: "Up", - 39: "Right", - 40: "Down", - 44: "Print", - 45: "Insert", - 46: "Delete", - 96: "Numpad0", - 97: "Numpad1", - 98: "Numpad2", - 99: "Numpad3", - 100: "Numpad4", - 101: "Numpad5", - 102: "Numpad6", - 103: "Numpad7", - 104: "Numpad8", - 105: "Numpad9", - "-13": "NumpadEnter", - 112: "F1", - 113: "F2", - 114: "F3", - 115: "F4", - 116: "F5", - 117: "F6", - 118: "F7", - 119: "F8", - 120: "F9", - 121: "F10", - 122: "F11", - 123: "F12", - 144: "Numlock", - 145: "Scrolllock" - }, - PRINTABLE_KEYS: { - 32: " ", - 48: "0", - 49: "1", - 50: "2", - 51: "3", - 52: "4", - 53: "5", - 54: "6", - 55: "7", - 56: "8", - 57: "9", - 59: ";", - 61: "=", - 65: "a", - 66: "b", - 67: "c", - 68: "d", - 69: "e", - 70: "f", - 71: "g", - 72: "h", - 73: "i", - 74: "j", - 75: "k", - 76: "l", - 77: "m", - 78: "n", - 79: "o", - 80: "p", - 81: "q", - 82: "r", - 83: "s", - 84: "t", - 85: "u", - 86: "v", - 87: "w", - 88: "x", - 89: "y", - 90: "z", - 107: "+", - 109: "-", - 110: ".", - 186: ";", - 187: "=", - 188: ",", - 189: "-", - 190: ".", - 191: "/", - 192: "`", - 219: "[", - 220: "\\", - 221: "]", - 222: "'", - 111: "/", - 106: "*" - } - }, - t, - n; - for (n in e.FUNCTION_KEYS) - (t = e.FUNCTION_KEYS[n].toLowerCase()), (e[t] = parseInt(n, 10)); - for (n in e.PRINTABLE_KEYS) - (t = e.PRINTABLE_KEYS[n].toLowerCase()), (e[t] = parseInt(n, 10)); - return ( - r.mixin(e, e.MODIFIER_KEYS), - r.mixin(e, e.PRINTABLE_KEYS), - r.mixin(e, e.FUNCTION_KEYS), - (e.enter = e["return"]), - (e.escape = e.esc), - (e.del = e["delete"]), - (e[173] = "-"), - (function() { - var t = ["cmd", "ctrl", "alt", "shift"]; - for (var n = Math.pow(2, t.length); n--; ) - e.KEY_MODS[n] = - t - .filter(function(t) { - return n & e.KEY_MODS[t]; - }) - .join("-") + "-"; - })(), - (e.KEY_MODS[0] = ""), - (e.KEY_MODS[-1] = "input-"), - e - ); - })(); - r.mixin(t, i), - (t.keyCodeToString = function(e) { - var t = i[e]; - return ( - typeof t != "string" && (t = String.fromCharCode(e)), t.toLowerCase() - ); - }); - }), - define("ace/lib/useragent", ["require", "exports", "module"], function( - e, - t, - n - ) { - "use strict"; - (t.OS = { LINUX: "LINUX", MAC: "MAC", WINDOWS: "WINDOWS" }), - (t.getOS = function() { - return t.isMac ? t.OS.MAC : t.isLinux ? t.OS.LINUX : t.OS.WINDOWS; - }); - if (typeof navigator != "object") return; - var r = (navigator.platform.match(/mac|win|linux/i) || [ - "other" - ])[0].toLowerCase(), - i = navigator.userAgent; - (t.isWin = r == "win"), - (t.isMac = r == "mac"), - (t.isLinux = r == "linux"), - (t.isGecko = t.isMozilla = - (window.Controllers || window.controllers) && - window.navigator.product === "Gecko"), - (t.isOldGecko = - t.isGecko && parseInt((i.match(/rv:(\d+)/) || [])[1], 10) < 4), - (t.isOpera = - window.opera && - Object.prototype.toString.call(window.opera) == "[object Opera]"), - (t.isWebKit = parseFloat(i.split("WebKit/")[1]) || undefined), - (t.isChrome = parseFloat(i.split(" Chrome/")[1]) || undefined), - (t.isAIR = i.indexOf("AdobeAIR") >= 0), - (t.isIPad = i.indexOf("iPad") >= 0), - (t.isTouchPad = i.indexOf("TouchPad") >= 0), - (t.isChromeOS = i.indexOf(" CrOS ") >= 0); + })); }), - define("ace/lib/event", [ - "require", - "exports", - "module", + define( "ace/lib/keys", - "ace/lib/useragent" - ], function(e, t, n) { - "use strict"; - function a(e, t, n) { - var a = u(t); - if (!i.isMac && s) { - t.getModifierState && - (t.getModifierState("OS") || t.getModifierState("Win")) && - (a |= 8); - if (s.altGr) { - if ((3 & a) == 3) return; - s.altGr = 0; + ["require", "exports", "module", "ace/lib/fixoldbrowsers", "ace/lib/oop"], + function (e, t, n) { + "use strict"; + e("./fixoldbrowsers"); + var r = e("./oop"), + i = (function () { + var e = { + MODIFIER_KEYS: { + 16: "Shift", + 17: "Ctrl", + 18: "Alt", + 224: "Meta" + }, + KEY_MODS: { + ctrl: 1, + alt: 2, + option: 2, + shift: 4, + super: 8, + meta: 8, + command: 8, + cmd: 8 + }, + FUNCTION_KEYS: { + 8: "Backspace", + 9: "Tab", + 13: "Return", + 19: "Pause", + 27: "Esc", + 32: "Space", + 33: "PageUp", + 34: "PageDown", + 35: "End", + 36: "Home", + 37: "Left", + 38: "Up", + 39: "Right", + 40: "Down", + 44: "Print", + 45: "Insert", + 46: "Delete", + 96: "Numpad0", + 97: "Numpad1", + 98: "Numpad2", + 99: "Numpad3", + 100: "Numpad4", + 101: "Numpad5", + 102: "Numpad6", + 103: "Numpad7", + 104: "Numpad8", + 105: "Numpad9", + "-13": "NumpadEnter", + 112: "F1", + 113: "F2", + 114: "F3", + 115: "F4", + 116: "F5", + 117: "F6", + 118: "F7", + 119: "F8", + 120: "F9", + 121: "F10", + 122: "F11", + 123: "F12", + 144: "Numlock", + 145: "Scrolllock" + }, + PRINTABLE_KEYS: { + 32: " ", + 48: "0", + 49: "1", + 50: "2", + 51: "3", + 52: "4", + 53: "5", + 54: "6", + 55: "7", + 56: "8", + 57: "9", + 59: ";", + 61: "=", + 65: "a", + 66: "b", + 67: "c", + 68: "d", + 69: "e", + 70: "f", + 71: "g", + 72: "h", + 73: "i", + 74: "j", + 75: "k", + 76: "l", + 77: "m", + 78: "n", + 79: "o", + 80: "p", + 81: "q", + 82: "r", + 83: "s", + 84: "t", + 85: "u", + 86: "v", + 87: "w", + 88: "x", + 89: "y", + 90: "z", + 107: "+", + 109: "-", + 110: ".", + 186: ";", + 187: "=", + 188: ",", + 189: "-", + 190: ".", + 191: "/", + 192: "`", + 219: "[", + 220: "\\", + 221: "]", + 222: "'", + 111: "/", + 106: "*" + } + }, + t, + n; + for (n in e.FUNCTION_KEYS) + ((t = e.FUNCTION_KEYS[n].toLowerCase()), (e[t] = parseInt(n, 10))); + for (n in e.PRINTABLE_KEYS) + ((t = e.PRINTABLE_KEYS[n].toLowerCase()), (e[t] = parseInt(n, 10))); + return ( + r.mixin(e, e.MODIFIER_KEYS), + r.mixin(e, e.PRINTABLE_KEYS), + r.mixin(e, e.FUNCTION_KEYS), + (e.enter = e["return"]), + (e.escape = e.esc), + (e.del = e["delete"]), + (e[173] = "-"), + (function () { + var t = ["cmd", "ctrl", "alt", "shift"]; + for (var n = Math.pow(2, t.length); n--;) + e.KEY_MODS[n] = + t + .filter(function (t) { + return n & e.KEY_MODS[t]; + }) + .join("-") + "-"; + })(), + (e.KEY_MODS[0] = ""), + (e.KEY_MODS[-1] = "input-"), + e + ); + })(); + (r.mixin(t, i), + (t.keyCodeToString = function (e) { + var t = i[e]; + return ( + typeof t != "string" && (t = String.fromCharCode(e)), + t.toLowerCase() + ); + })); + } + ), + define( + "ace/lib/useragent", + ["require", "exports", "module"], + function (e, t, n) { + "use strict"; + ((t.OS = { LINUX: "LINUX", MAC: "MAC", WINDOWS: "WINDOWS" }), + (t.getOS = function () { + return t.isMac ? t.OS.MAC : t.isLinux ? t.OS.LINUX : t.OS.WINDOWS; + })); + if (typeof navigator != "object") return; + var r = (navigator.platform.match(/mac|win|linux/i) || [ + "other" + ])[0].toLowerCase(), + i = navigator.userAgent; + ((t.isWin = r == "win"), + (t.isMac = r == "mac"), + (t.isLinux = r == "linux"), + (t.isGecko = t.isMozilla = + (window.Controllers || window.controllers) && + window.navigator.product === "Gecko"), + (t.isOldGecko = + t.isGecko && parseInt((i.match(/rv:(\d+)/) || [])[1], 10) < 4), + (t.isOpera = + window.opera && + Object.prototype.toString.call(window.opera) == "[object Opera]"), + (t.isWebKit = parseFloat(i.split("WebKit/")[1]) || undefined), + (t.isChrome = parseFloat(i.split(" Chrome/")[1]) || undefined), + (t.isAIR = i.indexOf("AdobeAIR") >= 0), + (t.isIPad = i.indexOf("iPad") >= 0), + (t.isTouchPad = i.indexOf("TouchPad") >= 0), + (t.isChromeOS = i.indexOf(" CrOS ") >= 0)); + } + ), + define( + "ace/lib/event", + ["require", "exports", "module", "ace/lib/keys", "ace/lib/useragent"], + function (e, t, n) { + "use strict"; + function a(e, t, n) { + var a = u(t); + if (!i.isMac && s) { + t.getModifierState && + (t.getModifierState("OS") || t.getModifierState("Win")) && + (a |= 8); + if (s.altGr) { + if ((3 & a) == 3) return; + s.altGr = 0; + } + if (n === 18 || n === 17) { + var f = "location" in t ? t.location : t.keyLocation; + if (n === 17 && f === 1) s[n] == 1 && (o = t.timeStamp); + else if (n === 18 && a === 3 && f === 2) { + var l = t.timeStamp - o; + l < 50 && (s.altGr = !0); + } + } } - if (n === 18 || n === 17) { + (n in r.MODIFIER_KEYS && (n = -1), + a & 8 && n >= 91 && n <= 93 && (n = -1)); + if (!a && n === 13) { var f = "location" in t ? t.location : t.keyLocation; - if (n === 17 && f === 1) s[n] == 1 && (o = t.timeStamp); - else if (n === 18 && a === 3 && f === 2) { - var l = t.timeStamp - o; - l < 50 && (s.altGr = !0); + if (f === 3) { + e(t, a, -n); + if (t.defaultPrevented) return; } } - } - n in r.MODIFIER_KEYS && (n = -1), a & 8 && n >= 91 && n <= 93 && (n = -1); - if (!a && n === 13) { - var f = "location" in t ? t.location : t.keyLocation; - if (f === 3) { - e(t, a, -n); + if (i.isChromeOS && a & 8) { + e(t, a, n); if (t.defaultPrevented) return; + a &= -9; } + return !!a || n in r.FUNCTION_KEYS || n in r.PRINTABLE_KEYS + ? e(t, a, n) + : !1; } - if (i.isChromeOS && a & 8) { - e(t, a, n); - if (t.defaultPrevented) return; - a &= -9; - } - return !!a || n in r.FUNCTION_KEYS || n in r.PRINTABLE_KEYS - ? e(t, a, n) - : !1; - } - function f() { - s = Object.create(null); - } - var r = e("./keys"), - i = e("./useragent"), - s = null, - o = 0; - (t.addListener = function(e, t, n) { - if (e.addEventListener) return e.addEventListener(t, n, !1); - if (e.attachEvent) { - var r = function() { - n.call(e, window.event); - }; - (n._wrapper = r), e.attachEvent("on" + t, r); + function f() { + s = Object.create(null); } - }), - (t.removeListener = function(e, t, n) { - if (e.removeEventListener) return e.removeEventListener(t, n, !1); - e.detachEvent && e.detachEvent("on" + t, n._wrapper || n); - }), - (t.stopEvent = function(e) { - return t.stopPropagation(e), t.preventDefault(e), !1; - }), - (t.stopPropagation = function(e) { - e.stopPropagation ? e.stopPropagation() : (e.cancelBubble = !0); - }), - (t.preventDefault = function(e) { - e.preventDefault ? e.preventDefault() : (e.returnValue = !1); - }), - (t.getButton = function(e) { - return e.type == "dblclick" - ? 0 - : e.type == "contextmenu" || - (i.isMac && e.ctrlKey && !e.altKey && !e.shiftKey) - ? 2 - : e.preventDefault - ? e.button - : { 1: 0, 2: 2, 4: 1 }[e.button]; - }), - (t.capture = function(e, n, r) { - function i(e) { - n && n(e), - r && r(e), - t.removeListener(document, "mousemove", n, !0), - t.removeListener(document, "mouseup", i, !0), - t.removeListener(document, "dragstart", i, !0); + var r = e("./keys"), + i = e("./useragent"), + s = null, + o = 0; + ((t.addListener = function (e, t, n) { + if (e.addEventListener) return e.addEventListener(t, n, !1); + if (e.attachEvent) { + var r = function () { + n.call(e, window.event); + }; + ((n._wrapper = r), e.attachEvent("on" + t, r)); } - return ( - t.addListener(document, "mousemove", n, !0), - t.addListener(document, "mouseup", i, !0), - t.addListener(document, "dragstart", i, !0), - i - ); - }), - (t.addTouchMoveListener = function(e, n) { - if ("ontouchmove" in e) { - var r, i; - t.addListener(e, "touchstart", function(e) { - var t = e.changedTouches[0]; - (r = t.clientX), (i = t.clientY); - }), - t.addListener(e, "touchmove", function(e) { - var t = 1, - s = e.changedTouches[0]; - (e.wheelX = -(s.clientX - r) / t), - (e.wheelY = -(s.clientY - i) / t), - (r = s.clientX), - (i = s.clientY), - n(e); - }); - } - }), - (t.addMouseWheelListener = function(e, n) { - "onmousewheel" in e - ? t.addListener(e, "mousewheel", function(e) { - var t = 8; - e.wheelDeltaX !== undefined - ? ((e.wheelX = -e.wheelDeltaX / t), - (e.wheelY = -e.wheelDeltaY / t)) - : ((e.wheelX = 0), (e.wheelY = -e.wheelDelta / t)), - n(e); - }) - : "onwheel" in e - ? t.addListener(e, "wheel", function(e) { - var t = 0.35; - switch (e.deltaMode) { - case e.DOM_DELTA_PIXEL: - (e.wheelX = e.deltaX * t || 0), - (e.wheelY = e.deltaY * t || 0); - break; - case e.DOM_DELTA_LINE: - case e.DOM_DELTA_PAGE: - (e.wheelX = (e.deltaX || 0) * 5), - (e.wheelY = (e.deltaY || 0) * 5); - } - n(e); - }) - : t.addListener(e, "DOMMouseScroll", function(e) { - e.axis && e.axis == e.HORIZONTAL_AXIS - ? ((e.wheelX = (e.detail || 0) * 5), (e.wheelY = 0)) - : ((e.wheelX = 0), (e.wheelY = (e.detail || 0) * 5)), - n(e); - }); }), - (t.addMultiMouseDownListener = function(e, n, r, s) { - function c(e) { - t.getButton(e) !== 0 - ? (o = 0) - : e.detail > 1 - ? (o++, o > 4 && (o = 1)) - : (o = 1); - (e._clicks = o), r[s]("mousedown", e); - if (o > 4) o = 0; - else if (o > 1) return r[s](l[o], e); - } - function h(e) { - (o = 2), - f && clearTimeout(f), - (f = setTimeout(function() { - f = null; - }, n[o - 1] || 600)), - r[s]("mousedown", e), - r[s](l[o], e); - } - var o = 0, - u, - a, - f, - l = { 2: "dblclick", 3: "tripleclick", 4: "quadclick" }; - Array.isArray(e) || (e = [e]), - e.forEach(function(e) { - t.addListener(e, "mousedown", c); - }); - }); - var u = - !i.isMac || !i.isOpera || "KeyboardEvent" in window - ? function(e) { - return ( - 0 | - (e.ctrlKey ? 1 : 0) | - (e.altKey ? 2 : 0) | - (e.shiftKey ? 4 : 0) | - (e.metaKey ? 8 : 0) - ); + (t.removeListener = function (e, t, n) { + if (e.removeEventListener) return e.removeEventListener(t, n, !1); + e.detachEvent && e.detachEvent("on" + t, n._wrapper || n); + }), + (t.stopEvent = function (e) { + return (t.stopPropagation(e), t.preventDefault(e), !1); + }), + (t.stopPropagation = function (e) { + e.stopPropagation ? e.stopPropagation() : (e.cancelBubble = !0); + }), + (t.preventDefault = function (e) { + e.preventDefault ? e.preventDefault() : (e.returnValue = !1); + }), + (t.getButton = function (e) { + return e.type == "dblclick" + ? 0 + : e.type == "contextmenu" || + (i.isMac && e.ctrlKey && !e.altKey && !e.shiftKey) + ? 2 + : e.preventDefault + ? e.button + : { 1: 0, 2: 2, 4: 1 }[e.button]; + }), + (t.capture = function (e, n, r) { + function i(e) { + (n && n(e), + r && r(e), + t.removeListener(document, "mousemove", n, !0), + t.removeListener(document, "mouseup", i, !0), + t.removeListener(document, "dragstart", i, !0)); } - : function(e) { - return ( - 0 | - (e.metaKey ? 1 : 0) | - (e.altKey ? 2 : 0) | - (e.shiftKey ? 4 : 0) | - (e.ctrlKey ? 8 : 0) - ); - }; - (t.getModifierString = function(e) { - return r.KEY_MODS[u(e)]; - }), - (t.addCommandKeyListener = function(e, n) { - var r = t.addListener; - if (i.isOldGecko || (i.isOpera && !("KeyboardEvent" in window))) { - var o = null; - r(e, "keydown", function(e) { - o = e.keyCode; - }), - r(e, "keypress", function(e) { - return a(n, e, o); - }); - } else { - var u = null; - r(e, "keydown", function(e) { - s[e.keyCode] = (s[e.keyCode] || 0) + 1; - var t = a(n, e, e.keyCode); - return (u = e.defaultPrevented), t; - }), - r(e, "keypress", function(e) { - u && - (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) && - (t.stopEvent(e), (u = null)); - }), - r(e, "keyup", function(e) { - s[e.keyCode] = null; + return ( + t.addListener(document, "mousemove", n, !0), + t.addListener(document, "mouseup", i, !0), + t.addListener(document, "dragstart", i, !0), + i + ); + }), + (t.addTouchMoveListener = function (e, n) { + if ("ontouchmove" in e) { + var r, i; + (t.addListener(e, "touchstart", function (e) { + var t = e.changedTouches[0]; + ((r = t.clientX), (i = t.clientY)); }), - s || (f(), r(window, "focus", f)); - } - }); - if (typeof window == "object" && window.postMessage) { - var l = 1; - t.nextTick = function(e, n) { - n = n || window; - var r = "zero-timeout-message-" + l; - t.addListener(n, "message", function i(s) { - s.data == r && - (t.stopPropagation(s), t.removeListener(n, "message", i), e()); + t.addListener(e, "touchmove", function (e) { + var t = 1, + s = e.changedTouches[0]; + ((e.wheelX = -(s.clientX - r) / t), + (e.wheelY = -(s.clientY - i) / t), + (r = s.clientX), + (i = s.clientY), + n(e)); + })); + } }), - n.postMessage(r, "*"); - }; + (t.addMouseWheelListener = function (e, n) { + "onmousewheel" in e + ? t.addListener(e, "mousewheel", function (e) { + var t = 8; + (e.wheelDeltaX !== undefined + ? ((e.wheelX = -e.wheelDeltaX / t), + (e.wheelY = -e.wheelDeltaY / t)) + : ((e.wheelX = 0), (e.wheelY = -e.wheelDelta / t)), + n(e)); + }) + : "onwheel" in e + ? t.addListener(e, "wheel", function (e) { + var t = 0.35; + switch (e.deltaMode) { + case e.DOM_DELTA_PIXEL: + ((e.wheelX = e.deltaX * t || 0), + (e.wheelY = e.deltaY * t || 0)); + break; + case e.DOM_DELTA_LINE: + case e.DOM_DELTA_PAGE: + ((e.wheelX = (e.deltaX || 0) * 5), + (e.wheelY = (e.deltaY || 0) * 5)); + } + n(e); + }) + : t.addListener(e, "DOMMouseScroll", function (e) { + (e.axis && e.axis == e.HORIZONTAL_AXIS + ? ((e.wheelX = (e.detail || 0) * 5), (e.wheelY = 0)) + : ((e.wheelX = 0), (e.wheelY = (e.detail || 0) * 5)), + n(e)); + }); + }), + (t.addMultiMouseDownListener = function (e, n, r, s) { + function c(e) { + t.getButton(e) !== 0 + ? (o = 0) + : e.detail > 1 + ? (o++, o > 4 && (o = 1)) + : (o = 1); + ((e._clicks = o), r[s]("mousedown", e)); + if (o > 4) o = 0; + else if (o > 1) return r[s](l[o], e); + } + function h(e) { + ((o = 2), + f && clearTimeout(f), + (f = setTimeout( + function () { + f = null; + }, + n[o - 1] || 600 + )), + r[s]("mousedown", e), + r[s](l[o], e)); + } + var o = 0, + u, + a, + f, + l = { 2: "dblclick", 3: "tripleclick", 4: "quadclick" }; + (Array.isArray(e) || (e = [e]), + e.forEach(function (e) { + t.addListener(e, "mousedown", c); + })); + })); + var u = + !i.isMac || !i.isOpera || "KeyboardEvent" in window + ? function (e) { + return ( + 0 | + (e.ctrlKey ? 1 : 0) | + (e.altKey ? 2 : 0) | + (e.shiftKey ? 4 : 0) | + (e.metaKey ? 8 : 0) + ); + } + : function (e) { + return ( + 0 | + (e.metaKey ? 1 : 0) | + (e.altKey ? 2 : 0) | + (e.shiftKey ? 4 : 0) | + (e.ctrlKey ? 8 : 0) + ); + }; + ((t.getModifierString = function (e) { + return r.KEY_MODS[u(e)]; + }), + (t.addCommandKeyListener = function (e, n) { + var r = t.addListener; + if (i.isOldGecko || (i.isOpera && !("KeyboardEvent" in window))) { + var o = null; + (r(e, "keydown", function (e) { + o = e.keyCode; + }), + r(e, "keypress", function (e) { + return a(n, e, o); + })); + } else { + var u = null; + (r(e, "keydown", function (e) { + s[e.keyCode] = (s[e.keyCode] || 0) + 1; + var t = a(n, e, e.keyCode); + return ((u = e.defaultPrevented), t); + }), + r(e, "keypress", function (e) { + u && + (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) && + (t.stopEvent(e), (u = null)); + }), + r(e, "keyup", function (e) { + s[e.keyCode] = null; + }), + s || (f(), r(window, "focus", f))); + } + })); + if (typeof window == "object" && window.postMessage) { + var l = 1; + t.nextTick = function (e, n) { + n = n || window; + var r = "zero-timeout-message-" + l; + (t.addListener(n, "message", function i(s) { + s.data == r && + (t.stopPropagation(s), t.removeListener(n, "message", i), e()); + }), + n.postMessage(r, "*")); + }; + } + ((t.nextFrame = + typeof window == "object" && + (window.requestAnimationFrame || + window.mozRequestAnimationFrame || + window.webkitRequestAnimationFrame || + window.msRequestAnimationFrame || + window.oRequestAnimationFrame)), + t.nextFrame + ? (t.nextFrame = t.nextFrame.bind(window)) + : (t.nextFrame = function (e) { + setTimeout(e, 17); + })); } - (t.nextFrame = - typeof window == "object" && - (window.requestAnimationFrame || - window.mozRequestAnimationFrame || - window.webkitRequestAnimationFrame || - window.msRequestAnimationFrame || - window.oRequestAnimationFrame)), - t.nextFrame - ? (t.nextFrame = t.nextFrame.bind(window)) - : (t.nextFrame = function(e) { - setTimeout(e, 17); - }); - }), - define("ace/lib/lang", ["require", "exports", "module"], function(e, t, n) { + ), + define("ace/lib/lang", ["require", "exports", "module"], function (e, t, n) { "use strict"; - (t.last = function(e) { + ((t.last = function (e) { return e[e.length - 1]; }), - (t.stringReverse = function(e) { - return e - .split("") - .reverse() - .join(""); + (t.stringReverse = function (e) { + return e.split("").reverse().join(""); }), - (t.stringRepeat = function(e, t) { + (t.stringRepeat = function (e, t) { var n = ""; while (t > 0) { t & 1 && (n += e); if ((t >>= 1)) e += e; } return n; - }); + })); var r = /^\s\s*/, i = /\s\s*$/; - (t.stringTrimLeft = function(e) { + ((t.stringTrimLeft = function (e) { return e.replace(r, ""); }), - (t.stringTrimRight = function(e) { + (t.stringTrimRight = function (e) { return e.replace(i, ""); }), - (t.copyObject = function(e) { + (t.copyObject = function (e) { var t = {}; for (var n in e) t[n] = e[n]; return t; }), - (t.copyArray = function(e) { + (t.copyArray = function (e) { var t = []; for (var n = 0, r = e.length; n < r; n++) e[n] && typeof e[n] == "object" @@ -1306,33 +1321,33 @@ for (var n in e) t[n] = s(e[n]); return t; }), - (t.arrayToMap = function(e) { + (t.arrayToMap = function (e) { var t = {}; for (var n = 0; n < e.length; n++) t[e[n]] = 1; return t; }), - (t.createMap = function(e) { + (t.createMap = function (e) { var t = Object.create(null); for (var n in e) t[n] = e[n]; return t; }), - (t.arrayRemove = function(e, t) { + (t.arrayRemove = function (e, t) { for (var n = 0; n <= e.length; n++) t === e[n] && e.splice(n, 1); }), - (t.escapeRegExp = function(e) { + (t.escapeRegExp = function (e) { return e.replace(/([.*+?^${}()|[\]\/\\])/g, "\\$1"); }), - (t.escapeHTML = function(e) { + (t.escapeHTML = function (e) { return e .replace(/&/g, "&") .replace(/"/g, """) .replace(/'/g, "'") .replace(/ 1), - e.preventDefault() - ); - }), - (this.startSelect = function(e, t) { - e = e || this.editor.renderer.screenToTextCoordinates(this.x, this.y); - var n = this.editor; - n.$blockScrolling++, - this.mousedownEvent.getShiftKey() - ? n.selection.selectToPosition(e) - : t || n.selection.moveToPosition(e), - t || this.select(), - n.renderer.scroller.setCapture && n.renderer.scroller.setCapture(), - n.setStyle("ace_selecting"), - this.setState("select"), - n.$blockScrolling--; - }), - (this.select = function() { - var e, - t = this.editor, - n = t.renderer.screenToTextCoordinates(this.x, this.y); - t.$blockScrolling++; - if (this.$clickSelection) { - var r = this.$clickSelection.comparePoint(n); - if (r == -1) e = this.$clickSelection.end; - else if (r == 1) e = this.$clickSelection.start; - else { - var i = f(this.$clickSelection, n); - (n = i.cursor), (e = i.anchor); + this.mousedownEvent.time = Date.now(); + if (t && !r.isFocused()) { + r.focus(); + if ( + this.$focusTimout && + !this.$clickSelection && + !r.inMultiSelectMode + ) { + (this.setState("focusWait"), this.captureMouse(e)); + return; } - t.selection.setSelectionAnchor(e.row, e.column); } - t.selection.selectToPosition(n), - t.$blockScrolling--, - t.renderer.scrollCursorIntoView(); + return ( + this.captureMouse(e), + this.startSelect(n, e.domEvent._clicks > 1), + e.preventDefault() + ); }), - (this.extendSelectionBy = function(e) { - var t, - n = this.editor, - r = n.renderer.screenToTextCoordinates(this.x, this.y), - i = n.selection[e](r.row, r.column); - n.$blockScrolling++; - if (this.$clickSelection) { - var s = this.$clickSelection.comparePoint(i.start), - o = this.$clickSelection.comparePoint(i.end); - if (s == -1 && o <= 0) { - t = this.$clickSelection.end; - if (i.end.row != r.row || i.end.column != r.column) r = i.start; - } else if (o == 1 && s >= 0) { - t = this.$clickSelection.start; - if (i.start.row != r.row || i.start.column != r.column) r = i.end; - } else if (s == -1 && o == 1) (r = i.end), (t = i.start); - else { - var u = f(this.$clickSelection, r); - (r = u.cursor), (t = u.anchor); + (this.startSelect = function (e, t) { + e = + e || this.editor.renderer.screenToTextCoordinates(this.x, this.y); + var n = this.editor; + (n.$blockScrolling++, + this.mousedownEvent.getShiftKey() + ? n.selection.selectToPosition(e) + : t || n.selection.moveToPosition(e), + t || this.select(), + n.renderer.scroller.setCapture && + n.renderer.scroller.setCapture(), + n.setStyle("ace_selecting"), + this.setState("select"), + n.$blockScrolling--); + }), + (this.select = function () { + var e, + t = this.editor, + n = t.renderer.screenToTextCoordinates(this.x, this.y); + t.$blockScrolling++; + if (this.$clickSelection) { + var r = this.$clickSelection.comparePoint(n); + if (r == -1) e = this.$clickSelection.end; + else if (r == 1) e = this.$clickSelection.start; + else { + var i = f(this.$clickSelection, n); + ((n = i.cursor), (e = i.anchor)); + } + t.selection.setSelectionAnchor(e.row, e.column); } - n.selection.setSelectionAnchor(t.row, t.column); - } - n.selection.selectToPosition(r), - n.$blockScrolling--, - n.renderer.scrollCursorIntoView(); - }), - (this.selectEnd = this.selectAllEnd = this.selectByWordsEnd = this.selectByLinesEnd = function() { - (this.$clickSelection = null), - this.editor.unsetStyle("ace_selecting"), - this.editor.renderer.scroller.releaseCapture && - this.editor.renderer.scroller.releaseCapture(); - }), - (this.focusWait = function() { - var e = a( - this.mousedownEvent.x, - this.mousedownEvent.y, - this.x, - this.y - ), - t = Date.now(); - (e > o || t - this.mousedownEvent.time > this.$focusTimout) && - this.startSelect(this.mousedownEvent.getDocumentPosition()); - }), - (this.onDoubleClick = function(e) { - var t = e.getDocumentPosition(), - n = this.editor, - r = n.session, - i = r.getBracketRange(t); - i - ? (i.isEmpty() && (i.start.column--, i.end.column++), - this.setState("select")) - : ((i = n.selection.getWordRange(t.row, t.column)), - this.setState("selectByWords")), - (this.$clickSelection = i), - this.select(); - }), - (this.onTripleClick = function(e) { - var t = e.getDocumentPosition(), - n = this.editor; - this.setState("selectByLines"); - var r = n.getSelectionRange(); - r.isMultiLine() && r.contains(t.row, t.column) - ? ((this.$clickSelection = n.selection.getLineRange(r.start.row)), - (this.$clickSelection.end = n.selection.getLineRange( - r.end.row - ).end)) - : (this.$clickSelection = n.selection.getLineRange(t.row)), - this.select(); - }), - (this.onQuadClick = function(e) { - var t = this.editor; - t.selectAll(), - (this.$clickSelection = t.getSelectionRange()), - this.setState("selectAll"); - }), - (this.onMouseWheel = function(e) { - if (e.getAccelKey()) return; - e.getShiftKey() && - e.wheelY && - !e.wheelX && - ((e.wheelX = e.wheelY), (e.wheelY = 0)); - var t = e.domEvent.timeStamp, - n = t - (this.$lastScrollTime || 0), - r = this.editor, - i = r.renderer.isScrollableBy( - e.wheelX * e.speed, - e.wheelY * e.speed - ); - if (i || n < 200) - return ( - (this.$lastScrollTime = t), - r.renderer.scrollBy(e.wheelX * e.speed, e.wheelY * e.speed), - e.stop() - ); - }), - (this.onTouchMove = function(e) { - var t = e.domEvent.timeStamp, - n = t - (this.$lastScrollTime || 0), - r = this.editor, - i = r.renderer.isScrollableBy( - e.wheelX * e.speed, - e.wheelY * e.speed - ); - if (i || n < 200) - return ( - (this.$lastScrollTime = t), - r.renderer.scrollBy(e.wheelX * e.speed, e.wheelY * e.speed), - e.stop() - ); - }); - }.call(u.prototype), - (t.DefaultHandlers = u)); - }), - define("ace/tooltip", [ - "require", - "exports", - "module", - "ace/lib/oop", - "ace/lib/dom" - ], function(e, t, n) { - "use strict"; - function s(e) { - (this.isOpen = !1), (this.$element = null), (this.$parentNode = e); + (t.selection.selectToPosition(n), + t.$blockScrolling--, + t.renderer.scrollCursorIntoView()); + }), + (this.extendSelectionBy = function (e) { + var t, + n = this.editor, + r = n.renderer.screenToTextCoordinates(this.x, this.y), + i = n.selection[e](r.row, r.column); + n.$blockScrolling++; + if (this.$clickSelection) { + var s = this.$clickSelection.comparePoint(i.start), + o = this.$clickSelection.comparePoint(i.end); + if (s == -1 && o <= 0) { + t = this.$clickSelection.end; + if (i.end.row != r.row || i.end.column != r.column) r = i.start; + } else if (o == 1 && s >= 0) { + t = this.$clickSelection.start; + if (i.start.row != r.row || i.start.column != r.column) + r = i.end; + } else if (s == -1 && o == 1) ((r = i.end), (t = i.start)); + else { + var u = f(this.$clickSelection, r); + ((r = u.cursor), (t = u.anchor)); + } + n.selection.setSelectionAnchor(t.row, t.column); + } + (n.selection.selectToPosition(r), + n.$blockScrolling--, + n.renderer.scrollCursorIntoView()); + }), + (this.selectEnd = + this.selectAllEnd = + this.selectByWordsEnd = + this.selectByLinesEnd = + function () { + ((this.$clickSelection = null), + this.editor.unsetStyle("ace_selecting"), + this.editor.renderer.scroller.releaseCapture && + this.editor.renderer.scroller.releaseCapture()); + }), + (this.focusWait = function () { + var e = a( + this.mousedownEvent.x, + this.mousedownEvent.y, + this.x, + this.y + ), + t = Date.now(); + (e > o || t - this.mousedownEvent.time > this.$focusTimout) && + this.startSelect(this.mousedownEvent.getDocumentPosition()); + }), + (this.onDoubleClick = function (e) { + var t = e.getDocumentPosition(), + n = this.editor, + r = n.session, + i = r.getBracketRange(t); + (i + ? (i.isEmpty() && (i.start.column--, i.end.column++), + this.setState("select")) + : ((i = n.selection.getWordRange(t.row, t.column)), + this.setState("selectByWords")), + (this.$clickSelection = i), + this.select()); + }), + (this.onTripleClick = function (e) { + var t = e.getDocumentPosition(), + n = this.editor; + this.setState("selectByLines"); + var r = n.getSelectionRange(); + (r.isMultiLine() && r.contains(t.row, t.column) + ? ((this.$clickSelection = n.selection.getLineRange(r.start.row)), + (this.$clickSelection.end = n.selection.getLineRange( + r.end.row + ).end)) + : (this.$clickSelection = n.selection.getLineRange(t.row)), + this.select()); + }), + (this.onQuadClick = function (e) { + var t = this.editor; + (t.selectAll(), + (this.$clickSelection = t.getSelectionRange()), + this.setState("selectAll")); + }), + (this.onMouseWheel = function (e) { + if (e.getAccelKey()) return; + e.getShiftKey() && + e.wheelY && + !e.wheelX && + ((e.wheelX = e.wheelY), (e.wheelY = 0)); + var t = e.domEvent.timeStamp, + n = t - (this.$lastScrollTime || 0), + r = this.editor, + i = r.renderer.isScrollableBy( + e.wheelX * e.speed, + e.wheelY * e.speed + ); + if (i || n < 200) + return ( + (this.$lastScrollTime = t), + r.renderer.scrollBy(e.wheelX * e.speed, e.wheelY * e.speed), + e.stop() + ); + }), + (this.onTouchMove = function (e) { + var t = e.domEvent.timeStamp, + n = t - (this.$lastScrollTime || 0), + r = this.editor, + i = r.renderer.isScrollableBy( + e.wheelX * e.speed, + e.wheelY * e.speed + ); + if (i || n < 200) + return ( + (this.$lastScrollTime = t), + r.renderer.scrollBy(e.wheelX * e.speed, e.wheelY * e.speed), + e.stop() + ); + })); + }).call(u.prototype), + (t.DefaultHandlers = u)); } - var r = e("./lib/oop"), - i = e("./lib/dom"); - (function() { - (this.$init = function() { - return ( - (this.$element = i.createElement("div")), - (this.$element.className = "ace_tooltip"), - (this.$element.style.display = "none"), - this.$parentNode.appendChild(this.$element), - this.$element - ); - }), - (this.getElement = function() { - return this.$element || this.$init(); - }), - (this.setText = function(e) { - i.setInnerText(this.getElement(), e); - }), - (this.setHtml = function(e) { - this.getElement().innerHTML = e; - }), - (this.setPosition = function(e, t) { - (this.getElement().style.left = e + "px"), - (this.getElement().style.top = t + "px"); - }), - (this.setClassName = function(e) { - i.addCssClass(this.getElement(), e); - }), - (this.show = function(e, t, n) { - e != null && this.setText(e), - t != null && n != null && this.setPosition(t, n), - this.isOpen || - ((this.getElement().style.display = "block"), (this.isOpen = !0)); - }), - (this.hide = function() { - this.isOpen && - ((this.getElement().style.display = "none"), (this.isOpen = !1)); - }), - (this.getHeight = function() { - return this.getElement().offsetHeight; + ), + define( + "ace/tooltip", + ["require", "exports", "module", "ace/lib/oop", "ace/lib/dom"], + function (e, t, n) { + "use strict"; + function s(e) { + ((this.isOpen = !1), (this.$element = null), (this.$parentNode = e)); + } + var r = e("./lib/oop"), + i = e("./lib/dom"); + ((function () { + ((this.$init = function () { + return ( + (this.$element = i.createElement("div")), + (this.$element.className = "ace_tooltip"), + (this.$element.style.display = "none"), + this.$parentNode.appendChild(this.$element), + this.$element + ); }), - (this.getWidth = function() { - return this.getElement().offsetWidth; - }); - }.call(s.prototype), - (t.Tooltip = s)); - }), - define("ace/mouse/default_gutter_handler", [ - "require", - "exports", - "module", - "ace/lib/dom", - "ace/lib/oop", - "ace/lib/event", - "ace/tooltip" - ], function(e, t, n) { - "use strict"; - function u(e) { - function l() { - var r = u.getDocumentPosition().row, - s = n.$annotations[r]; - if (!s) return c(); - var o = t.session.getLength(); - if (r == o) { - var a = t.renderer.pixelToScreenCoordinates(0, u.y).row, - l = u.$pos; - if (a > t.session.documentToScreenRow(l.row, l.column)) return c(); + (this.getElement = function () { + return this.$element || this.$init(); + }), + (this.setText = function (e) { + i.setInnerText(this.getElement(), e); + }), + (this.setHtml = function (e) { + this.getElement().innerHTML = e; + }), + (this.setPosition = function (e, t) { + ((this.getElement().style.left = e + "px"), + (this.getElement().style.top = t + "px")); + }), + (this.setClassName = function (e) { + i.addCssClass(this.getElement(), e); + }), + (this.show = function (e, t, n) { + (e != null && this.setText(e), + t != null && n != null && this.setPosition(t, n), + this.isOpen || + ((this.getElement().style.display = "block"), + (this.isOpen = !0))); + }), + (this.hide = function () { + this.isOpen && + ((this.getElement().style.display = "none"), (this.isOpen = !1)); + }), + (this.getHeight = function () { + return this.getElement().offsetHeight; + }), + (this.getWidth = function () { + return this.getElement().offsetWidth; + })); + }).call(s.prototype), + (t.Tooltip = s)); + } + ), + define( + "ace/mouse/default_gutter_handler", + [ + "require", + "exports", + "module", + "ace/lib/dom", + "ace/lib/oop", + "ace/lib/event", + "ace/tooltip" + ], + function (e, t, n) { + "use strict"; + function u(e) { + function l() { + var r = u.getDocumentPosition().row, + s = n.$annotations[r]; + if (!s) return c(); + var o = t.session.getLength(); + if (r == o) { + var a = t.renderer.pixelToScreenCoordinates(0, u.y).row, + l = u.$pos; + if (a > t.session.documentToScreenRow(l.row, l.column)) return c(); + } + if (f == s) return; + ((f = s.text.join("
")), + i.setHtml(f), + i.show(), + t._signal("showGutterTooltip", i), + t.on("mousewheel", c)); + if (e.$tooltipFollowsMouse) h(u); + else { + var p = u.domEvent.target, + d = p.getBoundingClientRect(), + v = i.getElement().style; + ((v.left = d.right + "px"), (v.top = d.bottom + "px")); + } } - if (f == s) return; - (f = s.text.join("
")), - i.setHtml(f), - i.show(), - t._signal("showGutterTooltip", i), - t.on("mousewheel", c); - if (e.$tooltipFollowsMouse) h(u); - else { - var p = u.domEvent.target, - d = p.getBoundingClientRect(), - v = i.getElement().style; - (v.left = d.right + "px"), (v.top = d.bottom + "px"); + function c() { + (o && (o = clearTimeout(o)), + f && + (i.hide(), + (f = null), + t._signal("hideGutterTooltip", i), + t.removeEventListener("mousewheel", c))); } - } - function c() { - o && (o = clearTimeout(o)), - f && - (i.hide(), - (f = null), - t._signal("hideGutterTooltip", i), - t.removeEventListener("mousewheel", c)); - } - function h(e) { - i.setPosition(e.x, e.y); - } - var t = e.editor, - n = t.renderer.$gutterLayer, - i = new a(t.container); - e.editor.setDefaultHandler("guttermousedown", function(r) { - if (!t.isFocused() || r.getButton() != 0) return; - var i = n.getRegion(r); - if (i == "foldWidgets") return; - var s = r.getDocumentPosition().row, - o = t.session.selection; - if (r.getShiftKey()) o.selectTo(s, 0); - else { - if (r.domEvent.detail == 2) return t.selectAll(), r.preventDefault(); - e.$clickSelection = t.selection.getLineRange(s); + function h(e) { + i.setPosition(e.x, e.y); } - return ( - e.setState("selectByLines"), e.captureMouse(r), r.preventDefault() - ); - }); - var o, u, f; - e.editor.setDefaultHandler("guttermousemove", function(t) { - var n = t.domEvent.target || t.domEvent.srcElement; - if (r.hasCssClass(n, "ace_fold-widget")) return c(); - f && e.$tooltipFollowsMouse && h(t), (u = t); - if (o) return; - o = setTimeout(function() { - (o = null), u && !e.isMousePressed ? l() : c(); - }, 50); - }), - s.addListener(t.renderer.$gutter, "mouseout", function(e) { - u = null; - if (!f || o) return; - o = setTimeout(function() { - (o = null), c(); + var t = e.editor, + n = t.renderer.$gutterLayer, + i = new a(t.container); + e.editor.setDefaultHandler("guttermousedown", function (r) { + if (!t.isFocused() || r.getButton() != 0) return; + var i = n.getRegion(r); + if (i == "foldWidgets") return; + var s = r.getDocumentPosition().row, + o = t.session.selection; + if (r.getShiftKey()) o.selectTo(s, 0); + else { + if (r.domEvent.detail == 2) + return (t.selectAll(), r.preventDefault()); + e.$clickSelection = t.selection.getLineRange(s); + } + return ( + e.setState("selectByLines"), + e.captureMouse(r), + r.preventDefault() + ); + }); + var o, u, f; + (e.editor.setDefaultHandler("guttermousemove", function (t) { + var n = t.domEvent.target || t.domEvent.srcElement; + if (r.hasCssClass(n, "ace_fold-widget")) return c(); + (f && e.$tooltipFollowsMouse && h(t), (u = t)); + if (o) return; + o = setTimeout(function () { + ((o = null), u && !e.isMousePressed ? l() : c()); }, 50); }), - t.on("changeSession", c); - } - function a(e) { - o.call(this, e); + s.addListener(t.renderer.$gutter, "mouseout", function (e) { + u = null; + if (!f || o) return; + o = setTimeout(function () { + ((o = null), c()); + }, 50); + }), + t.on("changeSession", c)); + } + function a(e) { + o.call(this, e); + } + var r = e("../lib/dom"), + i = e("../lib/oop"), + s = e("../lib/event"), + o = e("../tooltip").Tooltip; + (i.inherits(a, o), + function () { + this.setPosition = function (e, t) { + var n = window.innerWidth || document.documentElement.clientWidth, + r = window.innerHeight || document.documentElement.clientHeight, + i = this.getWidth(), + s = this.getHeight(); + ((e += 15), + (t += 15), + e + i > n && (e -= e + i - n), + t + s > r && (t -= 20 + s), + o.prototype.setPosition.call(this, e, t)); + }; + }.call(a.prototype), + (t.GutterHandler = u)); } - var r = e("../lib/dom"), - i = e("../lib/oop"), - s = e("../lib/event"), - o = e("../tooltip").Tooltip; - i.inherits(a, o), - function() { - this.setPosition = function(e, t) { - var n = window.innerWidth || document.documentElement.clientWidth, - r = window.innerHeight || document.documentElement.clientHeight, - i = this.getWidth(), - s = this.getHeight(); - (e += 15), - (t += 15), - e + i > n && (e -= e + i - n), - t + s > r && (t -= 20 + s), - o.prototype.setPosition.call(this, e, t); - }; - }.call(a.prototype), - (t.GutterHandler = u); - }), - define("ace/mouse/mouse_event", [ - "require", - "exports", - "module", - "ace/lib/event", - "ace/lib/useragent" - ], function(e, t, n) { - "use strict"; - var r = e("../lib/event"), - i = e("../lib/useragent"), - s = (t.MouseEvent = function(e, t) { - (this.domEvent = e), - (this.editor = t), - (this.x = this.clientX = e.clientX), - (this.y = this.clientY = e.clientY), - (this.$pos = null), - (this.$inSelection = null), - (this.propagationStopped = !1), - (this.defaultPrevented = !1); - }); - (function() { - (this.stopPropagation = function() { - r.stopPropagation(this.domEvent), (this.propagationStopped = !0); - }), - (this.preventDefault = function() { - r.preventDefault(this.domEvent), (this.defaultPrevented = !0); - }), - (this.stop = function() { - this.stopPropagation(), this.preventDefault(); - }), - (this.getDocumentPosition = function() { - return this.$pos - ? this.$pos - : ((this.$pos = this.editor.renderer.screenToTextCoordinates( - this.clientX, - this.clientY - )), - this.$pos); + ), + define( + "ace/mouse/mouse_event", + ["require", "exports", "module", "ace/lib/event", "ace/lib/useragent"], + function (e, t, n) { + "use strict"; + var r = e("../lib/event"), + i = e("../lib/useragent"), + s = (t.MouseEvent = function (e, t) { + ((this.domEvent = e), + (this.editor = t), + (this.x = this.clientX = e.clientX), + (this.y = this.clientY = e.clientY), + (this.$pos = null), + (this.$inSelection = null), + (this.propagationStopped = !1), + (this.defaultPrevented = !1)); + }); + (function () { + ((this.stopPropagation = function () { + (r.stopPropagation(this.domEvent), (this.propagationStopped = !0)); }), - (this.inSelection = function() { - if (this.$inSelection !== null) return this.$inSelection; - var e = this.editor, - t = e.getSelectionRange(); - if (t.isEmpty()) this.$inSelection = !1; + (this.preventDefault = function () { + (r.preventDefault(this.domEvent), (this.defaultPrevented = !0)); + }), + (this.stop = function () { + (this.stopPropagation(), this.preventDefault()); + }), + (this.getDocumentPosition = function () { + return this.$pos + ? this.$pos + : ((this.$pos = this.editor.renderer.screenToTextCoordinates( + this.clientX, + this.clientY + )), + this.$pos); + }), + (this.inSelection = function () { + if (this.$inSelection !== null) return this.$inSelection; + var e = this.editor, + t = e.getSelectionRange(); + if (t.isEmpty()) this.$inSelection = !1; + else { + var n = this.getDocumentPosition(); + this.$inSelection = t.contains(n.row, n.column); + } + return this.$inSelection; + }), + (this.getButton = function () { + return r.getButton(this.domEvent); + }), + (this.getShiftKey = function () { + return this.domEvent.shiftKey; + }), + (this.getAccelKey = i.isMac + ? function () { + return this.domEvent.metaKey; + } + : function () { + return this.domEvent.ctrlKey; + })); + }).call(s.prototype); + } + ), + define( + "ace/mouse/dragdrop_handler", + [ + "require", + "exports", + "module", + "ace/lib/dom", + "ace/lib/event", + "ace/lib/useragent" + ], + function (e, t, n) { + "use strict"; + function f(e) { + function T(e, n) { + var r = Date.now(), + i = !n || e.row != n.row, + s = !n || e.column != n.column; + if (!S || i || s) + ((t.$blockScrolling += 1), + t.moveCursorToPosition(e), + (t.$blockScrolling -= 1), + (S = r), + (x = { x: p, y: d })); else { - var n = this.getDocumentPosition(); - this.$inSelection = t.contains(n.row, n.column); + var o = l(x.x, x.y, p, d); + o > a + ? (S = null) + : r - S >= u && (t.renderer.scrollCursorIntoView(), (S = null)); } - return this.$inSelection; - }), - (this.getButton = function() { - return r.getButton(this.domEvent); - }), - (this.getShiftKey = function() { - return this.domEvent.shiftKey; - }), - (this.getAccelKey = i.isMac - ? function() { - return this.domEvent.metaKey; - } - : function() { - return this.domEvent.ctrlKey; - }); - }.call(s.prototype)); - }), - define("ace/mouse/dragdrop_handler", [ - "require", - "exports", - "module", - "ace/lib/dom", - "ace/lib/event", - "ace/lib/useragent" - ], function(e, t, n) { - "use strict"; - function f(e) { - function T(e, n) { - var r = Date.now(), - i = !n || e.row != n.row, - s = !n || e.column != n.column; - if (!S || i || s) - (t.$blockScrolling += 1), - t.moveCursorToPosition(e), + } + function N(e, n) { + var r = Date.now(), + i = t.renderer.layerConfig.lineHeight, + s = t.renderer.layerConfig.characterWidth, + u = t.renderer.scroller.getBoundingClientRect(), + a = { + x: { left: p - u.left, right: u.right - p }, + y: { top: d - u.top, bottom: u.bottom - d } + }, + f = Math.min(a.x.left, a.x.right), + l = Math.min(a.y.top, a.y.bottom), + c = { row: e.row, column: e.column }; + (f / s <= 2 && (c.column += a.x.left < a.x.right ? -3 : 2), + l / i <= 1 && (c.row += a.y.top < a.y.bottom ? -1 : 1)); + var h = e.row != c.row, + v = e.column != c.column, + m = !n || e.row != n.row; + h || (v && !m) + ? E + ? r - E >= o && t.renderer.scrollCursorIntoView(c) + : (E = r) + : (E = null); + } + function C() { + var e = g; + ((g = t.renderer.screenToTextCoordinates(p, d)), T(g, e), N(g, e)); + } + function k() { + ((m = t.selection.toOrientedRange()), + (h = t.session.addMarker( + m, + "ace_selection", + t.getSelectionStyle() + )), + t.clearSelection(), + t.isFocused() && t.renderer.$cursorLayer.setBlinking(!1), + clearInterval(v), + C(), + (v = setInterval(C, 20)), + (y = 0), + i.addListener(document, "mousemove", O)); + } + function L() { + (clearInterval(v), + t.session.removeMarker(h), + (h = null), + (t.$blockScrolling += 1), + t.selection.fromOrientedRange(m), (t.$blockScrolling -= 1), - (S = r), - (x = { x: p, y: d }); - else { - var o = l(x.x, x.y, p, d); - o > a - ? (S = null) - : r - S >= u && (t.renderer.scrollCursorIntoView(), (S = null)); + t.isFocused() && + !w && + t.renderer.$cursorLayer.setBlinking(!t.getReadOnly()), + (m = null), + (g = null), + (y = 0), + (E = null), + (S = null), + i.removeListener(document, "mousemove", O)); } - } - function N(e, n) { - var r = Date.now(), - i = t.renderer.layerConfig.lineHeight, - s = t.renderer.layerConfig.characterWidth, - u = t.renderer.scroller.getBoundingClientRect(), - a = { - x: { left: p - u.left, right: u.right - p }, - y: { top: d - u.top, bottom: u.bottom - d } - }, - f = Math.min(a.x.left, a.x.right), - l = Math.min(a.y.top, a.y.bottom), - c = { row: e.row, column: e.column }; - f / s <= 2 && (c.column += a.x.left < a.x.right ? -3 : 2), - l / i <= 1 && (c.row += a.y.top < a.y.bottom ? -1 : 1); - var h = e.row != c.row, - v = e.column != c.column, - m = !n || e.row != n.row; - h || (v && !m) - ? E - ? r - E >= o && t.renderer.scrollCursorIntoView(c) - : (E = r) - : (E = null); - } - function C() { - var e = g; - (g = t.renderer.screenToTextCoordinates(p, d)), T(g, e), N(g, e); - } - function k() { - (m = t.selection.toOrientedRange()), - (h = t.session.addMarker(m, "ace_selection", t.getSelectionStyle())), - t.clearSelection(), - t.isFocused() && t.renderer.$cursorLayer.setBlinking(!1), - clearInterval(v), - C(), - (v = setInterval(C, 20)), - (y = 0), - i.addListener(document, "mousemove", O); - } - function L() { - clearInterval(v), - t.session.removeMarker(h), - (h = null), - (t.$blockScrolling += 1), - t.selection.fromOrientedRange(m), - (t.$blockScrolling -= 1), - t.isFocused() && - !w && - t.renderer.$cursorLayer.setBlinking(!t.getReadOnly()), - (m = null), - (g = null), - (y = 0), - (E = null), - (S = null), - i.removeListener(document, "mousemove", O); - } - function O() { - A == null && - (A = setTimeout(function() { - A != null && h && L(); - }, 20)); - } - function M(e) { - var t = e.types; - return ( - !t || - Array.prototype.some.call(t, function(e) { - return e == "text/plain" || e == "Text"; - }) - ); - } - function _(e) { - var t = ["copy", "copymove", "all", "uninitialized"], - n = ["move", "copymove", "linkmove", "all", "uninitialized"], - r = s.isMac ? e.altKey : e.ctrlKey, - i = "uninitialized"; - try { - i = e.dataTransfer.effectAllowed.toLowerCase(); - } catch (e) {} - var o = "none"; - return ( - r && t.indexOf(i) >= 0 - ? (o = "copy") - : n.indexOf(i) >= 0 - ? (o = "move") - : t.indexOf(i) >= 0 && (o = "copy"), - o - ); - } - var t = e.editor, - n = r.createElement("img"); - (n.src = - "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="), - s.isOpera && - (n.style.cssText = - "width:1px;height:1px;position:fixed;top:0;left:0;z-index:2147483647;opacity:0;"); - var f = [ - "dragWait", - "dragWaitEnd", - "startDrag", - "dragReadyEnd", - "onMouseDrag" - ]; - f.forEach(function(t) { - e[t] = this[t]; - }, this), - t.addEventListener("mousedown", this.onMouseDown.bind(e)); - var c = t.container, - h, - p, - d, - v, - m, - g, - y = 0, - b, - w, - E, - S, - x; - (this.onDragStart = function(e) { - if (this.cancelDrag || !c.draggable) { - var r = this; - return ( - setTimeout(function() { - r.startSelect(), r.captureMouse(e); - }, 0), - e.preventDefault() - ); + function O() { + A == null && + (A = setTimeout(function () { + A != null && h && L(); + }, 20)); } - m = t.getSelectionRange(); - var i = e.dataTransfer; - (i.effectAllowed = t.getReadOnly() ? "copy" : "copyMove"), - s.isOpera && (t.container.appendChild(n), (n.scrollTop = 0)), - i.setDragImage && i.setDragImage(n, 0, 0), - s.isOpera && t.container.removeChild(n), - i.clearData(), - i.setData("Text", t.session.getTextRange()), - (w = !0), - this.setState("drag"); - }), - (this.onDragEnd = function(e) { - (c.draggable = !1), (w = !1), this.setState(null); - if (!t.getReadOnly()) { - var n = e.dataTransfer.dropEffect; - !b && n == "move" && t.session.remove(t.getSelectionRange()), - t.renderer.$cursorLayer.setBlinking(!0); - } - this.editor.unsetStyle("ace_dragging"), - this.editor.renderer.setCursorStyle(""); - }), - (this.onDragEnter = function(e) { - if (t.getReadOnly() || !M(e.dataTransfer)) return; + function M(e) { + var t = e.types; return ( - (p = e.clientX), - (d = e.clientY), - h || k(), - y++, - (e.dataTransfer.dropEffect = b = _(e)), - i.preventDefault(e) + !t || + Array.prototype.some.call(t, function (e) { + return e == "text/plain" || e == "Text"; + }) ); - }), - (this.onDragOver = function(e) { - if (t.getReadOnly() || !M(e.dataTransfer)) return; + } + function _(e) { + var t = ["copy", "copymove", "all", "uninitialized"], + n = ["move", "copymove", "linkmove", "all", "uninitialized"], + r = s.isMac ? e.altKey : e.ctrlKey, + i = "uninitialized"; + try { + i = e.dataTransfer.effectAllowed.toLowerCase(); + } catch (e) {} + var o = "none"; return ( - (p = e.clientX), - (d = e.clientY), - h || (k(), y++), - A !== null && (A = null), - (e.dataTransfer.dropEffect = b = _(e)), - i.preventDefault(e) + r && t.indexOf(i) >= 0 + ? (o = "copy") + : n.indexOf(i) >= 0 + ? (o = "move") + : t.indexOf(i) >= 0 && (o = "copy"), + o ); - }), - (this.onDragLeave = function(e) { - y--; - if (y <= 0 && h) return L(), (b = null), i.preventDefault(e); - }), - (this.onDrop = function(e) { - if (!g) return; - var n = e.dataTransfer; - if (w) - switch (b) { - case "move": - m.contains(g.row, g.column) - ? (m = { start: g, end: g }) - : (m = t.moveText(m, g)); - break; - case "copy": - m = t.moveText(m, g, !0); - } - else { - var r = n.getData("Text"); - (m = { start: g, end: t.session.insert(g, r) }), - t.focus(), - (b = null); + } + var t = e.editor, + n = r.createElement("img"); + ((n.src = + "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="), + s.isOpera && + (n.style.cssText = + "width:1px;height:1px;position:fixed;top:0;left:0;z-index:2147483647;opacity:0;")); + var f = [ + "dragWait", + "dragWaitEnd", + "startDrag", + "dragReadyEnd", + "onMouseDrag" + ]; + (f.forEach(function (t) { + e[t] = this[t]; + }, this), + t.addEventListener("mousedown", this.onMouseDown.bind(e))); + var c = t.container, + h, + p, + d, + v, + m, + g, + y = 0, + b, + w, + E, + S, + x; + ((this.onDragStart = function (e) { + if (this.cancelDrag || !c.draggable) { + var r = this; + return ( + setTimeout(function () { + (r.startSelect(), r.captureMouse(e)); + }, 0), + e.preventDefault() + ); } - return L(), i.preventDefault(e); - }), - i.addListener(c, "dragstart", this.onDragStart.bind(e)), - i.addListener(c, "dragend", this.onDragEnd.bind(e)), - i.addListener(c, "dragenter", this.onDragEnter.bind(e)), - i.addListener(c, "dragover", this.onDragOver.bind(e)), - i.addListener(c, "dragleave", this.onDragLeave.bind(e)), - i.addListener(c, "drop", this.onDrop.bind(e)); - var A = null; - } - function l(e, t, n, r) { - return Math.sqrt(Math.pow(n - e, 2) + Math.pow(r - t, 2)); + m = t.getSelectionRange(); + var i = e.dataTransfer; + ((i.effectAllowed = t.getReadOnly() ? "copy" : "copyMove"), + s.isOpera && (t.container.appendChild(n), (n.scrollTop = 0)), + i.setDragImage && i.setDragImage(n, 0, 0), + s.isOpera && t.container.removeChild(n), + i.clearData(), + i.setData("Text", t.session.getTextRange()), + (w = !0), + this.setState("drag")); + }), + (this.onDragEnd = function (e) { + ((c.draggable = !1), (w = !1), this.setState(null)); + if (!t.getReadOnly()) { + var n = e.dataTransfer.dropEffect; + (!b && n == "move" && t.session.remove(t.getSelectionRange()), + t.renderer.$cursorLayer.setBlinking(!0)); + } + (this.editor.unsetStyle("ace_dragging"), + this.editor.renderer.setCursorStyle("")); + }), + (this.onDragEnter = function (e) { + if (t.getReadOnly() || !M(e.dataTransfer)) return; + return ( + (p = e.clientX), + (d = e.clientY), + h || k(), + y++, + (e.dataTransfer.dropEffect = b = _(e)), + i.preventDefault(e) + ); + }), + (this.onDragOver = function (e) { + if (t.getReadOnly() || !M(e.dataTransfer)) return; + return ( + (p = e.clientX), + (d = e.clientY), + h || (k(), y++), + A !== null && (A = null), + (e.dataTransfer.dropEffect = b = _(e)), + i.preventDefault(e) + ); + }), + (this.onDragLeave = function (e) { + y--; + if (y <= 0 && h) return (L(), (b = null), i.preventDefault(e)); + }), + (this.onDrop = function (e) { + if (!g) return; + var n = e.dataTransfer; + if (w) + switch (b) { + case "move": + m.contains(g.row, g.column) + ? (m = { start: g, end: g }) + : (m = t.moveText(m, g)); + break; + case "copy": + m = t.moveText(m, g, !0); + } + else { + var r = n.getData("Text"); + ((m = { start: g, end: t.session.insert(g, r) }), + t.focus(), + (b = null)); + } + return (L(), i.preventDefault(e)); + }), + i.addListener(c, "dragstart", this.onDragStart.bind(e)), + i.addListener(c, "dragend", this.onDragEnd.bind(e)), + i.addListener(c, "dragenter", this.onDragEnter.bind(e)), + i.addListener(c, "dragover", this.onDragOver.bind(e)), + i.addListener(c, "dragleave", this.onDragLeave.bind(e)), + i.addListener(c, "drop", this.onDrop.bind(e))); + var A = null; + } + function l(e, t, n, r) { + return Math.sqrt(Math.pow(n - e, 2) + Math.pow(r - t, 2)); + } + var r = e("../lib/dom"), + i = e("../lib/event"), + s = e("../lib/useragent"), + o = 200, + u = 200, + a = 5; + ((function () { + ((this.dragWait = function () { + var e = Date.now() - this.mousedownEvent.time; + e > this.editor.getDragDelay() && this.startDrag(); + }), + (this.dragWaitEnd = function () { + var e = this.editor.container; + ((e.draggable = !1), + this.startSelect(this.mousedownEvent.getDocumentPosition()), + this.selectEnd()); + }), + (this.dragReadyEnd = function (e) { + (this.editor.renderer.$cursorLayer.setBlinking( + !this.editor.getReadOnly() + ), + this.editor.unsetStyle("ace_dragging"), + this.editor.renderer.setCursorStyle(""), + this.dragWaitEnd()); + }), + (this.startDrag = function () { + this.cancelDrag = !1; + var e = this.editor, + t = e.container; + ((t.draggable = !0), + e.renderer.$cursorLayer.setBlinking(!1), + e.setStyle("ace_dragging")); + var n = s.isWin ? "default" : "move"; + (e.renderer.setCursorStyle(n), this.setState("dragReady")); + }), + (this.onMouseDrag = function (e) { + var t = this.editor.container; + if (this.state === "dragWait") { + var n = l( + this.mousedownEvent.x, + this.mousedownEvent.y, + this.x, + this.y + ); + n > 0 && + ((t.draggable = !1), + this.startSelect(this.mousedownEvent.getDocumentPosition())); + } + }), + (this.onMouseDown = function (e) { + if (!this.$dragEnabled) return; + this.mousedownEvent = e; + var t = this.editor, + n = e.inSelection(), + r = e.getButton(), + i = e.domEvent.detail || 1; + if (i === 1 && r === 0 && n) { + if ( + e.editor.inMultiSelectMode && + (e.getAccelKey() || e.getShiftKey()) + ) + return; + this.mousedownEvent.time = Date.now(); + var o = e.domEvent.target || e.domEvent.srcElement; + "unselectable" in o && (o.unselectable = "on"); + if (t.getDragDelay()) { + if (s.isWebKit) { + this.cancelDrag = !0; + var u = t.container; + u.draggable = !0; + } + this.setState("dragWait"); + } else this.startDrag(); + (this.captureMouse(e, this.onMouseDrag.bind(this)), + (e.defaultPrevented = !0)); + } + })); + }).call(f.prototype), + (t.DragdropHandler = f)); } - var r = e("../lib/dom"), - i = e("../lib/event"), - s = e("../lib/useragent"), - o = 200, - u = 200, - a = 5; - (function() { - (this.dragWait = function() { - var e = Date.now() - this.mousedownEvent.time; - e > this.editor.getDragDelay() && this.startDrag(); + ), + define( + "ace/lib/net", + ["require", "exports", "module", "ace/lib/dom"], + function (e, t, n) { + "use strict"; + var r = e("./dom"); + ((t.get = function (e, t) { + var n = new XMLHttpRequest(); + (n.open("GET", e, !0), + (n.onreadystatechange = function () { + n.readyState === 4 && t(n.responseText); + }), + n.send(null)); }), - (this.dragWaitEnd = function() { - var e = this.editor.container; - (e.draggable = !1), - this.startSelect(this.mousedownEvent.getDocumentPosition()), - this.selectEnd(); + (t.loadScript = function (e, t) { + var n = r.getDocumentHead(), + i = document.createElement("script"); + ((i.src = e), + n.appendChild(i), + (i.onload = i.onreadystatechange = + function (e, n) { + if ( + n || + !i.readyState || + i.readyState == "loaded" || + i.readyState == "complete" + ) + ((i = i.onload = i.onreadystatechange = null), n || t()); + })); }), - (this.dragReadyEnd = function(e) { - this.editor.renderer.$cursorLayer.setBlinking( - !this.editor.getReadOnly() - ), - this.editor.unsetStyle("ace_dragging"), - this.editor.renderer.setCursorStyle(""), - this.dragWaitEnd(); + (t.qualifyURL = function (e) { + var t = document.createElement("a"); + return ((t.href = e), t.href); + })); + } + ), + define( + "ace/lib/event_emitter", + ["require", "exports", "module"], + function (e, t, n) { + "use strict"; + var r = {}, + i = function () { + this.propagationStopped = !0; + }, + s = function () { + this.defaultPrevented = !0; + }; + ((r._emit = r._dispatchEvent = + function (e, t) { + (this._eventRegistry || (this._eventRegistry = {}), + this._defaultHandlers || (this._defaultHandlers = {})); + var n = this._eventRegistry[e] || [], + r = this._defaultHandlers[e]; + if (!n.length && !r) return; + if (typeof t != "object" || !t) t = {}; + (t.type || (t.type = e), + t.stopPropagation || (t.stopPropagation = i), + t.preventDefault || (t.preventDefault = s), + (n = n.slice())); + for (var o = 0; o < n.length; o++) { + n[o](t, this); + if (t.propagationStopped) break; + } + if (r && !t.defaultPrevented) return r(t, this); }), - (this.startDrag = function() { - this.cancelDrag = !1; - var e = this.editor, - t = e.container; - (t.draggable = !0), - e.renderer.$cursorLayer.setBlinking(!1), - e.setStyle("ace_dragging"); - var n = s.isWin ? "default" : "move"; - e.renderer.setCursorStyle(n), this.setState("dragReady"); + (r._signal = function (e, t) { + var n = (this._eventRegistry || {})[e]; + if (!n) return; + n = n.slice(); + for (var r = 0; r < n.length; r++) n[r](t, this); }), - (this.onMouseDrag = function(e) { - var t = this.editor.container; - if (this.state === "dragWait") { - var n = l( - this.mousedownEvent.x, - this.mousedownEvent.y, - this.x, - this.y + (r.once = function (e, t) { + var n = this; + t && + this.addEventListener(e, function r() { + (n.removeEventListener(e, r), t.apply(null, arguments)); + }); + }), + (r.setDefaultHandler = function (e, t) { + var n = this._defaultHandlers; + n || (n = this._defaultHandlers = { _disabled_: {} }); + if (n[e]) { + var r = n[e], + i = n._disabled_[e]; + (i || (n._disabled_[e] = i = []), i.push(r)); + var s = i.indexOf(t); + s != -1 && i.splice(s, 1); + } + n[e] = t; + }), + (r.removeDefaultHandler = function (e, t) { + var n = this._defaultHandlers; + if (!n) return; + var r = n._disabled_[e]; + if (n[e] == t) { + var i = n[e]; + r && this.setDefaultHandler(e, r.pop()); + } else if (r) { + var s = r.indexOf(t); + s != -1 && r.splice(s, 1); + } + }), + (r.on = r.addEventListener = + function (e, t, n) { + this._eventRegistry = this._eventRegistry || {}; + var r = this._eventRegistry[e]; + return ( + r || (r = this._eventRegistry[e] = []), + r.indexOf(t) == -1 && r[n ? "unshift" : "push"](t), + t ); - n > 0 && - ((t.draggable = !1), - this.startSelect(this.mousedownEvent.getDocumentPosition())); - } + }), + (r.off = + r.removeListener = + r.removeEventListener = + function (e, t) { + this._eventRegistry = this._eventRegistry || {}; + var n = this._eventRegistry[e]; + if (!n) return; + var r = n.indexOf(t); + r !== -1 && n.splice(r, 1); + }), + (r.removeAllListeners = function (e) { + this._eventRegistry && (this._eventRegistry[e] = []); }), - (this.onMouseDown = function(e) { - if (!this.$dragEnabled) return; - this.mousedownEvent = e; - var t = this.editor, - n = e.inSelection(), - r = e.getButton(), - i = e.domEvent.detail || 1; - if (i === 1 && r === 0 && n) { - if ( - e.editor.inMultiSelectMode && - (e.getAccelKey() || e.getShiftKey()) - ) - return; - this.mousedownEvent.time = Date.now(); - var o = e.domEvent.target || e.domEvent.srcElement; - "unselectable" in o && (o.unselectable = "on"); - if (t.getDragDelay()) { - if (s.isWebKit) { - this.cancelDrag = !0; - var u = t.container; - u.draggable = !0; - } - this.setState("dragWait"); - } else this.startDrag(); - this.captureMouse(e, this.onMouseDrag.bind(this)), - (e.defaultPrevented = !0); + (t.EventEmitter = r)); + } + ), + define( + "ace/lib/app_config", + ["require", "exports", "module", "ace/lib/oop", "ace/lib/event_emitter"], + function (e, t, n) { + "no use strict"; + function o(e) { + typeof console != "undefined" && + console.warn && + console.warn.apply(console, arguments); + } + function u(e, t) { + var n = new Error(e); + ((n.data = t), + typeof console == "object" && console.error && console.error(n), + setTimeout(function () { + throw n; + })); + } + var r = e("./oop"), + i = e("./event_emitter").EventEmitter, + s = { + setOptions: function (e) { + Object.keys(e).forEach(function (t) { + this.setOption(t, e[t]); + }, this); + }, + getOptions: function (e) { + var t = {}; + return ( + e + ? Array.isArray(e) || ((t = e), (e = Object.keys(t))) + : (e = Object.keys(this.$options)), + e.forEach(function (e) { + t[e] = this.getOption(e); + }, this), + t + ); + }, + setOption: function (e, t) { + if (this["$" + e] === t) return; + var n = this.$options[e]; + if (!n) return o('misspelled option "' + e + '"'); + if (n.forwardTo) + return this[n.forwardTo] && this[n.forwardTo].setOption(e, t); + (n.handlesSet || (this["$" + e] = t), + n && n.set && n.set.call(this, t)); + }, + getOption: function (e) { + var t = this.$options[e]; + return t + ? t.forwardTo + ? this[t.forwardTo] && this[t.forwardTo].getOption(e) + : t && t.get + ? t.get.call(this) + : this["$" + e] + : o('misspelled option "' + e + '"'); } + }, + a = function () { + this.$defaultOptions = {}; + }; + ((function () { + (r.implement(this, i), + (this.defineOptions = function (e, t, n) { + return ( + e.$options || (this.$defaultOptions[t] = e.$options = {}), + Object.keys(n).forEach(function (t) { + var r = n[t]; + (typeof r == "string" && (r = { forwardTo: r }), + r.name || (r.name = t), + (e.$options[r.name] = r), + "initialValue" in r && (e["$" + r.name] = r.initialValue)); + }), + r.implement(e, s), + this + ); + }), + (this.resetOptions = function (e) { + Object.keys(e.$options).forEach(function (t) { + var n = e.$options[t]; + "value" in n && e.setOption(t, n.value); + }); + }), + (this.setDefaultValue = function (e, t, n) { + var r = this.$defaultOptions[e] || (this.$defaultOptions[e] = {}); + r[t] && + (r.forwardTo + ? this.setDefaultValue(r.forwardTo, t, n) + : (r[t].value = n)); + }), + (this.setDefaultValues = function (e, t) { + Object.keys(t).forEach(function (n) { + this.setDefaultValue(e, n, t[n]); + }, this); + }), + (this.warn = o), + (this.reportError = u)); + }).call(a.prototype), + (t.AppConfig = a)); + } + ), + define( + "ace/config", + [ + "require", + "exports", + "module", + "ace/lib/lang", + "ace/lib/oop", + "ace/lib/net", + "ace/lib/app_config" + ], + function (e, t, n) { + "no use strict"; + function f(r) { + if (!u || !u.document) return; + a.packaged = + r || e.packaged || n.packaged || (u.define && define.packaged); + var i = {}, + s = "", + o = document.currentScript || document._currentScript, + f = (o && o.ownerDocument) || document, + c = f.getElementsByTagName("script"); + for (var h = 0; h < c.length; h++) { + var p = c[h], + d = p.src || p.getAttribute("src"); + if (!d) continue; + var v = p.attributes; + for (var m = 0, g = v.length; m < g; m++) { + var y = v[m]; + y.name.indexOf("data-ace-") === 0 && + (i[l(y.name.replace(/^data-ace-/, ""))] = y.value); + } + var b = d.match(/^(.*)\/ace(\-\w+)?\.js(\?|$)/); + b && (s = b[1]); + } + (s && ((i.base = i.base || s), (i.packaged = !0)), + (i.basePath = i.base), + (i.workerPath = i.workerPath || i.base), + (i.modePath = i.modePath || i.base), + (i.themePath = i.themePath || i.base), + delete i.base); + for (var w in i) typeof i[w] != "undefined" && t.set(w, i[w]); + } + function l(e) { + return e.replace(/-(.)/g, function (e, t) { + return t.toUpperCase(); }); - }.call(f.prototype), - (t.DragdropHandler = f)); - }), - define("ace/lib/net", [ - "require", - "exports", - "module", - "ace/lib/dom" - ], function(e, t, n) { - "use strict"; - var r = e("./dom"); - (t.get = function(e, t) { - var n = new XMLHttpRequest(); - n.open("GET", e, !0), - (n.onreadystatechange = function() { - n.readyState === 4 && t(n.responseText); - }), - n.send(null); - }), - (t.loadScript = function(e, t) { - var n = r.getDocumentHead(), - i = document.createElement("script"); - (i.src = e), - n.appendChild(i), - (i.onload = i.onreadystatechange = function(e, n) { - if ( - n || - !i.readyState || - i.readyState == "loaded" || - i.readyState == "complete" - ) - (i = i.onload = i.onreadystatechange = null), n || t(); - }); - }), - (t.qualifyURL = function(e) { - var t = document.createElement("a"); - return (t.href = e), t.href; - }); - }), - define("ace/lib/event_emitter", ["require", "exports", "module"], function( - e, - t, - n - ) { - "use strict"; - var r = {}, - i = function() { - this.propagationStopped = !0; - }, - s = function() { - this.defaultPrevented = !0; - }; - (r._emit = r._dispatchEvent = function(e, t) { - this._eventRegistry || (this._eventRegistry = {}), - this._defaultHandlers || (this._defaultHandlers = {}); - var n = this._eventRegistry[e] || [], - r = this._defaultHandlers[e]; - if (!n.length && !r) return; - if (typeof t != "object" || !t) t = {}; - t.type || (t.type = e), - t.stopPropagation || (t.stopPropagation = i), - t.preventDefault || (t.preventDefault = s), - (n = n.slice()); - for (var o = 0; o < n.length; o++) { - n[o](t, this); - if (t.propagationStopped) break; } - if (r && !t.defaultPrevented) return r(t, this); - }), - (r._signal = function(e, t) { - var n = (this._eventRegistry || {})[e]; - if (!n) return; - n = n.slice(); - for (var r = 0; r < n.length; r++) n[r](t, this); - }), - (r.once = function(e, t) { - var n = this; - t && - this.addEventListener(e, function r() { - n.removeEventListener(e, r), t.apply(null, arguments); - }); - }), - (r.setDefaultHandler = function(e, t) { - var n = this._defaultHandlers; - n || (n = this._defaultHandlers = { _disabled_: {} }); - if (n[e]) { - var r = n[e], - i = n._disabled_[e]; - i || (n._disabled_[e] = i = []), i.push(r); - var s = i.indexOf(t); - s != -1 && i.splice(s, 1); - } - n[e] = t; - }), - (r.removeDefaultHandler = function(e, t) { - var n = this._defaultHandlers; - if (!n) return; - var r = n._disabled_[e]; - if (n[e] == t) { - var i = n[e]; - r && this.setDefaultHandler(e, r.pop()); - } else if (r) { - var s = r.indexOf(t); - s != -1 && r.splice(s, 1); - } - }), - (r.on = r.addEventListener = function(e, t, n) { - this._eventRegistry = this._eventRegistry || {}; - var r = this._eventRegistry[e]; - return ( - r || (r = this._eventRegistry[e] = []), - r.indexOf(t) == -1 && r[n ? "unshift" : "push"](t), - t - ); - }), - (r.off = r.removeListener = r.removeEventListener = function(e, t) { - this._eventRegistry = this._eventRegistry || {}; - var n = this._eventRegistry[e]; - if (!n) return; - var r = n.indexOf(t); - r !== -1 && n.splice(r, 1); - }), - (r.removeAllListeners = function(e) { - this._eventRegistry && (this._eventRegistry[e] = []); + var r = e("./lib/lang"), + i = e("./lib/oop"), + s = e("./lib/net"), + o = e("./lib/app_config").AppConfig; + n.exports = t = new o(); + var u = (function () { + return this || (typeof window != "undefined" && window); + })(), + a = { + packaged: !1, + workerPath: null, + modePath: null, + themePath: null, + basePath: "", + suffix: ".js", + $moduleUrls: {} + }; + ((t.get = function (e) { + if (!a.hasOwnProperty(e)) throw new Error("Unknown config key: " + e); + return a[e]; }), - (t.EventEmitter = r); - }), - define("ace/lib/app_config", [ - "require", - "exports", - "module", - "ace/lib/oop", - "ace/lib/event_emitter" - ], function(e, t, n) { - "no use strict"; - function o(e) { - typeof console != "undefined" && - console.warn && - console.warn.apply(console, arguments); - } - function u(e, t) { - var n = new Error(e); - (n.data = t), - typeof console == "object" && console.error && console.error(n), - setTimeout(function() { - throw n; - }); - } - var r = e("./oop"), - i = e("./event_emitter").EventEmitter, - s = { - setOptions: function(e) { - Object.keys(e).forEach(function(t) { - this.setOption(t, e[t]); - }, this); - }, - getOptions: function(e) { - var t = {}; - return ( - e - ? Array.isArray(e) || ((t = e), (e = Object.keys(t))) - : (e = Object.keys(this.$options)), - e.forEach(function(e) { - t[e] = this.getOption(e); - }, this), - t - ); - }, - setOption: function(e, t) { - if (this["$" + e] === t) return; - var n = this.$options[e]; - if (!n) return o('misspelled option "' + e + '"'); - if (n.forwardTo) - return this[n.forwardTo] && this[n.forwardTo].setOption(e, t); - n.handlesSet || (this["$" + e] = t), - n && n.set && n.set.call(this, t); - }, - getOption: function(e) { - var t = this.$options[e]; - return t - ? t.forwardTo - ? this[t.forwardTo] && this[t.forwardTo].getOption(e) - : t && t.get - ? t.get.call(this) - : this["$" + e] - : o('misspelled option "' + e + '"'); - } - }, - a = function() { - this.$defaultOptions = {}; - }; - (function() { - r.implement(this, i), - (this.defineOptions = function(e, t, n) { + (t.set = function (e, t) { + if (!a.hasOwnProperty(e)) throw new Error("Unknown config key: " + e); + a[e] = t; + }), + (t.all = function () { + return r.copyObject(a); + }), + (t.moduleUrl = function (e, t) { + if (a.$moduleUrls[e]) return a.$moduleUrls[e]; + var n = e.split("/"); + t = t || n[n.length - 2] || ""; + var r = t == "snippets" ? "/" : "-", + i = n[n.length - 1]; + if (t == "worker" && r == "-") { + var s = new RegExp("^" + t + "[\\-_]|[\\-_]" + t + "$", "g"); + i = i.replace(s, ""); + } + (!i || i == t) && n.length > 1 && (i = n[n.length - 2]); + var o = a[t + "Path"]; return ( - e.$options || (this.$defaultOptions[t] = e.$options = {}), - Object.keys(n).forEach(function(t) { - var r = n[t]; - typeof r == "string" && (r = { forwardTo: r }), - r.name || (r.name = t), - (e.$options[r.name] = r), - "initialValue" in r && (e["$" + r.name] = r.initialValue); - }), - r.implement(e, s), - this + o == null ? (o = a.basePath) : r == "/" && (t = r = ""), + o && o.slice(-1) != "/" && (o += "/"), + o + t + r + i + this.get("suffix") ); }), - (this.resetOptions = function(e) { - Object.keys(e.$options).forEach(function(t) { - var n = e.$options[t]; - "value" in n && e.setOption(t, n.value); - }); + (t.setModuleUrl = function (e, t) { + return (a.$moduleUrls[e] = t); }), - (this.setDefaultValue = function(e, t, n) { - var r = this.$defaultOptions[e] || (this.$defaultOptions[e] = {}); - r[t] && - (r.forwardTo - ? this.setDefaultValue(r.forwardTo, t, n) - : (r[t].value = n)); - }), - (this.setDefaultValues = function(e, t) { - Object.keys(t).forEach(function(n) { - this.setDefaultValue(e, n, t[n]); - }, this); + (t.$loading = {}), + (t.loadModule = function (n, r) { + var i, o; + Array.isArray(n) && ((o = n[0]), (n = n[1])); + try { + i = e(n); + } catch (u) {} + if (i && !t.$loading[n]) return r && r(i); + (t.$loading[n] || (t.$loading[n] = []), t.$loading[n].push(r)); + if (t.$loading[n].length > 1) return; + var a = function () { + e([n], function (e) { + t._emit("load.module", { name: n, module: e }); + var r = t.$loading[n]; + ((t.$loading[n] = null), + r.forEach(function (t) { + t && t(e); + })); + }); + }; + if (!t.get("packaged")) return a(); + s.loadScript(t.moduleUrl(n, o), a); }), - (this.warn = o), - (this.reportError = u); - }.call(a.prototype), - (t.AppConfig = a)); - }), - define("ace/config", [ - "require", - "exports", - "module", - "ace/lib/lang", - "ace/lib/oop", - "ace/lib/net", - "ace/lib/app_config" - ], function(e, t, n) { - "no use strict"; - function f(r) { - if (!u || !u.document) return; - a.packaged = - r || e.packaged || n.packaged || (u.define && define.packaged); - var i = {}, - s = "", - o = document.currentScript || document._currentScript, - f = (o && o.ownerDocument) || document, - c = f.getElementsByTagName("script"); - for (var h = 0; h < c.length; h++) { - var p = c[h], - d = p.src || p.getAttribute("src"); - if (!d) continue; - var v = p.attributes; - for (var m = 0, g = v.length; m < g; m++) { - var y = v[m]; - y.name.indexOf("data-ace-") === 0 && - (i[l(y.name.replace(/^data-ace-/, ""))] = y.value); - } - var b = d.match(/^(.*)\/ace(\-\w+)?\.js(\?|$)/); - b && (s = b[1]); - } - s && ((i.base = i.base || s), (i.packaged = !0)), - (i.basePath = i.base), - (i.workerPath = i.workerPath || i.base), - (i.modePath = i.modePath || i.base), - (i.themePath = i.themePath || i.base), - delete i.base; - for (var w in i) typeof i[w] != "undefined" && t.set(w, i[w]); - } - function l(e) { - return e.replace(/-(.)/g, function(e, t) { - return t.toUpperCase(); - }); + (t.init = f)); } - var r = e("./lib/lang"), - i = e("./lib/oop"), - s = e("./lib/net"), - o = e("./lib/app_config").AppConfig; - n.exports = t = new o(); - var u = (function() { - return this || (typeof window != "undefined" && window); - })(), - a = { - packaged: !1, - workerPath: null, - modePath: null, - themePath: null, - basePath: "", - suffix: ".js", - $moduleUrls: {} - }; - (t.get = function(e) { - if (!a.hasOwnProperty(e)) throw new Error("Unknown config key: " + e); - return a[e]; - }), - (t.set = function(e, t) { - if (!a.hasOwnProperty(e)) throw new Error("Unknown config key: " + e); - a[e] = t; - }), - (t.all = function() { - return r.copyObject(a); - }), - (t.moduleUrl = function(e, t) { - if (a.$moduleUrls[e]) return a.$moduleUrls[e]; - var n = e.split("/"); - t = t || n[n.length - 2] || ""; - var r = t == "snippets" ? "/" : "-", - i = n[n.length - 1]; - if (t == "worker" && r == "-") { - var s = new RegExp("^" + t + "[\\-_]|[\\-_]" + t + "$", "g"); - i = i.replace(s, ""); - } - (!i || i == t) && n.length > 1 && (i = n[n.length - 2]); - var o = a[t + "Path"]; - return ( - o == null ? (o = a.basePath) : r == "/" && (t = r = ""), - o && o.slice(-1) != "/" && (o += "/"), - o + t + r + i + this.get("suffix") - ); - }), - (t.setModuleUrl = function(e, t) { - return (a.$moduleUrls[e] = t); - }), - (t.$loading = {}), - (t.loadModule = function(n, r) { - var i, o; - Array.isArray(n) && ((o = n[0]), (n = n[1])); - try { - i = e(n); - } catch (u) {} - if (i && !t.$loading[n]) return r && r(i); - t.$loading[n] || (t.$loading[n] = []), t.$loading[n].push(r); - if (t.$loading[n].length > 1) return; - var a = function() { - e([n], function(e) { - t._emit("load.module", { name: n, module: e }); - var r = t.$loading[n]; - (t.$loading[n] = null), - r.forEach(function(t) { - t && t(e); - }); - }); - }; - if (!t.get("packaged")) return a(); - s.loadScript(t.moduleUrl(n, o), a); - }), - (t.init = f); - }), - define("ace/mouse/mouse_handler", [ - "require", - "exports", - "module", - "ace/lib/event", - "ace/lib/useragent", - "ace/mouse/default_handlers", - "ace/mouse/default_gutter_handler", - "ace/mouse/mouse_event", - "ace/mouse/dragdrop_handler", - "ace/config" - ], function(e, t, n) { - "use strict"; - var r = e("../lib/event"), - i = e("../lib/useragent"), - s = e("./default_handlers").DefaultHandlers, - o = e("./default_gutter_handler").GutterHandler, - u = e("./mouse_event").MouseEvent, - a = e("./dragdrop_handler").DragdropHandler, - f = e("../config"), - l = function(e) { - var t = this; - (this.editor = e), new s(this), new o(this), new a(this); - var n = function(t) { - var n = - !document.hasFocus || - !document.hasFocus() || - (!e.isFocused() && - document.activeElement == - (e.textInput && e.textInput.getElement())); - n && window.focus(), e.focus(); - }, - u = e.renderer.getMouseEventTarget(); - r.addListener(u, "click", this.onMouseEvent.bind(this, "click")), - r.addListener( - u, - "mousemove", - this.onMouseMove.bind(this, "mousemove") - ), - r.addMultiMouseDownListener( - [ + ), + define( + "ace/mouse/mouse_handler", + [ + "require", + "exports", + "module", + "ace/lib/event", + "ace/lib/useragent", + "ace/mouse/default_handlers", + "ace/mouse/default_gutter_handler", + "ace/mouse/mouse_event", + "ace/mouse/dragdrop_handler", + "ace/config" + ], + function (e, t, n) { + "use strict"; + var r = e("../lib/event"), + i = e("../lib/useragent"), + s = e("./default_handlers").DefaultHandlers, + o = e("./default_gutter_handler").GutterHandler, + u = e("./mouse_event").MouseEvent, + a = e("./dragdrop_handler").DragdropHandler, + f = e("../config"), + l = function (e) { + var t = this; + ((this.editor = e), new s(this), new o(this), new a(this)); + var n = function (t) { + var n = + !document.hasFocus || + !document.hasFocus() || + (!e.isFocused() && + document.activeElement == + (e.textInput && e.textInput.getElement())); + (n && window.focus(), e.focus()); + }, + u = e.renderer.getMouseEventTarget(); + (r.addListener(u, "click", this.onMouseEvent.bind(this, "click")), + r.addListener( u, - e.renderer.scrollBarV && e.renderer.scrollBarV.inner, - e.renderer.scrollBarH && e.renderer.scrollBarH.inner, - e.textInput && e.textInput.getElement() - ].filter(Boolean), - [400, 300, 250], - this, - "onMouseEvent" + "mousemove", + this.onMouseMove.bind(this, "mousemove") + ), + r.addMultiMouseDownListener( + [ + u, + e.renderer.scrollBarV && e.renderer.scrollBarV.inner, + e.renderer.scrollBarH && e.renderer.scrollBarH.inner, + e.textInput && e.textInput.getElement() + ].filter(Boolean), + [400, 300, 250], + this, + "onMouseEvent" + ), + r.addMouseWheelListener( + e.container, + this.onMouseWheel.bind(this, "mousewheel") + ), + r.addTouchMoveListener( + e.container, + this.onTouchMove.bind(this, "touchmove") + )); + var f = e.renderer.$gutter; + (r.addListener( + f, + "mousedown", + this.onMouseEvent.bind(this, "guttermousedown") ), - r.addMouseWheelListener( - e.container, - this.onMouseWheel.bind(this, "mousewheel") - ), - r.addTouchMoveListener( - e.container, - this.onTouchMove.bind(this, "touchmove") - ); - var f = e.renderer.$gutter; - r.addListener( - f, - "mousedown", - this.onMouseEvent.bind(this, "guttermousedown") - ), - r.addListener( - f, - "click", - this.onMouseEvent.bind(this, "gutterclick") - ), - r.addListener( - f, - "dblclick", - this.onMouseEvent.bind(this, "gutterdblclick") - ), - r.addListener( - f, - "mousemove", - this.onMouseEvent.bind(this, "guttermousemove") - ), - r.addListener(u, "mousedown", n), - r.addListener(f, "mousedown", n), - e.on("mousemove", function(n) { - if (t.state || t.$dragDelay || !t.$dragEnabled) return; - var r = e.renderer.screenToTextCoordinates(n.x, n.y), - i = e.session.selection.getRange(), - s = e.renderer; - !i.isEmpty() && i.insideStart(r.row, r.column) - ? s.setCursorStyle("default") - : s.setCursorStyle(""); - }); - }; - (function() { - (this.onMouseEvent = function(e, t) { - this.editor._emit(e, new u(t, this.editor)); - }), - (this.onMouseMove = function(e, t) { - var n = - this.editor._eventRegistry && this.editor._eventRegistry.mousemove; - if (!n || !n.length) return; + r.addListener( + f, + "click", + this.onMouseEvent.bind(this, "gutterclick") + ), + r.addListener( + f, + "dblclick", + this.onMouseEvent.bind(this, "gutterdblclick") + ), + r.addListener( + f, + "mousemove", + this.onMouseEvent.bind(this, "guttermousemove") + ), + r.addListener(u, "mousedown", n), + r.addListener(f, "mousedown", n), + e.on("mousemove", function (n) { + if (t.state || t.$dragDelay || !t.$dragEnabled) return; + var r = e.renderer.screenToTextCoordinates(n.x, n.y), + i = e.session.selection.getRange(), + s = e.renderer; + !i.isEmpty() && i.insideStart(r.row, r.column) + ? s.setCursorStyle("default") + : s.setCursorStyle(""); + })); + }; + ((function () { + ((this.onMouseEvent = function (e, t) { this.editor._emit(e, new u(t, this.editor)); }), - (this.onMouseWheel = function(e, t) { - var n = new u(t, this.editor); - (n.speed = this.$scrollSpeed * 2), - (n.wheelX = t.wheelX), - (n.wheelY = t.wheelY), - this.editor._emit(e, n); - }), - (this.onTouchMove = function(e, t) { - var n = new u(t, this.editor); - (n.speed = 1), - (n.wheelX = t.wheelX), - (n.wheelY = t.wheelY), - this.editor._emit(e, n); - }), - (this.setState = function(e) { - this.state = e; - }), - (this.captureMouse = function(e, t) { - (this.x = e.x), (this.y = e.y), (this.isMousePressed = !0); - var n = this.editor.renderer; - n.$keepTextAreaAtCursor && (n.$keepTextAreaAtCursor = null); - var s = this, - o = function(e) { - if (!e) return; - if (i.isWebKit && !e.which && s.releaseMouse) - return s.releaseMouse(); - (s.x = e.clientX), - (s.y = e.clientY), - t && t(e), - (s.mouseEvent = new u(e, s.editor)), - (s.$mouseMoved = !0); - }, - a = function(e) { - clearInterval(l), - f(), - s[s.state + "End"] && s[s.state + "End"](e), - (s.state = ""), - n.$keepTextAreaAtCursor == null && - ((n.$keepTextAreaAtCursor = !0), n.$moveTextAreaToCursor()), - (s.isMousePressed = !1), - (s.$onCaptureMouseMove = s.releaseMouse = null), - e && s.onMouseEvent("mouseup", e); - }, - f = function() { - s[s.state] && s[s.state](), (s.$mouseMoved = !1); - }; - (s.$onCaptureMouseMove = o), - (s.releaseMouse = r.capture(this.editor.container, o, a)); - var l = setInterval(f, 20); - }), - (this.releaseMouse = null), - (this.cancelContextMenu = function() { - var e = function(t) { - if (t && t.domEvent && t.domEvent.type != "contextmenu") return; - this.editor.off("nativecontextmenu", e), - t && t.domEvent && r.stopEvent(t.domEvent); - }.bind(this); - setTimeout(e, 10), this.editor.on("nativecontextmenu", e); - }); - }.call(l.prototype), - f.defineOptions(l.prototype, "mouseHandler", { - scrollSpeed: { initialValue: 2 }, - dragDelay: { initialValue: i.isMac ? 150 : 0 }, - dragEnabled: { initialValue: !0 }, - focusTimout: { initialValue: 0 }, - tooltipFollowsMouse: { initialValue: !0 } - }), - (t.MouseHandler = l)); - }), - define("ace/mouse/fold_handler", ["require", "exports", "module"], function( - e, - t, - n - ) { - "use strict"; - function r(e) { - e.on("click", function(t) { - var n = t.getDocumentPosition(), - r = e.session, - i = r.getFoldAt(n.row, n.column, 1); - i && (t.getAccelKey() ? r.removeFold(i) : r.expandFold(i), t.stop()); - }), - e.on("gutterclick", function(t) { - var n = e.renderer.$gutterLayer.getRegion(t); - if (n == "foldWidgets") { - var r = t.getDocumentPosition().row, - i = e.session; - i.foldWidgets && - i.foldWidgets[r] && - e.session.onFoldWidgetClick(r, t), - e.isFocused() || e.focus(), + (this.onMouseMove = function (e, t) { + var n = + this.editor._eventRegistry && + this.editor._eventRegistry.mousemove; + if (!n || !n.length) return; + this.editor._emit(e, new u(t, this.editor)); + }), + (this.onMouseWheel = function (e, t) { + var n = new u(t, this.editor); + ((n.speed = this.$scrollSpeed * 2), + (n.wheelX = t.wheelX), + (n.wheelY = t.wheelY), + this.editor._emit(e, n)); + }), + (this.onTouchMove = function (e, t) { + var n = new u(t, this.editor); + ((n.speed = 1), + (n.wheelX = t.wheelX), + (n.wheelY = t.wheelY), + this.editor._emit(e, n)); + }), + (this.setState = function (e) { + this.state = e; + }), + (this.captureMouse = function (e, t) { + ((this.x = e.x), (this.y = e.y), (this.isMousePressed = !0)); + var n = this.editor.renderer; + n.$keepTextAreaAtCursor && (n.$keepTextAreaAtCursor = null); + var s = this, + o = function (e) { + if (!e) return; + if (i.isWebKit && !e.which && s.releaseMouse) + return s.releaseMouse(); + ((s.x = e.clientX), + (s.y = e.clientY), + t && t(e), + (s.mouseEvent = new u(e, s.editor)), + (s.$mouseMoved = !0)); + }, + a = function (e) { + (clearInterval(l), + f(), + s[s.state + "End"] && s[s.state + "End"](e), + (s.state = ""), + n.$keepTextAreaAtCursor == null && + ((n.$keepTextAreaAtCursor = !0), n.$moveTextAreaToCursor()), + (s.isMousePressed = !1), + (s.$onCaptureMouseMove = s.releaseMouse = null), + e && s.onMouseEvent("mouseup", e)); + }, + f = function () { + (s[s.state] && s[s.state](), (s.$mouseMoved = !1)); + }; + ((s.$onCaptureMouseMove = o), + (s.releaseMouse = r.capture(this.editor.container, o, a))); + var l = setInterval(f, 20); + }), + (this.releaseMouse = null), + (this.cancelContextMenu = function () { + var e = function (t) { + if (t && t.domEvent && t.domEvent.type != "contextmenu") return; + (this.editor.off("nativecontextmenu", e), + t && t.domEvent && r.stopEvent(t.domEvent)); + }.bind(this); + (setTimeout(e, 10), this.editor.on("nativecontextmenu", e)); + })); + }).call(l.prototype), + f.defineOptions(l.prototype, "mouseHandler", { + scrollSpeed: { initialValue: 2 }, + dragDelay: { initialValue: i.isMac ? 150 : 0 }, + dragEnabled: { initialValue: !0 }, + focusTimout: { initialValue: 0 }, + tooltipFollowsMouse: { initialValue: !0 } + }), + (t.MouseHandler = l)); + } + ), + define( + "ace/mouse/fold_handler", + ["require", "exports", "module"], + function (e, t, n) { + "use strict"; + function r(e) { + (e.on("click", function (t) { + var n = t.getDocumentPosition(), + r = e.session, + i = r.getFoldAt(n.row, n.column, 1); + i && (t.getAccelKey() ? r.removeFold(i) : r.expandFold(i), t.stop()); + }), + e.on("gutterclick", function (t) { + var n = e.renderer.$gutterLayer.getRegion(t); + if (n == "foldWidgets") { + var r = t.getDocumentPosition().row, + i = e.session; + (i.foldWidgets && + i.foldWidgets[r] && + e.session.onFoldWidgetClick(r, t), + e.isFocused() || e.focus(), + t.stop()); + } + }), + e.on("gutterdblclick", function (t) { + var n = e.renderer.$gutterLayer.getRegion(t); + if (n == "foldWidgets") { + var r = t.getDocumentPosition().row, + i = e.session, + s = i.getParentFoldRangeData(r, !0), + o = s.range || s.firstRange; + if (o) { + r = o.start.row; + var u = i.getFoldAt(r, i.getLine(r).length, 1); + u + ? i.removeFold(u) + : (i.addFold("...", o), + e.renderer.scrollCursorIntoView({ + row: o.start.row, + column: 0 + })); + } t.stop(); - } - }), - e.on("gutterdblclick", function(t) { - var n = e.renderer.$gutterLayer.getRegion(t); - if (n == "foldWidgets") { - var r = t.getDocumentPosition().row, - i = e.session, - s = i.getParentFoldRangeData(r, !0), - o = s.range || s.firstRange; - if (o) { - r = o.start.row; - var u = i.getFoldAt(r, i.getLine(r).length, 1); - u - ? i.removeFold(u) - : (i.addFold("...", o), - e.renderer.scrollCursorIntoView({ - row: o.start.row, - column: 0 - })); } - t.stop(); - } - }); + })); + } + t.FoldHandler = r; } - t.FoldHandler = r; - }), - define("ace/keyboard/keybinding", [ - "require", - "exports", - "module", - "ace/lib/keys", - "ace/lib/event" - ], function(e, t, n) { - "use strict"; - var r = e("../lib/keys"), - i = e("../lib/event"), - s = function(e) { - (this.$editor = e), - (this.$data = { editor: e }), - (this.$handlers = []), - this.setDefaultHandler(e.commands); - }; - (function() { - (this.setDefaultHandler = function(e) { - this.removeKeyboardHandler(this.$defaultHandler), - (this.$defaultHandler = e), - this.addKeyboardHandler(e, 0); - }), - (this.setKeyboardHandler = function(e) { - var t = this.$handlers; - if (t[t.length - 1] == e) return; - while (t[t.length - 1] && t[t.length - 1] != this.$defaultHandler) - this.removeKeyboardHandler(t[t.length - 1]); - this.addKeyboardHandler(e, 1); - }), - (this.addKeyboardHandler = function(e, t) { - if (!e) return; - typeof e == "function" && !e.handleKeyboard && (e.handleKeyboard = e); - var n = this.$handlers.indexOf(e); - n != -1 && this.$handlers.splice(n, 1), - t == undefined - ? this.$handlers.push(e) - : this.$handlers.splice(t, 0, e), - n == -1 && e.attach && e.attach(this.$editor); - }), - (this.removeKeyboardHandler = function(e) { - var t = this.$handlers.indexOf(e); - return t == -1 - ? !1 - : (this.$handlers.splice(t, 1), - e.detach && e.detach(this.$editor), - !0); - }), - (this.getKeyboardHandler = function() { - return this.$handlers[this.$handlers.length - 1]; - }), - (this.getStatusText = function() { - var e = this.$data, - t = e.editor; - return this.$handlers - .map(function(n) { - return (n.getStatusText && n.getStatusText(t, e)) || ""; - }) - .filter(Boolean) - .join(" "); - }), - (this.$callKeyboardHandlers = function(e, t, n, r) { - var s, - o = !1, - u = this.$editor.commands; - for (var a = this.$handlers.length; a--; ) { - s = this.$handlers[a].handleKeyboard(this.$data, e, t, n, r); - if (!s || !s.command) continue; - s.command == "null" - ? (o = !0) - : (o = u.exec(s.command, this.$editor, s.args, r)), + ), + define( + "ace/keyboard/keybinding", + ["require", "exports", "module", "ace/lib/keys", "ace/lib/event"], + function (e, t, n) { + "use strict"; + var r = e("../lib/keys"), + i = e("../lib/event"), + s = function (e) { + ((this.$editor = e), + (this.$data = { editor: e }), + (this.$handlers = []), + this.setDefaultHandler(e.commands)); + }; + ((function () { + ((this.setDefaultHandler = function (e) { + (this.removeKeyboardHandler(this.$defaultHandler), + (this.$defaultHandler = e), + this.addKeyboardHandler(e, 0)); + }), + (this.setKeyboardHandler = function (e) { + var t = this.$handlers; + if (t[t.length - 1] == e) return; + while (t[t.length - 1] && t[t.length - 1] != this.$defaultHandler) + this.removeKeyboardHandler(t[t.length - 1]); + this.addKeyboardHandler(e, 1); + }), + (this.addKeyboardHandler = function (e, t) { + if (!e) return; + typeof e == "function" && + !e.handleKeyboard && + (e.handleKeyboard = e); + var n = this.$handlers.indexOf(e); + (n != -1 && this.$handlers.splice(n, 1), + t == undefined + ? this.$handlers.push(e) + : this.$handlers.splice(t, 0, e), + n == -1 && e.attach && e.attach(this.$editor)); + }), + (this.removeKeyboardHandler = function (e) { + var t = this.$handlers.indexOf(e); + return t == -1 + ? !1 + : (this.$handlers.splice(t, 1), + e.detach && e.detach(this.$editor), + !0); + }), + (this.getKeyboardHandler = function () { + return this.$handlers[this.$handlers.length - 1]; + }), + (this.getStatusText = function () { + var e = this.$data, + t = e.editor; + return this.$handlers + .map(function (n) { + return (n.getStatusText && n.getStatusText(t, e)) || ""; + }) + .filter(Boolean) + .join(" "); + }), + (this.$callKeyboardHandlers = function (e, t, n, r) { + var s, + o = !1, + u = this.$editor.commands; + for (var a = this.$handlers.length; a--;) { + s = this.$handlers[a].handleKeyboard(this.$data, e, t, n, r); + if (!s || !s.command) continue; + (s.command == "null" + ? (o = !0) + : (o = u.exec(s.command, this.$editor, s.args, r)), + o && + r && + e != -1 && + s.passEvent != 1 && + s.command.passEvent != 1 && + i.stopEvent(r)); + if (o) break; + } + return ( + !o && + e == -1 && + ((s = { command: "insertstring" }), + (o = u.exec("insertstring", this.$editor, t))), o && - r && - e != -1 && - s.passEvent != 1 && - s.command.passEvent != 1 && - i.stopEvent(r); - if (o) break; - } - return ( - !o && - e == -1 && - ((s = { command: "insertstring" }), - (o = u.exec("insertstring", this.$editor, t))), - o && - this.$editor._signal && - this.$editor._signal("keyboardActivity", s), - o - ); - }), - (this.onCommandKey = function(e, t, n) { - var i = r.keyCodeToString(n); - this.$callKeyboardHandlers(t, i, n, e); - }), - (this.onTextInput = function(e) { - this.$callKeyboardHandlers(-1, e); - }); - }.call(s.prototype), - (t.KeyBinding = s)); - }), - define("ace/range", ["require", "exports", "module"], function(e, t, n) { + this.$editor._signal && + this.$editor._signal("keyboardActivity", s), + o + ); + }), + (this.onCommandKey = function (e, t, n) { + var i = r.keyCodeToString(n); + this.$callKeyboardHandlers(t, i, n, e); + }), + (this.onTextInput = function (e) { + this.$callKeyboardHandlers(-1, e); + })); + }).call(s.prototype), + (t.KeyBinding = s)); + } + ), + define("ace/range", ["require", "exports", "module"], function (e, t, n) { "use strict"; - var r = function(e, t) { + var r = function (e, t) { return e.row - t.row || e.column - t.column; }, - i = function(e, t, n, r) { - (this.start = { row: e, column: t }), - (this.end = { row: n, column: r }); + i = function (e, t, n, r) { + ((this.start = { row: e, column: t }), + (this.end = { row: n, column: r })); }; - (function() { - (this.isEqual = function(e) { + ((function () { + ((this.isEqual = function (e) { return ( this.start.row === e.start.row && this.end.row === e.end.row && @@ -3165,7 +3224,7 @@ this.end.column === e.end.column ); }), - (this.toString = function() { + (this.toString = function () { return ( "Range: [" + this.start.row + @@ -3178,10 +3237,10 @@ "]" ); }), - (this.contains = function(e, t) { + (this.contains = function (e, t) { return this.compare(e, t) == 0; }), - (this.compareRange = function(e) { + (this.compareRange = function (e) { var t, n = e.end, r = e.start; @@ -3191,117 +3250,117 @@ ? ((t = this.compare(r.row, r.column)), t == 1 ? 2 : t == 0 ? 1 : 0) : t == -1 - ? -2 - : ((t = this.compare(r.row, r.column)), - t == -1 ? -1 : t == 1 ? 42 : 0) + ? -2 + : ((t = this.compare(r.row, r.column)), + t == -1 ? -1 : t == 1 ? 42 : 0) ); }), - (this.comparePoint = function(e) { + (this.comparePoint = function (e) { return this.compare(e.row, e.column); }), - (this.containsRange = function(e) { + (this.containsRange = function (e) { return ( this.comparePoint(e.start) == 0 && this.comparePoint(e.end) == 0 ); }), - (this.intersects = function(e) { + (this.intersects = function (e) { var t = this.compareRange(e); return t == -1 || t == 0 || t == 1; }), - (this.isEnd = function(e, t) { + (this.isEnd = function (e, t) { return this.end.row == e && this.end.column == t; }), - (this.isStart = function(e, t) { + (this.isStart = function (e, t) { return this.start.row == e && this.start.column == t; }), - (this.setStart = function(e, t) { + (this.setStart = function (e, t) { typeof e == "object" ? ((this.start.column = e.column), (this.start.row = e.row)) : ((this.start.row = e), (this.start.column = t)); }), - (this.setEnd = function(e, t) { + (this.setEnd = function (e, t) { typeof e == "object" ? ((this.end.column = e.column), (this.end.row = e.row)) : ((this.end.row = e), (this.end.column = t)); }), - (this.inside = function(e, t) { + (this.inside = function (e, t) { return this.compare(e, t) == 0 ? this.isEnd(e, t) || this.isStart(e, t) ? !1 : !0 : !1; }), - (this.insideStart = function(e, t) { + (this.insideStart = function (e, t) { return this.compare(e, t) == 0 ? (this.isEnd(e, t) ? !1 : !0) : !1; }), - (this.insideEnd = function(e, t) { + (this.insideEnd = function (e, t) { return this.compare(e, t) == 0 ? (this.isStart(e, t) ? !1 : !0) : !1; }), - (this.compare = function(e, t) { + (this.compare = function (e, t) { return !this.isMultiLine() && e === this.start.row ? t < this.start.column ? -1 : t > this.end.column - ? 1 - : 0 + ? 1 + : 0 : e < this.start.row - ? -1 - : e > this.end.row - ? 1 - : this.start.row === e - ? t >= this.start.column - ? 0 - : -1 - : this.end.row === e - ? t <= this.end.column - ? 0 - : 1 - : 0; - }), - (this.compareStart = function(e, t) { + ? -1 + : e > this.end.row + ? 1 + : this.start.row === e + ? t >= this.start.column + ? 0 + : -1 + : this.end.row === e + ? t <= this.end.column + ? 0 + : 1 + : 0; + }), + (this.compareStart = function (e, t) { return this.start.row == e && this.start.column == t ? -1 : this.compare(e, t); }), - (this.compareEnd = function(e, t) { + (this.compareEnd = function (e, t) { return this.end.row == e && this.end.column == t ? 1 : this.compare(e, t); }), - (this.compareInside = function(e, t) { + (this.compareInside = function (e, t) { return this.end.row == e && this.end.column == t ? 1 : this.start.row == e && this.start.column == t - ? -1 - : this.compare(e, t); + ? -1 + : this.compare(e, t); }), - (this.clipRows = function(e, t) { + (this.clipRows = function (e, t) { if (this.end.row > t) var n = { row: t + 1, column: 0 }; else if (this.end.row < e) var n = { row: e, column: 0 }; if (this.start.row > t) var r = { row: t + 1, column: 0 }; else if (this.start.row < e) var r = { row: e, column: 0 }; return i.fromPoints(r || this.start, n || this.end); }), - (this.extend = function(e, t) { + (this.extend = function (e, t) { var n = this.compare(e, t); if (n == 0) return this; if (n == -1) var r = { row: e, column: t }; else var s = { row: e, column: t }; return i.fromPoints(r || this.start, s || this.end); }), - (this.isEmpty = function() { + (this.isEmpty = function () { return ( this.start.row === this.end.row && this.start.column === this.end.column ); }), - (this.isMultiLine = function() { + (this.isMultiLine = function () { return this.start.row !== this.end.row; }), - (this.clone = function() { + (this.clone = function () { return i.fromPoints(this.start, this.end); }), - (this.collapseRows = function() { + (this.collapseRows = function () { return this.end.column == 0 ? new i( this.start.row, @@ -3311,8119 +3370,8269 @@ ) : new i(this.start.row, 0, this.end.row, 0); }), - (this.toScreenRange = function(e) { + (this.toScreenRange = function (e) { var t = e.documentToScreenPosition(this.start), n = e.documentToScreenPosition(this.end); return new i(t.row, t.column, n.row, n.column); }), - (this.moveBy = function(e, t) { - (this.start.row += e), + (this.moveBy = function (e, t) { + ((this.start.row += e), (this.start.column += t), (this.end.row += e), - (this.end.column += t); - }); - }.call(i.prototype), - (i.fromPoints = function(e, t) { + (this.end.column += t)); + })); + }).call(i.prototype), + (i.fromPoints = function (e, t) { return new i(e.row, e.column, t.row, t.column); }), (i.comparePoints = r), - (i.comparePoints = function(e, t) { + (i.comparePoints = function (e, t) { return e.row - t.row || e.column - t.column; }), (t.Range = i)); }), - define("ace/selection", [ - "require", - "exports", - "module", - "ace/lib/oop", - "ace/lib/lang", - "ace/lib/event_emitter", - "ace/range" - ], function(e, t, n) { - "use strict"; - var r = e("./lib/oop"), - i = e("./lib/lang"), - s = e("./lib/event_emitter").EventEmitter, - o = e("./range").Range, - u = function(e) { - (this.session = e), - (this.doc = e.getDocument()), - this.clearSelection(), - (this.lead = this.selectionLead = this.doc.createAnchor(0, 0)), - (this.anchor = this.selectionAnchor = this.doc.createAnchor(0, 0)); - var t = this; - this.lead.on("change", function(e) { - t._emit("changeCursor"), - t.$isEmpty || t._emit("changeSelection"), - !t.$keepDesiredColumnOnChange && - e.old.column != e.value.column && - (t.$desiredColumn = null); - }), - this.selectionAnchor.on("change", function() { - t.$isEmpty || t._emit("changeSelection"); - }); - }; - (function() { - r.implement(this, s), - (this.isEmpty = function() { - return ( + define( + "ace/selection", + [ + "require", + "exports", + "module", + "ace/lib/oop", + "ace/lib/lang", + "ace/lib/event_emitter", + "ace/range" + ], + function (e, t, n) { + "use strict"; + var r = e("./lib/oop"), + i = e("./lib/lang"), + s = e("./lib/event_emitter").EventEmitter, + o = e("./range").Range, + u = function (e) { + ((this.session = e), + (this.doc = e.getDocument()), + this.clearSelection(), + (this.lead = this.selectionLead = this.doc.createAnchor(0, 0)), + (this.anchor = this.selectionAnchor = this.doc.createAnchor(0, 0))); + var t = this; + (this.lead.on("change", function (e) { + (t._emit("changeCursor"), + t.$isEmpty || t._emit("changeSelection"), + !t.$keepDesiredColumnOnChange && + e.old.column != e.value.column && + (t.$desiredColumn = null)); + }), + this.selectionAnchor.on("change", function () { + t.$isEmpty || t._emit("changeSelection"); + })); + }; + ((function () { + (r.implement(this, s), + (this.isEmpty = function () { + return ( + this.$isEmpty || + (this.anchor.row == this.lead.row && + this.anchor.column == this.lead.column) + ); + }), + (this.isMultiLine = function () { + return this.isEmpty() ? !1 : this.getRange().isMultiLine(); + }), + (this.getCursor = function () { + return this.lead.getPosition(); + }), + (this.setSelectionAnchor = function (e, t) { + (this.anchor.setPosition(e, t), + this.$isEmpty && + ((this.$isEmpty = !1), this._emit("changeSelection"))); + }), + (this.getSelectionAnchor = function () { + return this.$isEmpty + ? this.getSelectionLead() + : this.anchor.getPosition(); + }), + (this.getSelectionLead = function () { + return this.lead.getPosition(); + }), + (this.shiftSelection = function (e) { + if (this.$isEmpty) { + this.moveCursorTo(this.lead.row, this.lead.column + e); + return; + } + var t = this.getSelectionAnchor(), + n = this.getSelectionLead(), + r = this.isBackwards(); + ((!r || t.column !== 0) && + this.setSelectionAnchor(t.row, t.column + e), + (r || n.column !== 0) && + this.$moveSelection(function () { + this.moveCursorTo(n.row, n.column + e); + })); + }), + (this.isBackwards = function () { + var e = this.anchor, + t = this.lead; + return e.row > t.row || (e.row == t.row && e.column > t.column); + }), + (this.getRange = function () { + var e = this.anchor, + t = this.lead; + return this.isEmpty() + ? o.fromPoints(t, t) + : this.isBackwards() + ? o.fromPoints(t, e) + : o.fromPoints(e, t); + }), + (this.clearSelection = function () { this.$isEmpty || - (this.anchor.row == this.lead.row && - this.anchor.column == this.lead.column) - ); - }), - (this.isMultiLine = function() { - return this.isEmpty() ? !1 : this.getRange().isMultiLine(); - }), - (this.getCursor = function() { - return this.lead.getPosition(); - }), - (this.setSelectionAnchor = function(e, t) { - this.anchor.setPosition(e, t), - this.$isEmpty && - ((this.$isEmpty = !1), this._emit("changeSelection")); - }), - (this.getSelectionAnchor = function() { - return this.$isEmpty - ? this.getSelectionLead() - : this.anchor.getPosition(); - }), - (this.getSelectionLead = function() { - return this.lead.getPosition(); - }), - (this.shiftSelection = function(e) { - if (this.$isEmpty) { - this.moveCursorTo(this.lead.row, this.lead.column + e); - return; - } - var t = this.getSelectionAnchor(), - n = this.getSelectionLead(), - r = this.isBackwards(); - (!r || t.column !== 0) && - this.setSelectionAnchor(t.row, t.column + e), - (r || n.column !== 0) && - this.$moveSelection(function() { - this.moveCursorTo(n.row, n.column + e); - }); - }), - (this.isBackwards = function() { - var e = this.anchor, - t = this.lead; - return e.row > t.row || (e.row == t.row && e.column > t.column); - }), - (this.getRange = function() { - var e = this.anchor, - t = this.lead; - return this.isEmpty() - ? o.fromPoints(t, t) - : this.isBackwards() - ? o.fromPoints(t, e) - : o.fromPoints(e, t); - }), - (this.clearSelection = function() { - this.$isEmpty || - ((this.$isEmpty = !0), this._emit("changeSelection")); - }), - (this.selectAll = function() { - var e = this.doc.getLength() - 1; - this.setSelectionAnchor(0, 0), - this.moveCursorTo(e, this.doc.getLine(e).length); - }), - (this.setRange = this.setSelectionRange = function(e, t) { - t - ? (this.setSelectionAnchor(e.end.row, e.end.column), - this.selectTo(e.start.row, e.start.column)) - : (this.setSelectionAnchor(e.start.row, e.start.column), - this.selectTo(e.end.row, e.end.column)), - this.getRange().isEmpty() && (this.$isEmpty = !0), - (this.$desiredColumn = null); - }), - (this.$moveSelection = function(e) { - var t = this.lead; - this.$isEmpty && this.setSelectionAnchor(t.row, t.column), - e.call(this); - }), - (this.selectTo = function(e, t) { - this.$moveSelection(function() { + ((this.$isEmpty = !0), this._emit("changeSelection")); + }), + (this.selectAll = function () { + var e = this.doc.getLength() - 1; + (this.setSelectionAnchor(0, 0), + this.moveCursorTo(e, this.doc.getLine(e).length)); + }), + (this.setRange = this.setSelectionRange = + function (e, t) { + (t + ? (this.setSelectionAnchor(e.end.row, e.end.column), + this.selectTo(e.start.row, e.start.column)) + : (this.setSelectionAnchor(e.start.row, e.start.column), + this.selectTo(e.end.row, e.end.column)), + this.getRange().isEmpty() && (this.$isEmpty = !0), + (this.$desiredColumn = null)); + }), + (this.$moveSelection = function (e) { + var t = this.lead; + (this.$isEmpty && this.setSelectionAnchor(t.row, t.column), + e.call(this)); + }), + (this.selectTo = function (e, t) { + this.$moveSelection(function () { + this.moveCursorTo(e, t); + }); + }), + (this.selectToPosition = function (e) { + this.$moveSelection(function () { + this.moveCursorToPosition(e); + }); + }), + (this.moveTo = function (e, t) { + (this.clearSelection(), this.moveCursorTo(e, t)); + }), + (this.moveToPosition = function (e) { + (this.clearSelection(), this.moveCursorToPosition(e)); + }), + (this.selectUp = function () { + this.$moveSelection(this.moveCursorUp); + }), + (this.selectDown = function () { + this.$moveSelection(this.moveCursorDown); + }), + (this.selectRight = function () { + this.$moveSelection(this.moveCursorRight); + }), + (this.selectLeft = function () { + this.$moveSelection(this.moveCursorLeft); + }), + (this.selectLineStart = function () { + this.$moveSelection(this.moveCursorLineStart); + }), + (this.selectLineEnd = function () { + this.$moveSelection(this.moveCursorLineEnd); + }), + (this.selectFileEnd = function () { + this.$moveSelection(this.moveCursorFileEnd); + }), + (this.selectFileStart = function () { + this.$moveSelection(this.moveCursorFileStart); + }), + (this.selectWordRight = function () { + this.$moveSelection(this.moveCursorWordRight); + }), + (this.selectWordLeft = function () { + this.$moveSelection(this.moveCursorWordLeft); + }), + (this.getWordRange = function (e, t) { + if (typeof t == "undefined") { + var n = e || this.lead; + ((e = n.row), (t = n.column)); + } + return this.session.getWordRange(e, t); + }), + (this.selectWord = function () { + this.setSelectionRange(this.getWordRange()); + }), + (this.selectAWord = function () { + var e = this.getCursor(), + t = this.session.getAWordRange(e.row, e.column); + this.setSelectionRange(t); + }), + (this.getLineRange = function (e, t) { + var n = typeof e == "number" ? e : this.lead.row, + r, + i = this.session.getFoldLine(n); + return ( + i ? ((n = i.start.row), (r = i.end.row)) : (r = n), + t === !0 + ? new o(n, 0, r, this.session.getLine(r).length) + : new o(n, 0, r + 1, 0) + ); + }), + (this.selectLine = function () { + this.setSelectionRange(this.getLineRange()); + }), + (this.moveCursorUp = function () { + this.moveCursorBy(-1, 0); + }), + (this.moveCursorDown = function () { + this.moveCursorBy(1, 0); + }), + (this.moveCursorLeft = function () { + var e = this.lead.getPosition(), + t; + if ((t = this.session.getFoldAt(e.row, e.column, -1))) + this.moveCursorTo(t.start.row, t.start.column); + else if (e.column === 0) + e.row > 0 && + this.moveCursorTo( + e.row - 1, + this.doc.getLine(e.row - 1).length + ); + else { + var n = this.session.getTabSize(); + this.session.isTabStop(e) && + this.doc + .getLine(e.row) + .slice(e.column - n, e.column) + .split(" ").length - + 1 == + n + ? this.moveCursorBy(0, -n) + : this.moveCursorBy(0, -1); + } + }), + (this.moveCursorRight = function () { + var e = this.lead.getPosition(), + t; + if ((t = this.session.getFoldAt(e.row, e.column, 1))) + this.moveCursorTo(t.end.row, t.end.column); + else if (this.lead.column == this.doc.getLine(this.lead.row).length) + this.lead.row < this.doc.getLength() - 1 && + this.moveCursorTo(this.lead.row + 1, 0); + else { + var n = this.session.getTabSize(), + e = this.lead; + this.session.isTabStop(e) && + this.doc + .getLine(e.row) + .slice(e.column, e.column + n) + .split(" ").length - + 1 == + n + ? this.moveCursorBy(0, n) + : this.moveCursorBy(0, 1); + } + }), + (this.moveCursorLineStart = function () { + var e = this.lead.row, + t = this.lead.column, + n = this.session.documentToScreenRow(e, t), + r = this.session.screenToDocumentPosition(n, 0), + i = this.session.getDisplayLine(e, null, r.row, r.column), + s = i.match(/^\s*/); + (s[0].length != t && + !this.session.$useEmacsStyleLineStart && + (r.column += s[0].length), + this.moveCursorToPosition(r)); + }), + (this.moveCursorLineEnd = function () { + var e = this.lead, + t = this.session.getDocumentLastRowColumnPosition( + e.row, + e.column + ); + if (this.lead.column == t.column) { + var n = this.session.getLine(t.row); + if (t.column == n.length) { + var r = n.search(/\s+$/); + r > 0 && (t.column = r); + } + } + this.moveCursorTo(t.row, t.column); + }), + (this.moveCursorFileEnd = function () { + var e = this.doc.getLength() - 1, + t = this.doc.getLine(e).length; this.moveCursorTo(e, t); - }); - }), - (this.selectToPosition = function(e) { - this.$moveSelection(function() { - this.moveCursorToPosition(e); - }); - }), - (this.moveTo = function(e, t) { - this.clearSelection(), this.moveCursorTo(e, t); - }), - (this.moveToPosition = function(e) { - this.clearSelection(), this.moveCursorToPosition(e); - }), - (this.selectUp = function() { - this.$moveSelection(this.moveCursorUp); - }), - (this.selectDown = function() { - this.$moveSelection(this.moveCursorDown); - }), - (this.selectRight = function() { - this.$moveSelection(this.moveCursorRight); - }), - (this.selectLeft = function() { - this.$moveSelection(this.moveCursorLeft); - }), - (this.selectLineStart = function() { - this.$moveSelection(this.moveCursorLineStart); - }), - (this.selectLineEnd = function() { - this.$moveSelection(this.moveCursorLineEnd); - }), - (this.selectFileEnd = function() { - this.$moveSelection(this.moveCursorFileEnd); - }), - (this.selectFileStart = function() { - this.$moveSelection(this.moveCursorFileStart); - }), - (this.selectWordRight = function() { - this.$moveSelection(this.moveCursorWordRight); - }), - (this.selectWordLeft = function() { - this.$moveSelection(this.moveCursorWordLeft); - }), - (this.getWordRange = function(e, t) { - if (typeof t == "undefined") { - var n = e || this.lead; - (e = n.row), (t = n.column); - } - return this.session.getWordRange(e, t); - }), - (this.selectWord = function() { - this.setSelectionRange(this.getWordRange()); - }), - (this.selectAWord = function() { - var e = this.getCursor(), - t = this.session.getAWordRange(e.row, e.column); - this.setSelectionRange(t); - }), - (this.getLineRange = function(e, t) { - var n = typeof e == "number" ? e : this.lead.row, - r, - i = this.session.getFoldLine(n); - return ( - i ? ((n = i.start.row), (r = i.end.row)) : (r = n), - t === !0 - ? new o(n, 0, r, this.session.getLine(r).length) - : new o(n, 0, r + 1, 0) - ); - }), - (this.selectLine = function() { - this.setSelectionRange(this.getLineRange()); - }), - (this.moveCursorUp = function() { - this.moveCursorBy(-1, 0); - }), - (this.moveCursorDown = function() { - this.moveCursorBy(1, 0); - }), - (this.moveCursorLeft = function() { - var e = this.lead.getPosition(), - t; - if ((t = this.session.getFoldAt(e.row, e.column, -1))) - this.moveCursorTo(t.start.row, t.start.column); - else if (e.column === 0) - e.row > 0 && - this.moveCursorTo(e.row - 1, this.doc.getLine(e.row - 1).length); - else { - var n = this.session.getTabSize(); - this.session.isTabStop(e) && - this.doc - .getLine(e.row) - .slice(e.column - n, e.column) - .split(" ").length - - 1 == - n - ? this.moveCursorBy(0, -n) - : this.moveCursorBy(0, -1); - } - }), - (this.moveCursorRight = function() { - var e = this.lead.getPosition(), - t; - if ((t = this.session.getFoldAt(e.row, e.column, 1))) - this.moveCursorTo(t.end.row, t.end.column); - else if (this.lead.column == this.doc.getLine(this.lead.row).length) - this.lead.row < this.doc.getLength() - 1 && - this.moveCursorTo(this.lead.row + 1, 0); - else { - var n = this.session.getTabSize(), - e = this.lead; - this.session.isTabStop(e) && - this.doc - .getLine(e.row) - .slice(e.column, e.column + n) - .split(" ").length - - 1 == - n - ? this.moveCursorBy(0, n) - : this.moveCursorBy(0, 1); - } - }), - (this.moveCursorLineStart = function() { - var e = this.lead.row, - t = this.lead.column, - n = this.session.documentToScreenRow(e, t), - r = this.session.screenToDocumentPosition(n, 0), - i = this.session.getDisplayLine(e, null, r.row, r.column), - s = i.match(/^\s*/); - s[0].length != t && - !this.session.$useEmacsStyleLineStart && - (r.column += s[0].length), - this.moveCursorToPosition(r); - }), - (this.moveCursorLineEnd = function() { - var e = this.lead, - t = this.session.getDocumentLastRowColumnPosition(e.row, e.column); - if (this.lead.column == t.column) { - var n = this.session.getLine(t.row); - if (t.column == n.length) { - var r = n.search(/\s+$/); - r > 0 && (t.column = r); + }), + (this.moveCursorFileStart = function () { + this.moveCursorTo(0, 0); + }), + (this.moveCursorLongWordRight = function () { + var e = this.lead.row, + t = this.lead.column, + n = this.doc.getLine(e), + r = n.substring(t), + i; + ((this.session.nonTokenRe.lastIndex = 0), + (this.session.tokenRe.lastIndex = 0)); + var s = this.session.getFoldAt(e, t, 1); + if (s) { + this.moveCursorTo(s.end.row, s.end.column); + return; } - } - this.moveCursorTo(t.row, t.column); - }), - (this.moveCursorFileEnd = function() { - var e = this.doc.getLength() - 1, - t = this.doc.getLine(e).length; - this.moveCursorTo(e, t); - }), - (this.moveCursorFileStart = function() { - this.moveCursorTo(0, 0); - }), - (this.moveCursorLongWordRight = function() { - var e = this.lead.row, - t = this.lead.column, - n = this.doc.getLine(e), - r = n.substring(t), - i; - (this.session.nonTokenRe.lastIndex = 0), - (this.session.tokenRe.lastIndex = 0); - var s = this.session.getFoldAt(e, t, 1); - if (s) { - this.moveCursorTo(s.end.row, s.end.column); - return; - } - if ((i = this.session.nonTokenRe.exec(r))) - (t += this.session.nonTokenRe.lastIndex), - (this.session.nonTokenRe.lastIndex = 0), - (r = n.substring(t)); - if (t >= n.length) { - this.moveCursorTo(e, n.length), - this.moveCursorRight(), - e < this.doc.getLength() - 1 && this.moveCursorWordRight(); - return; - } - if ((i = this.session.tokenRe.exec(r))) - (t += this.session.tokenRe.lastIndex), - (this.session.tokenRe.lastIndex = 0); - this.moveCursorTo(e, t); - }), - (this.moveCursorLongWordLeft = function() { - var e = this.lead.row, - t = this.lead.column, - n; - if ((n = this.session.getFoldAt(e, t, -1))) { - this.moveCursorTo(n.start.row, n.start.column); - return; - } - var r = this.session.getFoldStringAt(e, t, -1); - r == null && (r = this.doc.getLine(e).substring(0, t)); - var s = i.stringReverse(r), - o; - (this.session.nonTokenRe.lastIndex = 0), - (this.session.tokenRe.lastIndex = 0); - if ((o = this.session.nonTokenRe.exec(s))) - (t -= this.session.nonTokenRe.lastIndex), - (s = s.slice(this.session.nonTokenRe.lastIndex)), - (this.session.nonTokenRe.lastIndex = 0); - if (t <= 0) { - this.moveCursorTo(e, 0), - this.moveCursorLeft(), - e > 0 && this.moveCursorWordLeft(); - return; - } - if ((o = this.session.tokenRe.exec(s))) - (t -= this.session.tokenRe.lastIndex), - (this.session.tokenRe.lastIndex = 0); - this.moveCursorTo(e, t); - }), - (this.$shortWordEndIndex = function(e) { - var t, - n = 0, - r, - i = /\s/, - s = this.session.tokenRe; - s.lastIndex = 0; - if ((t = this.session.tokenRe.exec(e))) - n = this.session.tokenRe.lastIndex; - else { - while ((r = e[n]) && i.test(r)) n++; - if (n < 1) { - s.lastIndex = 0; - while ((r = e[n]) && !s.test(r)) { - (s.lastIndex = 0), n++; - if (i.test(r)) { - if (n > 2) { - n--; - break; + if ((i = this.session.nonTokenRe.exec(r))) + ((t += this.session.nonTokenRe.lastIndex), + (this.session.nonTokenRe.lastIndex = 0), + (r = n.substring(t))); + if (t >= n.length) { + (this.moveCursorTo(e, n.length), + this.moveCursorRight(), + e < this.doc.getLength() - 1 && this.moveCursorWordRight()); + return; + } + if ((i = this.session.tokenRe.exec(r))) + ((t += this.session.tokenRe.lastIndex), + (this.session.tokenRe.lastIndex = 0)); + this.moveCursorTo(e, t); + }), + (this.moveCursorLongWordLeft = function () { + var e = this.lead.row, + t = this.lead.column, + n; + if ((n = this.session.getFoldAt(e, t, -1))) { + this.moveCursorTo(n.start.row, n.start.column); + return; + } + var r = this.session.getFoldStringAt(e, t, -1); + r == null && (r = this.doc.getLine(e).substring(0, t)); + var s = i.stringReverse(r), + o; + ((this.session.nonTokenRe.lastIndex = 0), + (this.session.tokenRe.lastIndex = 0)); + if ((o = this.session.nonTokenRe.exec(s))) + ((t -= this.session.nonTokenRe.lastIndex), + (s = s.slice(this.session.nonTokenRe.lastIndex)), + (this.session.nonTokenRe.lastIndex = 0)); + if (t <= 0) { + (this.moveCursorTo(e, 0), + this.moveCursorLeft(), + e > 0 && this.moveCursorWordLeft()); + return; + } + if ((o = this.session.tokenRe.exec(s))) + ((t -= this.session.tokenRe.lastIndex), + (this.session.tokenRe.lastIndex = 0)); + this.moveCursorTo(e, t); + }), + (this.$shortWordEndIndex = function (e) { + var t, + n = 0, + r, + i = /\s/, + s = this.session.tokenRe; + s.lastIndex = 0; + if ((t = this.session.tokenRe.exec(e))) + n = this.session.tokenRe.lastIndex; + else { + while ((r = e[n]) && i.test(r)) n++; + if (n < 1) { + s.lastIndex = 0; + while ((r = e[n]) && !s.test(r)) { + ((s.lastIndex = 0), n++); + if (i.test(r)) { + if (n > 2) { + n--; + break; + } + while ((r = e[n]) && i.test(r)) n++; + if (n > 2) break; } - while ((r = e[n]) && i.test(r)) n++; - if (n > 2) break; } } } - } - return (s.lastIndex = 0), n; - }), - (this.moveCursorShortWordRight = function() { - var e = this.lead.row, - t = this.lead.column, - n = this.doc.getLine(e), - r = n.substring(t), - i = this.session.getFoldAt(e, t, 1); - if (i) return this.moveCursorTo(i.end.row, i.end.column); - if (t == n.length) { - var s = this.doc.getLength(); - do e++, (r = this.doc.getLine(e)); - while (e < s && /^\s*$/.test(r)); - /^\s+/.test(r) || (r = ""), (t = 0); - } - var o = this.$shortWordEndIndex(r); - this.moveCursorTo(e, t + o); - }), - (this.moveCursorShortWordLeft = function() { - var e = this.lead.row, - t = this.lead.column, - n; - if ((n = this.session.getFoldAt(e, t, -1))) - return this.moveCursorTo(n.start.row, n.start.column); - var r = this.session.getLine(e).substring(0, t); - if (t === 0) { - do e--, (r = this.doc.getLine(e)); - while (e > 0 && /^\s*$/.test(r)); - (t = r.length), /\s+$/.test(r) || (r = ""); - } - var s = i.stringReverse(r), - o = this.$shortWordEndIndex(s); - return this.moveCursorTo(e, t - o); - }), - (this.moveCursorWordRight = function() { - this.session.$selectLongWords - ? this.moveCursorLongWordRight() - : this.moveCursorShortWordRight(); - }), - (this.moveCursorWordLeft = function() { - this.session.$selectLongWords - ? this.moveCursorLongWordLeft() - : this.moveCursorShortWordLeft(); - }), - (this.moveCursorBy = function(e, t) { - var n = this.session.documentToScreenPosition( - this.lead.row, - this.lead.column - ); - t === 0 && - (this.$desiredColumn - ? (n.column = this.$desiredColumn) - : (this.$desiredColumn = n.column)); - var r = this.session.screenToDocumentPosition(n.row + e, n.column); - e !== 0 && - t === 0 && - r.row === this.lead.row && - r.column === this.lead.column && - this.session.lineWidgets && - this.session.lineWidgets[r.row] && - (r.row > 0 || e > 0) && - r.row++, - this.moveCursorTo(r.row, r.column + t, t === 0); - }), - (this.moveCursorToPosition = function(e) { - this.moveCursorTo(e.row, e.column); - }), - (this.moveCursorTo = function(e, t, n) { - var r = this.session.getFoldAt(e, t, 1); - r && ((e = r.start.row), (t = r.start.column)), - (this.$keepDesiredColumnOnChange = !0), - this.lead.setPosition(e, t), - (this.$keepDesiredColumnOnChange = !1), - n || (this.$desiredColumn = null); - }), - (this.moveCursorToScreen = function(e, t, n) { - var r = this.session.screenToDocumentPosition(e, t); - this.moveCursorTo(r.row, r.column, n); - }), - (this.detach = function() { - this.lead.detach(), - this.anchor.detach(), - (this.session = this.doc = null); - }), - (this.fromOrientedRange = function(e) { - this.setSelectionRange(e, e.cursor == e.start), - (this.$desiredColumn = e.desiredColumn || this.$desiredColumn); - }), - (this.toOrientedRange = function(e) { - var t = this.getRange(); - return ( - e - ? ((e.start.column = t.start.column), - (e.start.row = t.start.row), - (e.end.column = t.end.column), - (e.end.row = t.end.row)) - : (e = t), - (e.cursor = this.isBackwards() ? e.start : e.end), - (e.desiredColumn = this.$desiredColumn), - e - ); - }), - (this.getRangeOfMovements = function(e) { - var t = this.getCursor(); - try { - e(this); - var n = this.getCursor(); - return o.fromPoints(t, n); - } catch (r) { - return o.fromPoints(t, t); - } finally { - this.moveCursorToPosition(t); - } - }), - (this.toJSON = function() { - if (this.rangeCount) - var e = this.ranges.map(function(e) { - var t = e.clone(); - return (t.isBackwards = e.cursor == e.start), t; - }); - else { - var e = this.getRange(); - e.isBackwards = this.isBackwards(); - } - return e; - }), - (this.fromJSON = function(e) { - if (e.start == undefined) { - if (this.rangeList) { - this.toSingleRange(e[0]); - for (var t = e.length; t--; ) { - var n = o.fromPoints(e[t].start, e[t].end); - e[t].isBackwards && (n.cursor = n.start), this.addRange(n, !0); - } - return; + return ((s.lastIndex = 0), n); + }), + (this.moveCursorShortWordRight = function () { + var e = this.lead.row, + t = this.lead.column, + n = this.doc.getLine(e), + r = n.substring(t), + i = this.session.getFoldAt(e, t, 1); + if (i) return this.moveCursorTo(i.end.row, i.end.column); + if (t == n.length) { + var s = this.doc.getLength(); + do (e++, (r = this.doc.getLine(e))); + while (e < s && /^\s*$/.test(r)); + (/^\s+/.test(r) || (r = ""), (t = 0)); } - e = e[0]; - } - this.rangeList && this.toSingleRange(e), - this.setSelectionRange(e, e.isBackwards); - }), - (this.isEqual = function(e) { - if ((e.length || this.rangeCount) && e.length != this.rangeCount) - return !1; - if (!e.length || !this.ranges) return this.getRange().isEqual(e); - for (var t = this.ranges.length; t--; ) - if (!this.ranges[t].isEqual(e[t])) return !1; - return !0; - }); - }.call(u.prototype), - (t.Selection = u)); - }), - define("ace/tokenizer", [ - "require", - "exports", - "module", - "ace/config" - ], function(e, t, n) { - "use strict"; - var r = e("./config"), - i = 2e3, - s = function(e) { - (this.states = e), (this.regExps = {}), (this.matchMappings = {}); - for (var t in this.states) { - var n = this.states[t], - r = [], - i = 0, - s = (this.matchMappings[t] = { defaultToken: "text" }), - o = "g", - u = []; - for (var a = 0; a < n.length; a++) { - var f = n[a]; - f.defaultToken && (s.defaultToken = f.defaultToken), - f.caseInsensitive && (o = "gi"); - if (f.regex == null) continue; - f.regex instanceof RegExp && - (f.regex = f.regex.toString().slice(1, -1)); - var l = f.regex, - c = new RegExp("(?:(" + l + ")|(.))").exec("a").length - 2; - Array.isArray(f.token) - ? f.token.length == 1 || c == 1 - ? (f.token = f.token[0]) - : c - 1 != f.token.length - ? (this.reportError( - "number of classes and regexp groups doesn't match", - { rule: f, groupCount: c - 1 } - ), - (f.token = f.token[0])) - : ((f.tokenArray = f.token), - (f.token = null), - (f.onMatch = this.$arrayTokens)) - : typeof f.token == "function" && - !f.onMatch && - (c > 1 - ? (f.onMatch = this.$applyToken) - : (f.onMatch = f.token)), - c > 1 && - (/\\\d/.test(f.regex) - ? (l = f.regex.replace(/\\([0-9]+)/g, function(e, t) { - return "\\" + (parseInt(t, 10) + i + 1); - })) - : ((c = 1), (l = this.removeCapturingGroups(f.regex))), - !f.splitRegex && typeof f.token != "string" && u.push(f)), - (s[i] = a), - (i += c), - r.push(l), - f.onMatch || (f.onMatch = null); - } - r.length || ((s[0] = 0), r.push("$")), - u.forEach(function(e) { - e.splitRegex = this.createSplitterRegexp(e.regex, o); - }, this), - (this.regExps[t] = new RegExp("(" + r.join(")|(") + ")|($)", o)); - } - }; - (function() { - (this.$setMaxTokenCount = function(e) { - i = e | 0; - }), - (this.$applyToken = function(e) { - var t = this.splitRegex.exec(e).slice(1), - n = this.token.apply(this, t); - if (typeof n == "string") return [{ type: n, value: e }]; - var r = []; - for (var i = 0, s = n.length; i < s; i++) - t[i] && (r[r.length] = { type: n[i], value: t[i] }); - return r; - }), - (this.$arrayTokens = function(e) { - if (!e) return []; - var t = this.splitRegex.exec(e); - if (!t) return "text"; - var n = [], - r = this.tokenArray; - for (var i = 0, s = r.length; i < s; i++) - t[i + 1] && (n[n.length] = { type: r[i], value: t[i + 1] }); - return n; - }), - (this.removeCapturingGroups = function(e) { - var t = e.replace(/\[(?:\\.|[^\]])*?\]|\\.|\(\?[:=!]|(\()/g, function( - e, - t - ) { - return t ? "(?:" : e; - }); - return t; - }), - (this.createSplitterRegexp = function(e, t) { - if (e.indexOf("(?=") != -1) { - var n = 0, - r = !1, - i = {}; - e.replace(/(\\.)|(\((?:\?[=!])?)|(\))|([\[\]])/g, function( - e, - t, - s, - o, - u, - a - ) { - return ( - r - ? (r = u != "]") - : u - ? (r = !0) - : o - ? (n == i.stack && ((i.end = a + 1), (i.stack = -1)), n--) - : s && (n++, s.length != 1 && ((i.stack = n), (i.start = a))), - e - ); - }), - i.end != null && - /^\)*$/.test(e.substr(i.end)) && - (e = e.substring(0, i.start) + e.substr(i.end)); - } - return ( - e.charAt(0) != "^" && (e = "^" + e), - e.charAt(e.length - 1) != "$" && (e += "$"), - new RegExp(e, (t || "").replace("g", "")) - ); - }), - (this.getLineTokens = function(e, t) { - if (t && typeof t != "string") { - var n = t.slice(0); - (t = n[0]), t === "#tmp" && (n.shift(), (t = n.shift())); - } else var n = []; - var r = t || "start", - s = this.states[r]; - s || ((r = "start"), (s = this.states[r])); - var o = this.matchMappings[r], - u = this.regExps[r]; - u.lastIndex = 0; - var a, - f = [], - l = 0, - c = 0, - h = { type: null, value: "" }; - while ((a = u.exec(e))) { - var p = o.defaultToken, - d = null, - v = a[0], - m = u.lastIndex; - if (m - v.length > l) { - var g = e.substring(l, m - v.length); - h.type == p - ? (h.value += g) - : (h.type && f.push(h), (h = { type: p, value: g })); - } - for (var y = 0; y < a.length - 2; y++) { - if (a[y + 1] === undefined) continue; - (d = s[o[y]]), - d.onMatch ? (p = d.onMatch(v, r, n)) : (p = d.token), - d.next && - (typeof d.next == "string" - ? (r = d.next) - : (r = d.next(r, n)), - (s = this.states[r]), - s || - (this.reportError("state doesn't exist", r), - (r = "start"), - (s = this.states[r])), - (o = this.matchMappings[r]), - (l = m), - (u = this.regExps[r]), - (u.lastIndex = m)); - break; - } - if (v) - if (typeof p == "string") - (!!d && d.merge === !1) || h.type !== p - ? (h.type && f.push(h), (h = { type: p, value: v })) - : (h.value += v); - else if (p) { - h.type && f.push(h), (h = { type: null, value: "" }); - for (var y = 0; y < p.length; y++) f.push(p[y]); - } - if (l == e.length) break; - l = m; - if (c++ > i) { - c > 2 * e.length && - this.reportError("infinite loop with in ace tokenizer", { - startState: t, - line: e - }); - while (l < e.length) - h.type && f.push(h), - (h = { value: e.substring(l, (l += 2e3)), type: "overflow" }); - (r = "start"), (n = []); - break; + var o = this.$shortWordEndIndex(r); + this.moveCursorTo(e, t + o); + }), + (this.moveCursorShortWordLeft = function () { + var e = this.lead.row, + t = this.lead.column, + n; + if ((n = this.session.getFoldAt(e, t, -1))) + return this.moveCursorTo(n.start.row, n.start.column); + var r = this.session.getLine(e).substring(0, t); + if (t === 0) { + do (e--, (r = this.doc.getLine(e))); + while (e > 0 && /^\s*$/.test(r)); + ((t = r.length), /\s+$/.test(r) || (r = "")); } - } - return ( - h.type && f.push(h), - n.length > 1 && n[0] !== r && n.unshift("#tmp", r), - { tokens: f, state: n.length ? n : r } - ); - }), - (this.reportError = r.reportError); - }.call(s.prototype), - (t.Tokenizer = s)); - }), - define("ace/mode/text_highlight_rules", [ - "require", - "exports", - "module", - "ace/lib/lang" - ], function(e, t, n) { - "use strict"; - var r = e("../lib/lang"), - i = function() { - this.$rules = { - start: [ - { token: "empty_line", regex: "^$" }, - { defaultToken: "text" } - ] - }; - }; - (function() { - (this.addRules = function(e, t) { - if (!t) { - for (var n in e) this.$rules[n] = e[n]; - return; - } - for (var n in e) { - var r = e[n]; - for (var i = 0; i < r.length; i++) { - var s = r[i]; - if (s.next || s.onMatch) - typeof s.next == "string" && - s.next.indexOf(t) !== 0 && - (s.next = t + s.next), - s.nextState && - s.nextState.indexOf(t) !== 0 && - (s.nextState = t + s.nextState); - } - this.$rules[t + n] = r; - } - }), - (this.getRules = function() { - return this.$rules; - }), - (this.embedRules = function(e, t, n, i, s) { - var o = typeof e == "function" ? new e().getRules() : e; - if (i) for (var u = 0; u < i.length; u++) i[u] = t + i[u]; - else { - i = []; - for (var a in o) i.push(t + a); - } - this.addRules(o, t); - if (n) { - var f = Array.prototype[s ? "push" : "unshift"]; - for (var u = 0; u < i.length; u++) - f.apply(this.$rules[i[u]], r.deepCopy(n)); - } - this.$embeds || (this.$embeds = []), this.$embeds.push(t); - }), - (this.getEmbeds = function() { - return this.$embeds; - }); - var e = function(e, t) { - return ( - (e != "start" || t.length) && t.unshift(this.nextState, e), - this.nextState - ); - }, - t = function(e, t) { - return t.shift(), t.shift() || "start"; - }; - (this.normalizeRules = function() { - function i(s) { - var o = r[s]; - o.processed = !0; - for (var u = 0; u < o.length; u++) { - var a = o[u], - f = null; - Array.isArray(a) && ((f = a), (a = {})), - !a.regex && - a.start && - ((a.regex = a.start), - a.next || (a.next = []), - a.next.push( - { defaultToken: a.token }, - { - token: a.token + ".end", - regex: a.end || a.start, - next: "pop" - } - ), - (a.token = a.token + ".start"), - (a.push = !0)); - var l = a.next || a.push; - if (l && Array.isArray(l)) { - var c = a.stateName; - c || - ((c = a.token), - typeof c != "string" && (c = c[0] || ""), - r[c] && (c += n++)), - (r[c] = l), - (a.next = c), - i(c); - } else l == "pop" && (a.next = t); - a.push && - ((a.nextState = a.next || a.push), (a.next = e), delete a.push); - if (a.rules) - for (var h in a.rules) - r[h] - ? r[h].push && r[h].push.apply(r[h], a.rules[h]) - : (r[h] = a.rules[h]); - var p = - typeof a == "string" - ? a - : typeof a.include == "string" - ? a.include - : ""; - p && (f = r[p]); - if (f) { - var d = [u, 1].concat(f); - a.noEscape && - (d = d.filter(function(e) { - return !e.next; - })), - o.splice.apply(o, d), - u--; - } - a.keywordMap && - ((a.token = this.createKeywordMapper( - a.keywordMap, - a.defaultToken || "text", - a.caseInsensitive - )), - delete a.defaultToken); - } - } - var n = 0, - r = this.$rules; - Object.keys(r).forEach(i, this); - }), - (this.createKeywordMapper = function(e, t, n, r) { - var i = Object.create(null); - return ( - Object.keys(e).forEach(function(t) { - var s = e[t]; - n && (s = s.toLowerCase()); - var o = s.split(r || "|"); - for (var u = o.length; u--; ) i[o[u]] = t; - }), - Object.getPrototypeOf(i) && (i.__proto__ = null), - (this.$keywordList = Object.keys(i)), - (e = null), - n - ? function(e) { - return i[e.toLowerCase()] || t; - } - : function(e) { - return i[e] || t; - } - ); - }), - (this.getKeywords = function() { - return this.$keywords; - }); - }.call(i.prototype), - (t.TextHighlightRules = i)); - }), - define("ace/mode/behaviour", ["require", "exports", "module"], function( - e, - t, - n - ) { - "use strict"; - var r = function() { - this.$behaviours = {}; - }; - (function() { - (this.add = function(e, t, n) { - switch (undefined) { - case this.$behaviours: - this.$behaviours = {}; - case this.$behaviours[e]: - this.$behaviours[e] = {}; - } - this.$behaviours[e][t] = n; - }), - (this.addBehaviours = function(e) { - for (var t in e) for (var n in e[t]) this.add(t, n, e[t][n]); - }), - (this.remove = function(e) { - this.$behaviours && this.$behaviours[e] && delete this.$behaviours[e]; - }), - (this.inherit = function(e, t) { - if (typeof e == "function") var n = new e().getBehaviours(t); - else var n = e.getBehaviours(t); - this.addBehaviours(n); - }), - (this.getBehaviours = function(e) { - if (!e) return this.$behaviours; - var t = {}; - for (var n = 0; n < e.length; n++) - this.$behaviours[e[n]] && (t[e[n]] = this.$behaviours[e[n]]); - return t; - }); - }.call(r.prototype), - (t.Behaviour = r)); - }), - define("ace/token_iterator", ["require", "exports", "module"], function( - e, - t, - n - ) { - "use strict"; - var r = function(e, t, n) { - (this.$session = e), (this.$row = t), (this.$rowTokens = e.getTokens(t)); - var r = e.getTokenAt(t, n); - this.$tokenIndex = r ? r.index : -1; - }; - (function() { - (this.stepBackward = function() { - this.$tokenIndex -= 1; - while (this.$tokenIndex < 0) { - this.$row -= 1; - if (this.$row < 0) return (this.$row = 0), null; - (this.$rowTokens = this.$session.getTokens(this.$row)), - (this.$tokenIndex = this.$rowTokens.length - 1); - } - return this.$rowTokens[this.$tokenIndex]; - }), - (this.stepForward = function() { - this.$tokenIndex += 1; - var e; - while (this.$tokenIndex >= this.$rowTokens.length) { - (this.$row += 1), e || (e = this.$session.getLength()); - if (this.$row >= e) return (this.$row = e - 1), null; - (this.$rowTokens = this.$session.getTokens(this.$row)), - (this.$tokenIndex = 0); - } - return this.$rowTokens[this.$tokenIndex]; - }), - (this.getCurrentToken = function() { - return this.$rowTokens[this.$tokenIndex]; - }), - (this.getCurrentTokenRow = function() { - return this.$row; - }), - (this.getCurrentTokenColumn = function() { - var e = this.$rowTokens, - t = this.$tokenIndex, - n = e[t].start; - if (n !== undefined) return n; - n = 0; - while (t > 0) (t -= 1), (n += e[t].value.length); - return n; - }), - (this.getCurrentTokenPosition = function() { - return { row: this.$row, column: this.getCurrentTokenColumn() }; - }); - }.call(r.prototype), - (t.TokenIterator = r)); - }), - define("ace/mode/behaviour/cstyle", [ - "require", - "exports", - "module", - "ace/lib/oop", - "ace/mode/behaviour", - "ace/token_iterator", - "ace/lib/lang" - ], function(e, t, n) { - "use strict"; - var r = e("../../lib/oop"), - i = e("../behaviour").Behaviour, - s = e("../../token_iterator").TokenIterator, - o = e("../../lib/lang"), - u = ["text", "paren.rparen", "punctuation.operator"], - a = ["text", "paren.rparen", "punctuation.operator", "comment"], - f, - l = {}, - c = function(e) { - var t = -1; - e.multiSelect && - ((t = e.selection.index), - l.rangeCount != e.multiSelect.rangeCount && - (l = { rangeCount: e.multiSelect.rangeCount })); - if (l[t]) return (f = l[t]); - f = l[t] = { - autoInsertedBrackets: 0, - autoInsertedRow: -1, - autoInsertedLineEnd: "", - maybeInsertedBrackets: 0, - maybeInsertedRow: -1, - maybeInsertedLineStart: "", - maybeInsertedLineEnd: "" - }; - }, - h = function(e, t, n, r) { - var i = e.end.row - e.start.row; - return { - text: n + t + r, - selection: [0, e.start.column + 1, i, e.end.column + (i ? 0 : 1)] - }; - }, - p = function() { - this.add("braces", "insertion", function(e, t, n, r, i) { - var s = n.getCursorPosition(), - u = r.doc.getLine(s.row); - if (i == "{") { - c(n); - var a = n.getSelectionRange(), - l = r.doc.getTextRange(a); - if (l !== "" && l !== "{" && n.getWrapBehavioursEnabled()) - return h(a, l, "{", "}"); - if (p.isSaneInsertion(n, r)) - return /[\]\}\)]/.test(u[s.column]) || n.inMultiSelectMode - ? (p.recordAutoInsert(n, r, "}"), - { text: "{}", selection: [1, 1] }) - : (p.recordMaybeInsert(n, r, "{"), - { text: "{", selection: [1, 1] }); - } else if (i == "}") { - c(n); - var d = u.substring(s.column, s.column + 1); - if (d == "}") { - var v = r.$findOpeningBracket("}", { - column: s.column + 1, - row: s.row + var s = i.stringReverse(r), + o = this.$shortWordEndIndex(s); + return this.moveCursorTo(e, t - o); + }), + (this.moveCursorWordRight = function () { + this.session.$selectLongWords + ? this.moveCursorLongWordRight() + : this.moveCursorShortWordRight(); + }), + (this.moveCursorWordLeft = function () { + this.session.$selectLongWords + ? this.moveCursorLongWordLeft() + : this.moveCursorShortWordLeft(); + }), + (this.moveCursorBy = function (e, t) { + var n = this.session.documentToScreenPosition( + this.lead.row, + this.lead.column + ); + t === 0 && + (this.$desiredColumn + ? (n.column = this.$desiredColumn) + : (this.$desiredColumn = n.column)); + var r = this.session.screenToDocumentPosition(n.row + e, n.column); + (e !== 0 && + t === 0 && + r.row === this.lead.row && + r.column === this.lead.column && + this.session.lineWidgets && + this.session.lineWidgets[r.row] && + (r.row > 0 || e > 0) && + r.row++, + this.moveCursorTo(r.row, r.column + t, t === 0)); + }), + (this.moveCursorToPosition = function (e) { + this.moveCursorTo(e.row, e.column); + }), + (this.moveCursorTo = function (e, t, n) { + var r = this.session.getFoldAt(e, t, 1); + (r && ((e = r.start.row), (t = r.start.column)), + (this.$keepDesiredColumnOnChange = !0), + this.lead.setPosition(e, t), + (this.$keepDesiredColumnOnChange = !1), + n || (this.$desiredColumn = null)); + }), + (this.moveCursorToScreen = function (e, t, n) { + var r = this.session.screenToDocumentPosition(e, t); + this.moveCursorTo(r.row, r.column, n); + }), + (this.detach = function () { + (this.lead.detach(), + this.anchor.detach(), + (this.session = this.doc = null)); + }), + (this.fromOrientedRange = function (e) { + (this.setSelectionRange(e, e.cursor == e.start), + (this.$desiredColumn = e.desiredColumn || this.$desiredColumn)); + }), + (this.toOrientedRange = function (e) { + var t = this.getRange(); + return ( + e + ? ((e.start.column = t.start.column), + (e.start.row = t.start.row), + (e.end.column = t.end.column), + (e.end.row = t.end.row)) + : (e = t), + (e.cursor = this.isBackwards() ? e.start : e.end), + (e.desiredColumn = this.$desiredColumn), + e + ); + }), + (this.getRangeOfMovements = function (e) { + var t = this.getCursor(); + try { + e(this); + var n = this.getCursor(); + return o.fromPoints(t, n); + } catch (r) { + return o.fromPoints(t, t); + } finally { + this.moveCursorToPosition(t); + } + }), + (this.toJSON = function () { + if (this.rangeCount) + var e = this.ranges.map(function (e) { + var t = e.clone(); + return ((t.isBackwards = e.cursor == e.start), t); }); - if (v !== null && p.isAutoInsertedClosing(s, u, i)) - return ( - p.popAutoInsertedClosing(), { text: "", selection: [1, 1] } - ); + else { + var e = this.getRange(); + e.isBackwards = this.isBackwards(); } - } else { - if (i == "\n" || i == "\r\n") { - c(n); - var m = ""; - p.isMaybeInsertedClosing(s, u) && - ((m = o.stringRepeat("}", f.maybeInsertedBrackets)), - p.clearMaybeInsertedClosing()); - var d = u.substring(s.column, s.column + 1); - if (d === "}") { - var g = r.findMatchingBracket( - { row: s.row, column: s.column + 1 }, - "}" - ); - if (!g) return null; - var y = this.$getIndent(r.getLine(g.row)); - } else { - if (!m) { - p.clearMaybeInsertedClosing(); - return; + return e; + }), + (this.fromJSON = function (e) { + if (e.start == undefined) { + if (this.rangeList) { + this.toSingleRange(e[0]); + for (var t = e.length; t--;) { + var n = o.fromPoints(e[t].start, e[t].end); + (e[t].isBackwards && (n.cursor = n.start), + this.addRange(n, !0)); } - var y = this.$getIndent(u); + return; } - var b = y + r.getTabString(); - return { - text: "\n" + b + "\n" + y + m, - selection: [1, b.length, 1, b.length] - }; - } - p.clearMaybeInsertedClosing(); - } - }), - this.add("braces", "deletion", function(e, t, n, r, i) { - var s = r.doc.getTextRange(i); - if (!i.isMultiLine() && s == "{") { - c(n); - var o = r.doc.getLine(i.start.row), - u = o.substring(i.end.column, i.end.column + 1); - if (u == "}") return i.end.column++, i; - f.maybeInsertedBrackets--; + e = e[0]; } + (this.rangeList && this.toSingleRange(e), + this.setSelectionRange(e, e.isBackwards)); }), - this.add("parens", "insertion", function(e, t, n, r, i) { - if (i == "(") { - c(n); - var s = n.getSelectionRange(), - o = r.doc.getTextRange(s); - if (o !== "" && n.getWrapBehavioursEnabled()) - return h(s, o, "(", ")"); - if (p.isSaneInsertion(n, r)) - return ( - p.recordAutoInsert(n, r, ")"), - { text: "()", selection: [1, 1] } - ); - } else if (i == ")") { - c(n); - var u = n.getCursorPosition(), - a = r.doc.getLine(u.row), - f = a.substring(u.column, u.column + 1); - if (f == ")") { - var l = r.$findOpeningBracket(")", { - column: u.column + 1, - row: u.row - }); - if (l !== null && p.isAutoInsertedClosing(u, a, i)) - return ( - p.popAutoInsertedClosing(), { text: "", selection: [1, 1] } - ); - } + (this.isEqual = function (e) { + if ((e.length || this.rangeCount) && e.length != this.rangeCount) + return !1; + if (!e.length || !this.ranges) return this.getRange().isEqual(e); + for (var t = this.ranges.length; t--;) + if (!this.ranges[t].isEqual(e[t])) return !1; + return !0; + })); + }).call(u.prototype), + (t.Selection = u)); + } + ), + define( + "ace/tokenizer", + ["require", "exports", "module", "ace/config"], + function (e, t, n) { + "use strict"; + var r = e("./config"), + i = 2e3, + s = function (e) { + ((this.states = e), (this.regExps = {}), (this.matchMappings = {})); + for (var t in this.states) { + var n = this.states[t], + r = [], + i = 0, + s = (this.matchMappings[t] = { defaultToken: "text" }), + o = "g", + u = []; + for (var a = 0; a < n.length; a++) { + var f = n[a]; + (f.defaultToken && (s.defaultToken = f.defaultToken), + f.caseInsensitive && (o = "gi")); + if (f.regex == null) continue; + f.regex instanceof RegExp && + (f.regex = f.regex.toString().slice(1, -1)); + var l = f.regex, + c = new RegExp("(?:(" + l + ")|(.))").exec("a").length - 2; + (Array.isArray(f.token) + ? f.token.length == 1 || c == 1 + ? (f.token = f.token[0]) + : c - 1 != f.token.length + ? (this.reportError( + "number of classes and regexp groups doesn't match", + { rule: f, groupCount: c - 1 } + ), + (f.token = f.token[0])) + : ((f.tokenArray = f.token), + (f.token = null), + (f.onMatch = this.$arrayTokens)) + : typeof f.token == "function" && + !f.onMatch && + (c > 1 + ? (f.onMatch = this.$applyToken) + : (f.onMatch = f.token)), + c > 1 && + (/\\\d/.test(f.regex) + ? (l = f.regex.replace(/\\([0-9]+)/g, function (e, t) { + return "\\" + (parseInt(t, 10) + i + 1); + })) + : ((c = 1), (l = this.removeCapturingGroups(f.regex))), + !f.splitRegex && typeof f.token != "string" && u.push(f)), + (s[i] = a), + (i += c), + r.push(l), + f.onMatch || (f.onMatch = null)); } + (r.length || ((s[0] = 0), r.push("$")), + u.forEach(function (e) { + e.splitRegex = this.createSplitterRegexp(e.regex, o); + }, this), + (this.regExps[t] = new RegExp("(" + r.join(")|(") + ")|($)", o))); + } + }; + ((function () { + ((this.$setMaxTokenCount = function (e) { + i = e | 0; + }), + (this.$applyToken = function (e) { + var t = this.splitRegex.exec(e).slice(1), + n = this.token.apply(this, t); + if (typeof n == "string") return [{ type: n, value: e }]; + var r = []; + for (var i = 0, s = n.length; i < s; i++) + t[i] && (r[r.length] = { type: n[i], value: t[i] }); + return r; }), - this.add("parens", "deletion", function(e, t, n, r, i) { - var s = r.doc.getTextRange(i); - if (!i.isMultiLine() && s == "(") { - c(n); - var o = r.doc.getLine(i.start.row), - u = o.substring(i.start.column + 1, i.start.column + 2); - if (u == ")") return i.end.column++, i; - } + (this.$arrayTokens = function (e) { + if (!e) return []; + var t = this.splitRegex.exec(e); + if (!t) return "text"; + var n = [], + r = this.tokenArray; + for (var i = 0, s = r.length; i < s; i++) + t[i + 1] && (n[n.length] = { type: r[i], value: t[i + 1] }); + return n; }), - this.add("brackets", "insertion", function(e, t, n, r, i) { - if (i == "[") { - c(n); - var s = n.getSelectionRange(), - o = r.doc.getTextRange(s); - if (o !== "" && n.getWrapBehavioursEnabled()) - return h(s, o, "[", "]"); - if (p.isSaneInsertion(n, r)) - return ( - p.recordAutoInsert(n, r, "]"), - { text: "[]", selection: [1, 1] } - ); - } else if (i == "]") { - c(n); - var u = n.getCursorPosition(), - a = r.doc.getLine(u.row), - f = a.substring(u.column, u.column + 1); - if (f == "]") { - var l = r.$findOpeningBracket("]", { - column: u.column + 1, - row: u.row - }); - if (l !== null && p.isAutoInsertedClosing(u, a, i)) + (this.removeCapturingGroups = function (e) { + var t = e.replace( + /\[(?:\\.|[^\]])*?\]|\\.|\(\?[:=!]|(\()/g, + function (e, t) { + return t ? "(?:" : e; + } + ); + return t; + }), + (this.createSplitterRegexp = function (e, t) { + if (e.indexOf("(?=") != -1) { + var n = 0, + r = !1, + i = {}; + (e.replace( + /(\\.)|(\((?:\?[=!])?)|(\))|([\[\]])/g, + function (e, t, s, o, u, a) { return ( - p.popAutoInsertedClosing(), { text: "", selection: [1, 1] } + r + ? (r = u != "]") + : u + ? (r = !0) + : o + ? (n == i.stack && ((i.end = a + 1), (i.stack = -1)), + n--) + : s && + (n++, + s.length != 1 && ((i.stack = n), (i.start = a))), + e ); + } + ), + i.end != null && + /^\)*$/.test(e.substr(i.end)) && + (e = e.substring(0, i.start) + e.substr(i.end))); + } + return ( + e.charAt(0) != "^" && (e = "^" + e), + e.charAt(e.length - 1) != "$" && (e += "$"), + new RegExp(e, (t || "").replace("g", "")) + ); + }), + (this.getLineTokens = function (e, t) { + if (t && typeof t != "string") { + var n = t.slice(0); + ((t = n[0]), t === "#tmp" && (n.shift(), (t = n.shift()))); + } else var n = []; + var r = t || "start", + s = this.states[r]; + s || ((r = "start"), (s = this.states[r])); + var o = this.matchMappings[r], + u = this.regExps[r]; + u.lastIndex = 0; + var a, + f = [], + l = 0, + c = 0, + h = { type: null, value: "" }; + while ((a = u.exec(e))) { + var p = o.defaultToken, + d = null, + v = a[0], + m = u.lastIndex; + if (m - v.length > l) { + var g = e.substring(l, m - v.length); + h.type == p + ? (h.value += g) + : (h.type && f.push(h), (h = { type: p, value: g })); + } + for (var y = 0; y < a.length - 2; y++) { + if (a[y + 1] === undefined) continue; + ((d = s[o[y]]), + d.onMatch ? (p = d.onMatch(v, r, n)) : (p = d.token), + d.next && + (typeof d.next == "string" + ? (r = d.next) + : (r = d.next(r, n)), + (s = this.states[r]), + s || + (this.reportError("state doesn't exist", r), + (r = "start"), + (s = this.states[r])), + (o = this.matchMappings[r]), + (l = m), + (u = this.regExps[r]), + (u.lastIndex = m))); + break; + } + if (v) + if (typeof p == "string") + (!!d && d.merge === !1) || h.type !== p + ? (h.type && f.push(h), (h = { type: p, value: v })) + : (h.value += v); + else if (p) { + (h.type && f.push(h), (h = { type: null, value: "" })); + for (var y = 0; y < p.length; y++) f.push(p[y]); + } + if (l == e.length) break; + l = m; + if (c++ > i) { + c > 2 * e.length && + this.reportError("infinite loop with in ace tokenizer", { + startState: t, + line: e + }); + while (l < e.length) + (h.type && f.push(h), + (h = { + value: e.substring(l, (l += 2e3)), + type: "overflow" + })); + ((r = "start"), (n = [])); + break; } } + return ( + h.type && f.push(h), + n.length > 1 && n[0] !== r && n.unshift("#tmp", r), + { tokens: f, state: n.length ? n : r } + ); }), - this.add("brackets", "deletion", function(e, t, n, r, i) { - var s = r.doc.getTextRange(i); - if (!i.isMultiLine() && s == "[") { - c(n); - var o = r.doc.getLine(i.start.row), - u = o.substring(i.start.column + 1, i.start.column + 2); - if (u == "]") return i.end.column++, i; + (this.reportError = r.reportError)); + }).call(s.prototype), + (t.Tokenizer = s)); + } + ), + define( + "ace/mode/text_highlight_rules", + ["require", "exports", "module", "ace/lib/lang"], + function (e, t, n) { + "use strict"; + var r = e("../lib/lang"), + i = function () { + this.$rules = { + start: [ + { token: "empty_line", regex: "^$" }, + { defaultToken: "text" } + ] + }; + }; + ((function () { + ((this.addRules = function (e, t) { + if (!t) { + for (var n in e) this.$rules[n] = e[n]; + return; + } + for (var n in e) { + var r = e[n]; + for (var i = 0; i < r.length; i++) { + var s = r[i]; + if (s.next || s.onMatch) + (typeof s.next == "string" && + s.next.indexOf(t) !== 0 && + (s.next = t + s.next), + s.nextState && + s.nextState.indexOf(t) !== 0 && + (s.nextState = t + s.nextState)); } + this.$rules[t + n] = r; + } + }), + (this.getRules = function () { + return this.$rules; }), - this.add("string_dquotes", "insertion", function(e, t, n, r, i) { - if (i == '"' || i == "'") { - if ( - this.lineCommentStart && - this.lineCommentStart.indexOf(i) != -1 - ) - return; - c(n); - var s = i, - o = n.getSelectionRange(), - u = r.doc.getTextRange(o); - if ( - u !== "" && - u !== "'" && - u != '"' && - n.getWrapBehavioursEnabled() - ) - return h(o, u, s, s); - if (!u) { - var a = n.getCursorPosition(), - f = r.doc.getLine(a.row), - l = f.substring(a.column - 1, a.column), - p = f.substring(a.column, a.column + 1), - d = r.getTokenAt(a.row, a.column), - v = r.getTokenAt(a.row, a.column + 1); - if (l == "\\" && d && /escape/.test(d.type)) return null; - var m = d && /string|escape/.test(d.type), - g = !v || /string|escape/.test(v.type), - y; - if (p == s) - (y = m !== g), y && /string\.end/.test(v.type) && (y = !1); - else { - if (m && !g) return null; - if (m && g) return null; - var b = r.$mode.tokenRe; - b.lastIndex = 0; - var w = b.test(l); - b.lastIndex = 0; - var E = b.test(l); - if (w || E) return null; - if (p && !/[\s;,.})\]\\]/.test(p)) return null; - y = !0; - } - return { text: y ? s + s : "", selection: [1, 1] }; - } + (this.embedRules = function (e, t, n, i, s) { + var o = typeof e == "function" ? new e().getRules() : e; + if (i) for (var u = 0; u < i.length; u++) i[u] = t + i[u]; + else { + i = []; + for (var a in o) i.push(t + a); + } + this.addRules(o, t); + if (n) { + var f = Array.prototype[s ? "push" : "unshift"]; + for (var u = 0; u < i.length; u++) + f.apply(this.$rules[i[u]], r.deepCopy(n)); } + (this.$embeds || (this.$embeds = []), this.$embeds.push(t)); }), - this.add("string_dquotes", "deletion", function(e, t, n, r, i) { - var s = r.doc.getTextRange(i); - if (!i.isMultiLine() && (s == '"' || s == "'")) { - c(n); - var o = r.doc.getLine(i.start.row), - u = o.substring(i.start.column + 1, i.start.column + 2); - if (u == s) return i.end.column++, i; + (this.getEmbeds = function () { + return this.$embeds; + })); + var e = function (e, t) { + return ( + (e != "start" || t.length) && t.unshift(this.nextState, e), + this.nextState + ); + }, + t = function (e, t) { + return (t.shift(), t.shift() || "start"); + }; + ((this.normalizeRules = function () { + function i(s) { + var o = r[s]; + o.processed = !0; + for (var u = 0; u < o.length; u++) { + var a = o[u], + f = null; + (Array.isArray(a) && ((f = a), (a = {})), + !a.regex && + a.start && + ((a.regex = a.start), + a.next || (a.next = []), + a.next.push( + { defaultToken: a.token }, + { + token: a.token + ".end", + regex: a.end || a.start, + next: "pop" + } + ), + (a.token = a.token + ".start"), + (a.push = !0))); + var l = a.next || a.push; + if (l && Array.isArray(l)) { + var c = a.stateName; + (c || + ((c = a.token), + typeof c != "string" && (c = c[0] || ""), + r[c] && (c += n++)), + (r[c] = l), + (a.next = c), + i(c)); + } else l == "pop" && (a.next = t); + a.push && + ((a.nextState = a.next || a.push), (a.next = e), delete a.push); + if (a.rules) + for (var h in a.rules) + r[h] + ? r[h].push && r[h].push.apply(r[h], a.rules[h]) + : (r[h] = a.rules[h]); + var p = + typeof a == "string" + ? a + : typeof a.include == "string" + ? a.include + : ""; + p && (f = r[p]); + if (f) { + var d = [u, 1].concat(f); + (a.noEscape && + (d = d.filter(function (e) { + return !e.next; + })), + o.splice.apply(o, d), + u--); + } + a.keywordMap && + ((a.token = this.createKeywordMapper( + a.keywordMap, + a.defaultToken || "text", + a.caseInsensitive + )), + delete a.defaultToken); } - }); - }; - (p.isSaneInsertion = function(e, t) { - var n = e.getCursorPosition(), - r = new s(t, n.row, n.column); - if (!this.$matchTokenType(r.getCurrentToken() || "text", u)) { - var i = new s(t, n.row, n.column + 1); - if (!this.$matchTokenType(i.getCurrentToken() || "text", u)) return !1; - } - return ( - r.stepForward(), - r.getCurrentTokenRow() !== n.row || - this.$matchTokenType(r.getCurrentToken() || "text", a) - ); - }), - (p.$matchTokenType = function(e, t) { - return t.indexOf(e.type || e) > -1; - }), - (p.recordAutoInsert = function(e, t, n) { - var r = e.getCursorPosition(), - i = t.doc.getLine(r.row); - this.isAutoInsertedClosing(r, i, f.autoInsertedLineEnd[0]) || - (f.autoInsertedBrackets = 0), - (f.autoInsertedRow = r.row), - (f.autoInsertedLineEnd = n + i.substr(r.column)), - f.autoInsertedBrackets++; - }), - (p.recordMaybeInsert = function(e, t, n) { - var r = e.getCursorPosition(), - i = t.doc.getLine(r.row); - this.isMaybeInsertedClosing(r, i) || (f.maybeInsertedBrackets = 0), - (f.maybeInsertedRow = r.row), - (f.maybeInsertedLineStart = i.substr(0, r.column) + n), - (f.maybeInsertedLineEnd = i.substr(r.column)), - f.maybeInsertedBrackets++; - }), - (p.isAutoInsertedClosing = function(e, t, n) { - return ( - f.autoInsertedBrackets > 0 && - e.row === f.autoInsertedRow && - n === f.autoInsertedLineEnd[0] && - t.substr(e.column) === f.autoInsertedLineEnd - ); - }), - (p.isMaybeInsertedClosing = function(e, t) { + } + var n = 0, + r = this.$rules; + Object.keys(r).forEach(i, this); + }), + (this.createKeywordMapper = function (e, t, n, r) { + var i = Object.create(null); + return ( + Object.keys(e).forEach(function (t) { + var s = e[t]; + n && (s = s.toLowerCase()); + var o = s.split(r || "|"); + for (var u = o.length; u--;) i[o[u]] = t; + }), + Object.getPrototypeOf(i) && (i.__proto__ = null), + (this.$keywordList = Object.keys(i)), + (e = null), + n + ? function (e) { + return i[e.toLowerCase()] || t; + } + : function (e) { + return i[e] || t; + } + ); + }), + (this.getKeywords = function () { + return this.$keywords; + })); + }).call(i.prototype), + (t.TextHighlightRules = i)); + } + ), + define( + "ace/mode/behaviour", + ["require", "exports", "module"], + function (e, t, n) { + "use strict"; + var r = function () { + this.$behaviours = {}; + }; + ((function () { + ((this.add = function (e, t, n) { + switch (undefined) { + case this.$behaviours: + this.$behaviours = {}; + case this.$behaviours[e]: + this.$behaviours[e] = {}; + } + this.$behaviours[e][t] = n; + }), + (this.addBehaviours = function (e) { + for (var t in e) for (var n in e[t]) this.add(t, n, e[t][n]); + }), + (this.remove = function (e) { + this.$behaviours && + this.$behaviours[e] && + delete this.$behaviours[e]; + }), + (this.inherit = function (e, t) { + if (typeof e == "function") var n = new e().getBehaviours(t); + else var n = e.getBehaviours(t); + this.addBehaviours(n); + }), + (this.getBehaviours = function (e) { + if (!e) return this.$behaviours; + var t = {}; + for (var n = 0; n < e.length; n++) + this.$behaviours[e[n]] && (t[e[n]] = this.$behaviours[e[n]]); + return t; + })); + }).call(r.prototype), + (t.Behaviour = r)); + } + ), + define( + "ace/token_iterator", + ["require", "exports", "module"], + function (e, t, n) { + "use strict"; + var r = function (e, t, n) { + ((this.$session = e), + (this.$row = t), + (this.$rowTokens = e.getTokens(t))); + var r = e.getTokenAt(t, n); + this.$tokenIndex = r ? r.index : -1; + }; + ((function () { + ((this.stepBackward = function () { + this.$tokenIndex -= 1; + while (this.$tokenIndex < 0) { + this.$row -= 1; + if (this.$row < 0) return ((this.$row = 0), null); + ((this.$rowTokens = this.$session.getTokens(this.$row)), + (this.$tokenIndex = this.$rowTokens.length - 1)); + } + return this.$rowTokens[this.$tokenIndex]; + }), + (this.stepForward = function () { + this.$tokenIndex += 1; + var e; + while (this.$tokenIndex >= this.$rowTokens.length) { + ((this.$row += 1), e || (e = this.$session.getLength())); + if (this.$row >= e) return ((this.$row = e - 1), null); + ((this.$rowTokens = this.$session.getTokens(this.$row)), + (this.$tokenIndex = 0)); + } + return this.$rowTokens[this.$tokenIndex]; + }), + (this.getCurrentToken = function () { + return this.$rowTokens[this.$tokenIndex]; + }), + (this.getCurrentTokenRow = function () { + return this.$row; + }), + (this.getCurrentTokenColumn = function () { + var e = this.$rowTokens, + t = this.$tokenIndex, + n = e[t].start; + if (n !== undefined) return n; + n = 0; + while (t > 0) ((t -= 1), (n += e[t].value.length)); + return n; + }), + (this.getCurrentTokenPosition = function () { + return { row: this.$row, column: this.getCurrentTokenColumn() }; + })); + }).call(r.prototype), + (t.TokenIterator = r)); + } + ), + define( + "ace/mode/behaviour/cstyle", + [ + "require", + "exports", + "module", + "ace/lib/oop", + "ace/mode/behaviour", + "ace/token_iterator", + "ace/lib/lang" + ], + function (e, t, n) { + "use strict"; + var r = e("../../lib/oop"), + i = e("../behaviour").Behaviour, + s = e("../../token_iterator").TokenIterator, + o = e("../../lib/lang"), + u = ["text", "paren.rparen", "punctuation.operator"], + a = ["text", "paren.rparen", "punctuation.operator", "comment"], + f, + l = {}, + c = function (e) { + var t = -1; + e.multiSelect && + ((t = e.selection.index), + l.rangeCount != e.multiSelect.rangeCount && + (l = { rangeCount: e.multiSelect.rangeCount })); + if (l[t]) return (f = l[t]); + f = l[t] = { + autoInsertedBrackets: 0, + autoInsertedRow: -1, + autoInsertedLineEnd: "", + maybeInsertedBrackets: 0, + maybeInsertedRow: -1, + maybeInsertedLineStart: "", + maybeInsertedLineEnd: "" + }; + }, + h = function (e, t, n, r) { + var i = e.end.row - e.start.row; + return { + text: n + t + r, + selection: [0, e.start.column + 1, i, e.end.column + (i ? 0 : 1)] + }; + }, + p = function () { + (this.add("braces", "insertion", function (e, t, n, r, i) { + var s = n.getCursorPosition(), + u = r.doc.getLine(s.row); + if (i == "{") { + c(n); + var a = n.getSelectionRange(), + l = r.doc.getTextRange(a); + if (l !== "" && l !== "{" && n.getWrapBehavioursEnabled()) + return h(a, l, "{", "}"); + if (p.isSaneInsertion(n, r)) + return /[\]\}\)]/.test(u[s.column]) || n.inMultiSelectMode + ? (p.recordAutoInsert(n, r, "}"), + { text: "{}", selection: [1, 1] }) + : (p.recordMaybeInsert(n, r, "{"), + { text: "{", selection: [1, 1] }); + } else if (i == "}") { + c(n); + var d = u.substring(s.column, s.column + 1); + if (d == "}") { + var v = r.$findOpeningBracket("}", { + column: s.column + 1, + row: s.row + }); + if (v !== null && p.isAutoInsertedClosing(s, u, i)) + return ( + p.popAutoInsertedClosing(), + { text: "", selection: [1, 1] } + ); + } + } else { + if (i == "\n" || i == "\r\n") { + c(n); + var m = ""; + p.isMaybeInsertedClosing(s, u) && + ((m = o.stringRepeat("}", f.maybeInsertedBrackets)), + p.clearMaybeInsertedClosing()); + var d = u.substring(s.column, s.column + 1); + if (d === "}") { + var g = r.findMatchingBracket( + { row: s.row, column: s.column + 1 }, + "}" + ); + if (!g) return null; + var y = this.$getIndent(r.getLine(g.row)); + } else { + if (!m) { + p.clearMaybeInsertedClosing(); + return; + } + var y = this.$getIndent(u); + } + var b = y + r.getTabString(); + return { + text: "\n" + b + "\n" + y + m, + selection: [1, b.length, 1, b.length] + }; + } + p.clearMaybeInsertedClosing(); + } + }), + this.add("braces", "deletion", function (e, t, n, r, i) { + var s = r.doc.getTextRange(i); + if (!i.isMultiLine() && s == "{") { + c(n); + var o = r.doc.getLine(i.start.row), + u = o.substring(i.end.column, i.end.column + 1); + if (u == "}") return (i.end.column++, i); + f.maybeInsertedBrackets--; + } + }), + this.add("parens", "insertion", function (e, t, n, r, i) { + if (i == "(") { + c(n); + var s = n.getSelectionRange(), + o = r.doc.getTextRange(s); + if (o !== "" && n.getWrapBehavioursEnabled()) + return h(s, o, "(", ")"); + if (p.isSaneInsertion(n, r)) + return ( + p.recordAutoInsert(n, r, ")"), + { text: "()", selection: [1, 1] } + ); + } else if (i == ")") { + c(n); + var u = n.getCursorPosition(), + a = r.doc.getLine(u.row), + f = a.substring(u.column, u.column + 1); + if (f == ")") { + var l = r.$findOpeningBracket(")", { + column: u.column + 1, + row: u.row + }); + if (l !== null && p.isAutoInsertedClosing(u, a, i)) + return ( + p.popAutoInsertedClosing(), + { text: "", selection: [1, 1] } + ); + } + } + }), + this.add("parens", "deletion", function (e, t, n, r, i) { + var s = r.doc.getTextRange(i); + if (!i.isMultiLine() && s == "(") { + c(n); + var o = r.doc.getLine(i.start.row), + u = o.substring(i.start.column + 1, i.start.column + 2); + if (u == ")") return (i.end.column++, i); + } + }), + this.add("brackets", "insertion", function (e, t, n, r, i) { + if (i == "[") { + c(n); + var s = n.getSelectionRange(), + o = r.doc.getTextRange(s); + if (o !== "" && n.getWrapBehavioursEnabled()) + return h(s, o, "[", "]"); + if (p.isSaneInsertion(n, r)) + return ( + p.recordAutoInsert(n, r, "]"), + { text: "[]", selection: [1, 1] } + ); + } else if (i == "]") { + c(n); + var u = n.getCursorPosition(), + a = r.doc.getLine(u.row), + f = a.substring(u.column, u.column + 1); + if (f == "]") { + var l = r.$findOpeningBracket("]", { + column: u.column + 1, + row: u.row + }); + if (l !== null && p.isAutoInsertedClosing(u, a, i)) + return ( + p.popAutoInsertedClosing(), + { text: "", selection: [1, 1] } + ); + } + } + }), + this.add("brackets", "deletion", function (e, t, n, r, i) { + var s = r.doc.getTextRange(i); + if (!i.isMultiLine() && s == "[") { + c(n); + var o = r.doc.getLine(i.start.row), + u = o.substring(i.start.column + 1, i.start.column + 2); + if (u == "]") return (i.end.column++, i); + } + }), + this.add("string_dquotes", "insertion", function (e, t, n, r, i) { + if (i == '"' || i == "'") { + if ( + this.lineCommentStart && + this.lineCommentStart.indexOf(i) != -1 + ) + return; + c(n); + var s = i, + o = n.getSelectionRange(), + u = r.doc.getTextRange(o); + if ( + u !== "" && + u !== "'" && + u != '"' && + n.getWrapBehavioursEnabled() + ) + return h(o, u, s, s); + if (!u) { + var a = n.getCursorPosition(), + f = r.doc.getLine(a.row), + l = f.substring(a.column - 1, a.column), + p = f.substring(a.column, a.column + 1), + d = r.getTokenAt(a.row, a.column), + v = r.getTokenAt(a.row, a.column + 1); + if (l == "\\" && d && /escape/.test(d.type)) return null; + var m = d && /string|escape/.test(d.type), + g = !v || /string|escape/.test(v.type), + y; + if (p == s) + ((y = m !== g), + y && /string\.end/.test(v.type) && (y = !1)); + else { + if (m && !g) return null; + if (m && g) return null; + var b = r.$mode.tokenRe; + b.lastIndex = 0; + var w = b.test(l); + b.lastIndex = 0; + var E = b.test(l); + if (w || E) return null; + if (p && !/[\s;,.})\]\\]/.test(p)) return null; + y = !0; + } + return { text: y ? s + s : "", selection: [1, 1] }; + } + } + }), + this.add("string_dquotes", "deletion", function (e, t, n, r, i) { + var s = r.doc.getTextRange(i); + if (!i.isMultiLine() && (s == '"' || s == "'")) { + c(n); + var o = r.doc.getLine(i.start.row), + u = o.substring(i.start.column + 1, i.start.column + 2); + if (u == s) return (i.end.column++, i); + } + })); + }; + ((p.isSaneInsertion = function (e, t) { + var n = e.getCursorPosition(), + r = new s(t, n.row, n.column); + if (!this.$matchTokenType(r.getCurrentToken() || "text", u)) { + var i = new s(t, n.row, n.column + 1); + if (!this.$matchTokenType(i.getCurrentToken() || "text", u)) + return !1; + } return ( - f.maybeInsertedBrackets > 0 && - e.row === f.maybeInsertedRow && - t.substr(e.column) === f.maybeInsertedLineEnd && - t.substr(0, e.column) == f.maybeInsertedLineStart + r.stepForward(), + r.getCurrentTokenRow() !== n.row || + this.$matchTokenType(r.getCurrentToken() || "text", a) ); }), - (p.popAutoInsertedClosing = function() { - (f.autoInsertedLineEnd = f.autoInsertedLineEnd.substr(1)), - f.autoInsertedBrackets--; - }), - (p.clearMaybeInsertedClosing = function() { - f && ((f.maybeInsertedBrackets = 0), (f.maybeInsertedRow = -1)); - }), - r.inherits(p, i), - (t.CstyleBehaviour = p); - }), - define("ace/unicode", ["require", "exports", "module"], function(e, t, n) { + (p.$matchTokenType = function (e, t) { + return t.indexOf(e.type || e) > -1; + }), + (p.recordAutoInsert = function (e, t, n) { + var r = e.getCursorPosition(), + i = t.doc.getLine(r.row); + (this.isAutoInsertedClosing(r, i, f.autoInsertedLineEnd[0]) || + (f.autoInsertedBrackets = 0), + (f.autoInsertedRow = r.row), + (f.autoInsertedLineEnd = n + i.substr(r.column)), + f.autoInsertedBrackets++); + }), + (p.recordMaybeInsert = function (e, t, n) { + var r = e.getCursorPosition(), + i = t.doc.getLine(r.row); + (this.isMaybeInsertedClosing(r, i) || (f.maybeInsertedBrackets = 0), + (f.maybeInsertedRow = r.row), + (f.maybeInsertedLineStart = i.substr(0, r.column) + n), + (f.maybeInsertedLineEnd = i.substr(r.column)), + f.maybeInsertedBrackets++); + }), + (p.isAutoInsertedClosing = function (e, t, n) { + return ( + f.autoInsertedBrackets > 0 && + e.row === f.autoInsertedRow && + n === f.autoInsertedLineEnd[0] && + t.substr(e.column) === f.autoInsertedLineEnd + ); + }), + (p.isMaybeInsertedClosing = function (e, t) { + return ( + f.maybeInsertedBrackets > 0 && + e.row === f.maybeInsertedRow && + t.substr(e.column) === f.maybeInsertedLineEnd && + t.substr(0, e.column) == f.maybeInsertedLineStart + ); + }), + (p.popAutoInsertedClosing = function () { + ((f.autoInsertedLineEnd = f.autoInsertedLineEnd.substr(1)), + f.autoInsertedBrackets--); + }), + (p.clearMaybeInsertedClosing = function () { + f && ((f.maybeInsertedBrackets = 0), (f.maybeInsertedRow = -1)); + }), + r.inherits(p, i), + (t.CstyleBehaviour = p)); + } + ), + define("ace/unicode", ["require", "exports", "module"], function (e, t, n) { "use strict"; function r(e) { var n = /\w{4}/g; for (var r in e) t.packages[r] = e[r].replace(n, "\\u$&"); } - (t.packages = {}), + ((t.packages = {}), r({ - L: - "0041-005A0061-007A00AA00B500BA00C0-00D600D8-00F600F8-02C102C6-02D102E0-02E402EC02EE0370-037403760377037A-037D03860388-038A038C038E-03A103A3-03F503F7-0481048A-05250531-055605590561-058705D0-05EA05F0-05F20621-064A066E066F0671-06D306D506E506E606EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA07F407F507FA0800-0815081A082408280904-0939093D09500958-0961097109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E460E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EC60EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10A0-10C510D0-10FA10FC1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317D717DC1820-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541AA71B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C7D1CE9-1CEC1CEE-1CF11D00-1DBF1E00-1F151F18-1F1D1F20-1F451F48-1F4D1F50-1F571F591F5B1F5D1F5F-1F7D1F80-1FB41FB6-1FBC1FBE1FC2-1FC41FC6-1FCC1FD0-1FD31FD6-1FDB1FE0-1FEC1FF2-1FF41FF6-1FFC2071207F2090-209421022107210A-211321152119-211D212421262128212A-212D212F-2139213C-213F2145-2149214E218321842C00-2C2E2C30-2C5E2C60-2CE42CEB-2CEE2D00-2D252D30-2D652D6F2D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE2E2F300530063031-3035303B303C3041-3096309D-309F30A1-30FA30FC-30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A48CA4D0-A4FDA500-A60CA610-A61FA62AA62BA640-A65FA662-A66EA67F-A697A6A0-A6E5A717-A71FA722-A788A78BA78CA7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2A9CFAA00-AA28AA40-AA42AA44-AA4BAA60-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADB-AADDABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB00-FB06FB13-FB17FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF21-FF3AFF41-FF5AFF66-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC", - Ll: - "0061-007A00AA00B500BA00DF-00F600F8-00FF01010103010501070109010B010D010F01110113011501170119011B011D011F01210123012501270129012B012D012F01310133013501370138013A013C013E014001420144014601480149014B014D014F01510153015501570159015B015D015F01610163016501670169016B016D016F0171017301750177017A017C017E-0180018301850188018C018D019201950199-019B019E01A101A301A501A801AA01AB01AD01B001B401B601B901BA01BD-01BF01C601C901CC01CE01D001D201D401D601D801DA01DC01DD01DF01E101E301E501E701E901EB01ED01EF01F001F301F501F901FB01FD01FF02010203020502070209020B020D020F02110213021502170219021B021D021F02210223022502270229022B022D022F02310233-0239023C023F0240024202470249024B024D024F-02930295-02AF037103730377037B-037D039003AC-03CE03D003D103D5-03D703D903DB03DD03DF03E103E303E503E703E903EB03ED03EF-03F303F503F803FB03FC0430-045F04610463046504670469046B046D046F04710473047504770479047B047D047F0481048B048D048F04910493049504970499049B049D049F04A104A304A504A704A904AB04AD04AF04B104B304B504B704B904BB04BD04BF04C204C404C604C804CA04CC04CE04CF04D104D304D504D704D904DB04DD04DF04E104E304E504E704E904EB04ED04EF04F104F304F504F704F904FB04FD04FF05010503050505070509050B050D050F05110513051505170519051B051D051F0521052305250561-05871D00-1D2B1D62-1D771D79-1D9A1E011E031E051E071E091E0B1E0D1E0F1E111E131E151E171E191E1B1E1D1E1F1E211E231E251E271E291E2B1E2D1E2F1E311E331E351E371E391E3B1E3D1E3F1E411E431E451E471E491E4B1E4D1E4F1E511E531E551E571E591E5B1E5D1E5F1E611E631E651E671E691E6B1E6D1E6F1E711E731E751E771E791E7B1E7D1E7F1E811E831E851E871E891E8B1E8D1E8F1E911E931E95-1E9D1E9F1EA11EA31EA51EA71EA91EAB1EAD1EAF1EB11EB31EB51EB71EB91EBB1EBD1EBF1EC11EC31EC51EC71EC91ECB1ECD1ECF1ED11ED31ED51ED71ED91EDB1EDD1EDF1EE11EE31EE51EE71EE91EEB1EED1EEF1EF11EF31EF51EF71EF91EFB1EFD1EFF-1F071F10-1F151F20-1F271F30-1F371F40-1F451F50-1F571F60-1F671F70-1F7D1F80-1F871F90-1F971FA0-1FA71FB0-1FB41FB61FB71FBE1FC2-1FC41FC61FC71FD0-1FD31FD61FD71FE0-1FE71FF2-1FF41FF61FF7210A210E210F2113212F21342139213C213D2146-2149214E21842C30-2C5E2C612C652C662C682C6A2C6C2C712C732C742C76-2C7C2C812C832C852C872C892C8B2C8D2C8F2C912C932C952C972C992C9B2C9D2C9F2CA12CA32CA52CA72CA92CAB2CAD2CAF2CB12CB32CB52CB72CB92CBB2CBD2CBF2CC12CC32CC52CC72CC92CCB2CCD2CCF2CD12CD32CD52CD72CD92CDB2CDD2CDF2CE12CE32CE42CEC2CEE2D00-2D25A641A643A645A647A649A64BA64DA64FA651A653A655A657A659A65BA65DA65FA663A665A667A669A66BA66DA681A683A685A687A689A68BA68DA68FA691A693A695A697A723A725A727A729A72BA72DA72F-A731A733A735A737A739A73BA73DA73FA741A743A745A747A749A74BA74DA74FA751A753A755A757A759A75BA75DA75FA761A763A765A767A769A76BA76DA76FA771-A778A77AA77CA77FA781A783A785A787A78CFB00-FB06FB13-FB17FF41-FF5A", - Lu: - "0041-005A00C0-00D600D8-00DE01000102010401060108010A010C010E01100112011401160118011A011C011E01200122012401260128012A012C012E01300132013401360139013B013D013F0141014301450147014A014C014E01500152015401560158015A015C015E01600162016401660168016A016C016E017001720174017601780179017B017D018101820184018601870189-018B018E-0191019301940196-0198019C019D019F01A001A201A401A601A701A901AC01AE01AF01B1-01B301B501B701B801BC01C401C701CA01CD01CF01D101D301D501D701D901DB01DE01E001E201E401E601E801EA01EC01EE01F101F401F6-01F801FA01FC01FE02000202020402060208020A020C020E02100212021402160218021A021C021E02200222022402260228022A022C022E02300232023A023B023D023E02410243-02460248024A024C024E03700372037603860388-038A038C038E038F0391-03A103A3-03AB03CF03D2-03D403D803DA03DC03DE03E003E203E403E603E803EA03EC03EE03F403F703F903FA03FD-042F04600462046404660468046A046C046E04700472047404760478047A047C047E0480048A048C048E04900492049404960498049A049C049E04A004A204A404A604A804AA04AC04AE04B004B204B404B604B804BA04BC04BE04C004C104C304C504C704C904CB04CD04D004D204D404D604D804DA04DC04DE04E004E204E404E604E804EA04EC04EE04F004F204F404F604F804FA04FC04FE05000502050405060508050A050C050E05100512051405160518051A051C051E0520052205240531-055610A0-10C51E001E021E041E061E081E0A1E0C1E0E1E101E121E141E161E181E1A1E1C1E1E1E201E221E241E261E281E2A1E2C1E2E1E301E321E341E361E381E3A1E3C1E3E1E401E421E441E461E481E4A1E4C1E4E1E501E521E541E561E581E5A1E5C1E5E1E601E621E641E661E681E6A1E6C1E6E1E701E721E741E761E781E7A1E7C1E7E1E801E821E841E861E881E8A1E8C1E8E1E901E921E941E9E1EA01EA21EA41EA61EA81EAA1EAC1EAE1EB01EB21EB41EB61EB81EBA1EBC1EBE1EC01EC21EC41EC61EC81ECA1ECC1ECE1ED01ED21ED41ED61ED81EDA1EDC1EDE1EE01EE21EE41EE61EE81EEA1EEC1EEE1EF01EF21EF41EF61EF81EFA1EFC1EFE1F08-1F0F1F18-1F1D1F28-1F2F1F38-1F3F1F48-1F4D1F591F5B1F5D1F5F1F68-1F6F1FB8-1FBB1FC8-1FCB1FD8-1FDB1FE8-1FEC1FF8-1FFB21022107210B-210D2110-211221152119-211D212421262128212A-212D2130-2133213E213F214521832C00-2C2E2C602C62-2C642C672C692C6B2C6D-2C702C722C752C7E-2C802C822C842C862C882C8A2C8C2C8E2C902C922C942C962C982C9A2C9C2C9E2CA02CA22CA42CA62CA82CAA2CAC2CAE2CB02CB22CB42CB62CB82CBA2CBC2CBE2CC02CC22CC42CC62CC82CCA2CCC2CCE2CD02CD22CD42CD62CD82CDA2CDC2CDE2CE02CE22CEB2CEDA640A642A644A646A648A64AA64CA64EA650A652A654A656A658A65AA65CA65EA662A664A666A668A66AA66CA680A682A684A686A688A68AA68CA68EA690A692A694A696A722A724A726A728A72AA72CA72EA732A734A736A738A73AA73CA73EA740A742A744A746A748A74AA74CA74EA750A752A754A756A758A75AA75CA75EA760A762A764A766A768A76AA76CA76EA779A77BA77DA77EA780A782A784A786A78BFF21-FF3A", + L: "0041-005A0061-007A00AA00B500BA00C0-00D600D8-00F600F8-02C102C6-02D102E0-02E402EC02EE0370-037403760377037A-037D03860388-038A038C038E-03A103A3-03F503F7-0481048A-05250531-055605590561-058705D0-05EA05F0-05F20621-064A066E066F0671-06D306D506E506E606EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA07F407F507FA0800-0815081A082408280904-0939093D09500958-0961097109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E460E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EC60EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10A0-10C510D0-10FA10FC1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317D717DC1820-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541AA71B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C7D1CE9-1CEC1CEE-1CF11D00-1DBF1E00-1F151F18-1F1D1F20-1F451F48-1F4D1F50-1F571F591F5B1F5D1F5F-1F7D1F80-1FB41FB6-1FBC1FBE1FC2-1FC41FC6-1FCC1FD0-1FD31FD6-1FDB1FE0-1FEC1FF2-1FF41FF6-1FFC2071207F2090-209421022107210A-211321152119-211D212421262128212A-212D212F-2139213C-213F2145-2149214E218321842C00-2C2E2C30-2C5E2C60-2CE42CEB-2CEE2D00-2D252D30-2D652D6F2D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE2E2F300530063031-3035303B303C3041-3096309D-309F30A1-30FA30FC-30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A48CA4D0-A4FDA500-A60CA610-A61FA62AA62BA640-A65FA662-A66EA67F-A697A6A0-A6E5A717-A71FA722-A788A78BA78CA7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2A9CFAA00-AA28AA40-AA42AA44-AA4BAA60-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADB-AADDABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB00-FB06FB13-FB17FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF21-FF3AFF41-FF5AFF66-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC", + Ll: "0061-007A00AA00B500BA00DF-00F600F8-00FF01010103010501070109010B010D010F01110113011501170119011B011D011F01210123012501270129012B012D012F01310133013501370138013A013C013E014001420144014601480149014B014D014F01510153015501570159015B015D015F01610163016501670169016B016D016F0171017301750177017A017C017E-0180018301850188018C018D019201950199-019B019E01A101A301A501A801AA01AB01AD01B001B401B601B901BA01BD-01BF01C601C901CC01CE01D001D201D401D601D801DA01DC01DD01DF01E101E301E501E701E901EB01ED01EF01F001F301F501F901FB01FD01FF02010203020502070209020B020D020F02110213021502170219021B021D021F02210223022502270229022B022D022F02310233-0239023C023F0240024202470249024B024D024F-02930295-02AF037103730377037B-037D039003AC-03CE03D003D103D5-03D703D903DB03DD03DF03E103E303E503E703E903EB03ED03EF-03F303F503F803FB03FC0430-045F04610463046504670469046B046D046F04710473047504770479047B047D047F0481048B048D048F04910493049504970499049B049D049F04A104A304A504A704A904AB04AD04AF04B104B304B504B704B904BB04BD04BF04C204C404C604C804CA04CC04CE04CF04D104D304D504D704D904DB04DD04DF04E104E304E504E704E904EB04ED04EF04F104F304F504F704F904FB04FD04FF05010503050505070509050B050D050F05110513051505170519051B051D051F0521052305250561-05871D00-1D2B1D62-1D771D79-1D9A1E011E031E051E071E091E0B1E0D1E0F1E111E131E151E171E191E1B1E1D1E1F1E211E231E251E271E291E2B1E2D1E2F1E311E331E351E371E391E3B1E3D1E3F1E411E431E451E471E491E4B1E4D1E4F1E511E531E551E571E591E5B1E5D1E5F1E611E631E651E671E691E6B1E6D1E6F1E711E731E751E771E791E7B1E7D1E7F1E811E831E851E871E891E8B1E8D1E8F1E911E931E95-1E9D1E9F1EA11EA31EA51EA71EA91EAB1EAD1EAF1EB11EB31EB51EB71EB91EBB1EBD1EBF1EC11EC31EC51EC71EC91ECB1ECD1ECF1ED11ED31ED51ED71ED91EDB1EDD1EDF1EE11EE31EE51EE71EE91EEB1EED1EEF1EF11EF31EF51EF71EF91EFB1EFD1EFF-1F071F10-1F151F20-1F271F30-1F371F40-1F451F50-1F571F60-1F671F70-1F7D1F80-1F871F90-1F971FA0-1FA71FB0-1FB41FB61FB71FBE1FC2-1FC41FC61FC71FD0-1FD31FD61FD71FE0-1FE71FF2-1FF41FF61FF7210A210E210F2113212F21342139213C213D2146-2149214E21842C30-2C5E2C612C652C662C682C6A2C6C2C712C732C742C76-2C7C2C812C832C852C872C892C8B2C8D2C8F2C912C932C952C972C992C9B2C9D2C9F2CA12CA32CA52CA72CA92CAB2CAD2CAF2CB12CB32CB52CB72CB92CBB2CBD2CBF2CC12CC32CC52CC72CC92CCB2CCD2CCF2CD12CD32CD52CD72CD92CDB2CDD2CDF2CE12CE32CE42CEC2CEE2D00-2D25A641A643A645A647A649A64BA64DA64FA651A653A655A657A659A65BA65DA65FA663A665A667A669A66BA66DA681A683A685A687A689A68BA68DA68FA691A693A695A697A723A725A727A729A72BA72DA72F-A731A733A735A737A739A73BA73DA73FA741A743A745A747A749A74BA74DA74FA751A753A755A757A759A75BA75DA75FA761A763A765A767A769A76BA76DA76FA771-A778A77AA77CA77FA781A783A785A787A78CFB00-FB06FB13-FB17FF41-FF5A", + Lu: "0041-005A00C0-00D600D8-00DE01000102010401060108010A010C010E01100112011401160118011A011C011E01200122012401260128012A012C012E01300132013401360139013B013D013F0141014301450147014A014C014E01500152015401560158015A015C015E01600162016401660168016A016C016E017001720174017601780179017B017D018101820184018601870189-018B018E-0191019301940196-0198019C019D019F01A001A201A401A601A701A901AC01AE01AF01B1-01B301B501B701B801BC01C401C701CA01CD01CF01D101D301D501D701D901DB01DE01E001E201E401E601E801EA01EC01EE01F101F401F6-01F801FA01FC01FE02000202020402060208020A020C020E02100212021402160218021A021C021E02200222022402260228022A022C022E02300232023A023B023D023E02410243-02460248024A024C024E03700372037603860388-038A038C038E038F0391-03A103A3-03AB03CF03D2-03D403D803DA03DC03DE03E003E203E403E603E803EA03EC03EE03F403F703F903FA03FD-042F04600462046404660468046A046C046E04700472047404760478047A047C047E0480048A048C048E04900492049404960498049A049C049E04A004A204A404A604A804AA04AC04AE04B004B204B404B604B804BA04BC04BE04C004C104C304C504C704C904CB04CD04D004D204D404D604D804DA04DC04DE04E004E204E404E604E804EA04EC04EE04F004F204F404F604F804FA04FC04FE05000502050405060508050A050C050E05100512051405160518051A051C051E0520052205240531-055610A0-10C51E001E021E041E061E081E0A1E0C1E0E1E101E121E141E161E181E1A1E1C1E1E1E201E221E241E261E281E2A1E2C1E2E1E301E321E341E361E381E3A1E3C1E3E1E401E421E441E461E481E4A1E4C1E4E1E501E521E541E561E581E5A1E5C1E5E1E601E621E641E661E681E6A1E6C1E6E1E701E721E741E761E781E7A1E7C1E7E1E801E821E841E861E881E8A1E8C1E8E1E901E921E941E9E1EA01EA21EA41EA61EA81EAA1EAC1EAE1EB01EB21EB41EB61EB81EBA1EBC1EBE1EC01EC21EC41EC61EC81ECA1ECC1ECE1ED01ED21ED41ED61ED81EDA1EDC1EDE1EE01EE21EE41EE61EE81EEA1EEC1EEE1EF01EF21EF41EF61EF81EFA1EFC1EFE1F08-1F0F1F18-1F1D1F28-1F2F1F38-1F3F1F48-1F4D1F591F5B1F5D1F5F1F68-1F6F1FB8-1FBB1FC8-1FCB1FD8-1FDB1FE8-1FEC1FF8-1FFB21022107210B-210D2110-211221152119-211D212421262128212A-212D2130-2133213E213F214521832C00-2C2E2C602C62-2C642C672C692C6B2C6D-2C702C722C752C7E-2C802C822C842C862C882C8A2C8C2C8E2C902C922C942C962C982C9A2C9C2C9E2CA02CA22CA42CA62CA82CAA2CAC2CAE2CB02CB22CB42CB62CB82CBA2CBC2CBE2CC02CC22CC42CC62CC82CCA2CCC2CCE2CD02CD22CD42CD62CD82CDA2CDC2CDE2CE02CE22CEB2CEDA640A642A644A646A648A64AA64CA64EA650A652A654A656A658A65AA65CA65EA662A664A666A668A66AA66CA680A682A684A686A688A68AA68CA68EA690A692A694A696A722A724A726A728A72AA72CA72EA732A734A736A738A73AA73CA73EA740A742A744A746A748A74AA74CA74EA750A752A754A756A758A75AA75CA75EA760A762A764A766A768A76AA76CA76EA779A77BA77DA77EA780A782A784A786A78BFF21-FF3A", Lt: "01C501C801CB01F21F88-1F8F1F98-1F9F1FA8-1FAF1FBC1FCC1FFC", - Lm: - "02B0-02C102C6-02D102E0-02E402EC02EE0374037A0559064006E506E607F407F507FA081A0824082809710E460EC610FC17D718431AA71C78-1C7D1D2C-1D611D781D9B-1DBF2071207F2090-20942C7D2D6F2E2F30053031-3035303B309D309E30FC-30FEA015A4F8-A4FDA60CA67FA717-A71FA770A788A9CFAA70AADDFF70FF9EFF9F", - Lo: - "01BB01C0-01C3029405D0-05EA05F0-05F20621-063F0641-064A066E066F0671-06D306D506EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA0800-08150904-0939093D09500958-096109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E450E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10D0-10FA1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317DC1820-18421844-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C771CE9-1CEC1CEE-1CF12135-21382D30-2D652D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE3006303C3041-3096309F30A1-30FA30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A014A016-A48CA4D0-A4F7A500-A60BA610-A61FA62AA62BA66EA6A0-A6E5A7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2AA00-AA28AA40-AA42AA44-AA4BAA60-AA6FAA71-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADBAADCABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF66-FF6FFF71-FF9DFFA0-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC", - M: - "0300-036F0483-04890591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DE-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0903093C093E-094E0951-0955096209630981-098309BC09BE-09C409C709C809CB-09CD09D709E209E30A01-0A030A3C0A3E-0A420A470A480A4B-0A4D0A510A700A710A750A81-0A830ABC0ABE-0AC50AC7-0AC90ACB-0ACD0AE20AE30B01-0B030B3C0B3E-0B440B470B480B4B-0B4D0B560B570B620B630B820BBE-0BC20BC6-0BC80BCA-0BCD0BD70C01-0C030C3E-0C440C46-0C480C4A-0C4D0C550C560C620C630C820C830CBC0CBE-0CC40CC6-0CC80CCA-0CCD0CD50CD60CE20CE30D020D030D3E-0D440D46-0D480D4A-0D4D0D570D620D630D820D830DCA0DCF-0DD40DD60DD8-0DDF0DF20DF30E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F3E0F3F0F71-0F840F860F870F90-0F970F99-0FBC0FC6102B-103E1056-1059105E-10601062-10641067-106D1071-10741082-108D108F109A-109D135F1712-17141732-1734175217531772177317B6-17D317DD180B-180D18A91920-192B1930-193B19B0-19C019C819C91A17-1A1B1A55-1A5E1A60-1A7C1A7F1B00-1B041B34-1B441B6B-1B731B80-1B821BA1-1BAA1C24-1C371CD0-1CD21CD4-1CE81CED1CF21DC0-1DE61DFD-1DFF20D0-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66F-A672A67CA67DA6F0A6F1A802A806A80BA823-A827A880A881A8B4-A8C4A8E0-A8F1A926-A92DA947-A953A980-A983A9B3-A9C0AA29-AA36AA43AA4CAA4DAA7BAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE3-ABEAABECABEDFB1EFE00-FE0FFE20-FE26", - Mn: - "0300-036F0483-04870591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DF-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0902093C0941-0948094D0951-095509620963098109BC09C1-09C409CD09E209E30A010A020A3C0A410A420A470A480A4B-0A4D0A510A700A710A750A810A820ABC0AC1-0AC50AC70AC80ACD0AE20AE30B010B3C0B3F0B41-0B440B4D0B560B620B630B820BC00BCD0C3E-0C400C46-0C480C4A-0C4D0C550C560C620C630CBC0CBF0CC60CCC0CCD0CE20CE30D41-0D440D4D0D620D630DCA0DD2-0DD40DD60E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F71-0F7E0F80-0F840F860F870F90-0F970F99-0FBC0FC6102D-10301032-10371039103A103D103E10581059105E-10601071-1074108210851086108D109D135F1712-17141732-1734175217531772177317B7-17BD17C617C9-17D317DD180B-180D18A91920-19221927192819321939-193B1A171A181A561A58-1A5E1A601A621A65-1A6C1A73-1A7C1A7F1B00-1B031B341B36-1B3A1B3C1B421B6B-1B731B801B811BA2-1BA51BA81BA91C2C-1C331C361C371CD0-1CD21CD4-1CE01CE2-1CE81CED1DC0-1DE61DFD-1DFF20D0-20DC20E120E5-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66FA67CA67DA6F0A6F1A802A806A80BA825A826A8C4A8E0-A8F1A926-A92DA947-A951A980-A982A9B3A9B6-A9B9A9BCAA29-AA2EAA31AA32AA35AA36AA43AA4CAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE5ABE8ABEDFB1EFE00-FE0FFE20-FE26", - Mc: - "0903093E-09400949-094C094E0982098309BE-09C009C709C809CB09CC09D70A030A3E-0A400A830ABE-0AC00AC90ACB0ACC0B020B030B3E0B400B470B480B4B0B4C0B570BBE0BBF0BC10BC20BC6-0BC80BCA-0BCC0BD70C01-0C030C41-0C440C820C830CBE0CC0-0CC40CC70CC80CCA0CCB0CD50CD60D020D030D3E-0D400D46-0D480D4A-0D4C0D570D820D830DCF-0DD10DD8-0DDF0DF20DF30F3E0F3F0F7F102B102C10311038103B103C105610571062-10641067-106D108310841087-108C108F109A-109C17B617BE-17C517C717C81923-19261929-192B193019311933-193819B0-19C019C819C91A19-1A1B1A551A571A611A631A641A6D-1A721B041B351B3B1B3D-1B411B431B441B821BA11BA61BA71BAA1C24-1C2B1C341C351CE11CF2A823A824A827A880A881A8B4-A8C3A952A953A983A9B4A9B5A9BAA9BBA9BD-A9C0AA2FAA30AA33AA34AA4DAA7BABE3ABE4ABE6ABE7ABE9ABEAABEC", + Lm: "02B0-02C102C6-02D102E0-02E402EC02EE0374037A0559064006E506E607F407F507FA081A0824082809710E460EC610FC17D718431AA71C78-1C7D1D2C-1D611D781D9B-1DBF2071207F2090-20942C7D2D6F2E2F30053031-3035303B309D309E30FC-30FEA015A4F8-A4FDA60CA67FA717-A71FA770A788A9CFAA70AADDFF70FF9EFF9F", + Lo: "01BB01C0-01C3029405D0-05EA05F0-05F20621-063F0641-064A066E066F0671-06D306D506EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA0800-08150904-0939093D09500958-096109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E450E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10D0-10FA1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317DC1820-18421844-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C771CE9-1CEC1CEE-1CF12135-21382D30-2D652D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE3006303C3041-3096309F30A1-30FA30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A014A016-A48CA4D0-A4F7A500-A60BA610-A61FA62AA62BA66EA6A0-A6E5A7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2AA00-AA28AA40-AA42AA44-AA4BAA60-AA6FAA71-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADBAADCABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF66-FF6FFF71-FF9DFFA0-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC", + M: "0300-036F0483-04890591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DE-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0903093C093E-094E0951-0955096209630981-098309BC09BE-09C409C709C809CB-09CD09D709E209E30A01-0A030A3C0A3E-0A420A470A480A4B-0A4D0A510A700A710A750A81-0A830ABC0ABE-0AC50AC7-0AC90ACB-0ACD0AE20AE30B01-0B030B3C0B3E-0B440B470B480B4B-0B4D0B560B570B620B630B820BBE-0BC20BC6-0BC80BCA-0BCD0BD70C01-0C030C3E-0C440C46-0C480C4A-0C4D0C550C560C620C630C820C830CBC0CBE-0CC40CC6-0CC80CCA-0CCD0CD50CD60CE20CE30D020D030D3E-0D440D46-0D480D4A-0D4D0D570D620D630D820D830DCA0DCF-0DD40DD60DD8-0DDF0DF20DF30E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F3E0F3F0F71-0F840F860F870F90-0F970F99-0FBC0FC6102B-103E1056-1059105E-10601062-10641067-106D1071-10741082-108D108F109A-109D135F1712-17141732-1734175217531772177317B6-17D317DD180B-180D18A91920-192B1930-193B19B0-19C019C819C91A17-1A1B1A55-1A5E1A60-1A7C1A7F1B00-1B041B34-1B441B6B-1B731B80-1B821BA1-1BAA1C24-1C371CD0-1CD21CD4-1CE81CED1CF21DC0-1DE61DFD-1DFF20D0-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66F-A672A67CA67DA6F0A6F1A802A806A80BA823-A827A880A881A8B4-A8C4A8E0-A8F1A926-A92DA947-A953A980-A983A9B3-A9C0AA29-AA36AA43AA4CAA4DAA7BAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE3-ABEAABECABEDFB1EFE00-FE0FFE20-FE26", + Mn: "0300-036F0483-04870591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DF-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0902093C0941-0948094D0951-095509620963098109BC09C1-09C409CD09E209E30A010A020A3C0A410A420A470A480A4B-0A4D0A510A700A710A750A810A820ABC0AC1-0AC50AC70AC80ACD0AE20AE30B010B3C0B3F0B41-0B440B4D0B560B620B630B820BC00BCD0C3E-0C400C46-0C480C4A-0C4D0C550C560C620C630CBC0CBF0CC60CCC0CCD0CE20CE30D41-0D440D4D0D620D630DCA0DD2-0DD40DD60E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F71-0F7E0F80-0F840F860F870F90-0F970F99-0FBC0FC6102D-10301032-10371039103A103D103E10581059105E-10601071-1074108210851086108D109D135F1712-17141732-1734175217531772177317B7-17BD17C617C9-17D317DD180B-180D18A91920-19221927192819321939-193B1A171A181A561A58-1A5E1A601A621A65-1A6C1A73-1A7C1A7F1B00-1B031B341B36-1B3A1B3C1B421B6B-1B731B801B811BA2-1BA51BA81BA91C2C-1C331C361C371CD0-1CD21CD4-1CE01CE2-1CE81CED1DC0-1DE61DFD-1DFF20D0-20DC20E120E5-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66FA67CA67DA6F0A6F1A802A806A80BA825A826A8C4A8E0-A8F1A926-A92DA947-A951A980-A982A9B3A9B6-A9B9A9BCAA29-AA2EAA31AA32AA35AA36AA43AA4CAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE5ABE8ABEDFB1EFE00-FE0FFE20-FE26", + Mc: "0903093E-09400949-094C094E0982098309BE-09C009C709C809CB09CC09D70A030A3E-0A400A830ABE-0AC00AC90ACB0ACC0B020B030B3E0B400B470B480B4B0B4C0B570BBE0BBF0BC10BC20BC6-0BC80BCA-0BCC0BD70C01-0C030C41-0C440C820C830CBE0CC0-0CC40CC70CC80CCA0CCB0CD50CD60D020D030D3E-0D400D46-0D480D4A-0D4C0D570D820D830DCF-0DD10DD8-0DDF0DF20DF30F3E0F3F0F7F102B102C10311038103B103C105610571062-10641067-106D108310841087-108C108F109A-109C17B617BE-17C517C717C81923-19261929-192B193019311933-193819B0-19C019C819C91A19-1A1B1A551A571A611A631A641A6D-1A721B041B351B3B1B3D-1B411B431B441B821BA11BA61BA71BAA1C24-1C2B1C341C351CE11CF2A823A824A827A880A881A8B4-A8C3A952A953A983A9B4A9B5A9BAA9BBA9BD-A9C0AA2FAA30AA33AA34AA4DAA7BABE3ABE4ABE6ABE7ABE9ABEAABEC", Me: "0488048906DE20DD-20E020E2-20E4A670-A672", - N: - "0030-003900B200B300B900BC-00BE0660-066906F0-06F907C0-07C90966-096F09E6-09EF09F4-09F90A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BF20C66-0C6F0C78-0C7E0CE6-0CEF0D66-0D750E50-0E590ED0-0ED90F20-0F331040-10491090-10991369-137C16EE-16F017E0-17E917F0-17F91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C5920702074-20792080-20892150-21822185-21892460-249B24EA-24FF2776-27932CFD30073021-30293038-303A3192-31953220-32293251-325F3280-328932B1-32BFA620-A629A6E6-A6EFA830-A835A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19", - Nd: - "0030-00390660-066906F0-06F907C0-07C90966-096F09E6-09EF0A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BEF0C66-0C6F0CE6-0CEF0D66-0D6F0E50-0E590ED0-0ED90F20-0F291040-10491090-109917E0-17E91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C59A620-A629A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19", + N: "0030-003900B200B300B900BC-00BE0660-066906F0-06F907C0-07C90966-096F09E6-09EF09F4-09F90A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BF20C66-0C6F0C78-0C7E0CE6-0CEF0D66-0D750E50-0E590ED0-0ED90F20-0F331040-10491090-10991369-137C16EE-16F017E0-17E917F0-17F91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C5920702074-20792080-20892150-21822185-21892460-249B24EA-24FF2776-27932CFD30073021-30293038-303A3192-31953220-32293251-325F3280-328932B1-32BFA620-A629A6E6-A6EFA830-A835A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19", + Nd: "0030-00390660-066906F0-06F907C0-07C90966-096F09E6-09EF0A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BEF0C66-0C6F0CE6-0CEF0D66-0D6F0E50-0E590ED0-0ED90F20-0F291040-10491090-109917E0-17E91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C59A620-A629A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19", Nl: "16EE-16F02160-21822185-218830073021-30293038-303AA6E6-A6EF", - No: - "00B200B300B900BC-00BE09F4-09F90BF0-0BF20C78-0C7E0D70-0D750F2A-0F331369-137C17F0-17F920702074-20792080-20892150-215F21892460-249B24EA-24FF2776-27932CFD3192-31953220-32293251-325F3280-328932B1-32BFA830-A835", - P: - "0021-00230025-002A002C-002F003A003B003F0040005B-005D005F007B007D00A100AB00B700BB00BF037E0387055A-055F0589058A05BE05C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F3A-0F3D0F850FD0-0FD4104A-104F10FB1361-13681400166D166E169B169C16EB-16ED1735173617D4-17D617D8-17DA1800-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD32010-20272030-20432045-20512053-205E207D207E208D208E2329232A2768-277527C527C627E6-27EF2983-299829D8-29DB29FC29FD2CF9-2CFC2CFE2CFF2E00-2E2E2E302E313001-30033008-30113014-301F3030303D30A030FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFD3EFD3FFE10-FE19FE30-FE52FE54-FE61FE63FE68FE6AFE6BFF01-FF03FF05-FF0AFF0C-FF0FFF1AFF1BFF1FFF20FF3B-FF3DFF3FFF5BFF5DFF5F-FF65", - Pd: - "002D058A05BE140018062010-20152E172E1A301C303030A0FE31FE32FE58FE63FF0D", - Ps: - "0028005B007B0F3A0F3C169B201A201E2045207D208D23292768276A276C276E27702772277427C527E627E827EA27EC27EE2983298529872989298B298D298F299129932995299729D829DA29FC2E222E242E262E283008300A300C300E3010301430163018301A301DFD3EFE17FE35FE37FE39FE3BFE3DFE3FFE41FE43FE47FE59FE5BFE5DFF08FF3BFF5BFF5FFF62", - Pe: - "0029005D007D0F3B0F3D169C2046207E208E232A2769276B276D276F27712773277527C627E727E927EB27ED27EF298429862988298A298C298E2990299229942996299829D929DB29FD2E232E252E272E293009300B300D300F3011301530173019301B301E301FFD3FFE18FE36FE38FE3AFE3CFE3EFE40FE42FE44FE48FE5AFE5CFE5EFF09FF3DFF5DFF60FF63", + No: "00B200B300B900BC-00BE09F4-09F90BF0-0BF20C78-0C7E0D70-0D750F2A-0F331369-137C17F0-17F920702074-20792080-20892150-215F21892460-249B24EA-24FF2776-27932CFD3192-31953220-32293251-325F3280-328932B1-32BFA830-A835", + P: "0021-00230025-002A002C-002F003A003B003F0040005B-005D005F007B007D00A100AB00B700BB00BF037E0387055A-055F0589058A05BE05C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F3A-0F3D0F850FD0-0FD4104A-104F10FB1361-13681400166D166E169B169C16EB-16ED1735173617D4-17D617D8-17DA1800-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD32010-20272030-20432045-20512053-205E207D207E208D208E2329232A2768-277527C527C627E6-27EF2983-299829D8-29DB29FC29FD2CF9-2CFC2CFE2CFF2E00-2E2E2E302E313001-30033008-30113014-301F3030303D30A030FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFD3EFD3FFE10-FE19FE30-FE52FE54-FE61FE63FE68FE6AFE6BFF01-FF03FF05-FF0AFF0C-FF0FFF1AFF1BFF1FFF20FF3B-FF3DFF3FFF5BFF5DFF5F-FF65", + Pd: "002D058A05BE140018062010-20152E172E1A301C303030A0FE31FE32FE58FE63FF0D", + Ps: "0028005B007B0F3A0F3C169B201A201E2045207D208D23292768276A276C276E27702772277427C527E627E827EA27EC27EE2983298529872989298B298D298F299129932995299729D829DA29FC2E222E242E262E283008300A300C300E3010301430163018301A301DFD3EFE17FE35FE37FE39FE3BFE3DFE3FFE41FE43FE47FE59FE5BFE5DFF08FF3BFF5BFF5FFF62", + Pe: "0029005D007D0F3B0F3D169C2046207E208E232A2769276B276D276F27712773277527C627E727E927EB27ED27EF298429862988298A298C298E2990299229942996299829D929DB29FD2E232E252E272E293009300B300D300F3011301530173019301B301E301FFD3FFE18FE36FE38FE3AFE3CFE3EFE40FE42FE44FE48FE5AFE5CFE5EFF09FF3DFF5DFF60FF63", Pi: "00AB2018201B201C201F20392E022E042E092E0C2E1C2E20", Pf: "00BB2019201D203A2E032E052E0A2E0D2E1D2E21", Pc: "005F203F20402054FE33FE34FE4D-FE4FFF3F", - Po: - "0021-00230025-0027002A002C002E002F003A003B003F0040005C00A100B700BF037E0387055A-055F058905C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F850FD0-0FD4104A-104F10FB1361-1368166D166E16EB-16ED1735173617D4-17D617D8-17DA1800-18051807-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD3201620172020-20272030-2038203B-203E2041-20432047-205120532055-205E2CF9-2CFC2CFE2CFF2E002E012E06-2E082E0B2E0E-2E162E182E192E1B2E1E2E1F2E2A-2E2E2E302E313001-3003303D30FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFE10-FE16FE19FE30FE45FE46FE49-FE4CFE50-FE52FE54-FE57FE5F-FE61FE68FE6AFE6BFF01-FF03FF05-FF07FF0AFF0CFF0EFF0FFF1AFF1BFF1FFF20FF3CFF61FF64FF65", - S: - "0024002B003C-003E005E0060007C007E00A2-00A900AC00AE-00B100B400B600B800D700F702C2-02C502D2-02DF02E5-02EB02ED02EF-02FF03750384038503F604820606-0608060B060E060F06E906FD06FE07F609F209F309FA09FB0AF10B700BF3-0BFA0C7F0CF10CF20D790E3F0F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-139917DB194019E0-19FF1B61-1B6A1B74-1B7C1FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE20442052207A-207C208A-208C20A0-20B8210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B2140-2144214A-214D214F2190-2328232B-23E82400-24262440-244A249C-24E92500-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE27C0-27C427C7-27CA27CC27D0-27E527F0-29822999-29D729DC-29FB29FE-2B4C2B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F309B309C319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A700-A716A720A721A789A78AA828-A82BA836-A839AA77-AA79FB29FDFCFDFDFE62FE64-FE66FE69FF04FF0BFF1C-FF1EFF3EFF40FF5CFF5EFFE0-FFE6FFE8-FFEEFFFCFFFD", - Sm: - "002B003C-003E007C007E00AC00B100D700F703F60606-060820442052207A-207C208A-208C2140-2144214B2190-2194219A219B21A021A321A621AE21CE21CF21D221D421F4-22FF2308-230B23202321237C239B-23B323DC-23E125B725C125F8-25FF266F27C0-27C427C7-27CA27CC27D0-27E527F0-27FF2900-29822999-29D729DC-29FB29FE-2AFF2B30-2B442B47-2B4CFB29FE62FE64-FE66FF0BFF1C-FF1EFF5CFF5EFFE2FFE9-FFEC", - Sc: - "002400A2-00A5060B09F209F309FB0AF10BF90E3F17DB20A0-20B8A838FDFCFE69FF04FFE0FFE1FFE5FFE6", - Sk: - "005E006000A800AF00B400B802C2-02C502D2-02DF02E5-02EB02ED02EF-02FF0375038403851FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE309B309CA700-A716A720A721A789A78AFF3EFF40FFE3", - So: - "00A600A700A900AE00B000B60482060E060F06E906FD06FE07F609FA0B700BF3-0BF80BFA0C7F0CF10CF20D790F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-1399194019E0-19FF1B61-1B6A1B74-1B7C210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B214A214C214D214F2195-2199219C-219F21A121A221A421A521A7-21AD21AF-21CD21D021D121D321D5-21F32300-2307230C-231F2322-2328232B-237B237D-239A23B4-23DB23E2-23E82400-24262440-244A249C-24E92500-25B625B8-25C025C2-25F72600-266E2670-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE2800-28FF2B00-2B2F2B452B462B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A828-A82BA836A837A839AA77-AA79FDFDFFE4FFE8FFEDFFEEFFFCFFFD", + Po: "0021-00230025-0027002A002C002E002F003A003B003F0040005C00A100B700BF037E0387055A-055F058905C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F850FD0-0FD4104A-104F10FB1361-1368166D166E16EB-16ED1735173617D4-17D617D8-17DA1800-18051807-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD3201620172020-20272030-2038203B-203E2041-20432047-205120532055-205E2CF9-2CFC2CFE2CFF2E002E012E06-2E082E0B2E0E-2E162E182E192E1B2E1E2E1F2E2A-2E2E2E302E313001-3003303D30FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFE10-FE16FE19FE30FE45FE46FE49-FE4CFE50-FE52FE54-FE57FE5F-FE61FE68FE6AFE6BFF01-FF03FF05-FF07FF0AFF0CFF0EFF0FFF1AFF1BFF1FFF20FF3CFF61FF64FF65", + S: "0024002B003C-003E005E0060007C007E00A2-00A900AC00AE-00B100B400B600B800D700F702C2-02C502D2-02DF02E5-02EB02ED02EF-02FF03750384038503F604820606-0608060B060E060F06E906FD06FE07F609F209F309FA09FB0AF10B700BF3-0BFA0C7F0CF10CF20D790E3F0F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-139917DB194019E0-19FF1B61-1B6A1B74-1B7C1FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE20442052207A-207C208A-208C20A0-20B8210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B2140-2144214A-214D214F2190-2328232B-23E82400-24262440-244A249C-24E92500-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE27C0-27C427C7-27CA27CC27D0-27E527F0-29822999-29D729DC-29FB29FE-2B4C2B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F309B309C319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A700-A716A720A721A789A78AA828-A82BA836-A839AA77-AA79FB29FDFCFDFDFE62FE64-FE66FE69FF04FF0BFF1C-FF1EFF3EFF40FF5CFF5EFFE0-FFE6FFE8-FFEEFFFCFFFD", + Sm: "002B003C-003E007C007E00AC00B100D700F703F60606-060820442052207A-207C208A-208C2140-2144214B2190-2194219A219B21A021A321A621AE21CE21CF21D221D421F4-22FF2308-230B23202321237C239B-23B323DC-23E125B725C125F8-25FF266F27C0-27C427C7-27CA27CC27D0-27E527F0-27FF2900-29822999-29D729DC-29FB29FE-2AFF2B30-2B442B47-2B4CFB29FE62FE64-FE66FF0BFF1C-FF1EFF5CFF5EFFE2FFE9-FFEC", + Sc: "002400A2-00A5060B09F209F309FB0AF10BF90E3F17DB20A0-20B8A838FDFCFE69FF04FFE0FFE1FFE5FFE6", + Sk: "005E006000A800AF00B400B802C2-02C502D2-02DF02E5-02EB02ED02EF-02FF0375038403851FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE309B309CA700-A716A720A721A789A78AFF3EFF40FFE3", + So: "00A600A700A900AE00B000B60482060E060F06E906FD06FE07F609FA0B700BF3-0BF80BFA0C7F0CF10CF20D790F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-1399194019E0-19FF1B61-1B6A1B74-1B7C210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B214A214C214D214F2195-2199219C-219F21A121A221A421A521A7-21AD21AF-21CD21D021D121D321D5-21F32300-2307230C-231F2322-2328232B-237B237D-239A23B4-23DB23E2-23E82400-24262440-244A249C-24E92500-25B625B8-25C025C2-25F72600-266E2670-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE2800-28FF2B00-2B2F2B452B462B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A828-A82BA836A837A839AA77-AA79FDFDFFE4FFE8FFEDFFEEFFFCFFFD", Z: "002000A01680180E2000-200A20282029202F205F3000", Zs: "002000A01680180E2000-200A202F205F3000", Zl: "2028", Zp: "2029", - C: - "0000-001F007F-009F00AD03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-0605061C061D0620065F06DD070E070F074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17B417B517DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF200B-200F202A-202E2060-206F20722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-F8FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFD-FF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFFBFFFEFFFF", + C: "0000-001F007F-009F00AD03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-0605061C061D0620065F06DD070E070F074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17B417B517DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF200B-200F202A-202E2060-206F20722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-F8FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFD-FF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFFBFFFEFFFF", Cc: "0000-001F007F-009F", - Cf: - "00AD0600-060306DD070F17B417B5200B-200F202A-202E2060-2064206A-206FFEFFFFF9-FFFB", + Cf: "00AD0600-060306DD070F17B417B5200B-200F202A-202E2060-2064206A-206FFEFFFFF9-FFFB", Co: "E000-F8FF", Cs: "D800-DFFF", - Cn: - "03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-05FF06040605061C061D0620065F070E074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF2065-206920722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-D7FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFDFEFEFF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFF8FFFEFFFF" - }); + Cn: "03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-05FF06040605061C061D0620065F070E074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF2065-206920722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-D7FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFDFEFEFF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFF8FFFEFFFF" + })); }), - define("ace/mode/text", [ - "require", - "exports", - "module", - "ace/tokenizer", - "ace/mode/text_highlight_rules", - "ace/mode/behaviour/cstyle", - "ace/unicode", - "ace/lib/lang", - "ace/token_iterator", - "ace/range" - ], function(e, t, n) { - "use strict"; - var r = e("../tokenizer").Tokenizer, - i = e("./text_highlight_rules").TextHighlightRules, - s = e("./behaviour/cstyle").CstyleBehaviour, - o = e("../unicode"), - u = e("../lib/lang"), - a = e("../token_iterator").TokenIterator, - f = e("../range").Range, - l = function() { - this.HighlightRules = i; - }; - (function() { - (this.$behaviour = new s()), - (this.tokenRe = new RegExp( - "^[" + - o.packages.L + - o.packages.Mn + - o.packages.Mc + - o.packages.Nd + - o.packages.Pc + - "\\$_]+", - "g" - )), - (this.nonTokenRe = new RegExp( - "^(?:[^" + - o.packages.L + - o.packages.Mn + - o.packages.Mc + - o.packages.Nd + - o.packages.Pc + - "\\$_]|\\s])+", - "g" - )), - (this.getTokenizer = function() { - return ( - this.$tokenizer || - ((this.$highlightRules = - this.$highlightRules || - new this.HighlightRules(this.$highlightRuleConfig)), - (this.$tokenizer = new r(this.$highlightRules.getRules()))), - this.$tokenizer - ); - }), - (this.lineCommentStart = ""), - (this.blockComment = ""), - (this.toggleCommentLines = function(e, t, n, r) { - function w(e) { - for (var t = n; t <= r; t++) e(i.getLine(t), t); - } - var i = t.doc, - s = !0, - o = !0, - a = Infinity, - f = t.getTabSize(), - l = !1; - if (!this.lineCommentStart) { - if (!this.blockComment) return !1; - var c = this.blockComment.start, - h = this.blockComment.end, - p = new RegExp("^(\\s*)(?:" + u.escapeRegExp(c) + ")"), - d = new RegExp("(?:" + u.escapeRegExp(h) + ")\\s*$"), - v = function(e, t) { - if (g(e, t)) return; - if (!s || /\S/.test(e)) - i.insertInLine({ row: t, column: e.length }, h), - i.insertInLine({ row: t, column: a }, c); - }, - m = function(e, t) { - var n; - (n = e.match(d)) && - i.removeInLine(t, e.length - n[0].length, e.length), - (n = e.match(p)) && - i.removeInLine(t, n[1].length, n[0].length); - }, - g = function(e, n) { - if (p.test(e)) return !0; - var r = t.getTokens(n); - for (var i = 0; i < r.length; i++) - if (r[i].type === "comment") return !0; - }; - } else { - if (Array.isArray(this.lineCommentStart)) - var p = this.lineCommentStart.map(u.escapeRegExp).join("|"), - c = this.lineCommentStart[0]; - else - var p = u.escapeRegExp(this.lineCommentStart), - c = this.lineCommentStart; - (p = new RegExp("^(\\s*)(?:" + p + ") ?")), - (l = t.getUseSoftTabs()); - var m = function(e, t) { - var n = e.match(p); - if (!n) return; - var r = n[1].length, - s = n[0].length; - !b(e, r, s) && n[0][s - 1] == " " && s--, - i.removeInLine(t, r, s); - }, - y = c + " ", - v = function(e, t) { - if (!s || /\S/.test(e)) - b(e, a, a) - ? i.insertInLine({ row: t, column: a }, y) - : i.insertInLine({ row: t, column: a }, c); - }, - g = function(e, t) { - return p.test(e); - }, - b = function(e, t, n) { - var r = 0; - while (t-- && e.charAt(t) == " ") r++; - if (r % f != 0) return !1; - var r = 0; - while (e.charAt(n++) == " ") r++; - return f > 2 ? r % f != f - 1 : r % f == 0; - }; - } - var E = Infinity; - w(function(e, t) { - var n = e.search(/\S/); - n !== -1 - ? (n < a && (a = n), o && !g(e, t) && (o = !1)) - : E > e.length && (E = e.length); - }), - a == Infinity && ((a = E), (s = !1), (o = !1)), - l && a % f != 0 && (a = Math.floor(a / f) * f), - w(o ? m : v); - }), - (this.toggleBlockComment = function(e, t, n, r) { - var i = this.blockComment; - if (!i) return; - !i.start && i[0] && (i = i[0]); - var s = new a(t, r.row, r.column), - o = s.getCurrentToken(), - u = t.selection, - l = t.selection.toOrientedRange(), - c, - h; - if (o && /comment/.test(o.type)) { - var p, d; - while (o && /comment/.test(o.type)) { - var v = o.value.indexOf(i.start); - if (v != -1) { - var m = s.getCurrentTokenRow(), - g = s.getCurrentTokenColumn() + v; - p = new f(m, g, m, g + i.start.length); - break; - } - o = s.stepBackward(); + define( + "ace/mode/text", + [ + "require", + "exports", + "module", + "ace/tokenizer", + "ace/mode/text_highlight_rules", + "ace/mode/behaviour/cstyle", + "ace/unicode", + "ace/lib/lang", + "ace/token_iterator", + "ace/range" + ], + function (e, t, n) { + "use strict"; + var r = e("../tokenizer").Tokenizer, + i = e("./text_highlight_rules").TextHighlightRules, + s = e("./behaviour/cstyle").CstyleBehaviour, + o = e("../unicode"), + u = e("../lib/lang"), + a = e("../token_iterator").TokenIterator, + f = e("../range").Range, + l = function () { + this.HighlightRules = i; + }; + ((function () { + ((this.$behaviour = new s()), + (this.tokenRe = new RegExp( + "^[" + + o.packages.L + + o.packages.Mn + + o.packages.Mc + + o.packages.Nd + + o.packages.Pc + + "\\$_]+", + "g" + )), + (this.nonTokenRe = new RegExp( + "^(?:[^" + + o.packages.L + + o.packages.Mn + + o.packages.Mc + + o.packages.Nd + + o.packages.Pc + + "\\$_]|\\s])+", + "g" + )), + (this.getTokenizer = function () { + return ( + this.$tokenizer || + ((this.$highlightRules = + this.$highlightRules || + new this.HighlightRules(this.$highlightRuleConfig)), + (this.$tokenizer = new r(this.$highlightRules.getRules()))), + this.$tokenizer + ); + }), + (this.lineCommentStart = ""), + (this.blockComment = ""), + (this.toggleCommentLines = function (e, t, n, r) { + function w(e) { + for (var t = n; t <= r; t++) e(i.getLine(t), t); + } + var i = t.doc, + s = !0, + o = !0, + a = Infinity, + f = t.getTabSize(), + l = !1; + if (!this.lineCommentStart) { + if (!this.blockComment) return !1; + var c = this.blockComment.start, + h = this.blockComment.end, + p = new RegExp("^(\\s*)(?:" + u.escapeRegExp(c) + ")"), + d = new RegExp("(?:" + u.escapeRegExp(h) + ")\\s*$"), + v = function (e, t) { + if (g(e, t)) return; + if (!s || /\S/.test(e)) + (i.insertInLine({ row: t, column: e.length }, h), + i.insertInLine({ row: t, column: a }, c)); + }, + m = function (e, t) { + var n; + ((n = e.match(d)) && + i.removeInLine(t, e.length - n[0].length, e.length), + (n = e.match(p)) && + i.removeInLine(t, n[1].length, n[0].length)); + }, + g = function (e, n) { + if (p.test(e)) return !0; + var r = t.getTokens(n); + for (var i = 0; i < r.length; i++) + if (r[i].type === "comment") return !0; + }; + } else { + if (Array.isArray(this.lineCommentStart)) + var p = this.lineCommentStart.map(u.escapeRegExp).join("|"), + c = this.lineCommentStart[0]; + else + var p = u.escapeRegExp(this.lineCommentStart), + c = this.lineCommentStart; + ((p = new RegExp("^(\\s*)(?:" + p + ") ?")), + (l = t.getUseSoftTabs())); + var m = function (e, t) { + var n = e.match(p); + if (!n) return; + var r = n[1].length, + s = n[0].length; + (!b(e, r, s) && n[0][s - 1] == " " && s--, + i.removeInLine(t, r, s)); + }, + y = c + " ", + v = function (e, t) { + if (!s || /\S/.test(e)) + b(e, a, a) + ? i.insertInLine({ row: t, column: a }, y) + : i.insertInLine({ row: t, column: a }, c); + }, + g = function (e, t) { + return p.test(e); + }, + b = function (e, t, n) { + var r = 0; + while (t-- && e.charAt(t) == " ") r++; + if (r % f != 0) return !1; + var r = 0; + while (e.charAt(n++) == " ") r++; + return f > 2 ? r % f != f - 1 : r % f == 0; + }; } + var E = Infinity; + (w(function (e, t) { + var n = e.search(/\S/); + n !== -1 + ? (n < a && (a = n), o && !g(e, t) && (o = !1)) + : E > e.length && (E = e.length); + }), + a == Infinity && ((a = E), (s = !1), (o = !1)), + l && a % f != 0 && (a = Math.floor(a / f) * f), + w(o ? m : v)); + }), + (this.toggleBlockComment = function (e, t, n, r) { + var i = this.blockComment; + if (!i) return; + !i.start && i[0] && (i = i[0]); var s = new a(t, r.row, r.column), - o = s.getCurrentToken(); - while (o && /comment/.test(o.type)) { - var v = o.value.indexOf(i.end); - if (v != -1) { - var m = s.getCurrentTokenRow(), - g = s.getCurrentTokenColumn() + v; - d = new f(m, g, m, g + i.end.length); - break; + o = s.getCurrentToken(), + u = t.selection, + l = t.selection.toOrientedRange(), + c, + h; + if (o && /comment/.test(o.type)) { + var p, d; + while (o && /comment/.test(o.type)) { + var v = o.value.indexOf(i.start); + if (v != -1) { + var m = s.getCurrentTokenRow(), + g = s.getCurrentTokenColumn() + v; + p = new f(m, g, m, g + i.start.length); + break; + } + o = s.stepBackward(); + } + var s = new a(t, r.row, r.column), + o = s.getCurrentToken(); + while (o && /comment/.test(o.type)) { + var v = o.value.indexOf(i.end); + if (v != -1) { + var m = s.getCurrentTokenRow(), + g = s.getCurrentTokenColumn() + v; + d = new f(m, g, m, g + i.end.length); + break; + } + o = s.stepForward(); + } + (d && t.remove(d), + p && (t.remove(p), (c = p.start.row), (h = -i.start.length))); + } else + ((h = i.start.length), + (c = n.start.row), + t.insert(n.end, i.end), + t.insert(n.start, i.start)); + (l.start.row == c && (l.start.column += h), + l.end.row == c && (l.end.column += h), + t.selection.fromOrientedRange(l)); + }), + (this.getNextLineIndent = function (e, t, n) { + return this.$getIndent(t); + }), + (this.checkOutdent = function (e, t, n) { + return !1; + }), + (this.autoOutdent = function (e, t, n) {}), + (this.$getIndent = function (e) { + return e.match(/^\s*/)[0]; + }), + (this.createWorker = function (e) { + return null; + }), + (this.createModeDelegates = function (e) { + ((this.$embeds = []), (this.$modes = {})); + for (var t in e) + e[t] && (this.$embeds.push(t), (this.$modes[t] = new e[t]())); + var n = [ + "toggleBlockComment", + "toggleCommentLines", + "getNextLineIndent", + "checkOutdent", + "autoOutdent", + "transformAction", + "getCompletions" + ]; + for (var t = 0; t < n.length; t++) + (function (e) { + var r = n[t], + i = e[r]; + e[n[t]] = function () { + return this.$delegator(r, arguments, i); + }; + })(this); + }), + (this.$delegator = function (e, t, n) { + var r = t[0]; + typeof r != "string" && (r = r[0]); + for (var i = 0; i < this.$embeds.length; i++) { + if (!this.$modes[this.$embeds[i]]) continue; + var s = r.split(this.$embeds[i]); + if (!s[0] && s[1]) { + t[0] = s[1]; + var o = this.$modes[this.$embeds[i]]; + return o[e].apply(o, t); } - o = s.stepForward(); - } - d && t.remove(d), - p && (t.remove(p), (c = p.start.row), (h = -i.start.length)); - } else - (h = i.start.length), - (c = n.start.row), - t.insert(n.end, i.end), - t.insert(n.start, i.start); - l.start.row == c && (l.start.column += h), - l.end.row == c && (l.end.column += h), - t.selection.fromOrientedRange(l); - }), - (this.getNextLineIndent = function(e, t, n) { - return this.$getIndent(t); - }), - (this.checkOutdent = function(e, t, n) { - return !1; - }), - (this.autoOutdent = function(e, t, n) {}), - (this.$getIndent = function(e) { - return e.match(/^\s*/)[0]; - }), - (this.createWorker = function(e) { - return null; - }), - (this.createModeDelegates = function(e) { - (this.$embeds = []), (this.$modes = {}); - for (var t in e) - e[t] && (this.$embeds.push(t), (this.$modes[t] = new e[t]())); - var n = [ - "toggleBlockComment", - "toggleCommentLines", - "getNextLineIndent", - "checkOutdent", - "autoOutdent", - "transformAction", - "getCompletions" - ]; - for (var t = 0; t < n.length; t++) - (function(e) { - var r = n[t], - i = e[r]; - e[n[t]] = function() { - return this.$delegator(r, arguments, i); - }; - })(this); - }), - (this.$delegator = function(e, t, n) { - var r = t[0]; - typeof r != "string" && (r = r[0]); - for (var i = 0; i < this.$embeds.length; i++) { - if (!this.$modes[this.$embeds[i]]) continue; - var s = r.split(this.$embeds[i]); - if (!s[0] && s[1]) { - t[0] = s[1]; - var o = this.$modes[this.$embeds[i]]; - return o[e].apply(o, t); } - } - var u = n.apply(this, t); - return n ? u : undefined; - }), - (this.transformAction = function(e, t, n, r, i) { - if (this.$behaviour) { - var s = this.$behaviour.getBehaviours(); - for (var o in s) - if (s[o][t]) { - var u = s[o][t].apply(this, arguments); - if (u) return u; + var u = n.apply(this, t); + return n ? u : undefined; + }), + (this.transformAction = function (e, t, n, r, i) { + if (this.$behaviour) { + var s = this.$behaviour.getBehaviours(); + for (var o in s) + if (s[o][t]) { + var u = s[o][t].apply(this, arguments); + if (u) return u; + } + } + }), + (this.getKeywords = function (e) { + if (!this.completionKeywords) { + var t = this.$tokenizer.rules, + n = []; + for (var r in t) { + var i = t[r]; + for (var s = 0, o = i.length; s < o; s++) + if (typeof i[s].token == "string") + /keyword|support|storage/.test(i[s].token) && + n.push(i[s].regex); + else if (typeof i[s].token == "object") + for (var u = 0, a = i[s].token.length; u < a; u++) + if (/keyword|support|storage/.test(i[s].token[u])) { + var r = i[s].regex.match(/\(.+?\)/g)[u]; + n.push(r.substr(1, r.length - 2)); + } } - } - }), - (this.getKeywords = function(e) { - if (!this.completionKeywords) { - var t = this.$tokenizer.rules, - n = []; - for (var r in t) { - var i = t[r]; - for (var s = 0, o = i.length; s < o; s++) - if (typeof i[s].token == "string") - /keyword|support|storage/.test(i[s].token) && - n.push(i[s].regex); - else if (typeof i[s].token == "object") - for (var u = 0, a = i[s].token.length; u < a; u++) - if (/keyword|support|storage/.test(i[s].token[u])) { - var r = i[s].regex.match(/\(.+?\)/g)[u]; - n.push(r.substr(1, r.length - 2)); - } + this.completionKeywords = n; } - this.completionKeywords = n; - } - return e ? n.concat(this.$keywordList || []) : this.$keywordList; - }), - (this.$createKeywordList = function() { - return ( - this.$highlightRules || this.getTokenizer(), - (this.$keywordList = this.$highlightRules.$keywordList || []) - ); - }), - (this.getCompletions = function(e, t, n, r) { - var i = this.$keywordList || this.$createKeywordList(); - return i.map(function(e) { - return { name: e, value: e, score: 0, meta: "keyword" }; - }); - }), - (this.$id = "ace/mode/text"); - }.call(l.prototype), - (t.Mode = l)); - }), - define("ace/apply_delta", ["require", "exports", "module"], function( - e, - t, - n - ) { - "use strict"; - function r(e, t) { - throw (console.log("Invalid Delta:", e), "Invalid Delta: " + t); - } - function i(e, t) { - return ( - t.row >= 0 && - t.row < e.length && - t.column >= 0 && - t.column <= e[t.row].length - ); - } - function s(e, t) { - t.action != "insert" && - t.action != "remove" && - r(t, "delta.action must be 'insert' or 'remove'"), - t.lines instanceof Array || r(t, "delta.lines must be an Array"), - (!t.start || !t.end) && r(t, "delta.start/end must be an present"); - var n = t.start; - i(e, t.start) || r(t, "delta.start must be contained in document"); - var s = t.end; - t.action == "remove" && - !i(e, s) && - r(t, "delta.end must contained in document for 'remove' actions"); - var o = s.row - n.row, - u = s.column - (o == 0 ? n.column : 0); - (o != t.lines.length - 1 || t.lines[o].length != u) && - r(t, "delta.range must match delta lines"); + return e ? n.concat(this.$keywordList || []) : this.$keywordList; + }), + (this.$createKeywordList = function () { + return ( + this.$highlightRules || this.getTokenizer(), + (this.$keywordList = this.$highlightRules.$keywordList || []) + ); + }), + (this.getCompletions = function (e, t, n, r) { + var i = this.$keywordList || this.$createKeywordList(); + return i.map(function (e) { + return { name: e, value: e, score: 0, meta: "keyword" }; + }); + }), + (this.$id = "ace/mode/text")); + }).call(l.prototype), + (t.Mode = l)); } - t.applyDelta = function(e, t, n) { - var r = t.start.row, - i = t.start.column, - s = e[r] || ""; - switch (t.action) { - case "insert": - var o = t.lines; - if (o.length === 1) - e[r] = s.substring(0, i) + t.lines[0] + s.substring(i); - else { - var u = [r, 1].concat(t.lines); - e.splice.apply(e, u), - (e[r] = s.substring(0, i) + e[r]), - (e[r + t.lines.length - 1] += s.substring(i)); - } - break; - case "remove": - var a = t.end.column, - f = t.end.row; - r === f - ? (e[r] = s.substring(0, i) + s.substring(a)) - : e.splice(r, f - r + 1, s.substring(0, i) + e[f].substring(a)); + ), + define( + "ace/apply_delta", + ["require", "exports", "module"], + function (e, t, n) { + "use strict"; + function r(e, t) { + throw (console.log("Invalid Delta:", e), "Invalid Delta: " + t); } - }; - }), - define("ace/anchor", [ - "require", - "exports", - "module", - "ace/lib/oop", - "ace/lib/event_emitter" - ], function(e, t, n) { - "use strict"; - var r = e("./lib/oop"), - i = e("./lib/event_emitter").EventEmitter, - s = (t.Anchor = function(e, t, n) { - (this.$onChange = this.onChange.bind(this)), - this.attach(e), - typeof n == "undefined" - ? this.setPosition(t.row, t.column) - : this.setPosition(t, n); - }); - (function() { - function e(e, t, n) { - var r = n ? e.column <= t.column : e.column < t.column; - return e.row < t.row || (e.row == t.row && r); + function i(e, t) { + return ( + t.row >= 0 && + t.row < e.length && + t.column >= 0 && + t.column <= e[t.row].length + ); } - function t(t, n, r) { - var i = t.action == "insert", - s = (i ? 1 : -1) * (t.end.row - t.start.row), - o = (i ? 1 : -1) * (t.end.column - t.start.column), - u = t.start, - a = i ? u : t.end; - return e(n, u, r) - ? { row: n.row, column: n.column } - : e(a, n, !r) - ? { row: n.row + s, column: n.column + (n.row == a.row ? o : 0) } - : { row: u.row, column: u.column }; + function s(e, t) { + (t.action != "insert" && + t.action != "remove" && + r(t, "delta.action must be 'insert' or 'remove'"), + t.lines instanceof Array || r(t, "delta.lines must be an Array"), + (!t.start || !t.end) && r(t, "delta.start/end must be an present")); + var n = t.start; + i(e, t.start) || r(t, "delta.start must be contained in document"); + var s = t.end; + t.action == "remove" && + !i(e, s) && + r(t, "delta.end must contained in document for 'remove' actions"); + var o = s.row - n.row, + u = s.column - (o == 0 ? n.column : 0); + (o != t.lines.length - 1 || t.lines[o].length != u) && + r(t, "delta.range must match delta lines"); } - r.implement(this, i), - (this.getPosition = function() { - return this.$clipPositionToDocument(this.row, this.column); - }), - (this.getDocument = function() { - return this.document; - }), - (this.$insertRight = !1), - (this.onChange = function(e) { - if (e.start.row == e.end.row && e.start.row != this.row) return; - if (e.start.row > this.row) return; - var n = t( - e, - { row: this.row, column: this.column }, - this.$insertRight - ); - this.setPosition(n.row, n.column, !0); - }), - (this.setPosition = function(e, t, n) { - var r; - n - ? (r = { row: e, column: t }) - : (r = this.$clipPositionToDocument(e, t)); - if (this.row == r.row && this.column == r.column) return; - var i = { row: this.row, column: this.column }; - (this.row = r.row), - (this.column = r.column), - this._signal("change", { old: i, value: r }); - }), - (this.detach = function() { - this.document.removeEventListener("change", this.$onChange); - }), - (this.attach = function(e) { - (this.document = e || this.document), - this.document.on("change", this.$onChange); - }), - (this.$clipPositionToDocument = function(e, t) { - var n = {}; - return ( - e >= this.document.getLength() - ? ((n.row = Math.max(0, this.document.getLength() - 1)), - (n.column = this.document.getLine(n.row).length)) - : e < 0 - ? ((n.row = 0), (n.column = 0)) - : ((n.row = e), - (n.column = Math.min( - this.document.getLine(n.row).length, - Math.max(0, t) - ))), - t < 0 && (n.column = 0), - n - ); - }); - }.call(s.prototype)); - }), - define("ace/document", [ - "require", - "exports", - "module", - "ace/lib/oop", - "ace/apply_delta", - "ace/lib/event_emitter", - "ace/range", - "ace/anchor" - ], function(e, t, n) { - "use strict"; - var r = e("./lib/oop"), - i = e("./apply_delta").applyDelta, - s = e("./lib/event_emitter").EventEmitter, - o = e("./range").Range, - u = e("./anchor").Anchor, - a = function(e) { - (this.$lines = [""]), - e.length === 0 - ? (this.$lines = [""]) - : Array.isArray(e) - ? this.insertMergedLines({ row: 0, column: 0 }, e) - : this.insert({ row: 0, column: 0 }, e); + t.applyDelta = function (e, t, n) { + var r = t.start.row, + i = t.start.column, + s = e[r] || ""; + switch (t.action) { + case "insert": + var o = t.lines; + if (o.length === 1) + e[r] = s.substring(0, i) + t.lines[0] + s.substring(i); + else { + var u = [r, 1].concat(t.lines); + (e.splice.apply(e, u), + (e[r] = s.substring(0, i) + e[r]), + (e[r + t.lines.length - 1] += s.substring(i))); + } + break; + case "remove": + var a = t.end.column, + f = t.end.row; + r === f + ? (e[r] = s.substring(0, i) + s.substring(a)) + : e.splice(r, f - r + 1, s.substring(0, i) + e[f].substring(a)); + } }; - (function() { - r.implement(this, s), - (this.setValue = function(e) { - var t = this.getLength() - 1; - this.remove(new o(0, 0, t, this.getLine(t).length)), - this.insert({ row: 0, column: 0 }, e); - }), - (this.getValue = function() { - return this.getAllLines().join(this.getNewLineCharacter()); - }), - (this.createAnchor = function(e, t) { - return new u(this, e, t); - }), - "aaa".split(/a/).length === 0 - ? (this.$split = function(e) { - return e.replace(/\r\n|\r/g, "\n").split("\n"); - }) - : (this.$split = function(e) { - return e.split(/\r\n|\r|\n/); - }), - (this.$detectNewLine = function(e) { - var t = e.match(/^.*?(\r\n|\r|\n)/m); - (this.$autoNewLine = t ? t[1] : "\n"), - this._signal("changeNewLineMode"); - }), - (this.getNewLineCharacter = function() { - switch (this.$newLineMode) { - case "windows": - return "\r\n"; - case "unix": - return "\n"; - default: - return this.$autoNewLine || "\n"; - } - }), - (this.$autoNewLine = ""), - (this.$newLineMode = "auto"), - (this.setNewLineMode = function(e) { - if (this.$newLineMode === e) return; - (this.$newLineMode = e), this._signal("changeNewLineMode"); - }), - (this.getNewLineMode = function() { - return this.$newLineMode; - }), - (this.isNewLine = function(e) { - return e == "\r\n" || e == "\r" || e == "\n"; - }), - (this.getLine = function(e) { - return this.$lines[e] || ""; - }), - (this.getLines = function(e, t) { - return this.$lines.slice(e, t + 1); - }), - (this.getAllLines = function() { - return this.getLines(0, this.getLength()); - }), - (this.getLength = function() { - return this.$lines.length; - }), - (this.getTextRange = function(e) { - return this.getLinesForRange(e).join(this.getNewLineCharacter()); - }), - (this.getLinesForRange = function(e) { - var t; - if (e.start.row === e.end.row) - t = [ - this.getLine(e.start.row).substring(e.start.column, e.end.column) - ]; - else { - (t = this.getLines(e.start.row, e.end.row)), - (t[0] = (t[0] || "").substring(e.start.column)); - var n = t.length - 1; - e.end.row - e.start.row == n && - (t[n] = t[n].substring(0, e.end.column)); - } - return t; - }), - (this.insertLines = function(e, t) { - return ( - console.warn( - "Use of document.insertLines is deprecated. Use the insertFullLines method instead." - ), - this.insertFullLines(e, t) - ); - }), - (this.removeLines = function(e, t) { - return ( - console.warn( - "Use of document.removeLines is deprecated. Use the removeFullLines method instead." - ), - this.removeFullLines(e, t) - ); - }), - (this.insertNewLine = function(e) { - return ( - console.warn( - "Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead." - ), - this.insertMergedLines(e, ["", ""]) - ); - }), - (this.insert = function(e, t) { - return ( - this.getLength() <= 1 && this.$detectNewLine(t), - this.insertMergedLines(e, this.$split(t)) - ); - }), - (this.insertInLine = function(e, t) { - var n = this.clippedPos(e.row, e.column), - r = this.pos(e.row, e.column + t.length); - return ( - this.applyDelta( - { start: n, end: r, action: "insert", lines: [t] }, - !0 - ), - this.clonePos(r) - ); - }), - (this.clippedPos = function(e, t) { - var n = this.getLength(); - e === undefined - ? (e = n) - : e < 0 - ? (e = 0) - : e >= n && ((e = n - 1), (t = undefined)); - var r = this.getLine(e); - return ( - t == undefined && (t = r.length), - (t = Math.min(Math.max(t, 0), r.length)), - { row: e, column: t } - ); - }), - (this.clonePos = function(e) { - return { row: e.row, column: e.column }; - }), - (this.pos = function(e, t) { - return { row: e, column: t }; - }), - (this.$clipPosition = function(e) { - var t = this.getLength(); - return ( - e.row >= t - ? ((e.row = Math.max(0, t - 1)), - (e.column = this.getLine(t - 1).length)) - : ((e.row = Math.max(0, e.row)), - (e.column = Math.min( - Math.max(e.column, 0), - this.getLine(e.row).length - ))), - e - ); - }), - (this.insertFullLines = function(e, t) { - e = Math.min(Math.max(e, 0), this.getLength()); - var n = 0; - e < this.getLength() - ? ((t = t.concat([""])), (n = 0)) - : ((t = [""].concat(t)), e--, (n = this.$lines[e].length)), - this.insertMergedLines({ row: e, column: n }, t); - }), - (this.insertMergedLines = function(e, t) { - var n = this.clippedPos(e.row, e.column), - r = { - row: n.row + t.length - 1, - column: (t.length == 1 ? n.column : 0) + t[t.length - 1].length - }; - return ( - this.applyDelta({ start: n, end: r, action: "insert", lines: t }), - this.clonePos(r) - ); - }), - (this.remove = function(e) { - var t = this.clippedPos(e.start.row, e.start.column), - n = this.clippedPos(e.end.row, e.end.column); - return ( - this.applyDelta({ - start: t, - end: n, - action: "remove", - lines: this.getLinesForRange({ start: t, end: n }) - }), - this.clonePos(t) - ); - }), - (this.removeInLine = function(e, t, n) { - var r = this.clippedPos(e, t), - i = this.clippedPos(e, n); - return ( - this.applyDelta( - { - start: r, - end: i, - action: "remove", - lines: this.getLinesForRange({ start: r, end: i }) - }, - !0 - ), - this.clonePos(r) - ); - }), - (this.removeFullLines = function(e, t) { - (e = Math.min(Math.max(0, e), this.getLength() - 1)), - (t = Math.min(Math.max(0, t), this.getLength() - 1)); - var n = t == this.getLength() - 1 && e > 0, - r = t < this.getLength() - 1, - i = n ? e - 1 : e, - s = n ? this.getLine(i).length : 0, - u = r ? t + 1 : t, - a = r ? 0 : this.getLine(u).length, - f = new o(i, s, u, a), - l = this.$lines.slice(e, t + 1); - return ( - this.applyDelta({ - start: f.start, - end: f.end, - action: "remove", - lines: this.getLinesForRange(f) - }), - l - ); - }), - (this.removeNewLine = function(e) { - e < this.getLength() - 1 && - e >= 0 && - this.applyDelta({ - start: this.pos(e, this.getLine(e).length), - end: this.pos(e + 1, 0), - action: "remove", - lines: ["", ""] - }); - }), - (this.replace = function(e, t) { - e instanceof o || (e = o.fromPoints(e.start, e.end)); - if (t.length === 0 && e.isEmpty()) return e.start; - if (t == this.getTextRange(e)) return e.end; - this.remove(e); - var n; - return t ? (n = this.insert(e.start, t)) : (n = e.start), n; - }), - (this.applyDeltas = function(e) { - for (var t = 0; t < e.length; t++) this.applyDelta(e[t]); - }), - (this.revertDeltas = function(e) { - for (var t = e.length - 1; t >= 0; t--) this.revertDelta(e[t]); - }), - (this.applyDelta = function(e, t) { - var n = e.action == "insert"; - if ( - n - ? e.lines.length <= 1 && !e.lines[0] - : !o.comparePoints(e.start, e.end) - ) - return; - n && e.lines.length > 2e4 && this.$splitAndapplyLargeDelta(e, 2e4), - i(this.$lines, e, t), - this._signal("change", e); - }), - (this.$splitAndapplyLargeDelta = function(e, t) { - var n = e.lines, - r = n.length, - i = e.start.row, - s = e.start.column, - o = 0, - u = 0; - do { - (o = u), (u += t - 1); - var a = n.slice(o, u); - if (u > r) { - (e.lines = a), (e.start.row = i + o), (e.start.column = s); - break; - } - a.push(""), - this.applyDelta( - { - start: this.pos(i + o, s), - end: this.pos(i + u, (s = 0)), - action: e.action, - lines: a - }, - !0 - ); - } while (!0); - }), - (this.revertDelta = function(e) { - this.applyDelta({ - start: this.clonePos(e.start), - end: this.clonePos(e.end), - action: e.action == "insert" ? "remove" : "insert", - lines: e.lines.slice() - }); - }), - (this.indexToPosition = function(e, t) { - var n = this.$lines || this.getAllLines(), - r = this.getNewLineCharacter().length; - for (var i = t || 0, s = n.length; i < s; i++) { - e -= n[i].length + r; - if (e < 0) return { row: i, column: e + n[i].length + r }; - } - return { row: s - 1, column: n[s - 1].length }; - }), - (this.positionToIndex = function(e, t) { - var n = this.$lines || this.getAllLines(), - r = this.getNewLineCharacter().length, - i = 0, - s = Math.min(e.row, n.length); - for (var o = t || 0; o < s; ++o) i += n[o].length + r; - return i + e.column; - }); - }.call(a.prototype), - (t.Document = a)); - }), - define("ace/background_tokenizer", [ - "require", - "exports", - "module", - "ace/lib/oop", - "ace/lib/event_emitter" - ], function(e, t, n) { - "use strict"; - var r = e("./lib/oop"), - i = e("./lib/event_emitter").EventEmitter, - s = function(e, t) { - (this.running = !1), - (this.lines = []), - (this.states = []), - (this.currentLine = 0), - (this.tokenizer = e); - var n = this; - this.$worker = function() { - if (!n.running) return; - var e = new Date(), - t = n.currentLine, - r = -1, - i = n.doc, - s = t; - while (n.lines[t]) t++; - var o = i.getLength(), - u = 0; - n.running = !1; - while (t < o) { - n.$tokenizeRow(t), (r = t); - do t++; - while (n.lines[t]); - u++; - if (u % 5 === 0 && new Date() - e > 20) { - n.running = setTimeout(n.$worker, 20); - break; - } - } - (n.currentLine = t), s <= r && n.fireUpdateEvent(s, r); - }; - }; - (function() { - r.implement(this, i), - (this.setTokenizer = function(e) { - (this.tokenizer = e), - (this.lines = []), - (this.states = []), - this.start(0); - }), - (this.setDocument = function(e) { - (this.doc = e), (this.lines = []), (this.states = []), this.stop(); - }), - (this.fireUpdateEvent = function(e, t) { - var n = { first: e, last: t }; - this._signal("update", { data: n }); - }), - (this.start = function(e) { - (this.currentLine = Math.min( - e || 0, - this.currentLine, - this.doc.getLength() - )), - this.lines.splice(this.currentLine, this.lines.length), - this.states.splice(this.currentLine, this.states.length), - this.stop(), - (this.running = setTimeout(this.$worker, 700)); - }), - (this.scheduleStart = function() { - this.running || (this.running = setTimeout(this.$worker, 700)); - }), - (this.$updateOnChange = function(e) { - var t = e.start.row, - n = e.end.row - t; - if (n === 0) this.lines[t] = null; - else if (e.action == "remove") - this.lines.splice(t, n + 1, null), - this.states.splice(t, n + 1, null); - else { - var r = Array(n + 1); - r.unshift(t, 1), - this.lines.splice.apply(this.lines, r), - this.states.splice.apply(this.states, r); - } - (this.currentLine = Math.min( - t, - this.currentLine, - this.doc.getLength() - )), - this.stop(); - }), - (this.stop = function() { - this.running && clearTimeout(this.running), (this.running = !1); - }), - (this.getTokens = function(e) { - return this.lines[e] || this.$tokenizeRow(e); - }), - (this.getState = function(e) { - return ( - this.currentLine == e && this.$tokenizeRow(e), - this.states[e] || "start" - ); - }), - (this.$tokenizeRow = function(e) { - var t = this.doc.getLine(e), - n = this.states[e - 1], - r = this.tokenizer.getLineTokens(t, n, e); - return ( - this.states[e] + "" != r.state + "" - ? ((this.states[e] = r.state), - (this.lines[e + 1] = null), - this.currentLine > e + 1 && (this.currentLine = e + 1)) - : this.currentLine == e && (this.currentLine = e + 1), - (this.lines[e] = r.tokens) - ); - }); - }.call(s.prototype), - (t.BackgroundTokenizer = s)); - }), - define("ace/search_highlight", [ - "require", - "exports", - "module", - "ace/lib/lang", - "ace/lib/oop", - "ace/range" - ], function(e, t, n) { - "use strict"; - var r = e("./lib/lang"), - i = e("./lib/oop"), - s = e("./range").Range, - o = function(e, t, n) { - this.setRegexp(e), (this.clazz = t), (this.type = n || "text"); - }; - (function() { - (this.MAX_RANGES = 500), - (this.setRegexp = function(e) { - if (this.regExp + "" == e + "") return; - (this.regExp = e), (this.cache = []); - }), - (this.update = function(e, t, n, i) { - if (!this.regExp) return; - var o = i.firstRow, - u = i.lastRow; - for (var a = o; a <= u; a++) { - var f = this.cache[a]; - f == null && - ((f = r.getMatchOffsets(n.getLine(a), this.regExp)), - f.length > this.MAX_RANGES && (f = f.slice(0, this.MAX_RANGES)), - (f = f.map(function(e) { - return new s(a, e.offset, a, e.offset + e.length); - })), - (this.cache[a] = f.length ? f : "")); - for (var l = f.length; l--; ) - t.drawSingleLineMarker(e, f[l].toScreenRange(n), this.clazz, i); - } - }); - }.call(o.prototype), - (t.SearchHighlight = o)); - }), - define("ace/edit_session/fold_line", [ - "require", - "exports", - "module", - "ace/range" - ], function(e, t, n) { - "use strict"; - function i(e, t) { - (this.foldData = e), - Array.isArray(t) ? (this.folds = t) : (t = this.folds = [t]); - var n = t[t.length - 1]; - (this.range = new r( - t[0].start.row, - t[0].start.column, - n.end.row, - n.end.column - )), - (this.start = this.range.start), - (this.end = this.range.end), - this.folds.forEach(function(e) { - e.setFoldLine(this); - }, this); } - var r = e("../range").Range; - (function() { - (this.shiftRow = function(e) { - (this.start.row += e), - (this.end.row += e), - this.folds.forEach(function(t) { - (t.start.row += e), (t.end.row += e); - }); - }), - (this.addFold = function(e) { - if (e.sameRow) { - if (e.start.row < this.startRow || e.endRow > this.endRow) - throw new Error( - "Can't add a fold to this FoldLine as it has no connection" - ); - this.folds.push(e), - this.folds.sort(function(e, t) { - return -e.range.compareEnd(t.start.row, t.start.column); - }), - this.range.compareEnd(e.start.row, e.start.column) > 0 - ? ((this.end.row = e.end.row), (this.end.column = e.end.column)) - : this.range.compareStart(e.end.row, e.end.column) < 0 && - ((this.start.row = e.start.row), - (this.start.column = e.start.column)); - } else if (e.start.row == this.end.row) - this.folds.push(e), - (this.end.row = e.end.row), - (this.end.column = e.end.column); - else { - if (e.end.row != this.start.row) - throw new Error( - "Trying to add fold to FoldRow that doesn't have a matching row" - ); - this.folds.unshift(e), - (this.start.row = e.start.row), - (this.start.column = e.start.column); - } - e.foldLine = this; - }), - (this.containsRow = function(e) { - return e >= this.start.row && e <= this.end.row; - }), - (this.walk = function(e, t, n) { - var r = 0, - i = this.folds, - s, - o, - u, - a = !0; - t == null && ((t = this.end.row), (n = this.end.column)); - for (var f = 0; f < i.length; f++) { - (s = i[f]), (o = s.range.compareStart(t, n)); - if (o == -1) { - e(null, t, n, r, a); - return; - } - (u = e(null, s.start.row, s.start.column, r, a)), - (u = !u && e(s.placeholder, s.start.row, s.start.column, r)); - if (u || o === 0) return; - (a = !s.sameRow), (r = s.end.column); - } - e(null, t, n, r, a); - }), - (this.getNextFoldTo = function(e, t) { - var n, r; - for (var i = 0; i < this.folds.length; i++) { - (n = this.folds[i]), (r = n.range.compareEnd(e, t)); - if (r == -1) return { fold: n, kind: "after" }; - if (r === 0) return { fold: n, kind: "inside" }; - } - return null; - }), - (this.addRemoveChars = function(e, t, n) { - var r = this.getNextFoldTo(e, t), - i, - s; - if (r) { - i = r.fold; - if (r.kind == "inside" && i.start.column != t && i.start.row != e) - window.console && window.console.log(e, t, i); - else if (i.start.row == e) { - s = this.folds; - var o = s.indexOf(i); - o === 0 && (this.start.column += n); - for (o; o < s.length; o++) { - (i = s[o]), (i.start.column += n); - if (!i.sameRow) return; - i.end.column += n; - } - this.end.column += n; - } - } - }), - (this.split = function(e, t) { - var n = this.getNextFoldTo(e, t); - if (!n || n.kind == "inside") return null; - var r = n.fold, - s = this.folds, - o = this.foldData, - u = s.indexOf(r), - a = s[u - 1]; - (this.end.row = a.end.row), - (this.end.column = a.end.column), - (s = s.splice(u, s.length - u)); - var f = new i(o, s); - return o.splice(o.indexOf(this) + 1, 0, f), f; - }), - (this.merge = function(e) { - var t = e.folds; - for (var n = 0; n < t.length; n++) this.addFold(t[n]); - var r = this.foldData; - r.splice(r.indexOf(e), 1); - }), - (this.toString = function() { - var e = [this.range.toString() + ": ["]; - return ( - this.folds.forEach(function(t) { - e.push(" " + t.toString()); - }), - e.push("]"), - e.join("\n") - ); - }), - (this.idxToPosition = function(e) { - var t = 0; - for (var n = 0; n < this.folds.length; n++) { - var r = this.folds[n]; - e -= r.start.column - t; - if (e < 0) return { row: r.start.row, column: r.start.column + e }; - e -= r.placeholder.length; - if (e < 0) return r.start; - t = r.end.column; - } - return { row: this.end.row, column: this.end.column + e }; - }); - }.call(i.prototype), - (t.FoldLine = i)); - }), - define("ace/range_list", [ - "require", - "exports", - "module", - "ace/range" - ], function(e, t, n) { - "use strict"; - var r = e("./range").Range, - i = r.comparePoints, - s = function() { - this.ranges = []; - }; - (function() { - (this.comparePoints = i), - (this.pointIndex = function(e, t, n) { - var r = this.ranges; - for (var s = n || 0; s < r.length; s++) { - var o = r[s], - u = i(e, o.end); - if (u > 0) continue; - var a = i(e, o.start); - return u === 0 - ? t && a !== 0 - ? -s - 2 - : s - : a > 0 || (a === 0 && !t) - ? s - : -s - 1; - } - return -s - 1; - }), - (this.add = function(e) { - var t = !e.isEmpty(), - n = this.pointIndex(e.start, t); - n < 0 && (n = -n - 1); - var r = this.pointIndex(e.end, t, n); - return r < 0 ? (r = -r - 1) : r++, this.ranges.splice(n, r - n, e); - }), - (this.addList = function(e) { - var t = []; - for (var n = e.length; n--; ) t.push.apply(t, this.add(e[n])); - return t; - }), - (this.substractPoint = function(e) { - var t = this.pointIndex(e); - if (t >= 0) return this.ranges.splice(t, 1); - }), - (this.merge = function() { - var e = [], - t = this.ranges; - t = t.sort(function(e, t) { - return i(e.start, t.start); - }); - var n = t[0], - r; - for (var s = 1; s < t.length; s++) { - (r = n), (n = t[s]); - var o = i(r.end, n.start); - if (o < 0) continue; - if (o == 0 && !r.isEmpty() && !n.isEmpty()) continue; - i(r.end, n.end) < 0 && - ((r.end.row = n.end.row), (r.end.column = n.end.column)), - t.splice(s, 1), - e.push(n), - (n = r), - s--; - } - return (this.ranges = t), e; - }), - (this.contains = function(e, t) { - return this.pointIndex({ row: e, column: t }) >= 0; - }), - (this.containsPoint = function(e) { - return this.pointIndex(e) >= 0; - }), - (this.rangeAtPoint = function(e) { - var t = this.pointIndex(e); - if (t >= 0) return this.ranges[t]; - }), - (this.clipRows = function(e, t) { - var n = this.ranges; - if (n[0].start.row > t || n[n.length - 1].start.row < e) return []; - var r = this.pointIndex({ row: e, column: 0 }); - r < 0 && (r = -r - 1); - var i = this.pointIndex({ row: t, column: 0 }, r); - i < 0 && (i = -i - 1); - var s = []; - for (var o = r; o < i; o++) s.push(n[o]); - return s; - }), - (this.removeAll = function() { - return this.ranges.splice(0, this.ranges.length); - }), - (this.attach = function(e) { - this.session && this.detach(), - (this.session = e), - (this.onChange = this.$onChange.bind(this)), - this.session.on("change", this.onChange); - }), - (this.detach = function() { - if (!this.session) return; - this.session.removeListener("change", this.onChange), - (this.session = null); - }), - (this.$onChange = function(e) { - if (e.action == "insert") - var t = e.start, - n = e.end; - else - var n = e.start, - t = e.end; - var r = t.row, - i = n.row, - s = i - r, - o = -t.column + n.column, - u = this.ranges; - for (var a = 0, f = u.length; a < f; a++) { - var l = u[a]; - if (l.end.row < r) continue; - if (l.start.row > r) break; - l.start.row == r && - l.start.column >= t.column && - (l.start.column != t.column || !this.$insertRight) && - ((l.start.column += o), (l.start.row += s)); - if (l.end.row == r && l.end.column >= t.column) { - if (l.end.column == t.column && this.$insertRight) continue; - l.end.column == t.column && - o > 0 && - a < f - 1 && - l.end.column > l.start.column && - l.end.column == u[a + 1].start.column && - (l.end.column -= o), - (l.end.column += o), - (l.end.row += s); - } - } - if (s != 0 && a < f) - for (; a < f; a++) { - var l = u[a]; - (l.start.row += s), (l.end.row += s); - } + ), + define( + "ace/anchor", + ["require", "exports", "module", "ace/lib/oop", "ace/lib/event_emitter"], + function (e, t, n) { + "use strict"; + var r = e("./lib/oop"), + i = e("./lib/event_emitter").EventEmitter, + s = (t.Anchor = function (e, t, n) { + ((this.$onChange = this.onChange.bind(this)), + this.attach(e), + typeof n == "undefined" + ? this.setPosition(t.row, t.column) + : this.setPosition(t, n)); }); - }.call(s.prototype), - (t.RangeList = s)); - }), - define("ace/edit_session/fold", [ - "require", - "exports", - "module", - "ace/range", - "ace/range_list", - "ace/lib/oop" - ], function(e, t, n) { - "use strict"; - function u(e, t) { - (e.row -= t.row), e.row == 0 && (e.column -= t.column); - } - function a(e, t) { - u(e.start, t), u(e.end, t); - } - function f(e, t) { - e.row == 0 && (e.column += t.column), (e.row += t.row); - } - function l(e, t) { - f(e.start, t), f(e.end, t); - } - var r = e("../range").Range, - i = e("../range_list").RangeList, - s = e("../lib/oop"), - o = (t.Fold = function(e, t) { - (this.foldLine = null), - (this.placeholder = t), - (this.range = e), - (this.start = e.start), - (this.end = e.end), - (this.sameRow = e.start.row == e.end.row), - (this.subFolds = this.ranges = []); - }); - s.inherits(o, i), - function() { - (this.toString = function() { - return '"' + this.placeholder + '" ' + this.range.toString(); - }), - (this.setFoldLine = function(e) { - (this.foldLine = e), - this.subFolds.forEach(function(t) { - t.setFoldLine(e); - }); + (function () { + function e(e, t, n) { + var r = n ? e.column <= t.column : e.column < t.column; + return e.row < t.row || (e.row == t.row && r); + } + function t(t, n, r) { + var i = t.action == "insert", + s = (i ? 1 : -1) * (t.end.row - t.start.row), + o = (i ? 1 : -1) * (t.end.column - t.start.column), + u = t.start, + a = i ? u : t.end; + return e(n, u, r) + ? { row: n.row, column: n.column } + : e(a, n, !r) + ? { row: n.row + s, column: n.column + (n.row == a.row ? o : 0) } + : { row: u.row, column: u.column }; + } + (r.implement(this, i), + (this.getPosition = function () { + return this.$clipPositionToDocument(this.row, this.column); + }), + (this.getDocument = function () { + return this.document; + }), + (this.$insertRight = !1), + (this.onChange = function (e) { + if (e.start.row == e.end.row && e.start.row != this.row) return; + if (e.start.row > this.row) return; + var n = t( + e, + { row: this.row, column: this.column }, + this.$insertRight + ); + this.setPosition(n.row, n.column, !0); + }), + (this.setPosition = function (e, t, n) { + var r; + n + ? (r = { row: e, column: t }) + : (r = this.$clipPositionToDocument(e, t)); + if (this.row == r.row && this.column == r.column) return; + var i = { row: this.row, column: this.column }; + ((this.row = r.row), + (this.column = r.column), + this._signal("change", { old: i, value: r })); + }), + (this.detach = function () { + this.document.removeEventListener("change", this.$onChange); }), - (this.clone = function() { - var e = this.range.clone(), - t = new o(e, this.placeholder); + (this.attach = function (e) { + ((this.document = e || this.document), + this.document.on("change", this.$onChange)); + }), + (this.$clipPositionToDocument = function (e, t) { + var n = {}; return ( - this.subFolds.forEach(function(e) { - t.subFolds.push(e.clone()); - }), - (t.collapseChildren = this.collapseChildren), - t + e >= this.document.getLength() + ? ((n.row = Math.max(0, this.document.getLength() - 1)), + (n.column = this.document.getLine(n.row).length)) + : e < 0 + ? ((n.row = 0), (n.column = 0)) + : ((n.row = e), + (n.column = Math.min( + this.document.getLine(n.row).length, + Math.max(0, t) + ))), + t < 0 && (n.column = 0), + n ); + })); + }).call(s.prototype); + } + ), + define( + "ace/document", + [ + "require", + "exports", + "module", + "ace/lib/oop", + "ace/apply_delta", + "ace/lib/event_emitter", + "ace/range", + "ace/anchor" + ], + function (e, t, n) { + "use strict"; + var r = e("./lib/oop"), + i = e("./apply_delta").applyDelta, + s = e("./lib/event_emitter").EventEmitter, + o = e("./range").Range, + u = e("./anchor").Anchor, + a = function (e) { + ((this.$lines = [""]), + e.length === 0 + ? (this.$lines = [""]) + : Array.isArray(e) + ? this.insertMergedLines({ row: 0, column: 0 }, e) + : this.insert({ row: 0, column: 0 }, e)); + }; + ((function () { + (r.implement(this, s), + (this.setValue = function (e) { + var t = this.getLength() - 1; + (this.remove(new o(0, 0, t, this.getLine(t).length)), + this.insert({ row: 0, column: 0 }, e)); }), - (this.addSubFold = function(e) { - if (this.range.isEqual(e)) return; - if (!this.range.containsRange(e)) - throw new Error( - "A fold can't intersect already existing fold" + - e.range + - this.range - ); - a(e, this.start); - var t = e.start.row, - n = e.start.column; - for (var r = 0, i = -1; r < this.subFolds.length; r++) { - i = this.subFolds[r].range.compare(t, n); - if (i != 1) break; - } - var s = this.subFolds[r]; - if (i == 0) return s.addSubFold(e); - var t = e.range.end.row, - n = e.range.end.column; - for (var o = r, i = -1; o < this.subFolds.length; o++) { - i = this.subFolds[o].range.compare(t, n); - if (i != 1) break; - } - var u = this.subFolds[o]; - if (i == 0) - throw new Error( - "A fold can't intersect already existing fold" + - e.range + - this.range - ); - var f = this.subFolds.splice(r, o - r, e); - return e.setFoldLine(this.foldLine), e; + (this.getValue = function () { + return this.getAllLines().join(this.getNewLineCharacter()); }), - (this.restoreRange = function(e) { - return l(e, this.start); - }); - }.call(o.prototype); - }), - define("ace/edit_session/folding", [ - "require", - "exports", - "module", - "ace/range", - "ace/edit_session/fold_line", - "ace/edit_session/fold", - "ace/token_iterator" - ], function(e, t, n) { - "use strict"; - function u() { - (this.getFoldAt = function(e, t, n) { - var r = this.getFoldLine(e); - if (!r) return null; - var i = r.folds; - for (var s = 0; s < i.length; s++) { - var o = i[s]; - if (o.range.contains(e, t)) { - if (n == 1 && o.range.isEnd(e, t)) continue; - if (n == -1 && o.range.isStart(e, t)) continue; - return o; - } - } - }), - (this.getFoldsInRange = function(e) { - var t = e.start, - n = e.end, - r = this.$foldData, - i = []; - (t.column += 1), (n.column -= 1); - for (var s = 0; s < r.length; s++) { - var o = r[s].range.compareRange(e); - if (o == 2) continue; - if (o == -2) break; - var u = r[s].folds; - for (var a = 0; a < u.length; a++) { - var f = u[a]; - o = f.range.compareRange(e); - if (o == -2) break; - if (o == 2) continue; - if (o == 42) break; - i.push(f); - } - } - return (t.column -= 1), (n.column += 1), i; - }), - (this.getFoldsInRangeList = function(e) { - if (Array.isArray(e)) { - var t = []; - e.forEach(function(e) { - t = t.concat(this.getFoldsInRange(e)); - }, this); - } else var t = this.getFoldsInRange(e); - return t; - }), - (this.getAllFolds = function() { - var e = [], - t = this.$foldData; - for (var n = 0; n < t.length; n++) - for (var r = 0; r < t[n].folds.length; r++) e.push(t[n].folds[r]); - return e; - }), - (this.getFoldStringAt = function(e, t, n, r) { - r = r || this.getFoldLine(e); - if (!r) return null; - var i = { end: { column: 0 } }, - s, - o; - for (var u = 0; u < r.folds.length; u++) { - o = r.folds[u]; - var a = o.range.compareEnd(e, t); - if (a == -1) { - s = this.getLine(o.start.row).substring( - i.end.column, - o.start.column - ); - break; + (this.createAnchor = function (e, t) { + return new u(this, e, t); + }), + "aaa".split(/a/).length === 0 + ? (this.$split = function (e) { + return e.replace(/\r\n|\r/g, "\n").split("\n"); + }) + : (this.$split = function (e) { + return e.split(/\r\n|\r|\n/); + }), + (this.$detectNewLine = function (e) { + var t = e.match(/^.*?(\r\n|\r|\n)/m); + ((this.$autoNewLine = t ? t[1] : "\n"), + this._signal("changeNewLineMode")); + }), + (this.getNewLineCharacter = function () { + switch (this.$newLineMode) { + case "windows": + return "\r\n"; + case "unix": + return "\n"; + default: + return this.$autoNewLine || "\n"; } - if (a === 0) return null; - i = o; - } - return ( - s || (s = this.getLine(o.start.row).substring(i.end.column)), - n == -1 - ? s.substring(0, t - i.end.column) - : n == 1 - ? s.substring(t - i.end.column) - : s - ); - }), - (this.getFoldLine = function(e, t) { - var n = this.$foldData, - r = 0; - t && (r = n.indexOf(t)), r == -1 && (r = 0); - for (r; r < n.length; r++) { - var i = n[r]; - if (i.start.row <= e && i.end.row >= e) return i; - if (i.end.row > e) return null; - } - return null; - }), - (this.getNextFoldLine = function(e, t) { - var n = this.$foldData, - r = 0; - t && (r = n.indexOf(t)), r == -1 && (r = 0); - for (r; r < n.length; r++) { - var i = n[r]; - if (i.end.row >= e) return i; - } - return null; - }), - (this.getFoldedRowCount = function(e, t) { - var n = this.$foldData, - r = t - e + 1; - for (var i = 0; i < n.length; i++) { - var s = n[i], - o = s.end.row, - u = s.start.row; - if (o >= t) { - u < t && (u >= e ? (r -= t - u) : (r = 0)); - break; - } - o >= e && (u >= e ? (r -= o - u) : (r -= o - e + 1)); - } - return r; - }), - (this.$addFoldLine = function(e) { - return ( - this.$foldData.push(e), - this.$foldData.sort(function(e, t) { - return e.start.row - t.start.row; - }), - e - ); - }), - (this.addFold = function(e, t) { - var n = this.$foldData, - r = !1, - o; - e instanceof s - ? (o = e) - : ((o = new s(t, e)), (o.collapseChildren = t.collapseChildren)), - this.$clipRangeToDocument(o.range); - var u = o.start.row, - a = o.start.column, - f = o.end.row, - l = o.end.column; - if (u < f || (u == f && a <= l - 2)) { - var c = this.getFoldAt(u, a, 1), - h = this.getFoldAt(f, l, -1); - if (c && h == c) return c.addSubFold(o); - c && !c.range.isStart(u, a) && this.removeFold(c), - h && !h.range.isEnd(f, l) && this.removeFold(h); - var p = this.getFoldsInRange(o.range); - p.length > 0 && - (this.removeFolds(p), - p.forEach(function(e) { - o.addSubFold(e); - })); - for (var d = 0; d < n.length; d++) { - var v = n[d]; - if (f == v.start.row) { - v.addFold(o), (r = !0); - break; - } - if (u == v.end.row) { - v.addFold(o), (r = !0); - if (!o.sameRow) { - var m = n[d + 1]; - if (m && m.start.row == f) { - v.merge(m); - break; - } - } - break; - } - if (f <= v.start.row) break; + }), + (this.$autoNewLine = ""), + (this.$newLineMode = "auto"), + (this.setNewLineMode = function (e) { + if (this.$newLineMode === e) return; + ((this.$newLineMode = e), this._signal("changeNewLineMode")); + }), + (this.getNewLineMode = function () { + return this.$newLineMode; + }), + (this.isNewLine = function (e) { + return e == "\r\n" || e == "\r" || e == "\n"; + }), + (this.getLine = function (e) { + return this.$lines[e] || ""; + }), + (this.getLines = function (e, t) { + return this.$lines.slice(e, t + 1); + }), + (this.getAllLines = function () { + return this.getLines(0, this.getLength()); + }), + (this.getLength = function () { + return this.$lines.length; + }), + (this.getTextRange = function (e) { + return this.getLinesForRange(e).join(this.getNewLineCharacter()); + }), + (this.getLinesForRange = function (e) { + var t; + if (e.start.row === e.end.row) + t = [ + this.getLine(e.start.row).substring( + e.start.column, + e.end.column + ) + ]; + else { + ((t = this.getLines(e.start.row, e.end.row)), + (t[0] = (t[0] || "").substring(e.start.column))); + var n = t.length - 1; + e.end.row - e.start.row == n && + (t[n] = t[n].substring(0, e.end.column)); } + return t; + }), + (this.insertLines = function (e, t) { return ( - r || (v = this.$addFoldLine(new i(this.$foldData, o))), - this.$useWrapMode - ? this.$updateWrapData(v.start.row, v.start.row) - : this.$updateRowLengthCache(v.start.row, v.start.row), - (this.$modified = !0), - this._signal("changeFold", { data: o, action: "add" }), - o + console.warn( + "Use of document.insertLines is deprecated. Use the insertFullLines method instead." + ), + this.insertFullLines(e, t) ); - } - throw new Error("The range has to be at least 2 characters width"); - }), - (this.addFolds = function(e) { - e.forEach(function(e) { - this.addFold(e); - }, this); - }), - (this.removeFold = function(e) { - var t = e.foldLine, - n = t.start.row, - r = t.end.row, - i = this.$foldData, - s = t.folds; - if (s.length == 1) i.splice(i.indexOf(t), 1); - else if (t.range.isEnd(e.end.row, e.end.column)) - s.pop(), - (t.end.row = s[s.length - 1].end.row), - (t.end.column = s[s.length - 1].end.column); - else if (t.range.isStart(e.start.row, e.start.column)) - s.shift(), - (t.start.row = s[0].start.row), - (t.start.column = s[0].start.column); - else if (e.sameRow) s.splice(s.indexOf(e), 1); - else { - var o = t.split(e.start.row, e.start.column); - (s = o.folds), - s.shift(), - (o.start.row = s[0].start.row), - (o.start.column = s[0].start.column); - } - this.$updating || - (this.$useWrapMode - ? this.$updateWrapData(n, r) - : this.$updateRowLengthCache(n, r)), - (this.$modified = !0), - this._signal("changeFold", { data: e, action: "remove" }); - }), - (this.removeFolds = function(e) { - var t = []; - for (var n = 0; n < e.length; n++) t.push(e[n]); - t.forEach(function(e) { - this.removeFold(e); - }, this), - (this.$modified = !0); - }), - (this.expandFold = function(e) { - this.removeFold(e), - e.subFolds.forEach(function(t) { - e.restoreRange(t), this.addFold(t); - }, this), - e.collapseChildren > 0 && - this.foldAll(e.start.row + 1, e.end.row, e.collapseChildren - 1), - (e.subFolds = []); - }), - (this.expandFolds = function(e) { - e.forEach(function(e) { - this.expandFold(e); - }, this); - }), - (this.unfold = function(e, t) { - var n, i; - e == null - ? ((n = new r(0, 0, this.getLength(), 0)), (t = !0)) - : typeof e == "number" - ? (n = new r(e, 0, e, this.getLine(e).length)) - : "row" in e - ? (n = r.fromPoints(e, e)) - : (n = e), - (i = this.getFoldsInRangeList(n)); - if (t) this.removeFolds(i); - else { - var s = i; - while (s.length) - this.expandFolds(s), (s = this.getFoldsInRangeList(n)); - } - if (i.length) return i; - }), - (this.isRowFolded = function(e, t) { - return !!this.getFoldLine(e, t); - }), - (this.getRowFoldEnd = function(e, t) { - var n = this.getFoldLine(e, t); - return n ? n.end.row : e; - }), - (this.getRowFoldStart = function(e, t) { - var n = this.getFoldLine(e, t); - return n ? n.start.row : e; - }), - (this.getFoldDisplayLine = function(e, t, n, r, i) { - r == null && (r = e.start.row), - i == null && (i = 0), - t == null && (t = e.end.row), - n == null && (n = this.getLine(t).length); - var s = this.doc, - o = ""; - return ( - e.walk( - function(e, t, n, u) { - if (t < r) return; - if (t == r) { - if (n < i) return; - u = Math.max(i, u); - } - e != null ? (o += e) : (o += s.getLine(t).substring(u, n)); - }, - t, - n - ), - o - ); - }), - (this.getDisplayLine = function(e, t, n, r) { - var i = this.getFoldLine(e); - if (!i) { - var s; + }), + (this.removeLines = function (e, t) { return ( - (s = this.doc.getLine(e)), s.substring(r || 0, t || s.length) + console.warn( + "Use of document.removeLines is deprecated. Use the removeFullLines method instead." + ), + this.removeFullLines(e, t) ); - } - return this.getFoldDisplayLine(i, e, t, n, r); - }), - (this.$cloneFoldData = function() { - var e = []; - return ( - (e = this.$foldData.map(function(t) { - var n = t.folds.map(function(e) { - return e.clone(); + }), + (this.insertNewLine = function (e) { + return ( + console.warn( + "Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead." + ), + this.insertMergedLines(e, ["", ""]) + ); + }), + (this.insert = function (e, t) { + return ( + this.getLength() <= 1 && this.$detectNewLine(t), + this.insertMergedLines(e, this.$split(t)) + ); + }), + (this.insertInLine = function (e, t) { + var n = this.clippedPos(e.row, e.column), + r = this.pos(e.row, e.column + t.length); + return ( + this.applyDelta( + { start: n, end: r, action: "insert", lines: [t] }, + !0 + ), + this.clonePos(r) + ); + }), + (this.clippedPos = function (e, t) { + var n = this.getLength(); + e === undefined + ? (e = n) + : e < 0 + ? (e = 0) + : e >= n && ((e = n - 1), (t = undefined)); + var r = this.getLine(e); + return ( + t == undefined && (t = r.length), + (t = Math.min(Math.max(t, 0), r.length)), + { row: e, column: t } + ); + }), + (this.clonePos = function (e) { + return { row: e.row, column: e.column }; + }), + (this.pos = function (e, t) { + return { row: e, column: t }; + }), + (this.$clipPosition = function (e) { + var t = this.getLength(); + return ( + e.row >= t + ? ((e.row = Math.max(0, t - 1)), + (e.column = this.getLine(t - 1).length)) + : ((e.row = Math.max(0, e.row)), + (e.column = Math.min( + Math.max(e.column, 0), + this.getLine(e.row).length + ))), + e + ); + }), + (this.insertFullLines = function (e, t) { + e = Math.min(Math.max(e, 0), this.getLength()); + var n = 0; + (e < this.getLength() + ? ((t = t.concat([""])), (n = 0)) + : ((t = [""].concat(t)), e--, (n = this.$lines[e].length)), + this.insertMergedLines({ row: e, column: n }, t)); + }), + (this.insertMergedLines = function (e, t) { + var n = this.clippedPos(e.row, e.column), + r = { + row: n.row + t.length - 1, + column: (t.length == 1 ? n.column : 0) + t[t.length - 1].length + }; + return ( + this.applyDelta({ start: n, end: r, action: "insert", lines: t }), + this.clonePos(r) + ); + }), + (this.remove = function (e) { + var t = this.clippedPos(e.start.row, e.start.column), + n = this.clippedPos(e.end.row, e.end.column); + return ( + this.applyDelta({ + start: t, + end: n, + action: "remove", + lines: this.getLinesForRange({ start: t, end: n }) + }), + this.clonePos(t) + ); + }), + (this.removeInLine = function (e, t, n) { + var r = this.clippedPos(e, t), + i = this.clippedPos(e, n); + return ( + this.applyDelta( + { + start: r, + end: i, + action: "remove", + lines: this.getLinesForRange({ start: r, end: i }) + }, + !0 + ), + this.clonePos(r) + ); + }), + (this.removeFullLines = function (e, t) { + ((e = Math.min(Math.max(0, e), this.getLength() - 1)), + (t = Math.min(Math.max(0, t), this.getLength() - 1))); + var n = t == this.getLength() - 1 && e > 0, + r = t < this.getLength() - 1, + i = n ? e - 1 : e, + s = n ? this.getLine(i).length : 0, + u = r ? t + 1 : t, + a = r ? 0 : this.getLine(u).length, + f = new o(i, s, u, a), + l = this.$lines.slice(e, t + 1); + return ( + this.applyDelta({ + start: f.start, + end: f.end, + action: "remove", + lines: this.getLinesForRange(f) + }), + l + ); + }), + (this.removeNewLine = function (e) { + e < this.getLength() - 1 && + e >= 0 && + this.applyDelta({ + start: this.pos(e, this.getLine(e).length), + end: this.pos(e + 1, 0), + action: "remove", + lines: ["", ""] }); - return new i(e, n); - })), - e - ); - }), - (this.toggleFold = function(e) { - var t = this.selection, - n = t.getRange(), - r, - i; - if (n.isEmpty()) { - var s = n.start; - r = this.getFoldAt(s.row, s.column); - if (r) { - this.expandFold(r); - return; - } - (i = this.findMatchingBracket(s)) - ? n.comparePoint(i) == 1 - ? (n.end = i) - : ((n.start = i), n.start.column++, n.end.column--) - : (i = this.findMatchingBracket({ - row: s.row, - column: s.column + 1 - })) - ? (n.comparePoint(i) == 1 ? (n.end = i) : (n.start = i), - n.start.column++) - : (n = this.getCommentFoldRange(s.row, s.column) || n); - } else { - var o = this.getFoldsInRange(n); - if (e && o.length) { - this.expandFolds(o); + }), + (this.replace = function (e, t) { + e instanceof o || (e = o.fromPoints(e.start, e.end)); + if (t.length === 0 && e.isEmpty()) return e.start; + if (t == this.getTextRange(e)) return e.end; + this.remove(e); + var n; + return (t ? (n = this.insert(e.start, t)) : (n = e.start), n); + }), + (this.applyDeltas = function (e) { + for (var t = 0; t < e.length; t++) this.applyDelta(e[t]); + }), + (this.revertDeltas = function (e) { + for (var t = e.length - 1; t >= 0; t--) this.revertDelta(e[t]); + }), + (this.applyDelta = function (e, t) { + var n = e.action == "insert"; + if ( + n + ? e.lines.length <= 1 && !e.lines[0] + : !o.comparePoints(e.start, e.end) + ) return; + (n && e.lines.length > 2e4 && this.$splitAndapplyLargeDelta(e, 2e4), + i(this.$lines, e, t), + this._signal("change", e)); + }), + (this.$splitAndapplyLargeDelta = function (e, t) { + var n = e.lines, + r = n.length, + i = e.start.row, + s = e.start.column, + o = 0, + u = 0; + do { + ((o = u), (u += t - 1)); + var a = n.slice(o, u); + if (u > r) { + ((e.lines = a), (e.start.row = i + o), (e.start.column = s)); + break; + } + (a.push(""), + this.applyDelta( + { + start: this.pos(i + o, s), + end: this.pos(i + u, (s = 0)), + action: e.action, + lines: a + }, + !0 + )); + } while (!0); + }), + (this.revertDelta = function (e) { + this.applyDelta({ + start: this.clonePos(e.start), + end: this.clonePos(e.end), + action: e.action == "insert" ? "remove" : "insert", + lines: e.lines.slice() + }); + }), + (this.indexToPosition = function (e, t) { + var n = this.$lines || this.getAllLines(), + r = this.getNewLineCharacter().length; + for (var i = t || 0, s = n.length; i < s; i++) { + e -= n[i].length + r; + if (e < 0) return { row: i, column: e + n[i].length + r }; } - o.length == 1 && (r = o[0]); - } - r || (r = this.getFoldAt(n.start.row, n.start.column)); - if (r && r.range.toString() == n.toString()) { - this.expandFold(r); - return; - } - var u = "..."; - if (!n.isMultiLine()) { - u = this.getTextRange(n); - if (u.length < 4) return; - u = u.trim().substring(0, 2) + ".."; - } - this.addFold(u, n); - }), - (this.getCommentFoldRange = function(e, t, n) { - var i = new o(this, e, t), - s = i.getCurrentToken(); - if (s && /^comment|string/.test(s.type)) { - var u = new r(), - a = new RegExp(s.type.replace(/\..*/, "\\.")); - if (n != 1) { - do s = i.stepBackward(); - while (s && a.test(s.type)); - i.stepForward(); - } - (u.start.row = i.getCurrentTokenRow()), - (u.start.column = i.getCurrentTokenColumn() + 2), - (i = new o(this, e, t)); - if (n != -1) { - do s = i.stepForward(); - while (s && a.test(s.type)); - s = i.stepBackward(); - } else s = i.getCurrentToken(); - return ( - (u.end.row = i.getCurrentTokenRow()), - (u.end.column = i.getCurrentTokenColumn() + s.value.length - 2), - u - ); - } - }), - (this.foldAll = function(e, t, n) { - n == undefined && (n = 1e5); - var r = this.foldWidgets; - if (!r) return; - (t = t || this.getLength()), (e = e || 0); - for (var i = e; i < t; i++) { - r[i] == null && (r[i] = this.getFoldWidget(i)); - if (r[i] != "start") continue; - var s = this.getFoldWidgetRange(i); - if (s && s.isMultiLine() && s.end.row <= t && s.start.row >= e) { - i = s.end.row; - try { - var o = this.addFold("...", s); - o && (o.collapseChildren = n); - } catch (u) {} + return { row: s - 1, column: n[s - 1].length }; + }), + (this.positionToIndex = function (e, t) { + var n = this.$lines || this.getAllLines(), + r = this.getNewLineCharacter().length, + i = 0, + s = Math.min(e.row, n.length); + for (var o = t || 0; o < s; ++o) i += n[o].length + r; + return i + e.column; + })); + }).call(a.prototype), + (t.Document = a)); + } + ), + define( + "ace/background_tokenizer", + ["require", "exports", "module", "ace/lib/oop", "ace/lib/event_emitter"], + function (e, t, n) { + "use strict"; + var r = e("./lib/oop"), + i = e("./lib/event_emitter").EventEmitter, + s = function (e, t) { + ((this.running = !1), + (this.lines = []), + (this.states = []), + (this.currentLine = 0), + (this.tokenizer = e)); + var n = this; + this.$worker = function () { + if (!n.running) return; + var e = new Date(), + t = n.currentLine, + r = -1, + i = n.doc, + s = t; + while (n.lines[t]) t++; + var o = i.getLength(), + u = 0; + n.running = !1; + while (t < o) { + (n.$tokenizeRow(t), (r = t)); + do t++; + while (n.lines[t]); + u++; + if (u % 5 === 0 && new Date() - e > 20) { + n.running = setTimeout(n.$worker, 20); + break; + } } - } - }), - (this.$foldStyles = { manual: 1, markbegin: 1, markbeginend: 1 }), - (this.$foldStyle = "markbegin"), - (this.setFoldStyle = function(e) { - if (!this.$foldStyles[e]) - throw new Error( - "invalid fold style: " + - e + - "[" + - Object.keys(this.$foldStyles).join(", ") + - "]" - ); - if (this.$foldStyle == e) return; - (this.$foldStyle = e), e == "manual" && this.unfold(); - var t = this.$foldMode; - this.$setFolding(null), this.$setFolding(t); - }), - (this.$setFolding = function(e) { - if (this.$foldMode == e) return; - (this.$foldMode = e), - this.off("change", this.$updateFoldWidgets), - this.off("tokenizerUpdate", this.$tokenizerUpdateFoldWidgets), - this._signal("changeAnnotation"); - if (!e || this.$foldStyle == "manual") { - this.foldWidgets = null; - return; - } - (this.foldWidgets = []), - (this.getFoldWidget = e.getFoldWidget.bind( - e, - this, - this.$foldStyle - )), - (this.getFoldWidgetRange = e.getFoldWidgetRange.bind( - e, - this, - this.$foldStyle + ((n.currentLine = t), s <= r && n.fireUpdateEvent(s, r)); + }; + }; + ((function () { + (r.implement(this, i), + (this.setTokenizer = function (e) { + ((this.tokenizer = e), + (this.lines = []), + (this.states = []), + this.start(0)); + }), + (this.setDocument = function (e) { + ((this.doc = e), + (this.lines = []), + (this.states = []), + this.stop()); + }), + (this.fireUpdateEvent = function (e, t) { + var n = { first: e, last: t }; + this._signal("update", { data: n }); + }), + (this.start = function (e) { + ((this.currentLine = Math.min( + e || 0, + this.currentLine, + this.doc.getLength() )), - (this.$updateFoldWidgets = this.updateFoldWidgets.bind(this)), - (this.$tokenizerUpdateFoldWidgets = this.tokenizerUpdateFoldWidgets.bind( - this + this.lines.splice(this.currentLine, this.lines.length), + this.states.splice(this.currentLine, this.states.length), + this.stop(), + (this.running = setTimeout(this.$worker, 700))); + }), + (this.scheduleStart = function () { + this.running || (this.running = setTimeout(this.$worker, 700)); + }), + (this.$updateOnChange = function (e) { + var t = e.start.row, + n = e.end.row - t; + if (n === 0) this.lines[t] = null; + else if (e.action == "remove") + (this.lines.splice(t, n + 1, null), + this.states.splice(t, n + 1, null)); + else { + var r = Array(n + 1); + (r.unshift(t, 1), + this.lines.splice.apply(this.lines, r), + this.states.splice.apply(this.states, r)); + } + ((this.currentLine = Math.min( + t, + this.currentLine, + this.doc.getLength() )), - this.on("change", this.$updateFoldWidgets), - this.on("tokenizerUpdate", this.$tokenizerUpdateFoldWidgets); - }), - (this.getParentFoldRangeData = function(e, t) { - var n = this.foldWidgets; - if (!n || (t && n[e])) return {}; - var r = e - 1, - i; - while (r >= 0) { - var s = n[r]; - s == null && (s = n[r] = this.getFoldWidget(r)); - if (s == "start") { - var o = this.getFoldWidgetRange(r); - i || (i = o); - if (o && o.end.row >= e) break; - } - r--; - } - return { range: r !== -1 && o, firstRange: i }; - }), - (this.onFoldWidgetClick = function(e, t) { - t = t.domEvent; - var n = { - children: t.shiftKey, - all: t.ctrlKey || t.metaKey, - siblings: t.altKey - }, - r = this.$toggleFoldWidget(e, n); - if (!r) { - var i = t.target || t.srcElement; - i && - /ace_fold-widget/.test(i.className) && - (i.className += " ace_invalid"); - } - }), - (this.$toggleFoldWidget = function(e, t) { - if (!this.getFoldWidget) return; - var n = this.getFoldWidget(e), - r = this.getLine(e), - i = n === "end" ? -1 : 1, - s = this.getFoldAt(e, i === -1 ? 0 : r.length, i); - if (s) + this.stop()); + }), + (this.stop = function () { + (this.running && clearTimeout(this.running), (this.running = !1)); + }), + (this.getTokens = function (e) { + return this.lines[e] || this.$tokenizeRow(e); + }), + (this.getState = function (e) { return ( - t.children || t.all ? this.removeFold(s) : this.expandFold(s), s + this.currentLine == e && this.$tokenizeRow(e), + this.states[e] || "start" ); - var o = this.getFoldWidgetRange(e, !0); - if (o && !o.isMultiLine()) { - s = this.getFoldAt(o.start.row, o.start.column, 1); - if (s && o.isEqual(s.range)) return this.removeFold(s), s; - } - if (t.siblings) { - var u = this.getParentFoldRangeData(e); - if (u.range) - var a = u.range.start.row + 1, - f = u.range.end.row; - this.foldAll(a, f, t.all ? 1e4 : 0); - } else - t.children - ? ((f = o ? o.end.row : this.getLength()), - this.foldAll(e + 1, f, t.all ? 1e4 : 0)) - : o && - (t.all && (o.collapseChildren = 1e4), this.addFold("...", o)); - return o; - }), - (this.toggleFoldWidget = function(e) { - var t = this.selection.getCursor().row; - t = this.getRowFoldStart(t); - var n = this.$toggleFoldWidget(t, {}); - if (n) return; - var r = this.getParentFoldRangeData(t, !0); - n = r.range || r.firstRange; - if (n) { - t = n.start.row; - var i = this.getFoldAt(t, this.getLine(t).length, 1); - i ? this.removeFold(i) : this.addFold("...", n); - } - }), - (this.updateFoldWidgets = function(e) { - var t = e.start.row, - n = e.end.row - t; - if (n === 0) this.foldWidgets[t] = null; - else if (e.action == "remove") - this.foldWidgets.splice(t, n + 1, null); - else { - var r = Array(n + 1); - r.unshift(t, 1), this.foldWidgets.splice.apply(this.foldWidgets, r); - } - }), - (this.tokenizerUpdateFoldWidgets = function(e) { - var t = e.data; - t.first != t.last && - this.foldWidgets.length > t.first && - this.foldWidgets.splice(t.first, this.foldWidgets.length); - }); + }), + (this.$tokenizeRow = function (e) { + var t = this.doc.getLine(e), + n = this.states[e - 1], + r = this.tokenizer.getLineTokens(t, n, e); + return ( + this.states[e] + "" != r.state + "" + ? ((this.states[e] = r.state), + (this.lines[e + 1] = null), + this.currentLine > e + 1 && (this.currentLine = e + 1)) + : this.currentLine == e && (this.currentLine = e + 1), + (this.lines[e] = r.tokens) + ); + })); + }).call(s.prototype), + (t.BackgroundTokenizer = s)); } - var r = e("../range").Range, - i = e("./fold_line").FoldLine, - s = e("./fold").Fold, - o = e("../token_iterator").TokenIterator; - t.Folding = u; - }), - define("ace/edit_session/bracket_match", [ - "require", - "exports", - "module", - "ace/token_iterator", - "ace/range" - ], function(e, t, n) { - "use strict"; - function s() { - (this.findMatchingBracket = function(e, t) { - if (e.column == 0) return null; - var n = t || this.getLine(e.row).charAt(e.column - 1); - if (n == "") return null; - var r = n.match(/([\(\[\{])|([\)\]\}])/); - return r - ? r[1] - ? this.$findClosingBracket(r[1], e) - : this.$findOpeningBracket(r[2], e) - : null; - }), - (this.getBracketRange = function(e) { - var t = this.getLine(e.row), - n = !0, - r, - s = t.charAt(e.column - 1), - o = s && s.match(/([\(\[\{])|([\)\]\}])/); - o || - ((s = t.charAt(e.column)), - (e = { row: e.row, column: e.column + 1 }), - (o = s && s.match(/([\(\[\{])|([\)\]\}])/)), - (n = !1)); - if (!o) return null; - if (o[1]) { - var u = this.$findClosingBracket(o[1], e); - if (!u) return null; - (r = i.fromPoints(e, u)), - n || (r.end.column++, r.start.column--), - (r.cursor = r.end); - } else { - var u = this.$findOpeningBracket(o[2], e); - if (!u) return null; - (r = i.fromPoints(u, e)), - n || (r.start.column++, r.end.column--), - (r.cursor = r.start); - } - return r; - }), - (this.$brackets = { - ")": "(", - "(": ")", - "]": "[", - "[": "]", - "{": "}", - "}": "{" - }), - (this.$findOpeningBracket = function(e, t, n) { - var i = this.$brackets[e], - s = 1, - o = new r(this, t.row, t.column), - u = o.getCurrentToken(); - u || (u = o.stepForward()); - if (!u) return; - n || - (n = new RegExp( - "(\\.?" + - u.type - .replace(".", "\\.") - .replace("rparen", ".paren") - .replace(/\b(?:end)\b/, "(?:start|begin|end)") + - ")+" - )); - var a = t.column - o.getCurrentTokenColumn() - 2, - f = u.value; - for (;;) { - while (a >= 0) { - var l = f.charAt(a); - if (l == i) { - s -= 1; - if (s == 0) - return { - row: o.getCurrentTokenRow(), - column: a + o.getCurrentTokenColumn() - }; - } else l == e && (s += 1); - a -= 1; - } - do u = o.stepBackward(); - while (u && !n.test(u.type)); - if (u == null) break; - (f = u.value), (a = f.length - 1); - } - return null; - }), - (this.$findClosingBracket = function(e, t, n) { - var i = this.$brackets[e], - s = 1, - o = new r(this, t.row, t.column), - u = o.getCurrentToken(); - u || (u = o.stepForward()); - if (!u) return; - n || - (n = new RegExp( - "(\\.?" + - u.type - .replace(".", "\\.") - .replace("lparen", ".paren") - .replace(/\b(?:start|begin)\b/, "(?:start|begin|end)") + - ")+" - )); - var a = t.column - o.getCurrentTokenColumn(); - for (;;) { - var f = u.value, - l = f.length; - while (a < l) { - var c = f.charAt(a); - if (c == i) { - s -= 1; - if (s == 0) - return { - row: o.getCurrentTokenRow(), - column: a + o.getCurrentTokenColumn() - }; - } else c == e && (s += 1); - a += 1; + ), + define( + "ace/search_highlight", + [ + "require", + "exports", + "module", + "ace/lib/lang", + "ace/lib/oop", + "ace/range" + ], + function (e, t, n) { + "use strict"; + var r = e("./lib/lang"), + i = e("./lib/oop"), + s = e("./range").Range, + o = function (e, t, n) { + (this.setRegexp(e), (this.clazz = t), (this.type = n || "text")); + }; + ((function () { + ((this.MAX_RANGES = 500), + (this.setRegexp = function (e) { + if (this.regExp + "" == e + "") return; + ((this.regExp = e), (this.cache = [])); + }), + (this.update = function (e, t, n, i) { + if (!this.regExp) return; + var o = i.firstRow, + u = i.lastRow; + for (var a = o; a <= u; a++) { + var f = this.cache[a]; + f == null && + ((f = r.getMatchOffsets(n.getLine(a), this.regExp)), + f.length > this.MAX_RANGES && (f = f.slice(0, this.MAX_RANGES)), + (f = f.map(function (e) { + return new s(a, e.offset, a, e.offset + e.length); + })), + (this.cache[a] = f.length ? f : "")); + for (var l = f.length; l--;) + t.drawSingleLineMarker(e, f[l].toScreenRange(n), this.clazz, i); } - do u = o.stepForward(); - while (u && !n.test(u.type)); - if (u == null) break; - a = 0; - } - return null; - }); + })); + }).call(o.prototype), + (t.SearchHighlight = o)); } - var r = e("../token_iterator").TokenIterator, - i = e("../range").Range; - t.BracketMatch = s; - }), - define("ace/edit_session", [ - "require", - "exports", - "module", - "ace/lib/oop", - "ace/lib/lang", - "ace/config", - "ace/lib/event_emitter", - "ace/selection", - "ace/mode/text", - "ace/range", - "ace/document", - "ace/background_tokenizer", - "ace/search_highlight", - "ace/edit_session/folding", - "ace/edit_session/bracket_match" - ], function(e, t, n) { - "use strict"; - var r = e("./lib/oop"), - i = e("./lib/lang"), - s = e("./config"), - o = e("./lib/event_emitter").EventEmitter, - u = e("./selection").Selection, - a = e("./mode/text").Mode, - f = e("./range").Range, - l = e("./document").Document, - c = e("./background_tokenizer").BackgroundTokenizer, - h = e("./search_highlight").SearchHighlight, - p = function(e, t) { - (this.$breakpoints = []), - (this.$decorations = []), - (this.$frontMarkers = {}), - (this.$backMarkers = {}), - (this.$markerId = 1), - (this.$undoSelect = !0), - (this.$foldData = []), - (this.id = "session" + ++p.$uid), - (this.$foldData.toString = function() { - return this.join("\n"); - }), - this.on("changeFold", this.onChangeFold.bind(this)), - (this.$onChange = this.onChange.bind(this)); - if (typeof e != "object" || !e.getLine) e = new l(e); - this.setDocument(e), - (this.selection = new u(this)), - s.resetOptions(this), - this.setMode(t), - s._signal("session", this); - }; - (function() { - function m(e) { - return e < 4352 - ? !1 - : (e >= 4352 && e <= 4447) || - (e >= 4515 && e <= 4519) || - (e >= 4602 && e <= 4607) || - (e >= 9001 && e <= 9002) || - (e >= 11904 && e <= 11929) || - (e >= 11931 && e <= 12019) || - (e >= 12032 && e <= 12245) || - (e >= 12272 && e <= 12283) || - (e >= 12288 && e <= 12350) || - (e >= 12353 && e <= 12438) || - (e >= 12441 && e <= 12543) || - (e >= 12549 && e <= 12589) || - (e >= 12593 && e <= 12686) || - (e >= 12688 && e <= 12730) || - (e >= 12736 && e <= 12771) || - (e >= 12784 && e <= 12830) || - (e >= 12832 && e <= 12871) || - (e >= 12880 && e <= 13054) || - (e >= 13056 && e <= 19903) || - (e >= 19968 && e <= 42124) || - (e >= 42128 && e <= 42182) || - (e >= 43360 && e <= 43388) || - (e >= 44032 && e <= 55203) || - (e >= 55216 && e <= 55238) || - (e >= 55243 && e <= 55291) || - (e >= 63744 && e <= 64255) || - (e >= 65040 && e <= 65049) || - (e >= 65072 && e <= 65106) || - (e >= 65108 && e <= 65126) || - (e >= 65128 && e <= 65131) || - (e >= 65281 && e <= 65376) || - (e >= 65504 && e <= 65510); + ), + define( + "ace/edit_session/fold_line", + ["require", "exports", "module", "ace/range"], + function (e, t, n) { + "use strict"; + function i(e, t) { + ((this.foldData = e), + Array.isArray(t) ? (this.folds = t) : (t = this.folds = [t])); + var n = t[t.length - 1]; + ((this.range = new r( + t[0].start.row, + t[0].start.column, + n.end.row, + n.end.column + )), + (this.start = this.range.start), + (this.end = this.range.end), + this.folds.forEach(function (e) { + e.setFoldLine(this); + }, this)); } - r.implement(this, o), - (this.setDocument = function(e) { - this.doc && this.doc.removeListener("change", this.$onChange), - (this.doc = e), - e.on("change", this.$onChange), - this.bgTokenizer && - this.bgTokenizer.setDocument(this.getDocument()), - this.resetCaches(); - }), - (this.getDocument = function() { - return this.doc; - }), - (this.$resetRowCache = function(e) { - if (!e) { - (this.$docRowCache = []), (this.$screenRowCache = []); - return; - } - var t = this.$docRowCache.length, - n = this.$getRowCacheIndex(this.$docRowCache, e) + 1; - t > n && - (this.$docRowCache.splice(n, t), this.$screenRowCache.splice(n, t)); - }), - (this.$getRowCacheIndex = function(e, t) { - var n = 0, - r = e.length - 1; - while (n <= r) { - var i = (n + r) >> 1, - s = e[i]; - if (t > s) n = i + 1; + var r = e("../range").Range; + ((function () { + ((this.shiftRow = function (e) { + ((this.start.row += e), + (this.end.row += e), + this.folds.forEach(function (t) { + ((t.start.row += e), (t.end.row += e)); + })); + }), + (this.addFold = function (e) { + if (e.sameRow) { + if (e.start.row < this.startRow || e.endRow > this.endRow) + throw new Error( + "Can't add a fold to this FoldLine as it has no connection" + ); + (this.folds.push(e), + this.folds.sort(function (e, t) { + return -e.range.compareEnd(t.start.row, t.start.column); + }), + this.range.compareEnd(e.start.row, e.start.column) > 0 + ? ((this.end.row = e.end.row), + (this.end.column = e.end.column)) + : this.range.compareStart(e.end.row, e.end.column) < 0 && + ((this.start.row = e.start.row), + (this.start.column = e.start.column))); + } else if (e.start.row == this.end.row) + (this.folds.push(e), + (this.end.row = e.end.row), + (this.end.column = e.end.column)); else { - if (!(t < s)) return i; - r = i - 1; + if (e.end.row != this.start.row) + throw new Error( + "Trying to add fold to FoldRow that doesn't have a matching row" + ); + (this.folds.unshift(e), + (this.start.row = e.start.row), + (this.start.column = e.start.column)); } - } - return n - 1; - }), - (this.resetCaches = function() { - (this.$modified = !0), - (this.$wrapData = []), - (this.$rowLengthCache = []), - this.$resetRowCache(0), - this.bgTokenizer && this.bgTokenizer.start(0); - }), - (this.onChangeFold = function(e) { - var t = e.data; - this.$resetRowCache(t.start.row); - }), - (this.onChange = function(e) { - (this.$modified = !0), this.$resetRowCache(e.start.row); - var t = this.$updateInternalDataOnChange(e); - !this.$fromUndo && - this.$undoManager && - !e.ignore && - (this.$deltasDoc.push(e), - t && - t.length != 0 && - this.$deltasFold.push({ action: "removeFolds", folds: t }), - this.$informUndoManager.schedule()), - this.bgTokenizer && this.bgTokenizer.$updateOnChange(e), - this._signal("change", e); - }), - (this.setValue = function(e) { - this.doc.setValue(e), - this.selection.moveTo(0, 0), - this.$resetRowCache(0), - (this.$deltas = []), - (this.$deltasDoc = []), - (this.$deltasFold = []), - this.setUndoManager(this.$undoManager), - this.getUndoManager().reset(); - }), - (this.getValue = this.toString = function() { - return this.doc.getValue(); - }), - (this.getSelection = function() { - return this.selection; - }), - (this.getState = function(e) { - return this.bgTokenizer.getState(e); - }), - (this.getTokens = function(e) { - return this.bgTokenizer.getTokens(e); - }), - (this.getTokenAt = function(e, t) { - var n = this.bgTokenizer.getTokens(e), - r, - i = 0; - if (t == null) (s = n.length - 1), (i = this.getLine(e).length); - else - for (var s = 0; s < n.length; s++) { - i += n[s].value.length; - if (i >= t) break; + e.foldLine = this; + }), + (this.containsRow = function (e) { + return e >= this.start.row && e <= this.end.row; + }), + (this.walk = function (e, t, n) { + var r = 0, + i = this.folds, + s, + o, + u, + a = !0; + t == null && ((t = this.end.row), (n = this.end.column)); + for (var f = 0; f < i.length; f++) { + ((s = i[f]), (o = s.range.compareStart(t, n))); + if (o == -1) { + e(null, t, n, r, a); + return; + } + ((u = e(null, s.start.row, s.start.column, r, a)), + (u = !u && e(s.placeholder, s.start.row, s.start.column, r))); + if (u || o === 0) return; + ((a = !s.sameRow), (r = s.end.column)); } - return ( - (r = n[s]), - r ? ((r.index = s), (r.start = i - r.value.length), r) : null - ); - }), - (this.setUndoManager = function(e) { - (this.$undoManager = e), - (this.$deltas = []), - (this.$deltasDoc = []), - (this.$deltasFold = []), - this.$informUndoManager && this.$informUndoManager.cancel(); - if (e) { - var t = this; - (this.$syncInformUndoManager = function() { - t.$informUndoManager.cancel(), - t.$deltasFold.length && - (t.$deltas.push({ group: "fold", deltas: t.$deltasFold }), - (t.$deltasFold = [])), - t.$deltasDoc.length && - (t.$deltas.push({ group: "doc", deltas: t.$deltasDoc }), - (t.$deltasDoc = [])), - t.$deltas.length > 0 && - e.execute({ - action: "aceupdate", - args: [t.$deltas, t], - merge: t.mergeUndoDeltas - }), - (t.mergeUndoDeltas = !1), - (t.$deltas = []); - }), - (this.$informUndoManager = i.delayedCall( - this.$syncInformUndoManager - )); - } - }), - (this.markUndoGroup = function() { - this.$syncInformUndoManager && this.$syncInformUndoManager(); - }), - (this.$defaultUndoManager = { - undo: function() {}, - redo: function() {}, - reset: function() {} - }), - (this.getUndoManager = function() { - return this.$undoManager || this.$defaultUndoManager; - }), - (this.getTabString = function() { - return this.getUseSoftTabs() - ? i.stringRepeat(" ", this.getTabSize()) - : " "; - }), - (this.setUseSoftTabs = function(e) { - this.setOption("useSoftTabs", e); - }), - (this.getUseSoftTabs = function() { - return this.$useSoftTabs && !this.$mode.$indentWithTabs; - }), - (this.setTabSize = function(e) { - this.setOption("tabSize", e); - }), - (this.getTabSize = function() { - return this.$tabSize; - }), - (this.isTabStop = function(e) { - return this.$useSoftTabs && e.column % this.$tabSize === 0; - }), - (this.$overwrite = !1), - (this.setOverwrite = function(e) { - this.setOption("overwrite", e); - }), - (this.getOverwrite = function() { - return this.$overwrite; - }), - (this.toggleOverwrite = function() { - this.setOverwrite(!this.$overwrite); - }), - (this.addGutterDecoration = function(e, t) { - this.$decorations[e] || (this.$decorations[e] = ""), - (this.$decorations[e] += " " + t), - this._signal("changeBreakpoint", {}); - }), - (this.removeGutterDecoration = function(e, t) { - (this.$decorations[e] = (this.$decorations[e] || "").replace( - " " + t, - "" - )), - this._signal("changeBreakpoint", {}); - }), - (this.getBreakpoints = function() { - return this.$breakpoints; - }), - (this.setBreakpoints = function(e) { - this.$breakpoints = []; - for (var t = 0; t < e.length; t++) - this.$breakpoints[e[t]] = "ace_breakpoint"; - this._signal("changeBreakpoint", {}); - }), - (this.clearBreakpoints = function() { - (this.$breakpoints = []), this._signal("changeBreakpoint", {}); - }), - (this.setBreakpoint = function(e, t) { - t === undefined && (t = "ace_breakpoint"), - t ? (this.$breakpoints[e] = t) : delete this.$breakpoints[e], - this._signal("changeBreakpoint", {}); - }), - (this.clearBreakpoint = function(e) { - delete this.$breakpoints[e], this._signal("changeBreakpoint", {}); - }), - (this.addMarker = function(e, t, n, r) { - var i = this.$markerId++, - s = { - range: e, - type: n || "line", - renderer: typeof n == "function" ? n : null, - clazz: t, - inFront: !!r, - id: i - }; - return ( - r - ? ((this.$frontMarkers[i] = s), this._signal("changeFrontMarker")) - : ((this.$backMarkers[i] = s), this._signal("changeBackMarker")), - i - ); - }), - (this.addDynamicMarker = function(e, t) { - if (!e.update) return; - var n = this.$markerId++; - return ( - (e.id = n), - (e.inFront = !!t), - t - ? ((this.$frontMarkers[n] = e), this._signal("changeFrontMarker")) - : ((this.$backMarkers[n] = e), this._signal("changeBackMarker")), - e - ); - }), - (this.removeMarker = function(e) { - var t = this.$frontMarkers[e] || this.$backMarkers[e]; - if (!t) return; - var n = t.inFront ? this.$frontMarkers : this.$backMarkers; - t && - (delete n[e], - this._signal(t.inFront ? "changeFrontMarker" : "changeBackMarker")); - }), - (this.getMarkers = function(e) { - return e ? this.$frontMarkers : this.$backMarkers; - }), - (this.highlight = function(e) { - if (!this.$searchHighlight) { - var t = new h(null, "ace_selected-word", "text"); - this.$searchHighlight = this.addDynamicMarker(t); - } - this.$searchHighlight.setRegexp(e); - }), - (this.highlightLines = function(e, t, n, r) { - typeof t != "number" && ((n = t), (t = e)), n || (n = "ace_step"); - var i = new f(e, 0, t, Infinity); - return (i.id = this.addMarker(i, n, "fullLine", r)), i; - }), - (this.setAnnotations = function(e) { - (this.$annotations = e), this._signal("changeAnnotation", {}); - }), - (this.getAnnotations = function() { - return this.$annotations || []; - }), - (this.clearAnnotations = function() { - this.setAnnotations([]); - }), - (this.$detectNewLine = function(e) { - var t = e.match(/^.*?(\r?\n)/m); - t ? (this.$autoNewLine = t[1]) : (this.$autoNewLine = "\n"); - }), - (this.getWordRange = function(e, t) { - var n = this.getLine(e), - r = !1; - t > 0 && (r = !!n.charAt(t - 1).match(this.tokenRe)), - r || (r = !!n.charAt(t).match(this.tokenRe)); - if (r) var i = this.tokenRe; - else if (/^\s+$/.test(n.slice(t - 1, t + 1))) var i = /\s/; - else var i = this.nonTokenRe; - var s = t; - if (s > 0) { - do s--; - while (s >= 0 && n.charAt(s).match(i)); - s++; - } - var o = t; - while (o < n.length && n.charAt(o).match(i)) o++; - return new f(e, s, e, o); - }), - (this.getAWordRange = function(e, t) { - var n = this.getWordRange(e, t), - r = this.getLine(n.end.row); - while (r.charAt(n.end.column).match(/[ \t]/)) n.end.column += 1; - return n; - }), - (this.setNewLineMode = function(e) { - this.doc.setNewLineMode(e); - }), - (this.getNewLineMode = function() { - return this.doc.getNewLineMode(); - }), - (this.setUseWorker = function(e) { - this.setOption("useWorker", e); - }), - (this.getUseWorker = function() { - return this.$useWorker; - }), - (this.onReloadTokenizer = function(e) { - var t = e.data; - this.bgTokenizer.start(t.first), this._signal("tokenizerUpdate", e); - }), - (this.$modes = {}), - (this.$mode = null), - (this.$modeId = null), - (this.setMode = function(e, t) { - if (e && typeof e == "object") { - if (e.getTokenizer) return this.$onChangeMode(e); - var n = e, - r = n.path; - } else r = e || "ace/mode/text"; - this.$modes["ace/mode/text"] || - (this.$modes["ace/mode/text"] = new a()); - if (this.$modes[r] && !n) { - this.$onChangeMode(this.$modes[r]), t && t(); - return; - } - (this.$modeId = r), - s.loadModule( - ["mode", r], - function(e) { - if (this.$modeId !== r) return t && t(); - this.$modes[r] && !n - ? this.$onChangeMode(this.$modes[r]) - : e && - e.Mode && - ((e = new e.Mode(n)), - n || ((this.$modes[r] = e), (e.$id = r)), - this.$onChangeMode(e)), - t && t(); - }.bind(this) - ), - this.$mode || this.$onChangeMode(this.$modes["ace/mode/text"], !0); - }), - (this.$onChangeMode = function(e, t) { - t || (this.$modeId = e.$id); - if (this.$mode === e) return; - (this.$mode = e), - this.$stopWorker(), - this.$useWorker && this.$startWorker(); - var n = e.getTokenizer(); - if (n.addEventListener !== undefined) { - var r = this.onReloadTokenizer.bind(this); - n.addEventListener("update", r); - } - if (!this.bgTokenizer) { - this.bgTokenizer = new c(n); - var i = this; - this.bgTokenizer.addEventListener("update", function(e) { - i._signal("tokenizerUpdate", e); - }); - } else this.bgTokenizer.setTokenizer(n); - this.bgTokenizer.setDocument(this.getDocument()), - (this.tokenRe = e.tokenRe), - (this.nonTokenRe = e.nonTokenRe), - t || - (e.attachToSession && e.attachToSession(this), - this.$options.wrapMethod.set.call(this, this.$wrapMethod), - this.$setFolding(e.foldingRules), - this.bgTokenizer.start(0), - this._emit("changeMode")); - }), - (this.$stopWorker = function() { - this.$worker && (this.$worker.terminate(), (this.$worker = null)); - }), - (this.$startWorker = function() { - try { - this.$worker = this.$mode.createWorker(this); - } catch (e) { - s.warn("Could not load worker", e), (this.$worker = null); - } - }), - (this.getMode = function() { - return this.$mode; - }), - (this.$scrollTop = 0), - (this.setScrollTop = function(e) { - if (this.$scrollTop === e || isNaN(e)) return; - (this.$scrollTop = e), this._signal("changeScrollTop", e); - }), - (this.getScrollTop = function() { - return this.$scrollTop; - }), - (this.$scrollLeft = 0), - (this.setScrollLeft = function(e) { - if (this.$scrollLeft === e || isNaN(e)) return; - (this.$scrollLeft = e), this._signal("changeScrollLeft", e); - }), - (this.getScrollLeft = function() { - return this.$scrollLeft; - }), - (this.getScreenWidth = function() { - return ( - this.$computeWidth(), - this.lineWidgets - ? Math.max(this.getLineWidgetMaxWidth(), this.screenWidth) - : this.screenWidth - ); - }), - (this.getLineWidgetMaxWidth = function() { - if (this.lineWidgetsWidth != null) return this.lineWidgetsWidth; - var e = 0; - return ( - this.lineWidgets.forEach(function(t) { - t && t.screenWidth > e && (e = t.screenWidth); - }), - (this.lineWidgetWidth = e) - ); - }), - (this.$computeWidth = function(e) { - if (this.$modified || e) { - this.$modified = !1; - if (this.$useWrapMode) return (this.screenWidth = this.$wrapLimit); - var t = this.doc.getAllLines(), - n = this.$rowLengthCache, - r = 0, - i = 0, - s = this.$foldData[i], - o = s ? s.start.row : Infinity, - u = t.length; - for (var a = 0; a < u; a++) { - if (a > o) { - a = s.end.row + 1; - if (a >= u) break; - (s = this.$foldData[i++]), (o = s ? s.start.row : Infinity); + e(null, t, n, r, a); + }), + (this.getNextFoldTo = function (e, t) { + var n, r; + for (var i = 0; i < this.folds.length; i++) { + ((n = this.folds[i]), (r = n.range.compareEnd(e, t))); + if (r == -1) return { fold: n, kind: "after" }; + if (r === 0) return { fold: n, kind: "inside" }; + } + return null; + }), + (this.addRemoveChars = function (e, t, n) { + var r = this.getNextFoldTo(e, t), + i, + s; + if (r) { + i = r.fold; + if (r.kind == "inside" && i.start.column != t && i.start.row != e) + window.console && window.console.log(e, t, i); + else if (i.start.row == e) { + s = this.folds; + var o = s.indexOf(i); + o === 0 && (this.start.column += n); + for (o; o < s.length; o++) { + ((i = s[o]), (i.start.column += n)); + if (!i.sameRow) return; + i.end.column += n; + } + this.end.column += n; } - n[a] == null && (n[a] = this.$getStringScreenWidth(t[a])[0]), - n[a] > r && (r = n[a]); } - this.screenWidth = r; - } - }), - (this.getLine = function(e) { - return this.doc.getLine(e); - }), - (this.getLines = function(e, t) { - return this.doc.getLines(e, t); - }), - (this.getLength = function() { - return this.doc.getLength(); - }), - (this.getTextRange = function(e) { - return this.doc.getTextRange(e || this.selection.getRange()); - }), - (this.insert = function(e, t) { - return this.doc.insert(e, t); - }), - (this.remove = function(e) { - return this.doc.remove(e); - }), - (this.removeFullLines = function(e, t) { - return this.doc.removeFullLines(e, t); - }), - (this.undoChanges = function(e, t) { - if (!e.length) return; - this.$fromUndo = !0; - var n = null; - for (var r = e.length - 1; r != -1; r--) { - var i = e[r]; - i.group == "doc" - ? (this.doc.revertDeltas(i.deltas), - (n = this.$getUndoSelection(i.deltas, !0, n))) - : i.deltas.forEach(function(e) { - this.addFolds(e.folds); - }, this); - } - return ( - (this.$fromUndo = !1), - n && this.$undoSelect && !t && this.selection.setSelectionRange(n), - n - ); - }), - (this.redoChanges = function(e, t) { - if (!e.length) return; - this.$fromUndo = !0; - var n = null; - for (var r = 0; r < e.length; r++) { - var i = e[r]; - i.group == "doc" && - (this.doc.applyDeltas(i.deltas), - (n = this.$getUndoSelection(i.deltas, !1, n))); - } - return ( - (this.$fromUndo = !1), - n && this.$undoSelect && !t && this.selection.setSelectionRange(n), - n - ); - }), - (this.setUndoSelect = function(e) { - this.$undoSelect = e; - }), - (this.$getUndoSelection = function(e, t, n) { - function r(e) { - return t ? e.action !== "insert" : e.action === "insert"; - } - var i = e[0], - s, - o, - u = !1; - r(i) - ? ((s = f.fromPoints(i.start, i.end)), (u = !0)) - : ((s = f.fromPoints(i.start, i.start)), (u = !1)); - for (var a = 1; a < e.length; a++) - (i = e[a]), - r(i) - ? ((o = i.start), - s.compare(o.row, o.column) == -1 && s.setStart(o), - (o = i.end), - s.compare(o.row, o.column) == 1 && s.setEnd(o), - (u = !0)) - : ((o = i.start), - s.compare(o.row, o.column) == -1 && - (s = f.fromPoints(i.start, i.start)), - (u = !1)); - if (n != null) { - f.comparePoints(n.start, s.start) === 0 && - ((n.start.column += s.end.column - s.start.column), - (n.end.column += s.end.column - s.start.column)); - var l = n.compareRange(s); - l == 1 ? s.setStart(n.start) : l == -1 && s.setEnd(n.end); - } - return s; - }), - (this.replace = function(e, t) { - return this.doc.replace(e, t); - }), - (this.moveText = function(e, t, n) { - var r = this.getTextRange(e), - i = this.getFoldsInRange(e), - s = f.fromPoints(t, t); - if (!n) { - this.remove(e); - var o = e.start.row - e.end.row, - u = o ? -e.end.column : e.start.column - e.end.column; - u && - (s.start.row == e.end.row && - s.start.column > e.end.column && - (s.start.column += u), - s.end.row == e.end.row && - s.end.column > e.end.column && - (s.end.column += u)), - o && - s.start.row >= e.end.row && - ((s.start.row += o), (s.end.row += o)); - } - s.end = this.insert(s.start, r); - if (i.length) { - var a = e.start, - l = s.start, - o = l.row - a.row, - u = l.column - a.column; - this.addFolds( - i.map(function(e) { - return ( - (e = e.clone()), - e.start.row == a.row && (e.start.column += u), - e.end.row == a.row && (e.end.column += u), - (e.start.row += o), - (e.end.row += o), - e - ); - }) + }), + (this.split = function (e, t) { + var n = this.getNextFoldTo(e, t); + if (!n || n.kind == "inside") return null; + var r = n.fold, + s = this.folds, + o = this.foldData, + u = s.indexOf(r), + a = s[u - 1]; + ((this.end.row = a.end.row), + (this.end.column = a.end.column), + (s = s.splice(u, s.length - u))); + var f = new i(o, s); + return (o.splice(o.indexOf(this) + 1, 0, f), f); + }), + (this.merge = function (e) { + var t = e.folds; + for (var n = 0; n < t.length; n++) this.addFold(t[n]); + var r = this.foldData; + r.splice(r.indexOf(e), 1); + }), + (this.toString = function () { + var e = [this.range.toString() + ": ["]; + return ( + this.folds.forEach(function (t) { + e.push(" " + t.toString()); + }), + e.push("]"), + e.join("\n") ); - } - return s; - }), - (this.indentRows = function(e, t, n) { - n = n.replace(/\t/g, this.getTabString()); - for (var r = e; r <= t; r++) - this.doc.insertInLine({ row: r, column: 0 }, n); - }), - (this.outdentRows = function(e) { - var t = e.collapseRows(), - n = new f(0, 0, 0, 0), - r = this.getTabSize(); - for (var i = t.start.row; i <= t.end.row; ++i) { - var s = this.getLine(i); - (n.start.row = i), (n.end.row = i); - for (var o = 0; o < r; ++o) if (s.charAt(o) != " ") break; - o < r && s.charAt(o) == " " - ? ((n.start.column = o), (n.end.column = o + 1)) - : ((n.start.column = 0), (n.end.column = o)), - this.remove(n); - } - }), - (this.$moveLines = function(e, t, n) { - (e = this.getRowFoldStart(e)), (t = this.getRowFoldEnd(t)); - if (n < 0) { - var r = this.getRowFoldStart(e + n); - if (r < 0) return 0; - var i = r - e; - } else if (n > 0) { - var r = this.getRowFoldEnd(t + n); - if (r > this.doc.getLength() - 1) return 0; - var i = r - t; - } else { - (e = this.$clipRowToDocument(e)), (t = this.$clipRowToDocument(t)); - var i = t - e + 1; - } - var s = new f(e, 0, t, Number.MAX_VALUE), - o = this.getFoldsInRange(s).map(function(e) { - return (e = e.clone()), (e.start.row += i), (e.end.row += i), e; - }), - u = - n == 0 ? this.doc.getLines(e, t) : this.doc.removeFullLines(e, t); - return ( - this.doc.insertFullLines(e + i, u), o.length && this.addFolds(o), i - ); - }), - (this.moveLinesUp = function(e, t) { - return this.$moveLines(e, t, -1); - }), - (this.moveLinesDown = function(e, t) { - return this.$moveLines(e, t, 1); - }), - (this.duplicateLines = function(e, t) { - return this.$moveLines(e, t, 0); - }), - (this.$clipRowToDocument = function(e) { - return Math.max(0, Math.min(e, this.doc.getLength() - 1)); - }), - (this.$clipColumnToRow = function(e, t) { - return t < 0 ? 0 : Math.min(this.doc.getLine(e).length, t); - }), - (this.$clipPositionToDocument = function(e, t) { - t = Math.max(0, t); - if (e < 0) (e = 0), (t = 0); - else { - var n = this.doc.getLength(); - e >= n - ? ((e = n - 1), (t = this.doc.getLine(n - 1).length)) - : (t = Math.min(this.doc.getLine(e).length, t)); - } - return { row: e, column: t }; - }), - (this.$clipRangeToDocument = function(e) { - e.start.row < 0 - ? ((e.start.row = 0), (e.start.column = 0)) - : (e.start.column = this.$clipColumnToRow( - e.start.row, - e.start.column - )); - var t = this.doc.getLength() - 1; - return ( - e.end.row > t - ? ((e.end.row = t), (e.end.column = this.doc.getLine(t).length)) - : (e.end.column = this.$clipColumnToRow(e.end.row, e.end.column)), - e - ); - }), - (this.$wrapLimit = 80), - (this.$useWrapMode = !1), - (this.$wrapLimitRange = { min: null, max: null }), - (this.setUseWrapMode = function(e) { - if (e != this.$useWrapMode) { - (this.$useWrapMode = e), - (this.$modified = !0), - this.$resetRowCache(0); - if (e) { - var t = this.getLength(); - (this.$wrapData = Array(t)), this.$updateWrapData(0, t - 1); + }), + (this.idxToPosition = function (e) { + var t = 0; + for (var n = 0; n < this.folds.length; n++) { + var r = this.folds[n]; + e -= r.start.column - t; + if (e < 0) + return { row: r.start.row, column: r.start.column + e }; + e -= r.placeholder.length; + if (e < 0) return r.start; + t = r.end.column; } - this._signal("changeWrapMode"); - } - }), - (this.getUseWrapMode = function() { - return this.$useWrapMode; - }), - (this.setWrapLimitRange = function(e, t) { - if (this.$wrapLimitRange.min !== e || this.$wrapLimitRange.max !== t) - (this.$wrapLimitRange = { min: e, max: t }), - (this.$modified = !0), - this.$useWrapMode && this._signal("changeWrapMode"); - }), - (this.adjustWrapLimit = function(e, t) { - var n = this.$wrapLimitRange; - n.max < 0 && (n = { min: t, max: t }); - var r = this.$constrainWrapLimit(e, n.min, n.max); - return r != this.$wrapLimit && r > 1 - ? ((this.$wrapLimit = r), - (this.$modified = !0), - this.$useWrapMode && - (this.$updateWrapData(0, this.getLength() - 1), - this.$resetRowCache(0), - this._signal("changeWrapLimit")), - !0) - : !1; - }), - (this.$constrainWrapLimit = function(e, t, n) { - return t && (e = Math.max(t, e)), n && (e = Math.min(n, e)), e; - }), - (this.getWrapLimit = function() { - return this.$wrapLimit; - }), - (this.setWrapLimit = function(e) { - this.setWrapLimitRange(e, e); - }), - (this.getWrapLimitRange = function() { - return { - min: this.$wrapLimitRange.min, - max: this.$wrapLimitRange.max - }; - }), - (this.$updateInternalDataOnChange = function(e) { - var t = this.$useWrapMode, - n = e.action, - r = e.start, - i = e.end, - s = r.row, - o = i.row, - u = o - s, - a = null; - this.$updating = !0; - if (u != 0) - if (n === "remove") { - this[t ? "$wrapData" : "$rowLengthCache"].splice(s, u); - var f = this.$foldData; - (a = this.getFoldsInRange(e)), this.removeFolds(a); - var l = this.getFoldLine(i.row), - c = 0; - if (l) { - l.addRemoveChars(i.row, i.column, r.column - i.column), - l.shiftRow(-u); - var h = this.getFoldLine(s); - h && h !== l && (h.merge(l), (l = h)), (c = f.indexOf(l) + 1); + return { row: this.end.row, column: this.end.column + e }; + })); + }).call(i.prototype), + (t.FoldLine = i)); + } + ), + define( + "ace/range_list", + ["require", "exports", "module", "ace/range"], + function (e, t, n) { + "use strict"; + var r = e("./range").Range, + i = r.comparePoints, + s = function () { + this.ranges = []; + }; + ((function () { + ((this.comparePoints = i), + (this.pointIndex = function (e, t, n) { + var r = this.ranges; + for (var s = n || 0; s < r.length; s++) { + var o = r[s], + u = i(e, o.end); + if (u > 0) continue; + var a = i(e, o.start); + return u === 0 + ? t && a !== 0 + ? -s - 2 + : s + : a > 0 || (a === 0 && !t) + ? s + : -s - 1; + } + return -s - 1; + }), + (this.add = function (e) { + var t = !e.isEmpty(), + n = this.pointIndex(e.start, t); + n < 0 && (n = -n - 1); + var r = this.pointIndex(e.end, t, n); + return ( + r < 0 ? (r = -r - 1) : r++, + this.ranges.splice(n, r - n, e) + ); + }), + (this.addList = function (e) { + var t = []; + for (var n = e.length; n--;) t.push.apply(t, this.add(e[n])); + return t; + }), + (this.substractPoint = function (e) { + var t = this.pointIndex(e); + if (t >= 0) return this.ranges.splice(t, 1); + }), + (this.merge = function () { + var e = [], + t = this.ranges; + t = t.sort(function (e, t) { + return i(e.start, t.start); + }); + var n = t[0], + r; + for (var s = 1; s < t.length; s++) { + ((r = n), (n = t[s])); + var o = i(r.end, n.start); + if (o < 0) continue; + if (o == 0 && !r.isEmpty() && !n.isEmpty()) continue; + (i(r.end, n.end) < 0 && + ((r.end.row = n.end.row), (r.end.column = n.end.column)), + t.splice(s, 1), + e.push(n), + (n = r), + s--); + } + return ((this.ranges = t), e); + }), + (this.contains = function (e, t) { + return this.pointIndex({ row: e, column: t }) >= 0; + }), + (this.containsPoint = function (e) { + return this.pointIndex(e) >= 0; + }), + (this.rangeAtPoint = function (e) { + var t = this.pointIndex(e); + if (t >= 0) return this.ranges[t]; + }), + (this.clipRows = function (e, t) { + var n = this.ranges; + if (n[0].start.row > t || n[n.length - 1].start.row < e) return []; + var r = this.pointIndex({ row: e, column: 0 }); + r < 0 && (r = -r - 1); + var i = this.pointIndex({ row: t, column: 0 }, r); + i < 0 && (i = -i - 1); + var s = []; + for (var o = r; o < i; o++) s.push(n[o]); + return s; + }), + (this.removeAll = function () { + return this.ranges.splice(0, this.ranges.length); + }), + (this.attach = function (e) { + (this.session && this.detach(), + (this.session = e), + (this.onChange = this.$onChange.bind(this)), + this.session.on("change", this.onChange)); + }), + (this.detach = function () { + if (!this.session) return; + (this.session.removeListener("change", this.onChange), + (this.session = null)); + }), + (this.$onChange = function (e) { + if (e.action == "insert") + var t = e.start, + n = e.end; + else + var n = e.start, + t = e.end; + var r = t.row, + i = n.row, + s = i - r, + o = -t.column + n.column, + u = this.ranges; + for (var a = 0, f = u.length; a < f; a++) { + var l = u[a]; + if (l.end.row < r) continue; + if (l.start.row > r) break; + l.start.row == r && + l.start.column >= t.column && + (l.start.column != t.column || !this.$insertRight) && + ((l.start.column += o), (l.start.row += s)); + if (l.end.row == r && l.end.column >= t.column) { + if (l.end.column == t.column && this.$insertRight) continue; + (l.end.column == t.column && + o > 0 && + a < f - 1 && + l.end.column > l.start.column && + l.end.column == u[a + 1].start.column && + (l.end.column -= o), + (l.end.column += o), + (l.end.row += s)); } - for (c; c < f.length; c++) { - var l = f[c]; - l.start.row >= i.row && l.shiftRow(-u); + } + if (s != 0 && a < f) + for (; a < f; a++) { + var l = u[a]; + ((l.start.row += s), (l.end.row += s)); } - o = s; - } else { - var p = Array(u); - p.unshift(s, 0); - var d = t ? this.$wrapData : this.$rowLengthCache; - d.splice.apply(d, p); - var f = this.$foldData, - l = this.getFoldLine(s), - c = 0; - if (l) { - var v = l.range.compareInside(r.row, r.column); - v == 0 - ? ((l = l.split(r.row, r.column)), - l && - (l.shiftRow(u), - l.addRemoveChars(o, 0, i.column - r.column))) - : v == -1 && - (l.addRemoveChars(s, 0, i.column - r.column), - l.shiftRow(u)), - (c = f.indexOf(l) + 1); + })); + }).call(s.prototype), + (t.RangeList = s)); + } + ), + define( + "ace/edit_session/fold", + [ + "require", + "exports", + "module", + "ace/range", + "ace/range_list", + "ace/lib/oop" + ], + function (e, t, n) { + "use strict"; + function u(e, t) { + ((e.row -= t.row), e.row == 0 && (e.column -= t.column)); + } + function a(e, t) { + (u(e.start, t), u(e.end, t)); + } + function f(e, t) { + (e.row == 0 && (e.column += t.column), (e.row += t.row)); + } + function l(e, t) { + (f(e.start, t), f(e.end, t)); + } + var r = e("../range").Range, + i = e("../range_list").RangeList, + s = e("../lib/oop"), + o = (t.Fold = function (e, t) { + ((this.foldLine = null), + (this.placeholder = t), + (this.range = e), + (this.start = e.start), + (this.end = e.end), + (this.sameRow = e.start.row == e.end.row), + (this.subFolds = this.ranges = [])); + }); + (s.inherits(o, i), + function () { + ((this.toString = function () { + return '"' + this.placeholder + '" ' + this.range.toString(); + }), + (this.setFoldLine = function (e) { + ((this.foldLine = e), + this.subFolds.forEach(function (t) { + t.setFoldLine(e); + })); + }), + (this.clone = function () { + var e = this.range.clone(), + t = new o(e, this.placeholder); + return ( + this.subFolds.forEach(function (e) { + t.subFolds.push(e.clone()); + }), + (t.collapseChildren = this.collapseChildren), + t + ); + }), + (this.addSubFold = function (e) { + if (this.range.isEqual(e)) return; + if (!this.range.containsRange(e)) + throw new Error( + "A fold can't intersect already existing fold" + + e.range + + this.range + ); + a(e, this.start); + var t = e.start.row, + n = e.start.column; + for (var r = 0, i = -1; r < this.subFolds.length; r++) { + i = this.subFolds[r].range.compare(t, n); + if (i != 1) break; } - for (c; c < f.length; c++) { - var l = f[c]; - l.start.row >= s && l.shiftRow(u); + var s = this.subFolds[r]; + if (i == 0) return s.addSubFold(e); + var t = e.range.end.row, + n = e.range.end.column; + for (var o = r, i = -1; o < this.subFolds.length; o++) { + i = this.subFolds[o].range.compare(t, n); + if (i != 1) break; } + var u = this.subFolds[o]; + if (i == 0) + throw new Error( + "A fold can't intersect already existing fold" + + e.range + + this.range + ); + var f = this.subFolds.splice(r, o - r, e); + return (e.setFoldLine(this.foldLine), e); + }), + (this.restoreRange = function (e) { + return l(e, this.start); + })); + }.call(o.prototype)); + } + ), + define( + "ace/edit_session/folding", + [ + "require", + "exports", + "module", + "ace/range", + "ace/edit_session/fold_line", + "ace/edit_session/fold", + "ace/token_iterator" + ], + function (e, t, n) { + "use strict"; + function u() { + ((this.getFoldAt = function (e, t, n) { + var r = this.getFoldLine(e); + if (!r) return null; + var i = r.folds; + for (var s = 0; s < i.length; s++) { + var o = i[s]; + if (o.range.contains(e, t)) { + if (n == 1 && o.range.isEnd(e, t)) continue; + if (n == -1 && o.range.isStart(e, t)) continue; + return o; } - else { - (u = Math.abs(e.start.column - e.end.column)), - n === "remove" && - ((a = this.getFoldsInRange(e)), this.removeFolds(a), (u = -u)); - var l = this.getFoldLine(s); - l && l.addRemoveChars(s, r.column, u); } - return ( - t && - this.$wrapData.length != this.doc.getLength() && - console.error( - "doc.getLength() and $wrapData.length have to be the same!" - ), - (this.$updating = !1), - t ? this.$updateWrapData(s, o) : this.$updateRowLengthCache(s, o), - a - ); }), - (this.$updateRowLengthCache = function(e, t, n) { - (this.$rowLengthCache[e] = null), (this.$rowLengthCache[t] = null); - }), - (this.$updateWrapData = function(e, t) { - var r = this.doc.getAllLines(), - i = this.getTabSize(), - s = this.$wrapData, - o = this.$wrapLimit, - a, - f, - l = e; - t = Math.min(t, r.length - 1); - while (l <= t) - (f = this.getFoldLine(l, f)), - f - ? ((a = []), - f.walk( - function(e, t, i, s) { - var o; - if (e != null) { - (o = this.$getDisplayTokens(e, a.length)), (o[0] = n); - for (var f = 1; f < o.length; f++) o[f] = u; - } else - o = this.$getDisplayTokens( - r[t].substring(s, i), - a.length - ); - a = a.concat(o); - }.bind(this), - f.end.row, - r[f.end.row].length + 1 - ), - (s[f.start.row] = this.$computeWrapSplits(a, o, i)), - (l = f.end.row + 1)) - : ((a = this.$getDisplayTokens(r[l])), - (s[l] = this.$computeWrapSplits(a, o, i)), - l++); - }); - var e = 1, - t = 2, - n = 3, - u = 4, - l = 9, - p = 10, - d = 11, - v = 12; - (this.$computeWrapSplits = function(e, r, i) { - function g() { - var t = 0; - if (m === 0) return t; - if (h) - for (var n = 0; n < e.length; n++) { - var r = e[n]; - if (r == p) t += 1; - else { - if (r != d) { - if (r == v) continue; - break; - } - t += i; + (this.getFoldsInRange = function (e) { + var t = e.start, + n = e.end, + r = this.$foldData, + i = []; + ((t.column += 1), (n.column -= 1)); + for (var s = 0; s < r.length; s++) { + var o = r[s].range.compareRange(e); + if (o == 2) continue; + if (o == -2) break; + var u = r[s].folds; + for (var a = 0; a < u.length; a++) { + var f = u[a]; + o = f.range.compareRange(e); + if (o == -2) break; + if (o == 2) continue; + if (o == 42) break; + i.push(f); } } - return c && h !== !1 && (t += i), Math.min(t, m); - } - function y(t) { - var n = e.slice(a, t), - r = n.length; - n - .join("") - .replace(/12/g, function() { - r -= 1; - }) - .replace(/2/g, function() { - r -= 1; - }), - s.length || ((b = g()), (s.indent = b)), - (f += r), - s.push(f), - (a = t); - } - if (e.length == 0) return []; - var s = [], - o = e.length, - a = 0, - f = 0, - c = this.$wrapAsCode, - h = this.$indentedSoftWrap, - m = r <= Math.max(2 * i, 8) || h === !1 ? 0 : Math.floor(r / 2), - b = 0; - while (o - a > r - b) { - var w = a + r - b; - if (e[w - 1] >= p && e[w] >= p) { - y(w); - continue; - } - if (e[w] == n || e[w] == u) { - for (w; w != a - 1; w--) if (e[w] == n) break; - if (w > a) { - y(w); - continue; + return ((t.column -= 1), (n.column += 1), i); + }), + (this.getFoldsInRangeList = function (e) { + if (Array.isArray(e)) { + var t = []; + e.forEach(function (e) { + t = t.concat(this.getFoldsInRange(e)); + }, this); + } else var t = this.getFoldsInRange(e); + return t; + }), + (this.getAllFolds = function () { + var e = [], + t = this.$foldData; + for (var n = 0; n < t.length; n++) + for (var r = 0; r < t[n].folds.length; r++) e.push(t[n].folds[r]); + return e; + }), + (this.getFoldStringAt = function (e, t, n, r) { + r = r || this.getFoldLine(e); + if (!r) return null; + var i = { end: { column: 0 } }, + s, + o; + for (var u = 0; u < r.folds.length; u++) { + o = r.folds[u]; + var a = o.range.compareEnd(e, t); + if (a == -1) { + s = this.getLine(o.start.row).substring( + i.end.column, + o.start.column + ); + break; + } + if (a === 0) return null; + i = o; } - w = a + r; - for (w; w < e.length; w++) if (e[w] != u) break; - if (w == e.length) break; - y(w); - continue; - } - var E = Math.max(w - (r - (r >> 2)), a - 1); - while (w > E && e[w] < n) w--; - if (c) { - while (w > E && e[w] < n) w--; - while (w > E && e[w] == l) w--; - } else while (w > E && e[w] < p) w--; - if (w > E) { - y(++w); - continue; - } - (w = a + r), e[w] == t && w--, y(w - b); - } - return s; - }), - (this.$getDisplayTokens = function(n, r) { - var i = [], - s; - r = r || 0; - for (var o = 0; o < n.length; o++) { - var u = n.charCodeAt(o); - if (u == 9) { - (s = this.getScreenTabSize(i.length + r)), i.push(d); - for (var a = 1; a < s; a++) i.push(v); - } else - u == 32 - ? i.push(p) - : (u > 39 && u < 48) || (u > 57 && u < 64) - ? i.push(l) - : u >= 4352 && m(u) - ? i.push(e, t) - : i.push(e); - } - return i; - }), - (this.$getStringScreenWidth = function(e, t, n) { - if (t == 0) return [0, 0]; - t == null && (t = Infinity), (n = n || 0); - var r, i; - for (i = 0; i < e.length; i++) { - (r = e.charCodeAt(i)), - r == 9 - ? (n += this.getScreenTabSize(n)) - : r >= 4352 && m(r) - ? (n += 2) - : (n += 1); - if (n > t) break; - } - return [n, i]; - }), - (this.lineWidgets = null), - (this.getRowLength = function(e) { - if (this.lineWidgets) - var t = (this.lineWidgets[e] && this.lineWidgets[e].rowCount) || 0; - else t = 0; - return !this.$useWrapMode || !this.$wrapData[e] - ? 1 + t - : this.$wrapData[e].length + 1 + t; - }), - (this.getRowLineCount = function(e) { - return !this.$useWrapMode || !this.$wrapData[e] - ? 1 - : this.$wrapData[e].length + 1; - }), - (this.getRowWrapIndent = function(e) { - if (this.$useWrapMode) { - var t = this.screenToDocumentPosition(e, Number.MAX_VALUE), - n = this.$wrapData[t.row]; - return n.length && n[0] < t.column ? n.indent : 0; - } - return 0; - }), - (this.getScreenLastRowColumn = function(e) { - var t = this.screenToDocumentPosition(e, Number.MAX_VALUE); - return this.documentToScreenColumn(t.row, t.column); - }), - (this.getDocumentLastRowColumn = function(e, t) { - var n = this.documentToScreenRow(e, t); - return this.getScreenLastRowColumn(n); - }), - (this.getDocumentLastRowColumnPosition = function(e, t) { - var n = this.documentToScreenRow(e, t); - return this.screenToDocumentPosition(n, Number.MAX_VALUE / 10); - }), - (this.getRowSplitData = function(e) { - return this.$useWrapMode ? this.$wrapData[e] : undefined; - }), - (this.getScreenTabSize = function(e) { - return this.$tabSize - (e % this.$tabSize); - }), - (this.screenToDocumentRow = function(e, t) { - return this.screenToDocumentPosition(e, t).row; - }), - (this.screenToDocumentColumn = function(e, t) { - return this.screenToDocumentPosition(e, t).column; - }), - (this.screenToDocumentPosition = function(e, t) { - if (e < 0) return { row: 0, column: 0 }; - var n, - r = 0, - i = 0, - s, - o = 0, - u = 0, - a = this.$screenRowCache, - f = this.$getRowCacheIndex(a, e), - l = a.length; - if (l && f >= 0) - var o = a[f], - r = this.$docRowCache[f], - c = e > a[l - 1]; - else var c = !l; - var h = this.getLength() - 1, - p = this.getNextFoldLine(r), - d = p ? p.start.row : Infinity; - while (o <= e) { - u = this.getRowLength(r); - if (o + u > e || r >= h) break; - (o += u), - r++, - r > d && - ((r = p.end.row + 1), - (p = this.getNextFoldLine(r, p)), - (d = p ? p.start.row : Infinity)), - c && (this.$docRowCache.push(r), this.$screenRowCache.push(o)); - } - if (p && p.start.row <= r) - (n = this.getFoldDisplayLine(p)), (r = p.start.row); - else { - if (o + u <= e || r > h) - return { row: h, column: this.getLine(h).length }; - (n = this.getLine(r)), (p = null); - } - var v = 0; - if (this.$useWrapMode) { - var m = this.$wrapData[r]; - if (m) { - var g = Math.floor(e - o); - (s = m[g]), - g > 0 && - m.length && - ((v = m.indent), - (i = m[g - 1] || m[m.length - 1]), - (n = n.substring(i))); - } - } - return ( - (i += this.$getStringScreenWidth(n, t - v)[1]), - this.$useWrapMode && i >= s && (i = s - 1), - p ? p.idxToPosition(i) : { row: r, column: i } - ); - }), - (this.documentToScreenPosition = function(e, t) { - if (typeof t == "undefined") - var n = this.$clipPositionToDocument(e.row, e.column); - else n = this.$clipPositionToDocument(e, t); - (e = n.row), (t = n.column); - var r = 0, - i = null, - s = null; - (s = this.getFoldAt(e, t, 1)), - s && ((e = s.start.row), (t = s.start.column)); - var o, - u = 0, - a = this.$docRowCache, - f = this.$getRowCacheIndex(a, e), - l = a.length; - if (l && f >= 0) - var u = a[f], - r = this.$screenRowCache[f], - c = e > a[l - 1]; - else var c = !l; - var h = this.getNextFoldLine(u), - p = h ? h.start.row : Infinity; - while (u < e) { - if (u >= p) { - o = h.end.row + 1; - if (o > e) break; - (h = this.getNextFoldLine(o, h)), - (p = h ? h.start.row : Infinity); - } else o = u + 1; - (r += this.getRowLength(u)), - (u = o), - c && (this.$docRowCache.push(u), this.$screenRowCache.push(r)); - } - var d = ""; - h && u >= p - ? ((d = this.getFoldDisplayLine(h, e, t)), (i = h.start.row)) - : ((d = this.getLine(e).substring(0, t)), (i = e)); - var v = 0; - if (this.$useWrapMode) { - var m = this.$wrapData[i]; - if (m) { - var g = 0; - while (d.length >= m[g]) r++, g++; - (d = d.substring(m[g - 1] || 0, d.length)), - (v = g > 0 ? m.indent : 0); - } - } - return { row: r, column: v + this.$getStringScreenWidth(d)[0] }; - }), - (this.documentToScreenColumn = function(e, t) { - return this.documentToScreenPosition(e, t).column; - }), - (this.documentToScreenRow = function(e, t) { - return this.documentToScreenPosition(e, t).row; - }), - (this.getScreenLength = function() { - var e = 0, - t = null; - if (!this.$useWrapMode) { - e = this.getLength(); - var n = this.$foldData; - for (var r = 0; r < n.length; r++) - (t = n[r]), (e -= t.end.row - t.start.row); - } else { - var i = this.$wrapData.length, - s = 0, - r = 0, - t = this.$foldData[r++], - o = t ? t.start.row : Infinity; - while (s < i) { - var u = this.$wrapData[s]; - (e += u ? u.length + 1 : 1), - s++, - s > o && - ((s = t.end.row + 1), - (t = this.$foldData[r++]), - (o = t ? t.start.row : Infinity)); + return ( + s || (s = this.getLine(o.start.row).substring(i.end.column)), + n == -1 + ? s.substring(0, t - i.end.column) + : n == 1 + ? s.substring(t - i.end.column) + : s + ); + }), + (this.getFoldLine = function (e, t) { + var n = this.$foldData, + r = 0; + (t && (r = n.indexOf(t)), r == -1 && (r = 0)); + for (r; r < n.length; r++) { + var i = n[r]; + if (i.start.row <= e && i.end.row >= e) return i; + if (i.end.row > e) return null; } - } - return this.lineWidgets && (e += this.$getWidgetScreenLength()), e; - }), - (this.$setFontMetrics = function(e) { - if (!this.$enableVarChar) return; - this.$getStringScreenWidth = function(t, n, r) { - if (n === 0) return [0, 0]; - n || (n = Infinity), (r = r || 0); - var i, s; - for (s = 0; s < t.length; s++) { - (i = t.charAt(s)), - i === " " - ? (r += this.getScreenTabSize(r)) - : (r += e.getCharacterWidth(i)); - if (r > n) break; - } - return [r, s]; - }; - }), - (this.destroy = function() { - this.bgTokenizer && - (this.bgTokenizer.setDocument(null), (this.bgTokenizer = null)), - this.$stopWorker(); - }); - }.call(p.prototype), - e("./edit_session/folding").Folding.call(p.prototype), - e("./edit_session/bracket_match").BracketMatch.call(p.prototype), - s.defineOptions(p.prototype, "session", { - wrap: { - set: function(e) { - !e || e == "off" - ? (e = !1) - : e == "free" - ? (e = !0) - : e == "printMargin" - ? (e = -1) - : typeof e == "string" && (e = parseInt(e, 10) || !1); - if (this.$wrap == e) return; - this.$wrap = e; - if (!e) this.setUseWrapMode(!1); - else { - var t = typeof e == "number" ? e : null; - this.setWrapLimitRange(t, t), this.setUseWrapMode(!0); + return null; + }), + (this.getNextFoldLine = function (e, t) { + var n = this.$foldData, + r = 0; + (t && (r = n.indexOf(t)), r == -1 && (r = 0)); + for (r; r < n.length; r++) { + var i = n[r]; + if (i.end.row >= e) return i; } - }, - get: function() { - return this.getUseWrapMode() - ? this.$wrap == -1 - ? "printMargin" - : this.getWrapLimitRange().min - ? this.$wrap - : "free" - : "off"; - }, - handlesSet: !0 - }, - wrapMethod: { - set: function(e) { - (e = e == "auto" ? this.$mode.type != "text" : e != "text"), - e != this.$wrapAsCode && - ((this.$wrapAsCode = e), - this.$useWrapMode && - ((this.$modified = !0), - this.$resetRowCache(0), - this.$updateWrapData(0, this.getLength() - 1))); - }, - initialValue: "auto" - }, - indentedSoftWrap: { initialValue: !0 }, - firstLineNumber: { - set: function() { - this._signal("changeBreakpoint"); - }, - initialValue: 1 - }, - useWorker: { - set: function(e) { - (this.$useWorker = e), this.$stopWorker(), e && this.$startWorker(); - }, - initialValue: !0 - }, - useSoftTabs: { initialValue: !0 }, - tabSize: { - set: function(e) { - if (isNaN(e) || this.$tabSize === e) return; - (this.$modified = !0), - (this.$rowLengthCache = []), - (this.$tabSize = e), - this._signal("changeTabSize"); - }, - initialValue: 4, - handlesSet: !0 - }, - overwrite: { - set: function(e) { - this._signal("changeOverwrite"); - }, - initialValue: !1 - }, - newLineMode: { - set: function(e) { - this.doc.setNewLineMode(e); - }, - get: function() { - return this.doc.getNewLineMode(); - }, - handlesSet: !0 - }, - mode: { - set: function(e) { - this.setMode(e); - }, - get: function() { - return this.$modeId; - } - } - }), - (t.EditSession = p)); - }), - define("ace/search", [ - "require", - "exports", - "module", - "ace/lib/lang", - "ace/lib/oop", - "ace/range" - ], function(e, t, n) { - "use strict"; - var r = e("./lib/lang"), - i = e("./lib/oop"), - s = e("./range").Range, - o = function() { - this.$options = {}; - }; - (function() { - (this.set = function(e) { - return i.mixin(this.$options, e), this; - }), - (this.getOptions = function() { - return r.copyObject(this.$options); - }), - (this.setOptions = function(e) { - this.$options = e; - }), - (this.find = function(e) { - var t = this.$options, - n = this.$matchIterator(e, t); - if (!n) return !1; - var r = null; - return ( - n.forEach(function(e, n, i) { - if (!e.start) { - var o = e.offset + (i || 0); - r = new s(n, o, n, o + e.length); - if ( - !e.length && - t.start && - t.start.start && - t.skipCurrent != 0 && - r.isEqual(t.start) - ) - return (r = null), !1; - } else r = e; - return !0; - }), - r - ); - }), - (this.findAll = function(e) { - var t = this.$options; - if (!t.needle) return []; - this.$assembleRegExp(t); - var n = t.range, - i = n ? e.getLines(n.start.row, n.end.row) : e.doc.getAllLines(), - o = [], - u = t.re; - if (t.$isMultiLine) { - var a = u.length, - f = i.length - a, - l; - e: for (var c = u.offset || 0; c <= f; c++) { - for (var h = 0; h < a; h++) - if (i[c + h].search(u[h]) == -1) continue e; - var p = i[c], - d = i[c + a - 1], - v = p.length - p.match(u[0])[0].length, - m = d.match(u[a - 1])[0].length; - if (l && l.end.row === c && l.end.column > v) continue; - o.push((l = new s(c, v, c + a - 1, m))), a > 2 && (c = c + a - 2); - } - } else - for (var g = 0; g < i.length; g++) { - var y = r.getMatchOffsets(i[g], u); - for (var h = 0; h < y.length; h++) { - var b = y[h]; - o.push(new s(g, b.offset, g, b.offset + b.length)); + return null; + }), + (this.getFoldedRowCount = function (e, t) { + var n = this.$foldData, + r = t - e + 1; + for (var i = 0; i < n.length; i++) { + var s = n[i], + o = s.end.row, + u = s.start.row; + if (o >= t) { + u < t && (u >= e ? (r -= t - u) : (r = 0)); + break; } + o >= e && (u >= e ? (r -= o - u) : (r -= o - e + 1)); } - if (n) { - var w = n.start.column, - E = n.start.column, - g = 0, - h = o.length - 1; - while ( - g < h && - o[g].start.column < w && - o[g].start.row == n.start.row - ) - g++; - while (g < h && o[h].end.column > E && o[h].end.row == n.end.row) - h--; - o = o.slice(g, h + 1); - for (g = 0, h = o.length; g < h; g++) - (o[g].start.row += n.start.row), (o[g].end.row += n.start.row); - } - return o; - }), - (this.replace = function(e, t) { - var n = this.$options, - r = this.$assembleRegExp(n); - if (n.$isMultiLine) return t; - if (!r) return; - var i = r.exec(e); - if (!i || i[0].length != e.length) return null; - t = e.replace(r, t); - if (n.preserveCase) { - t = t.split(""); - for (var s = Math.min(e.length, e.length); s--; ) { - var o = e[s]; - o && o.toLowerCase() != o - ? (t[s] = t[s].toUpperCase()) - : (t[s] = t[s].toLowerCase()); - } - t = t.join(""); - } - return t; - }), - (this.$matchIterator = function(e, t) { - var n = this.$assembleRegExp(t); - if (!n) return !1; - var i; - if (t.$isMultiLine) - var o = n.length, - u = function(t, r, u) { - var a = t.search(n[0]); - if (a == -1) return; - for (var f = 1; f < o; f++) { - t = e.getLine(r + f); - if (t.search(n[f]) == -1) return; + return r; + }), + (this.$addFoldLine = function (e) { + return ( + this.$foldData.push(e), + this.$foldData.sort(function (e, t) { + return e.start.row - t.start.row; + }), + e + ); + }), + (this.addFold = function (e, t) { + var n = this.$foldData, + r = !1, + o; + (e instanceof s + ? (o = e) + : ((o = new s(t, e)), (o.collapseChildren = t.collapseChildren)), + this.$clipRangeToDocument(o.range)); + var u = o.start.row, + a = o.start.column, + f = o.end.row, + l = o.end.column; + if (u < f || (u == f && a <= l - 2)) { + var c = this.getFoldAt(u, a, 1), + h = this.getFoldAt(f, l, -1); + if (c && h == c) return c.addSubFold(o); + (c && !c.range.isStart(u, a) && this.removeFold(c), + h && !h.range.isEnd(f, l) && this.removeFold(h)); + var p = this.getFoldsInRange(o.range); + p.length > 0 && + (this.removeFolds(p), + p.forEach(function (e) { + o.addSubFold(e); + })); + for (var d = 0; d < n.length; d++) { + var v = n[d]; + if (f == v.start.row) { + (v.addFold(o), (r = !0)); + break; } - var l = t.match(n[o - 1])[0].length, - c = new s(r, a, r + o - 1, l); - n.offset == 1 - ? (c.start.row--, (c.start.column = Number.MAX_VALUE)) - : u && (c.start.column += u); - if (i(c)) return !0; - }; - else if (t.backwards) - var u = function(e, t, s) { - var o = r.getMatchOffsets(e, n); - for (var u = o.length - 1; u >= 0; u--) - if (i(o[u], t, s)) return !0; - }; - else - var u = function(e, t, s) { - var o = r.getMatchOffsets(e, n); - for (var u = 0; u < o.length; u++) if (i(o[u], t, s)) return !0; - }; - var a = this.$lineIterator(e, t); - return { - forEach: function(e) { - (i = e), a.forEach(u); - } - }; - }), - (this.$assembleRegExp = function(e, t) { - if (e.needle instanceof RegExp) return (e.re = e.needle); - var n = e.needle; - if (!e.needle) return (e.re = !1); - e.regExp || (n = r.escapeRegExp(n)), - e.wholeWord && (n = "\\b" + n + "\\b"); - var i = e.caseSensitive ? "gm" : "gmi"; - e.$isMultiLine = !t && /[\n\r]/.test(n); - if (e.$isMultiLine) - return (e.re = this.$assembleMultilineRegExp(n, i)); - try { - var s = new RegExp(n, i); - } catch (o) { - s = !1; - } - return (e.re = s); - }), - (this.$assembleMultilineRegExp = function(e, t) { - var n = e.replace(/\r\n|\r|\n/g, "$\n^").split("\n"), - r = []; - for (var i = 0; i < n.length; i++) - try { - r.push(new RegExp(n[i], t)); - } catch (s) { - return !1; - } - return n[0] == "" ? (r.shift(), (r.offset = 1)) : (r.offset = 0), r; - }), - (this.$lineIterator = function(e, t) { - var n = t.backwards == 1, - r = t.skipCurrent != 0, - i = t.range, - s = t.start; - s || (s = i ? i[n ? "end" : "start"] : e.selection.getRange()), - s.start && (s = s[r != n ? "end" : "start"]); - var o = i ? i.start.row : 0, - u = i ? i.end.row : e.getLength() - 1, - a = n - ? function(n) { - var r = s.row, - i = e.getLine(r).substring(0, s.column); - if (n(i, r)) return; - for (r--; r >= o; r--) if (n(e.getLine(r), r)) return; - if (t.wrap == 0) return; - for (r = u, o = s.row; r >= o; r--) - if (n(e.getLine(r), r)) return; + if (u == v.end.row) { + (v.addFold(o), (r = !0)); + if (!o.sameRow) { + var m = n[d + 1]; + if (m && m.start.row == f) { + v.merge(m); + break; + } + } + break; } - : function(n) { - var r = s.row, - i = e.getLine(r).substr(s.column); - if (n(i, r, s.column)) return; - for (r += 1; r <= u; r++) if (n(e.getLine(r), r)) return; - if (t.wrap == 0) return; - for (r = o, u = s.row; r <= u; r++) - if (n(e.getLine(r), r)) return; - }; - return { forEach: a }; - }); - }.call(o.prototype), - (t.Search = o)); - }), - define("ace/keyboard/hash_handler", [ - "require", - "exports", - "module", - "ace/lib/keys", - "ace/lib/useragent" - ], function(e, t, n) { - "use strict"; - function o(e, t) { - (this.platform = t || (i.isMac ? "mac" : "win")), - (this.commands = {}), - (this.commandKeyBinding = {}), - this.addCommands(e), - (this.$singleCommand = !0); - } - function u(e, t) { - o.call(this, e, t), (this.$singleCommand = !1); - } - var r = e("../lib/keys"), - i = e("../lib/useragent"), - s = r.KEY_MODS; - (u.prototype = o.prototype), - function() { - function e(e) { - return (typeof e == "object" && e.bindKey && e.bindKey.position) || 0; - } - (this.addCommand = function(e) { - this.commands[e.name] && this.removeCommand(e), - (this.commands[e.name] = e), - e.bindKey && this._buildKeyHash(e); - }), - (this.removeCommand = function(e, t) { - var n = e && (typeof e == "string" ? e : e.name); - (e = this.commands[n]), t || delete this.commands[n]; - var r = this.commandKeyBinding; - for (var i in r) { - var s = r[i]; - if (s == e) delete r[i]; - else if (Array.isArray(s)) { - var o = s.indexOf(e); - o != -1 && (s.splice(o, 1), s.length == 1 && (r[i] = s[0])); + if (f <= v.start.row) break; } + return ( + r || (v = this.$addFoldLine(new i(this.$foldData, o))), + this.$useWrapMode + ? this.$updateWrapData(v.start.row, v.start.row) + : this.$updateRowLengthCache(v.start.row, v.start.row), + (this.$modified = !0), + this._signal("changeFold", { data: o, action: "add" }), + o + ); } + throw new Error("The range has to be at least 2 characters width"); }), - (this.bindKey = function(e, t, n) { - typeof e == "object" && - e && - (n == undefined && (n = e.position), (e = e[this.platform])); - if (!e) return; - if (typeof t == "function") - return this.addCommand({ - exec: t, - bindKey: e, - name: t.name || e - }); - e.split("|").forEach(function(e) { - var r = ""; - if (e.indexOf(" ") != -1) { - var i = e.split(/\s+/); - (e = i.pop()), - i.forEach(function(e) { - var t = this.parseKeys(e), - n = s[t.hashId] + t.key; - (r += (r ? " " : "") + n), - this._addCommandToBinding(r, "chainKeys"); - }, this), - (r += " "); - } - var o = this.parseKeys(e), - u = s[o.hashId] + o.key; - this._addCommandToBinding(r + u, t, n); + (this.addFolds = function (e) { + e.forEach(function (e) { + this.addFold(e); }, this); }), - (this._addCommandToBinding = function(t, n, r) { - var i = this.commandKeyBinding, - s; - if (!n) delete i[t]; - else if (!i[t] || this.$singleCommand) i[t] = n; + (this.removeFold = function (e) { + var t = e.foldLine, + n = t.start.row, + r = t.end.row, + i = this.$foldData, + s = t.folds; + if (s.length == 1) i.splice(i.indexOf(t), 1); + else if (t.range.isEnd(e.end.row, e.end.column)) + (s.pop(), + (t.end.row = s[s.length - 1].end.row), + (t.end.column = s[s.length - 1].end.column)); + else if (t.range.isStart(e.start.row, e.start.column)) + (s.shift(), + (t.start.row = s[0].start.row), + (t.start.column = s[0].start.column)); + else if (e.sameRow) s.splice(s.indexOf(e), 1); else { - Array.isArray(i[t]) - ? (s = i[t].indexOf(n)) != -1 && i[t].splice(s, 1) - : (i[t] = [i[t]]), - typeof r != "number" && - (r || n.isDefault ? (r = -100) : (r = e(n))); - var o = i[t]; - for (s = 0; s < o.length; s++) { - var u = o[s], - a = e(u); - if (a > r) break; - } - o.splice(s, 0, n); + var o = t.split(e.start.row, e.start.column); + ((s = o.folds), + s.shift(), + (o.start.row = s[0].start.row), + (o.start.column = s[0].start.column)); } + (this.$updating || + (this.$useWrapMode + ? this.$updateWrapData(n, r) + : this.$updateRowLengthCache(n, r)), + (this.$modified = !0), + this._signal("changeFold", { data: e, action: "remove" })); }), - (this.addCommands = function(e) { - e && - Object.keys(e).forEach(function(t) { - var n = e[t]; - if (!n) return; - if (typeof n == "string") return this.bindKey(n, t); - typeof n == "function" && (n = { exec: n }); - if (typeof n != "object") return; - n.name || (n.name = t), this.addCommand(n); - }, this); + (this.removeFolds = function (e) { + var t = []; + for (var n = 0; n < e.length; n++) t.push(e[n]); + (t.forEach(function (e) { + this.removeFold(e); + }, this), + (this.$modified = !0)); }), - (this.removeCommands = function(e) { - Object.keys(e).forEach(function(t) { - this.removeCommand(e[t]); - }, this); + (this.expandFold = function (e) { + (this.removeFold(e), + e.subFolds.forEach(function (t) { + (e.restoreRange(t), this.addFold(t)); + }, this), + e.collapseChildren > 0 && + this.foldAll( + e.start.row + 1, + e.end.row, + e.collapseChildren - 1 + ), + (e.subFolds = [])); }), - (this.bindKeys = function(e) { - Object.keys(e).forEach(function(t) { - this.bindKey(t, e[t]); + (this.expandFolds = function (e) { + e.forEach(function (e) { + this.expandFold(e); }, this); }), - (this._buildKeyHash = function(e) { - this.bindKey(e.bindKey, e); - }), - (this.parseKeys = function(e) { - var t = e - .toLowerCase() - .split(/[\-\+]([\-\+])?/) - .filter(function(e) { - return e; - }), - n = t.pop(), - i = r[n]; - if (r.FUNCTION_KEYS[i]) n = r.FUNCTION_KEYS[i].toLowerCase(); + (this.unfold = function (e, t) { + var n, i; + (e == null + ? ((n = new r(0, 0, this.getLength(), 0)), (t = !0)) + : typeof e == "number" + ? (n = new r(e, 0, e, this.getLine(e).length)) + : "row" in e + ? (n = r.fromPoints(e, e)) + : (n = e), + (i = this.getFoldsInRangeList(n))); + if (t) this.removeFolds(i); else { - if (!t.length) return { key: n, hashId: -1 }; - if (t.length == 1 && t[0] == "shift") - return { key: n.toUpperCase(), hashId: -1 }; - } - var s = 0; - for (var o = t.length; o--; ) { - var u = r.KEY_MODS[t[o]]; - if (u == null) - return ( - typeof console != "undefined" && - console.error("invalid modifier " + t[o] + " in " + e), - !1 - ); - s |= u; - } - return { key: n, hashId: s }; - }), - (this.findKeyCommand = function(t, n) { - var r = s[t] + n; - return this.commandKeyBinding[r]; - }), - (this.handleKeyboard = function(e, t, n, r) { - if (r < 0) return; - var i = s[t] + n, - o = this.commandKeyBinding[i]; - e.$keyChain && - ((e.$keyChain += " " + i), - (o = this.commandKeyBinding[e.$keyChain] || o)); - if (o) - if (o == "chainKeys" || o[o.length - 1] == "chainKeys") - return (e.$keyChain = e.$keyChain || i), { command: "null" }; - if (e.$keyChain) - if ((!!t && t != 4) || n.length != 1) { - if (t == -1 || r > 0) e.$keyChain = ""; - } else e.$keyChain = e.$keyChain.slice(0, -i.length - 1); - return { command: o }; - }), - (this.getStatusText = function(e, t) { - return t.$keyChain || ""; - }); - }.call(o.prototype), - (t.HashHandler = o), - (t.MultiHashHandler = u); - }), - define("ace/commands/command_manager", [ - "require", - "exports", - "module", - "ace/lib/oop", - "ace/keyboard/hash_handler", - "ace/lib/event_emitter" - ], function(e, t, n) { - "use strict"; - var r = e("../lib/oop"), - i = e("../keyboard/hash_handler").MultiHashHandler, - s = e("../lib/event_emitter").EventEmitter, - o = function(e, t) { - i.call(this, t, e), - (this.byName = this.commands), - this.setDefaultHandler("exec", function(e) { - return e.command.exec(e.editor, e.args || {}); - }); - }; - r.inherits(o, i), - function() { - r.implement(this, s), - (this.exec = function(e, t, n) { - if (Array.isArray(e)) { - for (var r = e.length; r--; ) - if (this.exec(e[r], t, n)) return !0; - return !1; + var s = i; + while (s.length) + (this.expandFolds(s), (s = this.getFoldsInRangeList(n))); } - typeof e == "string" && (e = this.commands[e]); - if (!e) return !1; - if (t && t.$readOnly && !e.readOnly) return !1; - var i = { editor: t, command: e, args: n }; + if (i.length) return i; + }), + (this.isRowFolded = function (e, t) { + return !!this.getFoldLine(e, t); + }), + (this.getRowFoldEnd = function (e, t) { + var n = this.getFoldLine(e, t); + return n ? n.end.row : e; + }), + (this.getRowFoldStart = function (e, t) { + var n = this.getFoldLine(e, t); + return n ? n.start.row : e; + }), + (this.getFoldDisplayLine = function (e, t, n, r, i) { + (r == null && (r = e.start.row), + i == null && (i = 0), + t == null && (t = e.end.row), + n == null && (n = this.getLine(t).length)); + var s = this.doc, + o = ""; return ( - (i.returnValue = this._emit("exec", i)), - this._signal("afterExec", i), - i.returnValue === !1 ? !1 : !0 + e.walk( + function (e, t, n, u) { + if (t < r) return; + if (t == r) { + if (n < i) return; + u = Math.max(i, u); + } + e != null ? (o += e) : (o += s.getLine(t).substring(u, n)); + }, + t, + n + ), + o ); }), - (this.toggleRecording = function(e) { - if (this.$inReplay) return; + (this.getDisplayLine = function (e, t, n, r) { + var i = this.getFoldLine(e); + if (!i) { + var s; + return ( + (s = this.doc.getLine(e)), + s.substring(r || 0, t || s.length) + ); + } + return this.getFoldDisplayLine(i, e, t, n, r); + }), + (this.$cloneFoldData = function () { + var e = []; return ( - e && e._emit("changeStatus"), - this.recording - ? (this.macro.pop(), - this.removeEventListener("exec", this.$addCommandToMacro), - this.macro.length || (this.macro = this.oldMacro), - (this.recording = !1)) - : (this.$addCommandToMacro || - (this.$addCommandToMacro = function(e) { - this.macro.push([e.command, e.args]); - }.bind(this)), - (this.oldMacro = this.macro), - (this.macro = []), - this.on("exec", this.$addCommandToMacro), - (this.recording = !0)) + (e = this.$foldData.map(function (t) { + var n = t.folds.map(function (e) { + return e.clone(); + }); + return new i(e, n); + })), + e ); }), - (this.replay = function(e) { - if (this.$inReplay || !this.macro) return; - if (this.recording) return this.toggleRecording(e); - try { - (this.$inReplay = !0), - this.macro.forEach(function(t) { - typeof t == "string" - ? this.exec(t, e) - : this.exec(t[0], e, t[1]); - }, this); - } finally { - this.$inReplay = !1; + (this.toggleFold = function (e) { + var t = this.selection, + n = t.getRange(), + r, + i; + if (n.isEmpty()) { + var s = n.start; + r = this.getFoldAt(s.row, s.column); + if (r) { + this.expandFold(r); + return; + } + (i = this.findMatchingBracket(s)) + ? n.comparePoint(i) == 1 + ? (n.end = i) + : ((n.start = i), n.start.column++, n.end.column--) + : (i = this.findMatchingBracket({ + row: s.row, + column: s.column + 1 + })) + ? (n.comparePoint(i) == 1 ? (n.end = i) : (n.start = i), + n.start.column++) + : (n = this.getCommentFoldRange(s.row, s.column) || n); + } else { + var o = this.getFoldsInRange(n); + if (e && o.length) { + this.expandFolds(o); + return; + } + o.length == 1 && (r = o[0]); } + r || (r = this.getFoldAt(n.start.row, n.start.column)); + if (r && r.range.toString() == n.toString()) { + this.expandFold(r); + return; + } + var u = "..."; + if (!n.isMultiLine()) { + u = this.getTextRange(n); + if (u.length < 4) return; + u = u.trim().substring(0, 2) + ".."; + } + this.addFold(u, n); }), - (this.trimMacro = function(e) { - return e.map(function(e) { + (this.getCommentFoldRange = function (e, t, n) { + var i = new o(this, e, t), + s = i.getCurrentToken(); + if (s && /^comment|string/.test(s.type)) { + var u = new r(), + a = new RegExp(s.type.replace(/\..*/, "\\.")); + if (n != 1) { + do s = i.stepBackward(); + while (s && a.test(s.type)); + i.stepForward(); + } + ((u.start.row = i.getCurrentTokenRow()), + (u.start.column = i.getCurrentTokenColumn() + 2), + (i = new o(this, e, t))); + if (n != -1) { + do s = i.stepForward(); + while (s && a.test(s.type)); + s = i.stepBackward(); + } else s = i.getCurrentToken(); return ( - typeof e[0] != "string" && (e[0] = e[0].name), - e[1] || (e = e[0]), - e + (u.end.row = i.getCurrentTokenRow()), + (u.end.column = i.getCurrentTokenColumn() + s.value.length - 2), + u ); - }); - }); - }.call(o.prototype), - (t.CommandManager = o); - }), - define("ace/commands/default_commands", [ - "require", - "exports", - "module", - "ace/lib/lang", - "ace/config", - "ace/range" - ], function(e, t, n) { - "use strict"; - function o(e, t) { - return { win: e, mac: t }; + } + }), + (this.foldAll = function (e, t, n) { + n == undefined && (n = 1e5); + var r = this.foldWidgets; + if (!r) return; + ((t = t || this.getLength()), (e = e || 0)); + for (var i = e; i < t; i++) { + r[i] == null && (r[i] = this.getFoldWidget(i)); + if (r[i] != "start") continue; + var s = this.getFoldWidgetRange(i); + if (s && s.isMultiLine() && s.end.row <= t && s.start.row >= e) { + i = s.end.row; + try { + var o = this.addFold("...", s); + o && (o.collapseChildren = n); + } catch (u) {} + } + } + }), + (this.$foldStyles = { manual: 1, markbegin: 1, markbeginend: 1 }), + (this.$foldStyle = "markbegin"), + (this.setFoldStyle = function (e) { + if (!this.$foldStyles[e]) + throw new Error( + "invalid fold style: " + + e + + "[" + + Object.keys(this.$foldStyles).join(", ") + + "]" + ); + if (this.$foldStyle == e) return; + ((this.$foldStyle = e), e == "manual" && this.unfold()); + var t = this.$foldMode; + (this.$setFolding(null), this.$setFolding(t)); + }), + (this.$setFolding = function (e) { + if (this.$foldMode == e) return; + ((this.$foldMode = e), + this.off("change", this.$updateFoldWidgets), + this.off("tokenizerUpdate", this.$tokenizerUpdateFoldWidgets), + this._signal("changeAnnotation")); + if (!e || this.$foldStyle == "manual") { + this.foldWidgets = null; + return; + } + ((this.foldWidgets = []), + (this.getFoldWidget = e.getFoldWidget.bind( + e, + this, + this.$foldStyle + )), + (this.getFoldWidgetRange = e.getFoldWidgetRange.bind( + e, + this, + this.$foldStyle + )), + (this.$updateFoldWidgets = this.updateFoldWidgets.bind(this)), + (this.$tokenizerUpdateFoldWidgets = + this.tokenizerUpdateFoldWidgets.bind(this)), + this.on("change", this.$updateFoldWidgets), + this.on("tokenizerUpdate", this.$tokenizerUpdateFoldWidgets)); + }), + (this.getParentFoldRangeData = function (e, t) { + var n = this.foldWidgets; + if (!n || (t && n[e])) return {}; + var r = e - 1, + i; + while (r >= 0) { + var s = n[r]; + s == null && (s = n[r] = this.getFoldWidget(r)); + if (s == "start") { + var o = this.getFoldWidgetRange(r); + i || (i = o); + if (o && o.end.row >= e) break; + } + r--; + } + return { range: r !== -1 && o, firstRange: i }; + }), + (this.onFoldWidgetClick = function (e, t) { + t = t.domEvent; + var n = { + children: t.shiftKey, + all: t.ctrlKey || t.metaKey, + siblings: t.altKey + }, + r = this.$toggleFoldWidget(e, n); + if (!r) { + var i = t.target || t.srcElement; + i && + /ace_fold-widget/.test(i.className) && + (i.className += " ace_invalid"); + } + }), + (this.$toggleFoldWidget = function (e, t) { + if (!this.getFoldWidget) return; + var n = this.getFoldWidget(e), + r = this.getLine(e), + i = n === "end" ? -1 : 1, + s = this.getFoldAt(e, i === -1 ? 0 : r.length, i); + if (s) + return ( + t.children || t.all ? this.removeFold(s) : this.expandFold(s), + s + ); + var o = this.getFoldWidgetRange(e, !0); + if (o && !o.isMultiLine()) { + s = this.getFoldAt(o.start.row, o.start.column, 1); + if (s && o.isEqual(s.range)) return (this.removeFold(s), s); + } + if (t.siblings) { + var u = this.getParentFoldRangeData(e); + if (u.range) + var a = u.range.start.row + 1, + f = u.range.end.row; + this.foldAll(a, f, t.all ? 1e4 : 0); + } else + t.children + ? ((f = o ? o.end.row : this.getLength()), + this.foldAll(e + 1, f, t.all ? 1e4 : 0)) + : o && + (t.all && (o.collapseChildren = 1e4), this.addFold("...", o)); + return o; + }), + (this.toggleFoldWidget = function (e) { + var t = this.selection.getCursor().row; + t = this.getRowFoldStart(t); + var n = this.$toggleFoldWidget(t, {}); + if (n) return; + var r = this.getParentFoldRangeData(t, !0); + n = r.range || r.firstRange; + if (n) { + t = n.start.row; + var i = this.getFoldAt(t, this.getLine(t).length, 1); + i ? this.removeFold(i) : this.addFold("...", n); + } + }), + (this.updateFoldWidgets = function (e) { + var t = e.start.row, + n = e.end.row - t; + if (n === 0) this.foldWidgets[t] = null; + else if (e.action == "remove") + this.foldWidgets.splice(t, n + 1, null); + else { + var r = Array(n + 1); + (r.unshift(t, 1), + this.foldWidgets.splice.apply(this.foldWidgets, r)); + } + }), + (this.tokenizerUpdateFoldWidgets = function (e) { + var t = e.data; + t.first != t.last && + this.foldWidgets.length > t.first && + this.foldWidgets.splice(t.first, this.foldWidgets.length); + })); + } + var r = e("../range").Range, + i = e("./fold_line").FoldLine, + s = e("./fold").Fold, + o = e("../token_iterator").TokenIterator; + t.Folding = u; } - var r = e("../lib/lang"), - i = e("../config"), - s = e("../range").Range; - t.commands = [ - { - name: "showSettingsMenu", - bindKey: o("Ctrl-,", "Command-,"), - exec: function(e) { - i.loadModule("ace/ext/settings_menu", function(t) { - t.init(e), e.showSettingsMenu(); - }); - }, - readOnly: !0 - }, - { - name: "goToNextError", - bindKey: o("Alt-E", "Ctrl-E"), - exec: function(e) { - i.loadModule("ace/ext/error_marker", function(t) { - t.showErrorMarker(e, 1); - }); - }, - scrollIntoView: "animate", - readOnly: !0 - }, - { - name: "goToPreviousError", - bindKey: o("Alt-Shift-E", "Ctrl-Shift-E"), - exec: function(e) { - i.loadModule("ace/ext/error_marker", function(t) { - t.showErrorMarker(e, -1); - }); - }, - scrollIntoView: "animate", - readOnly: !0 - }, - { - name: "selectall", - bindKey: o("Ctrl-A", "Command-A"), - exec: function(e) { - e.selectAll(); - }, - readOnly: !0 - }, - { - name: "centerselection", - bindKey: o(null, "Ctrl-L"), - exec: function(e) { - e.centerSelection(); - }, - readOnly: !0 - }, - { - name: "gotoline", - bindKey: o("Ctrl-L", "Command-L"), - exec: function(e) { - var t = parseInt(prompt("Enter line number:"), 10); - isNaN(t) || e.gotoLine(t); - }, - readOnly: !0 - }, - { - name: "fold", - bindKey: o("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"), - exec: function(e) { - e.session.toggleFold(!1); - }, - multiSelectAction: "forEach", - scrollIntoView: "center", - readOnly: !0 - }, - { - name: "unfold", - bindKey: o( - "Alt-Shift-L|Ctrl-Shift-F1", - "Command-Alt-Shift-L|Command-Shift-F1" - ), - exec: function(e) { - e.session.toggleFold(!0); - }, - multiSelectAction: "forEach", - scrollIntoView: "center", - readOnly: !0 - }, - { - name: "toggleFoldWidget", - bindKey: o("F2", "F2"), - exec: function(e) { - e.session.toggleFoldWidget(); - }, - multiSelectAction: "forEach", - scrollIntoView: "center", - readOnly: !0 - }, - { - name: "toggleParentFoldWidget", - bindKey: o("Alt-F2", "Alt-F2"), - exec: function(e) { - e.session.toggleFoldWidget(!0); - }, - multiSelectAction: "forEach", - scrollIntoView: "center", - readOnly: !0 - }, - { - name: "foldall", - bindKey: o(null, "Ctrl-Command-Option-0"), - exec: function(e) { - e.session.foldAll(); - }, - scrollIntoView: "center", - readOnly: !0 - }, - { - name: "foldOther", - bindKey: o("Alt-0", "Command-Option-0"), - exec: function(e) { - e.session.foldAll(), e.session.unfold(e.selection.getAllRanges()); - }, - scrollIntoView: "center", - readOnly: !0 - }, - { - name: "unfoldall", - bindKey: o("Alt-Shift-0", "Command-Option-Shift-0"), - exec: function(e) { - e.session.unfold(); - }, - scrollIntoView: "center", - readOnly: !0 - }, - { - name: "findnext", - bindKey: o("Ctrl-K", "Command-G"), - exec: function(e) { - e.findNext(); - }, - multiSelectAction: "forEach", - scrollIntoView: "center", - readOnly: !0 - }, - { - name: "findprevious", - bindKey: o("Ctrl-Shift-K", "Command-Shift-G"), - exec: function(e) { - e.findPrevious(); - }, - multiSelectAction: "forEach", - scrollIntoView: "center", - readOnly: !0 - }, - { - name: "selectOrFindNext", - bindKey: o("Alt-K", "Ctrl-G"), - exec: function(e) { - e.selection.isEmpty() ? e.selection.selectWord() : e.findNext(); - }, - readOnly: !0 - }, - { - name: "selectOrFindPrevious", - bindKey: o("Alt-Shift-K", "Ctrl-Shift-G"), - exec: function(e) { - e.selection.isEmpty() ? e.selection.selectWord() : e.findPrevious(); + ), + define( + "ace/edit_session/bracket_match", + ["require", "exports", "module", "ace/token_iterator", "ace/range"], + function (e, t, n) { + "use strict"; + function s() { + ((this.findMatchingBracket = function (e, t) { + if (e.column == 0) return null; + var n = t || this.getLine(e.row).charAt(e.column - 1); + if (n == "") return null; + var r = n.match(/([\(\[\{])|([\)\]\}])/); + return r + ? r[1] + ? this.$findClosingBracket(r[1], e) + : this.$findOpeningBracket(r[2], e) + : null; + }), + (this.getBracketRange = function (e) { + var t = this.getLine(e.row), + n = !0, + r, + s = t.charAt(e.column - 1), + o = s && s.match(/([\(\[\{])|([\)\]\}])/); + o || + ((s = t.charAt(e.column)), + (e = { row: e.row, column: e.column + 1 }), + (o = s && s.match(/([\(\[\{])|([\)\]\}])/)), + (n = !1)); + if (!o) return null; + if (o[1]) { + var u = this.$findClosingBracket(o[1], e); + if (!u) return null; + ((r = i.fromPoints(e, u)), + n || (r.end.column++, r.start.column--), + (r.cursor = r.end)); + } else { + var u = this.$findOpeningBracket(o[2], e); + if (!u) return null; + ((r = i.fromPoints(u, e)), + n || (r.start.column++, r.end.column--), + (r.cursor = r.start)); + } + return r; + }), + (this.$brackets = { + ")": "(", + "(": ")", + "]": "[", + "[": "]", + "{": "}", + "}": "{" + }), + (this.$findOpeningBracket = function (e, t, n) { + var i = this.$brackets[e], + s = 1, + o = new r(this, t.row, t.column), + u = o.getCurrentToken(); + u || (u = o.stepForward()); + if (!u) return; + n || + (n = new RegExp( + "(\\.?" + + u.type + .replace(".", "\\.") + .replace("rparen", ".paren") + .replace(/\b(?:end)\b/, "(?:start|begin|end)") + + ")+" + )); + var a = t.column - o.getCurrentTokenColumn() - 2, + f = u.value; + for (;;) { + while (a >= 0) { + var l = f.charAt(a); + if (l == i) { + s -= 1; + if (s == 0) + return { + row: o.getCurrentTokenRow(), + column: a + o.getCurrentTokenColumn() + }; + } else l == e && (s += 1); + a -= 1; + } + do u = o.stepBackward(); + while (u && !n.test(u.type)); + if (u == null) break; + ((f = u.value), (a = f.length - 1)); + } + return null; + }), + (this.$findClosingBracket = function (e, t, n) { + var i = this.$brackets[e], + s = 1, + o = new r(this, t.row, t.column), + u = o.getCurrentToken(); + u || (u = o.stepForward()); + if (!u) return; + n || + (n = new RegExp( + "(\\.?" + + u.type + .replace(".", "\\.") + .replace("lparen", ".paren") + .replace(/\b(?:start|begin)\b/, "(?:start|begin|end)") + + ")+" + )); + var a = t.column - o.getCurrentTokenColumn(); + for (;;) { + var f = u.value, + l = f.length; + while (a < l) { + var c = f.charAt(a); + if (c == i) { + s -= 1; + if (s == 0) + return { + row: o.getCurrentTokenRow(), + column: a + o.getCurrentTokenColumn() + }; + } else c == e && (s += 1); + a += 1; + } + do u = o.stepForward(); + while (u && !n.test(u.type)); + if (u == null) break; + a = 0; + } + return null; + })); + } + var r = e("../token_iterator").TokenIterator, + i = e("../range").Range; + t.BracketMatch = s; + } + ), + define( + "ace/edit_session", + [ + "require", + "exports", + "module", + "ace/lib/oop", + "ace/lib/lang", + "ace/config", + "ace/lib/event_emitter", + "ace/selection", + "ace/mode/text", + "ace/range", + "ace/document", + "ace/background_tokenizer", + "ace/search_highlight", + "ace/edit_session/folding", + "ace/edit_session/bracket_match" + ], + function (e, t, n) { + "use strict"; + var r = e("./lib/oop"), + i = e("./lib/lang"), + s = e("./config"), + o = e("./lib/event_emitter").EventEmitter, + u = e("./selection").Selection, + a = e("./mode/text").Mode, + f = e("./range").Range, + l = e("./document").Document, + c = e("./background_tokenizer").BackgroundTokenizer, + h = e("./search_highlight").SearchHighlight, + p = function (e, t) { + ((this.$breakpoints = []), + (this.$decorations = []), + (this.$frontMarkers = {}), + (this.$backMarkers = {}), + (this.$markerId = 1), + (this.$undoSelect = !0), + (this.$foldData = []), + (this.id = "session" + ++p.$uid), + (this.$foldData.toString = function () { + return this.join("\n"); + }), + this.on("changeFold", this.onChangeFold.bind(this)), + (this.$onChange = this.onChange.bind(this))); + if (typeof e != "object" || !e.getLine) e = new l(e); + (this.setDocument(e), + (this.selection = new u(this)), + s.resetOptions(this), + this.setMode(t), + s._signal("session", this)); + }; + ((function () { + function m(e) { + return e < 4352 + ? !1 + : (e >= 4352 && e <= 4447) || + (e >= 4515 && e <= 4519) || + (e >= 4602 && e <= 4607) || + (e >= 9001 && e <= 9002) || + (e >= 11904 && e <= 11929) || + (e >= 11931 && e <= 12019) || + (e >= 12032 && e <= 12245) || + (e >= 12272 && e <= 12283) || + (e >= 12288 && e <= 12350) || + (e >= 12353 && e <= 12438) || + (e >= 12441 && e <= 12543) || + (e >= 12549 && e <= 12589) || + (e >= 12593 && e <= 12686) || + (e >= 12688 && e <= 12730) || + (e >= 12736 && e <= 12771) || + (e >= 12784 && e <= 12830) || + (e >= 12832 && e <= 12871) || + (e >= 12880 && e <= 13054) || + (e >= 13056 && e <= 19903) || + (e >= 19968 && e <= 42124) || + (e >= 42128 && e <= 42182) || + (e >= 43360 && e <= 43388) || + (e >= 44032 && e <= 55203) || + (e >= 55216 && e <= 55238) || + (e >= 55243 && e <= 55291) || + (e >= 63744 && e <= 64255) || + (e >= 65040 && e <= 65049) || + (e >= 65072 && e <= 65106) || + (e >= 65108 && e <= 65126) || + (e >= 65128 && e <= 65131) || + (e >= 65281 && e <= 65376) || + (e >= 65504 && e <= 65510); + } + (r.implement(this, o), + (this.setDocument = function (e) { + (this.doc && this.doc.removeListener("change", this.$onChange), + (this.doc = e), + e.on("change", this.$onChange), + this.bgTokenizer && + this.bgTokenizer.setDocument(this.getDocument()), + this.resetCaches()); + }), + (this.getDocument = function () { + return this.doc; + }), + (this.$resetRowCache = function (e) { + if (!e) { + ((this.$docRowCache = []), (this.$screenRowCache = [])); + return; + } + var t = this.$docRowCache.length, + n = this.$getRowCacheIndex(this.$docRowCache, e) + 1; + t > n && + (this.$docRowCache.splice(n, t), + this.$screenRowCache.splice(n, t)); + }), + (this.$getRowCacheIndex = function (e, t) { + var n = 0, + r = e.length - 1; + while (n <= r) { + var i = (n + r) >> 1, + s = e[i]; + if (t > s) n = i + 1; + else { + if (!(t < s)) return i; + r = i - 1; + } + } + return n - 1; + }), + (this.resetCaches = function () { + ((this.$modified = !0), + (this.$wrapData = []), + (this.$rowLengthCache = []), + this.$resetRowCache(0), + this.bgTokenizer && this.bgTokenizer.start(0)); + }), + (this.onChangeFold = function (e) { + var t = e.data; + this.$resetRowCache(t.start.row); + }), + (this.onChange = function (e) { + ((this.$modified = !0), this.$resetRowCache(e.start.row)); + var t = this.$updateInternalDataOnChange(e); + (!this.$fromUndo && + this.$undoManager && + !e.ignore && + (this.$deltasDoc.push(e), + t && + t.length != 0 && + this.$deltasFold.push({ action: "removeFolds", folds: t }), + this.$informUndoManager.schedule()), + this.bgTokenizer && this.bgTokenizer.$updateOnChange(e), + this._signal("change", e)); + }), + (this.setValue = function (e) { + (this.doc.setValue(e), + this.selection.moveTo(0, 0), + this.$resetRowCache(0), + (this.$deltas = []), + (this.$deltasDoc = []), + (this.$deltasFold = []), + this.setUndoManager(this.$undoManager), + this.getUndoManager().reset()); + }), + (this.getValue = this.toString = + function () { + return this.doc.getValue(); + }), + (this.getSelection = function () { + return this.selection; + }), + (this.getState = function (e) { + return this.bgTokenizer.getState(e); + }), + (this.getTokens = function (e) { + return this.bgTokenizer.getTokens(e); + }), + (this.getTokenAt = function (e, t) { + var n = this.bgTokenizer.getTokens(e), + r, + i = 0; + if (t == null) ((s = n.length - 1), (i = this.getLine(e).length)); + else + for (var s = 0; s < n.length; s++) { + i += n[s].value.length; + if (i >= t) break; + } + return ( + (r = n[s]), + r ? ((r.index = s), (r.start = i - r.value.length), r) : null + ); + }), + (this.setUndoManager = function (e) { + ((this.$undoManager = e), + (this.$deltas = []), + (this.$deltasDoc = []), + (this.$deltasFold = []), + this.$informUndoManager && this.$informUndoManager.cancel()); + if (e) { + var t = this; + ((this.$syncInformUndoManager = function () { + (t.$informUndoManager.cancel(), + t.$deltasFold.length && + (t.$deltas.push({ group: "fold", deltas: t.$deltasFold }), + (t.$deltasFold = [])), + t.$deltasDoc.length && + (t.$deltas.push({ group: "doc", deltas: t.$deltasDoc }), + (t.$deltasDoc = [])), + t.$deltas.length > 0 && + e.execute({ + action: "aceupdate", + args: [t.$deltas, t], + merge: t.mergeUndoDeltas + }), + (t.mergeUndoDeltas = !1), + (t.$deltas = [])); + }), + (this.$informUndoManager = i.delayedCall( + this.$syncInformUndoManager + ))); + } + }), + (this.markUndoGroup = function () { + this.$syncInformUndoManager && this.$syncInformUndoManager(); + }), + (this.$defaultUndoManager = { + undo: function () {}, + redo: function () {}, + reset: function () {} + }), + (this.getUndoManager = function () { + return this.$undoManager || this.$defaultUndoManager; + }), + (this.getTabString = function () { + return this.getUseSoftTabs() + ? i.stringRepeat(" ", this.getTabSize()) + : " "; + }), + (this.setUseSoftTabs = function (e) { + this.setOption("useSoftTabs", e); + }), + (this.getUseSoftTabs = function () { + return this.$useSoftTabs && !this.$mode.$indentWithTabs; + }), + (this.setTabSize = function (e) { + this.setOption("tabSize", e); + }), + (this.getTabSize = function () { + return this.$tabSize; + }), + (this.isTabStop = function (e) { + return this.$useSoftTabs && e.column % this.$tabSize === 0; + }), + (this.$overwrite = !1), + (this.setOverwrite = function (e) { + this.setOption("overwrite", e); + }), + (this.getOverwrite = function () { + return this.$overwrite; + }), + (this.toggleOverwrite = function () { + this.setOverwrite(!this.$overwrite); + }), + (this.addGutterDecoration = function (e, t) { + (this.$decorations[e] || (this.$decorations[e] = ""), + (this.$decorations[e] += " " + t), + this._signal("changeBreakpoint", {})); + }), + (this.removeGutterDecoration = function (e, t) { + ((this.$decorations[e] = (this.$decorations[e] || "").replace( + " " + t, + "" + )), + this._signal("changeBreakpoint", {})); + }), + (this.getBreakpoints = function () { + return this.$breakpoints; + }), + (this.setBreakpoints = function (e) { + this.$breakpoints = []; + for (var t = 0; t < e.length; t++) + this.$breakpoints[e[t]] = "ace_breakpoint"; + this._signal("changeBreakpoint", {}); + }), + (this.clearBreakpoints = function () { + ((this.$breakpoints = []), this._signal("changeBreakpoint", {})); + }), + (this.setBreakpoint = function (e, t) { + (t === undefined && (t = "ace_breakpoint"), + t ? (this.$breakpoints[e] = t) : delete this.$breakpoints[e], + this._signal("changeBreakpoint", {})); + }), + (this.clearBreakpoint = function (e) { + (delete this.$breakpoints[e], this._signal("changeBreakpoint", {})); + }), + (this.addMarker = function (e, t, n, r) { + var i = this.$markerId++, + s = { + range: e, + type: n || "line", + renderer: typeof n == "function" ? n : null, + clazz: t, + inFront: !!r, + id: i + }; + return ( + r + ? ((this.$frontMarkers[i] = s), + this._signal("changeFrontMarker")) + : ((this.$backMarkers[i] = s), + this._signal("changeBackMarker")), + i + ); + }), + (this.addDynamicMarker = function (e, t) { + if (!e.update) return; + var n = this.$markerId++; + return ( + (e.id = n), + (e.inFront = !!t), + t + ? ((this.$frontMarkers[n] = e), + this._signal("changeFrontMarker")) + : ((this.$backMarkers[n] = e), + this._signal("changeBackMarker")), + e + ); + }), + (this.removeMarker = function (e) { + var t = this.$frontMarkers[e] || this.$backMarkers[e]; + if (!t) return; + var n = t.inFront ? this.$frontMarkers : this.$backMarkers; + t && + (delete n[e], + this._signal( + t.inFront ? "changeFrontMarker" : "changeBackMarker" + )); + }), + (this.getMarkers = function (e) { + return e ? this.$frontMarkers : this.$backMarkers; + }), + (this.highlight = function (e) { + if (!this.$searchHighlight) { + var t = new h(null, "ace_selected-word", "text"); + this.$searchHighlight = this.addDynamicMarker(t); + } + this.$searchHighlight.setRegexp(e); + }), + (this.highlightLines = function (e, t, n, r) { + (typeof t != "number" && ((n = t), (t = e)), n || (n = "ace_step")); + var i = new f(e, 0, t, Infinity); + return ((i.id = this.addMarker(i, n, "fullLine", r)), i); + }), + (this.setAnnotations = function (e) { + ((this.$annotations = e), this._signal("changeAnnotation", {})); + }), + (this.getAnnotations = function () { + return this.$annotations || []; + }), + (this.clearAnnotations = function () { + this.setAnnotations([]); + }), + (this.$detectNewLine = function (e) { + var t = e.match(/^.*?(\r?\n)/m); + t ? (this.$autoNewLine = t[1]) : (this.$autoNewLine = "\n"); + }), + (this.getWordRange = function (e, t) { + var n = this.getLine(e), + r = !1; + (t > 0 && (r = !!n.charAt(t - 1).match(this.tokenRe)), + r || (r = !!n.charAt(t).match(this.tokenRe))); + if (r) var i = this.tokenRe; + else if (/^\s+$/.test(n.slice(t - 1, t + 1))) var i = /\s/; + else var i = this.nonTokenRe; + var s = t; + if (s > 0) { + do s--; + while (s >= 0 && n.charAt(s).match(i)); + s++; + } + var o = t; + while (o < n.length && n.charAt(o).match(i)) o++; + return new f(e, s, e, o); + }), + (this.getAWordRange = function (e, t) { + var n = this.getWordRange(e, t), + r = this.getLine(n.end.row); + while (r.charAt(n.end.column).match(/[ \t]/)) n.end.column += 1; + return n; + }), + (this.setNewLineMode = function (e) { + this.doc.setNewLineMode(e); + }), + (this.getNewLineMode = function () { + return this.doc.getNewLineMode(); + }), + (this.setUseWorker = function (e) { + this.setOption("useWorker", e); + }), + (this.getUseWorker = function () { + return this.$useWorker; + }), + (this.onReloadTokenizer = function (e) { + var t = e.data; + (this.bgTokenizer.start(t.first), + this._signal("tokenizerUpdate", e)); + }), + (this.$modes = {}), + (this.$mode = null), + (this.$modeId = null), + (this.setMode = function (e, t) { + if (e && typeof e == "object") { + if (e.getTokenizer) return this.$onChangeMode(e); + var n = e, + r = n.path; + } else r = e || "ace/mode/text"; + this.$modes["ace/mode/text"] || + (this.$modes["ace/mode/text"] = new a()); + if (this.$modes[r] && !n) { + (this.$onChangeMode(this.$modes[r]), t && t()); + return; + } + ((this.$modeId = r), + s.loadModule( + ["mode", r], + function (e) { + if (this.$modeId !== r) return t && t(); + (this.$modes[r] && !n + ? this.$onChangeMode(this.$modes[r]) + : e && + e.Mode && + ((e = new e.Mode(n)), + n || ((this.$modes[r] = e), (e.$id = r)), + this.$onChangeMode(e)), + t && t()); + }.bind(this) + ), + this.$mode || + this.$onChangeMode(this.$modes["ace/mode/text"], !0)); + }), + (this.$onChangeMode = function (e, t) { + t || (this.$modeId = e.$id); + if (this.$mode === e) return; + ((this.$mode = e), + this.$stopWorker(), + this.$useWorker && this.$startWorker()); + var n = e.getTokenizer(); + if (n.addEventListener !== undefined) { + var r = this.onReloadTokenizer.bind(this); + n.addEventListener("update", r); + } + if (!this.bgTokenizer) { + this.bgTokenizer = new c(n); + var i = this; + this.bgTokenizer.addEventListener("update", function (e) { + i._signal("tokenizerUpdate", e); + }); + } else this.bgTokenizer.setTokenizer(n); + (this.bgTokenizer.setDocument(this.getDocument()), + (this.tokenRe = e.tokenRe), + (this.nonTokenRe = e.nonTokenRe), + t || + (e.attachToSession && e.attachToSession(this), + this.$options.wrapMethod.set.call(this, this.$wrapMethod), + this.$setFolding(e.foldingRules), + this.bgTokenizer.start(0), + this._emit("changeMode"))); + }), + (this.$stopWorker = function () { + this.$worker && (this.$worker.terminate(), (this.$worker = null)); + }), + (this.$startWorker = function () { + try { + this.$worker = this.$mode.createWorker(this); + } catch (e) { + (s.warn("Could not load worker", e), (this.$worker = null)); + } + }), + (this.getMode = function () { + return this.$mode; + }), + (this.$scrollTop = 0), + (this.setScrollTop = function (e) { + if (this.$scrollTop === e || isNaN(e)) return; + ((this.$scrollTop = e), this._signal("changeScrollTop", e)); + }), + (this.getScrollTop = function () { + return this.$scrollTop; + }), + (this.$scrollLeft = 0), + (this.setScrollLeft = function (e) { + if (this.$scrollLeft === e || isNaN(e)) return; + ((this.$scrollLeft = e), this._signal("changeScrollLeft", e)); + }), + (this.getScrollLeft = function () { + return this.$scrollLeft; + }), + (this.getScreenWidth = function () { + return ( + this.$computeWidth(), + this.lineWidgets + ? Math.max(this.getLineWidgetMaxWidth(), this.screenWidth) + : this.screenWidth + ); + }), + (this.getLineWidgetMaxWidth = function () { + if (this.lineWidgetsWidth != null) return this.lineWidgetsWidth; + var e = 0; + return ( + this.lineWidgets.forEach(function (t) { + t && t.screenWidth > e && (e = t.screenWidth); + }), + (this.lineWidgetWidth = e) + ); + }), + (this.$computeWidth = function (e) { + if (this.$modified || e) { + this.$modified = !1; + if (this.$useWrapMode) + return (this.screenWidth = this.$wrapLimit); + var t = this.doc.getAllLines(), + n = this.$rowLengthCache, + r = 0, + i = 0, + s = this.$foldData[i], + o = s ? s.start.row : Infinity, + u = t.length; + for (var a = 0; a < u; a++) { + if (a > o) { + a = s.end.row + 1; + if (a >= u) break; + ((s = this.$foldData[i++]), (o = s ? s.start.row : Infinity)); + } + (n[a] == null && (n[a] = this.$getStringScreenWidth(t[a])[0]), + n[a] > r && (r = n[a])); + } + this.screenWidth = r; + } + }), + (this.getLine = function (e) { + return this.doc.getLine(e); + }), + (this.getLines = function (e, t) { + return this.doc.getLines(e, t); + }), + (this.getLength = function () { + return this.doc.getLength(); + }), + (this.getTextRange = function (e) { + return this.doc.getTextRange(e || this.selection.getRange()); + }), + (this.insert = function (e, t) { + return this.doc.insert(e, t); + }), + (this.remove = function (e) { + return this.doc.remove(e); + }), + (this.removeFullLines = function (e, t) { + return this.doc.removeFullLines(e, t); + }), + (this.undoChanges = function (e, t) { + if (!e.length) return; + this.$fromUndo = !0; + var n = null; + for (var r = e.length - 1; r != -1; r--) { + var i = e[r]; + i.group == "doc" + ? (this.doc.revertDeltas(i.deltas), + (n = this.$getUndoSelection(i.deltas, !0, n))) + : i.deltas.forEach(function (e) { + this.addFolds(e.folds); + }, this); + } + return ( + (this.$fromUndo = !1), + n && + this.$undoSelect && + !t && + this.selection.setSelectionRange(n), + n + ); + }), + (this.redoChanges = function (e, t) { + if (!e.length) return; + this.$fromUndo = !0; + var n = null; + for (var r = 0; r < e.length; r++) { + var i = e[r]; + i.group == "doc" && + (this.doc.applyDeltas(i.deltas), + (n = this.$getUndoSelection(i.deltas, !1, n))); + } + return ( + (this.$fromUndo = !1), + n && + this.$undoSelect && + !t && + this.selection.setSelectionRange(n), + n + ); + }), + (this.setUndoSelect = function (e) { + this.$undoSelect = e; + }), + (this.$getUndoSelection = function (e, t, n) { + function r(e) { + return t ? e.action !== "insert" : e.action === "insert"; + } + var i = e[0], + s, + o, + u = !1; + r(i) + ? ((s = f.fromPoints(i.start, i.end)), (u = !0)) + : ((s = f.fromPoints(i.start, i.start)), (u = !1)); + for (var a = 1; a < e.length; a++) + ((i = e[a]), + r(i) + ? ((o = i.start), + s.compare(o.row, o.column) == -1 && s.setStart(o), + (o = i.end), + s.compare(o.row, o.column) == 1 && s.setEnd(o), + (u = !0)) + : ((o = i.start), + s.compare(o.row, o.column) == -1 && + (s = f.fromPoints(i.start, i.start)), + (u = !1))); + if (n != null) { + f.comparePoints(n.start, s.start) === 0 && + ((n.start.column += s.end.column - s.start.column), + (n.end.column += s.end.column - s.start.column)); + var l = n.compareRange(s); + l == 1 ? s.setStart(n.start) : l == -1 && s.setEnd(n.end); + } + return s; + }), + (this.replace = function (e, t) { + return this.doc.replace(e, t); + }), + (this.moveText = function (e, t, n) { + var r = this.getTextRange(e), + i = this.getFoldsInRange(e), + s = f.fromPoints(t, t); + if (!n) { + this.remove(e); + var o = e.start.row - e.end.row, + u = o ? -e.end.column : e.start.column - e.end.column; + (u && + (s.start.row == e.end.row && + s.start.column > e.end.column && + (s.start.column += u), + s.end.row == e.end.row && + s.end.column > e.end.column && + (s.end.column += u)), + o && + s.start.row >= e.end.row && + ((s.start.row += o), (s.end.row += o))); + } + s.end = this.insert(s.start, r); + if (i.length) { + var a = e.start, + l = s.start, + o = l.row - a.row, + u = l.column - a.column; + this.addFolds( + i.map(function (e) { + return ( + (e = e.clone()), + e.start.row == a.row && (e.start.column += u), + e.end.row == a.row && (e.end.column += u), + (e.start.row += o), + (e.end.row += o), + e + ); + }) + ); + } + return s; + }), + (this.indentRows = function (e, t, n) { + n = n.replace(/\t/g, this.getTabString()); + for (var r = e; r <= t; r++) + this.doc.insertInLine({ row: r, column: 0 }, n); + }), + (this.outdentRows = function (e) { + var t = e.collapseRows(), + n = new f(0, 0, 0, 0), + r = this.getTabSize(); + for (var i = t.start.row; i <= t.end.row; ++i) { + var s = this.getLine(i); + ((n.start.row = i), (n.end.row = i)); + for (var o = 0; o < r; ++o) if (s.charAt(o) != " ") break; + (o < r && s.charAt(o) == " " + ? ((n.start.column = o), (n.end.column = o + 1)) + : ((n.start.column = 0), (n.end.column = o)), + this.remove(n)); + } + }), + (this.$moveLines = function (e, t, n) { + ((e = this.getRowFoldStart(e)), (t = this.getRowFoldEnd(t))); + if (n < 0) { + var r = this.getRowFoldStart(e + n); + if (r < 0) return 0; + var i = r - e; + } else if (n > 0) { + var r = this.getRowFoldEnd(t + n); + if (r > this.doc.getLength() - 1) return 0; + var i = r - t; + } else { + ((e = this.$clipRowToDocument(e)), + (t = this.$clipRowToDocument(t))); + var i = t - e + 1; + } + var s = new f(e, 0, t, Number.MAX_VALUE), + o = this.getFoldsInRange(s).map(function (e) { + return ( + (e = e.clone()), + (e.start.row += i), + (e.end.row += i), + e + ); + }), + u = + n == 0 + ? this.doc.getLines(e, t) + : this.doc.removeFullLines(e, t); + return ( + this.doc.insertFullLines(e + i, u), + o.length && this.addFolds(o), + i + ); + }), + (this.moveLinesUp = function (e, t) { + return this.$moveLines(e, t, -1); + }), + (this.moveLinesDown = function (e, t) { + return this.$moveLines(e, t, 1); + }), + (this.duplicateLines = function (e, t) { + return this.$moveLines(e, t, 0); + }), + (this.$clipRowToDocument = function (e) { + return Math.max(0, Math.min(e, this.doc.getLength() - 1)); + }), + (this.$clipColumnToRow = function (e, t) { + return t < 0 ? 0 : Math.min(this.doc.getLine(e).length, t); + }), + (this.$clipPositionToDocument = function (e, t) { + t = Math.max(0, t); + if (e < 0) ((e = 0), (t = 0)); + else { + var n = this.doc.getLength(); + e >= n + ? ((e = n - 1), (t = this.doc.getLine(n - 1).length)) + : (t = Math.min(this.doc.getLine(e).length, t)); + } + return { row: e, column: t }; + }), + (this.$clipRangeToDocument = function (e) { + e.start.row < 0 + ? ((e.start.row = 0), (e.start.column = 0)) + : (e.start.column = this.$clipColumnToRow( + e.start.row, + e.start.column + )); + var t = this.doc.getLength() - 1; + return ( + e.end.row > t + ? ((e.end.row = t), (e.end.column = this.doc.getLine(t).length)) + : (e.end.column = this.$clipColumnToRow( + e.end.row, + e.end.column + )), + e + ); + }), + (this.$wrapLimit = 80), + (this.$useWrapMode = !1), + (this.$wrapLimitRange = { min: null, max: null }), + (this.setUseWrapMode = function (e) { + if (e != this.$useWrapMode) { + ((this.$useWrapMode = e), + (this.$modified = !0), + this.$resetRowCache(0)); + if (e) { + var t = this.getLength(); + ((this.$wrapData = Array(t)), this.$updateWrapData(0, t - 1)); + } + this._signal("changeWrapMode"); + } + }), + (this.getUseWrapMode = function () { + return this.$useWrapMode; + }), + (this.setWrapLimitRange = function (e, t) { + if ( + this.$wrapLimitRange.min !== e || + this.$wrapLimitRange.max !== t + ) + ((this.$wrapLimitRange = { min: e, max: t }), + (this.$modified = !0), + this.$useWrapMode && this._signal("changeWrapMode")); + }), + (this.adjustWrapLimit = function (e, t) { + var n = this.$wrapLimitRange; + n.max < 0 && (n = { min: t, max: t }); + var r = this.$constrainWrapLimit(e, n.min, n.max); + return r != this.$wrapLimit && r > 1 + ? ((this.$wrapLimit = r), + (this.$modified = !0), + this.$useWrapMode && + (this.$updateWrapData(0, this.getLength() - 1), + this.$resetRowCache(0), + this._signal("changeWrapLimit")), + !0) + : !1; + }), + (this.$constrainWrapLimit = function (e, t, n) { + return (t && (e = Math.max(t, e)), n && (e = Math.min(n, e)), e); + }), + (this.getWrapLimit = function () { + return this.$wrapLimit; + }), + (this.setWrapLimit = function (e) { + this.setWrapLimitRange(e, e); + }), + (this.getWrapLimitRange = function () { + return { + min: this.$wrapLimitRange.min, + max: this.$wrapLimitRange.max + }; + }), + (this.$updateInternalDataOnChange = function (e) { + var t = this.$useWrapMode, + n = e.action, + r = e.start, + i = e.end, + s = r.row, + o = i.row, + u = o - s, + a = null; + this.$updating = !0; + if (u != 0) + if (n === "remove") { + this[t ? "$wrapData" : "$rowLengthCache"].splice(s, u); + var f = this.$foldData; + ((a = this.getFoldsInRange(e)), this.removeFolds(a)); + var l = this.getFoldLine(i.row), + c = 0; + if (l) { + (l.addRemoveChars(i.row, i.column, r.column - i.column), + l.shiftRow(-u)); + var h = this.getFoldLine(s); + (h && h !== l && (h.merge(l), (l = h)), + (c = f.indexOf(l) + 1)); + } + for (c; c < f.length; c++) { + var l = f[c]; + l.start.row >= i.row && l.shiftRow(-u); + } + o = s; + } else { + var p = Array(u); + p.unshift(s, 0); + var d = t ? this.$wrapData : this.$rowLengthCache; + d.splice.apply(d, p); + var f = this.$foldData, + l = this.getFoldLine(s), + c = 0; + if (l) { + var v = l.range.compareInside(r.row, r.column); + (v == 0 + ? ((l = l.split(r.row, r.column)), + l && + (l.shiftRow(u), + l.addRemoveChars(o, 0, i.column - r.column))) + : v == -1 && + (l.addRemoveChars(s, 0, i.column - r.column), + l.shiftRow(u)), + (c = f.indexOf(l) + 1)); + } + for (c; c < f.length; c++) { + var l = f[c]; + l.start.row >= s && l.shiftRow(u); + } + } + else { + ((u = Math.abs(e.start.column - e.end.column)), + n === "remove" && + ((a = this.getFoldsInRange(e)), + this.removeFolds(a), + (u = -u))); + var l = this.getFoldLine(s); + l && l.addRemoveChars(s, r.column, u); + } + return ( + t && + this.$wrapData.length != this.doc.getLength() && + console.error( + "doc.getLength() and $wrapData.length have to be the same!" + ), + (this.$updating = !1), + t ? this.$updateWrapData(s, o) : this.$updateRowLengthCache(s, o), + a + ); + }), + (this.$updateRowLengthCache = function (e, t, n) { + ((this.$rowLengthCache[e] = null), + (this.$rowLengthCache[t] = null)); + }), + (this.$updateWrapData = function (e, t) { + var r = this.doc.getAllLines(), + i = this.getTabSize(), + s = this.$wrapData, + o = this.$wrapLimit, + a, + f, + l = e; + t = Math.min(t, r.length - 1); + while (l <= t) + ((f = this.getFoldLine(l, f)), + f + ? ((a = []), + f.walk( + function (e, t, i, s) { + var o; + if (e != null) { + ((o = this.$getDisplayTokens(e, a.length)), + (o[0] = n)); + for (var f = 1; f < o.length; f++) o[f] = u; + } else + o = this.$getDisplayTokens( + r[t].substring(s, i), + a.length + ); + a = a.concat(o); + }.bind(this), + f.end.row, + r[f.end.row].length + 1 + ), + (s[f.start.row] = this.$computeWrapSplits(a, o, i)), + (l = f.end.row + 1)) + : ((a = this.$getDisplayTokens(r[l])), + (s[l] = this.$computeWrapSplits(a, o, i)), + l++)); + })); + var e = 1, + t = 2, + n = 3, + u = 4, + l = 9, + p = 10, + d = 11, + v = 12; + ((this.$computeWrapSplits = function (e, r, i) { + function g() { + var t = 0; + if (m === 0) return t; + if (h) + for (var n = 0; n < e.length; n++) { + var r = e[n]; + if (r == p) t += 1; + else { + if (r != d) { + if (r == v) continue; + break; + } + t += i; + } + } + return (c && h !== !1 && (t += i), Math.min(t, m)); + } + function y(t) { + var n = e.slice(a, t), + r = n.length; + (n + .join("") + .replace(/12/g, function () { + r -= 1; + }) + .replace(/2/g, function () { + r -= 1; + }), + s.length || ((b = g()), (s.indent = b)), + (f += r), + s.push(f), + (a = t)); + } + if (e.length == 0) return []; + var s = [], + o = e.length, + a = 0, + f = 0, + c = this.$wrapAsCode, + h = this.$indentedSoftWrap, + m = r <= Math.max(2 * i, 8) || h === !1 ? 0 : Math.floor(r / 2), + b = 0; + while (o - a > r - b) { + var w = a + r - b; + if (e[w - 1] >= p && e[w] >= p) { + y(w); + continue; + } + if (e[w] == n || e[w] == u) { + for (w; w != a - 1; w--) if (e[w] == n) break; + if (w > a) { + y(w); + continue; + } + w = a + r; + for (w; w < e.length; w++) if (e[w] != u) break; + if (w == e.length) break; + y(w); + continue; + } + var E = Math.max(w - (r - (r >> 2)), a - 1); + while (w > E && e[w] < n) w--; + if (c) { + while (w > E && e[w] < n) w--; + while (w > E && e[w] == l) w--; + } else while (w > E && e[w] < p) w--; + if (w > E) { + y(++w); + continue; + } + ((w = a + r), e[w] == t && w--, y(w - b)); + } + return s; + }), + (this.$getDisplayTokens = function (n, r) { + var i = [], + s; + r = r || 0; + for (var o = 0; o < n.length; o++) { + var u = n.charCodeAt(o); + if (u == 9) { + ((s = this.getScreenTabSize(i.length + r)), i.push(d)); + for (var a = 1; a < s; a++) i.push(v); + } else + u == 32 + ? i.push(p) + : (u > 39 && u < 48) || (u > 57 && u < 64) + ? i.push(l) + : u >= 4352 && m(u) + ? i.push(e, t) + : i.push(e); + } + return i; + }), + (this.$getStringScreenWidth = function (e, t, n) { + if (t == 0) return [0, 0]; + (t == null && (t = Infinity), (n = n || 0)); + var r, i; + for (i = 0; i < e.length; i++) { + ((r = e.charCodeAt(i)), + r == 9 + ? (n += this.getScreenTabSize(n)) + : r >= 4352 && m(r) + ? (n += 2) + : (n += 1)); + if (n > t) break; + } + return [n, i]; + }), + (this.lineWidgets = null), + (this.getRowLength = function (e) { + if (this.lineWidgets) + var t = + (this.lineWidgets[e] && this.lineWidgets[e].rowCount) || 0; + else t = 0; + return !this.$useWrapMode || !this.$wrapData[e] + ? 1 + t + : this.$wrapData[e].length + 1 + t; + }), + (this.getRowLineCount = function (e) { + return !this.$useWrapMode || !this.$wrapData[e] + ? 1 + : this.$wrapData[e].length + 1; + }), + (this.getRowWrapIndent = function (e) { + if (this.$useWrapMode) { + var t = this.screenToDocumentPosition(e, Number.MAX_VALUE), + n = this.$wrapData[t.row]; + return n.length && n[0] < t.column ? n.indent : 0; + } + return 0; + }), + (this.getScreenLastRowColumn = function (e) { + var t = this.screenToDocumentPosition(e, Number.MAX_VALUE); + return this.documentToScreenColumn(t.row, t.column); + }), + (this.getDocumentLastRowColumn = function (e, t) { + var n = this.documentToScreenRow(e, t); + return this.getScreenLastRowColumn(n); + }), + (this.getDocumentLastRowColumnPosition = function (e, t) { + var n = this.documentToScreenRow(e, t); + return this.screenToDocumentPosition(n, Number.MAX_VALUE / 10); + }), + (this.getRowSplitData = function (e) { + return this.$useWrapMode ? this.$wrapData[e] : undefined; + }), + (this.getScreenTabSize = function (e) { + return this.$tabSize - (e % this.$tabSize); + }), + (this.screenToDocumentRow = function (e, t) { + return this.screenToDocumentPosition(e, t).row; + }), + (this.screenToDocumentColumn = function (e, t) { + return this.screenToDocumentPosition(e, t).column; + }), + (this.screenToDocumentPosition = function (e, t) { + if (e < 0) return { row: 0, column: 0 }; + var n, + r = 0, + i = 0, + s, + o = 0, + u = 0, + a = this.$screenRowCache, + f = this.$getRowCacheIndex(a, e), + l = a.length; + if (l && f >= 0) + var o = a[f], + r = this.$docRowCache[f], + c = e > a[l - 1]; + else var c = !l; + var h = this.getLength() - 1, + p = this.getNextFoldLine(r), + d = p ? p.start.row : Infinity; + while (o <= e) { + u = this.getRowLength(r); + if (o + u > e || r >= h) break; + ((o += u), + r++, + r > d && + ((r = p.end.row + 1), + (p = this.getNextFoldLine(r, p)), + (d = p ? p.start.row : Infinity)), + c && (this.$docRowCache.push(r), this.$screenRowCache.push(o))); + } + if (p && p.start.row <= r) + ((n = this.getFoldDisplayLine(p)), (r = p.start.row)); + else { + if (o + u <= e || r > h) + return { row: h, column: this.getLine(h).length }; + ((n = this.getLine(r)), (p = null)); + } + var v = 0; + if (this.$useWrapMode) { + var m = this.$wrapData[r]; + if (m) { + var g = Math.floor(e - o); + ((s = m[g]), + g > 0 && + m.length && + ((v = m.indent), + (i = m[g - 1] || m[m.length - 1]), + (n = n.substring(i)))); + } + } + return ( + (i += this.$getStringScreenWidth(n, t - v)[1]), + this.$useWrapMode && i >= s && (i = s - 1), + p ? p.idxToPosition(i) : { row: r, column: i } + ); + }), + (this.documentToScreenPosition = function (e, t) { + if (typeof t == "undefined") + var n = this.$clipPositionToDocument(e.row, e.column); + else n = this.$clipPositionToDocument(e, t); + ((e = n.row), (t = n.column)); + var r = 0, + i = null, + s = null; + ((s = this.getFoldAt(e, t, 1)), + s && ((e = s.start.row), (t = s.start.column))); + var o, + u = 0, + a = this.$docRowCache, + f = this.$getRowCacheIndex(a, e), + l = a.length; + if (l && f >= 0) + var u = a[f], + r = this.$screenRowCache[f], + c = e > a[l - 1]; + else var c = !l; + var h = this.getNextFoldLine(u), + p = h ? h.start.row : Infinity; + while (u < e) { + if (u >= p) { + o = h.end.row + 1; + if (o > e) break; + ((h = this.getNextFoldLine(o, h)), + (p = h ? h.start.row : Infinity)); + } else o = u + 1; + ((r += this.getRowLength(u)), + (u = o), + c && (this.$docRowCache.push(u), this.$screenRowCache.push(r))); + } + var d = ""; + h && u >= p + ? ((d = this.getFoldDisplayLine(h, e, t)), (i = h.start.row)) + : ((d = this.getLine(e).substring(0, t)), (i = e)); + var v = 0; + if (this.$useWrapMode) { + var m = this.$wrapData[i]; + if (m) { + var g = 0; + while (d.length >= m[g]) (r++, g++); + ((d = d.substring(m[g - 1] || 0, d.length)), + (v = g > 0 ? m.indent : 0)); + } + } + return { row: r, column: v + this.$getStringScreenWidth(d)[0] }; + }), + (this.documentToScreenColumn = function (e, t) { + return this.documentToScreenPosition(e, t).column; + }), + (this.documentToScreenRow = function (e, t) { + return this.documentToScreenPosition(e, t).row; + }), + (this.getScreenLength = function () { + var e = 0, + t = null; + if (!this.$useWrapMode) { + e = this.getLength(); + var n = this.$foldData; + for (var r = 0; r < n.length; r++) + ((t = n[r]), (e -= t.end.row - t.start.row)); + } else { + var i = this.$wrapData.length, + s = 0, + r = 0, + t = this.$foldData[r++], + o = t ? t.start.row : Infinity; + while (s < i) { + var u = this.$wrapData[s]; + ((e += u ? u.length + 1 : 1), + s++, + s > o && + ((s = t.end.row + 1), + (t = this.$foldData[r++]), + (o = t ? t.start.row : Infinity))); + } + } + return ( + this.lineWidgets && (e += this.$getWidgetScreenLength()), + e + ); + }), + (this.$setFontMetrics = function (e) { + if (!this.$enableVarChar) return; + this.$getStringScreenWidth = function (t, n, r) { + if (n === 0) return [0, 0]; + (n || (n = Infinity), (r = r || 0)); + var i, s; + for (s = 0; s < t.length; s++) { + ((i = t.charAt(s)), + i === " " + ? (r += this.getScreenTabSize(r)) + : (r += e.getCharacterWidth(i))); + if (r > n) break; + } + return [r, s]; + }; + }), + (this.destroy = function () { + (this.bgTokenizer && + (this.bgTokenizer.setDocument(null), (this.bgTokenizer = null)), + this.$stopWorker()); + })); + }).call(p.prototype), + e("./edit_session/folding").Folding.call(p.prototype), + e("./edit_session/bracket_match").BracketMatch.call(p.prototype), + s.defineOptions(p.prototype, "session", { + wrap: { + set: function (e) { + !e || e == "off" + ? (e = !1) + : e == "free" + ? (e = !0) + : e == "printMargin" + ? (e = -1) + : typeof e == "string" && (e = parseInt(e, 10) || !1); + if (this.$wrap == e) return; + this.$wrap = e; + if (!e) this.setUseWrapMode(!1); + else { + var t = typeof e == "number" ? e : null; + (this.setWrapLimitRange(t, t), this.setUseWrapMode(!0)); + } + }, + get: function () { + return this.getUseWrapMode() + ? this.$wrap == -1 + ? "printMargin" + : this.getWrapLimitRange().min + ? this.$wrap + : "free" + : "off"; + }, + handlesSet: !0 + }, + wrapMethod: { + set: function (e) { + ((e = e == "auto" ? this.$mode.type != "text" : e != "text"), + e != this.$wrapAsCode && + ((this.$wrapAsCode = e), + this.$useWrapMode && + ((this.$modified = !0), + this.$resetRowCache(0), + this.$updateWrapData(0, this.getLength() - 1)))); + }, + initialValue: "auto" + }, + indentedSoftWrap: { initialValue: !0 }, + firstLineNumber: { + set: function () { + this._signal("changeBreakpoint"); + }, + initialValue: 1 + }, + useWorker: { + set: function (e) { + ((this.$useWorker = e), + this.$stopWorker(), + e && this.$startWorker()); + }, + initialValue: !0 + }, + useSoftTabs: { initialValue: !0 }, + tabSize: { + set: function (e) { + if (isNaN(e) || this.$tabSize === e) return; + ((this.$modified = !0), + (this.$rowLengthCache = []), + (this.$tabSize = e), + this._signal("changeTabSize")); + }, + initialValue: 4, + handlesSet: !0 + }, + overwrite: { + set: function (e) { + this._signal("changeOverwrite"); + }, + initialValue: !1 + }, + newLineMode: { + set: function (e) { + this.doc.setNewLineMode(e); + }, + get: function () { + return this.doc.getNewLineMode(); + }, + handlesSet: !0 + }, + mode: { + set: function (e) { + this.setMode(e); + }, + get: function () { + return this.$modeId; + } + } + }), + (t.EditSession = p)); + } + ), + define( + "ace/search", + [ + "require", + "exports", + "module", + "ace/lib/lang", + "ace/lib/oop", + "ace/range" + ], + function (e, t, n) { + "use strict"; + var r = e("./lib/lang"), + i = e("./lib/oop"), + s = e("./range").Range, + o = function () { + this.$options = {}; + }; + ((function () { + ((this.set = function (e) { + return (i.mixin(this.$options, e), this); + }), + (this.getOptions = function () { + return r.copyObject(this.$options); + }), + (this.setOptions = function (e) { + this.$options = e; + }), + (this.find = function (e) { + var t = this.$options, + n = this.$matchIterator(e, t); + if (!n) return !1; + var r = null; + return ( + n.forEach(function (e, n, i) { + if (!e.start) { + var o = e.offset + (i || 0); + r = new s(n, o, n, o + e.length); + if ( + !e.length && + t.start && + t.start.start && + t.skipCurrent != 0 && + r.isEqual(t.start) + ) + return ((r = null), !1); + } else r = e; + return !0; + }), + r + ); + }), + (this.findAll = function (e) { + var t = this.$options; + if (!t.needle) return []; + this.$assembleRegExp(t); + var n = t.range, + i = n ? e.getLines(n.start.row, n.end.row) : e.doc.getAllLines(), + o = [], + u = t.re; + if (t.$isMultiLine) { + var a = u.length, + f = i.length - a, + l; + e: for (var c = u.offset || 0; c <= f; c++) { + for (var h = 0; h < a; h++) + if (i[c + h].search(u[h]) == -1) continue e; + var p = i[c], + d = i[c + a - 1], + v = p.length - p.match(u[0])[0].length, + m = d.match(u[a - 1])[0].length; + if (l && l.end.row === c && l.end.column > v) continue; + (o.push((l = new s(c, v, c + a - 1, m))), + a > 2 && (c = c + a - 2)); + } + } else + for (var g = 0; g < i.length; g++) { + var y = r.getMatchOffsets(i[g], u); + for (var h = 0; h < y.length; h++) { + var b = y[h]; + o.push(new s(g, b.offset, g, b.offset + b.length)); + } + } + if (n) { + var w = n.start.column, + E = n.start.column, + g = 0, + h = o.length - 1; + while ( + g < h && + o[g].start.column < w && + o[g].start.row == n.start.row + ) + g++; + while (g < h && o[h].end.column > E && o[h].end.row == n.end.row) + h--; + o = o.slice(g, h + 1); + for (g = 0, h = o.length; g < h; g++) + ((o[g].start.row += n.start.row), + (o[g].end.row += n.start.row)); + } + return o; + }), + (this.replace = function (e, t) { + var n = this.$options, + r = this.$assembleRegExp(n); + if (n.$isMultiLine) return t; + if (!r) return; + var i = r.exec(e); + if (!i || i[0].length != e.length) return null; + t = e.replace(r, t); + if (n.preserveCase) { + t = t.split(""); + for (var s = Math.min(e.length, e.length); s--;) { + var o = e[s]; + o && o.toLowerCase() != o + ? (t[s] = t[s].toUpperCase()) + : (t[s] = t[s].toLowerCase()); + } + t = t.join(""); + } + return t; + }), + (this.$matchIterator = function (e, t) { + var n = this.$assembleRegExp(t); + if (!n) return !1; + var i; + if (t.$isMultiLine) + var o = n.length, + u = function (t, r, u) { + var a = t.search(n[0]); + if (a == -1) return; + for (var f = 1; f < o; f++) { + t = e.getLine(r + f); + if (t.search(n[f]) == -1) return; + } + var l = t.match(n[o - 1])[0].length, + c = new s(r, a, r + o - 1, l); + n.offset == 1 + ? (c.start.row--, (c.start.column = Number.MAX_VALUE)) + : u && (c.start.column += u); + if (i(c)) return !0; + }; + else if (t.backwards) + var u = function (e, t, s) { + var o = r.getMatchOffsets(e, n); + for (var u = o.length - 1; u >= 0; u--) + if (i(o[u], t, s)) return !0; + }; + else + var u = function (e, t, s) { + var o = r.getMatchOffsets(e, n); + for (var u = 0; u < o.length; u++) if (i(o[u], t, s)) return !0; + }; + var a = this.$lineIterator(e, t); + return { + forEach: function (e) { + ((i = e), a.forEach(u)); + } + }; + }), + (this.$assembleRegExp = function (e, t) { + if (e.needle instanceof RegExp) return (e.re = e.needle); + var n = e.needle; + if (!e.needle) return (e.re = !1); + (e.regExp || (n = r.escapeRegExp(n)), + e.wholeWord && (n = "\\b" + n + "\\b")); + var i = e.caseSensitive ? "gm" : "gmi"; + e.$isMultiLine = !t && /[\n\r]/.test(n); + if (e.$isMultiLine) + return (e.re = this.$assembleMultilineRegExp(n, i)); + try { + var s = new RegExp(n, i); + } catch (o) { + s = !1; + } + return (e.re = s); + }), + (this.$assembleMultilineRegExp = function (e, t) { + var n = e.replace(/\r\n|\r|\n/g, "$\n^").split("\n"), + r = []; + for (var i = 0; i < n.length; i++) + try { + r.push(new RegExp(n[i], t)); + } catch (s) { + return !1; + } + return ( + n[0] == "" ? (r.shift(), (r.offset = 1)) : (r.offset = 0), + r + ); + }), + (this.$lineIterator = function (e, t) { + var n = t.backwards == 1, + r = t.skipCurrent != 0, + i = t.range, + s = t.start; + (s || (s = i ? i[n ? "end" : "start"] : e.selection.getRange()), + s.start && (s = s[r != n ? "end" : "start"])); + var o = i ? i.start.row : 0, + u = i ? i.end.row : e.getLength() - 1, + a = n + ? function (n) { + var r = s.row, + i = e.getLine(r).substring(0, s.column); + if (n(i, r)) return; + for (r--; r >= o; r--) if (n(e.getLine(r), r)) return; + if (t.wrap == 0) return; + for (r = u, o = s.row; r >= o; r--) + if (n(e.getLine(r), r)) return; + } + : function (n) { + var r = s.row, + i = e.getLine(r).substr(s.column); + if (n(i, r, s.column)) return; + for (r += 1; r <= u; r++) if (n(e.getLine(r), r)) return; + if (t.wrap == 0) return; + for (r = o, u = s.row; r <= u; r++) + if (n(e.getLine(r), r)) return; + }; + return { forEach: a }; + })); + }).call(o.prototype), + (t.Search = o)); + } + ), + define( + "ace/keyboard/hash_handler", + ["require", "exports", "module", "ace/lib/keys", "ace/lib/useragent"], + function (e, t, n) { + "use strict"; + function o(e, t) { + ((this.platform = t || (i.isMac ? "mac" : "win")), + (this.commands = {}), + (this.commandKeyBinding = {}), + this.addCommands(e), + (this.$singleCommand = !0)); + } + function u(e, t) { + (o.call(this, e, t), (this.$singleCommand = !1)); + } + var r = e("../lib/keys"), + i = e("../lib/useragent"), + s = r.KEY_MODS; + ((u.prototype = o.prototype), + function () { + function e(e) { + return ( + (typeof e == "object" && e.bindKey && e.bindKey.position) || 0 + ); + } + ((this.addCommand = function (e) { + (this.commands[e.name] && this.removeCommand(e), + (this.commands[e.name] = e), + e.bindKey && this._buildKeyHash(e)); + }), + (this.removeCommand = function (e, t) { + var n = e && (typeof e == "string" ? e : e.name); + ((e = this.commands[n]), t || delete this.commands[n]); + var r = this.commandKeyBinding; + for (var i in r) { + var s = r[i]; + if (s == e) delete r[i]; + else if (Array.isArray(s)) { + var o = s.indexOf(e); + o != -1 && (s.splice(o, 1), s.length == 1 && (r[i] = s[0])); + } + } + }), + (this.bindKey = function (e, t, n) { + typeof e == "object" && + e && + (n == undefined && (n = e.position), (e = e[this.platform])); + if (!e) return; + if (typeof t == "function") + return this.addCommand({ + exec: t, + bindKey: e, + name: t.name || e + }); + e.split("|").forEach(function (e) { + var r = ""; + if (e.indexOf(" ") != -1) { + var i = e.split(/\s+/); + ((e = i.pop()), + i.forEach(function (e) { + var t = this.parseKeys(e), + n = s[t.hashId] + t.key; + ((r += (r ? " " : "") + n), + this._addCommandToBinding(r, "chainKeys")); + }, this), + (r += " ")); + } + var o = this.parseKeys(e), + u = s[o.hashId] + o.key; + this._addCommandToBinding(r + u, t, n); + }, this); + }), + (this._addCommandToBinding = function (t, n, r) { + var i = this.commandKeyBinding, + s; + if (!n) delete i[t]; + else if (!i[t] || this.$singleCommand) i[t] = n; + else { + (Array.isArray(i[t]) + ? (s = i[t].indexOf(n)) != -1 && i[t].splice(s, 1) + : (i[t] = [i[t]]), + typeof r != "number" && + (r || n.isDefault ? (r = -100) : (r = e(n)))); + var o = i[t]; + for (s = 0; s < o.length; s++) { + var u = o[s], + a = e(u); + if (a > r) break; + } + o.splice(s, 0, n); + } + }), + (this.addCommands = function (e) { + e && + Object.keys(e).forEach(function (t) { + var n = e[t]; + if (!n) return; + if (typeof n == "string") return this.bindKey(n, t); + typeof n == "function" && (n = { exec: n }); + if (typeof n != "object") return; + (n.name || (n.name = t), this.addCommand(n)); + }, this); + }), + (this.removeCommands = function (e) { + Object.keys(e).forEach(function (t) { + this.removeCommand(e[t]); + }, this); + }), + (this.bindKeys = function (e) { + Object.keys(e).forEach(function (t) { + this.bindKey(t, e[t]); + }, this); + }), + (this._buildKeyHash = function (e) { + this.bindKey(e.bindKey, e); + }), + (this.parseKeys = function (e) { + var t = e + .toLowerCase() + .split(/[\-\+]([\-\+])?/) + .filter(function (e) { + return e; + }), + n = t.pop(), + i = r[n]; + if (r.FUNCTION_KEYS[i]) n = r.FUNCTION_KEYS[i].toLowerCase(); + else { + if (!t.length) return { key: n, hashId: -1 }; + if (t.length == 1 && t[0] == "shift") + return { key: n.toUpperCase(), hashId: -1 }; + } + var s = 0; + for (var o = t.length; o--;) { + var u = r.KEY_MODS[t[o]]; + if (u == null) + return ( + typeof console != "undefined" && + console.error("invalid modifier " + t[o] + " in " + e), + !1 + ); + s |= u; + } + return { key: n, hashId: s }; + }), + (this.findKeyCommand = function (t, n) { + var r = s[t] + n; + return this.commandKeyBinding[r]; + }), + (this.handleKeyboard = function (e, t, n, r) { + if (r < 0) return; + var i = s[t] + n, + o = this.commandKeyBinding[i]; + e.$keyChain && + ((e.$keyChain += " " + i), + (o = this.commandKeyBinding[e.$keyChain] || o)); + if (o) + if (o == "chainKeys" || o[o.length - 1] == "chainKeys") + return ( + (e.$keyChain = e.$keyChain || i), + { command: "null" } + ); + if (e.$keyChain) + if ((!!t && t != 4) || n.length != 1) { + if (t == -1 || r > 0) e.$keyChain = ""; + } else e.$keyChain = e.$keyChain.slice(0, -i.length - 1); + return { command: o }; + }), + (this.getStatusText = function (e, t) { + return t.$keyChain || ""; + })); + }.call(o.prototype), + (t.HashHandler = o), + (t.MultiHashHandler = u)); + } + ), + define( + "ace/commands/command_manager", + [ + "require", + "exports", + "module", + "ace/lib/oop", + "ace/keyboard/hash_handler", + "ace/lib/event_emitter" + ], + function (e, t, n) { + "use strict"; + var r = e("../lib/oop"), + i = e("../keyboard/hash_handler").MultiHashHandler, + s = e("../lib/event_emitter").EventEmitter, + o = function (e, t) { + (i.call(this, t, e), + (this.byName = this.commands), + this.setDefaultHandler("exec", function (e) { + return e.command.exec(e.editor, e.args || {}); + })); + }; + (r.inherits(o, i), + function () { + (r.implement(this, s), + (this.exec = function (e, t, n) { + if (Array.isArray(e)) { + for (var r = e.length; r--;) + if (this.exec(e[r], t, n)) return !0; + return !1; + } + typeof e == "string" && (e = this.commands[e]); + if (!e) return !1; + if (t && t.$readOnly && !e.readOnly) return !1; + var i = { editor: t, command: e, args: n }; + return ( + (i.returnValue = this._emit("exec", i)), + this._signal("afterExec", i), + i.returnValue === !1 ? !1 : !0 + ); + }), + (this.toggleRecording = function (e) { + if (this.$inReplay) return; + return ( + e && e._emit("changeStatus"), + this.recording + ? (this.macro.pop(), + this.removeEventListener("exec", this.$addCommandToMacro), + this.macro.length || (this.macro = this.oldMacro), + (this.recording = !1)) + : (this.$addCommandToMacro || + (this.$addCommandToMacro = function (e) { + this.macro.push([e.command, e.args]); + }.bind(this)), + (this.oldMacro = this.macro), + (this.macro = []), + this.on("exec", this.$addCommandToMacro), + (this.recording = !0)) + ); + }), + (this.replay = function (e) { + if (this.$inReplay || !this.macro) return; + if (this.recording) return this.toggleRecording(e); + try { + ((this.$inReplay = !0), + this.macro.forEach(function (t) { + typeof t == "string" + ? this.exec(t, e) + : this.exec(t[0], e, t[1]); + }, this)); + } finally { + this.$inReplay = !1; + } + }), + (this.trimMacro = function (e) { + return e.map(function (e) { + return ( + typeof e[0] != "string" && (e[0] = e[0].name), + e[1] || (e = e[0]), + e + ); + }); + })); + }.call(o.prototype), + (t.CommandManager = o)); + } + ), + define( + "ace/commands/default_commands", + ["require", "exports", "module", "ace/lib/lang", "ace/config", "ace/range"], + function (e, t, n) { + "use strict"; + function o(e, t) { + return { win: e, mac: t }; + } + var r = e("../lib/lang"), + i = e("../config"), + s = e("../range").Range; + t.commands = [ + { + name: "showSettingsMenu", + bindKey: o("Ctrl-,", "Command-,"), + exec: function (e) { + i.loadModule("ace/ext/settings_menu", function (t) { + (t.init(e), e.showSettingsMenu()); + }); + }, + readOnly: !0 }, - readOnly: !0 - }, - { - name: "find", - bindKey: o("Ctrl-F", "Command-F"), - exec: function(e) { - i.loadModule("ace/ext/searchbox", function(t) { - t.Search(e); - }); + { + name: "goToNextError", + bindKey: o("Alt-E", "Ctrl-E"), + exec: function (e) { + i.loadModule("ace/ext/error_marker", function (t) { + t.showErrorMarker(e, 1); + }); + }, + scrollIntoView: "animate", + readOnly: !0 }, - readOnly: !0 - }, - { - name: "overwrite", - bindKey: "Insert", - exec: function(e) { - e.toggleOverwrite(); + { + name: "goToPreviousError", + bindKey: o("Alt-Shift-E", "Ctrl-Shift-E"), + exec: function (e) { + i.loadModule("ace/ext/error_marker", function (t) { + t.showErrorMarker(e, -1); + }); + }, + scrollIntoView: "animate", + readOnly: !0 + }, + { + name: "selectall", + bindKey: o("Ctrl-A", "Command-A"), + exec: function (e) { + e.selectAll(); + }, + readOnly: !0 + }, + { + name: "centerselection", + bindKey: o(null, "Ctrl-L"), + exec: function (e) { + e.centerSelection(); + }, + readOnly: !0 + }, + { + name: "gotoline", + bindKey: o("Ctrl-L", "Command-L"), + exec: function (e) { + var t = parseInt(prompt("Enter line number:"), 10); + isNaN(t) || e.gotoLine(t); + }, + readOnly: !0 + }, + { + name: "fold", + bindKey: o("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"), + exec: function (e) { + e.session.toggleFold(!1); + }, + multiSelectAction: "forEach", + scrollIntoView: "center", + readOnly: !0 + }, + { + name: "unfold", + bindKey: o( + "Alt-Shift-L|Ctrl-Shift-F1", + "Command-Alt-Shift-L|Command-Shift-F1" + ), + exec: function (e) { + e.session.toggleFold(!0); + }, + multiSelectAction: "forEach", + scrollIntoView: "center", + readOnly: !0 + }, + { + name: "toggleFoldWidget", + bindKey: o("F2", "F2"), + exec: function (e) { + e.session.toggleFoldWidget(); + }, + multiSelectAction: "forEach", + scrollIntoView: "center", + readOnly: !0 + }, + { + name: "toggleParentFoldWidget", + bindKey: o("Alt-F2", "Alt-F2"), + exec: function (e) { + e.session.toggleFoldWidget(!0); + }, + multiSelectAction: "forEach", + scrollIntoView: "center", + readOnly: !0 + }, + { + name: "foldall", + bindKey: o(null, "Ctrl-Command-Option-0"), + exec: function (e) { + e.session.foldAll(); + }, + scrollIntoView: "center", + readOnly: !0 + }, + { + name: "foldOther", + bindKey: o("Alt-0", "Command-Option-0"), + exec: function (e) { + (e.session.foldAll(), e.session.unfold(e.selection.getAllRanges())); + }, + scrollIntoView: "center", + readOnly: !0 + }, + { + name: "unfoldall", + bindKey: o("Alt-Shift-0", "Command-Option-Shift-0"), + exec: function (e) { + e.session.unfold(); + }, + scrollIntoView: "center", + readOnly: !0 + }, + { + name: "findnext", + bindKey: o("Ctrl-K", "Command-G"), + exec: function (e) { + e.findNext(); + }, + multiSelectAction: "forEach", + scrollIntoView: "center", + readOnly: !0 + }, + { + name: "findprevious", + bindKey: o("Ctrl-Shift-K", "Command-Shift-G"), + exec: function (e) { + e.findPrevious(); + }, + multiSelectAction: "forEach", + scrollIntoView: "center", + readOnly: !0 + }, + { + name: "selectOrFindNext", + bindKey: o("Alt-K", "Ctrl-G"), + exec: function (e) { + e.selection.isEmpty() ? e.selection.selectWord() : e.findNext(); + }, + readOnly: !0 + }, + { + name: "selectOrFindPrevious", + bindKey: o("Alt-Shift-K", "Ctrl-Shift-G"), + exec: function (e) { + e.selection.isEmpty() ? e.selection.selectWord() : e.findPrevious(); + }, + readOnly: !0 + }, + { + name: "find", + bindKey: o("Ctrl-F", "Command-F"), + exec: function (e) { + i.loadModule("ace/ext/searchbox", function (t) { + t.Search(e); + }); + }, + readOnly: !0 + }, + { + name: "overwrite", + bindKey: "Insert", + exec: function (e) { + e.toggleOverwrite(); + }, + readOnly: !0 + }, + { + name: "selecttostart", + bindKey: o("Ctrl-Shift-Home", "Command-Shift-Up"), + exec: function (e) { + e.getSelection().selectFileStart(); + }, + multiSelectAction: "forEach", + readOnly: !0, + scrollIntoView: "animate", + aceCommandGroup: "fileJump" + }, + { + name: "gotostart", + bindKey: o("Ctrl-Home", "Command-Home|Command-Up"), + exec: function (e) { + e.navigateFileStart(); + }, + multiSelectAction: "forEach", + readOnly: !0, + scrollIntoView: "animate", + aceCommandGroup: "fileJump" + }, + { + name: "selectup", + bindKey: o("Shift-Up", "Shift-Up"), + exec: function (e) { + e.getSelection().selectUp(); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: !0 + }, + { + name: "golineup", + bindKey: o("Up", "Up|Ctrl-P"), + exec: function (e, t) { + e.navigateUp(t.times); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: !0 }, - readOnly: !0 - }, - { - name: "selecttostart", - bindKey: o("Ctrl-Shift-Home", "Command-Shift-Up"), - exec: function(e) { - e.getSelection().selectFileStart(); + { + name: "selecttoend", + bindKey: o("Ctrl-Shift-End", "Command-Shift-Down"), + exec: function (e) { + e.getSelection().selectFileEnd(); + }, + multiSelectAction: "forEach", + readOnly: !0, + scrollIntoView: "animate", + aceCommandGroup: "fileJump" }, - multiSelectAction: "forEach", - readOnly: !0, - scrollIntoView: "animate", - aceCommandGroup: "fileJump" - }, - { - name: "gotostart", - bindKey: o("Ctrl-Home", "Command-Home|Command-Up"), - exec: function(e) { - e.navigateFileStart(); + { + name: "gotoend", + bindKey: o("Ctrl-End", "Command-End|Command-Down"), + exec: function (e) { + e.navigateFileEnd(); + }, + multiSelectAction: "forEach", + readOnly: !0, + scrollIntoView: "animate", + aceCommandGroup: "fileJump" }, - multiSelectAction: "forEach", - readOnly: !0, - scrollIntoView: "animate", - aceCommandGroup: "fileJump" - }, - { - name: "selectup", - bindKey: o("Shift-Up", "Shift-Up"), - exec: function(e) { - e.getSelection().selectUp(); + { + name: "selectdown", + bindKey: o("Shift-Down", "Shift-Down"), + exec: function (e) { + e.getSelection().selectDown(); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: !0 }, - multiSelectAction: "forEach", - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "golineup", - bindKey: o("Up", "Up|Ctrl-P"), - exec: function(e, t) { - e.navigateUp(t.times); + { + name: "golinedown", + bindKey: o("Down", "Down|Ctrl-N"), + exec: function (e, t) { + e.navigateDown(t.times); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: !0 }, - multiSelectAction: "forEach", - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "selecttoend", - bindKey: o("Ctrl-Shift-End", "Command-Shift-Down"), - exec: function(e) { - e.getSelection().selectFileEnd(); + { + name: "selectwordleft", + bindKey: o("Ctrl-Shift-Left", "Option-Shift-Left"), + exec: function (e) { + e.getSelection().selectWordLeft(); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: !0 }, - multiSelectAction: "forEach", - readOnly: !0, - scrollIntoView: "animate", - aceCommandGroup: "fileJump" - }, - { - name: "gotoend", - bindKey: o("Ctrl-End", "Command-End|Command-Down"), - exec: function(e) { - e.navigateFileEnd(); + { + name: "gotowordleft", + bindKey: o("Ctrl-Left", "Option-Left"), + exec: function (e) { + e.navigateWordLeft(); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: !0 }, - multiSelectAction: "forEach", - readOnly: !0, - scrollIntoView: "animate", - aceCommandGroup: "fileJump" - }, - { - name: "selectdown", - bindKey: o("Shift-Down", "Shift-Down"), - exec: function(e) { - e.getSelection().selectDown(); + { + name: "selecttolinestart", + bindKey: o("Alt-Shift-Left", "Command-Shift-Left"), + exec: function (e) { + e.getSelection().selectLineStart(); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: !0 }, - multiSelectAction: "forEach", - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "golinedown", - bindKey: o("Down", "Down|Ctrl-N"), - exec: function(e, t) { - e.navigateDown(t.times); + { + name: "gotolinestart", + bindKey: o("Alt-Left|Home", "Command-Left|Home|Ctrl-A"), + exec: function (e) { + e.navigateLineStart(); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: !0 }, - multiSelectAction: "forEach", - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "selectwordleft", - bindKey: o("Ctrl-Shift-Left", "Option-Shift-Left"), - exec: function(e) { - e.getSelection().selectWordLeft(); + { + name: "selectleft", + bindKey: o("Shift-Left", "Shift-Left"), + exec: function (e) { + e.getSelection().selectLeft(); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: !0 }, - multiSelectAction: "forEach", - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "gotowordleft", - bindKey: o("Ctrl-Left", "Option-Left"), - exec: function(e) { - e.navigateWordLeft(); + { + name: "gotoleft", + bindKey: o("Left", "Left|Ctrl-B"), + exec: function (e, t) { + e.navigateLeft(t.times); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: !0 }, - multiSelectAction: "forEach", - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "selecttolinestart", - bindKey: o("Alt-Shift-Left", "Command-Shift-Left"), - exec: function(e) { - e.getSelection().selectLineStart(); + { + name: "selectwordright", + bindKey: o("Ctrl-Shift-Right", "Option-Shift-Right"), + exec: function (e) { + e.getSelection().selectWordRight(); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: !0 }, - multiSelectAction: "forEach", - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "gotolinestart", - bindKey: o("Alt-Left|Home", "Command-Left|Home|Ctrl-A"), - exec: function(e) { - e.navigateLineStart(); + { + name: "gotowordright", + bindKey: o("Ctrl-Right", "Option-Right"), + exec: function (e) { + e.navigateWordRight(); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: !0 }, - multiSelectAction: "forEach", - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "selectleft", - bindKey: o("Shift-Left", "Shift-Left"), - exec: function(e) { - e.getSelection().selectLeft(); + { + name: "selecttolineend", + bindKey: o("Alt-Shift-Right", "Command-Shift-Right"), + exec: function (e) { + e.getSelection().selectLineEnd(); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: !0 }, - multiSelectAction: "forEach", - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "gotoleft", - bindKey: o("Left", "Left|Ctrl-B"), - exec: function(e, t) { - e.navigateLeft(t.times); + { + name: "gotolineend", + bindKey: o("Alt-Right|End", "Command-Right|End|Ctrl-E"), + exec: function (e) { + e.navigateLineEnd(); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: !0 }, - multiSelectAction: "forEach", - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "selectwordright", - bindKey: o("Ctrl-Shift-Right", "Option-Shift-Right"), - exec: function(e) { - e.getSelection().selectWordRight(); + { + name: "selectright", + bindKey: o("Shift-Right", "Shift-Right"), + exec: function (e) { + e.getSelection().selectRight(); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: !0 }, - multiSelectAction: "forEach", - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "gotowordright", - bindKey: o("Ctrl-Right", "Option-Right"), - exec: function(e) { - e.navigateWordRight(); + { + name: "gotoright", + bindKey: o("Right", "Right|Ctrl-F"), + exec: function (e, t) { + e.navigateRight(t.times); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: !0 }, - multiSelectAction: "forEach", - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "selecttolineend", - bindKey: o("Alt-Shift-Right", "Command-Shift-Right"), - exec: function(e) { - e.getSelection().selectLineEnd(); + { + name: "selectpagedown", + bindKey: "Shift-PageDown", + exec: function (e) { + e.selectPageDown(); + }, + readOnly: !0 }, - multiSelectAction: "forEach", - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "gotolineend", - bindKey: o("Alt-Right|End", "Command-Right|End|Ctrl-E"), - exec: function(e) { - e.navigateLineEnd(); + { + name: "pagedown", + bindKey: o(null, "Option-PageDown"), + exec: function (e) { + e.scrollPageDown(); + }, + readOnly: !0 }, - multiSelectAction: "forEach", - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "selectright", - bindKey: o("Shift-Right", "Shift-Right"), - exec: function(e) { - e.getSelection().selectRight(); + { + name: "gotopagedown", + bindKey: o("PageDown", "PageDown|Ctrl-V"), + exec: function (e) { + e.gotoPageDown(); + }, + readOnly: !0 }, - multiSelectAction: "forEach", - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "gotoright", - bindKey: o("Right", "Right|Ctrl-F"), - exec: function(e, t) { - e.navigateRight(t.times); + { + name: "selectpageup", + bindKey: "Shift-PageUp", + exec: function (e) { + e.selectPageUp(); + }, + readOnly: !0 }, - multiSelectAction: "forEach", - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "selectpagedown", - bindKey: "Shift-PageDown", - exec: function(e) { - e.selectPageDown(); + { + name: "pageup", + bindKey: o(null, "Option-PageUp"), + exec: function (e) { + e.scrollPageUp(); + }, + readOnly: !0 }, - readOnly: !0 - }, - { - name: "pagedown", - bindKey: o(null, "Option-PageDown"), - exec: function(e) { - e.scrollPageDown(); + { + name: "gotopageup", + bindKey: "PageUp", + exec: function (e) { + e.gotoPageUp(); + }, + readOnly: !0 }, - readOnly: !0 - }, - { - name: "gotopagedown", - bindKey: o("PageDown", "PageDown|Ctrl-V"), - exec: function(e) { - e.gotoPageDown(); + { + name: "scrollup", + bindKey: o("Ctrl-Up", null), + exec: function (e) { + e.renderer.scrollBy(0, -2 * e.renderer.layerConfig.lineHeight); + }, + readOnly: !0 }, - readOnly: !0 - }, - { - name: "selectpageup", - bindKey: "Shift-PageUp", - exec: function(e) { - e.selectPageUp(); + { + name: "scrolldown", + bindKey: o("Ctrl-Down", null), + exec: function (e) { + e.renderer.scrollBy(0, 2 * e.renderer.layerConfig.lineHeight); + }, + readOnly: !0 }, - readOnly: !0 - }, - { - name: "pageup", - bindKey: o(null, "Option-PageUp"), - exec: function(e) { - e.scrollPageUp(); + { + name: "selectlinestart", + bindKey: "Shift-Home", + exec: function (e) { + e.getSelection().selectLineStart(); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: !0 }, - readOnly: !0 - }, - { - name: "gotopageup", - bindKey: "PageUp", - exec: function(e) { - e.gotoPageUp(); + { + name: "selectlineend", + bindKey: "Shift-End", + exec: function (e) { + e.getSelection().selectLineEnd(); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: !0 }, - readOnly: !0 - }, - { - name: "scrollup", - bindKey: o("Ctrl-Up", null), - exec: function(e) { - e.renderer.scrollBy(0, -2 * e.renderer.layerConfig.lineHeight); + { + name: "togglerecording", + bindKey: o("Ctrl-Alt-E", "Command-Option-E"), + exec: function (e) { + e.commands.toggleRecording(e); + }, + readOnly: !0 }, - readOnly: !0 - }, - { - name: "scrolldown", - bindKey: o("Ctrl-Down", null), - exec: function(e) { - e.renderer.scrollBy(0, 2 * e.renderer.layerConfig.lineHeight); + { + name: "replaymacro", + bindKey: o("Ctrl-Shift-E", "Command-Shift-E"), + exec: function (e) { + e.commands.replay(e); + }, + readOnly: !0 }, - readOnly: !0 - }, - { - name: "selectlinestart", - bindKey: "Shift-Home", - exec: function(e) { - e.getSelection().selectLineStart(); + { + name: "jumptomatching", + bindKey: o("Ctrl-P", "Ctrl-P"), + exec: function (e) { + e.jumpToMatching(); + }, + multiSelectAction: "forEach", + scrollIntoView: "animate", + readOnly: !0 }, - multiSelectAction: "forEach", - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "selectlineend", - bindKey: "Shift-End", - exec: function(e) { - e.getSelection().selectLineEnd(); + { + name: "selecttomatching", + bindKey: o("Ctrl-Shift-P", "Ctrl-Shift-P"), + exec: function (e) { + e.jumpToMatching(!0); + }, + multiSelectAction: "forEach", + scrollIntoView: "animate", + readOnly: !0 }, - multiSelectAction: "forEach", - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "togglerecording", - bindKey: o("Ctrl-Alt-E", "Command-Option-E"), - exec: function(e) { - e.commands.toggleRecording(e); + { + name: "expandToMatching", + bindKey: o("Ctrl-Shift-M", "Ctrl-Shift-M"), + exec: function (e) { + e.jumpToMatching(!0, !0); + }, + multiSelectAction: "forEach", + scrollIntoView: "animate", + readOnly: !0 }, - readOnly: !0 - }, - { - name: "replaymacro", - bindKey: o("Ctrl-Shift-E", "Command-Shift-E"), - exec: function(e) { - e.commands.replay(e); + { + name: "passKeysToBrowser", + bindKey: o(null, null), + exec: function () {}, + passEvent: !0, + readOnly: !0 }, - readOnly: !0 - }, - { - name: "jumptomatching", - bindKey: o("Ctrl-P", "Ctrl-P"), - exec: function(e) { - e.jumpToMatching(); + { name: "copy", exec: function (e) {}, readOnly: !0 }, + { + name: "cut", + exec: function (e) { + var t = e.getSelectionRange(); + (e._emit("cut", t), + e.selection.isEmpty() || + (e.session.remove(t), e.clearSelection())); + }, + scrollIntoView: "cursor", + multiSelectAction: "forEach" }, - multiSelectAction: "forEach", - scrollIntoView: "animate", - readOnly: !0 - }, - { - name: "selecttomatching", - bindKey: o("Ctrl-Shift-P", "Ctrl-Shift-P"), - exec: function(e) { - e.jumpToMatching(!0); + { + name: "paste", + exec: function (e, t) { + e.$handlePaste(t); + }, + scrollIntoView: "cursor" }, - multiSelectAction: "forEach", - scrollIntoView: "animate", - readOnly: !0 - }, - { - name: "expandToMatching", - bindKey: o("Ctrl-Shift-M", "Ctrl-Shift-M"), - exec: function(e) { - e.jumpToMatching(!0, !0); + { + name: "removeline", + bindKey: o("Ctrl-D", "Command-D"), + exec: function (e) { + e.removeLines(); + }, + scrollIntoView: "cursor", + multiSelectAction: "forEachLine" }, - multiSelectAction: "forEach", - scrollIntoView: "animate", - readOnly: !0 - }, - { - name: "passKeysToBrowser", - bindKey: o(null, null), - exec: function() {}, - passEvent: !0, - readOnly: !0 - }, - { name: "copy", exec: function(e) {}, readOnly: !0 }, - { - name: "cut", - exec: function(e) { - var t = e.getSelectionRange(); - e._emit("cut", t), - e.selection.isEmpty() || (e.session.remove(t), e.clearSelection()); + { + name: "duplicateSelection", + bindKey: o("Ctrl-Shift-D", "Command-Shift-D"), + exec: function (e) { + e.duplicateSelection(); + }, + scrollIntoView: "cursor", + multiSelectAction: "forEach" }, - scrollIntoView: "cursor", - multiSelectAction: "forEach" - }, - { - name: "paste", - exec: function(e, t) { - e.$handlePaste(t); + { + name: "sortlines", + bindKey: o("Ctrl-Alt-S", "Command-Alt-S"), + exec: function (e) { + e.sortLines(); + }, + scrollIntoView: "selection", + multiSelectAction: "forEachLine" }, - scrollIntoView: "cursor" - }, - { - name: "removeline", - bindKey: o("Ctrl-D", "Command-D"), - exec: function(e) { - e.removeLines(); + { + name: "togglecomment", + bindKey: o("Ctrl-/", "Command-/"), + exec: function (e) { + e.toggleCommentLines(); + }, + multiSelectAction: "forEachLine", + scrollIntoView: "selectionPart" }, - scrollIntoView: "cursor", - multiSelectAction: "forEachLine" - }, - { - name: "duplicateSelection", - bindKey: o("Ctrl-Shift-D", "Command-Shift-D"), - exec: function(e) { - e.duplicateSelection(); + { + name: "toggleBlockComment", + bindKey: o("Ctrl-Shift-/", "Command-Shift-/"), + exec: function (e) { + e.toggleBlockComment(); + }, + multiSelectAction: "forEach", + scrollIntoView: "selectionPart" }, - scrollIntoView: "cursor", - multiSelectAction: "forEach" - }, - { - name: "sortlines", - bindKey: o("Ctrl-Alt-S", "Command-Alt-S"), - exec: function(e) { - e.sortLines(); + { + name: "modifyNumberUp", + bindKey: o("Ctrl-Shift-Up", "Alt-Shift-Up"), + exec: function (e) { + e.modifyNumber(1); + }, + scrollIntoView: "cursor", + multiSelectAction: "forEach" }, - scrollIntoView: "selection", - multiSelectAction: "forEachLine" - }, - { - name: "togglecomment", - bindKey: o("Ctrl-/", "Command-/"), - exec: function(e) { - e.toggleCommentLines(); + { + name: "modifyNumberDown", + bindKey: o("Ctrl-Shift-Down", "Alt-Shift-Down"), + exec: function (e) { + e.modifyNumber(-1); + }, + scrollIntoView: "cursor", + multiSelectAction: "forEach" }, - multiSelectAction: "forEachLine", - scrollIntoView: "selectionPart" - }, - { - name: "toggleBlockComment", - bindKey: o("Ctrl-Shift-/", "Command-Shift-/"), - exec: function(e) { - e.toggleBlockComment(); + { + name: "replace", + bindKey: o("Ctrl-H", "Command-Option-F"), + exec: function (e) { + i.loadModule("ace/ext/searchbox", function (t) { + t.Search(e, !0); + }); + } }, - multiSelectAction: "forEach", - scrollIntoView: "selectionPart" - }, - { - name: "modifyNumberUp", - bindKey: o("Ctrl-Shift-Up", "Alt-Shift-Up"), - exec: function(e) { - e.modifyNumber(1); + { + name: "undo", + bindKey: o("Ctrl-Z", "Command-Z"), + exec: function (e) { + e.undo(); + } }, - scrollIntoView: "cursor", - multiSelectAction: "forEach" - }, - { - name: "modifyNumberDown", - bindKey: o("Ctrl-Shift-Down", "Alt-Shift-Down"), - exec: function(e) { - e.modifyNumber(-1); + { + name: "redo", + bindKey: o("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"), + exec: function (e) { + e.redo(); + } }, - scrollIntoView: "cursor", - multiSelectAction: "forEach" - }, - { - name: "replace", - bindKey: o("Ctrl-H", "Command-Option-F"), - exec: function(e) { - i.loadModule("ace/ext/searchbox", function(t) { - t.Search(e, !0); - }); - } - }, - { - name: "undo", - bindKey: o("Ctrl-Z", "Command-Z"), - exec: function(e) { - e.undo(); - } - }, - { - name: "redo", - bindKey: o("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"), - exec: function(e) { - e.redo(); - } - }, - { - name: "copylinesup", - bindKey: o("Alt-Shift-Up", "Command-Option-Up"), - exec: function(e) { - e.copyLinesUp(); + { + name: "copylinesup", + bindKey: o("Alt-Shift-Up", "Command-Option-Up"), + exec: function (e) { + e.copyLinesUp(); + }, + scrollIntoView: "cursor" }, - scrollIntoView: "cursor" - }, - { - name: "movelinesup", - bindKey: o("Alt-Up", "Option-Up"), - exec: function(e) { - e.moveLinesUp(); + { + name: "movelinesup", + bindKey: o("Alt-Up", "Option-Up"), + exec: function (e) { + e.moveLinesUp(); + }, + scrollIntoView: "cursor" }, - scrollIntoView: "cursor" - }, - { - name: "copylinesdown", - bindKey: o("Alt-Shift-Down", "Command-Option-Down"), - exec: function(e) { - e.copyLinesDown(); + { + name: "copylinesdown", + bindKey: o("Alt-Shift-Down", "Command-Option-Down"), + exec: function (e) { + e.copyLinesDown(); + }, + scrollIntoView: "cursor" }, - scrollIntoView: "cursor" - }, - { - name: "movelinesdown", - bindKey: o("Alt-Down", "Option-Down"), - exec: function(e) { - e.moveLinesDown(); + { + name: "movelinesdown", + bindKey: o("Alt-Down", "Option-Down"), + exec: function (e) { + e.moveLinesDown(); + }, + scrollIntoView: "cursor" }, - scrollIntoView: "cursor" - }, - { - name: "del", - bindKey: o("Delete", "Delete|Ctrl-D|Shift-Delete"), - exec: function(e) { - e.remove("right"); + { + name: "del", + bindKey: o("Delete", "Delete|Ctrl-D|Shift-Delete"), + exec: function (e) { + e.remove("right"); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" }, - multiSelectAction: "forEach", - scrollIntoView: "cursor" - }, - { - name: "backspace", - bindKey: o( - "Shift-Backspace|Backspace", - "Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H" - ), - exec: function(e) { - e.remove("left"); + { + name: "backspace", + bindKey: o( + "Shift-Backspace|Backspace", + "Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H" + ), + exec: function (e) { + e.remove("left"); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" }, - multiSelectAction: "forEach", - scrollIntoView: "cursor" - }, - { - name: "cut_or_delete", - bindKey: o("Shift-Delete", null), - exec: function(e) { - if (!e.selection.isEmpty()) return !1; - e.remove("left"); + { + name: "cut_or_delete", + bindKey: o("Shift-Delete", null), + exec: function (e) { + if (!e.selection.isEmpty()) return !1; + e.remove("left"); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" }, - multiSelectAction: "forEach", - scrollIntoView: "cursor" - }, - { - name: "removetolinestart", - bindKey: o("Alt-Backspace", "Command-Backspace"), - exec: function(e) { - e.removeToLineStart(); + { + name: "removetolinestart", + bindKey: o("Alt-Backspace", "Command-Backspace"), + exec: function (e) { + e.removeToLineStart(); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" }, - multiSelectAction: "forEach", - scrollIntoView: "cursor" - }, - { - name: "removetolineend", - bindKey: o("Alt-Delete", "Ctrl-K"), - exec: function(e) { - e.removeToLineEnd(); + { + name: "removetolineend", + bindKey: o("Alt-Delete", "Ctrl-K"), + exec: function (e) { + e.removeToLineEnd(); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" }, - multiSelectAction: "forEach", - scrollIntoView: "cursor" - }, - { - name: "removewordleft", - bindKey: o("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"), - exec: function(e) { - e.removeWordLeft(); + { + name: "removewordleft", + bindKey: o("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"), + exec: function (e) { + e.removeWordLeft(); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" }, - multiSelectAction: "forEach", - scrollIntoView: "cursor" - }, - { - name: "removewordright", - bindKey: o("Ctrl-Delete", "Alt-Delete"), - exec: function(e) { - e.removeWordRight(); + { + name: "removewordright", + bindKey: o("Ctrl-Delete", "Alt-Delete"), + exec: function (e) { + e.removeWordRight(); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" }, - multiSelectAction: "forEach", - scrollIntoView: "cursor" - }, - { - name: "outdent", - bindKey: o("Shift-Tab", "Shift-Tab"), - exec: function(e) { - e.blockOutdent(); + { + name: "outdent", + bindKey: o("Shift-Tab", "Shift-Tab"), + exec: function (e) { + e.blockOutdent(); + }, + multiSelectAction: "forEach", + scrollIntoView: "selectionPart" }, - multiSelectAction: "forEach", - scrollIntoView: "selectionPart" - }, - { - name: "indent", - bindKey: o("Tab", "Tab"), - exec: function(e) { - e.indent(); + { + name: "indent", + bindKey: o("Tab", "Tab"), + exec: function (e) { + e.indent(); + }, + multiSelectAction: "forEach", + scrollIntoView: "selectionPart" }, - multiSelectAction: "forEach", - scrollIntoView: "selectionPart" - }, - { - name: "blockoutdent", - bindKey: o("Ctrl-[", "Ctrl-["), - exec: function(e) { - e.blockOutdent(); + { + name: "blockoutdent", + bindKey: o("Ctrl-[", "Ctrl-["), + exec: function (e) { + e.blockOutdent(); + }, + multiSelectAction: "forEachLine", + scrollIntoView: "selectionPart" }, - multiSelectAction: "forEachLine", - scrollIntoView: "selectionPart" - }, - { - name: "blockindent", - bindKey: o("Ctrl-]", "Ctrl-]"), - exec: function(e) { - e.blockIndent(); + { + name: "blockindent", + bindKey: o("Ctrl-]", "Ctrl-]"), + exec: function (e) { + e.blockIndent(); + }, + multiSelectAction: "forEachLine", + scrollIntoView: "selectionPart" }, - multiSelectAction: "forEachLine", - scrollIntoView: "selectionPart" - }, - { - name: "insertstring", - exec: function(e, t) { - e.insert(t); + { + name: "insertstring", + exec: function (e, t) { + e.insert(t); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" }, - multiSelectAction: "forEach", - scrollIntoView: "cursor" - }, - { - name: "inserttext", - exec: function(e, t) { - e.insert(r.stringRepeat(t.text || "", t.times || 1)); + { + name: "inserttext", + exec: function (e, t) { + e.insert(r.stringRepeat(t.text || "", t.times || 1)); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" }, - multiSelectAction: "forEach", - scrollIntoView: "cursor" - }, - { - name: "splitline", - bindKey: o(null, "Ctrl-O"), - exec: function(e) { - e.splitLine(); + { + name: "splitline", + bindKey: o(null, "Ctrl-O"), + exec: function (e) { + e.splitLine(); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" }, - multiSelectAction: "forEach", - scrollIntoView: "cursor" - }, - { - name: "transposeletters", - bindKey: o("Ctrl-T", "Ctrl-T"), - exec: function(e) { - e.transposeLetters(); + { + name: "transposeletters", + bindKey: o("Ctrl-T", "Ctrl-T"), + exec: function (e) { + e.transposeLetters(); + }, + multiSelectAction: function (e) { + e.transposeSelections(1); + }, + scrollIntoView: "cursor" }, - multiSelectAction: function(e) { - e.transposeSelections(1); + { + name: "touppercase", + bindKey: o("Ctrl-U", "Ctrl-U"), + exec: function (e) { + e.toUpperCase(); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" }, - scrollIntoView: "cursor" - }, - { - name: "touppercase", - bindKey: o("Ctrl-U", "Ctrl-U"), - exec: function(e) { - e.toUpperCase(); + { + name: "tolowercase", + bindKey: o("Ctrl-Shift-U", "Ctrl-Shift-U"), + exec: function (e) { + e.toLowerCase(); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" }, - multiSelectAction: "forEach", - scrollIntoView: "cursor" - }, - { - name: "tolowercase", - bindKey: o("Ctrl-Shift-U", "Ctrl-Shift-U"), - exec: function(e) { - e.toLowerCase(); + { + name: "expandtoline", + bindKey: o("Ctrl-Shift-L", "Command-Shift-L"), + exec: function (e) { + var t = e.selection.getRange(); + ((t.start.column = t.end.column = 0), + t.end.row++, + e.selection.setRange(t, !1)); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: !0 }, - multiSelectAction: "forEach", - scrollIntoView: "cursor" - }, - { - name: "expandtoline", - bindKey: o("Ctrl-Shift-L", "Command-Shift-L"), - exec: function(e) { - var t = e.selection.getRange(); - (t.start.column = t.end.column = 0), - t.end.row++, - e.selection.setRange(t, !1); + { + name: "joinlines", + bindKey: o(null, null), + exec: function (e) { + var t = e.selection.isBackwards(), + n = t + ? e.selection.getSelectionLead() + : e.selection.getSelectionAnchor(), + i = t + ? e.selection.getSelectionAnchor() + : e.selection.getSelectionLead(), + o = e.session.doc.getLine(n.row).length, + u = e.session.doc.getTextRange(e.selection.getRange()), + a = u.replace(/\n\s*/, " ").length, + f = e.session.doc.getLine(n.row); + for (var l = n.row + 1; l <= i.row + 1; l++) { + var c = r.stringTrimLeft( + r.stringTrimRight(e.session.doc.getLine(l)) + ); + (c.length !== 0 && (c = " " + c), (f += c)); + } + (i.row + 1 < e.session.doc.getLength() - 1 && + (f += e.session.doc.getNewLineCharacter()), + e.clearSelection(), + e.session.doc.replace(new s(n.row, 0, i.row + 2, 0), f), + a > 0 + ? (e.selection.moveCursorTo(n.row, n.column), + e.selection.selectTo(n.row, n.column + a)) + : ((o = e.session.doc.getLine(n.row).length > o ? o + 1 : o), + e.selection.moveCursorTo(n.row, o))); + }, + multiSelectAction: "forEach", + readOnly: !0 }, - multiSelectAction: "forEach", - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "joinlines", - bindKey: o(null, null), - exec: function(e) { - var t = e.selection.isBackwards(), - n = t - ? e.selection.getSelectionLead() - : e.selection.getSelectionAnchor(), - i = t - ? e.selection.getSelectionAnchor() - : e.selection.getSelectionLead(), - o = e.session.doc.getLine(n.row).length, - u = e.session.doc.getTextRange(e.selection.getRange()), - a = u.replace(/\n\s*/, " ").length, - f = e.session.doc.getLine(n.row); - for (var l = n.row + 1; l <= i.row + 1; l++) { - var c = r.stringTrimLeft( - r.stringTrimRight(e.session.doc.getLine(l)) + { + name: "invertSelection", + bindKey: o(null, null), + exec: function (e) { + var t = e.session.doc.getLength() - 1, + n = e.session.doc.getLine(t).length, + r = e.selection.rangeList.ranges, + i = []; + r.length < 1 && (r = [e.selection.getRange()]); + for (var o = 0; o < r.length; o++) + (o == r.length - 1 && + (r[o].end.row !== t || r[o].end.column !== n) && + i.push(new s(r[o].end.row, r[o].end.column, t, n)), + o === 0 + ? (r[o].start.row !== 0 || r[o].start.column !== 0) && + i.push(new s(0, 0, r[o].start.row, r[o].start.column)) + : i.push( + new s( + r[o - 1].end.row, + r[o - 1].end.column, + r[o].start.row, + r[o].start.column + ) + )); + (e.exitMultiSelectMode(), e.clearSelection()); + for (var o = 0; o < i.length; o++) e.selection.addRange(i[o], !1); + }, + readOnly: !0, + scrollIntoView: "none" + } + ]; + } + ), + define( + "ace/editor", + [ + "require", + "exports", + "module", + "ace/lib/fixoldbrowsers", + "ace/lib/oop", + "ace/lib/dom", + "ace/lib/lang", + "ace/lib/useragent", + "ace/keyboard/textinput", + "ace/mouse/mouse_handler", + "ace/mouse/fold_handler", + "ace/keyboard/keybinding", + "ace/edit_session", + "ace/search", + "ace/range", + "ace/lib/event_emitter", + "ace/commands/command_manager", + "ace/commands/default_commands", + "ace/config", + "ace/token_iterator" + ], + function (e, t, n) { + "use strict"; + e("./lib/fixoldbrowsers"); + var r = e("./lib/oop"), + i = e("./lib/dom"), + s = e("./lib/lang"), + o = e("./lib/useragent"), + u = e("./keyboard/textinput").TextInput, + a = e("./mouse/mouse_handler").MouseHandler, + f = e("./mouse/fold_handler").FoldHandler, + l = e("./keyboard/keybinding").KeyBinding, + c = e("./edit_session").EditSession, + h = e("./search").Search, + p = e("./range").Range, + d = e("./lib/event_emitter").EventEmitter, + v = e("./commands/command_manager").CommandManager, + m = e("./commands/default_commands").commands, + g = e("./config"), + y = e("./token_iterator").TokenIterator, + b = function (e, t) { + var n = e.getContainerElement(); + ((this.container = n), + (this.renderer = e), + (this.commands = new v(o.isMac ? "mac" : "win", m)), + (this.textInput = new u(e.getTextAreaContainer(), this)), + (this.renderer.textarea = this.textInput.getElement()), + (this.keyBinding = new l(this)), + (this.$mouseHandler = new a(this)), + new f(this), + (this.$blockScrolling = 0), + (this.$search = new h().set({ wrap: !0 })), + (this.$historyTracker = this.$historyTracker.bind(this)), + this.commands.on("exec", this.$historyTracker), + this.$initOperationListeners(), + (this._$emitInputEvent = s.delayedCall( + function () { + (this._signal("input", {}), + this.session && + this.session.bgTokenizer && + this.session.bgTokenizer.scheduleStart()); + }.bind(this) + )), + this.on("change", function (e, t) { + t._$emitInputEvent.schedule(31); + }), + this.setSession(t || new c("")), + g.resetOptions(this), + g._signal("editor", this)); + }; + ((function () { + (r.implement(this, d), + (this.$initOperationListeners = function () { + function e(e) { + return e[e.length - 1]; + } + ((this.selections = []), + this.commands.on("exec", this.startOperation.bind(this), !0), + this.commands.on("afterExec", this.endOperation.bind(this), !0), + (this.$opResetTimer = s.delayedCall( + this.endOperation.bind(this) + )), + this.on( + "change", + function () { + (this.curOp || this.startOperation(), + (this.curOp.docChanged = !0)); + }.bind(this), + !0 + ), + this.on( + "changeSelection", + function () { + (this.curOp || this.startOperation(), + (this.curOp.selectionChanged = !0)); + }.bind(this), + !0 + )); + }), + (this.curOp = null), + (this.prevOp = {}), + (this.startOperation = function (e) { + if (this.curOp) { + if (!e || this.curOp.command) return; + this.prevOp = this.curOp; + } + (e || ((this.previousCommand = null), (e = {})), + this.$opResetTimer.schedule(), + (this.curOp = { + command: e.command || {}, + args: e.args, + scrollTop: this.renderer.scrollTop + }), + this.curOp.command.name && + this.curOp.command.scrollIntoView !== undefined && + this.$blockScrolling++); + }), + (this.endOperation = function (e) { + if (this.curOp) { + if (e && e.returnValue === !1) return (this.curOp = null); + this._signal("beforeEndOperation"); + var t = this.curOp.command; + t.name && this.$blockScrolling > 0 && this.$blockScrolling--; + var n = t && t.scrollIntoView; + if (n) { + switch (n) { + case "center-animate": + n = "animate"; + case "center": + this.renderer.scrollCursorIntoView(null, 0.5); + break; + case "animate": + case "cursor": + this.renderer.scrollCursorIntoView(); + break; + case "selectionPart": + var r = this.selection.getRange(), + i = this.renderer.layerConfig; + (r.start.row >= i.lastRow || r.end.row <= i.firstRow) && + this.renderer.scrollSelectionIntoView( + this.selection.anchor, + this.selection.lead + ); + break; + default: + } + n == "animate" && + this.renderer.animateScrolling(this.curOp.scrollTop); + } + ((this.prevOp = this.curOp), (this.curOp = null)); + } + }), + (this.$mergeableCommands = ["backspace", "del", "insertstring"]), + (this.$historyTracker = function (e) { + if (!this.$mergeUndoDeltas) return; + var t = this.prevOp, + n = this.$mergeableCommands, + r = t.command && e.command.name == t.command.name; + if (e.command.name == "insertstring") { + var i = e.args; + (this.mergeNextCommand === undefined && + (this.mergeNextCommand = !0), + (r = + r && + this.mergeNextCommand && + (!/\s/.test(i) || /\s/.test(t.args))), + (this.mergeNextCommand = !0)); + } else r = r && n.indexOf(e.command.name) !== -1; + (this.$mergeUndoDeltas != "always" && + Date.now() - this.sequenceStartTime > 2e3 && + (r = !1), + r + ? (this.session.mergeUndoDeltas = !0) + : n.indexOf(e.command.name) !== -1 && + (this.sequenceStartTime = Date.now())); + }), + (this.setKeyboardHandler = function (e, t) { + if (e && typeof e == "string") { + this.$keybindingId = e; + var n = this; + g.loadModule(["keybinding", e], function (r) { + (n.$keybindingId == e && + n.keyBinding.setKeyboardHandler(r && r.handler), + t && t()); + }); + } else + ((this.$keybindingId = null), + this.keyBinding.setKeyboardHandler(e), + t && t()); + }), + (this.getKeyboardHandler = function () { + return this.keyBinding.getKeyboardHandler(); + }), + (this.setSession = function (e) { + if (this.session == e) return; + (this.curOp && this.endOperation(), (this.curOp = {})); + var t = this.session; + if (t) { + (this.session.off("change", this.$onDocumentChange), + this.session.off("changeMode", this.$onChangeMode), + this.session.off("tokenizerUpdate", this.$onTokenizerUpdate), + this.session.off("changeTabSize", this.$onChangeTabSize), + this.session.off("changeWrapLimit", this.$onChangeWrapLimit), + this.session.off("changeWrapMode", this.$onChangeWrapMode), + this.session.off("changeFold", this.$onChangeFold), + this.session.off( + "changeFrontMarker", + this.$onChangeFrontMarker + ), + this.session.off("changeBackMarker", this.$onChangeBackMarker), + this.session.off("changeBreakpoint", this.$onChangeBreakpoint), + this.session.off("changeAnnotation", this.$onChangeAnnotation), + this.session.off("changeOverwrite", this.$onCursorChange), + this.session.off("changeScrollTop", this.$onScrollTopChange), + this.session.off("changeScrollLeft", this.$onScrollLeftChange)); + var n = this.session.getSelection(); + (n.off("changeCursor", this.$onCursorChange), + n.off("changeSelection", this.$onSelectionChange)); + } + ((this.session = e), + e + ? ((this.$onDocumentChange = this.onDocumentChange.bind(this)), + e.on("change", this.$onDocumentChange), + this.renderer.setSession(e), + (this.$onChangeMode = this.onChangeMode.bind(this)), + e.on("changeMode", this.$onChangeMode), + (this.$onTokenizerUpdate = this.onTokenizerUpdate.bind(this)), + e.on("tokenizerUpdate", this.$onTokenizerUpdate), + (this.$onChangeTabSize = this.renderer.onChangeTabSize.bind( + this.renderer + )), + e.on("changeTabSize", this.$onChangeTabSize), + (this.$onChangeWrapLimit = this.onChangeWrapLimit.bind(this)), + e.on("changeWrapLimit", this.$onChangeWrapLimit), + (this.$onChangeWrapMode = this.onChangeWrapMode.bind(this)), + e.on("changeWrapMode", this.$onChangeWrapMode), + (this.$onChangeFold = this.onChangeFold.bind(this)), + e.on("changeFold", this.$onChangeFold), + (this.$onChangeFrontMarker = + this.onChangeFrontMarker.bind(this)), + this.session.on( + "changeFrontMarker", + this.$onChangeFrontMarker + ), + (this.$onChangeBackMarker = + this.onChangeBackMarker.bind(this)), + this.session.on("changeBackMarker", this.$onChangeBackMarker), + (this.$onChangeBreakpoint = + this.onChangeBreakpoint.bind(this)), + this.session.on("changeBreakpoint", this.$onChangeBreakpoint), + (this.$onChangeAnnotation = + this.onChangeAnnotation.bind(this)), + this.session.on("changeAnnotation", this.$onChangeAnnotation), + (this.$onCursorChange = this.onCursorChange.bind(this)), + this.session.on("changeOverwrite", this.$onCursorChange), + (this.$onScrollTopChange = this.onScrollTopChange.bind(this)), + this.session.on("changeScrollTop", this.$onScrollTopChange), + (this.$onScrollLeftChange = + this.onScrollLeftChange.bind(this)), + this.session.on("changeScrollLeft", this.$onScrollLeftChange), + (this.selection = e.getSelection()), + this.selection.on("changeCursor", this.$onCursorChange), + (this.$onSelectionChange = this.onSelectionChange.bind(this)), + this.selection.on("changeSelection", this.$onSelectionChange), + this.onChangeMode(), + (this.$blockScrolling += 1), + this.onCursorChange(), + (this.$blockScrolling -= 1), + this.onScrollTopChange(), + this.onScrollLeftChange(), + this.onSelectionChange(), + this.onChangeFrontMarker(), + this.onChangeBackMarker(), + this.onChangeBreakpoint(), + this.onChangeAnnotation(), + this.session.getUseWrapMode() && + this.renderer.adjustWrapLimit(), + this.renderer.updateFull()) + : ((this.selection = null), this.renderer.setSession(e)), + this._signal("changeSession", { session: e, oldSession: t }), + (this.curOp = null), + t && t._signal("changeEditor", { oldEditor: this }), + e && e._signal("changeEditor", { editor: this })); + }), + (this.getSession = function () { + return this.session; + }), + (this.setValue = function (e, t) { + return ( + this.session.doc.setValue(e), + t + ? t == 1 + ? this.navigateFileEnd() + : t == -1 && this.navigateFileStart() + : this.selectAll(), + e ); - c.length !== 0 && (c = " " + c), (f += c); - } - i.row + 1 < e.session.doc.getLength() - 1 && - (f += e.session.doc.getNewLineCharacter()), - e.clearSelection(), - e.session.doc.replace(new s(n.row, 0, i.row + 2, 0), f), - a > 0 - ? (e.selection.moveCursorTo(n.row, n.column), - e.selection.selectTo(n.row, n.column + a)) - : ((o = e.session.doc.getLine(n.row).length > o ? o + 1 : o), - e.selection.moveCursorTo(n.row, o)); - }, - multiSelectAction: "forEach", - readOnly: !0 - }, - { - name: "invertSelection", - bindKey: o(null, null), - exec: function(e) { - var t = e.session.doc.getLength() - 1, - n = e.session.doc.getLine(t).length, - r = e.selection.rangeList.ranges, - i = []; - r.length < 1 && (r = [e.selection.getRange()]); - for (var o = 0; o < r.length; o++) - o == r.length - 1 && - (r[o].end.row !== t || r[o].end.column !== n) && - i.push(new s(r[o].end.row, r[o].end.column, t, n)), - o === 0 - ? (r[o].start.row !== 0 || r[o].start.column !== 0) && - i.push(new s(0, 0, r[o].start.row, r[o].start.column)) - : i.push( - new s( - r[o - 1].end.row, - r[o - 1].end.column, - r[o].start.row, - r[o].start.column - ) - ); - e.exitMultiSelectMode(), e.clearSelection(); - for (var o = 0; o < i.length; o++) e.selection.addRange(i[o], !1); - }, - readOnly: !0, - scrollIntoView: "none" - } - ]; - }), - define("ace/editor", [ - "require", - "exports", - "module", - "ace/lib/fixoldbrowsers", - "ace/lib/oop", - "ace/lib/dom", - "ace/lib/lang", - "ace/lib/useragent", - "ace/keyboard/textinput", - "ace/mouse/mouse_handler", - "ace/mouse/fold_handler", - "ace/keyboard/keybinding", - "ace/edit_session", - "ace/search", - "ace/range", - "ace/lib/event_emitter", - "ace/commands/command_manager", - "ace/commands/default_commands", - "ace/config", - "ace/token_iterator" - ], function(e, t, n) { - "use strict"; - e("./lib/fixoldbrowsers"); - var r = e("./lib/oop"), - i = e("./lib/dom"), - s = e("./lib/lang"), - o = e("./lib/useragent"), - u = e("./keyboard/textinput").TextInput, - a = e("./mouse/mouse_handler").MouseHandler, - f = e("./mouse/fold_handler").FoldHandler, - l = e("./keyboard/keybinding").KeyBinding, - c = e("./edit_session").EditSession, - h = e("./search").Search, - p = e("./range").Range, - d = e("./lib/event_emitter").EventEmitter, - v = e("./commands/command_manager").CommandManager, - m = e("./commands/default_commands").commands, - g = e("./config"), - y = e("./token_iterator").TokenIterator, - b = function(e, t) { - var n = e.getContainerElement(); - (this.container = n), - (this.renderer = e), - (this.commands = new v(o.isMac ? "mac" : "win", m)), - (this.textInput = new u(e.getTextAreaContainer(), this)), - (this.renderer.textarea = this.textInput.getElement()), - (this.keyBinding = new l(this)), - (this.$mouseHandler = new a(this)), - new f(this), - (this.$blockScrolling = 0), - (this.$search = new h().set({ wrap: !0 })), - (this.$historyTracker = this.$historyTracker.bind(this)), - this.commands.on("exec", this.$historyTracker), - this.$initOperationListeners(), - (this._$emitInputEvent = s.delayedCall( - function() { - this._signal("input", {}), - this.session && - this.session.bgTokenizer && - this.session.bgTokenizer.scheduleStart(); - }.bind(this) - )), - this.on("change", function(e, t) { - t._$emitInputEvent.schedule(31); }), - this.setSession(t || new c("")), - g.resetOptions(this), - g._signal("editor", this); - }; - (function() { - r.implement(this, d), - (this.$initOperationListeners = function() { - function e(e) { - return e[e.length - 1]; - } - (this.selections = []), - this.commands.on("exec", this.startOperation.bind(this), !0), - this.commands.on("afterExec", this.endOperation.bind(this), !0), - (this.$opResetTimer = s.delayedCall(this.endOperation.bind(this))), - this.on( - "change", - function() { - this.curOp || this.startOperation(), - (this.curOp.docChanged = !0); - }.bind(this), - !0 - ), - this.on( - "changeSelection", - function() { - this.curOp || this.startOperation(), - (this.curOp.selectionChanged = !0); - }.bind(this), - !0 + (this.getValue = function () { + return this.session.getValue(); + }), + (this.getSelection = function () { + return this.selection; + }), + (this.resize = function (e) { + this.renderer.onResize(e); + }), + (this.setTheme = function (e, t) { + this.renderer.setTheme(e, t); + }), + (this.getTheme = function () { + return this.renderer.getTheme(); + }), + (this.setStyle = function (e) { + this.renderer.setStyle(e); + }), + (this.unsetStyle = function (e) { + this.renderer.unsetStyle(e); + }), + (this.getFontSize = function () { + return ( + this.getOption("fontSize") || + i.computedStyle(this.container, "fontSize") ); - }), - (this.curOp = null), - (this.prevOp = {}), - (this.startOperation = function(e) { - if (this.curOp) { - if (!e || this.curOp.command) return; - this.prevOp = this.curOp; - } - e || ((this.previousCommand = null), (e = {})), - this.$opResetTimer.schedule(), - (this.curOp = { - command: e.command || {}, - args: e.args, - scrollTop: this.renderer.scrollTop + }), + (this.setFontSize = function (e) { + this.setOption("fontSize", e); + }), + (this.$highlightBrackets = function () { + this.session.$bracketHighlight && + (this.session.removeMarker(this.session.$bracketHighlight), + (this.session.$bracketHighlight = null)); + if (this.$highlightPending) return; + var e = this; + ((this.$highlightPending = !0), + setTimeout(function () { + e.$highlightPending = !1; + var t = e.session; + if (!t || !t.bgTokenizer) return; + var n = t.findMatchingBracket(e.getCursorPosition()); + if (n) var r = new p(n.row, n.column, n.row, n.column + 1); + else if (t.$mode.getMatching) + var r = t.$mode.getMatching(e.session); + r && + (t.$bracketHighlight = t.addMarker(r, "ace_bracket", "text")); + }, 50)); + }), + (this.$highlightTags = function () { + if (this.$highlightTagPending) return; + var e = this; + ((this.$highlightTagPending = !0), + setTimeout(function () { + e.$highlightTagPending = !1; + var t = e.session; + if (!t || !t.bgTokenizer) return; + var n = e.getCursorPosition(), + r = new y(e.session, n.row, n.column), + i = r.getCurrentToken(); + if (!i || !/\b(?:tag-open|tag-name)/.test(i.type)) { + (t.removeMarker(t.$tagHighlight), (t.$tagHighlight = null)); + return; + } + if (i.type.indexOf("tag-open") != -1) { + i = r.stepForward(); + if (!i) return; + } + var s = i.value, + o = 0, + u = r.stepBackward(); + if (u.value == "<") { + do + ((u = i), + (i = r.stepForward()), + i && + i.value === s && + i.type.indexOf("tag-name") !== -1 && + (u.value === "<" ? o++ : u.value === "= 0); + } else { + do + ((i = u), + (u = r.stepBackward()), + i && + i.value === s && + i.type.indexOf("tag-name") !== -1 && + (u.value === "<" ? o++ : u.value === " 0 && this.$blockScrolling--; - var n = t && t.scrollIntoView; - if (n) { - switch (n) { - case "center-animate": - n = "animate"; - case "center": - this.renderer.scrollCursorIntoView(null, 0.5); - break; - case "animate": - case "cursor": - this.renderer.scrollCursorIntoView(); - break; - case "selectionPart": - var r = this.selection.getRange(), - i = this.renderer.layerConfig; - (r.start.row >= i.lastRow || r.end.row <= i.firstRow) && - this.renderer.scrollSelectionIntoView( - this.selection.anchor, - this.selection.lead - ); - break; - default: - } - n == "animate" && - this.renderer.animateScrolling(this.curOp.scrollTop); + this.textInput.focus()); + }), + (this.isFocused = function () { + return this.textInput.isFocused(); + }), + (this.blur = function () { + this.textInput.blur(); + }), + (this.onFocus = function (e) { + if (this.$isFocused) return; + ((this.$isFocused = !0), + this.renderer.showCursor(), + this.renderer.visualizeFocus(), + this._emit("focus", e)); + }), + (this.onBlur = function (e) { + if (!this.$isFocused) return; + ((this.$isFocused = !1), + this.renderer.hideCursor(), + this.renderer.visualizeBlur(), + this._emit("blur", e)); + }), + (this.$cursorChange = function () { + this.renderer.updateCursor(); + }), + (this.onDocumentChange = function (e) { + var t = this.session.$useWrapMode, + n = e.start.row == e.end.row ? e.end.row : Infinity; + (this.renderer.updateLines(e.start.row, n, t), + this._signal("change", e), + this.$cursorChange(), + this.$updateHighlightActiveLine()); + }), + (this.onTokenizerUpdate = function (e) { + var t = e.data; + this.renderer.updateLines(t.first, t.last); + }), + (this.onScrollTopChange = function () { + this.renderer.scrollToY(this.session.getScrollTop()); + }), + (this.onScrollLeftChange = function () { + this.renderer.scrollToX(this.session.getScrollLeft()); + }), + (this.onCursorChange = function () { + (this.$cursorChange(), + this.$blockScrolling || + (g.warn( + "Automatically scrolling cursor into view after selection change", + "this will be disabled in the next version", + "set editor.$blockScrolling = Infinity to disable this message" + ), + this.renderer.scrollCursorIntoView()), + this.$highlightBrackets(), + this.$highlightTags(), + this.$updateHighlightActiveLine(), + this._signal("changeSelection")); + }), + (this.$updateHighlightActiveLine = function () { + var e = this.getSession(), + t; + if (this.$highlightActiveLine) { + if ( + this.$selectionStyle != "line" || + !this.selection.isMultiLine() + ) + t = this.getCursorPosition(); + this.renderer.$maxLines && + this.session.getLength() === 1 && + !(this.renderer.$minLines > 1) && + (t = !1); } - (this.prevOp = this.curOp), (this.curOp = null); - } - }), - (this.$mergeableCommands = ["backspace", "del", "insertstring"]), - (this.$historyTracker = function(e) { - if (!this.$mergeUndoDeltas) return; - var t = this.prevOp, - n = this.$mergeableCommands, - r = t.command && e.command.name == t.command.name; - if (e.command.name == "insertstring") { - var i = e.args; - this.mergeNextCommand === undefined && (this.mergeNextCommand = !0), - (r = - r && - this.mergeNextCommand && - (!/\s/.test(i) || /\s/.test(t.args))), - (this.mergeNextCommand = !0); - } else r = r && n.indexOf(e.command.name) !== -1; - this.$mergeUndoDeltas != "always" && - Date.now() - this.sequenceStartTime > 2e3 && - (r = !1), - r - ? (this.session.mergeUndoDeltas = !0) - : n.indexOf(e.command.name) !== -1 && - (this.sequenceStartTime = Date.now()); - }), - (this.setKeyboardHandler = function(e, t) { - if (e && typeof e == "string") { - this.$keybindingId = e; - var n = this; - g.loadModule(["keybinding", e], function(r) { - n.$keybindingId == e && - n.keyBinding.setKeyboardHandler(r && r.handler), - t && t(); + if (e.$highlightLineMarker && !t) + (e.removeMarker(e.$highlightLineMarker.id), + (e.$highlightLineMarker = null)); + else if (!e.$highlightLineMarker && t) { + var n = new p(t.row, t.column, t.row, Infinity); + ((n.id = e.addMarker(n, "ace_active-line", "screenLine")), + (e.$highlightLineMarker = n)); + } else + t && + ((e.$highlightLineMarker.start.row = t.row), + (e.$highlightLineMarker.end.row = t.row), + (e.$highlightLineMarker.start.column = t.column), + e._signal("changeBackMarker")); + }), + (this.onSelectionChange = function (e) { + var t = this.session; + (t.$selectionMarker && t.removeMarker(t.$selectionMarker), + (t.$selectionMarker = null)); + if (!this.selection.isEmpty()) { + var n = this.selection.getRange(), + r = this.getSelectionStyle(); + t.$selectionMarker = t.addMarker(n, "ace_selection", r); + } else this.$updateHighlightActiveLine(); + var i = + this.$highlightSelectedWord && + this.$getSelectionHighLightRegexp(); + (this.session.highlight(i), this._signal("changeSelection")); + }), + (this.$getSelectionHighLightRegexp = function () { + var e = this.session, + t = this.getSelectionRange(); + if (t.isEmpty() || t.isMultiLine()) return; + var n = t.start.column - 1, + r = t.end.column + 1, + i = e.getLine(t.start.row), + s = i.length, + o = i.substring(Math.max(n, 0), Math.min(r, s)); + if ((n >= 0 && /^[\w\d]/.test(o)) || (r <= s && /[\w\d]$/.test(o))) + return; + o = i.substring(t.start.column, t.end.column); + if (!/^[\w\d]+$/.test(o)) return; + var u = this.$search.$assembleRegExp({ + wholeWord: !0, + caseSensitive: !0, + needle: o }); - } else - (this.$keybindingId = null), - this.keyBinding.setKeyboardHandler(e), - t && t(); - }), - (this.getKeyboardHandler = function() { - return this.keyBinding.getKeyboardHandler(); - }), - (this.setSession = function(e) { - if (this.session == e) return; - this.curOp && this.endOperation(), (this.curOp = {}); - var t = this.session; - if (t) { - this.session.off("change", this.$onDocumentChange), - this.session.off("changeMode", this.$onChangeMode), - this.session.off("tokenizerUpdate", this.$onTokenizerUpdate), - this.session.off("changeTabSize", this.$onChangeTabSize), - this.session.off("changeWrapLimit", this.$onChangeWrapLimit), - this.session.off("changeWrapMode", this.$onChangeWrapMode), - this.session.off("changeFold", this.$onChangeFold), - this.session.off("changeFrontMarker", this.$onChangeFrontMarker), - this.session.off("changeBackMarker", this.$onChangeBackMarker), - this.session.off("changeBreakpoint", this.$onChangeBreakpoint), - this.session.off("changeAnnotation", this.$onChangeAnnotation), - this.session.off("changeOverwrite", this.$onCursorChange), - this.session.off("changeScrollTop", this.$onScrollTopChange), - this.session.off("changeScrollLeft", this.$onScrollLeftChange); - var n = this.session.getSelection(); - n.off("changeCursor", this.$onCursorChange), - n.off("changeSelection", this.$onSelectionChange); - } - (this.session = e), - e - ? ((this.$onDocumentChange = this.onDocumentChange.bind(this)), - e.on("change", this.$onDocumentChange), - this.renderer.setSession(e), - (this.$onChangeMode = this.onChangeMode.bind(this)), - e.on("changeMode", this.$onChangeMode), - (this.$onTokenizerUpdate = this.onTokenizerUpdate.bind(this)), - e.on("tokenizerUpdate", this.$onTokenizerUpdate), - (this.$onChangeTabSize = this.renderer.onChangeTabSize.bind( - this.renderer - )), - e.on("changeTabSize", this.$onChangeTabSize), - (this.$onChangeWrapLimit = this.onChangeWrapLimit.bind(this)), - e.on("changeWrapLimit", this.$onChangeWrapLimit), - (this.$onChangeWrapMode = this.onChangeWrapMode.bind(this)), - e.on("changeWrapMode", this.$onChangeWrapMode), - (this.$onChangeFold = this.onChangeFold.bind(this)), - e.on("changeFold", this.$onChangeFold), - (this.$onChangeFrontMarker = this.onChangeFrontMarker.bind( - this - )), - this.session.on("changeFrontMarker", this.$onChangeFrontMarker), - (this.$onChangeBackMarker = this.onChangeBackMarker.bind(this)), - this.session.on("changeBackMarker", this.$onChangeBackMarker), - (this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this)), - this.session.on("changeBreakpoint", this.$onChangeBreakpoint), - (this.$onChangeAnnotation = this.onChangeAnnotation.bind(this)), - this.session.on("changeAnnotation", this.$onChangeAnnotation), - (this.$onCursorChange = this.onCursorChange.bind(this)), - this.session.on("changeOverwrite", this.$onCursorChange), - (this.$onScrollTopChange = this.onScrollTopChange.bind(this)), - this.session.on("changeScrollTop", this.$onScrollTopChange), - (this.$onScrollLeftChange = this.onScrollLeftChange.bind(this)), - this.session.on("changeScrollLeft", this.$onScrollLeftChange), - (this.selection = e.getSelection()), - this.selection.on("changeCursor", this.$onCursorChange), - (this.$onSelectionChange = this.onSelectionChange.bind(this)), - this.selection.on("changeSelection", this.$onSelectionChange), - this.onChangeMode(), - (this.$blockScrolling += 1), - this.onCursorChange(), - (this.$blockScrolling -= 1), - this.onScrollTopChange(), - this.onScrollLeftChange(), - this.onSelectionChange(), - this.onChangeFrontMarker(), - this.onChangeBackMarker(), - this.onChangeBreakpoint(), - this.onChangeAnnotation(), - this.session.getUseWrapMode() && - this.renderer.adjustWrapLimit(), - this.renderer.updateFull()) - : ((this.selection = null), this.renderer.setSession(e)), - this._signal("changeSession", { session: e, oldSession: t }), - (this.curOp = null), - t && t._signal("changeEditor", { oldEditor: this }), - e && e._signal("changeEditor", { editor: this }); - }), - (this.getSession = function() { - return this.session; - }), - (this.setValue = function(e, t) { - return ( - this.session.doc.setValue(e), - t - ? t == 1 - ? this.navigateFileEnd() - : t == -1 && this.navigateFileStart() - : this.selectAll(), - e - ); - }), - (this.getValue = function() { - return this.session.getValue(); - }), - (this.getSelection = function() { - return this.selection; - }), - (this.resize = function(e) { - this.renderer.onResize(e); - }), - (this.setTheme = function(e, t) { - this.renderer.setTheme(e, t); - }), - (this.getTheme = function() { - return this.renderer.getTheme(); - }), - (this.setStyle = function(e) { - this.renderer.setStyle(e); - }), - (this.unsetStyle = function(e) { - this.renderer.unsetStyle(e); - }), - (this.getFontSize = function() { - return ( - this.getOption("fontSize") || - i.computedStyle(this.container, "fontSize") - ); - }), - (this.setFontSize = function(e) { - this.setOption("fontSize", e); - }), - (this.$highlightBrackets = function() { - this.session.$bracketHighlight && - (this.session.removeMarker(this.session.$bracketHighlight), - (this.session.$bracketHighlight = null)); - if (this.$highlightPending) return; - var e = this; - (this.$highlightPending = !0), - setTimeout(function() { - e.$highlightPending = !1; - var t = e.session; - if (!t || !t.bgTokenizer) return; - var n = t.findMatchingBracket(e.getCursorPosition()); - if (n) var r = new p(n.row, n.column, n.row, n.column + 1); - else if (t.$mode.getMatching) - var r = t.$mode.getMatching(e.session); - r && - (t.$bracketHighlight = t.addMarker(r, "ace_bracket", "text")); - }, 50); - }), - (this.$highlightTags = function() { - if (this.$highlightTagPending) return; - var e = this; - (this.$highlightTagPending = !0), - setTimeout(function() { - e.$highlightTagPending = !1; - var t = e.session; - if (!t || !t.bgTokenizer) return; - var n = e.getCursorPosition(), - r = new y(e.session, n.row, n.column), - i = r.getCurrentToken(); - if (!i || !/\b(?:tag-open|tag-name)/.test(i.type)) { - t.removeMarker(t.$tagHighlight), (t.$tagHighlight = null); - return; - } - if (i.type.indexOf("tag-open") != -1) { - i = r.stepForward(); - if (!i) return; - } - var s = i.value, - o = 0, - u = r.stepBackward(); - if (u.value == "<") { - do - (u = i), - (i = r.stepForward()), - i && - i.value === s && - i.type.indexOf("tag-name") !== -1 && - (u.value === "<" ? o++ : u.value === "= 0); - } else { - do - (i = u), - (u = r.stepBackward()), - i && - i.value === s && - i.type.indexOf("tag-name") !== -1 && - (u.value === "<" ? o++ : u.value === " r.length || n.length < 2 || !n[1]) + return this.commands.exec("insertstring", this, t); + for (var i = r.length; i--;) { + var s = r[i]; + (s.isEmpty() || this.session.remove(s), + this.session.insert(s.start, n[i])); } - var a = r.getCurrentTokenRow(), - f = r.getCurrentTokenColumn(), - l = new p(a, f, a, f + i.value.length); - t.$tagHighlight && - l.compareRange(t.$backMarkers[t.$tagHighlight].range) !== 0 && - (t.removeMarker(t.$tagHighlight), (t.$tagHighlight = null)), - l && - !t.$tagHighlight && - (t.$tagHighlight = t.addMarker(l, "ace_bracket", "text")); - }, 50); - }), - (this.focus = function() { - var e = this; - setTimeout(function() { - e.textInput.focus(); + } }), - this.textInput.focus(); - }), - (this.isFocused = function() { - return this.textInput.isFocused(); - }), - (this.blur = function() { - this.textInput.blur(); - }), - (this.onFocus = function(e) { - if (this.$isFocused) return; - (this.$isFocused = !0), - this.renderer.showCursor(), - this.renderer.visualizeFocus(), - this._emit("focus", e); - }), - (this.onBlur = function(e) { - if (!this.$isFocused) return; - (this.$isFocused = !1), - this.renderer.hideCursor(), - this.renderer.visualizeBlur(), - this._emit("blur", e); - }), - (this.$cursorChange = function() { - this.renderer.updateCursor(); - }), - (this.onDocumentChange = function(e) { - var t = this.session.$useWrapMode, - n = e.start.row == e.end.row ? e.end.row : Infinity; - this.renderer.updateLines(e.start.row, n, t), - this._signal("change", e), - this.$cursorChange(), - this.$updateHighlightActiveLine(); - }), - (this.onTokenizerUpdate = function(e) { - var t = e.data; - this.renderer.updateLines(t.first, t.last); - }), - (this.onScrollTopChange = function() { - this.renderer.scrollToY(this.session.getScrollTop()); - }), - (this.onScrollLeftChange = function() { - this.renderer.scrollToX(this.session.getScrollLeft()); - }), - (this.onCursorChange = function() { - this.$cursorChange(), - this.$blockScrolling || - (g.warn( - "Automatically scrolling cursor into view after selection change", - "this will be disabled in the next version", - "set editor.$blockScrolling = Infinity to disable this message" - ), - this.renderer.scrollCursorIntoView()), - this.$highlightBrackets(), - this.$highlightTags(), - this.$updateHighlightActiveLine(), - this._signal("changeSelection"); - }), - (this.$updateHighlightActiveLine = function() { - var e = this.getSession(), - t; - if (this.$highlightActiveLine) { - if (this.$selectionStyle != "line" || !this.selection.isMultiLine()) - t = this.getCursorPosition(); - this.renderer.$maxLines && - this.session.getLength() === 1 && - !(this.renderer.$minLines > 1) && - (t = !1); - } - if (e.$highlightLineMarker && !t) - e.removeMarker(e.$highlightLineMarker.id), - (e.$highlightLineMarker = null); - else if (!e.$highlightLineMarker && t) { - var n = new p(t.row, t.column, t.row, Infinity); - (n.id = e.addMarker(n, "ace_active-line", "screenLine")), - (e.$highlightLineMarker = n); - } else - t && - ((e.$highlightLineMarker.start.row = t.row), - (e.$highlightLineMarker.end.row = t.row), - (e.$highlightLineMarker.start.column = t.column), - e._signal("changeBackMarker")); - }), - (this.onSelectionChange = function(e) { - var t = this.session; - t.$selectionMarker && t.removeMarker(t.$selectionMarker), - (t.$selectionMarker = null); - if (!this.selection.isEmpty()) { - var n = this.selection.getRange(), - r = this.getSelectionStyle(); - t.$selectionMarker = t.addMarker(n, "ace_selection", r); - } else this.$updateHighlightActiveLine(); - var i = - this.$highlightSelectedWord && this.$getSelectionHighLightRegexp(); - this.session.highlight(i), this._signal("changeSelection"); - }), - (this.$getSelectionHighLightRegexp = function() { - var e = this.session, - t = this.getSelectionRange(); - if (t.isEmpty() || t.isMultiLine()) return; - var n = t.start.column - 1, - r = t.end.column + 1, - i = e.getLine(t.start.row), - s = i.length, - o = i.substring(Math.max(n, 0), Math.min(r, s)); - if ((n >= 0 && /^[\w\d]/.test(o)) || (r <= s && /[\w\d]$/.test(o))) - return; - o = i.substring(t.start.column, t.end.column); - if (!/^[\w\d]+$/.test(o)) return; - var u = this.$search.$assembleRegExp({ - wholeWord: !0, - caseSensitive: !0, - needle: o - }); - return u; - }), - (this.onChangeFrontMarker = function() { - this.renderer.updateFrontMarkers(); - }), - (this.onChangeBackMarker = function() { - this.renderer.updateBackMarkers(); - }), - (this.onChangeBreakpoint = function() { - this.renderer.updateBreakpoints(); - }), - (this.onChangeAnnotation = function() { - this.renderer.setAnnotations(this.session.getAnnotations()); - }), - (this.onChangeMode = function(e) { - this.renderer.updateText(), this._emit("changeMode", e); - }), - (this.onChangeWrapLimit = function() { - this.renderer.updateFull(); - }), - (this.onChangeWrapMode = function() { - this.renderer.onResize(!0); - }), - (this.onChangeFold = function() { - this.$updateHighlightActiveLine(), this.renderer.updateFull(); - }), - (this.getSelectedText = function() { - return this.session.getTextRange(this.getSelectionRange()); - }), - (this.getCopyText = function() { - var e = this.getSelectedText(); - return this._signal("copy", e), e; - }), - (this.onCopy = function() { - this.commands.exec("copy", this); - }), - (this.onCut = function() { - this.commands.exec("cut", this); - }), - (this.onPaste = function(e, t) { - var n = { text: e, event: t }; - this.commands.exec("paste", this, n); - }), - (this.$handlePaste = function(e) { - typeof e == "string" && (e = { text: e }), this._signal("paste", e); - var t = e.text; - if (!this.inMultiSelectMode || this.inVirtualSelectionMode) - this.insert(t); - else { - var n = t.split(/\r\n|\r|\n/), - r = this.selection.rangeList.ranges; - if (n.length > r.length || n.length < 2 || !n[1]) - return this.commands.exec("insertstring", this, t); - for (var i = r.length; i--; ) { - var s = r[i]; - s.isEmpty() || this.session.remove(s), - this.session.insert(s.start, n[i]); + (this.execCommand = function (e, t) { + return this.commands.exec(e, this, t); + }), + (this.insert = function (e, t) { + var n = this.session, + r = n.getMode(), + i = this.getCursorPosition(); + if (this.getBehavioursEnabled() && !t) { + var s = r.transformAction( + n.getState(i.row), + "insertion", + this, + n, + e + ); + s && + (e !== s.text && + ((this.session.mergeUndoDeltas = !1), + (this.$mergeNextCommand = !1)), + (e = s.text)); } - } - }), - (this.execCommand = function(e, t) { - return this.commands.exec(e, this, t); - }), - (this.insert = function(e, t) { - var n = this.session, - r = n.getMode(), - i = this.getCursorPosition(); - if (this.getBehavioursEnabled() && !t) { - var s = r.transformAction( - n.getState(i.row), - "insertion", - this, - n, - e - ); - s && - (e !== s.text && - ((this.session.mergeUndoDeltas = !1), - (this.$mergeNextCommand = !1)), - (e = s.text)); - } - e == " " && (e = this.session.getTabString()); - if (!this.selection.isEmpty()) { - var o = this.getSelectionRange(); - (i = this.session.remove(o)), this.clearSelection(); - } else if (this.session.getOverwrite()) { - var o = new p.fromPoints(i, i); - (o.end.column += e.length), this.session.remove(o); - } - if (e == "\n" || e == "\r\n") { - var u = n.getLine(i.row); - if (i.column > u.search(/\S|$/)) { - var a = u.substr(i.column).search(/\S|$/); - n.doc.removeInLine(i.row, i.column, i.column + a); + e == " " && (e = this.session.getTabString()); + if (!this.selection.isEmpty()) { + var o = this.getSelectionRange(); + ((i = this.session.remove(o)), this.clearSelection()); + } else if (this.session.getOverwrite()) { + var o = new p.fromPoints(i, i); + ((o.end.column += e.length), this.session.remove(o)); } - } - this.clearSelection(); - var f = i.column, - l = n.getState(i.row), - u = n.getLine(i.row), - c = r.checkOutdent(l, u, e), - h = n.insert(i, e); - s && - s.selection && - (s.selection.length == 2 - ? this.selection.setSelectionRange( - new p(i.row, f + s.selection[0], i.row, f + s.selection[1]) - ) - : this.selection.setSelectionRange( - new p( - i.row + s.selection[0], - s.selection[1], - i.row + s.selection[2], - s.selection[3] + if (e == "\n" || e == "\r\n") { + var u = n.getLine(i.row); + if (i.column > u.search(/\S|$/)) { + var a = u.substr(i.column).search(/\S|$/); + n.doc.removeInLine(i.row, i.column, i.column + a); + } + } + this.clearSelection(); + var f = i.column, + l = n.getState(i.row), + u = n.getLine(i.row), + c = r.checkOutdent(l, u, e), + h = n.insert(i, e); + s && + s.selection && + (s.selection.length == 2 + ? this.selection.setSelectionRange( + new p(i.row, f + s.selection[0], i.row, f + s.selection[1]) ) - )); - if (n.getDocument().isNewLine(e)) { - var d = r.getNextLineIndent( - l, - u.slice(0, i.column), - n.getTabString() - ); - n.insert({ row: i.row + 1, column: 0 }, d); - } - c && r.autoOutdent(l, n, i.row); - }), - (this.onTextInput = function(e) { - this.keyBinding.onTextInput(e); - }), - (this.onCommandKey = function(e, t, n) { - this.keyBinding.onCommandKey(e, t, n); - }), - (this.setOverwrite = function(e) { - this.session.setOverwrite(e); - }), - (this.getOverwrite = function() { - return this.session.getOverwrite(); - }), - (this.toggleOverwrite = function() { - this.session.toggleOverwrite(); - }), - (this.setScrollSpeed = function(e) { - this.setOption("scrollSpeed", e); - }), - (this.getScrollSpeed = function() { - return this.getOption("scrollSpeed"); - }), - (this.setDragDelay = function(e) { - this.setOption("dragDelay", e); - }), - (this.getDragDelay = function() { - return this.getOption("dragDelay"); - }), - (this.setSelectionStyle = function(e) { - this.setOption("selectionStyle", e); - }), - (this.getSelectionStyle = function() { - return this.getOption("selectionStyle"); - }), - (this.setHighlightActiveLine = function(e) { - this.setOption("highlightActiveLine", e); - }), - (this.getHighlightActiveLine = function() { - return this.getOption("highlightActiveLine"); - }), - (this.setHighlightGutterLine = function(e) { - this.setOption("highlightGutterLine", e); - }), - (this.getHighlightGutterLine = function() { - return this.getOption("highlightGutterLine"); - }), - (this.setHighlightSelectedWord = function(e) { - this.setOption("highlightSelectedWord", e); - }), - (this.getHighlightSelectedWord = function() { - return this.$highlightSelectedWord; - }), - (this.setAnimatedScroll = function(e) { - this.renderer.setAnimatedScroll(e); - }), - (this.getAnimatedScroll = function() { - return this.renderer.getAnimatedScroll(); - }), - (this.setShowInvisibles = function(e) { - this.renderer.setShowInvisibles(e); - }), - (this.getShowInvisibles = function() { - return this.renderer.getShowInvisibles(); - }), - (this.setDisplayIndentGuides = function(e) { - this.renderer.setDisplayIndentGuides(e); - }), - (this.getDisplayIndentGuides = function() { - return this.renderer.getDisplayIndentGuides(); - }), - (this.setShowPrintMargin = function(e) { - this.renderer.setShowPrintMargin(e); - }), - (this.getShowPrintMargin = function() { - return this.renderer.getShowPrintMargin(); - }), - (this.setPrintMarginColumn = function(e) { - this.renderer.setPrintMarginColumn(e); - }), - (this.getPrintMarginColumn = function() { - return this.renderer.getPrintMarginColumn(); - }), - (this.setReadOnly = function(e) { - this.setOption("readOnly", e); - }), - (this.getReadOnly = function() { - return this.getOption("readOnly"); - }), - (this.setBehavioursEnabled = function(e) { - this.setOption("behavioursEnabled", e); - }), - (this.getBehavioursEnabled = function() { - return this.getOption("behavioursEnabled"); - }), - (this.setWrapBehavioursEnabled = function(e) { - this.setOption("wrapBehavioursEnabled", e); - }), - (this.getWrapBehavioursEnabled = function() { - return this.getOption("wrapBehavioursEnabled"); - }), - (this.setShowFoldWidgets = function(e) { - this.setOption("showFoldWidgets", e); - }), - (this.getShowFoldWidgets = function() { - return this.getOption("showFoldWidgets"); - }), - (this.setFadeFoldWidgets = function(e) { - this.setOption("fadeFoldWidgets", e); - }), - (this.getFadeFoldWidgets = function() { - return this.getOption("fadeFoldWidgets"); - }), - (this.remove = function(e) { - this.selection.isEmpty() && - (e == "left" - ? this.selection.selectLeft() - : this.selection.selectRight()); - var t = this.getSelectionRange(); - if (this.getBehavioursEnabled()) { - var n = this.session, - r = n.getState(t.start.row), - i = n.getMode().transformAction(r, "deletion", this, n, t); - if (t.end.column === 0) { - var s = n.getTextRange(t); - if (s[s.length - 1] == "\n") { - var o = n.getLine(t.end.row); - /^\s+$/.test(o) && (t.end.column = o.length); + : this.selection.setSelectionRange( + new p( + i.row + s.selection[0], + s.selection[1], + i.row + s.selection[2], + s.selection[3] + ) + )); + if (n.getDocument().isNewLine(e)) { + var d = r.getNextLineIndent( + l, + u.slice(0, i.column), + n.getTabString() + ); + n.insert({ row: i.row + 1, column: 0 }, d); + } + c && r.autoOutdent(l, n, i.row); + }), + (this.onTextInput = function (e) { + this.keyBinding.onTextInput(e); + }), + (this.onCommandKey = function (e, t, n) { + this.keyBinding.onCommandKey(e, t, n); + }), + (this.setOverwrite = function (e) { + this.session.setOverwrite(e); + }), + (this.getOverwrite = function () { + return this.session.getOverwrite(); + }), + (this.toggleOverwrite = function () { + this.session.toggleOverwrite(); + }), + (this.setScrollSpeed = function (e) { + this.setOption("scrollSpeed", e); + }), + (this.getScrollSpeed = function () { + return this.getOption("scrollSpeed"); + }), + (this.setDragDelay = function (e) { + this.setOption("dragDelay", e); + }), + (this.getDragDelay = function () { + return this.getOption("dragDelay"); + }), + (this.setSelectionStyle = function (e) { + this.setOption("selectionStyle", e); + }), + (this.getSelectionStyle = function () { + return this.getOption("selectionStyle"); + }), + (this.setHighlightActiveLine = function (e) { + this.setOption("highlightActiveLine", e); + }), + (this.getHighlightActiveLine = function () { + return this.getOption("highlightActiveLine"); + }), + (this.setHighlightGutterLine = function (e) { + this.setOption("highlightGutterLine", e); + }), + (this.getHighlightGutterLine = function () { + return this.getOption("highlightGutterLine"); + }), + (this.setHighlightSelectedWord = function (e) { + this.setOption("highlightSelectedWord", e); + }), + (this.getHighlightSelectedWord = function () { + return this.$highlightSelectedWord; + }), + (this.setAnimatedScroll = function (e) { + this.renderer.setAnimatedScroll(e); + }), + (this.getAnimatedScroll = function () { + return this.renderer.getAnimatedScroll(); + }), + (this.setShowInvisibles = function (e) { + this.renderer.setShowInvisibles(e); + }), + (this.getShowInvisibles = function () { + return this.renderer.getShowInvisibles(); + }), + (this.setDisplayIndentGuides = function (e) { + this.renderer.setDisplayIndentGuides(e); + }), + (this.getDisplayIndentGuides = function () { + return this.renderer.getDisplayIndentGuides(); + }), + (this.setShowPrintMargin = function (e) { + this.renderer.setShowPrintMargin(e); + }), + (this.getShowPrintMargin = function () { + return this.renderer.getShowPrintMargin(); + }), + (this.setPrintMarginColumn = function (e) { + this.renderer.setPrintMarginColumn(e); + }), + (this.getPrintMarginColumn = function () { + return this.renderer.getPrintMarginColumn(); + }), + (this.setReadOnly = function (e) { + this.setOption("readOnly", e); + }), + (this.getReadOnly = function () { + return this.getOption("readOnly"); + }), + (this.setBehavioursEnabled = function (e) { + this.setOption("behavioursEnabled", e); + }), + (this.getBehavioursEnabled = function () { + return this.getOption("behavioursEnabled"); + }), + (this.setWrapBehavioursEnabled = function (e) { + this.setOption("wrapBehavioursEnabled", e); + }), + (this.getWrapBehavioursEnabled = function () { + return this.getOption("wrapBehavioursEnabled"); + }), + (this.setShowFoldWidgets = function (e) { + this.setOption("showFoldWidgets", e); + }), + (this.getShowFoldWidgets = function () { + return this.getOption("showFoldWidgets"); + }), + (this.setFadeFoldWidgets = function (e) { + this.setOption("fadeFoldWidgets", e); + }), + (this.getFadeFoldWidgets = function () { + return this.getOption("fadeFoldWidgets"); + }), + (this.remove = function (e) { + this.selection.isEmpty() && + (e == "left" + ? this.selection.selectLeft() + : this.selection.selectRight()); + var t = this.getSelectionRange(); + if (this.getBehavioursEnabled()) { + var n = this.session, + r = n.getState(t.start.row), + i = n.getMode().transformAction(r, "deletion", this, n, t); + if (t.end.column === 0) { + var s = n.getTextRange(t); + if (s[s.length - 1] == "\n") { + var o = n.getLine(t.end.row); + /^\s+$/.test(o) && (t.end.column = o.length); + } } + i && (t = i); } - i && (t = i); - } - this.session.remove(t), this.clearSelection(); - }), - (this.removeWordRight = function() { - this.selection.isEmpty() && this.selection.selectWordRight(), - this.session.remove(this.getSelectionRange()), - this.clearSelection(); - }), - (this.removeWordLeft = function() { - this.selection.isEmpty() && this.selection.selectWordLeft(), - this.session.remove(this.getSelectionRange()), - this.clearSelection(); - }), - (this.removeToLineStart = function() { - this.selection.isEmpty() && this.selection.selectLineStart(), - this.session.remove(this.getSelectionRange()), - this.clearSelection(); - }), - (this.removeToLineEnd = function() { - this.selection.isEmpty() && this.selection.selectLineEnd(); - var e = this.getSelectionRange(); - e.start.column == e.end.column && - e.start.row == e.end.row && - ((e.end.column = 0), e.end.row++), - this.session.remove(e), - this.clearSelection(); - }), - (this.splitLine = function() { - this.selection.isEmpty() || - (this.session.remove(this.getSelectionRange()), - this.clearSelection()); - var e = this.getCursorPosition(); - this.insert("\n"), this.moveCursorToPosition(e); - }), - (this.transposeLetters = function() { - if (!this.selection.isEmpty()) return; - var e = this.getCursorPosition(), - t = e.column; - if (t === 0) return; - var n = this.session.getLine(e.row), - r, - i; - t < n.length - ? ((r = n.charAt(t) + n.charAt(t - 1)), - (i = new p(e.row, t - 1, e.row, t + 1))) - : ((r = n.charAt(t - 1) + n.charAt(t - 2)), - (i = new p(e.row, t - 2, e.row, t))), - this.session.replace(i, r); - }), - (this.toLowerCase = function() { - var e = this.getSelectionRange(); - this.selection.isEmpty() && this.selection.selectWord(); - var t = this.getSelectionRange(), - n = this.session.getTextRange(t); - this.session.replace(t, n.toLowerCase()), - this.selection.setSelectionRange(e); - }), - (this.toUpperCase = function() { - var e = this.getSelectionRange(); - this.selection.isEmpty() && this.selection.selectWord(); - var t = this.getSelectionRange(), - n = this.session.getTextRange(t); - this.session.replace(t, n.toUpperCase()), - this.selection.setSelectionRange(e); - }), - (this.indent = function() { - var e = this.session, - t = this.getSelectionRange(); - if (t.start.row < t.end.row) { - var n = this.$getSelectedRows(); - e.indentRows(n.first, n.last, " "); - return; - } - if (t.start.column < t.end.column) { - var r = e.getTextRange(t); - if (!/^\s+$/.test(r)) { + (this.session.remove(t), this.clearSelection()); + }), + (this.removeWordRight = function () { + (this.selection.isEmpty() && this.selection.selectWordRight(), + this.session.remove(this.getSelectionRange()), + this.clearSelection()); + }), + (this.removeWordLeft = function () { + (this.selection.isEmpty() && this.selection.selectWordLeft(), + this.session.remove(this.getSelectionRange()), + this.clearSelection()); + }), + (this.removeToLineStart = function () { + (this.selection.isEmpty() && this.selection.selectLineStart(), + this.session.remove(this.getSelectionRange()), + this.clearSelection()); + }), + (this.removeToLineEnd = function () { + this.selection.isEmpty() && this.selection.selectLineEnd(); + var e = this.getSelectionRange(); + (e.start.column == e.end.column && + e.start.row == e.end.row && + ((e.end.column = 0), e.end.row++), + this.session.remove(e), + this.clearSelection()); + }), + (this.splitLine = function () { + this.selection.isEmpty() || + (this.session.remove(this.getSelectionRange()), + this.clearSelection()); + var e = this.getCursorPosition(); + (this.insert("\n"), this.moveCursorToPosition(e)); + }), + (this.transposeLetters = function () { + if (!this.selection.isEmpty()) return; + var e = this.getCursorPosition(), + t = e.column; + if (t === 0) return; + var n = this.session.getLine(e.row), + r, + i; + (t < n.length + ? ((r = n.charAt(t) + n.charAt(t - 1)), + (i = new p(e.row, t - 1, e.row, t + 1))) + : ((r = n.charAt(t - 1) + n.charAt(t - 2)), + (i = new p(e.row, t - 2, e.row, t))), + this.session.replace(i, r)); + }), + (this.toLowerCase = function () { + var e = this.getSelectionRange(); + this.selection.isEmpty() && this.selection.selectWord(); + var t = this.getSelectionRange(), + n = this.session.getTextRange(t); + (this.session.replace(t, n.toLowerCase()), + this.selection.setSelectionRange(e)); + }), + (this.toUpperCase = function () { + var e = this.getSelectionRange(); + this.selection.isEmpty() && this.selection.selectWord(); + var t = this.getSelectionRange(), + n = this.session.getTextRange(t); + (this.session.replace(t, n.toUpperCase()), + this.selection.setSelectionRange(e)); + }), + (this.indent = function () { + var e = this.session, + t = this.getSelectionRange(); + if (t.start.row < t.end.row) { var n = this.$getSelectedRows(); e.indentRows(n.first, n.last, " "); return; } - } - var i = e.getLine(t.start.row), - o = t.start, - u = e.getTabSize(), - a = e.documentToScreenColumn(o.row, o.column); - if (this.session.getUseSoftTabs()) - var f = u - (a % u), - l = s.stringRepeat(" ", f); - else { - var f = a % u; - while (i[t.start.column - 1] == " " && f) t.start.column--, f--; - this.selection.setSelectionRange(t), (l = " "); - } - return this.insert(l); - }), - (this.blockIndent = function() { - var e = this.$getSelectedRows(); - this.session.indentRows(e.first, e.last, " "); - }), - (this.blockOutdent = function() { - var e = this.session.getSelection(); - this.session.outdentRows(e.getRange()); - }), - (this.sortLines = function() { - var e = this.$getSelectedRows(), - t = this.session, - n = []; - for (i = e.first; i <= e.last; i++) n.push(t.getLine(i)); - n.sort(function(e, t) { - return e.toLowerCase() < t.toLowerCase() - ? -1 - : e.toLowerCase() > t.toLowerCase() - ? 1 - : 0; - }); - var r = new p(0, 0, 0, 0); - for (var i = e.first; i <= e.last; i++) { - var s = t.getLine(i); - (r.start.row = i), - (r.end.row = i), - (r.end.column = s.length), - t.replace(r, n[i - e.first]); - } - }), - (this.toggleCommentLines = function() { - var e = this.session.getState(this.getCursorPosition().row), - t = this.$getSelectedRows(); - this.session - .getMode() - .toggleCommentLines(e, this.session, t.first, t.last); - }), - (this.toggleBlockComment = function() { - var e = this.getCursorPosition(), - t = this.session.getState(e.row), - n = this.getSelectionRange(); - this.session.getMode().toggleBlockComment(t, this.session, n, e); - }), - (this.getNumberAt = function(e, t) { - var n = /[\-]?[0-9]+(?:\.[0-9]+)?/g; - n.lastIndex = 0; - var r = this.session.getLine(e); - while (n.lastIndex < t) { - var i = n.exec(r); - if (i.index <= t && i.index + i[0].length >= t) { - var s = { - value: i[0], - start: i.index, - end: i.index + i[0].length - }; - return s; + if (t.start.column < t.end.column) { + var r = e.getTextRange(t); + if (!/^\s+$/.test(r)) { + var n = this.$getSelectedRows(); + e.indentRows(n.first, n.last, " "); + return; + } } - } - return null; - }), - (this.modifyNumber = function(e) { - var t = this.selection.getCursor().row, - n = this.selection.getCursor().column, - r = new p(t, n - 1, t, n), - i = this.session.getTextRange(r); - if (!isNaN(parseFloat(i)) && isFinite(i)) { - var s = this.getNumberAt(t, n); - if (s) { - var o = - s.value.indexOf(".") >= 0 - ? s.start + s.value.indexOf(".") + 1 - : s.end, - u = s.start + s.value.length - o, - a = parseFloat(s.value); - (a *= Math.pow(10, u)), - o !== s.end && n < o - ? (e *= Math.pow(10, s.end - n - 1)) - : (e *= Math.pow(10, s.end - n)), - (a += e), - (a /= Math.pow(10, u)); - var f = a.toFixed(u), - l = new p(t, s.start, t, s.end); - this.session.replace(l, f), - this.moveCursorTo( - t, - Math.max(s.start + 1, n + f.length - s.value.length) - ); + var i = e.getLine(t.start.row), + o = t.start, + u = e.getTabSize(), + a = e.documentToScreenColumn(o.row, o.column); + if (this.session.getUseSoftTabs()) + var f = u - (a % u), + l = s.stringRepeat(" ", f); + else { + var f = a % u; + while (i[t.start.column - 1] == " " && f) (t.start.column--, f--); + (this.selection.setSelectionRange(t), (l = " ")); } - } - }), - (this.removeLines = function() { - var e = this.$getSelectedRows(); - this.session.removeFullLines(e.first, e.last), this.clearSelection(); - }), - (this.duplicateSelection = function() { - var e = this.selection, - t = this.session, - n = e.getRange(), - r = e.isBackwards(); - if (n.isEmpty()) { - var i = n.start.row; - t.duplicateLines(i, i); - } else { - var s = r ? n.start : n.end, - o = t.insert(s, t.getTextRange(n), !1); - (n.start = s), (n.end = o), e.setSelectionRange(n, r); - } - }), - (this.moveLinesDown = function() { - this.$moveLines(1, !1); - }), - (this.moveLinesUp = function() { - this.$moveLines(-1, !1); - }), - (this.moveText = function(e, t, n) { - return this.session.moveText(e, t, n); - }), - (this.copyLinesUp = function() { - this.$moveLines(-1, !0); - }), - (this.copyLinesDown = function() { - this.$moveLines(1, !0); - }), - (this.$moveLines = function(e, t) { - var n, - r, - i = this.selection; - if (!i.inMultiSelectMode || this.inVirtualSelectionMode) { - var s = i.toOrientedRange(); - (n = this.$getSelectedRows(s)), - (r = this.session.$moveLines(n.first, n.last, t ? 0 : e)), - t && e == -1 && (r = 0), - s.moveBy(r, 0), - i.fromOrientedRange(s); - } else { - var o = i.rangeList.ranges; - i.rangeList.detach(this.session), - (this.inVirtualSelectionMode = !0); - var u = 0, - a = 0, - f = o.length; - for (var l = 0; l < f; l++) { - var c = l; - o[l].moveBy(u, 0), (n = this.$getSelectedRows(o[l])); - var h = n.first, - p = n.last; - while (++l < f) { - a && o[l].moveBy(a, 0); - var d = this.$getSelectedRows(o[l]); - if (t && d.first != p) break; - if (!t && d.first > p + 1) break; - p = d.last; + return this.insert(l); + }), + (this.blockIndent = function () { + var e = this.$getSelectedRows(); + this.session.indentRows(e.first, e.last, " "); + }), + (this.blockOutdent = function () { + var e = this.session.getSelection(); + this.session.outdentRows(e.getRange()); + }), + (this.sortLines = function () { + var e = this.$getSelectedRows(), + t = this.session, + n = []; + for (i = e.first; i <= e.last; i++) n.push(t.getLine(i)); + n.sort(function (e, t) { + return e.toLowerCase() < t.toLowerCase() + ? -1 + : e.toLowerCase() > t.toLowerCase() + ? 1 + : 0; + }); + var r = new p(0, 0, 0, 0); + for (var i = e.first; i <= e.last; i++) { + var s = t.getLine(i); + ((r.start.row = i), + (r.end.row = i), + (r.end.column = s.length), + t.replace(r, n[i - e.first])); + } + }), + (this.toggleCommentLines = function () { + var e = this.session.getState(this.getCursorPosition().row), + t = this.$getSelectedRows(); + this.session + .getMode() + .toggleCommentLines(e, this.session, t.first, t.last); + }), + (this.toggleBlockComment = function () { + var e = this.getCursorPosition(), + t = this.session.getState(e.row), + n = this.getSelectionRange(); + this.session.getMode().toggleBlockComment(t, this.session, n, e); + }), + (this.getNumberAt = function (e, t) { + var n = /[\-]?[0-9]+(?:\.[0-9]+)?/g; + n.lastIndex = 0; + var r = this.session.getLine(e); + while (n.lastIndex < t) { + var i = n.exec(r); + if (i.index <= t && i.index + i[0].length >= t) { + var s = { + value: i[0], + start: i.index, + end: i.index + i[0].length + }; + return s; } - l--, - (u = this.session.$moveLines(h, p, t ? 0 : e)), - t && e == -1 && (c = l + 1); - while (c <= l) o[c].moveBy(u, 0), c++; - t || (u = 0), (a += u); - } - i.fromOrientedRange(i.ranges[0]), - i.rangeList.attach(this.session), - (this.inVirtualSelectionMode = !1); - } - }), - (this.$getSelectedRows = function(e) { - return ( - (e = (e || this.getSelectionRange()).collapseRows()), - { - first: this.session.getRowFoldStart(e.start.row), - last: this.session.getRowFoldEnd(e.end.row) } - ); - }), - (this.onCompositionStart = function(e) { - this.renderer.showComposition(this.getCursorPosition()); - }), - (this.onCompositionUpdate = function(e) { - this.renderer.setCompositionText(e); - }), - (this.onCompositionEnd = function() { - this.renderer.hideComposition(); - }), - (this.getFirstVisibleRow = function() { - return this.renderer.getFirstVisibleRow(); - }), - (this.getLastVisibleRow = function() { - return this.renderer.getLastVisibleRow(); - }), - (this.isRowVisible = function(e) { - return ( - e >= this.getFirstVisibleRow() && e <= this.getLastVisibleRow() - ); - }), - (this.isRowFullyVisible = function(e) { - return ( - e >= this.renderer.getFirstFullyVisibleRow() && - e <= this.renderer.getLastFullyVisibleRow() - ); - }), - (this.$getVisibleRowCount = function() { - return ( - this.renderer.getScrollBottomRow() - - this.renderer.getScrollTopRow() + - 1 - ); - }), - (this.$moveByPage = function(e, t) { - var n = this.renderer, - r = this.renderer.layerConfig, - i = e * Math.floor(r.height / r.lineHeight); - this.$blockScrolling++, - t === !0 - ? this.selection.$moveSelection(function() { - this.moveCursorBy(i, 0); - }) - : t === !1 && - (this.selection.moveCursorBy(i, 0), - this.selection.clearSelection()), - this.$blockScrolling--; - var s = n.scrollTop; - n.scrollBy(0, i * r.lineHeight), - t != null && n.scrollCursorIntoView(null, 0.5), - n.animateScrolling(s); - }), - (this.selectPageDown = function() { - this.$moveByPage(1, !0); - }), - (this.selectPageUp = function() { - this.$moveByPage(-1, !0); - }), - (this.gotoPageDown = function() { - this.$moveByPage(1, !1); - }), - (this.gotoPageUp = function() { - this.$moveByPage(-1, !1); - }), - (this.scrollPageDown = function() { - this.$moveByPage(1); - }), - (this.scrollPageUp = function() { - this.$moveByPage(-1); - }), - (this.scrollToRow = function(e) { - this.renderer.scrollToRow(e); - }), - (this.scrollToLine = function(e, t, n, r) { - this.renderer.scrollToLine(e, t, n, r); - }), - (this.centerSelection = function() { - var e = this.getSelectionRange(), - t = { - row: Math.floor(e.start.row + (e.end.row - e.start.row) / 2), - column: Math.floor( - e.start.column + (e.end.column - e.start.column) / 2 - ) - }; - this.renderer.alignCursor(t, 0.5); - }), - (this.getCursorPosition = function() { - return this.selection.getCursor(); - }), - (this.getCursorPositionScreen = function() { - return this.session.documentToScreenPosition( - this.getCursorPosition() - ); - }), - (this.getSelectionRange = function() { - return this.selection.getRange(); - }), - (this.selectAll = function() { - (this.$blockScrolling += 1), - this.selection.selectAll(), - (this.$blockScrolling -= 1); - }), - (this.clearSelection = function() { - this.selection.clearSelection(); - }), - (this.moveCursorTo = function(e, t) { - this.selection.moveCursorTo(e, t); - }), - (this.moveCursorToPosition = function(e) { - this.selection.moveCursorToPosition(e); - }), - (this.jumpToMatching = function(e, t) { - var n = this.getCursorPosition(), - r = new y(this.session, n.row, n.column), - i = r.getCurrentToken(), - s = i || r.stepForward(); - if (!s) return; - var o, - u = !1, - a = {}, - f = n.column - s.start, - l, - c = { ")": "(", "(": "(", "]": "[", "[": "[", "{": "{", "}": "{" }; - do { - if (s.value.match(/[{}()\[\]]/g)) - for (; f < s.value.length && !u; f++) { - if (!c[s.value[f]]) continue; - (l = c[s.value[f]] + "." + s.type.replace("rparen", "lparen")), - isNaN(a[l]) && (a[l] = 0); - switch (s.value[f]) { - case "(": - case "[": - case "{": - a[l]++; - break; - case ")": - case "]": - case "}": - a[l]--, a[l] === -1 && ((o = "bracket"), (u = !0)); + return null; + }), + (this.modifyNumber = function (e) { + var t = this.selection.getCursor().row, + n = this.selection.getCursor().column, + r = new p(t, n - 1, t, n), + i = this.session.getTextRange(r); + if (!isNaN(parseFloat(i)) && isFinite(i)) { + var s = this.getNumberAt(t, n); + if (s) { + var o = + s.value.indexOf(".") >= 0 + ? s.start + s.value.indexOf(".") + 1 + : s.end, + u = s.start + s.value.length - o, + a = parseFloat(s.value); + ((a *= Math.pow(10, u)), + o !== s.end && n < o + ? (e *= Math.pow(10, s.end - n - 1)) + : (e *= Math.pow(10, s.end - n)), + (a += e), + (a /= Math.pow(10, u))); + var f = a.toFixed(u), + l = new p(t, s.start, t, s.end); + (this.session.replace(l, f), + this.moveCursorTo( + t, + Math.max(s.start + 1, n + f.length - s.value.length) + )); + } + } + }), + (this.removeLines = function () { + var e = this.$getSelectedRows(); + (this.session.removeFullLines(e.first, e.last), + this.clearSelection()); + }), + (this.duplicateSelection = function () { + var e = this.selection, + t = this.session, + n = e.getRange(), + r = e.isBackwards(); + if (n.isEmpty()) { + var i = n.start.row; + t.duplicateLines(i, i); + } else { + var s = r ? n.start : n.end, + o = t.insert(s, t.getTextRange(n), !1); + ((n.start = s), (n.end = o), e.setSelectionRange(n, r)); + } + }), + (this.moveLinesDown = function () { + this.$moveLines(1, !1); + }), + (this.moveLinesUp = function () { + this.$moveLines(-1, !1); + }), + (this.moveText = function (e, t, n) { + return this.session.moveText(e, t, n); + }), + (this.copyLinesUp = function () { + this.$moveLines(-1, !0); + }), + (this.copyLinesDown = function () { + this.$moveLines(1, !0); + }), + (this.$moveLines = function (e, t) { + var n, + r, + i = this.selection; + if (!i.inMultiSelectMode || this.inVirtualSelectionMode) { + var s = i.toOrientedRange(); + ((n = this.$getSelectedRows(s)), + (r = this.session.$moveLines(n.first, n.last, t ? 0 : e)), + t && e == -1 && (r = 0), + s.moveBy(r, 0), + i.fromOrientedRange(s)); + } else { + var o = i.rangeList.ranges; + (i.rangeList.detach(this.session), + (this.inVirtualSelectionMode = !0)); + var u = 0, + a = 0, + f = o.length; + for (var l = 0; l < f; l++) { + var c = l; + (o[l].moveBy(u, 0), (n = this.$getSelectedRows(o[l]))); + var h = n.first, + p = n.last; + while (++l < f) { + a && o[l].moveBy(a, 0); + var d = this.$getSelectedRows(o[l]); + if (t && d.first != p) break; + if (!t && d.first > p + 1) break; + p = d.last; } + (l--, + (u = this.session.$moveLines(h, p, t ? 0 : e)), + t && e == -1 && (c = l + 1)); + while (c <= l) (o[c].moveBy(u, 0), c++); + (t || (u = 0), (a += u)); } - else - s && - s.type.indexOf("tag-name") !== -1 && - (isNaN(a[s.value]) && (a[s.value] = 0), - i.value === "<" - ? a[s.value]++ - : i.value === "= 0; --s) - this.$tryReplace(n[s], e) && r++; - return ( - this.selection.setSelectionRange(i), (this.$blockScrolling -= 1), r - ); - }), - (this.$tryReplace = function(e, t) { - var n = this.session.getTextRange(e); - return ( - (t = this.$search.replace(n, t)), - t !== null ? ((e.end = this.session.replace(e, t)), e) : null - ); - }), - (this.getLastSearchOptions = function() { - return this.$search.getOptions(); - }), - (this.find = function(e, t, n) { - t || (t = {}), - typeof e == "string" || e instanceof RegExp - ? (t.needle = e) - : typeof e == "object" && r.mixin(t, e); - var i = this.selection.getRange(); - t.needle == null && - ((e = this.session.getTextRange(i) || this.$search.$options.needle), - e || - ((i = this.session.getWordRange(i.start.row, i.start.column)), - (e = this.session.getTextRange(i))), - this.$search.set({ needle: e })), - this.$search.set(t), - t.start || this.$search.set({ start: i }); - var s = this.$search.find(this.session); - if (t.preventScroll) return s; - if (s) return this.revealRange(s, n), s; - t.backwards ? (i.start = i.end) : (i.end = i.start), - this.selection.setRange(i); - }), - (this.findNext = function(e, t) { - this.find({ skipCurrent: !0, backwards: !1 }, e, t); - }), - (this.findPrevious = function(e, t) { - this.find(e, { skipCurrent: !0, backwards: !0 }, t); - }), - (this.revealRange = function(e, t) { - (this.$blockScrolling += 1), - this.session.unfold(e), - this.selection.setSelectionRange(e), - (this.$blockScrolling -= 1); - var n = this.renderer.scrollTop; - this.renderer.scrollSelectionIntoView(e.start, e.end, 0.5), - t !== !1 && this.renderer.animateScrolling(n); - }), - (this.undo = function() { - this.$blockScrolling++, - this.session.getUndoManager().undo(), - this.$blockScrolling--, - this.renderer.scrollCursorIntoView(null, 0.5); - }), - (this.redo = function() { - this.$blockScrolling++, - this.session.getUndoManager().redo(), - this.$blockScrolling--, - this.renderer.scrollCursorIntoView(null, 0.5); - }), - (this.destroy = function() { - this.renderer.destroy(), - this._signal("destroy", this), - this.session && this.session.destroy(); - }), - (this.setAutoScrollEditorIntoView = function(e) { - if (!e) return; - var t, - n = this, - r = !1; - this.$scrollAnchor || - (this.$scrollAnchor = document.createElement("div")); - var i = this.$scrollAnchor; - (i.style.cssText = "position:absolute"), - this.container.insertBefore(i, this.container.firstChild); - var s = this.on("changeSelection", function() { - r = !0; - }), - o = this.renderer.on("beforeRender", function() { - r && (t = n.renderer.container.getBoundingClientRect()); - }), - u = this.renderer.on("afterRender", function() { - if ( - r && - t && - (n.isFocused() || (n.searchBox && n.searchBox.isFocused())) - ) { - var e = n.renderer, - s = e.$cursorLayer.$pixelPos, - o = e.layerConfig, - u = s.top - o.offset; - s.top >= 0 && u + t.top < 0 - ? (r = !0) - : s.top < o.height && - s.top + t.top + o.lineHeight > window.innerHeight - ? (r = !1) - : (r = null), - r != null && - ((i.style.top = u + "px"), - (i.style.left = s.left + "px"), - (i.style.height = o.lineHeight + "px"), - i.scrollIntoView(r)), - (r = t = null); + }), + (this.$getSelectedRows = function (e) { + return ( + (e = (e || this.getSelectionRange()).collapseRows()), + { + first: this.session.getRowFoldStart(e.start.row), + last: this.session.getRowFoldEnd(e.end.row) + } + ); + }), + (this.onCompositionStart = function (e) { + this.renderer.showComposition(this.getCursorPosition()); + }), + (this.onCompositionUpdate = function (e) { + this.renderer.setCompositionText(e); + }), + (this.onCompositionEnd = function () { + this.renderer.hideComposition(); + }), + (this.getFirstVisibleRow = function () { + return this.renderer.getFirstVisibleRow(); + }), + (this.getLastVisibleRow = function () { + return this.renderer.getLastVisibleRow(); + }), + (this.isRowVisible = function (e) { + return ( + e >= this.getFirstVisibleRow() && e <= this.getLastVisibleRow() + ); + }), + (this.isRowFullyVisible = function (e) { + return ( + e >= this.renderer.getFirstFullyVisibleRow() && + e <= this.renderer.getLastFullyVisibleRow() + ); + }), + (this.$getVisibleRowCount = function () { + return ( + this.renderer.getScrollBottomRow() - + this.renderer.getScrollTopRow() + + 1 + ); + }), + (this.$moveByPage = function (e, t) { + var n = this.renderer, + r = this.renderer.layerConfig, + i = e * Math.floor(r.height / r.lineHeight); + (this.$blockScrolling++, + t === !0 + ? this.selection.$moveSelection(function () { + this.moveCursorBy(i, 0); + }) + : t === !1 && + (this.selection.moveCursorBy(i, 0), + this.selection.clearSelection()), + this.$blockScrolling--); + var s = n.scrollTop; + (n.scrollBy(0, i * r.lineHeight), + t != null && n.scrollCursorIntoView(null, 0.5), + n.animateScrolling(s)); + }), + (this.selectPageDown = function () { + this.$moveByPage(1, !0); + }), + (this.selectPageUp = function () { + this.$moveByPage(-1, !0); + }), + (this.gotoPageDown = function () { + this.$moveByPage(1, !1); + }), + (this.gotoPageUp = function () { + this.$moveByPage(-1, !1); + }), + (this.scrollPageDown = function () { + this.$moveByPage(1); + }), + (this.scrollPageUp = function () { + this.$moveByPage(-1); + }), + (this.scrollToRow = function (e) { + this.renderer.scrollToRow(e); + }), + (this.scrollToLine = function (e, t, n, r) { + this.renderer.scrollToLine(e, t, n, r); + }), + (this.centerSelection = function () { + var e = this.getSelectionRange(), + t = { + row: Math.floor(e.start.row + (e.end.row - e.start.row) / 2), + column: Math.floor( + e.start.column + (e.end.column - e.start.column) / 2 + ) + }; + this.renderer.alignCursor(t, 0.5); + }), + (this.getCursorPosition = function () { + return this.selection.getCursor(); + }), + (this.getCursorPositionScreen = function () { + return this.session.documentToScreenPosition( + this.getCursorPosition() + ); + }), + (this.getSelectionRange = function () { + return this.selection.getRange(); + }), + (this.selectAll = function () { + ((this.$blockScrolling += 1), + this.selection.selectAll(), + (this.$blockScrolling -= 1)); + }), + (this.clearSelection = function () { + this.selection.clearSelection(); + }), + (this.moveCursorTo = function (e, t) { + this.selection.moveCursorTo(e, t); + }), + (this.moveCursorToPosition = function (e) { + this.selection.moveCursorToPosition(e); + }), + (this.jumpToMatching = function (e, t) { + var n = this.getCursorPosition(), + r = new y(this.session, n.row, n.column), + i = r.getCurrentToken(), + s = i || r.stepForward(); + if (!s) return; + var o, + u = !1, + a = {}, + f = n.column - s.start, + l, + c = { + ")": "(", + "(": "(", + "]": "[", + "[": "[", + "{": "{", + "}": "{" + }; + do { + if (s.value.match(/[{}()\[\]]/g)) + for (; f < s.value.length && !u; f++) { + if (!c[s.value[f]]) continue; + ((l = + c[s.value[f]] + "." + s.type.replace("rparen", "lparen")), + isNaN(a[l]) && (a[l] = 0)); + switch (s.value[f]) { + case "(": + case "[": + case "{": + a[l]++; + break; + case ")": + case "]": + case "}": + (a[l]--, a[l] === -1 && ((o = "bracket"), (u = !0))); + } + } + else + s && + s.type.indexOf("tag-name") !== -1 && + (isNaN(a[s.value]) && (a[s.value] = 0), + i.value === "<" + ? a[s.value]++ + : i.value === "= 0; --s) + this.$tryReplace(n[s], e) && r++; + return ( + this.selection.setSelectionRange(i), + (this.$blockScrolling -= 1), + r + ); + }), + (this.$tryReplace = function (e, t) { + var n = this.session.getTextRange(e); + return ( + (t = this.$search.replace(n, t)), + t !== null ? ((e.end = this.session.replace(e, t)), e) : null + ); + }), + (this.getLastSearchOptions = function () { + return this.$search.getOptions(); + }), + (this.find = function (e, t, n) { + (t || (t = {}), + typeof e == "string" || e instanceof RegExp + ? (t.needle = e) + : typeof e == "object" && r.mixin(t, e)); + var i = this.selection.getRange(); + (t.needle == null && + ((e = + this.session.getTextRange(i) || this.$search.$options.needle), + e || + ((i = this.session.getWordRange(i.start.row, i.start.column)), + (e = this.session.getTextRange(i))), + this.$search.set({ needle: e })), + this.$search.set(t), + t.start || this.$search.set({ start: i })); + var s = this.$search.find(this.session); + if (t.preventScroll) return s; + if (s) return (this.revealRange(s, n), s); + (t.backwards ? (i.start = i.end) : (i.end = i.start), + this.selection.setRange(i)); + }), + (this.findNext = function (e, t) { + this.find({ skipCurrent: !0, backwards: !1 }, e, t); + }), + (this.findPrevious = function (e, t) { + this.find(e, { skipCurrent: !0, backwards: !0 }, t); + }), + (this.revealRange = function (e, t) { + ((this.$blockScrolling += 1), + this.session.unfold(e), + this.selection.setSelectionRange(e), + (this.$blockScrolling -= 1)); + var n = this.renderer.scrollTop; + (this.renderer.scrollSelectionIntoView(e.start, e.end, 0.5), + t !== !1 && this.renderer.animateScrolling(n)); + }), + (this.undo = function () { + (this.$blockScrolling++, + this.session.getUndoManager().undo(), + this.$blockScrolling--, + this.renderer.scrollCursorIntoView(null, 0.5)); + }), + (this.redo = function () { + (this.$blockScrolling++, + this.session.getUndoManager().redo(), + this.$blockScrolling--, + this.renderer.scrollCursorIntoView(null, 0.5)); + }), + (this.destroy = function () { + (this.renderer.destroy(), + this._signal("destroy", this), + this.session && this.session.destroy()); + }), + (this.setAutoScrollEditorIntoView = function (e) { + if (!e) return; + var t, + n = this, + r = !1; + this.$scrollAnchor || + (this.$scrollAnchor = document.createElement("div")); + var i = this.$scrollAnchor; + ((i.style.cssText = "position:absolute"), + this.container.insertBefore(i, this.container.firstChild)); + var s = this.on("changeSelection", function () { + r = !0; + }), + o = this.renderer.on("beforeRender", function () { + r && (t = n.renderer.container.getBoundingClientRect()); + }), + u = this.renderer.on("afterRender", function () { + if ( + r && + t && + (n.isFocused() || (n.searchBox && n.searchBox.isFocused())) + ) { + var e = n.renderer, + s = e.$cursorLayer.$pixelPos, + o = e.layerConfig, + u = s.top - o.offset; + (s.top >= 0 && u + t.top < 0 + ? (r = !0) + : s.top < o.height && + s.top + t.top + o.lineHeight > window.innerHeight + ? (r = !1) + : (r = null), + r != null && + ((i.style.top = u + "px"), + (i.style.left = s.left + "px"), + (i.style.height = o.lineHeight + "px"), + i.scrollIntoView(r)), + (r = t = null)); + } + }); + this.setAutoScrollEditorIntoView = function (e) { + if (e) return; + (delete this.setAutoScrollEditorIntoView, + this.off("changeSelection", s), + this.renderer.off("afterRender", u), + this.renderer.off("beforeRender", o)); + }; + }), + (this.$resetCursorStyle = function () { + var e = this.$cursorStyle || "ace", + t = this.renderer.$cursorLayer; + if (!t) return; + (t.setSmoothBlinking(/smooth/.test(e)), + (t.isBlinking = !this.$readOnly && e != "wide"), + i.setCssClass(t.element, "ace_slim-cursors", /slim/.test(e))); + })); + }).call(b.prototype), + g.defineOptions(b.prototype, "editor", { + selectionStyle: { + set: function (e) { + (this.onSelectionChange(), + this._signal("changeSelectionStyle", { data: e })); + }, + initialValue: "line" }, - initialValue: !0 - }, - highlightSelectedWord: { - set: function(e) { - this.$onSelectionChange(); + highlightActiveLine: { + set: function () { + this.$updateHighlightActiveLine(); + }, + initialValue: !0 }, - initialValue: !0 - }, - readOnly: { - set: function(e) { - this.$resetCursorStyle(); + highlightSelectedWord: { + set: function (e) { + this.$onSelectionChange(); + }, + initialValue: !0 }, - initialValue: !1 - }, - cursorStyle: { - set: function(e) { - this.$resetCursorStyle(); + readOnly: { + set: function (e) { + this.$resetCursorStyle(); + }, + initialValue: !1 }, - values: ["ace", "slim", "smooth", "wide"], - initialValue: "ace" - }, - mergeUndoDeltas: { values: [!1, !0, "always"], initialValue: !0 }, - behavioursEnabled: { initialValue: !0 }, - wrapBehavioursEnabled: { initialValue: !0 }, - autoScrollEditorIntoView: { - set: function(e) { - this.setAutoScrollEditorIntoView(e); - } - }, - keyboardHandler: { - set: function(e) { - this.setKeyboardHandler(e); + cursorStyle: { + set: function (e) { + this.$resetCursorStyle(); + }, + values: ["ace", "slim", "smooth", "wide"], + initialValue: "ace" }, - get: function() { - return this.keybindingId; + mergeUndoDeltas: { values: [!1, !0, "always"], initialValue: !0 }, + behavioursEnabled: { initialValue: !0 }, + wrapBehavioursEnabled: { initialValue: !0 }, + autoScrollEditorIntoView: { + set: function (e) { + this.setAutoScrollEditorIntoView(e); + } }, - handlesSet: !0 - }, - hScrollBarAlwaysVisible: "renderer", - vScrollBarAlwaysVisible: "renderer", - highlightGutterLine: "renderer", - animatedScroll: "renderer", - showInvisibles: "renderer", - showPrintMargin: "renderer", - printMarginColumn: "renderer", - printMargin: "renderer", - fadeFoldWidgets: "renderer", - showFoldWidgets: "renderer", - showLineNumbers: "renderer", - showGutter: "renderer", - displayIndentGuides: "renderer", - fontSize: "renderer", - fontFamily: "renderer", - maxLines: "renderer", - minLines: "renderer", - scrollPastEnd: "renderer", - fixedWidthGutter: "renderer", - theme: "renderer", - scrollSpeed: "$mouseHandler", - dragDelay: "$mouseHandler", - dragEnabled: "$mouseHandler", - focusTimout: "$mouseHandler", - tooltipFollowsMouse: "$mouseHandler", - firstLineNumber: "session", - overwrite: "session", - newLineMode: "session", - useWorker: "session", - useSoftTabs: "session", - tabSize: "session", - wrap: "session", - indentedSoftWrap: "session", - foldStyle: "session", - mode: "session" - }), - (t.Editor = b)); - }), - define("ace/undomanager", ["require", "exports", "module"], function( - e, - t, - n - ) { - "use strict"; - var r = function() { - this.reset(); - }; - (function() { - function e(e) { - return { - action: e.action, - start: e.start, - end: e.end, - lines: e.lines.length == 1 ? null : e.lines, - text: e.lines.length == 1 ? e.lines[0] : null - }; - } - function t(e) { - return { - action: e.action, - start: e.start, - end: e.end, - lines: e.lines || [e.text] - }; - } - function n(e, t) { - var n = new Array(e.length); - for (var r = 0; r < e.length; r++) { - var i = e[r], - s = { group: i.group, deltas: new Array(i.length) }; - for (var o = 0; o < i.deltas.length; o++) { - var u = i.deltas[o]; - s.deltas[o] = t(u); + keyboardHandler: { + set: function (e) { + this.setKeyboardHandler(e); + }, + get: function () { + return this.keybindingId; + }, + handlesSet: !0 + }, + hScrollBarAlwaysVisible: "renderer", + vScrollBarAlwaysVisible: "renderer", + highlightGutterLine: "renderer", + animatedScroll: "renderer", + showInvisibles: "renderer", + showPrintMargin: "renderer", + printMarginColumn: "renderer", + printMargin: "renderer", + fadeFoldWidgets: "renderer", + showFoldWidgets: "renderer", + showLineNumbers: "renderer", + showGutter: "renderer", + displayIndentGuides: "renderer", + fontSize: "renderer", + fontFamily: "renderer", + maxLines: "renderer", + minLines: "renderer", + scrollPastEnd: "renderer", + fixedWidthGutter: "renderer", + theme: "renderer", + scrollSpeed: "$mouseHandler", + dragDelay: "$mouseHandler", + dragEnabled: "$mouseHandler", + focusTimout: "$mouseHandler", + tooltipFollowsMouse: "$mouseHandler", + firstLineNumber: "session", + overwrite: "session", + newLineMode: "session", + useWorker: "session", + useSoftTabs: "session", + tabSize: "session", + wrap: "session", + indentedSoftWrap: "session", + foldStyle: "session", + mode: "session" + }), + (t.Editor = b)); + } + ), + define( + "ace/undomanager", + ["require", "exports", "module"], + function (e, t, n) { + "use strict"; + var r = function () { + this.reset(); + }; + ((function () { + function e(e) { + return { + action: e.action, + start: e.start, + end: e.end, + lines: e.lines.length == 1 ? null : e.lines, + text: e.lines.length == 1 ? e.lines[0] : null + }; + } + function t(e) { + return { + action: e.action, + start: e.start, + end: e.end, + lines: e.lines || [e.text] + }; + } + function n(e, t) { + var n = new Array(e.length); + for (var r = 0; r < e.length; r++) { + var i = e[r], + s = { group: i.group, deltas: new Array(i.length) }; + for (var o = 0; o < i.deltas.length; o++) { + var u = i.deltas[o]; + s.deltas[o] = t(u); + } + n[r] = s; } - n[r] = s; + return n; } - return n; - } - (this.execute = function(e) { - var t = e.args[0]; - (this.$doc = e.args[1]), - e.merge && - this.hasUndo() && - (this.dirtyCounter--, (t = this.$undoStack.pop().concat(t))), - this.$undoStack.push(t), - (this.$redoStack = []), - this.dirtyCounter < 0 && (this.dirtyCounter = NaN), - this.dirtyCounter++; - }), - (this.undo = function(e) { - var t = this.$undoStack.pop(), - n = null; - return ( - t && - ((n = this.$doc.undoChanges(t, e)), - this.$redoStack.push(t), - this.dirtyCounter--), - n - ); - }), - (this.redo = function(e) { - var t = this.$redoStack.pop(), - n = null; - return ( - t && - ((n = this.$doc.redoChanges(this.$deserializeDeltas(t), e)), - this.$undoStack.push(t), - this.dirtyCounter++), - n - ); - }), - (this.reset = function() { - (this.$undoStack = []), + ((this.execute = function (e) { + var t = e.args[0]; + ((this.$doc = e.args[1]), + e.merge && + this.hasUndo() && + (this.dirtyCounter--, (t = this.$undoStack.pop().concat(t))), + this.$undoStack.push(t), (this.$redoStack = []), - (this.dirtyCounter = 0); - }), - (this.hasUndo = function() { - return this.$undoStack.length > 0; - }), - (this.hasRedo = function() { - return this.$redoStack.length > 0; - }), - (this.markClean = function() { - this.dirtyCounter = 0; - }), - (this.isClean = function() { - return this.dirtyCounter === 0; - }), - (this.$serializeDeltas = function(t) { - return n(t, e); - }), - (this.$deserializeDeltas = function(e) { - return n(e, t); - }); - }.call(r.prototype), - (t.UndoManager = r)); - }), - define("ace/layer/gutter", [ - "require", - "exports", - "module", - "ace/lib/dom", - "ace/lib/oop", - "ace/lib/lang", - "ace/lib/event_emitter" - ], function(e, t, n) { - "use strict"; - var r = e("../lib/dom"), - i = e("../lib/oop"), - s = e("../lib/lang"), - o = e("../lib/event_emitter").EventEmitter, - u = function(e) { - (this.element = r.createElement("div")), - (this.element.className = "ace_layer ace_gutter-layer"), - e.appendChild(this.element), - this.setShowFoldWidgets(this.$showFoldWidgets), - (this.gutterWidth = 0), - (this.$annotations = []), - (this.$updateAnnotations = this.$updateAnnotations.bind(this)), - (this.$cells = []); - }; - (function() { - i.implement(this, o), - (this.setSession = function(e) { - this.session && - this.session.removeEventListener("change", this.$updateAnnotations), - (this.session = e), - e && e.on("change", this.$updateAnnotations); + this.dirtyCounter < 0 && (this.dirtyCounter = NaN), + this.dirtyCounter++); }), - (this.addGutterDecoration = function(e, t) { - window.console && - console.warn && - console.warn("deprecated use session.addGutterDecoration"), - this.session.addGutterDecoration(e, t); - }), - (this.removeGutterDecoration = function(e, t) { - window.console && - console.warn && - console.warn("deprecated use session.removeGutterDecoration"), - this.session.removeGutterDecoration(e, t); - }), - (this.setAnnotations = function(e) { - this.$annotations = []; - for (var t = 0; t < e.length; t++) { - var n = e[t], - r = n.row, - i = this.$annotations[r]; - i || (i = this.$annotations[r] = { text: [] }); - var o = n.text; - (o = o ? s.escapeHTML(o) : n.html || ""), - i.text.indexOf(o) === -1 && i.text.push(o); - var u = n.type; - u == "error" - ? (i.className = " ace_error") - : u == "warning" && i.className != " ace_error" - ? (i.className = " ace_warning") - : u == "info" && !i.className && (i.className = " ace_info"); - } - }), - (this.$updateAnnotations = function(e) { - if (!this.$annotations.length) return; - var t = e.start.row, - n = e.end.row - t; - if (n !== 0) - if (e.action == "remove") this.$annotations.splice(t, n + 1, null); - else { - var r = new Array(n + 1); - r.unshift(t, 1), - this.$annotations.splice.apply(this.$annotations, r); + (this.undo = function (e) { + var t = this.$undoStack.pop(), + n = null; + return ( + t && + ((n = this.$doc.undoChanges(t, e)), + this.$redoStack.push(t), + this.dirtyCounter--), + n + ); + }), + (this.redo = function (e) { + var t = this.$redoStack.pop(), + n = null; + return ( + t && + ((n = this.$doc.redoChanges(this.$deserializeDeltas(t), e)), + this.$undoStack.push(t), + this.dirtyCounter++), + n + ); + }), + (this.reset = function () { + ((this.$undoStack = []), + (this.$redoStack = []), + (this.dirtyCounter = 0)); + }), + (this.hasUndo = function () { + return this.$undoStack.length > 0; + }), + (this.hasRedo = function () { + return this.$redoStack.length > 0; + }), + (this.markClean = function () { + this.dirtyCounter = 0; + }), + (this.isClean = function () { + return this.dirtyCounter === 0; + }), + (this.$serializeDeltas = function (t) { + return n(t, e); + }), + (this.$deserializeDeltas = function (e) { + return n(e, t); + })); + }).call(r.prototype), + (t.UndoManager = r)); + } + ), + define( + "ace/layer/gutter", + [ + "require", + "exports", + "module", + "ace/lib/dom", + "ace/lib/oop", + "ace/lib/lang", + "ace/lib/event_emitter" + ], + function (e, t, n) { + "use strict"; + var r = e("../lib/dom"), + i = e("../lib/oop"), + s = e("../lib/lang"), + o = e("../lib/event_emitter").EventEmitter, + u = function (e) { + ((this.element = r.createElement("div")), + (this.element.className = "ace_layer ace_gutter-layer"), + e.appendChild(this.element), + this.setShowFoldWidgets(this.$showFoldWidgets), + (this.gutterWidth = 0), + (this.$annotations = []), + (this.$updateAnnotations = this.$updateAnnotations.bind(this)), + (this.$cells = [])); + }; + ((function () { + (i.implement(this, o), + (this.setSession = function (e) { + (this.session && + this.session.removeEventListener( + "change", + this.$updateAnnotations + ), + (this.session = e), + e && e.on("change", this.$updateAnnotations)); + }), + (this.addGutterDecoration = function (e, t) { + (window.console && + console.warn && + console.warn("deprecated use session.addGutterDecoration"), + this.session.addGutterDecoration(e, t)); + }), + (this.removeGutterDecoration = function (e, t) { + (window.console && + console.warn && + console.warn("deprecated use session.removeGutterDecoration"), + this.session.removeGutterDecoration(e, t)); + }), + (this.setAnnotations = function (e) { + this.$annotations = []; + for (var t = 0; t < e.length; t++) { + var n = e[t], + r = n.row, + i = this.$annotations[r]; + i || (i = this.$annotations[r] = { text: [] }); + var o = n.text; + ((o = o ? s.escapeHTML(o) : n.html || ""), + i.text.indexOf(o) === -1 && i.text.push(o)); + var u = n.type; + u == "error" + ? (i.className = " ace_error") + : u == "warning" && i.className != " ace_error" + ? (i.className = " ace_warning") + : u == "info" && !i.className && (i.className = " ace_info"); } - }), - (this.update = function(e) { - var t = this.session, - n = e.firstRow, - i = Math.min(e.lastRow + e.gutterOffset, t.getLength() - 1), - s = t.getNextFoldLine(n), - o = s ? s.start.row : Infinity, - u = this.$showFoldWidgets && t.foldWidgets, - a = t.$breakpoints, - f = t.$decorations, - l = t.$firstLineNumber, - c = 0, - h = t.gutterRenderer || this.$renderer, - p = null, - d = -1, - v = n; - for (;;) { - v > o && - ((v = s.end.row + 1), - (s = t.getNextFoldLine(v, s)), - (o = s ? s.start.row : Infinity)); - if (v > i) { - while (this.$cells.length > d + 1) - (p = this.$cells.pop()), this.element.removeChild(p.element); - break; - } - (p = this.$cells[++d]), - p || - ((p = { element: null, textNode: null, foldWidget: null }), - (p.element = r.createElement("div")), - (p.textNode = document.createTextNode("")), - p.element.appendChild(p.textNode), - this.element.appendChild(p.element), - (this.$cells[d] = p)); - var m = "ace_gutter-cell "; - a[v] && (m += a[v]), - f[v] && (m += f[v]), - this.$annotations[v] && (m += this.$annotations[v].className), - p.element.className != m && (p.element.className = m); - var g = t.getRowLength(v) * e.lineHeight + "px"; - g != p.element.style.height && (p.element.style.height = g); - if (u) { - var y = u[v]; - y == null && (y = u[v] = t.getFoldWidget(v)); - } - if (y) { - p.foldWidget || - ((p.foldWidget = r.createElement("span")), - p.element.appendChild(p.foldWidget)); - var m = "ace_fold-widget ace_" + y; - y == "start" && v == o && v < s.end.row - ? (m += " ace_closed") - : (m += " ace_open"), - p.foldWidget.className != m && (p.foldWidget.className = m); - var g = e.lineHeight + "px"; - p.foldWidget.style.height != g && (p.foldWidget.style.height = g); - } else - p.foldWidget && - (p.element.removeChild(p.foldWidget), (p.foldWidget = null)); - var b = (c = h ? h.getText(t, v) : v + l); - b != p.textNode.data && (p.textNode.data = b), v++; - } - this.element.style.height = e.minHeight + "px"; - if (this.$fixedWidth || t.$useWrapMode) c = t.getLength() + l; - var w = h - ? h.getWidth(t, c, e) - : c.toString().length * e.characterWidth, - E = this.$padding || this.$computePadding(); - (w += E.left + E.right), - w !== this.gutterWidth && - !isNaN(w) && - ((this.gutterWidth = w), - (this.element.style.width = Math.ceil(this.gutterWidth) + "px"), - this._emit("changeGutterWidth", w)); - }), - (this.$fixedWidth = !1), - (this.$showLineNumbers = !0), - (this.$renderer = ""), - (this.setShowLineNumbers = function(e) { - this.$renderer = !e && { - getWidth: function() { - return ""; - }, - getText: function() { - return ""; + }), + (this.$updateAnnotations = function (e) { + if (!this.$annotations.length) return; + var t = e.start.row, + n = e.end.row - t; + if (n !== 0) + if (e.action == "remove") + this.$annotations.splice(t, n + 1, null); + else { + var r = new Array(n + 1); + (r.unshift(t, 1), + this.$annotations.splice.apply(this.$annotations, r)); + } + }), + (this.update = function (e) { + var t = this.session, + n = e.firstRow, + i = Math.min(e.lastRow + e.gutterOffset, t.getLength() - 1), + s = t.getNextFoldLine(n), + o = s ? s.start.row : Infinity, + u = this.$showFoldWidgets && t.foldWidgets, + a = t.$breakpoints, + f = t.$decorations, + l = t.$firstLineNumber, + c = 0, + h = t.gutterRenderer || this.$renderer, + p = null, + d = -1, + v = n; + for (;;) { + v > o && + ((v = s.end.row + 1), + (s = t.getNextFoldLine(v, s)), + (o = s ? s.start.row : Infinity)); + if (v > i) { + while (this.$cells.length > d + 1) + ((p = this.$cells.pop()), + this.element.removeChild(p.element)); + break; + } + ((p = this.$cells[++d]), + p || + ((p = { element: null, textNode: null, foldWidget: null }), + (p.element = r.createElement("div")), + (p.textNode = document.createTextNode("")), + p.element.appendChild(p.textNode), + this.element.appendChild(p.element), + (this.$cells[d] = p))); + var m = "ace_gutter-cell "; + (a[v] && (m += a[v]), + f[v] && (m += f[v]), + this.$annotations[v] && (m += this.$annotations[v].className), + p.element.className != m && (p.element.className = m)); + var g = t.getRowLength(v) * e.lineHeight + "px"; + g != p.element.style.height && (p.element.style.height = g); + if (u) { + var y = u[v]; + y == null && (y = u[v] = t.getFoldWidget(v)); + } + if (y) { + p.foldWidget || + ((p.foldWidget = r.createElement("span")), + p.element.appendChild(p.foldWidget)); + var m = "ace_fold-widget ace_" + y; + (y == "start" && v == o && v < s.end.row + ? (m += " ace_closed") + : (m += " ace_open"), + p.foldWidget.className != m && (p.foldWidget.className = m)); + var g = e.lineHeight + "px"; + p.foldWidget.style.height != g && + (p.foldWidget.style.height = g); + } else + p.foldWidget && + (p.element.removeChild(p.foldWidget), (p.foldWidget = null)); + var b = (c = h ? h.getText(t, v) : v + l); + (b != p.textNode.data && (p.textNode.data = b), v++); } - }; - }), - (this.getShowLineNumbers = function() { - return this.$showLineNumbers; - }), - (this.$showFoldWidgets = !0), - (this.setShowFoldWidgets = function(e) { - e - ? r.addCssClass(this.element, "ace_folding-enabled") - : r.removeCssClass(this.element, "ace_folding-enabled"), - (this.$showFoldWidgets = e), - (this.$padding = null); - }), - (this.getShowFoldWidgets = function() { - return this.$showFoldWidgets; - }), - (this.$computePadding = function() { - if (!this.element.firstChild) return { left: 0, right: 0 }; - var e = r.computedStyle(this.element.firstChild); - return ( - (this.$padding = {}), - (this.$padding.left = parseInt(e.paddingLeft) + 1 || 0), - (this.$padding.right = parseInt(e.paddingRight) || 0), - this.$padding - ); - }), - (this.getRegion = function(e) { - var t = this.$padding || this.$computePadding(), - n = this.element.getBoundingClientRect(); - if (e.x < t.left + n.left) return "markers"; - if (this.$showFoldWidgets && e.x > n.right - t.right) - return "foldWidgets"; - }); - }.call(u.prototype), - (t.Gutter = u)); - }), - define("ace/layer/marker", [ - "require", - "exports", - "module", - "ace/range", - "ace/lib/dom" - ], function(e, t, n) { - "use strict"; - var r = e("../range").Range, - i = e("../lib/dom"), - s = function(e) { - (this.element = i.createElement("div")), - (this.element.className = "ace_layer ace_marker-layer"), - e.appendChild(this.element); - }; - (function() { - function e(e, t, n, r) { - return (e ? 1 : 0) | (t ? 2 : 0) | (n ? 4 : 0) | (r ? 8 : 0); - } - (this.$padding = 0), - (this.setPadding = function(e) { - this.$padding = e; - }), - (this.setSession = function(e) { - this.session = e; - }), - (this.setMarkers = function(e) { - this.markers = e; - }), - (this.update = function(e) { - var e = e || this.config; - if (!e) return; - this.config = e; - var t = []; - for (var n in this.markers) { - var r = this.markers[n]; - if (!r.range) { - r.update(t, this, this.session, e); - continue; + this.element.style.height = e.minHeight + "px"; + if (this.$fixedWidth || t.$useWrapMode) c = t.getLength() + l; + var w = h + ? h.getWidth(t, c, e) + : c.toString().length * e.characterWidth, + E = this.$padding || this.$computePadding(); + ((w += E.left + E.right), + w !== this.gutterWidth && + !isNaN(w) && + ((this.gutterWidth = w), + (this.element.style.width = Math.ceil(this.gutterWidth) + "px"), + this._emit("changeGutterWidth", w))); + }), + (this.$fixedWidth = !1), + (this.$showLineNumbers = !0), + (this.$renderer = ""), + (this.setShowLineNumbers = function (e) { + this.$renderer = !e && { + getWidth: function () { + return ""; + }, + getText: function () { + return ""; + } + }; + }), + (this.getShowLineNumbers = function () { + return this.$showLineNumbers; + }), + (this.$showFoldWidgets = !0), + (this.setShowFoldWidgets = function (e) { + (e + ? r.addCssClass(this.element, "ace_folding-enabled") + : r.removeCssClass(this.element, "ace_folding-enabled"), + (this.$showFoldWidgets = e), + (this.$padding = null)); + }), + (this.getShowFoldWidgets = function () { + return this.$showFoldWidgets; + }), + (this.$computePadding = function () { + if (!this.element.firstChild) return { left: 0, right: 0 }; + var e = r.computedStyle(this.element.firstChild); + return ( + (this.$padding = {}), + (this.$padding.left = parseInt(e.paddingLeft) + 1 || 0), + (this.$padding.right = parseInt(e.paddingRight) || 0), + this.$padding + ); + }), + (this.getRegion = function (e) { + var t = this.$padding || this.$computePadding(), + n = this.element.getBoundingClientRect(); + if (e.x < t.left + n.left) return "markers"; + if (this.$showFoldWidgets && e.x > n.right - t.right) + return "foldWidgets"; + })); + }).call(u.prototype), + (t.Gutter = u)); + } + ), + define( + "ace/layer/marker", + ["require", "exports", "module", "ace/range", "ace/lib/dom"], + function (e, t, n) { + "use strict"; + var r = e("../range").Range, + i = e("../lib/dom"), + s = function (e) { + ((this.element = i.createElement("div")), + (this.element.className = "ace_layer ace_marker-layer"), + e.appendChild(this.element)); + }; + ((function () { + function e(e, t, n, r) { + return (e ? 1 : 0) | (t ? 2 : 0) | (n ? 4 : 0) | (r ? 8 : 0); + } + ((this.$padding = 0), + (this.setPadding = function (e) { + this.$padding = e; + }), + (this.setSession = function (e) { + this.session = e; + }), + (this.setMarkers = function (e) { + this.markers = e; + }), + (this.update = function (e) { + var e = e || this.config; + if (!e) return; + this.config = e; + var t = []; + for (var n in this.markers) { + var r = this.markers[n]; + if (!r.range) { + r.update(t, this, this.session, e); + continue; + } + var i = r.range.clipRows(e.firstRow, e.lastRow); + if (i.isEmpty()) continue; + i = i.toScreenRange(this.session); + if (r.renderer) { + var s = this.$getTop(i.start.row, e), + o = this.$padding + i.start.column * e.characterWidth; + r.renderer(t, i, o, s, e); + } else + r.type == "fullLine" + ? this.drawFullLineMarker(t, i, r.clazz, e) + : r.type == "screenLine" + ? this.drawScreenLineMarker(t, i, r.clazz, e) + : i.isMultiLine() + ? r.type == "text" + ? this.drawTextMarker(t, i, r.clazz, e) + : this.drawMultiLineMarker(t, i, r.clazz, e) + : this.drawSingleLineMarker( + t, + i, + r.clazz + " ace_start" + " ace_br15", + e + ); } - var i = r.range.clipRows(e.firstRow, e.lastRow); - if (i.isEmpty()) continue; - i = i.toScreenRange(this.session); - if (r.renderer) { - var s = this.$getTop(i.start.row, e), - o = this.$padding + i.start.column * e.characterWidth; - r.renderer(t, i, o, s, e); - } else - r.type == "fullLine" - ? this.drawFullLineMarker(t, i, r.clazz, e) - : r.type == "screenLine" - ? this.drawScreenLineMarker(t, i, r.clazz, e) - : i.isMultiLine() - ? r.type == "text" - ? this.drawTextMarker(t, i, r.clazz, e) - : this.drawMultiLineMarker(t, i, r.clazz, e) - : this.drawSingleLineMarker( - t, - i, - r.clazz + " ace_start" + " ace_br15", - e - ); - } - this.element.innerHTML = t.join(""); - }), - (this.$getTop = function(e, t) { - return (e - t.firstRowScreen) * t.lineHeight; - }), - (this.drawTextMarker = function(t, n, i, s, o) { - var u = this.session, - a = n.start.row, - f = n.end.row, - l = a, - c = 0, - h = 0, - p = u.getScreenLastRowColumn(l), - d = new r(l, n.start.column, l, h); - for (; l <= f; l++) - (d.start.row = d.end.row = l), - (d.start.column = - l == a ? n.start.column : u.getRowWrapIndent(l)), - (d.end.column = p), - (c = h), - (h = p), - (p = - l + 1 < f - ? u.getScreenLastRowColumn(l + 1) - : l == f - ? 0 - : n.end.column), - this.drawSingleLineMarker( - t, - d, - i + - (l == a ? " ace_start" : "") + - " ace_br" + - e( - l == a || (l == a + 1 && n.start.column), - c < h, - h > p, - l == f - ), - s, - l == f ? 0 : 1, - o - ); - }), - (this.drawMultiLineMarker = function(e, t, n, r, i) { - var s = this.$padding, - o = r.lineHeight, - u = this.$getTop(t.start.row, r), - a = s + t.start.column * r.characterWidth; - (i = i || ""), + this.element.innerHTML = t.join(""); + }), + (this.$getTop = function (e, t) { + return (e - t.firstRowScreen) * t.lineHeight; + }), + (this.drawTextMarker = function (t, n, i, s, o) { + var u = this.session, + a = n.start.row, + f = n.end.row, + l = a, + c = 0, + h = 0, + p = u.getScreenLastRowColumn(l), + d = new r(l, n.start.column, l, h); + for (; l <= f; l++) + ((d.start.row = d.end.row = l), + (d.start.column = + l == a ? n.start.column : u.getRowWrapIndent(l)), + (d.end.column = p), + (c = h), + (h = p), + (p = + l + 1 < f + ? u.getScreenLastRowColumn(l + 1) + : l == f + ? 0 + : n.end.column), + this.drawSingleLineMarker( + t, + d, + i + + (l == a ? " ace_start" : "") + + " ace_br" + + e( + l == a || (l == a + 1 && n.start.column), + c < h, + h > p, + l == f + ), + s, + l == f ? 0 : 1, + o + )); + }), + (this.drawMultiLineMarker = function (e, t, n, r, i) { + var s = this.$padding, + o = r.lineHeight, + u = this.$getTop(t.start.row, r), + a = s + t.start.column * r.characterWidth; + ((i = i || ""), + e.push( + "
" + ), + (u = this.$getTop(t.end.row, r))); + var f = t.end.column * r.characterWidth; + (e.push( + "
" + ), + (o = (t.end.row - t.start.row - 1) * r.lineHeight)); + if (o <= 0) return; + u = this.$getTop(t.start.row + 1, r); + var l = (t.start.column ? 1 : 0) | (t.end.column ? 0 : 8); + e.push( + "
" + ); + }), + (this.drawSingleLineMarker = function (e, t, n, r, i, s) { + var o = r.lineHeight, + u = (t.end.column + (i || 0) - t.start.column) * r.characterWidth, + a = this.$getTop(t.start.row, r), + f = this.$padding + t.start.column * r.characterWidth; e.push( "
" - ), - (u = this.$getTop(t.end.row, r)); - var f = t.end.column * r.characterWidth; - e.push( - "
" - ), - (o = (t.end.row - t.start.row - 1) * r.lineHeight); - if (o <= 0) return; - u = this.$getTop(t.start.row + 1, r); - var l = (t.start.column ? 1 : 0) | (t.end.column ? 0 : 8); - e.push( - "
" - ); - }), - (this.drawSingleLineMarker = function(e, t, n, r, i, s) { - var o = r.lineHeight, - u = (t.end.column + (i || 0) - t.start.column) * r.characterWidth, - a = this.$getTop(t.start.row, r), - f = this.$padding + t.start.column * r.characterWidth; - e.push( - "
" - ); - }), - (this.drawFullLineMarker = function(e, t, n, r, i) { - var s = this.$getTop(t.start.row, r), - o = r.lineHeight; - t.start.row != t.end.row && (o += this.$getTop(t.end.row, r) - s), + ); + }), + (this.drawFullLineMarker = function (e, t, n, r, i) { + var s = this.$getTop(t.start.row, r), + o = r.lineHeight; + (t.start.row != t.end.row && (o += this.$getTop(t.end.row, r) - s), + e.push( + "
" + )); + }), + (this.drawScreenLineMarker = function (e, t, n, r, i) { + var s = this.$getTop(t.start.row, r), + o = r.lineHeight; e.push( "
" ); - }), - (this.drawScreenLineMarker = function(e, t, n, r, i) { - var s = this.$getTop(t.start.row, r), - o = r.lineHeight; - e.push( - "
" - ); - }); - }.call(s.prototype), - (t.Marker = s)); - }), - define("ace/layer/text", [ - "require", - "exports", - "module", - "ace/lib/oop", - "ace/lib/dom", - "ace/lib/lang", - "ace/lib/useragent", - "ace/lib/event_emitter" - ], function(e, t, n) { - "use strict"; - var r = e("../lib/oop"), - i = e("../lib/dom"), - s = e("../lib/lang"), - o = e("../lib/useragent"), - u = e("../lib/event_emitter").EventEmitter, - a = function(e) { - (this.element = i.createElement("div")), - (this.element.className = "ace_layer ace_text-layer"), - e.appendChild(this.element), - (this.$updateEolChar = this.$updateEolChar.bind(this)); - }; - (function() { - r.implement(this, u), - (this.EOF_CHAR = "\u00b6"), - (this.EOL_CHAR_LF = "\u00ac"), - (this.EOL_CHAR_CRLF = "\u00a4"), - (this.EOL_CHAR = this.EOL_CHAR_LF), - (this.TAB_CHAR = "\u2014"), - (this.SPACE_CHAR = "\u00b7"), - (this.$padding = 0), - (this.$updateEolChar = function() { - var e = - this.session.doc.getNewLineCharacter() == "\n" - ? this.EOL_CHAR_LF - : this.EOL_CHAR_CRLF; - if (this.EOL_CHAR != e) return (this.EOL_CHAR = e), !0; - }), - (this.setPadding = function(e) { - (this.$padding = e), (this.element.style.padding = "0 " + e + "px"); - }), - (this.getLineHeight = function() { - return this.$fontMetrics.$characterSize.height || 0; - }), - (this.getCharacterWidth = function() { - return this.$fontMetrics.$characterSize.width || 0; - }), - (this.$setFontMetrics = function(e) { - (this.$fontMetrics = e), - this.$fontMetrics.on( - "changeCharacterSize", - function(e) { - this._signal("changeCharacterSize", e); - }.bind(this) - ), - this.$pollSizeChanges(); - }), - (this.checkForSizeChanges = function() { - this.$fontMetrics.checkForSizeChanges(); - }), - (this.$pollSizeChanges = function() { - return (this.$pollSizeChangesTimer = this.$fontMetrics.$pollSizeChanges()); - }), - (this.setSession = function(e) { - (this.session = e), e && this.$computeTabString(); - }), - (this.showInvisibles = !1), - (this.setShowInvisibles = function(e) { - return this.showInvisibles == e - ? !1 - : ((this.showInvisibles = e), this.$computeTabString(), !0); - }), - (this.displayIndentGuides = !0), - (this.setDisplayIndentGuides = function(e) { - return this.displayIndentGuides == e - ? !1 - : ((this.displayIndentGuides = e), this.$computeTabString(), !0); - }), - (this.$tabStrings = []), - (this.onChangeTabSize = this.$computeTabString = function() { - var e = this.session.getTabSize(); - this.tabSize = e; - var t = (this.$tabStrings = [0]); - for (var n = 1; n < e + 1; n++) - this.showInvisibles - ? t.push( - "" + - s.stringRepeat(this.TAB_CHAR, n) + - "" - ) - : t.push(s.stringRepeat(" ", n)); - if (this.displayIndentGuides) { - this.$indentGuideRe = /\s\S| \t|\t |\s$/; - var r = "ace_indent-guide", - i = "", - o = ""; - if (this.showInvisibles) { - (r += " ace_invisible"), - (i = " ace_invisible_space"), - (o = " ace_invisible_tab"); - var u = s.stringRepeat(this.SPACE_CHAR, this.tabSize), - a = s.stringRepeat(this.TAB_CHAR, this.tabSize); - } else - var u = s.stringRepeat(" ", this.tabSize), - a = u; - (this.$tabStrings[" "] = - "" + u + ""), - (this.$tabStrings[" "] = - "" + a + ""); - } - }), - (this.updateLines = function(e, t, n) { - (this.config.lastRow != e.lastRow || - this.config.firstRow != e.firstRow) && - this.scrollLines(e), - (this.config = e); - var r = Math.max(t, e.firstRow), - i = Math.min(n, e.lastRow), - s = this.element.childNodes, - o = 0; - for (var u = e.firstRow; u < r; u++) { - var a = this.session.getFoldLine(u); - if (a) { - if (a.containsRow(r)) { - r = a.start.row; - break; + })); + }).call(s.prototype), + (t.Marker = s)); + } + ), + define( + "ace/layer/text", + [ + "require", + "exports", + "module", + "ace/lib/oop", + "ace/lib/dom", + "ace/lib/lang", + "ace/lib/useragent", + "ace/lib/event_emitter" + ], + function (e, t, n) { + "use strict"; + var r = e("../lib/oop"), + i = e("../lib/dom"), + s = e("../lib/lang"), + o = e("../lib/useragent"), + u = e("../lib/event_emitter").EventEmitter, + a = function (e) { + ((this.element = i.createElement("div")), + (this.element.className = "ace_layer ace_text-layer"), + e.appendChild(this.element), + (this.$updateEolChar = this.$updateEolChar.bind(this))); + }; + ((function () { + (r.implement(this, u), + (this.EOF_CHAR = "\u00b6"), + (this.EOL_CHAR_LF = "\u00ac"), + (this.EOL_CHAR_CRLF = "\u00a4"), + (this.EOL_CHAR = this.EOL_CHAR_LF), + (this.TAB_CHAR = "\u2014"), + (this.SPACE_CHAR = "\u00b7"), + (this.$padding = 0), + (this.$updateEolChar = function () { + var e = + this.session.doc.getNewLineCharacter() == "\n" + ? this.EOL_CHAR_LF + : this.EOL_CHAR_CRLF; + if (this.EOL_CHAR != e) return ((this.EOL_CHAR = e), !0); + }), + (this.setPadding = function (e) { + ((this.$padding = e), + (this.element.style.padding = "0 " + e + "px")); + }), + (this.getLineHeight = function () { + return this.$fontMetrics.$characterSize.height || 0; + }), + (this.getCharacterWidth = function () { + return this.$fontMetrics.$characterSize.width || 0; + }), + (this.$setFontMetrics = function (e) { + ((this.$fontMetrics = e), + this.$fontMetrics.on( + "changeCharacterSize", + function (e) { + this._signal("changeCharacterSize", e); + }.bind(this) + ), + this.$pollSizeChanges()); + }), + (this.checkForSizeChanges = function () { + this.$fontMetrics.checkForSizeChanges(); + }), + (this.$pollSizeChanges = function () { + return (this.$pollSizeChangesTimer = + this.$fontMetrics.$pollSizeChanges()); + }), + (this.setSession = function (e) { + ((this.session = e), e && this.$computeTabString()); + }), + (this.showInvisibles = !1), + (this.setShowInvisibles = function (e) { + return this.showInvisibles == e + ? !1 + : ((this.showInvisibles = e), this.$computeTabString(), !0); + }), + (this.displayIndentGuides = !0), + (this.setDisplayIndentGuides = function (e) { + return this.displayIndentGuides == e + ? !1 + : ((this.displayIndentGuides = e), this.$computeTabString(), !0); + }), + (this.$tabStrings = []), + (this.onChangeTabSize = this.$computeTabString = + function () { + var e = this.session.getTabSize(); + this.tabSize = e; + var t = (this.$tabStrings = [0]); + for (var n = 1; n < e + 1; n++) + this.showInvisibles + ? t.push( + "" + + s.stringRepeat(this.TAB_CHAR, n) + + "" + ) + : t.push(s.stringRepeat(" ", n)); + if (this.displayIndentGuides) { + this.$indentGuideRe = /\s\S| \t|\t |\s$/; + var r = "ace_indent-guide", + i = "", + o = ""; + if (this.showInvisibles) { + ((r += " ace_invisible"), + (i = " ace_invisible_space"), + (o = " ace_invisible_tab")); + var u = s.stringRepeat(this.SPACE_CHAR, this.tabSize), + a = s.stringRepeat(this.TAB_CHAR, this.tabSize); + } else + var u = s.stringRepeat(" ", this.tabSize), + a = u; + ((this.$tabStrings[" "] = + "" + u + ""), + (this.$tabStrings[" "] = + "" + a + "")); + } + }), + (this.updateLines = function (e, t, n) { + ((this.config.lastRow != e.lastRow || + this.config.firstRow != e.firstRow) && + this.scrollLines(e), + (this.config = e)); + var r = Math.max(t, e.firstRow), + i = Math.min(n, e.lastRow), + s = this.element.childNodes, + o = 0; + for (var u = e.firstRow; u < r; u++) { + var a = this.session.getFoldLine(u); + if (a) { + if (a.containsRow(r)) { + r = a.start.row; + break; + } + u = a.end.row; } - u = a.end.row; + o++; } - o++; - } - var u = r, - a = this.session.getNextFoldLine(u), - f = a ? a.start.row : Infinity; - for (;;) { - u > f && - ((u = a.end.row + 1), - (a = this.session.getNextFoldLine(u, a)), - (f = a ? a.start.row : Infinity)); - if (u > i) break; - var l = s[o++]; - if (l) { - var c = []; - this.$renderLine(c, u, !this.$useLineGroups(), u == f ? a : !1), - (l.style.height = - e.lineHeight * this.session.getRowLength(u) + "px"), - (l.innerHTML = c.join("")); - } - u++; - } - }), - (this.scrollLines = function(e) { - var t = this.config; - this.config = e; - if (!t || t.lastRow < e.firstRow) return this.update(e); - if (e.lastRow < t.firstRow) return this.update(e); - var n = this.element; - if (t.firstRow < e.firstRow) - for ( - var r = this.session.getFoldedRowCount( - t.firstRow, - e.firstRow - 1 - ); - r > 0; - r-- - ) - n.removeChild(n.firstChild); - if (t.lastRow > e.lastRow) - for ( - var r = this.session.getFoldedRowCount(e.lastRow + 1, t.lastRow); - r > 0; - r-- - ) - n.removeChild(n.lastChild); - if (e.firstRow < t.firstRow) { - var i = this.$renderLinesFragment(e, e.firstRow, t.firstRow - 1); - n.firstChild ? n.insertBefore(i, n.firstChild) : n.appendChild(i); - } - if (e.lastRow > t.lastRow) { - var i = this.$renderLinesFragment(e, t.lastRow + 1, e.lastRow); - n.appendChild(i); - } - }), - (this.$renderLinesFragment = function(e, t, n) { - var r = this.element.ownerDocument.createDocumentFragment(), - s = t, - o = this.session.getNextFoldLine(s), - u = o ? o.start.row : Infinity; - for (;;) { - s > u && - ((s = o.end.row + 1), - (o = this.session.getNextFoldLine(s, o)), - (u = o ? o.start.row : Infinity)); - if (s > n) break; - var a = i.createElement("div"), - f = []; - this.$renderLine(f, s, !1, s == u ? o : !1), - (a.innerHTML = f.join("")); - if (this.$useLineGroups()) - (a.className = "ace_line_group"), - r.appendChild(a), - (a.style.height = - e.lineHeight * this.session.getRowLength(s) + "px"); - else while (a.firstChild) r.appendChild(a.firstChild); - s++; - } - return r; - }), - (this.update = function(e) { - this.config = e; - var t = [], - n = e.firstRow, - r = e.lastRow, - i = n, - s = this.session.getNextFoldLine(i), - o = s ? s.start.row : Infinity; - for (;;) { - i > o && - ((i = s.end.row + 1), - (s = this.session.getNextFoldLine(i, s)), - (o = s ? s.start.row : Infinity)); - if (i > r) break; - this.$useLineGroups() && - t.push( - "
" - ), - this.$renderLine(t, i, !1, i == o ? s : !1), - this.$useLineGroups() && t.push("
"), - i++; - } - this.element.innerHTML = t.join(""); - }), - (this.$textToken = { text: !0, rparen: !0, lparen: !0 }), - (this.$renderToken = function(e, t, n, r) { - var i = this, - o = /\t|&|<|>|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF\uFFF9-\uFFFC])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g, - u = function(e, n, r, o, u) { - if (n) - return i.showInvisibles - ? "" + - s.stringRepeat(i.SPACE_CHAR, e.length) + - "" - : e; - if (e == "&") return "&"; - if (e == "<") return "<"; - if (e == ">") return ">"; - if (e == " ") { - var a = i.session.getScreenTabSize(t + o); - return (t += a - 1), i.$tabStrings[a]; + var u = r, + a = this.session.getNextFoldLine(u), + f = a ? a.start.row : Infinity; + for (;;) { + u > f && + ((u = a.end.row + 1), + (a = this.session.getNextFoldLine(u, a)), + (f = a ? a.start.row : Infinity)); + if (u > i) break; + var l = s[o++]; + if (l) { + var c = []; + (this.$renderLine( + c, + u, + !this.$useLineGroups(), + u == f ? a : !1 + ), + (l.style.height = + e.lineHeight * this.session.getRowLength(u) + "px"), + (l.innerHTML = c.join(""))); } - if (e == "\u3000") { - var f = i.showInvisibles - ? "ace_cjk ace_invisible ace_invisible_space" - : "ace_cjk", - l = i.showInvisibles ? i.SPACE_CHAR : ""; - return ( - (t += 1), - "" + - l + - "" + u++; + } + }), + (this.scrollLines = function (e) { + var t = this.config; + this.config = e; + if (!t || t.lastRow < e.firstRow) return this.update(e); + if (e.lastRow < t.firstRow) return this.update(e); + var n = this.element; + if (t.firstRow < e.firstRow) + for ( + var r = this.session.getFoldedRowCount( + t.firstRow, + e.firstRow - 1 ); - } - return r - ? "" + - i.SPACE_CHAR + - "" - : ((t += 1), - "" + - e + - ""); - }, - a = r.replace(o, u); - if (!this.$textToken[n.type]) { - var f = "ace_" + n.type.replace(/\./g, " ace_"), - l = ""; - n.type == "fold" && - (l = - " style='width:" + - n.value.length * this.config.characterWidth + - "px;' "), - e.push("", a, ""); - } else e.push(a); - return t + r.length; - }), - (this.renderIndentGuide = function(e, t, n) { - var r = t.search(this.$indentGuideRe); - return r <= 0 || r >= n - ? t - : t[0] == " " - ? ((r -= r % this.tabSize), - e.push(s.stringRepeat(this.$tabStrings[" "], r / this.tabSize)), - t.substr(r)) - : t[0] == " " - ? (e.push(s.stringRepeat(this.$tabStrings[" "], r)), t.substr(r)) - : t; - }), - (this.$renderWrappedLine = function(e, t, n, r) { - var i = 0, - o = 0, - u = n[0], - a = 0; - for (var f = 0; f < t.length; f++) { - var l = t[f], - c = l.value; - if (f == 0 && this.displayIndentGuides) { - (i = c.length), (c = this.renderIndentGuide(e, c, u)); - if (!c) continue; - i -= c.length; - } - if (i + c.length < u) - (a = this.$renderToken(e, a, l, c)), (i += c.length); - else { - while (i + c.length >= u) - (a = this.$renderToken(e, a, l, c.substring(0, u - i))), - (c = c.substring(u - i)), - (i = u), - r || - e.push( - "", - "
" - ), - e.push(s.stringRepeat("\u00a0", n.indent)), - o++, - (a = 0), - (u = n[o] || Number.MAX_VALUE); - c.length != 0 && - ((i += c.length), (a = this.$renderToken(e, a, l, c))); + r > 0; + r-- + ) + n.removeChild(n.firstChild); + if (t.lastRow > e.lastRow) + for ( + var r = this.session.getFoldedRowCount( + e.lastRow + 1, + t.lastRow + ); + r > 0; + r-- + ) + n.removeChild(n.lastChild); + if (e.firstRow < t.firstRow) { + var i = this.$renderLinesFragment(e, e.firstRow, t.firstRow - 1); + n.firstChild ? n.insertBefore(i, n.firstChild) : n.appendChild(i); } - } - }), - (this.$renderSimpleLine = function(e, t) { - var n = 0, - r = t[0], - i = r.value; - this.displayIndentGuides && (i = this.renderIndentGuide(e, i)), - i && (n = this.$renderToken(e, n, r, i)); - for (var s = 1; s < t.length; s++) - (r = t[s]), (i = r.value), (n = this.$renderToken(e, n, r, i)); - }), - (this.$renderLine = function(e, t, n, r) { - !r && r != 0 && (r = this.session.getFoldLine(t)); - if (r) var i = this.$getFoldLineTokens(t, r); - else var i = this.session.getTokens(t); - n || - e.push( - "
" - ); - if (i.length) { - var s = this.session.getRowSplitData(t); - s && s.length - ? this.$renderWrappedLine(e, i, s, n) - : this.$renderSimpleLine(e, i); - } - this.showInvisibles && - (r && (t = r.end.row), - e.push( - "", - t == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR, - "" - )), - n || e.push("
"); - }), - (this.$getFoldLineTokens = function(e, t) { - function i(e, t, n) { - var i = 0, - s = 0; - while (s + e[i].value.length < t) { - (s += e[i].value.length), i++; - if (i == e.length) return; - } - if (s != t) { - var o = e[i].value.substring(t - s); - o.length > n - t && (o = o.substring(0, n - t)), - r.push({ type: e[i].type, value: o }), - (s = t + o.length), - (i += 1); - } - while (s < n && i < e.length) { - var o = e[i].value; - o.length + s > n - ? r.push({ type: e[i].type, value: o.substring(0, n - s) }) - : r.push(e[i]), - (s += o.length), - (i += 1); + if (e.lastRow > t.lastRow) { + var i = this.$renderLinesFragment(e, t.lastRow + 1, e.lastRow); + n.appendChild(i); } - } - var n = this.session, - r = [], - s = n.getTokens(e); - return ( - t.walk( - function(e, t, o, u, a) { - e != null - ? r.push({ type: "fold", value: e }) - : (a && (s = n.getTokens(t)), s.length && i(s, u, o)); + }), + (this.$renderLinesFragment = function (e, t, n) { + var r = this.element.ownerDocument.createDocumentFragment(), + s = t, + o = this.session.getNextFoldLine(s), + u = o ? o.start.row : Infinity; + for (;;) { + s > u && + ((s = o.end.row + 1), + (o = this.session.getNextFoldLine(s, o)), + (u = o ? o.start.row : Infinity)); + if (s > n) break; + var a = i.createElement("div"), + f = []; + (this.$renderLine(f, s, !1, s == u ? o : !1), + (a.innerHTML = f.join(""))); + if (this.$useLineGroups()) + ((a.className = "ace_line_group"), + r.appendChild(a), + (a.style.height = + e.lineHeight * this.session.getRowLength(s) + "px")); + else while (a.firstChild) r.appendChild(a.firstChild); + s++; + } + return r; + }), + (this.update = function (e) { + this.config = e; + var t = [], + n = e.firstRow, + r = e.lastRow, + i = n, + s = this.session.getNextFoldLine(i), + o = s ? s.start.row : Infinity; + for (;;) { + i > o && + ((i = s.end.row + 1), + (s = this.session.getNextFoldLine(i, s)), + (o = s ? s.start.row : Infinity)); + if (i > r) break; + (this.$useLineGroups() && + t.push( + "
" + ), + this.$renderLine(t, i, !1, i == o ? s : !1), + this.$useLineGroups() && t.push("
"), + i++); + } + this.element.innerHTML = t.join(""); + }), + (this.$textToken = { text: !0, rparen: !0, lparen: !0 }), + (this.$renderToken = function (e, t, n, r) { + var i = this, + o = + /\t|&|<|>|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF\uFFF9-\uFFFC])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g, + u = function (e, n, r, o, u) { + if (n) + return i.showInvisibles + ? "" + + s.stringRepeat(i.SPACE_CHAR, e.length) + + "" + : e; + if (e == "&") return "&"; + if (e == "<") return "<"; + if (e == ">") return ">"; + if (e == " ") { + var a = i.session.getScreenTabSize(t + o); + return ((t += a - 1), i.$tabStrings[a]); + } + if (e == "\u3000") { + var f = i.showInvisibles + ? "ace_cjk ace_invisible ace_invisible_space" + : "ace_cjk", + l = i.showInvisibles ? i.SPACE_CHAR : ""; + return ( + (t += 1), + "" + + l + + "" + ); + } + return r + ? "" + + i.SPACE_CHAR + + "" + : ((t += 1), + "" + + e + + ""); }, - t.end.row, - this.session.getLine(t.end.row).length - ), - r - ); - }), - (this.$useLineGroups = function() { - return this.session.getUseWrapMode(); - }), - (this.destroy = function() { - clearInterval(this.$pollSizeChangesTimer), - this.$measureNode && - this.$measureNode.parentNode.removeChild(this.$measureNode), - delete this.$measureNode; - }); - }.call(a.prototype), - (t.Text = a)); - }), - define("ace/layer/cursor", [ - "require", - "exports", - "module", - "ace/lib/dom" - ], function(e, t, n) { - "use strict"; - var r = e("../lib/dom"), - i, - s = function(e) { - (this.element = r.createElement("div")), - (this.element.className = "ace_layer ace_cursor-layer"), - e.appendChild(this.element), - i === undefined && (i = !("opacity" in this.element.style)), - (this.isVisible = !1), - (this.isBlinking = !0), - (this.blinkInterval = 1e3), - (this.smoothBlinking = !1), - (this.cursors = []), - (this.cursor = this.addCursor()), - r.addCssClass(this.element, "ace_hidden-cursors"), - (this.$updateCursors = (i - ? this.$updateVisibility - : this.$updateOpacity - ).bind(this)); - }; - (function() { - (this.$updateVisibility = function(e) { - var t = this.cursors; - for (var n = t.length; n--; ) t[n].style.visibility = e ? "" : "hidden"; - }), - (this.$updateOpacity = function(e) { - var t = this.cursors; - for (var n = t.length; n--; ) t[n].style.opacity = e ? "" : "0"; - }), - (this.$padding = 0), - (this.setPadding = function(e) { - this.$padding = e; - }), - (this.setSession = function(e) { - this.session = e; - }), - (this.setBlinking = function(e) { - e != this.isBlinking && ((this.isBlinking = e), this.restartTimer()); - }), - (this.setBlinkInterval = function(e) { - e != this.blinkInterval && - ((this.blinkInterval = e), this.restartTimer()); - }), - (this.setSmoothBlinking = function(e) { - e != this.smoothBlinking && - !i && - ((this.smoothBlinking = e), - r.setCssClass(this.element, "ace_smooth-blinking", e), - this.$updateCursors(!0), - (this.$updateCursors = this.$updateOpacity.bind(this)), - this.restartTimer()); - }), - (this.addCursor = function() { - var e = r.createElement("div"); - return ( - (e.className = "ace_cursor"), - this.element.appendChild(e), - this.cursors.push(e), - e - ); - }), - (this.removeCursor = function() { - if (this.cursors.length > 1) { - var e = this.cursors.pop(); - return e.parentNode.removeChild(e), e; - } - }), - (this.hideCursor = function() { - (this.isVisible = !1), - r.addCssClass(this.element, "ace_hidden-cursors"), - this.restartTimer(); - }), - (this.showCursor = function() { - (this.isVisible = !0), - r.removeCssClass(this.element, "ace_hidden-cursors"), - this.restartTimer(); - }), - (this.restartTimer = function() { - var e = this.$updateCursors; - clearInterval(this.intervalId), - clearTimeout(this.timeoutId), - this.smoothBlinking && - r.removeCssClass(this.element, "ace_smooth-blinking"), - e(!0); - if (!this.isBlinking || !this.blinkInterval || !this.isVisible) - return; - this.smoothBlinking && - setTimeout( - function() { - r.addCssClass(this.element, "ace_smooth-blinking"); - }.bind(this) - ); - var t = function() { - this.timeoutId = setTimeout(function() { - e(!1); - }, 0.6 * this.blinkInterval); - }.bind(this); - (this.intervalId = setInterval(function() { - e(!0), t(); - }, this.blinkInterval)), - t(); - }), - (this.getPixelPosition = function(e, t) { - if (!this.config || !this.session) return { left: 0, top: 0 }; - e || (e = this.session.selection.getCursor()); - var n = this.session.documentToScreenPosition(e), - r = this.$padding + n.column * this.config.characterWidth, - i = - (n.row - (t ? this.config.firstRowScreen : 0)) * - this.config.lineHeight; - return { left: r, top: i }; - }), - (this.update = function(e) { - this.config = e; - var t = this.session.$selectionMarkers, - n = 0, - r = 0; - if (t === undefined || t.length === 0) t = [{ cursor: null }]; - for (var n = 0, i = t.length; n < i; n++) { - var s = this.getPixelPosition(t[n].cursor, !0); - if ((s.top > e.height + e.offset || s.top < 0) && n > 1) continue; - var o = (this.cursors[r++] || this.addCursor()).style; - this.drawCursor - ? this.drawCursor(o, s, e, t[n], this.session) - : ((o.left = s.left + "px"), - (o.top = s.top + "px"), - (o.width = e.characterWidth + "px"), - (o.height = e.lineHeight + "px")); - } - while (this.cursors.length > r) this.removeCursor(); - var u = this.session.getOverwrite(); - this.$setOverwrite(u), (this.$pixelPos = s), this.restartTimer(); - }), - (this.drawCursor = null), - (this.$setOverwrite = function(e) { - e != this.overwrite && - ((this.overwrite = e), - e - ? r.addCssClass(this.element, "ace_overwrite-cursors") - : r.removeCssClass(this.element, "ace_overwrite-cursors")); - }), - (this.destroy = function() { - clearInterval(this.intervalId), clearTimeout(this.timeoutId); - }); - }.call(s.prototype), - (t.Cursor = s)); - }), - define("ace/scrollbar", [ - "require", - "exports", - "module", - "ace/lib/oop", - "ace/lib/dom", - "ace/lib/event", - "ace/lib/event_emitter" - ], function(e, t, n) { - "use strict"; - var r = e("./lib/oop"), - i = e("./lib/dom"), - s = e("./lib/event"), - o = e("./lib/event_emitter").EventEmitter, - u = 32768, - a = function(e) { - (this.element = i.createElement("div")), - (this.element.className = - "ace_scrollbar ace_scrollbar" + this.classSuffix), - (this.inner = i.createElement("div")), - (this.inner.className = "ace_scrollbar-inner"), - this.element.appendChild(this.inner), - e.appendChild(this.element), - this.setVisible(!1), - (this.skipEvent = !1), - s.addListener(this.element, "scroll", this.onScroll.bind(this)), - s.addListener(this.element, "mousedown", s.preventDefault); - }; - (function() { - r.implement(this, o), - (this.setVisible = function(e) { - (this.element.style.display = e ? "" : "none"), - (this.isVisible = e), - (this.coeff = 1); - }); - }.call(a.prototype)); - var f = function(e, t) { - a.call(this, e), - (this.scrollTop = 0), - (this.scrollHeight = 0), - (t.$scrollbarWidth = this.width = i.scrollbarWidth(e.ownerDocument)), - (this.inner.style.width = this.element.style.width = - (this.width || 15) + 5 + "px"); - }; - r.inherits(f, a), - function() { - (this.classSuffix = "-v"), - (this.onScroll = function() { - if (!this.skipEvent) { - this.scrollTop = this.element.scrollTop; - if (this.coeff != 1) { - var e = this.element.clientHeight / this.scrollHeight; - this.scrollTop = (this.scrollTop * (1 - e)) / (this.coeff - e); + a = r.replace(o, u); + if (!this.$textToken[n.type]) { + var f = "ace_" + n.type.replace(/\./g, " ace_"), + l = ""; + (n.type == "fold" && + (l = + " style='width:" + + n.value.length * this.config.characterWidth + + "px;' "), + e.push("", a, "")); + } else e.push(a); + return t + r.length; + }), + (this.renderIndentGuide = function (e, t, n) { + var r = t.search(this.$indentGuideRe); + return r <= 0 || r >= n + ? t + : t[0] == " " + ? ((r -= r % this.tabSize), + e.push( + s.stringRepeat(this.$tabStrings[" "], r / this.tabSize) + ), + t.substr(r)) + : t[0] == " " + ? (e.push(s.stringRepeat(this.$tabStrings[" "], r)), + t.substr(r)) + : t; + }), + (this.$renderWrappedLine = function (e, t, n, r) { + var i = 0, + o = 0, + u = n[0], + a = 0; + for (var f = 0; f < t.length; f++) { + var l = t[f], + c = l.value; + if (f == 0 && this.displayIndentGuides) { + ((i = c.length), (c = this.renderIndentGuide(e, c, u))); + if (!c) continue; + i -= c.length; + } + if (i + c.length < u) + ((a = this.$renderToken(e, a, l, c)), (i += c.length)); + else { + while (i + c.length >= u) + ((a = this.$renderToken(e, a, l, c.substring(0, u - i))), + (c = c.substring(u - i)), + (i = u), + r || + e.push( + "
", + "
" + ), + e.push(s.stringRepeat("\u00a0", n.indent)), + o++, + (a = 0), + (u = n[o] || Number.MAX_VALUE)); + c.length != 0 && + ((i += c.length), (a = this.$renderToken(e, a, l, c))); } - this._emit("scroll", { data: this.scrollTop }); - } - this.skipEvent = !1; - }), - (this.getWidth = function() { - return this.isVisible ? this.width : 0; - }), - (this.setHeight = function(e) { - this.element.style.height = e + "px"; - }), - (this.setInnerHeight = this.setScrollHeight = function(e) { - (this.scrollHeight = e), - e > u - ? ((this.coeff = u / e), (e = u)) - : this.coeff != 1 && (this.coeff = 1), - (this.inner.style.height = e + "px"); - }), - (this.setScrollTop = function(e) { - this.scrollTop != e && - ((this.skipEvent = !0), - (this.scrollTop = e), - (this.element.scrollTop = e * this.coeff)); - }); - }.call(f.prototype); - var l = function(e, t) { - a.call(this, e), - (this.scrollLeft = 0), - (this.height = t.$scrollbarWidth), - (this.inner.style.height = this.element.style.height = - (this.height || 15) + 5 + "px"); - }; - r.inherits(l, a), - function() { - (this.classSuffix = "-h"), - (this.onScroll = function() { - this.skipEvent || - ((this.scrollLeft = this.element.scrollLeft), - this._emit("scroll", { data: this.scrollLeft })), - (this.skipEvent = !1); - }), - (this.getHeight = function() { - return this.isVisible ? this.height : 0; - }), - (this.setWidth = function(e) { - this.element.style.width = e + "px"; - }), - (this.setInnerWidth = function(e) { - this.inner.style.width = e + "px"; - }), - (this.setScrollWidth = function(e) { - this.inner.style.width = e + "px"; - }), - (this.setScrollLeft = function(e) { - this.scrollLeft != e && - ((this.skipEvent = !0), - (this.scrollLeft = this.element.scrollLeft = e)); - }); - }.call(l.prototype), - (t.ScrollBar = f), - (t.ScrollBarV = f), - (t.ScrollBarH = l), - (t.VScrollBar = f), - (t.HScrollBar = l); - }), - define("ace/renderloop", [ - "require", - "exports", - "module", - "ace/lib/event" - ], function(e, t, n) { - "use strict"; - var r = e("./lib/event"), - i = function(e, t) { - (this.onRender = e), - (this.pending = !1), - (this.changes = 0), - (this.window = t || window); - }; - (function() { - this.schedule = function(e) { - this.changes = this.changes | e; - if (!this.pending && this.changes) { - this.pending = !0; - var t = this; - r.nextFrame(function() { - t.pending = !1; - var e; - while ((e = t.changes)) (t.changes = 0), t.onRender(e); - }, this.window); - } - }; - }.call(i.prototype), - (t.RenderLoop = i)); - }), - define("ace/layer/font_metrics", [ - "require", - "exports", - "module", - "ace/lib/oop", - "ace/lib/dom", - "ace/lib/lang", - "ace/lib/useragent", - "ace/lib/event_emitter" - ], function(e, t, n) { - var r = e("../lib/oop"), - i = e("../lib/dom"), - s = e("../lib/lang"), - o = e("../lib/useragent"), - u = e("../lib/event_emitter").EventEmitter, - a = 0, - f = (t.FontMetrics = function(e) { - (this.el = i.createElement("div")), - this.$setMeasureNodeStyles(this.el.style, !0), - (this.$main = i.createElement("div")), - this.$setMeasureNodeStyles(this.$main.style), - (this.$measureNode = i.createElement("div")), - this.$setMeasureNodeStyles(this.$measureNode.style), - this.el.appendChild(this.$main), - this.el.appendChild(this.$measureNode), - e.appendChild(this.el), - a || this.$testFractionalRect(), - (this.$measureNode.innerHTML = s.stringRepeat("X", a)), - (this.$characterSize = { width: 0, height: 0 }), - this.checkForSizeChanges(); - }); - (function() { - r.implement(this, u), - (this.$characterSize = { width: 0, height: 0 }), - (this.$testFractionalRect = function() { - var e = i.createElement("div"); - this.$setMeasureNodeStyles(e.style), - (e.style.width = "0.2px"), - document.documentElement.appendChild(e); - var t = e.getBoundingClientRect().width; - t > 0 && t < 1 ? (a = 50) : (a = 100), e.parentNode.removeChild(e); - }), - (this.$setMeasureNodeStyles = function(e, t) { - (e.width = e.height = "auto"), - (e.left = e.top = "0px"), - (e.visibility = "hidden"), - (e.position = "absolute"), - (e.whiteSpace = "pre"), - (e.font = "inherit"), - (e.overflow = t ? "hidden" : "visible"); - }), - (this.checkForSizeChanges = function() { - var e = this.$measureSizes(); - if ( - e && - (this.$characterSize.width !== e.width || - this.$characterSize.height !== e.height) - ) { - this.$measureNode.style.fontWeight = "bold"; - var t = this.$measureSizes(); - (this.$measureNode.style.fontWeight = ""), - (this.$characterSize = e), - (this.charSizes = Object.create(null)), - (this.allowBoldFonts = - t && t.width === e.width && t.height === e.height), - this._emit("changeCharacterSize", { data: e }); - } - }), - (this.$pollSizeChanges = function() { - if (this.$pollSizeChangesTimer) return this.$pollSizeChangesTimer; - var e = this; - return (this.$pollSizeChangesTimer = setInterval(function() { - e.checkForSizeChanges(); - }, 500)); - }), - (this.setPolling = function(e) { - e - ? this.$pollSizeChanges() - : this.$pollSizeChangesTimer && - (clearInterval(this.$pollSizeChangesTimer), - (this.$pollSizeChangesTimer = 0)); - }), - (this.$measureSizes = function() { - if (a === 50) { - var e = null; - try { - e = this.$measureNode.getBoundingClientRect(); - } catch (t) { - e = { width: 0, height: 0 }; } - var n = { height: e.height, width: e.width / a }; - } else - var n = { - height: this.$measureNode.clientHeight, - width: this.$measureNode.clientWidth / a - }; - return n.width === 0 || n.height === 0 ? null : n; - }), - (this.$measureCharWidth = function(e) { - this.$main.innerHTML = s.stringRepeat(e, a); - var t = this.$main.getBoundingClientRect(); - return t.width / a; - }), - (this.getCharacterWidth = function(e) { - var t = this.charSizes[e]; - return ( - t === undefined && - (t = this.charSizes[e] = - this.$measureCharWidth(e) / this.$characterSize.width), - t - ); - }), - (this.destroy = function() { - clearInterval(this.$pollSizeChangesTimer), - this.el && - this.el.parentNode && - this.el.parentNode.removeChild(this.el); - }); - }.call(f.prototype)); - }), - define("ace/virtual_renderer", [ - "require", - "exports", - "module", - "ace/lib/oop", - "ace/lib/dom", - "ace/config", - "ace/lib/useragent", - "ace/layer/gutter", - "ace/layer/marker", - "ace/layer/text", + }), + (this.$renderSimpleLine = function (e, t) { + var n = 0, + r = t[0], + i = r.value; + (this.displayIndentGuides && (i = this.renderIndentGuide(e, i)), + i && (n = this.$renderToken(e, n, r, i))); + for (var s = 1; s < t.length; s++) + ((r = t[s]), (i = r.value), (n = this.$renderToken(e, n, r, i))); + }), + (this.$renderLine = function (e, t, n, r) { + !r && r != 0 && (r = this.session.getFoldLine(t)); + if (r) var i = this.$getFoldLineTokens(t, r); + else var i = this.session.getTokens(t); + n || + e.push( + "
" + ); + if (i.length) { + var s = this.session.getRowSplitData(t); + s && s.length + ? this.$renderWrappedLine(e, i, s, n) + : this.$renderSimpleLine(e, i); + } + (this.showInvisibles && + (r && (t = r.end.row), + e.push( + "", + t == this.session.getLength() - 1 + ? this.EOF_CHAR + : this.EOL_CHAR, + "" + )), + n || e.push("
")); + }), + (this.$getFoldLineTokens = function (e, t) { + function i(e, t, n) { + var i = 0, + s = 0; + while (s + e[i].value.length < t) { + ((s += e[i].value.length), i++); + if (i == e.length) return; + } + if (s != t) { + var o = e[i].value.substring(t - s); + (o.length > n - t && (o = o.substring(0, n - t)), + r.push({ type: e[i].type, value: o }), + (s = t + o.length), + (i += 1)); + } + while (s < n && i < e.length) { + var o = e[i].value; + (o.length + s > n + ? r.push({ type: e[i].type, value: o.substring(0, n - s) }) + : r.push(e[i]), + (s += o.length), + (i += 1)); + } + } + var n = this.session, + r = [], + s = n.getTokens(e); + return ( + t.walk( + function (e, t, o, u, a) { + e != null + ? r.push({ type: "fold", value: e }) + : (a && (s = n.getTokens(t)), s.length && i(s, u, o)); + }, + t.end.row, + this.session.getLine(t.end.row).length + ), + r + ); + }), + (this.$useLineGroups = function () { + return this.session.getUseWrapMode(); + }), + (this.destroy = function () { + (clearInterval(this.$pollSizeChangesTimer), + this.$measureNode && + this.$measureNode.parentNode.removeChild(this.$measureNode), + delete this.$measureNode); + })); + }).call(a.prototype), + (t.Text = a)); + } + ), + define( "ace/layer/cursor", + ["require", "exports", "module", "ace/lib/dom"], + function (e, t, n) { + "use strict"; + var r = e("../lib/dom"), + i, + s = function (e) { + ((this.element = r.createElement("div")), + (this.element.className = "ace_layer ace_cursor-layer"), + e.appendChild(this.element), + i === undefined && (i = !("opacity" in this.element.style)), + (this.isVisible = !1), + (this.isBlinking = !0), + (this.blinkInterval = 1e3), + (this.smoothBlinking = !1), + (this.cursors = []), + (this.cursor = this.addCursor()), + r.addCssClass(this.element, "ace_hidden-cursors"), + (this.$updateCursors = ( + i ? this.$updateVisibility : this.$updateOpacity + ).bind(this))); + }; + ((function () { + ((this.$updateVisibility = function (e) { + var t = this.cursors; + for (var n = t.length; n--;) + t[n].style.visibility = e ? "" : "hidden"; + }), + (this.$updateOpacity = function (e) { + var t = this.cursors; + for (var n = t.length; n--;) t[n].style.opacity = e ? "" : "0"; + }), + (this.$padding = 0), + (this.setPadding = function (e) { + this.$padding = e; + }), + (this.setSession = function (e) { + this.session = e; + }), + (this.setBlinking = function (e) { + e != this.isBlinking && + ((this.isBlinking = e), this.restartTimer()); + }), + (this.setBlinkInterval = function (e) { + e != this.blinkInterval && + ((this.blinkInterval = e), this.restartTimer()); + }), + (this.setSmoothBlinking = function (e) { + e != this.smoothBlinking && + !i && + ((this.smoothBlinking = e), + r.setCssClass(this.element, "ace_smooth-blinking", e), + this.$updateCursors(!0), + (this.$updateCursors = this.$updateOpacity.bind(this)), + this.restartTimer()); + }), + (this.addCursor = function () { + var e = r.createElement("div"); + return ( + (e.className = "ace_cursor"), + this.element.appendChild(e), + this.cursors.push(e), + e + ); + }), + (this.removeCursor = function () { + if (this.cursors.length > 1) { + var e = this.cursors.pop(); + return (e.parentNode.removeChild(e), e); + } + }), + (this.hideCursor = function () { + ((this.isVisible = !1), + r.addCssClass(this.element, "ace_hidden-cursors"), + this.restartTimer()); + }), + (this.showCursor = function () { + ((this.isVisible = !0), + r.removeCssClass(this.element, "ace_hidden-cursors"), + this.restartTimer()); + }), + (this.restartTimer = function () { + var e = this.$updateCursors; + (clearInterval(this.intervalId), + clearTimeout(this.timeoutId), + this.smoothBlinking && + r.removeCssClass(this.element, "ace_smooth-blinking"), + e(!0)); + if (!this.isBlinking || !this.blinkInterval || !this.isVisible) + return; + this.smoothBlinking && + setTimeout( + function () { + r.addCssClass(this.element, "ace_smooth-blinking"); + }.bind(this) + ); + var t = function () { + this.timeoutId = setTimeout(function () { + e(!1); + }, 0.6 * this.blinkInterval); + }.bind(this); + ((this.intervalId = setInterval(function () { + (e(!0), t()); + }, this.blinkInterval)), + t()); + }), + (this.getPixelPosition = function (e, t) { + if (!this.config || !this.session) return { left: 0, top: 0 }; + e || (e = this.session.selection.getCursor()); + var n = this.session.documentToScreenPosition(e), + r = this.$padding + n.column * this.config.characterWidth, + i = + (n.row - (t ? this.config.firstRowScreen : 0)) * + this.config.lineHeight; + return { left: r, top: i }; + }), + (this.update = function (e) { + this.config = e; + var t = this.session.$selectionMarkers, + n = 0, + r = 0; + if (t === undefined || t.length === 0) t = [{ cursor: null }]; + for (var n = 0, i = t.length; n < i; n++) { + var s = this.getPixelPosition(t[n].cursor, !0); + if ((s.top > e.height + e.offset || s.top < 0) && n > 1) continue; + var o = (this.cursors[r++] || this.addCursor()).style; + this.drawCursor + ? this.drawCursor(o, s, e, t[n], this.session) + : ((o.left = s.left + "px"), + (o.top = s.top + "px"), + (o.width = e.characterWidth + "px"), + (o.height = e.lineHeight + "px")); + } + while (this.cursors.length > r) this.removeCursor(); + var u = this.session.getOverwrite(); + (this.$setOverwrite(u), (this.$pixelPos = s), this.restartTimer()); + }), + (this.drawCursor = null), + (this.$setOverwrite = function (e) { + e != this.overwrite && + ((this.overwrite = e), + e + ? r.addCssClass(this.element, "ace_overwrite-cursors") + : r.removeCssClass(this.element, "ace_overwrite-cursors")); + }), + (this.destroy = function () { + (clearInterval(this.intervalId), clearTimeout(this.timeoutId)); + })); + }).call(s.prototype), + (t.Cursor = s)); + } + ), + define( "ace/scrollbar", - "ace/scrollbar", + [ + "require", + "exports", + "module", + "ace/lib/oop", + "ace/lib/dom", + "ace/lib/event", + "ace/lib/event_emitter" + ], + function (e, t, n) { + "use strict"; + var r = e("./lib/oop"), + i = e("./lib/dom"), + s = e("./lib/event"), + o = e("./lib/event_emitter").EventEmitter, + u = 32768, + a = function (e) { + ((this.element = i.createElement("div")), + (this.element.className = + "ace_scrollbar ace_scrollbar" + this.classSuffix), + (this.inner = i.createElement("div")), + (this.inner.className = "ace_scrollbar-inner"), + this.element.appendChild(this.inner), + e.appendChild(this.element), + this.setVisible(!1), + (this.skipEvent = !1), + s.addListener(this.element, "scroll", this.onScroll.bind(this)), + s.addListener(this.element, "mousedown", s.preventDefault)); + }; + (function () { + (r.implement(this, o), + (this.setVisible = function (e) { + ((this.element.style.display = e ? "" : "none"), + (this.isVisible = e), + (this.coeff = 1)); + })); + }).call(a.prototype); + var f = function (e, t) { + (a.call(this, e), + (this.scrollTop = 0), + (this.scrollHeight = 0), + (t.$scrollbarWidth = this.width = i.scrollbarWidth(e.ownerDocument)), + (this.inner.style.width = this.element.style.width = + (this.width || 15) + 5 + "px")); + }; + (r.inherits(f, a), + function () { + ((this.classSuffix = "-v"), + (this.onScroll = function () { + if (!this.skipEvent) { + this.scrollTop = this.element.scrollTop; + if (this.coeff != 1) { + var e = this.element.clientHeight / this.scrollHeight; + this.scrollTop = + (this.scrollTop * (1 - e)) / (this.coeff - e); + } + this._emit("scroll", { data: this.scrollTop }); + } + this.skipEvent = !1; + }), + (this.getWidth = function () { + return this.isVisible ? this.width : 0; + }), + (this.setHeight = function (e) { + this.element.style.height = e + "px"; + }), + (this.setInnerHeight = this.setScrollHeight = + function (e) { + ((this.scrollHeight = e), + e > u + ? ((this.coeff = u / e), (e = u)) + : this.coeff != 1 && (this.coeff = 1), + (this.inner.style.height = e + "px")); + }), + (this.setScrollTop = function (e) { + this.scrollTop != e && + ((this.skipEvent = !0), + (this.scrollTop = e), + (this.element.scrollTop = e * this.coeff)); + })); + }.call(f.prototype)); + var l = function (e, t) { + (a.call(this, e), + (this.scrollLeft = 0), + (this.height = t.$scrollbarWidth), + (this.inner.style.height = this.element.style.height = + (this.height || 15) + 5 + "px")); + }; + (r.inherits(l, a), + function () { + ((this.classSuffix = "-h"), + (this.onScroll = function () { + (this.skipEvent || + ((this.scrollLeft = this.element.scrollLeft), + this._emit("scroll", { data: this.scrollLeft })), + (this.skipEvent = !1)); + }), + (this.getHeight = function () { + return this.isVisible ? this.height : 0; + }), + (this.setWidth = function (e) { + this.element.style.width = e + "px"; + }), + (this.setInnerWidth = function (e) { + this.inner.style.width = e + "px"; + }), + (this.setScrollWidth = function (e) { + this.inner.style.width = e + "px"; + }), + (this.setScrollLeft = function (e) { + this.scrollLeft != e && + ((this.skipEvent = !0), + (this.scrollLeft = this.element.scrollLeft = e)); + })); + }.call(l.prototype), + (t.ScrollBar = f), + (t.ScrollBarV = f), + (t.ScrollBarH = l), + (t.VScrollBar = f), + (t.HScrollBar = l)); + } + ), + define( "ace/renderloop", + ["require", "exports", "module", "ace/lib/event"], + function (e, t, n) { + "use strict"; + var r = e("./lib/event"), + i = function (e, t) { + ((this.onRender = e), + (this.pending = !1), + (this.changes = 0), + (this.window = t || window)); + }; + ((function () { + this.schedule = function (e) { + this.changes = this.changes | e; + if (!this.pending && this.changes) { + this.pending = !0; + var t = this; + r.nextFrame(function () { + t.pending = !1; + var e; + while ((e = t.changes)) ((t.changes = 0), t.onRender(e)); + }, this.window); + } + }; + }).call(i.prototype), + (t.RenderLoop = i)); + } + ), + define( "ace/layer/font_metrics", - "ace/lib/event_emitter" - ], function(e, t, n) { - "use strict"; - var r = e("./lib/oop"), - i = e("./lib/dom"), - s = e("./config"), - o = e("./lib/useragent"), - u = e("./layer/gutter").Gutter, - a = e("./layer/marker").Marker, - f = e("./layer/text").Text, - l = e("./layer/cursor").Cursor, - c = e("./scrollbar").HScrollBar, - h = e("./scrollbar").VScrollBar, - p = e("./renderloop").RenderLoop, - d = e("./layer/font_metrics").FontMetrics, - v = e("./lib/event_emitter").EventEmitter, - m = - '.ace_editor {position: relative;overflow: hidden;font: 12px/normal \'Monaco\', \'Menlo\', \'Ubuntu Mono\', \'Consolas\', \'source-code-pro\', monospace;direction: ltr;text-align: left;}.ace_scroller {position: absolute;overflow: hidden;top: 0;bottom: 0;background-color: inherit;-ms-user-select: none;-moz-user-select: none;-webkit-user-select: none;user-select: none;cursor: text;}.ace_content {position: absolute;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;min-width: 100%;}.ace_dragging .ace_scroller:before{position: absolute;top: 0;left: 0;right: 0;bottom: 0;content: \'\';background: rgba(250, 250, 250, 0.01);z-index: 1000;}.ace_dragging.ace_dark .ace_scroller:before{background: rgba(0, 0, 0, 0.01);}.ace_selecting, .ace_selecting * {cursor: text !important;}.ace_gutter {position: absolute;overflow : hidden;width: auto;top: 0;bottom: 0;left: 0;cursor: default;z-index: 4;-ms-user-select: none;-moz-user-select: none;-webkit-user-select: none;user-select: none;}.ace_gutter-active-line {position: absolute;left: 0;right: 0;}.ace_scroller.ace_scroll-left {box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;}.ace_gutter-cell {padding-left: 19px;padding-right: 6px;background-repeat: no-repeat;}.ace_gutter-cell.ace_error {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAABOFBMVEX/////////QRswFAb/Ui4wFAYwFAYwFAaWGAfDRymzOSH/PxswFAb/SiUwFAYwFAbUPRvjQiDllog5HhHdRybsTi3/Tyv9Tir+Syj/UC3////XurebMBIwFAb/RSHbPx/gUzfdwL3kzMivKBAwFAbbvbnhPx66NhowFAYwFAaZJg8wFAaxKBDZurf/RB6mMxb/SCMwFAYwFAbxQB3+RB4wFAb/Qhy4Oh+4QifbNRcwFAYwFAYwFAb/QRzdNhgwFAYwFAbav7v/Uy7oaE68MBK5LxLewr/r2NXewLswFAaxJw4wFAbkPRy2PyYwFAaxKhLm1tMwFAazPiQwFAaUGAb/QBrfOx3bvrv/VC/maE4wFAbRPBq6MRO8Qynew8Dp2tjfwb0wFAbx6eju5+by6uns4uH9/f36+vr/GkHjAAAAYnRSTlMAGt+64rnWu/bo8eAA4InH3+DwoN7j4eLi4xP99Nfg4+b+/u9B/eDs1MD1mO7+4PHg2MXa347g7vDizMLN4eG+Pv7i5evs/v79yu7S3/DV7/498Yv24eH+4ufQ3Ozu/v7+y13sRqwAAADLSURBVHjaZc/XDsFgGIBhtDrshlitmk2IrbHFqL2pvXf/+78DPokj7+Fz9qpU/9UXJIlhmPaTaQ6QPaz0mm+5gwkgovcV6GZzd5JtCQwgsxoHOvJO15kleRLAnMgHFIESUEPmawB9ngmelTtipwwfASilxOLyiV5UVUyVAfbG0cCPHig+GBkzAENHS0AstVF6bacZIOzgLmxsHbt2OecNgJC83JERmePUYq8ARGkJx6XtFsdddBQgZE2nPR6CICZhawjA4Fb/chv+399kfR+MMMDGOQAAAABJRU5ErkJggg==");background-repeat: no-repeat;background-position: 2px center;}.ace_gutter-cell.ace_warning {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAmVBMVEX///8AAAD///8AAAAAAABPSzb/5sAAAAB/blH/73z/ulkAAAAAAAD85pkAAAAAAAACAgP/vGz/rkDerGbGrV7/pkQICAf////e0IsAAAD/oED/qTvhrnUAAAD/yHD/njcAAADuv2r/nz//oTj/p064oGf/zHAAAAA9Nir/tFIAAAD/tlTiuWf/tkIAAACynXEAAAAAAAAtIRW7zBpBAAAAM3RSTlMAABR1m7RXO8Ln31Z36zT+neXe5OzooRDfn+TZ4p3h2hTf4t3k3ucyrN1K5+Xaks52Sfs9CXgrAAAAjklEQVR42o3PbQ+CIBQFYEwboPhSYgoYunIqqLn6/z8uYdH8Vmdnu9vz4WwXgN/xTPRD2+sgOcZjsge/whXZgUaYYvT8QnuJaUrjrHUQreGczuEafQCO/SJTufTbroWsPgsllVhq3wJEk2jUSzX3CUEDJC84707djRc5MTAQxoLgupWRwW6UB5fS++NV8AbOZgnsC7BpEAAAAABJRU5ErkJggg==");background-position: 2px center;}.ace_gutter-cell.ace_info {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=");background-position: 2px center;}.ace_dark .ace_gutter-cell.ace_info {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC");}.ace_scrollbar {position: absolute;right: 0;bottom: 0;z-index: 6;}.ace_scrollbar-inner {position: absolute;cursor: text;left: 0;top: 0;}.ace_scrollbar-v{overflow-x: hidden;overflow-y: scroll;top: 0;}.ace_scrollbar-h {overflow-x: scroll;overflow-y: hidden;left: 0;}.ace_print-margin {position: absolute;height: 100%;}.ace_text-input {position: absolute;z-index: 0;width: 0.5em;height: 1em;opacity: 0;background: transparent;-moz-appearance: none;appearance: none;border: none;resize: none;outline: none;overflow: hidden;font: inherit;padding: 0 1px;margin: 0 -1px;text-indent: -1em;-ms-user-select: text;-moz-user-select: text;-webkit-user-select: text;user-select: text;white-space: pre!important;}.ace_text-input.ace_composition {background: inherit;color: inherit;z-index: 1000;opacity: 1;text-indent: 0;}.ace_layer {z-index: 1;position: absolute;overflow: hidden;word-wrap: normal;white-space: pre;height: 100%;width: 100%;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;pointer-events: none;}.ace_gutter-layer {position: relative;width: auto;text-align: right;pointer-events: auto;}.ace_text-layer {font: inherit !important;}.ace_cjk {display: inline-block;text-align: center;}.ace_cursor-layer {z-index: 4;}.ace_cursor {z-index: 4;position: absolute;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;border-left: 2px solid;transform: translatez(0);}.ace_slim-cursors .ace_cursor {border-left-width: 1px;}.ace_overwrite-cursors .ace_cursor {border-left-width: 0;border-bottom: 1px solid;}.ace_hidden-cursors .ace_cursor {opacity: 0.2;}.ace_smooth-blinking .ace_cursor {-webkit-transition: opacity 0.18s;transition: opacity 0.18s;}.ace_editor.ace_multiselect .ace_cursor {border-left-width: 1px;}.ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {position: absolute;z-index: 3;}.ace_marker-layer .ace_selection {position: absolute;z-index: 5;}.ace_marker-layer .ace_bracket {position: absolute;z-index: 6;}.ace_marker-layer .ace_active-line {position: absolute;z-index: 2;}.ace_marker-layer .ace_selected-word {position: absolute;z-index: 4;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;}.ace_line .ace_fold {-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;display: inline-block;height: 11px;margin-top: -2px;vertical-align: middle;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII="),url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=");background-repeat: no-repeat, repeat-x;background-position: center center, top left;color: transparent;border: 1px solid black;border-radius: 2px;cursor: pointer;pointer-events: auto;}.ace_dark .ace_fold {}.ace_fold:hover{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII="),url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC");}.ace_tooltip {background-color: #FFF;background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1));background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));border: 1px solid gray;border-radius: 1px;box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);color: black;max-width: 100%;padding: 3px 4px;position: fixed;z-index: 999999;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;cursor: default;white-space: pre;word-wrap: break-word;line-height: normal;font-style: normal;font-weight: normal;letter-spacing: normal;pointer-events: none;}.ace_folding-enabled > .ace_gutter-cell {padding-right: 13px;}.ace_fold-widget {-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;margin: 0 -12px 0 1px;display: none;width: 11px;vertical-align: top;background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==");background-repeat: no-repeat;background-position: center;border-radius: 3px;border: 1px solid transparent;cursor: pointer;}.ace_folding-enabled .ace_fold-widget {display: inline-block; }.ace_fold-widget.ace_end {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==");}.ace_fold-widget.ace_closed {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==");}.ace_fold-widget:hover {border: 1px solid rgba(0, 0, 0, 0.3);background-color: rgba(255, 255, 255, 0.2);box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);}.ace_fold-widget:active {border: 1px solid rgba(0, 0, 0, 0.4);background-color: rgba(0, 0, 0, 0.05);box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);}.ace_dark .ace_fold-widget {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC");}.ace_dark .ace_fold-widget.ace_end {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==");}.ace_dark .ace_fold-widget.ace_closed {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==");}.ace_dark .ace_fold-widget:hover {box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);background-color: rgba(255, 255, 255, 0.1);}.ace_dark .ace_fold-widget:active {box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);}.ace_fold-widget.ace_invalid {background-color: #FFB4B4;border-color: #DE5555;}.ace_fade-fold-widgets .ace_fold-widget {-webkit-transition: opacity 0.4s ease 0.05s;transition: opacity 0.4s ease 0.05s;opacity: 0;}.ace_fade-fold-widgets:hover .ace_fold-widget {-webkit-transition: opacity 0.05s ease 0.05s;transition: opacity 0.05s ease 0.05s;opacity:1;}.ace_underline {text-decoration: underline;}.ace_bold {font-weight: bold;}.ace_nobold .ace_bold {font-weight: normal;}.ace_italic {font-style: italic;}.ace_error-marker {background-color: rgba(255, 0, 0,0.2);position: absolute;z-index: 9;}.ace_highlight-marker {background-color: rgba(255, 255, 0,0.2);position: absolute;z-index: 8;}.ace_br1 {border-top-left-radius : 3px;}.ace_br2 {border-top-right-radius : 3px;}.ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}.ace_br4 {border-bottom-right-radius: 3px;}.ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}.ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}.ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}.ace_br8 {border-bottom-left-radius : 3px;}.ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}.ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}.ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}.ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}.ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}.ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}.ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}'; - i.importCssString(m, "ace_editor.css"); - var g = function(e, t) { - var n = this; - (this.container = e || i.createElement("div")), - (this.$keepTextAreaAtCursor = true), - i.addCssClass(this.container, "ace_editor"), - this.setTheme(t), - (this.$gutter = i.createElement("div")), - (this.$gutter.className = "ace_gutter"), - this.container.appendChild(this.$gutter), - (this.scroller = i.createElement("div")), - (this.scroller.className = "ace_scroller"), - this.container.appendChild(this.scroller), - (this.content = i.createElement("div")), - (this.content.className = "ace_content"), - this.scroller.appendChild(this.content), - (this.$gutterLayer = new u(this.$gutter)), - this.$gutterLayer.on( - "changeGutterWidth", - this.onGutterResize.bind(this) - ), - (this.$markerBack = new a(this.content)); - var r = (this.$textLayer = new f(this.content)); - (this.canvas = r.element), - (this.$markerFront = new a(this.content)), - (this.$cursorLayer = new l(this.content)), - (this.$horizScroll = !1), - (this.$vScroll = !1), - (this.scrollBar = this.scrollBarV = new h(this.container, this)), - (this.scrollBarH = new c(this.container, this)), - this.scrollBarV.addEventListener("scroll", function(e) { - n.$scrollAnimation || - n.session.setScrollTop(e.data - n.scrollMargin.top); - }), - this.scrollBarH.addEventListener("scroll", function(e) { - n.$scrollAnimation || - n.session.setScrollLeft(e.data - n.scrollMargin.left); - }), - (this.scrollTop = 0), - (this.scrollLeft = 0), - (this.cursorPos = { row: 0, column: 0 }), - (this.$fontMetrics = new d(this.container)), - this.$textLayer.$setFontMetrics(this.$fontMetrics), - this.$textLayer.addEventListener("changeCharacterSize", function(e) { - n.updateCharacterSize(), - n.onResize(!0, n.gutterWidth, n.$size.width, n.$size.height), - n._signal("changeCharacterSize", e); - }), - (this.$size = { - width: 0, - height: 0, - scrollerHeight: 0, - scrollerWidth: 0, - $dirty: !0 - }), - (this.layerConfig = { - width: 1, - padding: 0, - firstRow: 0, - firstRowScreen: 0, - lastRow: 0, - lineHeight: 0, - characterWidth: 0, - minHeight: 1, - maxHeight: 1, - offset: 0, - height: 1, - gutterOffset: 1 - }), - (this.scrollMargin = { - left: 0, - right: 0, - top: 0, - bottom: 0, - v: 0, - h: 0 - }), - (this.$loop = new p( - this.$renderChanges.bind(this), - this.container.ownerDocument.defaultView - )), - this.$loop.schedule(this.CHANGE_FULL), - this.updateCharacterSize(), - this.setPadding(4), - s.resetOptions(this), - s._emit("renderer", this); - }; - (function() { - (this.CHANGE_CURSOR = 1), - (this.CHANGE_MARKER = 2), - (this.CHANGE_GUTTER = 4), - (this.CHANGE_SCROLL = 8), - (this.CHANGE_LINES = 16), - (this.CHANGE_TEXT = 32), - (this.CHANGE_SIZE = 64), - (this.CHANGE_MARKER_BACK = 128), - (this.CHANGE_MARKER_FRONT = 256), - (this.CHANGE_FULL = 512), - (this.CHANGE_H_SCROLL = 1024), - r.implement(this, v), - (this.updateCharacterSize = function() { - this.$textLayer.allowBoldFonts != this.$allowBoldFonts && - ((this.$allowBoldFonts = this.$textLayer.allowBoldFonts), - this.setStyle("ace_nobold", !this.$allowBoldFonts)), - (this.layerConfig.characterWidth = this.characterWidth = this.$textLayer.getCharacterWidth()), - (this.layerConfig.lineHeight = this.lineHeight = this.$textLayer.getLineHeight()), - this.$updatePrintMargin(); - }), - (this.setSession = function(e) { - this.session && - this.session.doc.off("changeNewLineMode", this.onChangeNewLineMode), - (this.session = e), - e && - this.scrollMargin.top && - e.getScrollTop() <= 0 && - e.setScrollTop(-this.scrollMargin.top), - this.$cursorLayer.setSession(e), - this.$markerBack.setSession(e), - this.$markerFront.setSession(e), - this.$gutterLayer.setSession(e), - this.$textLayer.setSession(e); - if (!e) return; + [ + "require", + "exports", + "module", + "ace/lib/oop", + "ace/lib/dom", + "ace/lib/lang", + "ace/lib/useragent", + "ace/lib/event_emitter" + ], + function (e, t, n) { + var r = e("../lib/oop"), + i = e("../lib/dom"), + s = e("../lib/lang"), + o = e("../lib/useragent"), + u = e("../lib/event_emitter").EventEmitter, + a = 0, + f = (t.FontMetrics = function (e) { + ((this.el = i.createElement("div")), + this.$setMeasureNodeStyles(this.el.style, !0), + (this.$main = i.createElement("div")), + this.$setMeasureNodeStyles(this.$main.style), + (this.$measureNode = i.createElement("div")), + this.$setMeasureNodeStyles(this.$measureNode.style), + this.el.appendChild(this.$main), + this.el.appendChild(this.$measureNode), + e.appendChild(this.el), + a || this.$testFractionalRect(), + (this.$measureNode.innerHTML = s.stringRepeat("X", a)), + (this.$characterSize = { width: 0, height: 0 }), + this.checkForSizeChanges()); + }); + (function () { + (r.implement(this, u), + (this.$characterSize = { width: 0, height: 0 }), + (this.$testFractionalRect = function () { + var e = i.createElement("div"); + (this.$setMeasureNodeStyles(e.style), + (e.style.width = "0.2px"), + document.documentElement.appendChild(e)); + var t = e.getBoundingClientRect().width; + (t > 0 && t < 1 ? (a = 50) : (a = 100), + e.parentNode.removeChild(e)); + }), + (this.$setMeasureNodeStyles = function (e, t) { + ((e.width = e.height = "auto"), + (e.left = e.top = "0px"), + (e.visibility = "hidden"), + (e.position = "absolute"), + (e.whiteSpace = "pre"), + (e.font = "inherit"), + (e.overflow = t ? "hidden" : "visible")); + }), + (this.checkForSizeChanges = function () { + var e = this.$measureSizes(); + if ( + e && + (this.$characterSize.width !== e.width || + this.$characterSize.height !== e.height) + ) { + this.$measureNode.style.fontWeight = "bold"; + var t = this.$measureSizes(); + ((this.$measureNode.style.fontWeight = ""), + (this.$characterSize = e), + (this.charSizes = Object.create(null)), + (this.allowBoldFonts = + t && t.width === e.width && t.height === e.height), + this._emit("changeCharacterSize", { data: e })); + } + }), + (this.$pollSizeChanges = function () { + if (this.$pollSizeChangesTimer) return this.$pollSizeChangesTimer; + var e = this; + return (this.$pollSizeChangesTimer = setInterval(function () { + e.checkForSizeChanges(); + }, 500)); + }), + (this.setPolling = function (e) { + e + ? this.$pollSizeChanges() + : this.$pollSizeChangesTimer && + (clearInterval(this.$pollSizeChangesTimer), + (this.$pollSizeChangesTimer = 0)); + }), + (this.$measureSizes = function () { + if (a === 50) { + var e = null; + try { + e = this.$measureNode.getBoundingClientRect(); + } catch (t) { + e = { width: 0, height: 0 }; + } + var n = { height: e.height, width: e.width / a }; + } else + var n = { + height: this.$measureNode.clientHeight, + width: this.$measureNode.clientWidth / a + }; + return n.width === 0 || n.height === 0 ? null : n; + }), + (this.$measureCharWidth = function (e) { + this.$main.innerHTML = s.stringRepeat(e, a); + var t = this.$main.getBoundingClientRect(); + return t.width / a; + }), + (this.getCharacterWidth = function (e) { + var t = this.charSizes[e]; + return ( + t === undefined && + (t = this.charSizes[e] = + this.$measureCharWidth(e) / this.$characterSize.width), + t + ); + }), + (this.destroy = function () { + (clearInterval(this.$pollSizeChangesTimer), + this.el && + this.el.parentNode && + this.el.parentNode.removeChild(this.el)); + })); + }).call(f.prototype); + } + ), + define( + "ace/virtual_renderer", + [ + "require", + "exports", + "module", + "ace/lib/oop", + "ace/lib/dom", + "ace/config", + "ace/lib/useragent", + "ace/layer/gutter", + "ace/layer/marker", + "ace/layer/text", + "ace/layer/cursor", + "ace/scrollbar", + "ace/scrollbar", + "ace/renderloop", + "ace/layer/font_metrics", + "ace/lib/event_emitter" + ], + function (e, t, n) { + "use strict"; + var r = e("./lib/oop"), + i = e("./lib/dom"), + s = e("./config"), + o = e("./lib/useragent"), + u = e("./layer/gutter").Gutter, + a = e("./layer/marker").Marker, + f = e("./layer/text").Text, + l = e("./layer/cursor").Cursor, + c = e("./scrollbar").HScrollBar, + h = e("./scrollbar").VScrollBar, + p = e("./renderloop").RenderLoop, + d = e("./layer/font_metrics").FontMetrics, + v = e("./lib/event_emitter").EventEmitter, + m = + '.ace_editor {position: relative;overflow: hidden;font: 12px/normal \'Monaco\', \'Menlo\', \'Ubuntu Mono\', \'Consolas\', \'source-code-pro\', monospace;direction: ltr;text-align: left;}.ace_scroller {position: absolute;overflow: hidden;top: 0;bottom: 0;background-color: inherit;-ms-user-select: none;-moz-user-select: none;-webkit-user-select: none;user-select: none;cursor: text;}.ace_content {position: absolute;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;min-width: 100%;}.ace_dragging .ace_scroller:before{position: absolute;top: 0;left: 0;right: 0;bottom: 0;content: \'\';background: rgba(250, 250, 250, 0.01);z-index: 1000;}.ace_dragging.ace_dark .ace_scroller:before{background: rgba(0, 0, 0, 0.01);}.ace_selecting, .ace_selecting * {cursor: text !important;}.ace_gutter {position: absolute;overflow : hidden;width: auto;top: 0;bottom: 0;left: 0;cursor: default;z-index: 4;-ms-user-select: none;-moz-user-select: none;-webkit-user-select: none;user-select: none;}.ace_gutter-active-line {position: absolute;left: 0;right: 0;}.ace_scroller.ace_scroll-left {box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;}.ace_gutter-cell {padding-left: 19px;padding-right: 6px;background-repeat: no-repeat;}.ace_gutter-cell.ace_error {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAABOFBMVEX/////////QRswFAb/Ui4wFAYwFAYwFAaWGAfDRymzOSH/PxswFAb/SiUwFAYwFAbUPRvjQiDllog5HhHdRybsTi3/Tyv9Tir+Syj/UC3////XurebMBIwFAb/RSHbPx/gUzfdwL3kzMivKBAwFAbbvbnhPx66NhowFAYwFAaZJg8wFAaxKBDZurf/RB6mMxb/SCMwFAYwFAbxQB3+RB4wFAb/Qhy4Oh+4QifbNRcwFAYwFAYwFAb/QRzdNhgwFAYwFAbav7v/Uy7oaE68MBK5LxLewr/r2NXewLswFAaxJw4wFAbkPRy2PyYwFAaxKhLm1tMwFAazPiQwFAaUGAb/QBrfOx3bvrv/VC/maE4wFAbRPBq6MRO8Qynew8Dp2tjfwb0wFAbx6eju5+by6uns4uH9/f36+vr/GkHjAAAAYnRSTlMAGt+64rnWu/bo8eAA4InH3+DwoN7j4eLi4xP99Nfg4+b+/u9B/eDs1MD1mO7+4PHg2MXa347g7vDizMLN4eG+Pv7i5evs/v79yu7S3/DV7/498Yv24eH+4ufQ3Ozu/v7+y13sRqwAAADLSURBVHjaZc/XDsFgGIBhtDrshlitmk2IrbHFqL2pvXf/+78DPokj7+Fz9qpU/9UXJIlhmPaTaQ6QPaz0mm+5gwkgovcV6GZzd5JtCQwgsxoHOvJO15kleRLAnMgHFIESUEPmawB9ngmelTtipwwfASilxOLyiV5UVUyVAfbG0cCPHig+GBkzAENHS0AstVF6bacZIOzgLmxsHbt2OecNgJC83JERmePUYq8ARGkJx6XtFsdddBQgZE2nPR6CICZhawjA4Fb/chv+399kfR+MMMDGOQAAAABJRU5ErkJggg==");background-repeat: no-repeat;background-position: 2px center;}.ace_gutter-cell.ace_warning {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAmVBMVEX///8AAAD///8AAAAAAABPSzb/5sAAAAB/blH/73z/ulkAAAAAAAD85pkAAAAAAAACAgP/vGz/rkDerGbGrV7/pkQICAf////e0IsAAAD/oED/qTvhrnUAAAD/yHD/njcAAADuv2r/nz//oTj/p064oGf/zHAAAAA9Nir/tFIAAAD/tlTiuWf/tkIAAACynXEAAAAAAAAtIRW7zBpBAAAAM3RSTlMAABR1m7RXO8Ln31Z36zT+neXe5OzooRDfn+TZ4p3h2hTf4t3k3ucyrN1K5+Xaks52Sfs9CXgrAAAAjklEQVR42o3PbQ+CIBQFYEwboPhSYgoYunIqqLn6/z8uYdH8Vmdnu9vz4WwXgN/xTPRD2+sgOcZjsge/whXZgUaYYvT8QnuJaUrjrHUQreGczuEafQCO/SJTufTbroWsPgsllVhq3wJEk2jUSzX3CUEDJC84707djRc5MTAQxoLgupWRwW6UB5fS++NV8AbOZgnsC7BpEAAAAABJRU5ErkJggg==");background-position: 2px center;}.ace_gutter-cell.ace_info {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=");background-position: 2px center;}.ace_dark .ace_gutter-cell.ace_info {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC");}.ace_scrollbar {position: absolute;right: 0;bottom: 0;z-index: 6;}.ace_scrollbar-inner {position: absolute;cursor: text;left: 0;top: 0;}.ace_scrollbar-v{overflow-x: hidden;overflow-y: scroll;top: 0;}.ace_scrollbar-h {overflow-x: scroll;overflow-y: hidden;left: 0;}.ace_print-margin {position: absolute;height: 100%;}.ace_text-input {position: absolute;z-index: 0;width: 0.5em;height: 1em;opacity: 0;background: transparent;-moz-appearance: none;appearance: none;border: none;resize: none;outline: none;overflow: hidden;font: inherit;padding: 0 1px;margin: 0 -1px;text-indent: -1em;-ms-user-select: text;-moz-user-select: text;-webkit-user-select: text;user-select: text;white-space: pre!important;}.ace_text-input.ace_composition {background: inherit;color: inherit;z-index: 1000;opacity: 1;text-indent: 0;}.ace_layer {z-index: 1;position: absolute;overflow: hidden;word-wrap: normal;white-space: pre;height: 100%;width: 100%;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;pointer-events: none;}.ace_gutter-layer {position: relative;width: auto;text-align: right;pointer-events: auto;}.ace_text-layer {font: inherit !important;}.ace_cjk {display: inline-block;text-align: center;}.ace_cursor-layer {z-index: 4;}.ace_cursor {z-index: 4;position: absolute;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;border-left: 2px solid;transform: translatez(0);}.ace_slim-cursors .ace_cursor {border-left-width: 1px;}.ace_overwrite-cursors .ace_cursor {border-left-width: 0;border-bottom: 1px solid;}.ace_hidden-cursors .ace_cursor {opacity: 0.2;}.ace_smooth-blinking .ace_cursor {-webkit-transition: opacity 0.18s;transition: opacity 0.18s;}.ace_editor.ace_multiselect .ace_cursor {border-left-width: 1px;}.ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {position: absolute;z-index: 3;}.ace_marker-layer .ace_selection {position: absolute;z-index: 5;}.ace_marker-layer .ace_bracket {position: absolute;z-index: 6;}.ace_marker-layer .ace_active-line {position: absolute;z-index: 2;}.ace_marker-layer .ace_selected-word {position: absolute;z-index: 4;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;}.ace_line .ace_fold {-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;display: inline-block;height: 11px;margin-top: -2px;vertical-align: middle;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII="),url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=");background-repeat: no-repeat, repeat-x;background-position: center center, top left;color: transparent;border: 1px solid black;border-radius: 2px;cursor: pointer;pointer-events: auto;}.ace_dark .ace_fold {}.ace_fold:hover{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII="),url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC");}.ace_tooltip {background-color: #FFF;background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1));background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));border: 1px solid gray;border-radius: 1px;box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);color: black;max-width: 100%;padding: 3px 4px;position: fixed;z-index: 999999;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;cursor: default;white-space: pre;word-wrap: break-word;line-height: normal;font-style: normal;font-weight: normal;letter-spacing: normal;pointer-events: none;}.ace_folding-enabled > .ace_gutter-cell {padding-right: 13px;}.ace_fold-widget {-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;margin: 0 -12px 0 1px;display: none;width: 11px;vertical-align: top;background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==");background-repeat: no-repeat;background-position: center;border-radius: 3px;border: 1px solid transparent;cursor: pointer;}.ace_folding-enabled .ace_fold-widget {display: inline-block; }.ace_fold-widget.ace_end {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==");}.ace_fold-widget.ace_closed {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==");}.ace_fold-widget:hover {border: 1px solid rgba(0, 0, 0, 0.3);background-color: rgba(255, 255, 255, 0.2);box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);}.ace_fold-widget:active {border: 1px solid rgba(0, 0, 0, 0.4);background-color: rgba(0, 0, 0, 0.05);box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);}.ace_dark .ace_fold-widget {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC");}.ace_dark .ace_fold-widget.ace_end {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==");}.ace_dark .ace_fold-widget.ace_closed {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==");}.ace_dark .ace_fold-widget:hover {box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);background-color: rgba(255, 255, 255, 0.1);}.ace_dark .ace_fold-widget:active {box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);}.ace_fold-widget.ace_invalid {background-color: #FFB4B4;border-color: #DE5555;}.ace_fade-fold-widgets .ace_fold-widget {-webkit-transition: opacity 0.4s ease 0.05s;transition: opacity 0.4s ease 0.05s;opacity: 0;}.ace_fade-fold-widgets:hover .ace_fold-widget {-webkit-transition: opacity 0.05s ease 0.05s;transition: opacity 0.05s ease 0.05s;opacity:1;}.ace_underline {text-decoration: underline;}.ace_bold {font-weight: bold;}.ace_nobold .ace_bold {font-weight: normal;}.ace_italic {font-style: italic;}.ace_error-marker {background-color: rgba(255, 0, 0,0.2);position: absolute;z-index: 9;}.ace_highlight-marker {background-color: rgba(255, 255, 0,0.2);position: absolute;z-index: 8;}.ace_br1 {border-top-left-radius : 3px;}.ace_br2 {border-top-right-radius : 3px;}.ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}.ace_br4 {border-bottom-right-radius: 3px;}.ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}.ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}.ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}.ace_br8 {border-bottom-left-radius : 3px;}.ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}.ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}.ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}.ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}.ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}.ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}.ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}'; + i.importCssString(m, "ace_editor.css"); + var g = function (e, t) { + var n = this; + ((this.container = e || i.createElement("div")), + (this.$keepTextAreaAtCursor = true), + i.addCssClass(this.container, "ace_editor"), + this.setTheme(t), + (this.$gutter = i.createElement("div")), + (this.$gutter.className = "ace_gutter"), + this.container.appendChild(this.$gutter), + (this.scroller = i.createElement("div")), + (this.scroller.className = "ace_scroller"), + this.container.appendChild(this.scroller), + (this.content = i.createElement("div")), + (this.content.className = "ace_content"), + this.scroller.appendChild(this.content), + (this.$gutterLayer = new u(this.$gutter)), + this.$gutterLayer.on( + "changeGutterWidth", + this.onGutterResize.bind(this) + ), + (this.$markerBack = new a(this.content))); + var r = (this.$textLayer = new f(this.content)); + ((this.canvas = r.element), + (this.$markerFront = new a(this.content)), + (this.$cursorLayer = new l(this.content)), + (this.$horizScroll = !1), + (this.$vScroll = !1), + (this.scrollBar = this.scrollBarV = new h(this.container, this)), + (this.scrollBarH = new c(this.container, this)), + this.scrollBarV.addEventListener("scroll", function (e) { + n.$scrollAnimation || + n.session.setScrollTop(e.data - n.scrollMargin.top); + }), + this.scrollBarH.addEventListener("scroll", function (e) { + n.$scrollAnimation || + n.session.setScrollLeft(e.data - n.scrollMargin.left); + }), + (this.scrollTop = 0), + (this.scrollLeft = 0), + (this.cursorPos = { row: 0, column: 0 }), + (this.$fontMetrics = new d(this.container)), + this.$textLayer.$setFontMetrics(this.$fontMetrics), + this.$textLayer.addEventListener("changeCharacterSize", function (e) { + (n.updateCharacterSize(), + n.onResize(!0, n.gutterWidth, n.$size.width, n.$size.height), + n._signal("changeCharacterSize", e)); + }), + (this.$size = { + width: 0, + height: 0, + scrollerHeight: 0, + scrollerWidth: 0, + $dirty: !0 + }), + (this.layerConfig = { + width: 1, + padding: 0, + firstRow: 0, + firstRowScreen: 0, + lastRow: 0, + lineHeight: 0, + characterWidth: 0, + minHeight: 1, + maxHeight: 1, + offset: 0, + height: 1, + gutterOffset: 1 + }), + (this.scrollMargin = { + left: 0, + right: 0, + top: 0, + bottom: 0, + v: 0, + h: 0 + }), + (this.$loop = new p( + this.$renderChanges.bind(this), + this.container.ownerDocument.defaultView + )), this.$loop.schedule(this.CHANGE_FULL), - this.session.$setFontMetrics(this.$fontMetrics), - (this.scrollBarV.scrollLeft = this.scrollBarV.scrollTop = null), - (this.onChangeNewLineMode = this.onChangeNewLineMode.bind(this)), - this.onChangeNewLineMode(), - this.session.doc.on("changeNewLineMode", this.onChangeNewLineMode); - }), - (this.updateLines = function(e, t, n) { - t === undefined && (t = Infinity), - this.$changedLines - ? (this.$changedLines.firstRow > e && - (this.$changedLines.firstRow = e), - this.$changedLines.lastRow < t && - (this.$changedLines.lastRow = t)) - : (this.$changedLines = { firstRow: e, lastRow: t }); - if (this.$changedLines.lastRow < this.layerConfig.firstRow) { - if (!n) return; - this.$changedLines.lastRow = this.layerConfig.lastRow; - } - if (this.$changedLines.firstRow > this.layerConfig.lastRow) return; - this.$loop.schedule(this.CHANGE_LINES); - }), - (this.onChangeNewLineMode = function() { - this.$loop.schedule(this.CHANGE_TEXT), - this.$textLayer.$updateEolChar(); - }), - (this.onChangeTabSize = function() { - this.$loop.schedule(this.CHANGE_TEXT | this.CHANGE_MARKER), - this.$textLayer.onChangeTabSize(); - }), - (this.updateText = function() { - this.$loop.schedule(this.CHANGE_TEXT); - }), - (this.updateFull = function(e) { - e - ? this.$renderChanges(this.CHANGE_FULL, !0) - : this.$loop.schedule(this.CHANGE_FULL); - }), - (this.updateFontSize = function() { - this.$textLayer.checkForSizeChanges(); - }), - (this.$changes = 0), - (this.$updateSizeAsync = function() { - this.$loop.pending ? (this.$size.$dirty = !0) : this.onResize(); - }), - (this.onResize = function(e, t, n, r) { - if (this.resizing > 2) return; - this.resizing > 0 ? this.resizing++ : (this.resizing = e ? 1 : 0); - var i = this.container; - r || (r = i.clientHeight || i.scrollHeight), - n || (n = i.clientWidth || i.scrollWidth); - var s = this.$updateCachedSize(e, t, n, r); - if (!this.$size.scrollerHeight || (!n && !r)) - return (this.resizing = 0); - e && (this.$gutterLayer.$padding = null), + this.updateCharacterSize(), + this.setPadding(4), + s.resetOptions(this), + s._emit("renderer", this)); + }; + ((function () { + ((this.CHANGE_CURSOR = 1), + (this.CHANGE_MARKER = 2), + (this.CHANGE_GUTTER = 4), + (this.CHANGE_SCROLL = 8), + (this.CHANGE_LINES = 16), + (this.CHANGE_TEXT = 32), + (this.CHANGE_SIZE = 64), + (this.CHANGE_MARKER_BACK = 128), + (this.CHANGE_MARKER_FRONT = 256), + (this.CHANGE_FULL = 512), + (this.CHANGE_H_SCROLL = 1024), + r.implement(this, v), + (this.updateCharacterSize = function () { + (this.$textLayer.allowBoldFonts != this.$allowBoldFonts && + ((this.$allowBoldFonts = this.$textLayer.allowBoldFonts), + this.setStyle("ace_nobold", !this.$allowBoldFonts)), + (this.layerConfig.characterWidth = this.characterWidth = + this.$textLayer.getCharacterWidth()), + (this.layerConfig.lineHeight = this.lineHeight = + this.$textLayer.getLineHeight()), + this.$updatePrintMargin()); + }), + (this.setSession = function (e) { + (this.session && + this.session.doc.off( + "changeNewLineMode", + this.onChangeNewLineMode + ), + (this.session = e), + e && + this.scrollMargin.top && + e.getScrollTop() <= 0 && + e.setScrollTop(-this.scrollMargin.top), + this.$cursorLayer.setSession(e), + this.$markerBack.setSession(e), + this.$markerFront.setSession(e), + this.$gutterLayer.setSession(e), + this.$textLayer.setSession(e)); + if (!e) return; + (this.$loop.schedule(this.CHANGE_FULL), + this.session.$setFontMetrics(this.$fontMetrics), + (this.scrollBarV.scrollLeft = this.scrollBarV.scrollTop = null), + (this.onChangeNewLineMode = this.onChangeNewLineMode.bind(this)), + this.onChangeNewLineMode(), + this.session.doc.on( + "changeNewLineMode", + this.onChangeNewLineMode + )); + }), + (this.updateLines = function (e, t, n) { + (t === undefined && (t = Infinity), + this.$changedLines + ? (this.$changedLines.firstRow > e && + (this.$changedLines.firstRow = e), + this.$changedLines.lastRow < t && + (this.$changedLines.lastRow = t)) + : (this.$changedLines = { firstRow: e, lastRow: t })); + if (this.$changedLines.lastRow < this.layerConfig.firstRow) { + if (!n) return; + this.$changedLines.lastRow = this.layerConfig.lastRow; + } + if (this.$changedLines.firstRow > this.layerConfig.lastRow) return; + this.$loop.schedule(this.CHANGE_LINES); + }), + (this.onChangeNewLineMode = function () { + (this.$loop.schedule(this.CHANGE_TEXT), + this.$textLayer.$updateEolChar()); + }), + (this.onChangeTabSize = function () { + (this.$loop.schedule(this.CHANGE_TEXT | this.CHANGE_MARKER), + this.$textLayer.onChangeTabSize()); + }), + (this.updateText = function () { + this.$loop.schedule(this.CHANGE_TEXT); + }), + (this.updateFull = function (e) { e - ? this.$renderChanges(s | this.$changes, !0) - : this.$loop.schedule(s | this.$changes), - this.resizing && (this.resizing = 0), - (this.scrollBarV.scrollLeft = this.scrollBarV.scrollTop = null); - }), - (this.$updateCachedSize = function(e, t, n, r) { - r -= this.$extraHeight || 0; - var i = 0, - s = this.$size, - o = { - width: s.width, - height: s.height, - scrollerHeight: s.scrollerHeight, - scrollerWidth: s.scrollerWidth - }; - r && - (e || s.height != r) && - ((s.height = r), - (i |= this.CHANGE_SIZE), - (s.scrollerHeight = s.height), - this.$horizScroll && - (s.scrollerHeight -= this.scrollBarH.getHeight()), - (this.scrollBarV.element.style.bottom = - this.scrollBarH.getHeight() + "px"), - (i |= this.CHANGE_SCROLL)); - if (n && (e || s.width != n)) { - (i |= this.CHANGE_SIZE), - (s.width = n), - t == null && - (t = this.$showGutter ? this.$gutter.offsetWidth : 0), - (this.gutterWidth = t), - (this.scrollBarH.element.style.left = this.scroller.style.left = - t + "px"), - (s.scrollerWidth = Math.max( - 0, - n - t - this.scrollBarV.getWidth() - )), - (this.scrollBarH.element.style.right = this.scroller.style.right = - this.scrollBarV.getWidth() + "px"), - (this.scroller.style.bottom = this.scrollBarH.getHeight() + "px"); - if ( - (this.session && - this.session.getUseWrapMode() && - this.adjustWrapLimit()) || + ? this.$renderChanges(this.CHANGE_FULL, !0) + : this.$loop.schedule(this.CHANGE_FULL); + }), + (this.updateFontSize = function () { + this.$textLayer.checkForSizeChanges(); + }), + (this.$changes = 0), + (this.$updateSizeAsync = function () { + this.$loop.pending ? (this.$size.$dirty = !0) : this.onResize(); + }), + (this.onResize = function (e, t, n, r) { + if (this.resizing > 2) return; + this.resizing > 0 ? this.resizing++ : (this.resizing = e ? 1 : 0); + var i = this.container; + (r || (r = i.clientHeight || i.scrollHeight), + n || (n = i.clientWidth || i.scrollWidth)); + var s = this.$updateCachedSize(e, t, n, r); + if (!this.$size.scrollerHeight || (!n && !r)) + return (this.resizing = 0); + (e && (this.$gutterLayer.$padding = null), e - ) - i |= this.CHANGE_FULL; - } - return (s.$dirty = !n || !r), i && this._signal("resize", o), i; - }), - (this.onGutterResize = function() { - var e = this.$showGutter ? this.$gutter.offsetWidth : 0; - e != this.gutterWidth && - (this.$changes |= this.$updateCachedSize( - !0, - e, - this.$size.width, - this.$size.height - )), - this.session.getUseWrapMode() && this.adjustWrapLimit() - ? this.$loop.schedule(this.CHANGE_FULL) - : this.$size.$dirty - ? this.$loop.schedule(this.CHANGE_FULL) - : (this.$computeLayerConfig(), - this.$loop.schedule(this.CHANGE_MARKER)); - }), - (this.adjustWrapLimit = function() { - var e = this.$size.scrollerWidth - this.$padding * 2, - t = Math.floor(e / this.characterWidth); - return this.session.adjustWrapLimit( - t, - this.$showPrintMargin && this.$printMarginColumn - ); - }), - (this.setAnimatedScroll = function(e) { - this.setOption("animatedScroll", e); - }), - (this.getAnimatedScroll = function() { - return this.$animatedScroll; - }), - (this.setShowInvisibles = function(e) { - this.setOption("showInvisibles", e); - }), - (this.getShowInvisibles = function() { - return this.getOption("showInvisibles"); - }), - (this.getDisplayIndentGuides = function() { - return this.getOption("displayIndentGuides"); - }), - (this.setDisplayIndentGuides = function(e) { - this.setOption("displayIndentGuides", e); - }), - (this.setShowPrintMargin = function(e) { - this.setOption("showPrintMargin", e); - }), - (this.getShowPrintMargin = function() { - return this.getOption("showPrintMargin"); - }), - (this.setPrintMarginColumn = function(e) { - this.setOption("printMarginColumn", e); - }), - (this.getPrintMarginColumn = function() { - return this.getOption("printMarginColumn"); - }), - (this.getShowGutter = function() { - return this.getOption("showGutter"); - }), - (this.setShowGutter = function(e) { - return this.setOption("showGutter", e); - }), - (this.getFadeFoldWidgets = function() { - return this.getOption("fadeFoldWidgets"); - }), - (this.setFadeFoldWidgets = function(e) { - this.setOption("fadeFoldWidgets", e); - }), - (this.setHighlightGutterLine = function(e) { - this.setOption("highlightGutterLine", e); - }), - (this.getHighlightGutterLine = function() { - return this.getOption("highlightGutterLine"); - }), - (this.$updateGutterLineHighlight = function() { - var e = this.$cursorLayer.$pixelPos, - t = this.layerConfig.lineHeight; - if (this.session.getUseWrapMode()) { - var n = this.session.selection.getCursor(); - (n.column = 0), - (e = this.$cursorLayer.getPixelPosition(n, !0)), - (t *= this.session.getRowLength(n.row)); - } - (this.$gutterLineHighlight.style.top = - e.top - this.layerConfig.offset + "px"), - (this.$gutterLineHighlight.style.height = t + "px"); - }), - (this.$updatePrintMargin = function() { - if (!this.$showPrintMargin && !this.$printMarginEl) return; - if (!this.$printMarginEl) { - var e = i.createElement("div"); - (e.className = "ace_layer ace_print-margin-layer"), - (this.$printMarginEl = i.createElement("div")), - (this.$printMarginEl.className = "ace_print-margin"), - e.appendChild(this.$printMarginEl), - this.content.insertBefore(e, this.content.firstChild); - } - var t = this.$printMarginEl.style; - (t.left = - this.characterWidth * this.$printMarginColumn + - this.$padding + - "px"), - (t.visibility = this.$showPrintMargin ? "visible" : "hidden"), - this.session && this.session.$wrap == -1 && this.adjustWrapLimit(); - }), - (this.getContainerElement = function() { - return this.container; - }), - (this.getMouseEventTarget = function() { - return this.scroller; - }), - (this.getTextAreaContainer = function() { - return this.container; - }), - (this.$moveTextAreaToCursor = function() { - if (!this.$keepTextAreaAtCursor) return; - var e = this.layerConfig, - t = this.$cursorLayer.$pixelPos.top, - n = this.$cursorLayer.$pixelPos.left; - t -= e.offset; - var r = this.textarea.style, - i = this.lineHeight; - if (t < 0 || t > e.height - i) { - r.top = r.left = "0"; - return; - } - var s = this.characterWidth; - if (this.$composition) { - var o = this.textarea.value.replace(/^\x01+/, ""); - (s *= this.session.$getStringScreenWidth(o)[0] + 2), (i += 2); - } - (n -= this.scrollLeft), - n > this.$size.scrollerWidth - s && - (n = this.$size.scrollerWidth - s), - (n += this.gutterWidth), - (r.height = i + "px"), - (r.width = s + "px"), - (r.left = Math.min(n, this.$size.scrollerWidth - s) + "px"), - (r.top = Math.min(t, this.$size.height - i) + "px"); - }), - (this.getFirstVisibleRow = function() { - return this.layerConfig.firstRow; - }), - (this.getFirstFullyVisibleRow = function() { - return ( - this.layerConfig.firstRow + (this.layerConfig.offset === 0 ? 0 : 1) - ); - }), - (this.getLastFullyVisibleRow = function() { - var e = this.layerConfig, - t = e.lastRow, - n = this.session.documentToScreenRow(t, 0) * e.lineHeight; - return n - this.session.getScrollTop() > e.height - e.lineHeight - ? t - 1 - : t; - }), - (this.getLastVisibleRow = function() { - return this.layerConfig.lastRow; - }), - (this.$padding = null), - (this.setPadding = function(e) { - (this.$padding = e), - this.$textLayer.setPadding(e), - this.$cursorLayer.setPadding(e), - this.$markerFront.setPadding(e), - this.$markerBack.setPadding(e), - this.$loop.schedule(this.CHANGE_FULL), - this.$updatePrintMargin(); - }), - (this.setScrollMargin = function(e, t, n, r) { - var i = this.scrollMargin; - (i.top = e | 0), - (i.bottom = t | 0), - (i.right = r | 0), - (i.left = n | 0), - (i.v = i.top + i.bottom), - (i.h = i.left + i.right), - i.top && - this.scrollTop <= 0 && - this.session && - this.session.setScrollTop(-i.top), - this.updateFull(); - }), - (this.getHScrollBarAlwaysVisible = function() { - return this.$hScrollBarAlwaysVisible; - }), - (this.setHScrollBarAlwaysVisible = function(e) { - this.setOption("hScrollBarAlwaysVisible", e); - }), - (this.getVScrollBarAlwaysVisible = function() { - return this.$vScrollBarAlwaysVisible; - }), - (this.setVScrollBarAlwaysVisible = function(e) { - this.setOption("vScrollBarAlwaysVisible", e); - }), - (this.$updateScrollBarV = function() { - var e = this.layerConfig.maxHeight, - t = this.$size.scrollerHeight; - !this.$maxLines && - this.$scrollPastEnd && - ((e -= (t - this.lineHeight) * this.$scrollPastEnd), - this.scrollTop > e - t && - ((e = this.scrollTop + t), (this.scrollBarV.scrollTop = null))), - this.scrollBarV.setScrollHeight(e + this.scrollMargin.v), - this.scrollBarV.setScrollTop( - this.scrollTop + this.scrollMargin.top + ? this.$renderChanges(s | this.$changes, !0) + : this.$loop.schedule(s | this.$changes), + this.resizing && (this.resizing = 0), + (this.scrollBarV.scrollLeft = this.scrollBarV.scrollTop = null)); + }), + (this.$updateCachedSize = function (e, t, n, r) { + r -= this.$extraHeight || 0; + var i = 0, + s = this.$size, + o = { + width: s.width, + height: s.height, + scrollerHeight: s.scrollerHeight, + scrollerWidth: s.scrollerWidth + }; + r && + (e || s.height != r) && + ((s.height = r), + (i |= this.CHANGE_SIZE), + (s.scrollerHeight = s.height), + this.$horizScroll && + (s.scrollerHeight -= this.scrollBarH.getHeight()), + (this.scrollBarV.element.style.bottom = + this.scrollBarH.getHeight() + "px"), + (i |= this.CHANGE_SCROLL)); + if (n && (e || s.width != n)) { + ((i |= this.CHANGE_SIZE), + (s.width = n), + t == null && + (t = this.$showGutter ? this.$gutter.offsetWidth : 0), + (this.gutterWidth = t), + (this.scrollBarH.element.style.left = this.scroller.style.left = + t + "px"), + (s.scrollerWidth = Math.max( + 0, + n - t - this.scrollBarV.getWidth() + )), + (this.scrollBarH.element.style.right = + this.scroller.style.right = + this.scrollBarV.getWidth() + "px"), + (this.scroller.style.bottom = + this.scrollBarH.getHeight() + "px")); + if ( + (this.session && + this.session.getUseWrapMode() && + this.adjustWrapLimit()) || + e + ) + i |= this.CHANGE_FULL; + } + return ((s.$dirty = !n || !r), i && this._signal("resize", o), i); + }), + (this.onGutterResize = function () { + var e = this.$showGutter ? this.$gutter.offsetWidth : 0; + (e != this.gutterWidth && + (this.$changes |= this.$updateCachedSize( + !0, + e, + this.$size.width, + this.$size.height + )), + this.session.getUseWrapMode() && this.adjustWrapLimit() + ? this.$loop.schedule(this.CHANGE_FULL) + : this.$size.$dirty + ? this.$loop.schedule(this.CHANGE_FULL) + : (this.$computeLayerConfig(), + this.$loop.schedule(this.CHANGE_MARKER))); + }), + (this.adjustWrapLimit = function () { + var e = this.$size.scrollerWidth - this.$padding * 2, + t = Math.floor(e / this.characterWidth); + return this.session.adjustWrapLimit( + t, + this.$showPrintMargin && this.$printMarginColumn ); - }), - (this.$updateScrollBarH = function() { - this.scrollBarH.setScrollWidth( - this.layerConfig.width + 2 * this.$padding + this.scrollMargin.h - ), - this.scrollBarH.setScrollLeft( - this.scrollLeft + this.scrollMargin.left + }), + (this.setAnimatedScroll = function (e) { + this.setOption("animatedScroll", e); + }), + (this.getAnimatedScroll = function () { + return this.$animatedScroll; + }), + (this.setShowInvisibles = function (e) { + this.setOption("showInvisibles", e); + }), + (this.getShowInvisibles = function () { + return this.getOption("showInvisibles"); + }), + (this.getDisplayIndentGuides = function () { + return this.getOption("displayIndentGuides"); + }), + (this.setDisplayIndentGuides = function (e) { + this.setOption("displayIndentGuides", e); + }), + (this.setShowPrintMargin = function (e) { + this.setOption("showPrintMargin", e); + }), + (this.getShowPrintMargin = function () { + return this.getOption("showPrintMargin"); + }), + (this.setPrintMarginColumn = function (e) { + this.setOption("printMarginColumn", e); + }), + (this.getPrintMarginColumn = function () { + return this.getOption("printMarginColumn"); + }), + (this.getShowGutter = function () { + return this.getOption("showGutter"); + }), + (this.setShowGutter = function (e) { + return this.setOption("showGutter", e); + }), + (this.getFadeFoldWidgets = function () { + return this.getOption("fadeFoldWidgets"); + }), + (this.setFadeFoldWidgets = function (e) { + this.setOption("fadeFoldWidgets", e); + }), + (this.setHighlightGutterLine = function (e) { + this.setOption("highlightGutterLine", e); + }), + (this.getHighlightGutterLine = function () { + return this.getOption("highlightGutterLine"); + }), + (this.$updateGutterLineHighlight = function () { + var e = this.$cursorLayer.$pixelPos, + t = this.layerConfig.lineHeight; + if (this.session.getUseWrapMode()) { + var n = this.session.selection.getCursor(); + ((n.column = 0), + (e = this.$cursorLayer.getPixelPosition(n, !0)), + (t *= this.session.getRowLength(n.row))); + } + ((this.$gutterLineHighlight.style.top = + e.top - this.layerConfig.offset + "px"), + (this.$gutterLineHighlight.style.height = t + "px")); + }), + (this.$updatePrintMargin = function () { + if (!this.$showPrintMargin && !this.$printMarginEl) return; + if (!this.$printMarginEl) { + var e = i.createElement("div"); + ((e.className = "ace_layer ace_print-margin-layer"), + (this.$printMarginEl = i.createElement("div")), + (this.$printMarginEl.className = "ace_print-margin"), + e.appendChild(this.$printMarginEl), + this.content.insertBefore(e, this.content.firstChild)); + } + var t = this.$printMarginEl.style; + ((t.left = + this.characterWidth * this.$printMarginColumn + + this.$padding + + "px"), + (t.visibility = this.$showPrintMargin ? "visible" : "hidden"), + this.session && + this.session.$wrap == -1 && + this.adjustWrapLimit()); + }), + (this.getContainerElement = function () { + return this.container; + }), + (this.getMouseEventTarget = function () { + return this.scroller; + }), + (this.getTextAreaContainer = function () { + return this.container; + }), + (this.$moveTextAreaToCursor = function () { + if (!this.$keepTextAreaAtCursor) return; + var e = this.layerConfig, + t = this.$cursorLayer.$pixelPos.top, + n = this.$cursorLayer.$pixelPos.left; + t -= e.offset; + var r = this.textarea.style, + i = this.lineHeight; + if (t < 0 || t > e.height - i) { + r.top = r.left = "0"; + return; + } + var s = this.characterWidth; + if (this.$composition) { + var o = this.textarea.value.replace(/^\x01+/, ""); + ((s *= this.session.$getStringScreenWidth(o)[0] + 2), (i += 2)); + } + ((n -= this.scrollLeft), + n > this.$size.scrollerWidth - s && + (n = this.$size.scrollerWidth - s), + (n += this.gutterWidth), + (r.height = i + "px"), + (r.width = s + "px"), + (r.left = Math.min(n, this.$size.scrollerWidth - s) + "px"), + (r.top = Math.min(t, this.$size.height - i) + "px")); + }), + (this.getFirstVisibleRow = function () { + return this.layerConfig.firstRow; + }), + (this.getFirstFullyVisibleRow = function () { + return ( + this.layerConfig.firstRow + + (this.layerConfig.offset === 0 ? 0 : 1) ); - }), - (this.$frozen = !1), - (this.freeze = function() { - this.$frozen = !0; - }), - (this.unfreeze = function() { - this.$frozen = !1; - }), - (this.$renderChanges = function(e, t) { - this.$changes && ((e |= this.$changes), (this.$changes = 0)); - if ( - !this.session || - !this.container.offsetWidth || - this.$frozen || - (!e && !t) - ) { - this.$changes |= e; - return; - } - if (this.$size.$dirty) return (this.$changes |= e), this.onResize(!0); - this.lineHeight || this.$textLayer.checkForSizeChanges(), - this._signal("beforeRender"); - var n = this.layerConfig; - if ( - e & this.CHANGE_FULL || - e & this.CHANGE_SIZE || - e & this.CHANGE_TEXT || - e & this.CHANGE_LINES || - e & this.CHANGE_SCROLL || - e & this.CHANGE_H_SCROLL - ) { - e |= this.$computeLayerConfig(); + }), + (this.getLastFullyVisibleRow = function () { + var e = this.layerConfig, + t = e.lastRow, + n = this.session.documentToScreenRow(t, 0) * e.lineHeight; + return n - this.session.getScrollTop() > e.height - e.lineHeight + ? t - 1 + : t; + }), + (this.getLastVisibleRow = function () { + return this.layerConfig.lastRow; + }), + (this.$padding = null), + (this.setPadding = function (e) { + ((this.$padding = e), + this.$textLayer.setPadding(e), + this.$cursorLayer.setPadding(e), + this.$markerFront.setPadding(e), + this.$markerBack.setPadding(e), + this.$loop.schedule(this.CHANGE_FULL), + this.$updatePrintMargin()); + }), + (this.setScrollMargin = function (e, t, n, r) { + var i = this.scrollMargin; + ((i.top = e | 0), + (i.bottom = t | 0), + (i.right = r | 0), + (i.left = n | 0), + (i.v = i.top + i.bottom), + (i.h = i.left + i.right), + i.top && + this.scrollTop <= 0 && + this.session && + this.session.setScrollTop(-i.top), + this.updateFull()); + }), + (this.getHScrollBarAlwaysVisible = function () { + return this.$hScrollBarAlwaysVisible; + }), + (this.setHScrollBarAlwaysVisible = function (e) { + this.setOption("hScrollBarAlwaysVisible", e); + }), + (this.getVScrollBarAlwaysVisible = function () { + return this.$vScrollBarAlwaysVisible; + }), + (this.setVScrollBarAlwaysVisible = function (e) { + this.setOption("vScrollBarAlwaysVisible", e); + }), + (this.$updateScrollBarV = function () { + var e = this.layerConfig.maxHeight, + t = this.$size.scrollerHeight; + (!this.$maxLines && + this.$scrollPastEnd && + ((e -= (t - this.lineHeight) * this.$scrollPastEnd), + this.scrollTop > e - t && + ((e = this.scrollTop + t), (this.scrollBarV.scrollTop = null))), + this.scrollBarV.setScrollHeight(e + this.scrollMargin.v), + this.scrollBarV.setScrollTop( + this.scrollTop + this.scrollMargin.top + )); + }), + (this.$updateScrollBarH = function () { + (this.scrollBarH.setScrollWidth( + this.layerConfig.width + 2 * this.$padding + this.scrollMargin.h + ), + this.scrollBarH.setScrollLeft( + this.scrollLeft + this.scrollMargin.left + )); + }), + (this.$frozen = !1), + (this.freeze = function () { + this.$frozen = !0; + }), + (this.unfreeze = function () { + this.$frozen = !1; + }), + (this.$renderChanges = function (e, t) { + this.$changes && ((e |= this.$changes), (this.$changes = 0)); if ( - n.firstRow != this.layerConfig.firstRow && - n.firstRowScreen == this.layerConfig.firstRowScreen + !this.session || + !this.container.offsetWidth || + this.$frozen || + (!e && !t) ) { - var r = - this.scrollTop + - (n.firstRow - this.layerConfig.firstRow) * this.lineHeight; - r > 0 && - ((this.scrollTop = r), - (e |= this.CHANGE_SCROLL), - (e |= this.$computeLayerConfig())); - } - (n = this.layerConfig), - this.$updateScrollBarV(), - e & this.CHANGE_H_SCROLL && this.$updateScrollBarH(), - (this.$gutterLayer.element.style.marginTop = -n.offset + "px"), - (this.content.style.marginTop = -n.offset + "px"), - (this.content.style.width = n.width + 2 * this.$padding + "px"), - (this.content.style.height = n.minHeight + "px"); - } - e & this.CHANGE_H_SCROLL && - ((this.content.style.marginLeft = -this.scrollLeft + "px"), - (this.scroller.className = - this.scrollLeft <= 0 - ? "ace_scroller" - : "ace_scroller ace_scroll-left")); - if (e & this.CHANGE_FULL) { - this.$textLayer.update(n), - this.$showGutter && this.$gutterLayer.update(n), - this.$markerBack.update(n), - this.$markerFront.update(n), - this.$cursorLayer.update(n), - this.$moveTextAreaToCursor(), - this.$highlightGutterLine && this.$updateGutterLineHighlight(), - this._signal("afterRender"); - return; - } - if (e & this.CHANGE_SCROLL) { - e & this.CHANGE_TEXT || e & this.CHANGE_LINES - ? this.$textLayer.update(n) - : this.$textLayer.scrollLines(n), - this.$showGutter && this.$gutterLayer.update(n), - this.$markerBack.update(n), - this.$markerFront.update(n), - this.$cursorLayer.update(n), - this.$highlightGutterLine && this.$updateGutterLineHighlight(), - this.$moveTextAreaToCursor(), - this._signal("afterRender"); - return; - } - e & this.CHANGE_TEXT - ? (this.$textLayer.update(n), - this.$showGutter && this.$gutterLayer.update(n)) - : e & this.CHANGE_LINES - ? (this.$updateLines() || - (e & this.CHANGE_GUTTER && this.$showGutter)) && - this.$gutterLayer.update(n) - : (e & this.CHANGE_TEXT || e & this.CHANGE_GUTTER) && - this.$showGutter && - this.$gutterLayer.update(n), - e & this.CHANGE_CURSOR && - (this.$cursorLayer.update(n), - this.$moveTextAreaToCursor(), - this.$highlightGutterLine && this.$updateGutterLineHighlight()), - e & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT) && - this.$markerFront.update(n), - e & (this.CHANGE_MARKER | this.CHANGE_MARKER_BACK) && - this.$markerBack.update(n), - this._signal("afterRender"); - }), - (this.$autosize = function() { - var e = this.session.getScreenLength() * this.lineHeight, - t = this.$maxLines * this.lineHeight, - n = - Math.min( - t, - Math.max((this.$minLines || 1) * this.lineHeight, e) - ) + - this.scrollMargin.v + - (this.$extraHeight || 0); - this.$horizScroll && (n += this.scrollBarH.getHeight()), - this.$maxPixelHeight && - n > this.$maxPixelHeight && - (n = this.$maxPixelHeight); - var r = e > t; - if ( - n != this.desiredHeight || - this.$size.height != this.desiredHeight || - r != this.$vScroll - ) { - r != this.$vScroll && - ((this.$vScroll = r), this.scrollBarV.setVisible(r)); - var i = this.container.clientWidth; - (this.container.style.height = n + "px"), - this.$updateCachedSize(!0, this.$gutterWidth, i, n), - (this.desiredHeight = n), - this._signal("autosize"); - } - }), - (this.$computeLayerConfig = function() { - var e = this.session, - t = this.$size, - n = t.height <= 2 * this.lineHeight, - r = this.session.getScreenLength(), - i = r * this.lineHeight, - s = this.$getLongestLine(), - o = - !n && - (this.$hScrollBarAlwaysVisible || - t.scrollerWidth - s - 2 * this.$padding < 0), - u = this.$horizScroll !== o; - u && ((this.$horizScroll = o), this.scrollBarH.setVisible(o)); - var a = this.$vScroll; - this.$maxLines && this.lineHeight > 1 && this.$autosize(); - var f = this.scrollTop % this.lineHeight, - l = t.scrollerHeight + this.lineHeight, - c = - !this.$maxLines && this.$scrollPastEnd - ? (t.scrollerHeight - this.lineHeight) * this.$scrollPastEnd - : 0; - i += c; - var h = this.scrollMargin; - this.session.setScrollTop( - Math.max( - -h.top, - Math.min(this.scrollTop, i - t.scrollerHeight + h.bottom) - ) - ), - this.session.setScrollLeft( - Math.max( - -h.left, + this.$changes |= e; + return; + } + if (this.$size.$dirty) + return ((this.$changes |= e), this.onResize(!0)); + (this.lineHeight || this.$textLayer.checkForSizeChanges(), + this._signal("beforeRender")); + var n = this.layerConfig; + if ( + e & this.CHANGE_FULL || + e & this.CHANGE_SIZE || + e & this.CHANGE_TEXT || + e & this.CHANGE_LINES || + e & this.CHANGE_SCROLL || + e & this.CHANGE_H_SCROLL + ) { + e |= this.$computeLayerConfig(); + if ( + n.firstRow != this.layerConfig.firstRow && + n.firstRowScreen == this.layerConfig.firstRowScreen + ) { + var r = + this.scrollTop + + (n.firstRow - this.layerConfig.firstRow) * this.lineHeight; + r > 0 && + ((this.scrollTop = r), + (e |= this.CHANGE_SCROLL), + (e |= this.$computeLayerConfig())); + } + ((n = this.layerConfig), + this.$updateScrollBarV(), + e & this.CHANGE_H_SCROLL && this.$updateScrollBarH(), + (this.$gutterLayer.element.style.marginTop = -n.offset + "px"), + (this.content.style.marginTop = -n.offset + "px"), + (this.content.style.width = n.width + 2 * this.$padding + "px"), + (this.content.style.height = n.minHeight + "px")); + } + e & this.CHANGE_H_SCROLL && + ((this.content.style.marginLeft = -this.scrollLeft + "px"), + (this.scroller.className = + this.scrollLeft <= 0 + ? "ace_scroller" + : "ace_scroller ace_scroll-left")); + if (e & this.CHANGE_FULL) { + (this.$textLayer.update(n), + this.$showGutter && this.$gutterLayer.update(n), + this.$markerBack.update(n), + this.$markerFront.update(n), + this.$cursorLayer.update(n), + this.$moveTextAreaToCursor(), + this.$highlightGutterLine && this.$updateGutterLineHighlight(), + this._signal("afterRender")); + return; + } + if (e & this.CHANGE_SCROLL) { + (e & this.CHANGE_TEXT || e & this.CHANGE_LINES + ? this.$textLayer.update(n) + : this.$textLayer.scrollLines(n), + this.$showGutter && this.$gutterLayer.update(n), + this.$markerBack.update(n), + this.$markerFront.update(n), + this.$cursorLayer.update(n), + this.$highlightGutterLine && this.$updateGutterLineHighlight(), + this.$moveTextAreaToCursor(), + this._signal("afterRender")); + return; + } + (e & this.CHANGE_TEXT + ? (this.$textLayer.update(n), + this.$showGutter && this.$gutterLayer.update(n)) + : e & this.CHANGE_LINES + ? (this.$updateLines() || + (e & this.CHANGE_GUTTER && this.$showGutter)) && + this.$gutterLayer.update(n) + : (e & this.CHANGE_TEXT || e & this.CHANGE_GUTTER) && + this.$showGutter && + this.$gutterLayer.update(n), + e & this.CHANGE_CURSOR && + (this.$cursorLayer.update(n), + this.$moveTextAreaToCursor(), + this.$highlightGutterLine && this.$updateGutterLineHighlight()), + e & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT) && + this.$markerFront.update(n), + e & (this.CHANGE_MARKER | this.CHANGE_MARKER_BACK) && + this.$markerBack.update(n), + this._signal("afterRender")); + }), + (this.$autosize = function () { + var e = this.session.getScreenLength() * this.lineHeight, + t = this.$maxLines * this.lineHeight, + n = Math.min( - this.scrollLeft, - s + 2 * this.$padding - t.scrollerWidth + h.right + t, + Math.max((this.$minLines || 1) * this.lineHeight, e) + ) + + this.scrollMargin.v + + (this.$extraHeight || 0); + (this.$horizScroll && (n += this.scrollBarH.getHeight()), + this.$maxPixelHeight && + n > this.$maxPixelHeight && + (n = this.$maxPixelHeight)); + var r = e > t; + if ( + n != this.desiredHeight || + this.$size.height != this.desiredHeight || + r != this.$vScroll + ) { + r != this.$vScroll && + ((this.$vScroll = r), this.scrollBarV.setVisible(r)); + var i = this.container.clientWidth; + ((this.container.style.height = n + "px"), + this.$updateCachedSize(!0, this.$gutterWidth, i, n), + (this.desiredHeight = n), + this._signal("autosize")); + } + }), + (this.$computeLayerConfig = function () { + var e = this.session, + t = this.$size, + n = t.height <= 2 * this.lineHeight, + r = this.session.getScreenLength(), + i = r * this.lineHeight, + s = this.$getLongestLine(), + o = + !n && + (this.$hScrollBarAlwaysVisible || + t.scrollerWidth - s - 2 * this.$padding < 0), + u = this.$horizScroll !== o; + u && ((this.$horizScroll = o), this.scrollBarH.setVisible(o)); + var a = this.$vScroll; + this.$maxLines && this.lineHeight > 1 && this.$autosize(); + var f = this.scrollTop % this.lineHeight, + l = t.scrollerHeight + this.lineHeight, + c = + !this.$maxLines && this.$scrollPastEnd + ? (t.scrollerHeight - this.lineHeight) * this.$scrollPastEnd + : 0; + i += c; + var h = this.scrollMargin; + (this.session.setScrollTop( + Math.max( + -h.top, + Math.min(this.scrollTop, i - t.scrollerHeight + h.bottom) + ) + ), + this.session.setScrollLeft( + Math.max( + -h.left, + Math.min( + this.scrollLeft, + s + 2 * this.$padding - t.scrollerWidth + h.right + ) ) + )); + var p = + !n && + (this.$vScrollBarAlwaysVisible || + t.scrollerHeight - i + c < 0 || + this.scrollTop > h.top), + d = a !== p; + d && ((this.$vScroll = p), this.scrollBarV.setVisible(p)); + var v = Math.ceil(l / this.lineHeight) - 1, + m = Math.max( + 0, + Math.round((this.scrollTop - f) / this.lineHeight) + ), + g = m + v, + y, + b, + w = this.lineHeight; + m = e.screenToDocumentRow(m, 0); + var E = e.getFoldLine(m); + (E && (m = E.start.row), + (y = e.documentToScreenRow(m, 0)), + (b = e.getRowLength(m) * w), + (g = Math.min(e.screenToDocumentRow(g, 0), e.getLength() - 1)), + (l = t.scrollerHeight + e.getRowLength(g) * w + b), + (f = this.scrollTop - y * w)); + var S = 0; + this.layerConfig.width != s && (S = this.CHANGE_H_SCROLL); + if (u || d) + ((S = this.$updateCachedSize( + !0, + this.gutterWidth, + t.width, + t.height + )), + this._signal("scrollbarVisibilityChanged"), + d && (s = this.$getLongestLine())); + return ( + (this.layerConfig = { + width: s, + padding: this.$padding, + firstRow: m, + firstRowScreen: y, + lastRow: g, + lineHeight: w, + characterWidth: this.characterWidth, + minHeight: l, + maxHeight: i, + offset: f, + gutterOffset: w + ? Math.max( + 0, + Math.ceil((f + t.height - t.scrollerHeight) / w) + ) + : 0, + height: this.$size.scrollerHeight + }), + S + ); + }), + (this.$updateLines = function () { + var e = this.$changedLines.firstRow, + t = this.$changedLines.lastRow; + this.$changedLines = null; + var n = this.layerConfig; + if (e > n.lastRow + 1) return; + if (t < n.firstRow) return; + if (t === Infinity) { + (this.$showGutter && this.$gutterLayer.update(n), + this.$textLayer.update(n)); + return; + } + return (this.$textLayer.updateLines(n, e, t), !0); + }), + (this.$getLongestLine = function () { + var e = this.session.getScreenWidth(); + return ( + this.showInvisibles && !this.session.$useWrapMode && (e += 1), + Math.max( + this.$size.scrollerWidth - 2 * this.$padding, + Math.round(e * this.characterWidth) ) ); - var p = - !n && - (this.$vScrollBarAlwaysVisible || - t.scrollerHeight - i + c < 0 || - this.scrollTop > h.top), - d = a !== p; - d && ((this.$vScroll = p), this.scrollBarV.setVisible(p)); - var v = Math.ceil(l / this.lineHeight) - 1, - m = Math.max(0, Math.round((this.scrollTop - f) / this.lineHeight)), - g = m + v, - y, - b, - w = this.lineHeight; - m = e.screenToDocumentRow(m, 0); - var E = e.getFoldLine(m); - E && (m = E.start.row), - (y = e.documentToScreenRow(m, 0)), - (b = e.getRowLength(m) * w), - (g = Math.min(e.screenToDocumentRow(g, 0), e.getLength() - 1)), - (l = t.scrollerHeight + e.getRowLength(g) * w + b), - (f = this.scrollTop - y * w); - var S = 0; - this.layerConfig.width != s && (S = this.CHANGE_H_SCROLL); - if (u || d) - (S = this.$updateCachedSize( - !0, - this.gutterWidth, - t.width, - t.height - )), - this._signal("scrollbarVisibilityChanged"), - d && (s = this.$getLongestLine()); - return ( - (this.layerConfig = { - width: s, - padding: this.$padding, - firstRow: m, - firstRowScreen: y, - lastRow: g, - lineHeight: w, - characterWidth: this.characterWidth, - minHeight: l, - maxHeight: i, - offset: f, - gutterOffset: w - ? Math.max(0, Math.ceil((f + t.height - t.scrollerHeight) / w)) - : 0, - height: this.$size.scrollerHeight - }), - S - ); - }), - (this.$updateLines = function() { - var e = this.$changedLines.firstRow, - t = this.$changedLines.lastRow; - this.$changedLines = null; - var n = this.layerConfig; - if (e > n.lastRow + 1) return; - if (t < n.firstRow) return; - if (t === Infinity) { - this.$showGutter && this.$gutterLayer.update(n), - this.$textLayer.update(n); - return; - } - return this.$textLayer.updateLines(n, e, t), !0; - }), - (this.$getLongestLine = function() { - var e = this.session.getScreenWidth(); - return ( - this.showInvisibles && !this.session.$useWrapMode && (e += 1), - Math.max( - this.$size.scrollerWidth - 2 * this.$padding, - Math.round(e * this.characterWidth) - ) - ); - }), - (this.updateFrontMarkers = function() { - this.$markerFront.setMarkers(this.session.getMarkers(!0)), - this.$loop.schedule(this.CHANGE_MARKER_FRONT); - }), - (this.updateBackMarkers = function() { - this.$markerBack.setMarkers(this.session.getMarkers()), - this.$loop.schedule(this.CHANGE_MARKER_BACK); - }), - (this.addGutterDecoration = function(e, t) { - this.$gutterLayer.addGutterDecoration(e, t); - }), - (this.removeGutterDecoration = function(e, t) { - this.$gutterLayer.removeGutterDecoration(e, t); - }), - (this.updateBreakpoints = function(e) { - this.$loop.schedule(this.CHANGE_GUTTER); - }), - (this.setAnnotations = function(e) { - this.$gutterLayer.setAnnotations(e), + }), + (this.updateFrontMarkers = function () { + (this.$markerFront.setMarkers(this.session.getMarkers(!0)), + this.$loop.schedule(this.CHANGE_MARKER_FRONT)); + }), + (this.updateBackMarkers = function () { + (this.$markerBack.setMarkers(this.session.getMarkers()), + this.$loop.schedule(this.CHANGE_MARKER_BACK)); + }), + (this.addGutterDecoration = function (e, t) { + this.$gutterLayer.addGutterDecoration(e, t); + }), + (this.removeGutterDecoration = function (e, t) { + this.$gutterLayer.removeGutterDecoration(e, t); + }), + (this.updateBreakpoints = function (e) { this.$loop.schedule(this.CHANGE_GUTTER); - }), - (this.updateCursor = function() { - this.$loop.schedule(this.CHANGE_CURSOR); - }), - (this.hideCursor = function() { - this.$cursorLayer.hideCursor(); - }), - (this.showCursor = function() { - this.$cursorLayer.showCursor(); - }), - (this.scrollSelectionIntoView = function(e, t, n) { - this.scrollCursorIntoView(e, n), this.scrollCursorIntoView(t, n); - }), - (this.scrollCursorIntoView = function(e, t, n) { - if (this.$size.scrollerHeight === 0) return; - var r = this.$cursorLayer.getPixelPosition(e), - i = r.left, - s = r.top, - o = (n && n.top) || 0, - u = (n && n.bottom) || 0, - a = this.$scrollAnimation - ? this.session.getScrollTop() - : this.scrollTop; - a + o > s - ? (t && - a + o > s + this.lineHeight && - (s -= t * this.$size.scrollerHeight), - s === 0 && (s = -this.scrollMargin.top), - this.session.setScrollTop(s)) - : a + this.$size.scrollerHeight - u < s + this.lineHeight && - (t && - a + this.$size.scrollerHeight - u < s - this.lineHeight && - (s += t * this.$size.scrollerHeight), - this.session.setScrollTop( - s + this.lineHeight - this.$size.scrollerHeight - )); - var f = this.scrollLeft; - f > i - ? (i < this.$padding + 2 * this.layerConfig.characterWidth && - (i = -this.scrollMargin.left), - this.session.setScrollLeft(i)) - : f + this.$size.scrollerWidth < i + this.characterWidth - ? this.session.setScrollLeft( - Math.round(i + this.characterWidth - this.$size.scrollerWidth) - ) - : f <= this.$padding && - i - f < this.characterWidth && - this.session.setScrollLeft(0); - }), - (this.getScrollTop = function() { - return this.session.getScrollTop(); - }), - (this.getScrollLeft = function() { - return this.session.getScrollLeft(); - }), - (this.getScrollTopRow = function() { - return this.scrollTop / this.lineHeight; - }), - (this.getScrollBottomRow = function() { - return Math.max( - 0, - Math.floor( - (this.scrollTop + this.$size.scrollerHeight) / this.lineHeight - ) - 1 - ); - }), - (this.scrollToRow = function(e) { - this.session.setScrollTop(e * this.lineHeight); - }), - (this.alignCursor = function(e, t) { - typeof e == "number" && (e = { row: e, column: 0 }); - var n = this.$cursorLayer.getPixelPosition(e), - r = this.$size.scrollerHeight - this.lineHeight, - i = n.top - r * (t || 0); - return this.session.setScrollTop(i), i; - }), - (this.STEPS = 8), - (this.$calcSteps = function(e, t) { - var n = 0, - r = this.STEPS, - i = [], - s = function(e, t, n) { - return n * (Math.pow(e - 1, 3) + 1) + t; - }; - for (n = 0; n < r; ++n) i.push(s(n / this.STEPS, e, t - e)); - return i; - }), - (this.scrollToLine = function(e, t, n, r) { - var i = this.$cursorLayer.getPixelPosition({ row: e, column: 0 }), - s = i.top; - t && (s -= this.$size.scrollerHeight / 2); - var o = this.scrollTop; - this.session.setScrollTop(s), n !== !1 && this.animateScrolling(o, r); - }), - (this.animateScrolling = function(e, t) { - var n = this.scrollTop; - if (!this.$animatedScroll) return; - var r = this; - if (e == n) return; - if (this.$scrollAnimation) { - var i = this.$scrollAnimation.steps; - if (i.length) { - e = i[0]; - if (e == n) return; + }), + (this.setAnnotations = function (e) { + (this.$gutterLayer.setAnnotations(e), + this.$loop.schedule(this.CHANGE_GUTTER)); + }), + (this.updateCursor = function () { + this.$loop.schedule(this.CHANGE_CURSOR); + }), + (this.hideCursor = function () { + this.$cursorLayer.hideCursor(); + }), + (this.showCursor = function () { + this.$cursorLayer.showCursor(); + }), + (this.scrollSelectionIntoView = function (e, t, n) { + (this.scrollCursorIntoView(e, n), this.scrollCursorIntoView(t, n)); + }), + (this.scrollCursorIntoView = function (e, t, n) { + if (this.$size.scrollerHeight === 0) return; + var r = this.$cursorLayer.getPixelPosition(e), + i = r.left, + s = r.top, + o = (n && n.top) || 0, + u = (n && n.bottom) || 0, + a = this.$scrollAnimation + ? this.session.getScrollTop() + : this.scrollTop; + a + o > s + ? (t && + a + o > s + this.lineHeight && + (s -= t * this.$size.scrollerHeight), + s === 0 && (s = -this.scrollMargin.top), + this.session.setScrollTop(s)) + : a + this.$size.scrollerHeight - u < s + this.lineHeight && + (t && + a + this.$size.scrollerHeight - u < s - this.lineHeight && + (s += t * this.$size.scrollerHeight), + this.session.setScrollTop( + s + this.lineHeight - this.$size.scrollerHeight + )); + var f = this.scrollLeft; + f > i + ? (i < this.$padding + 2 * this.layerConfig.characterWidth && + (i = -this.scrollMargin.left), + this.session.setScrollLeft(i)) + : f + this.$size.scrollerWidth < i + this.characterWidth + ? this.session.setScrollLeft( + Math.round( + i + this.characterWidth - this.$size.scrollerWidth + ) + ) + : f <= this.$padding && + i - f < this.characterWidth && + this.session.setScrollLeft(0); + }), + (this.getScrollTop = function () { + return this.session.getScrollTop(); + }), + (this.getScrollLeft = function () { + return this.session.getScrollLeft(); + }), + (this.getScrollTopRow = function () { + return this.scrollTop / this.lineHeight; + }), + (this.getScrollBottomRow = function () { + return Math.max( + 0, + Math.floor( + (this.scrollTop + this.$size.scrollerHeight) / this.lineHeight + ) - 1 + ); + }), + (this.scrollToRow = function (e) { + this.session.setScrollTop(e * this.lineHeight); + }), + (this.alignCursor = function (e, t) { + typeof e == "number" && (e = { row: e, column: 0 }); + var n = this.$cursorLayer.getPixelPosition(e), + r = this.$size.scrollerHeight - this.lineHeight, + i = n.top - r * (t || 0); + return (this.session.setScrollTop(i), i); + }), + (this.STEPS = 8), + (this.$calcSteps = function (e, t) { + var n = 0, + r = this.STEPS, + i = [], + s = function (e, t, n) { + return n * (Math.pow(e - 1, 3) + 1) + t; + }; + for (n = 0; n < r; ++n) i.push(s(n / this.STEPS, e, t - e)); + return i; + }), + (this.scrollToLine = function (e, t, n, r) { + var i = this.$cursorLayer.getPixelPosition({ row: e, column: 0 }), + s = i.top; + t && (s -= this.$size.scrollerHeight / 2); + var o = this.scrollTop; + (this.session.setScrollTop(s), + n !== !1 && this.animateScrolling(o, r)); + }), + (this.animateScrolling = function (e, t) { + var n = this.scrollTop; + if (!this.$animatedScroll) return; + var r = this; + if (e == n) return; + if (this.$scrollAnimation) { + var i = this.$scrollAnimation.steps; + if (i.length) { + e = i[0]; + if (e == n) return; + } } - } - var s = r.$calcSteps(e, n); - (this.$scrollAnimation = { from: e, to: n, steps: s }), - clearInterval(this.$timer), - r.session.setScrollTop(s.shift()), - (r.session.$scrollTop = n), - (this.$timer = setInterval(function() { - s.length - ? (r.session.setScrollTop(s.shift()), - (r.session.$scrollTop = n)) - : n != null - ? ((r.session.$scrollTop = -1), - r.session.setScrollTop(n), - (n = null)) - : ((r.$timer = clearInterval(r.$timer)), - (r.$scrollAnimation = null), - t && t()); - }, 10)); - }), - (this.scrollToY = function(e) { - this.scrollTop !== e && - (this.$loop.schedule(this.CHANGE_SCROLL), (this.scrollTop = e)); - }), - (this.scrollToX = function(e) { - this.scrollLeft !== e && (this.scrollLeft = e), - this.$loop.schedule(this.CHANGE_H_SCROLL); - }), - (this.scrollTo = function(e, t) { - this.session.setScrollTop(t), this.session.setScrollLeft(t); - }), - (this.scrollBy = function(e, t) { - t && this.session.setScrollTop(this.session.getScrollTop() + t), - e && this.session.setScrollLeft(this.session.getScrollLeft() + e); - }), - (this.isScrollableBy = function(e, t) { - if (t < 0 && this.session.getScrollTop() >= 1 - this.scrollMargin.top) - return !0; - if ( - t > 0 && - this.session.getScrollTop() + - this.$size.scrollerHeight - - this.layerConfig.maxHeight < - -1 + this.scrollMargin.bottom - ) - return !0; - if ( - e < 0 && - this.session.getScrollLeft() >= 1 - this.scrollMargin.left - ) - return !0; - if ( - e > 0 && - this.session.getScrollLeft() + - this.$size.scrollerWidth - - this.layerConfig.width < - -1 + this.scrollMargin.right - ) - return !0; - }), - (this.pixelToScreenCoordinates = function(e, t) { - var n = this.scroller.getBoundingClientRect(), - r = - (e + this.scrollLeft - n.left - this.$padding) / - this.characterWidth, - i = Math.floor((t + this.scrollTop - n.top) / this.lineHeight), - s = Math.round(r); - return { row: i, column: s, side: r - s > 0 ? 1 : -1 }; - }), - (this.screenToTextCoordinates = function(e, t) { - var n = this.scroller.getBoundingClientRect(), - r = Math.round( - (e + this.scrollLeft - n.left - this.$padding) / - this.characterWidth - ), - i = (t + this.scrollTop - n.top) / this.lineHeight; - return this.session.screenToDocumentPosition(i, Math.max(r, 0)); - }), - (this.textToScreenCoordinates = function(e, t) { - var n = this.scroller.getBoundingClientRect(), - r = this.session.documentToScreenPosition(e, t), - i = this.$padding + Math.round(r.column * this.characterWidth), - s = r.row * this.lineHeight; - return { - pageX: n.left + i - this.scrollLeft, - pageY: n.top + s - this.scrollTop - }; - }), - (this.visualizeFocus = function() { - i.addCssClass(this.container, "ace_focus"); - }), - (this.visualizeBlur = function() { - i.removeCssClass(this.container, "ace_focus"); - }), - (this.showComposition = function(e) { - this.$composition || - (this.$composition = { - keepTextAreaAtCursor: this.$keepTextAreaAtCursor, - cssText: this.textarea.style.cssText - }), - (this.$keepTextAreaAtCursor = !0), - i.addCssClass(this.textarea, "ace_composition"), - (this.textarea.style.cssText = ""), + var s = r.$calcSteps(e, n); + ((this.$scrollAnimation = { from: e, to: n, steps: s }), + clearInterval(this.$timer), + r.session.setScrollTop(s.shift()), + (r.session.$scrollTop = n), + (this.$timer = setInterval(function () { + s.length + ? (r.session.setScrollTop(s.shift()), + (r.session.$scrollTop = n)) + : n != null + ? ((r.session.$scrollTop = -1), + r.session.setScrollTop(n), + (n = null)) + : ((r.$timer = clearInterval(r.$timer)), + (r.$scrollAnimation = null), + t && t()); + }, 10))); + }), + (this.scrollToY = function (e) { + this.scrollTop !== e && + (this.$loop.schedule(this.CHANGE_SCROLL), (this.scrollTop = e)); + }), + (this.scrollToX = function (e) { + (this.scrollLeft !== e && (this.scrollLeft = e), + this.$loop.schedule(this.CHANGE_H_SCROLL)); + }), + (this.scrollTo = function (e, t) { + (this.session.setScrollTop(t), this.session.setScrollLeft(t)); + }), + (this.scrollBy = function (e, t) { + (t && this.session.setScrollTop(this.session.getScrollTop() + t), + e && + this.session.setScrollLeft(this.session.getScrollLeft() + e)); + }), + (this.isScrollableBy = function (e, t) { + if ( + t < 0 && + this.session.getScrollTop() >= 1 - this.scrollMargin.top + ) + return !0; + if ( + t > 0 && + this.session.getScrollTop() + + this.$size.scrollerHeight - + this.layerConfig.maxHeight < + -1 + this.scrollMargin.bottom + ) + return !0; + if ( + e < 0 && + this.session.getScrollLeft() >= 1 - this.scrollMargin.left + ) + return !0; + if ( + e > 0 && + this.session.getScrollLeft() + + this.$size.scrollerWidth - + this.layerConfig.width < + -1 + this.scrollMargin.right + ) + return !0; + }), + (this.pixelToScreenCoordinates = function (e, t) { + var n = this.scroller.getBoundingClientRect(), + r = + (e + this.scrollLeft - n.left - this.$padding) / + this.characterWidth, + i = Math.floor((t + this.scrollTop - n.top) / this.lineHeight), + s = Math.round(r); + return { row: i, column: s, side: r - s > 0 ? 1 : -1 }; + }), + (this.screenToTextCoordinates = function (e, t) { + var n = this.scroller.getBoundingClientRect(), + r = Math.round( + (e + this.scrollLeft - n.left - this.$padding) / + this.characterWidth + ), + i = (t + this.scrollTop - n.top) / this.lineHeight; + return this.session.screenToDocumentPosition(i, Math.max(r, 0)); + }), + (this.textToScreenCoordinates = function (e, t) { + var n = this.scroller.getBoundingClientRect(), + r = this.session.documentToScreenPosition(e, t), + i = this.$padding + Math.round(r.column * this.characterWidth), + s = r.row * this.lineHeight; + return { + pageX: n.left + i - this.scrollLeft, + pageY: n.top + s - this.scrollTop + }; + }), + (this.visualizeFocus = function () { + i.addCssClass(this.container, "ace_focus"); + }), + (this.visualizeBlur = function () { + i.removeCssClass(this.container, "ace_focus"); + }), + (this.showComposition = function (e) { + (this.$composition || + (this.$composition = { + keepTextAreaAtCursor: this.$keepTextAreaAtCursor, + cssText: this.textarea.style.cssText + }), + (this.$keepTextAreaAtCursor = !0), + i.addCssClass(this.textarea, "ace_composition"), + (this.textarea.style.cssText = ""), + this.$moveTextAreaToCursor()); + }), + (this.setCompositionText = function (e) { this.$moveTextAreaToCursor(); - }), - (this.setCompositionText = function(e) { - this.$moveTextAreaToCursor(); - }), - (this.hideComposition = function() { - if (!this.$composition) return; - i.removeCssClass(this.textarea, "ace_composition"), - (this.$keepTextAreaAtCursor = this.$composition.keepTextAreaAtCursor), - (this.textarea.style.cssText = this.$composition.cssText), - (this.$composition = null); - }), - (this.setTheme = function(e, t) { - function o(r) { - if (n.$themeId != e) return t && t(); - if (!r || !r.cssClass) - throw new Error( - "couldn't load module " + e + " or it didn't call define" - ); - i.importCssString(r.cssText, r.cssClass, n.container.ownerDocument), - n.theme && i.removeCssClass(n.container, n.theme.cssClass); - var s = - "padding" in r - ? r.padding - : "padding" in (n.theme || {}) - ? 4 - : n.$padding; - n.$padding && s != n.$padding && n.setPadding(s), - (n.$theme = r.cssClass), - (n.theme = r), - i.addCssClass(n.container, r.cssClass), - i.setCssClass(n.container, "ace_dark", r.isDark), - n.$size && ((n.$size.width = 0), n.$updateSizeAsync()), - n._dispatchEvent("themeLoaded", { theme: r }), - t && t(); - } - var n = this; - (this.$themeId = e), n._dispatchEvent("themeChange", { theme: e }); - if (!e || typeof e == "string") { - var r = e || this.$options.theme.initialValue; - s.loadModule(["theme", r], o); - } else o(e); - }), - (this.getTheme = function() { - return this.$themeId; - }), - (this.setStyle = function(e, t) { - i.setCssClass(this.container, e, t !== !1); - }), - (this.unsetStyle = function(e) { - i.removeCssClass(this.container, e); - }), - (this.setCursorStyle = function(e) { - this.scroller.style.cursor != e && (this.scroller.style.cursor = e); - }), - (this.setMouseCursor = function(e) { - this.scroller.style.cursor = e; - }), - (this.destroy = function() { - this.$textLayer.destroy(), this.$cursorLayer.destroy(); - }); - }.call(g.prototype), - s.defineOptions(g.prototype, "renderer", { - animatedScroll: { initialValue: !1 }, - showInvisibles: { - set: function(e) { - this.$textLayer.setShowInvisibles(e) && - this.$loop.schedule(this.CHANGE_TEXT); - }, - initialValue: !1 - }, - showPrintMargin: { - set: function() { - this.$updatePrintMargin(); + }), + (this.hideComposition = function () { + if (!this.$composition) return; + (i.removeCssClass(this.textarea, "ace_composition"), + (this.$keepTextAreaAtCursor = + this.$composition.keepTextAreaAtCursor), + (this.textarea.style.cssText = this.$composition.cssText), + (this.$composition = null)); + }), + (this.setTheme = function (e, t) { + function o(r) { + if (n.$themeId != e) return t && t(); + if (!r || !r.cssClass) + throw new Error( + "couldn't load module " + e + " or it didn't call define" + ); + (i.importCssString( + r.cssText, + r.cssClass, + n.container.ownerDocument + ), + n.theme && i.removeCssClass(n.container, n.theme.cssClass)); + var s = + "padding" in r + ? r.padding + : "padding" in (n.theme || {}) + ? 4 + : n.$padding; + (n.$padding && s != n.$padding && n.setPadding(s), + (n.$theme = r.cssClass), + (n.theme = r), + i.addCssClass(n.container, r.cssClass), + i.setCssClass(n.container, "ace_dark", r.isDark), + n.$size && ((n.$size.width = 0), n.$updateSizeAsync()), + n._dispatchEvent("themeLoaded", { theme: r }), + t && t()); + } + var n = this; + ((this.$themeId = e), + n._dispatchEvent("themeChange", { theme: e })); + if (!e || typeof e == "string") { + var r = e || this.$options.theme.initialValue; + s.loadModule(["theme", r], o); + } else o(e); + }), + (this.getTheme = function () { + return this.$themeId; + }), + (this.setStyle = function (e, t) { + i.setCssClass(this.container, e, t !== !1); + }), + (this.unsetStyle = function (e) { + i.removeCssClass(this.container, e); + }), + (this.setCursorStyle = function (e) { + this.scroller.style.cursor != e && (this.scroller.style.cursor = e); + }), + (this.setMouseCursor = function (e) { + this.scroller.style.cursor = e; + }), + (this.destroy = function () { + (this.$textLayer.destroy(), this.$cursorLayer.destroy()); + })); + }).call(g.prototype), + s.defineOptions(g.prototype, "renderer", { + animatedScroll: { initialValue: !1 }, + showInvisibles: { + set: function (e) { + this.$textLayer.setShowInvisibles(e) && + this.$loop.schedule(this.CHANGE_TEXT); + }, + initialValue: !1 }, - initialValue: !0 - }, - printMarginColumn: { - set: function() { - this.$updatePrintMargin(); + showPrintMargin: { + set: function () { + this.$updatePrintMargin(); + }, + initialValue: !0 }, - initialValue: 80 - }, - printMargin: { - set: function(e) { - typeof e == "number" && (this.$printMarginColumn = e), - (this.$showPrintMargin = !!e), + printMarginColumn: { + set: function () { this.$updatePrintMargin(); + }, + initialValue: 80 }, - get: function() { - return this.$showPrintMargin && this.$printMarginColumn; - } - }, - showGutter: { - set: function(e) { - (this.$gutter.style.display = e ? "block" : "none"), - this.$loop.schedule(this.CHANGE_FULL), - this.onGutterResize(); + printMargin: { + set: function (e) { + (typeof e == "number" && (this.$printMarginColumn = e), + (this.$showPrintMargin = !!e), + this.$updatePrintMargin()); + }, + get: function () { + return this.$showPrintMargin && this.$printMarginColumn; + } }, - initialValue: !0 - }, - fadeFoldWidgets: { - set: function(e) { - i.setCssClass(this.$gutter, "ace_fade-fold-widgets", e); + showGutter: { + set: function (e) { + ((this.$gutter.style.display = e ? "block" : "none"), + this.$loop.schedule(this.CHANGE_FULL), + this.onGutterResize()); + }, + initialValue: !0 }, - initialValue: !1 - }, - showFoldWidgets: { - set: function(e) { - this.$gutterLayer.setShowFoldWidgets(e); + fadeFoldWidgets: { + set: function (e) { + i.setCssClass(this.$gutter, "ace_fade-fold-widgets", e); + }, + initialValue: !1 }, - initialValue: !0 - }, - showLineNumbers: { - set: function(e) { - this.$gutterLayer.setShowLineNumbers(e), - this.$loop.schedule(this.CHANGE_GUTTER); + showFoldWidgets: { + set: function (e) { + this.$gutterLayer.setShowFoldWidgets(e); + }, + initialValue: !0 }, - initialValue: !0 - }, - displayIndentGuides: { - set: function(e) { - this.$textLayer.setDisplayIndentGuides(e) && - this.$loop.schedule(this.CHANGE_TEXT); + showLineNumbers: { + set: function (e) { + (this.$gutterLayer.setShowLineNumbers(e), + this.$loop.schedule(this.CHANGE_GUTTER)); + }, + initialValue: !0 }, - initialValue: !0 - }, - highlightGutterLine: { - set: function(e) { - if (!this.$gutterLineHighlight) { - (this.$gutterLineHighlight = i.createElement("div")), - (this.$gutterLineHighlight.className = - "ace_gutter-active-line"), - this.$gutter.appendChild(this.$gutterLineHighlight); - return; - } - (this.$gutterLineHighlight.style.display = e ? "" : "none"), - this.$cursorLayer.$pixelPos && this.$updateGutterLineHighlight(); + displayIndentGuides: { + set: function (e) { + this.$textLayer.setDisplayIndentGuides(e) && + this.$loop.schedule(this.CHANGE_TEXT); + }, + initialValue: !0 }, - initialValue: !1, - value: !0 - }, - hScrollBarAlwaysVisible: { - set: function(e) { - (!this.$hScrollBarAlwaysVisible || !this.$horizScroll) && - this.$loop.schedule(this.CHANGE_SCROLL); + highlightGutterLine: { + set: function (e) { + if (!this.$gutterLineHighlight) { + ((this.$gutterLineHighlight = i.createElement("div")), + (this.$gutterLineHighlight.className = + "ace_gutter-active-line"), + this.$gutter.appendChild(this.$gutterLineHighlight)); + return; + } + ((this.$gutterLineHighlight.style.display = e ? "" : "none"), + this.$cursorLayer.$pixelPos && + this.$updateGutterLineHighlight()); + }, + initialValue: !1, + value: !0 }, - initialValue: !1 - }, - vScrollBarAlwaysVisible: { - set: function(e) { - (!this.$vScrollBarAlwaysVisible || !this.$vScroll) && - this.$loop.schedule(this.CHANGE_SCROLL); + hScrollBarAlwaysVisible: { + set: function (e) { + (!this.$hScrollBarAlwaysVisible || !this.$horizScroll) && + this.$loop.schedule(this.CHANGE_SCROLL); + }, + initialValue: !1 }, - initialValue: !1 - }, - fontSize: { - set: function(e) { - typeof e == "number" && (e += "px"), - (this.container.style.fontSize = e), - this.updateFontSize(); + vScrollBarAlwaysVisible: { + set: function (e) { + (!this.$vScrollBarAlwaysVisible || !this.$vScroll) && + this.$loop.schedule(this.CHANGE_SCROLL); + }, + initialValue: !1 }, - initialValue: 12 - }, - fontFamily: { - set: function(e) { - (this.container.style.fontFamily = e), this.updateFontSize(); - } - }, - maxLines: { - set: function(e) { - this.updateFull(); - } - }, - minLines: { - set: function(e) { - this.updateFull(); - } - }, - maxPixelHeight: { - set: function(e) { - this.updateFull(); + fontSize: { + set: function (e) { + (typeof e == "number" && (e += "px"), + (this.container.style.fontSize = e), + this.updateFontSize()); + }, + initialValue: 12 }, - initialValue: 0 - }, - scrollPastEnd: { - set: function(e) { - e = +e || 0; - if (this.$scrollPastEnd == e) return; - (this.$scrollPastEnd = e), this.$loop.schedule(this.CHANGE_SCROLL); - }, - initialValue: 0, - handlesSet: !0 - }, - fixedWidthGutter: { - set: function(e) { - (this.$gutterLayer.$fixedWidth = !!e), - this.$loop.schedule(this.CHANGE_GUTTER); - } - }, - theme: { - set: function(e) { - this.setTheme(e); + fontFamily: { + set: function (e) { + ((this.container.style.fontFamily = e), this.updateFontSize()); + } }, - get: function() { - return this.$themeId || this.theme; + maxLines: { + set: function (e) { + this.updateFull(); + } }, - initialValue: "./theme/textmate", - handlesSet: !0 - } - }), - (t.VirtualRenderer = g)); - }), - define("ace/worker/worker_client", [ - "require", - "exports", - "module", - "ace/lib/oop", - "ace/lib/net", - "ace/lib/event_emitter", - "ace/config" - ], function(e, t, n) { - "use strict"; - var r = e("../lib/oop"), - i = e("../lib/net"), - s = e("../lib/event_emitter").EventEmitter, - o = e("../config"), - u = function(t, n, r, i) { - (this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this)), + minLines: { + set: function (e) { + this.updateFull(); + } + }, + maxPixelHeight: { + set: function (e) { + this.updateFull(); + }, + initialValue: 0 + }, + scrollPastEnd: { + set: function (e) { + e = +e || 0; + if (this.$scrollPastEnd == e) return; + ((this.$scrollPastEnd = e), + this.$loop.schedule(this.CHANGE_SCROLL)); + }, + initialValue: 0, + handlesSet: !0 + }, + fixedWidthGutter: { + set: function (e) { + ((this.$gutterLayer.$fixedWidth = !!e), + this.$loop.schedule(this.CHANGE_GUTTER)); + } + }, + theme: { + set: function (e) { + this.setTheme(e); + }, + get: function () { + return this.$themeId || this.theme; + }, + initialValue: "./theme/textmate", + handlesSet: !0 + } + }), + (t.VirtualRenderer = g)); + } + ), + define( + "ace/worker/worker_client", + [ + "require", + "exports", + "module", + "ace/lib/oop", + "ace/lib/net", + "ace/lib/event_emitter", + "ace/config" + ], + function (e, t, n) { + "use strict"; + var r = e("../lib/oop"), + i = e("../lib/net"), + s = e("../lib/event_emitter").EventEmitter, + o = e("../config"), + u = function (t, n, r, i) { + ((this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this)), + (this.changeListener = this.changeListener.bind(this)), + (this.onMessage = this.onMessage.bind(this)), + e.nameToUrl && !e.toUrl && (e.toUrl = e.nameToUrl)); + if (o.get("packaged") || !e.toUrl) i = i || o.moduleUrl(n, "worker"); + else { + var s = this.$normalizePath; + i = i || s(e.toUrl("ace/worker/worker.js", null, "_")); + var u = {}; + t.forEach(function (t) { + u[t] = s(e.toUrl(t, null, "_").replace(/(\.js)?(\?.*)?$/, "")); + }); + } + try { + this.$worker = new Worker(i); + } catch (a) { + if (!(a instanceof window.DOMException)) throw a; + var f = this.$workerBlob(i), + l = window.URL || window.webkitURL, + c = l.createObjectURL(f); + ((this.$worker = new Worker(c)), l.revokeObjectURL(c)); + } + (this.$worker.postMessage({ + init: !0, + tlns: u, + module: n, + classname: r + }), + (this.callbackId = 1), + (this.callbacks = {}), + (this.$worker.onmessage = this.onMessage)); + }; + (function () { + (r.implement(this, s), + (this.onMessage = function (e) { + var t = e.data; + switch (t.type) { + case "event": + this._signal(t.name, { data: t.data }); + break; + case "call": + var n = this.callbacks[t.id]; + n && (n(t.data), delete this.callbacks[t.id]); + break; + case "error": + this.reportError(t.data); + break; + case "log": + window.console && + console.log && + console.log.apply(console, t.data); + } + }), + (this.reportError = function (e) { + window.console && console.error && console.error(e); + }), + (this.$normalizePath = function (e) { + return i.qualifyURL(e); + }), + (this.terminate = function () { + (this._signal("terminate", {}), + (this.deltaQueue = null), + this.$worker.terminate(), + (this.$worker = null), + this.$doc && this.$doc.off("change", this.changeListener), + (this.$doc = null)); + }), + (this.send = function (e, t) { + this.$worker.postMessage({ command: e, args: t }); + }), + (this.call = function (e, t, n) { + if (n) { + var r = this.callbackId++; + ((this.callbacks[r] = n), t.push(r)); + } + this.send(e, t); + }), + (this.emit = function (e, t) { + try { + this.$worker.postMessage({ event: e, data: { data: t.data } }); + } catch (n) { + console.error(n.stack); + } + }), + (this.attachToDocument = function (e) { + (this.$doc && this.terminate(), + (this.$doc = e), + this.call("setValue", [e.getValue()]), + e.on("change", this.changeListener)); + }), + (this.changeListener = function (e) { + (this.deltaQueue || + ((this.deltaQueue = []), setTimeout(this.$sendDeltaQueue, 0)), + e.action == "insert" + ? this.deltaQueue.push(e.start, e.lines) + : this.deltaQueue.push(e.start, e.end)); + }), + (this.$sendDeltaQueue = function () { + var e = this.deltaQueue; + if (!e) return; + ((this.deltaQueue = null), + e.length > 50 && e.length > this.$doc.getLength() >> 1 + ? this.call("setValue", [this.$doc.getValue()]) + : this.emit("change", { data: e })); + }), + (this.$workerBlob = function (e) { + var t = "importScripts('" + i.qualifyURL(e) + "');"; + try { + return new Blob([t], { type: "application/javascript" }); + } catch (n) { + var r = + window.BlobBuilder || + window.WebKitBlobBuilder || + window.MozBlobBuilder, + s = new r(); + return (s.append(t), s.getBlob("application/javascript")); + } + })); + }).call(u.prototype); + var a = function (e, t, n) { + ((this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this)), (this.changeListener = this.changeListener.bind(this)), - (this.onMessage = this.onMessage.bind(this)), - e.nameToUrl && !e.toUrl && (e.toUrl = e.nameToUrl); - if (o.get("packaged") || !e.toUrl) i = i || o.moduleUrl(n, "worker"); - else { - var s = this.$normalizePath; - i = i || s(e.toUrl("ace/worker/worker.js", null, "_")); - var u = {}; - t.forEach(function(t) { - u[t] = s(e.toUrl(t, null, "_").replace(/(\.js)?(\?.*)?$/, "")); - }); - } - try { - this.$worker = new Worker(i); - } catch (a) { - if (!(a instanceof window.DOMException)) throw a; - var f = this.$workerBlob(i), - l = window.URL || window.webkitURL, - c = l.createObjectURL(f); - (this.$worker = new Worker(c)), l.revokeObjectURL(c); - } - this.$worker.postMessage({ - init: !0, - tlns: u, - module: n, - classname: r - }), (this.callbackId = 1), (this.callbacks = {}), - (this.$worker.onmessage = this.onMessage); - }; - (function() { - r.implement(this, s), - (this.onMessage = function(e) { - var t = e.data; - switch (t.type) { - case "event": - this._signal(t.name, { data: t.data }); - break; - case "call": - var n = this.callbacks[t.id]; - n && (n(t.data), delete this.callbacks[t.id]); - break; - case "error": - this.reportError(t.data); - break; - case "log": - window.console && - console.log && - console.log.apply(console, t.data); - } - }), - (this.reportError = function(e) { - window.console && console.error && console.error(e); - }), - (this.$normalizePath = function(e) { - return i.qualifyURL(e); - }), - (this.terminate = function() { - this._signal("terminate", {}), - (this.deltaQueue = null), - this.$worker.terminate(), - (this.$worker = null), - this.$doc && this.$doc.off("change", this.changeListener), - (this.$doc = null); - }), - (this.send = function(e, t) { - this.$worker.postMessage({ command: e, args: t }); - }), - (this.call = function(e, t, n) { - if (n) { - var r = this.callbackId++; - (this.callbacks[r] = n), t.push(r); - } - this.send(e, t); - }), - (this.emit = function(e, t) { - try { - this.$worker.postMessage({ event: e, data: { data: t.data } }); - } catch (n) { - console.error(n.stack); - } - }), - (this.attachToDocument = function(e) { - this.$doc && this.terminate(), - (this.$doc = e), - this.call("setValue", [e.getValue()]), - e.on("change", this.changeListener); - }), - (this.changeListener = function(e) { - this.deltaQueue || - ((this.deltaQueue = []), setTimeout(this.$sendDeltaQueue, 0)), - e.action == "insert" - ? this.deltaQueue.push(e.start, e.lines) - : this.deltaQueue.push(e.start, e.end); - }), - (this.$sendDeltaQueue = function() { - var e = this.deltaQueue; - if (!e) return; - (this.deltaQueue = null), - e.length > 50 && e.length > this.$doc.getLength() >> 1 - ? this.call("setValue", [this.$doc.getValue()]) - : this.emit("change", { data: e }); - }), - (this.$workerBlob = function(e) { - var t = "importScripts('" + i.qualifyURL(e) + "');"; - try { - return new Blob([t], { type: "application/javascript" }); - } catch (n) { - var r = - window.BlobBuilder || - window.WebKitBlobBuilder || - window.MozBlobBuilder, - s = new r(); - return s.append(t), s.getBlob("application/javascript"); - } - }); - }.call(u.prototype)); - var a = function(e, t, n) { - (this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this)), - (this.changeListener = this.changeListener.bind(this)), - (this.callbackId = 1), - (this.callbacks = {}), - (this.messageBuffer = []); - var r = null, - i = !1, - u = Object.create(s), - a = this; - (this.$worker = {}), - (this.$worker.terminate = function() {}), - (this.$worker.postMessage = function(e) { - a.messageBuffer.push(e), r && (i ? setTimeout(f) : f()); - }), - (this.setEmitSync = function(e) { - i = e; - }); - var f = function() { - var e = a.messageBuffer.shift(); - e.command - ? r[e.command].apply(r, e.args) - : e.event && u._signal(e.event, e.data); - }; - (u.postMessage = function(e) { - a.onMessage({ data: e }); - }), - (u.callback = function(e, t) { - this.postMessage({ type: "call", id: t, data: e }); - }), - (u.emit = function(e, t) { - this.postMessage({ type: "event", name: e, data: t }); + (this.messageBuffer = [])); + var r = null, + i = !1, + u = Object.create(s), + a = this; + ((this.$worker = {}), + (this.$worker.terminate = function () {}), + (this.$worker.postMessage = function (e) { + (a.messageBuffer.push(e), r && (i ? setTimeout(f) : f())); + }), + (this.setEmitSync = function (e) { + i = e; + })); + var f = function () { + var e = a.messageBuffer.shift(); + e.command + ? r[e.command].apply(r, e.args) + : e.event && u._signal(e.event, e.data); + }; + ((u.postMessage = function (e) { + a.onMessage({ data: e }); }), - o.loadModule(["worker", t], function(e) { - r = new e[n](u); - while (a.messageBuffer.length) f(); - }); - }; - (a.prototype = u.prototype), (t.UIWorkerClient = a), (t.WorkerClient = u); - }), - define("ace/placeholder", [ - "require", - "exports", - "module", - "ace/range", - "ace/lib/event_emitter", - "ace/lib/oop" - ], function(e, t, n) { - "use strict"; - var r = e("./range").Range, - i = e("./lib/event_emitter").EventEmitter, - s = e("./lib/oop"), - o = function(e, t, n, r, i, s) { - var o = this; - (this.length = t), - (this.session = e), - (this.doc = e.getDocument()), - (this.mainClass = i), - (this.othersClass = s), - (this.$onUpdate = this.onUpdate.bind(this)), - this.doc.on("change", this.$onUpdate), - (this.$others = r), - (this.$onCursorChange = function() { - setTimeout(function() { - o.onCursorChange(); - }); + (u.callback = function (e, t) { + this.postMessage({ type: "call", id: t, data: e }); }), - (this.$pos = n); - var u = e.getUndoManager().$undoStack || - e.getUndoManager().$undostack || { length: -1 }; - (this.$undoStackDepth = u.length), - this.setup(), - e.selection.on("changeCursor", this.$onCursorChange); + (u.emit = function (e, t) { + this.postMessage({ type: "event", name: e, data: t }); + }), + o.loadModule(["worker", t], function (e) { + r = new e[n](u); + while (a.messageBuffer.length) f(); + })); }; - (function() { - s.implement(this, i), - (this.setup = function() { - var e = this, - t = this.doc, - n = this.session; - (this.selectionBefore = n.selection.toJSON()), - n.selection.inMultiSelectMode && n.selection.toSingleRange(), - (this.pos = t.createAnchor(this.$pos.row, this.$pos.column)); - var i = this.pos; - (i.$insertRight = !0), - i.detach(), - (i.markerId = n.addMarker( - new r(i.row, i.column, i.row, i.column + this.length), - this.mainClass, - null, - !1 - )), - (this.others = []), - this.$others.forEach(function(n) { - var r = t.createAnchor(n.row, n.column); - (r.$insertRight = !0), r.detach(), e.others.push(r); + ((a.prototype = u.prototype), + (t.UIWorkerClient = a), + (t.WorkerClient = u)); + } + ), + define( + "ace/placeholder", + [ + "require", + "exports", + "module", + "ace/range", + "ace/lib/event_emitter", + "ace/lib/oop" + ], + function (e, t, n) { + "use strict"; + var r = e("./range").Range, + i = e("./lib/event_emitter").EventEmitter, + s = e("./lib/oop"), + o = function (e, t, n, r, i, s) { + var o = this; + ((this.length = t), + (this.session = e), + (this.doc = e.getDocument()), + (this.mainClass = i), + (this.othersClass = s), + (this.$onUpdate = this.onUpdate.bind(this)), + this.doc.on("change", this.$onUpdate), + (this.$others = r), + (this.$onCursorChange = function () { + setTimeout(function () { + o.onCursorChange(); + }); }), - n.setUndoSelect(!1); - }), - (this.showOtherMarkers = function() { - if (this.othersActive) return; - var e = this.session, - t = this; - (this.othersActive = !0), - this.others.forEach(function(n) { - n.markerId = e.addMarker( - new r(n.row, n.column, n.row, n.column + t.length), - t.othersClass, + (this.$pos = n)); + var u = e.getUndoManager().$undoStack || + e.getUndoManager().$undostack || { length: -1 }; + ((this.$undoStackDepth = u.length), + this.setup(), + e.selection.on("changeCursor", this.$onCursorChange)); + }; + ((function () { + (s.implement(this, i), + (this.setup = function () { + var e = this, + t = this.doc, + n = this.session; + ((this.selectionBefore = n.selection.toJSON()), + n.selection.inMultiSelectMode && n.selection.toSingleRange(), + (this.pos = t.createAnchor(this.$pos.row, this.$pos.column))); + var i = this.pos; + ((i.$insertRight = !0), + i.detach(), + (i.markerId = n.addMarker( + new r(i.row, i.column, i.row, i.column + this.length), + this.mainClass, null, !1 - ); - }); - }), - (this.hideOtherMarkers = function() { - if (!this.othersActive) return; - this.othersActive = !1; - for (var e = 0; e < this.others.length; e++) - this.session.removeMarker(this.others[e].markerId); - }), - (this.onUpdate = function(e) { - if (this.$updating) return this.updateAnchors(e); - var t = e; - if (t.start.row !== t.end.row) return; - if (t.start.row !== this.pos.row) return; - this.$updating = !0; - var n = - e.action === "insert" - ? t.end.column - t.start.column - : t.start.column - t.end.column, - i = - t.start.column >= this.pos.column && - t.start.column <= this.pos.column + this.length + 1, - s = t.start.column - this.pos.column; - this.updateAnchors(e), i && (this.length += n); - if (i && !this.session.$fromUndo) - if (e.action === "insert") - for (var o = this.others.length - 1; o >= 0; o--) { - var u = this.others[o], - a = { row: u.row, column: u.column + s }; - this.doc.insertMergedLines(a, e.lines); - } - else if (e.action === "remove") - for (var o = this.others.length - 1; o >= 0; o--) { - var u = this.others[o], - a = { row: u.row, column: u.column + s }; - this.doc.remove(new r(a.row, a.column, a.row, a.column - n)); - } - (this.$updating = !1), this.updateMarkers(); - }), - (this.updateAnchors = function(e) { - this.pos.onChange(e); - for (var t = this.others.length; t--; ) this.others[t].onChange(e); - this.updateMarkers(); - }), - (this.updateMarkers = function() { - if (this.$updating) return; - var e = this, - t = this.session, - n = function(n, i) { - t.removeMarker(n.markerId), - (n.markerId = t.addMarker( - new r(n.row, n.column, n.row, n.column + e.length), - i, + )), + (this.others = []), + this.$others.forEach(function (n) { + var r = t.createAnchor(n.row, n.column); + ((r.$insertRight = !0), r.detach(), e.others.push(r)); + }), + n.setUndoSelect(!1)); + }), + (this.showOtherMarkers = function () { + if (this.othersActive) return; + var e = this.session, + t = this; + ((this.othersActive = !0), + this.others.forEach(function (n) { + n.markerId = e.addMarker( + new r(n.row, n.column, n.row, n.column + t.length), + t.othersClass, null, !1 - )); - }; - n(this.pos, this.mainClass); - for (var i = this.others.length; i--; ) - n(this.others[i], this.othersClass); - }), - (this.onCursorChange = function(e) { - if (this.$updating || !this.session) return; - var t = this.session.selection.getCursor(); - t.row === this.pos.row && - t.column >= this.pos.column && - t.column <= this.pos.column + this.length - ? (this.showOtherMarkers(), this._emit("cursorEnter", e)) - : (this.hideOtherMarkers(), this._emit("cursorLeave", e)); - }), - (this.detach = function() { - this.session.removeMarker(this.pos && this.pos.markerId), - this.hideOtherMarkers(), - this.doc.removeEventListener("change", this.$onUpdate), - this.session.selection.removeEventListener( - "changeCursor", - this.$onCursorChange - ), - this.session.setUndoSelect(!0), - (this.session = null); - }), - (this.cancel = function() { - if (this.$undoStackDepth === -1) return; - var e = this.session.getUndoManager(), - t = (e.$undoStack || e.$undostack).length - this.$undoStackDepth; - for (var n = 0; n < t; n++) e.undo(!0); - this.selectionBefore && - this.session.selection.fromJSON(this.selectionBefore); - }); - }.call(o.prototype), - (t.PlaceHolder = o)); - }), - define("ace/mouse/multi_select_handler", [ - "require", - "exports", - "module", - "ace/lib/event", - "ace/lib/useragent" - ], function(e, t, n) { - function s(e, t) { - return e.row == t.row && e.column == t.column; + ); + })); + }), + (this.hideOtherMarkers = function () { + if (!this.othersActive) return; + this.othersActive = !1; + for (var e = 0; e < this.others.length; e++) + this.session.removeMarker(this.others[e].markerId); + }), + (this.onUpdate = function (e) { + if (this.$updating) return this.updateAnchors(e); + var t = e; + if (t.start.row !== t.end.row) return; + if (t.start.row !== this.pos.row) return; + this.$updating = !0; + var n = + e.action === "insert" + ? t.end.column - t.start.column + : t.start.column - t.end.column, + i = + t.start.column >= this.pos.column && + t.start.column <= this.pos.column + this.length + 1, + s = t.start.column - this.pos.column; + (this.updateAnchors(e), i && (this.length += n)); + if (i && !this.session.$fromUndo) + if (e.action === "insert") + for (var o = this.others.length - 1; o >= 0; o--) { + var u = this.others[o], + a = { row: u.row, column: u.column + s }; + this.doc.insertMergedLines(a, e.lines); + } + else if (e.action === "remove") + for (var o = this.others.length - 1; o >= 0; o--) { + var u = this.others[o], + a = { row: u.row, column: u.column + s }; + this.doc.remove(new r(a.row, a.column, a.row, a.column - n)); + } + ((this.$updating = !1), this.updateMarkers()); + }), + (this.updateAnchors = function (e) { + this.pos.onChange(e); + for (var t = this.others.length; t--;) this.others[t].onChange(e); + this.updateMarkers(); + }), + (this.updateMarkers = function () { + if (this.$updating) return; + var e = this, + t = this.session, + n = function (n, i) { + (t.removeMarker(n.markerId), + (n.markerId = t.addMarker( + new r(n.row, n.column, n.row, n.column + e.length), + i, + null, + !1 + ))); + }; + n(this.pos, this.mainClass); + for (var i = this.others.length; i--;) + n(this.others[i], this.othersClass); + }), + (this.onCursorChange = function (e) { + if (this.$updating || !this.session) return; + var t = this.session.selection.getCursor(); + t.row === this.pos.row && + t.column >= this.pos.column && + t.column <= this.pos.column + this.length + ? (this.showOtherMarkers(), this._emit("cursorEnter", e)) + : (this.hideOtherMarkers(), this._emit("cursorLeave", e)); + }), + (this.detach = function () { + (this.session.removeMarker(this.pos && this.pos.markerId), + this.hideOtherMarkers(), + this.doc.removeEventListener("change", this.$onUpdate), + this.session.selection.removeEventListener( + "changeCursor", + this.$onCursorChange + ), + this.session.setUndoSelect(!0), + (this.session = null)); + }), + (this.cancel = function () { + if (this.$undoStackDepth === -1) return; + var e = this.session.getUndoManager(), + t = (e.$undoStack || e.$undostack).length - this.$undoStackDepth; + for (var n = 0; n < t; n++) e.undo(!0); + this.selectionBefore && + this.session.selection.fromJSON(this.selectionBefore); + })); + }).call(o.prototype), + (t.PlaceHolder = o)); } - function o(e) { - var t = e.domEvent, - n = t.altKey, - o = t.shiftKey, - u = t.ctrlKey, - a = e.getAccelKey(), - f = e.getButton(); - u && i.isMac && (f = t.button); - if (e.editor.inMultiSelectMode && f == 2) { - e.editor.textInput.onContextMenu(e.domEvent); - return; - } - if (!u && !n && !a) { - f === 0 && e.editor.inMultiSelectMode && e.editor.exitMultiSelectMode(); - return; + ), + define( + "ace/mouse/multi_select_handler", + ["require", "exports", "module", "ace/lib/event", "ace/lib/useragent"], + function (e, t, n) { + function s(e, t) { + return e.row == t.row && e.column == t.column; } - if (f !== 0) return; - var l = e.editor, - c = l.selection, - h = l.inMultiSelectMode, - p = e.getDocumentPosition(), - d = c.getCursor(), - v = e.inSelection() || (c.isEmpty() && s(p, d)), - m = e.x, - g = e.y, - y = function(e) { - (m = e.clientX), (g = e.clientY); - }, - b = l.session, - w = l.renderer.pixelToScreenCoordinates(m, g), - E = w, - S; - if (l.$mouseHandler.$enableJumpToDef) - (u && n) || (a && n) - ? (S = o ? "block" : "add") - : n && l.$blockSelectEnabled && (S = "block"); - else if (a && !n) { - S = "add"; - if (!h && o) return; - } else n && l.$blockSelectEnabled && (S = "block"); - S && i.isMac && t.ctrlKey && l.$mouseHandler.cancelContextMenu(); - if (S == "add") { - if (!h && v) return; - if (!h) { - var x = c.toOrientedRange(); - l.addSelectionMarker(x); + function o(e) { + var t = e.domEvent, + n = t.altKey, + o = t.shiftKey, + u = t.ctrlKey, + a = e.getAccelKey(), + f = e.getButton(); + u && i.isMac && (f = t.button); + if (e.editor.inMultiSelectMode && f == 2) { + e.editor.textInput.onContextMenu(e.domEvent); + return; + } + if (!u && !n && !a) { + f === 0 && + e.editor.inMultiSelectMode && + e.editor.exitMultiSelectMode(); + return; + } + if (f !== 0) return; + var l = e.editor, + c = l.selection, + h = l.inMultiSelectMode, + p = e.getDocumentPosition(), + d = c.getCursor(), + v = e.inSelection() || (c.isEmpty() && s(p, d)), + m = e.x, + g = e.y, + y = function (e) { + ((m = e.clientX), (g = e.clientY)); + }, + b = l.session, + w = l.renderer.pixelToScreenCoordinates(m, g), + E = w, + S; + if (l.$mouseHandler.$enableJumpToDef) + (u && n) || (a && n) + ? (S = o ? "block" : "add") + : n && l.$blockSelectEnabled && (S = "block"); + else if (a && !n) { + S = "add"; + if (!h && o) return; + } else n && l.$blockSelectEnabled && (S = "block"); + S && i.isMac && t.ctrlKey && l.$mouseHandler.cancelContextMenu(); + if (S == "add") { + if (!h && v) return; + if (!h) { + var x = c.toOrientedRange(); + l.addSelectionMarker(x); + } + var T = c.rangeList.rangeAtPoint(p); + (l.$blockScrolling++, + (l.inVirtualSelectionMode = !0), + o && + ((T = null), (x = c.ranges[0] || x), l.removeSelectionMarker(x)), + l.once("mouseup", function () { + var e = c.toOrientedRange(); + (T && e.isEmpty() && s(T.cursor, e.cursor) + ? c.substractPoint(e.cursor) + : (o + ? c.substractPoint(x.cursor) + : x && (l.removeSelectionMarker(x), c.addRange(x)), + c.addRange(e)), + l.$blockScrolling--, + (l.inVirtualSelectionMode = !1)); + })); + } else if (S == "block") { + (e.stop(), (l.inVirtualSelectionMode = !0)); + var N, + C = [], + k = function () { + var e = l.renderer.pixelToScreenCoordinates(m, g), + t = b.screenToDocumentPosition(e.row, e.column); + if (s(E, e) && s(t, c.lead)) return; + ((E = e), + l.$blockScrolling++, + l.selection.moveToPosition(t), + l.renderer.scrollCursorIntoView(), + l.removeSelectionMarkers(C), + (C = c.rectangularRangeBlock(E, w)), + l.$mouseHandler.$clickSelection && + C.length == 1 && + C[0].isEmpty() && + (C[0] = l.$mouseHandler.$clickSelection.clone()), + C.forEach(l.addSelectionMarker, l), + l.updateSelectionMarkers(), + l.$blockScrolling--); + }; + (l.$blockScrolling++, + h && !a + ? c.toSingleRange() + : !h && a && ((N = c.toOrientedRange()), l.addSelectionMarker(N)), + o ? (w = b.documentToScreenPosition(c.lead)) : c.moveToPosition(p), + l.$blockScrolling--, + (E = { row: -1, column: -1 })); + var L = function (e) { + (clearInterval(O), + l.removeSelectionMarkers(C), + C.length || (C = [c.toOrientedRange()]), + l.$blockScrolling++, + N && (l.removeSelectionMarker(N), c.toSingleRange(N))); + for (var t = 0; t < C.length; t++) c.addRange(C[t]); + ((l.inVirtualSelectionMode = !1), + (l.$mouseHandler.$clickSelection = null), + l.$blockScrolling--); + }, + A = k; + r.capture(l.container, y, L); + var O = setInterval(function () { + A(); + }, 20); + return e.preventDefault(); } - var T = c.rangeList.rangeAtPoint(p); - l.$blockScrolling++, - (l.inVirtualSelectionMode = !0), - o && ((T = null), (x = c.ranges[0] || x), l.removeSelectionMarker(x)), - l.once("mouseup", function() { - var e = c.toOrientedRange(); - T && e.isEmpty() && s(T.cursor, e.cursor) - ? c.substractPoint(e.cursor) - : (o - ? c.substractPoint(x.cursor) - : x && (l.removeSelectionMarker(x), c.addRange(x)), - c.addRange(e)), - l.$blockScrolling--, - (l.inVirtualSelectionMode = !1); - }); - } else if (S == "block") { - e.stop(), (l.inVirtualSelectionMode = !0); - var N, - C = [], - k = function() { - var e = l.renderer.pixelToScreenCoordinates(m, g), - t = b.screenToDocumentPosition(e.row, e.column); - if (s(E, e) && s(t, c.lead)) return; - (E = e), - l.$blockScrolling++, - l.selection.moveToPosition(t), - l.renderer.scrollCursorIntoView(), - l.removeSelectionMarkers(C), - (C = c.rectangularRangeBlock(E, w)), - l.$mouseHandler.$clickSelection && - C.length == 1 && - C[0].isEmpty() && - (C[0] = l.$mouseHandler.$clickSelection.clone()), - C.forEach(l.addSelectionMarker, l), - l.updateSelectionMarkers(), - l.$blockScrolling--; - }; - l.$blockScrolling++, - h && !a - ? c.toSingleRange() - : !h && a && ((N = c.toOrientedRange()), l.addSelectionMarker(N)), - o ? (w = b.documentToScreenPosition(c.lead)) : c.moveToPosition(p), - l.$blockScrolling--, - (E = { row: -1, column: -1 }); - var L = function(e) { - clearInterval(O), - l.removeSelectionMarkers(C), - C.length || (C = [c.toOrientedRange()]), - l.$blockScrolling++, - N && (l.removeSelectionMarker(N), c.toSingleRange(N)); - for (var t = 0; t < C.length; t++) c.addRange(C[t]); - (l.inVirtualSelectionMode = !1), - (l.$mouseHandler.$clickSelection = null), - l.$blockScrolling--; - }, - A = k; - r.capture(l.container, y, L); - var O = setInterval(function() { - A(); - }, 20); - return e.preventDefault(); } + var r = e("../lib/event"), + i = e("../lib/useragent"); + t.onMouseDown = o; } - var r = e("../lib/event"), - i = e("../lib/useragent"); - t.onMouseDown = o; - }), - define("ace/commands/multi_select_commands", [ - "require", - "exports", - "module", - "ace/keyboard/hash_handler" - ], function(e, t, n) { - (t.defaultCommands = [ - { - name: "addCursorAbove", - exec: function(e) { - e.selectMoreLines(-1); - }, - bindKey: { win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up" }, - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "addCursorBelow", - exec: function(e) { - e.selectMoreLines(1); + ), + define( + "ace/commands/multi_select_commands", + ["require", "exports", "module", "ace/keyboard/hash_handler"], + function (e, t, n) { + ((t.defaultCommands = [ + { + name: "addCursorAbove", + exec: function (e) { + e.selectMoreLines(-1); + }, + bindKey: { win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up" }, + scrollIntoView: "cursor", + readOnly: !0 }, - bindKey: { win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down" }, - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "addCursorAboveSkipCurrent", - exec: function(e) { - e.selectMoreLines(-1, !0); + { + name: "addCursorBelow", + exec: function (e) { + e.selectMoreLines(1); + }, + bindKey: { win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down" }, + scrollIntoView: "cursor", + readOnly: !0 }, - bindKey: { win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up" }, - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "addCursorBelowSkipCurrent", - exec: function(e) { - e.selectMoreLines(1, !0); + { + name: "addCursorAboveSkipCurrent", + exec: function (e) { + e.selectMoreLines(-1, !0); + }, + bindKey: { win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up" }, + scrollIntoView: "cursor", + readOnly: !0 }, - bindKey: { win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down" }, - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "selectMoreBefore", - exec: function(e) { - e.selectMore(-1); + { + name: "addCursorBelowSkipCurrent", + exec: function (e) { + e.selectMoreLines(1, !0); + }, + bindKey: { win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down" }, + scrollIntoView: "cursor", + readOnly: !0 }, - bindKey: { win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left" }, - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "selectMoreAfter", - exec: function(e) { - e.selectMore(1); + { + name: "selectMoreBefore", + exec: function (e) { + e.selectMore(-1); + }, + bindKey: { win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left" }, + scrollIntoView: "cursor", + readOnly: !0 }, - bindKey: { win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right" }, - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "selectNextBefore", - exec: function(e) { - e.selectMore(-1, !0); + { + name: "selectMoreAfter", + exec: function (e) { + e.selectMore(1); + }, + bindKey: { win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right" }, + scrollIntoView: "cursor", + readOnly: !0 }, - bindKey: { win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left" }, - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "selectNextAfter", - exec: function(e) { - e.selectMore(1, !0); + { + name: "selectNextBefore", + exec: function (e) { + e.selectMore(-1, !0); + }, + bindKey: { win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left" }, + scrollIntoView: "cursor", + readOnly: !0 }, - bindKey: { win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right" }, - scrollIntoView: "cursor", - readOnly: !0 - }, - { - name: "splitIntoLines", - exec: function(e) { - e.multiSelect.splitIntoLines(); + { + name: "selectNextAfter", + exec: function (e) { + e.selectMore(1, !0); + }, + bindKey: { win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right" }, + scrollIntoView: "cursor", + readOnly: !0 }, - bindKey: { win: "Ctrl-Alt-L", mac: "Ctrl-Alt-L" }, - readOnly: !0 - }, - { - name: "alignCursors", - exec: function(e) { - e.alignCursors(); + { + name: "splitIntoLines", + exec: function (e) { + e.multiSelect.splitIntoLines(); + }, + bindKey: { win: "Ctrl-Alt-L", mac: "Ctrl-Alt-L" }, + readOnly: !0 }, - bindKey: { win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A" }, - scrollIntoView: "cursor" - }, - { - name: "findAll", - exec: function(e) { - e.findAll(); + { + name: "alignCursors", + exec: function (e) { + e.alignCursors(); + }, + bindKey: { win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A" }, + scrollIntoView: "cursor" }, - bindKey: { win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G" }, - scrollIntoView: "cursor", - readOnly: !0 - } - ]), - (t.multiSelectCommands = [ { - name: "singleSelection", - bindKey: "esc", - exec: function(e) { - e.exitMultiSelectMode(); + name: "findAll", + exec: function (e) { + e.findAll(); }, + bindKey: { win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G" }, scrollIntoView: "cursor", - readOnly: !0, - isAvailable: function(e) { - return e && e.inMultiSelectMode; - } + readOnly: !0 } - ]); - var r = e("../keyboard/hash_handler").HashHandler; - t.keyboardHandler = new r(t.multiSelectCommands); - }), - define("ace/multi_select", [ - "require", - "exports", - "module", - "ace/range_list", - "ace/range", - "ace/selection", - "ace/mouse/multi_select_handler", - "ace/lib/event", - "ace/lib/lang", - "ace/commands/multi_select_commands", - "ace/search", - "ace/edit_session", - "ace/editor", - "ace/config" - ], function(e, t, n) { - function h(e, t, n) { - return ( - (c.$options.wrap = !0), - (c.$options.needle = t), - (c.$options.backwards = n == -1), - c.find(e) - ); - } - function v(e, t) { - return e.row == t.row && e.column == t.column; - } - function m(e) { - if (e.$multiselectOnSessionChange) return; - (e.$onAddRange = e.$onAddRange.bind(e)), - (e.$onRemoveRange = e.$onRemoveRange.bind(e)), - (e.$onMultiSelect = e.$onMultiSelect.bind(e)), - (e.$onSingleSelect = e.$onSingleSelect.bind(e)), - (e.$multiselectOnSessionChange = t.onSessionChange.bind(e)), - (e.$checkMultiselectChange = e.$checkMultiselectChange.bind(e)), - e.$multiselectOnSessionChange(e), - e.on("changeSession", e.$multiselectOnSessionChange), - e.on("mousedown", o), - e.commands.addCommands(f.defaultCommands), - g(e); + ]), + (t.multiSelectCommands = [ + { + name: "singleSelection", + bindKey: "esc", + exec: function (e) { + e.exitMultiSelectMode(); + }, + scrollIntoView: "cursor", + readOnly: !0, + isAvailable: function (e) { + return e && e.inMultiSelectMode; + } + } + ])); + var r = e("../keyboard/hash_handler").HashHandler; + t.keyboardHandler = new r(t.multiSelectCommands); } - function g(e) { - function r(t) { - n && (e.renderer.setMouseCursor(""), (n = !1)); + ), + define( + "ace/multi_select", + [ + "require", + "exports", + "module", + "ace/range_list", + "ace/range", + "ace/selection", + "ace/mouse/multi_select_handler", + "ace/lib/event", + "ace/lib/lang", + "ace/commands/multi_select_commands", + "ace/search", + "ace/edit_session", + "ace/editor", + "ace/config" + ], + function (e, t, n) { + function h(e, t, n) { + return ( + (c.$options.wrap = !0), + (c.$options.needle = t), + (c.$options.backwards = n == -1), + c.find(e) + ); } - var t = e.textInput.getElement(), - n = !1; - u.addListener(t, "keydown", function(t) { - var i = t.keyCode == 18 && !(t.ctrlKey || t.shiftKey || t.metaKey); - e.$blockSelectEnabled && i - ? n || (e.renderer.setMouseCursor("crosshair"), (n = !0)) - : n && r(); - }), - u.addListener(t, "keyup", r), - u.addListener(t, "blur", r); - } - var r = e("./range_list").RangeList, - i = e("./range").Range, - s = e("./selection").Selection, - o = e("./mouse/multi_select_handler").onMouseDown, - u = e("./lib/event"), - a = e("./lib/lang"), - f = e("./commands/multi_select_commands"); - t.commands = f.defaultCommands.concat(f.multiSelectCommands); - var l = e("./search").Search, - c = new l(), - p = e("./edit_session").EditSession; - (function() { - this.getSelectionMarkers = function() { - return this.$selectionMarkers; - }; - }.call(p.prototype), - function() { - (this.ranges = null), - (this.rangeList = null), - (this.addRange = function(e, t) { - if (!e) return; - if (!this.inMultiSelectMode && this.rangeCount === 0) { - var n = this.toOrientedRange(); - this.rangeList.add(n), this.rangeList.add(e); - if (this.rangeList.ranges.length != 2) - return ( - this.rangeList.removeAll(), t || this.fromOrientedRange(e) + function v(e, t) { + return e.row == t.row && e.column == t.column; + } + function m(e) { + if (e.$multiselectOnSessionChange) return; + ((e.$onAddRange = e.$onAddRange.bind(e)), + (e.$onRemoveRange = e.$onRemoveRange.bind(e)), + (e.$onMultiSelect = e.$onMultiSelect.bind(e)), + (e.$onSingleSelect = e.$onSingleSelect.bind(e)), + (e.$multiselectOnSessionChange = t.onSessionChange.bind(e)), + (e.$checkMultiselectChange = e.$checkMultiselectChange.bind(e)), + e.$multiselectOnSessionChange(e), + e.on("changeSession", e.$multiselectOnSessionChange), + e.on("mousedown", o), + e.commands.addCommands(f.defaultCommands), + g(e)); + } + function g(e) { + function r(t) { + n && (e.renderer.setMouseCursor(""), (n = !1)); + } + var t = e.textInput.getElement(), + n = !1; + (u.addListener(t, "keydown", function (t) { + var i = t.keyCode == 18 && !(t.ctrlKey || t.shiftKey || t.metaKey); + e.$blockSelectEnabled && i + ? n || (e.renderer.setMouseCursor("crosshair"), (n = !0)) + : n && r(); + }), + u.addListener(t, "keyup", r), + u.addListener(t, "blur", r)); + } + var r = e("./range_list").RangeList, + i = e("./range").Range, + s = e("./selection").Selection, + o = e("./mouse/multi_select_handler").onMouseDown, + u = e("./lib/event"), + a = e("./lib/lang"), + f = e("./commands/multi_select_commands"); + t.commands = f.defaultCommands.concat(f.multiSelectCommands); + var l = e("./search").Search, + c = new l(), + p = e("./edit_session").EditSession; + ((function () { + this.getSelectionMarkers = function () { + return this.$selectionMarkers; + }; + }).call(p.prototype), + function () { + ((this.ranges = null), + (this.rangeList = null), + (this.addRange = function (e, t) { + if (!e) return; + if (!this.inMultiSelectMode && this.rangeCount === 0) { + var n = this.toOrientedRange(); + (this.rangeList.add(n), this.rangeList.add(e)); + if (this.rangeList.ranges.length != 2) + return ( + this.rangeList.removeAll(), + t || this.fromOrientedRange(e) + ); + (this.rangeList.removeAll(), + this.rangeList.add(n), + this.$onAddRange(n)); + } + e.cursor || (e.cursor = e.end); + var r = this.rangeList.add(e); + return ( + this.$onAddRange(e), + r.length && this.$onRemoveRange(r), + this.rangeCount > 1 && + !this.inMultiSelectMode && + (this._signal("multiSelect"), + (this.inMultiSelectMode = !0), + (this.session.$undoSelect = !1), + this.rangeList.attach(this.session)), + t || this.fromOrientedRange(e) + ); + }), + (this.toSingleRange = function (e) { + e = e || this.ranges[0]; + var t = this.rangeList.removeAll(); + (t.length && this.$onRemoveRange(t), + e && this.fromOrientedRange(e)); + }), + (this.substractPoint = function (e) { + var t = this.rangeList.substractPoint(e); + if (t) return (this.$onRemoveRange(t), t[0]); + }), + (this.mergeOverlappingRanges = function () { + var e = this.rangeList.merge(); + e.length + ? this.$onRemoveRange(e) + : this.ranges[0] && this.fromOrientedRange(this.ranges[0]); + }), + (this.$onAddRange = function (e) { + ((this.rangeCount = this.rangeList.ranges.length), + this.ranges.unshift(e), + this._signal("addRange", { range: e })); + }), + (this.$onRemoveRange = function (e) { + this.rangeCount = this.rangeList.ranges.length; + if (this.rangeCount == 1 && this.inMultiSelectMode) { + var t = this.rangeList.ranges.pop(); + (e.push(t), (this.rangeCount = 0)); + } + for (var n = e.length; n--;) { + var r = this.ranges.indexOf(e[n]); + this.ranges.splice(r, 1); + } + (this._signal("removeRange", { ranges: e }), + this.rangeCount === 0 && + this.inMultiSelectMode && + ((this.inMultiSelectMode = !1), + this._signal("singleSelect"), + (this.session.$undoSelect = !0), + this.rangeList.detach(this.session)), + (t = t || this.ranges[0]), + t && !t.isEqual(this.getRange()) && this.fromOrientedRange(t)); + }), + (this.$initRangeList = function () { + if (this.rangeList) return; + ((this.rangeList = new r()), + (this.ranges = []), + (this.rangeCount = 0)); + }), + (this.getAllRanges = function () { + return this.rangeCount + ? this.rangeList.ranges.concat() + : [this.getRange()]; + }), + (this.splitIntoLines = function () { + if (this.rangeCount > 1) { + var e = this.rangeList.ranges, + t = e[e.length - 1], + n = i.fromPoints(e[0].start, t.end); + (this.toSingleRange(), + this.setSelectionRange(n, t.cursor == t.start)); + } else { + var n = this.getRange(), + r = this.isBackwards(), + s = n.start.row, + o = n.end.row; + if (s == o) { + if (r) + var u = n.end, + a = n.start; + else + var u = n.start, + a = n.end; + (this.addRange(i.fromPoints(a, a)), + this.addRange(i.fromPoints(u, u))); + return; + } + var f = [], + l = this.getLineRange(s, !0); + ((l.start.column = n.start.column), f.push(l)); + for (var c = s + 1; c < o; c++) + f.push(this.getLineRange(c, !0)); + ((l = this.getLineRange(o, !0)), + (l.end.column = n.end.column), + f.push(l), + f.forEach(this.addRange, this)); + } + }), + (this.toggleBlockSelection = function () { + if (this.rangeCount > 1) { + var e = this.rangeList.ranges, + t = e[e.length - 1], + n = i.fromPoints(e[0].start, t.end); + (this.toSingleRange(), + this.setSelectionRange(n, t.cursor == t.start)); + } else { + var r = this.session.documentToScreenPosition( + this.selectionLead + ), + s = this.session.documentToScreenPosition( + this.selectionAnchor + ), + o = this.rectangularRangeBlock(r, s); + o.forEach(this.addRange, this); + } + }), + (this.rectangularRangeBlock = function (e, t, n) { + var r = [], + s = e.column < t.column; + if (s) + var o = e.column, + u = t.column; + else + var o = t.column, + u = e.column; + var a = e.row < t.row; + if (a) + var f = e.row, + l = t.row; + else + var f = t.row, + l = e.row; + (o < 0 && (o = 0), f < 0 && (f = 0), f == l && (n = !0)); + for (var c = f; c <= l; c++) { + var h = i.fromPoints( + this.session.screenToDocumentPosition(c, o), + this.session.screenToDocumentPosition(c, u) + ); + if (h.isEmpty()) { + if (p && v(h.end, p)) break; + var p = h.end; + } + ((h.cursor = s ? h.start : h.end), r.push(h)); + } + a && r.reverse(); + if (!n) { + var d = r.length - 1; + while (r[d].isEmpty() && d > 0) d--; + if (d > 0) { + var m = 0; + while (r[m].isEmpty()) m++; + } + for (var g = d; g >= m; g--) r[g].isEmpty() && r.splice(g, 1); + } + return r; + })); + }.call(s.prototype)); + var d = e("./editor").Editor; + ((function () { + ((this.updateSelectionMarkers = function () { + (this.renderer.updateCursor(), this.renderer.updateBackMarkers()); + }), + (this.addSelectionMarker = function (e) { + e.cursor || (e.cursor = e.end); + var t = this.getSelectionStyle(); + return ( + (e.marker = this.session.addMarker(e, "ace_selection", t)), + this.session.$selectionMarkers.push(e), + (this.session.selectionMarkerCount = + this.session.$selectionMarkers.length), + e + ); + }), + (this.removeSelectionMarker = function (e) { + if (!e.marker) return; + this.session.removeMarker(e.marker); + var t = this.session.$selectionMarkers.indexOf(e); + (t != -1 && this.session.$selectionMarkers.splice(t, 1), + (this.session.selectionMarkerCount = + this.session.$selectionMarkers.length)); + }), + (this.removeSelectionMarkers = function (e) { + var t = this.session.$selectionMarkers; + for (var n = e.length; n--;) { + var r = e[n]; + if (!r.marker) continue; + this.session.removeMarker(r.marker); + var i = t.indexOf(r); + i != -1 && t.splice(i, 1); + } + this.session.selectionMarkerCount = t.length; + }), + (this.$onAddRange = function (e) { + (this.addSelectionMarker(e.range), + this.renderer.updateCursor(), + this.renderer.updateBackMarkers()); + }), + (this.$onRemoveRange = function (e) { + (this.removeSelectionMarkers(e.ranges), + this.renderer.updateCursor(), + this.renderer.updateBackMarkers()); + }), + (this.$onMultiSelect = function (e) { + if (this.inMultiSelectMode) return; + ((this.inMultiSelectMode = !0), + this.setStyle("ace_multiselect"), + this.keyBinding.addKeyboardHandler(f.keyboardHandler), + this.commands.setDefaultHandler("exec", this.$onMultiSelectExec), + this.renderer.updateCursor(), + this.renderer.updateBackMarkers()); + }), + (this.$onSingleSelect = function (e) { + if (this.session.multiSelect.inVirtualMode) return; + ((this.inMultiSelectMode = !1), + this.unsetStyle("ace_multiselect"), + this.keyBinding.removeKeyboardHandler(f.keyboardHandler), + this.commands.removeDefaultHandler( + "exec", + this.$onMultiSelectExec + ), + this.renderer.updateCursor(), + this.renderer.updateBackMarkers(), + this._emit("changeSelection")); + }), + (this.$onMultiSelectExec = function (e) { + var t = e.command, + n = e.editor; + if (!n.multiSelect) return; + if (!t.multiSelectAction) { + var r = t.exec(n, e.args || {}); + (n.multiSelect.addRange(n.multiSelect.toOrientedRange()), + n.multiSelect.mergeOverlappingRanges()); + } else + t.multiSelectAction == "forEach" + ? (r = n.forEachSelection(t, e.args)) + : t.multiSelectAction == "forEachLine" + ? (r = n.forEachSelection(t, e.args, !0)) + : t.multiSelectAction == "single" + ? (n.exitMultiSelectMode(), (r = t.exec(n, e.args || {}))) + : (r = t.multiSelectAction(n, e.args || {})); + return r; + }), + (this.forEachSelection = function (e, t, n) { + if (this.inVirtualSelectionMode) return; + var r = n && n.keepOrder, + i = n == 1 || (n && n.$byLines), + o = this.session, + u = this.selection, + a = u.rangeList, + f = (r ? u : a).ranges, + l; + if (!f.length) + return e.exec ? e.exec(this, t || {}) : e(this, t || {}); + var c = u._eventRegistry; + u._eventRegistry = {}; + var h = new s(o); + this.inVirtualSelectionMode = !0; + for (var p = f.length; p--;) { + if (i) while (p > 0 && f[p].start.row == f[p - 1].end.row) p--; + (h.fromOrientedRange(f[p]), + (h.index = p), + (this.selection = o.selection = h)); + var d = e.exec ? e.exec(this, t || {}) : e(this, t || {}); + (!l && d !== undefined && (l = d), h.toOrientedRange(f[p])); + } + (h.detach(), + (this.selection = o.selection = u), + (this.inVirtualSelectionMode = !1), + (u._eventRegistry = c), + u.mergeOverlappingRanges()); + var v = this.renderer.$scrollAnimation; + return ( + this.onCursorChange(), + this.onSelectionChange(), + v && v.from == v.to && this.renderer.animateScrolling(v.from), + l + ); + }), + (this.exitMultiSelectMode = function () { + if (!this.inMultiSelectMode || this.inVirtualSelectionMode) return; + this.multiSelect.toSingleRange(); + }), + (this.getSelectedText = function () { + var e = ""; + if (this.inMultiSelectMode && !this.inVirtualSelectionMode) { + var t = this.multiSelect.rangeList.ranges, + n = []; + for (var r = 0; r < t.length; r++) + n.push(this.session.getTextRange(t[r])); + var i = this.session.getDocument().getNewLineCharacter(); + ((e = n.join(i)), + e.length == (n.length - 1) * i.length && (e = "")); + } else + this.selection.isEmpty() || + (e = this.session.getTextRange(this.getSelectionRange())); + return e; + }), + (this.$checkMultiselectChange = function (e, t) { + if (this.inMultiSelectMode && !this.inVirtualSelectionMode) { + var n = this.multiSelect.ranges[0]; + if (this.multiSelect.isEmpty() && t == this.multiSelect.anchor) + return; + var r = + t == this.multiSelect.anchor + ? n.cursor == n.start + ? n.end + : n.start + : n.cursor; + (r.row != t.row || + this.session.$clipPositionToDocument(r.row, r.column).column != + t.column) && + this.multiSelect.toSingleRange( + this.multiSelect.toOrientedRange() ); - this.rangeList.removeAll(), - this.rangeList.add(n), - this.$onAddRange(n); } - e.cursor || (e.cursor = e.end); - var r = this.rangeList.add(e); - return ( - this.$onAddRange(e), - r.length && this.$onRemoveRange(r), - this.rangeCount > 1 && - !this.inMultiSelectMode && - (this._signal("multiSelect"), - (this.inMultiSelectMode = !0), - (this.session.$undoSelect = !1), - this.rangeList.attach(this.session)), - t || this.fromOrientedRange(e) - ); }), - (this.toSingleRange = function(e) { - e = e || this.ranges[0]; - var t = this.rangeList.removeAll(); - t.length && this.$onRemoveRange(t), e && this.fromOrientedRange(e); - }), - (this.substractPoint = function(e) { - var t = this.rangeList.substractPoint(e); - if (t) return this.$onRemoveRange(t), t[0]; - }), - (this.mergeOverlappingRanges = function() { - var e = this.rangeList.merge(); - e.length - ? this.$onRemoveRange(e) - : this.ranges[0] && this.fromOrientedRange(this.ranges[0]); - }), - (this.$onAddRange = function(e) { - (this.rangeCount = this.rangeList.ranges.length), - this.ranges.unshift(e), - this._signal("addRange", { range: e }); - }), - (this.$onRemoveRange = function(e) { - this.rangeCount = this.rangeList.ranges.length; - if (this.rangeCount == 1 && this.inMultiSelectMode) { - var t = this.rangeList.ranges.pop(); - e.push(t), (this.rangeCount = 0); - } - for (var n = e.length; n--; ) { - var r = this.ranges.indexOf(e[n]); - this.ranges.splice(r, 1); - } - this._signal("removeRange", { ranges: e }), - this.rangeCount === 0 && - this.inMultiSelectMode && - ((this.inMultiSelectMode = !1), - this._signal("singleSelect"), - (this.session.$undoSelect = !0), - this.rangeList.detach(this.session)), - (t = t || this.ranges[0]), - t && !t.isEqual(this.getRange()) && this.fromOrientedRange(t); - }), - (this.$initRangeList = function() { - if (this.rangeList) return; - (this.rangeList = new r()), - (this.ranges = []), - (this.rangeCount = 0); - }), - (this.getAllRanges = function() { - return this.rangeCount - ? this.rangeList.ranges.concat() - : [this.getRange()]; - }), - (this.splitIntoLines = function() { - if (this.rangeCount > 1) { - var e = this.rangeList.ranges, - t = e[e.length - 1], - n = i.fromPoints(e[0].start, t.end); - this.toSingleRange(), - this.setSelectionRange(n, t.cursor == t.start); - } else { - var n = this.getRange(), - r = this.isBackwards(), - s = n.start.row, - o = n.end.row; - if (s == o) { - if (r) - var u = n.end, - a = n.start; - else - var u = n.start, - a = n.end; - this.addRange(i.fromPoints(a, a)), - this.addRange(i.fromPoints(u, u)); - return; + (this.findAll = function (e, t, n) { + ((t = t || {}), (t.needle = e || t.needle)); + if (t.needle == undefined) { + var r = this.selection.isEmpty() + ? this.selection.getWordRange() + : this.selection.getRange(); + t.needle = this.session.getTextRange(r); + } + this.$search.set(t); + var i = this.$search.findAll(this.session); + if (!i.length) return 0; + this.$blockScrolling += 1; + var s = this.multiSelect; + n || s.toSingleRange(i[0]); + for (var o = i.length; o--;) s.addRange(i[o], !0); + return ( + r && s.rangeList.rangeAtPoint(r.start) && s.addRange(r, !0), + (this.$blockScrolling -= 1), + i.length + ); + }), + (this.selectMoreLines = function (e, t) { + var n = this.selection.toOrientedRange(), + r = n.cursor == n.end, + s = this.session.documentToScreenPosition(n.cursor); + this.selection.$desiredColumn && + (s.column = this.selection.$desiredColumn); + var o = this.session.screenToDocumentPosition(s.row + e, s.column); + if (!n.isEmpty()) + var u = this.session.documentToScreenPosition( + r ? n.end : n.start + ), + a = this.session.screenToDocumentPosition(u.row + e, u.column); + else var a = o; + if (r) { + var f = i.fromPoints(o, a); + f.cursor = f.start; + } else { + var f = i.fromPoints(a, o); + f.cursor = f.end; + } + f.desiredColumn = s.column; + if (!this.selection.inMultiSelectMode) this.selection.addRange(n); + else if (t) var l = n.cursor; + (this.selection.addRange(f), l && this.selection.substractPoint(l)); + }), + (this.transposeSelections = function (e) { + var t = this.session, + n = t.multiSelect, + r = n.ranges; + for (var i = r.length; i--;) { + var s = r[i]; + if (s.isEmpty()) { + var o = t.getWordRange(s.start.row, s.start.column); + ((s.start.row = o.start.row), + (s.start.column = o.start.column), + (s.end.row = o.end.row), + (s.end.column = o.end.column)); + } + } + n.mergeOverlappingRanges(); + var u = []; + for (var i = r.length; i--;) { + var s = r[i]; + u.unshift(t.getTextRange(s)); + } + e < 0 ? u.unshift(u.pop()) : u.push(u.shift()); + for (var i = r.length; i--;) { + var s = r[i], + o = s.clone(); + (t.replace(s, u[i]), + (s.start.row = o.start.row), + (s.start.column = o.start.column)); + } + }), + (this.selectMore = function (e, t, n) { + var r = this.session, + i = r.multiSelect, + s = i.toOrientedRange(); + if (s.isEmpty()) { + ((s = r.getWordRange(s.start.row, s.start.column)), + (s.cursor = e == -1 ? s.start : s.end), + this.multiSelect.addRange(s)); + if (n) return; + } + var o = r.getTextRange(s), + u = h(r, o, e); + (u && + ((u.cursor = e == -1 ? u.start : u.end), + (this.$blockScrolling += 1), + this.session.unfold(u), + this.multiSelect.addRange(u), + (this.$blockScrolling -= 1), + this.renderer.scrollCursorIntoView(null, 0.5)), + t && this.multiSelect.substractPoint(s.cursor)); + }), + (this.alignCursors = function () { + var e = this.session, + t = e.multiSelect, + n = t.ranges, + r = -1, + s = n.filter(function (e) { + if (e.cursor.row == r) return !0; + r = e.cursor.row; + }); + if (!n.length || s.length == n.length - 1) { + var o = this.selection.getRange(), + u = o.start.row, + f = o.end.row, + l = u == f; + if (l) { + var c = this.session.getLength(), + h; + do h = this.session.getLine(f); + while (/[=:]/.test(h) && ++f < c); + do h = this.session.getLine(u); + while (/[=:]/.test(h) && --u > 0); + (u < 0 && (u = 0), f >= c && (f = c - 1)); } - var f = [], - l = this.getLineRange(s, !0); - (l.start.column = n.start.column), f.push(l); - for (var c = s + 1; c < o; c++) f.push(this.getLineRange(c, !0)); - (l = this.getLineRange(o, !0)), - (l.end.column = n.end.column), - f.push(l), - f.forEach(this.addRange, this); - } - }), - (this.toggleBlockSelection = function() { - if (this.rangeCount > 1) { - var e = this.rangeList.ranges, - t = e[e.length - 1], - n = i.fromPoints(e[0].start, t.end); - this.toSingleRange(), - this.setSelectionRange(n, t.cursor == t.start); + var p = this.session.removeFullLines(u, f); + ((p = this.$reAlignText(p, l)), + this.session.insert({ row: u, column: 0 }, p.join("\n") + "\n"), + l || + ((o.start.column = 0), + (o.end.column = p[p.length - 1].length)), + this.selection.setRange(o)); } else { - var r = this.session.documentToScreenPosition(this.selectionLead), - s = this.session.documentToScreenPosition(this.selectionAnchor), - o = this.rectangularRangeBlock(r, s); - o.forEach(this.addRange, this); + s.forEach(function (e) { + t.substractPoint(e.cursor); + }); + var d = 0, + v = Infinity, + m = n.map(function (t) { + var n = t.cursor, + r = e.getLine(n.row), + i = r.substr(n.column).search(/\S/g); + return ( + i == -1 && (i = 0), + n.column > d && (d = n.column), + i < v && (v = i), + i + ); + }); + (n.forEach(function (t, n) { + var r = t.cursor, + s = d - r.column, + o = m[n] - v; + (s > o + ? e.insert(r, a.stringRepeat(" ", s - o)) + : e.remove(new i(r.row, r.column, r.row, r.column - s + o)), + (t.start.column = t.end.column = d), + (t.start.row = t.end.row = r.row), + (t.cursor = t.end)); + }), + t.fromOrientedRange(n[0]), + this.renderer.updateCursor(), + this.renderer.updateBackMarkers()); } }), - (this.rectangularRangeBlock = function(e, t, n) { - var r = [], - s = e.column < t.column; - if (s) - var o = e.column, - u = t.column; - else - var o = t.column, - u = e.column; - var a = e.row < t.row; - if (a) - var f = e.row, - l = t.row; - else - var f = t.row, - l = e.row; - o < 0 && (o = 0), f < 0 && (f = 0), f == l && (n = !0); - for (var c = f; c <= l; c++) { - var h = i.fromPoints( - this.session.screenToDocumentPosition(c, o), - this.session.screenToDocumentPosition(c, u) - ); - if (h.isEmpty()) { - if (p && v(h.end, p)) break; - var p = h.end; - } - (h.cursor = s ? h.start : h.end), r.push(h); + (this.$reAlignText = function (e, t) { + function u(e) { + return a.stringRepeat(" ", e); } - a && r.reverse(); - if (!n) { - var d = r.length - 1; - while (r[d].isEmpty() && d > 0) d--; - if (d > 0) { - var m = 0; - while (r[m].isEmpty()) m++; - } - for (var g = d; g >= m; g--) r[g].isEmpty() && r.splice(g, 1); + function f(e) { + return e[2] + ? u(i) + + e[2] + + u(s - e[2].length + o) + + e[4].replace(/^([=:])\s+/, "$1 ") + : e[0]; } - return r; - }); - }.call(s.prototype)); - var d = e("./editor").Editor; - (function() { - (this.updateSelectionMarkers = function() { - this.renderer.updateCursor(), this.renderer.updateBackMarkers(); - }), - (this.addSelectionMarker = function(e) { - e.cursor || (e.cursor = e.end); - var t = this.getSelectionStyle(); - return ( - (e.marker = this.session.addMarker(e, "ace_selection", t)), - this.session.$selectionMarkers.push(e), - (this.session.selectionMarkerCount = this.session.$selectionMarkers.length), - e - ); - }), - (this.removeSelectionMarker = function(e) { - if (!e.marker) return; - this.session.removeMarker(e.marker); - var t = this.session.$selectionMarkers.indexOf(e); - t != -1 && this.session.$selectionMarkers.splice(t, 1), - (this.session.selectionMarkerCount = this.session.$selectionMarkers.length); - }), - (this.removeSelectionMarkers = function(e) { - var t = this.session.$selectionMarkers; - for (var n = e.length; n--; ) { - var r = e[n]; - if (!r.marker) continue; - this.session.removeMarker(r.marker); - var i = t.indexOf(r); - i != -1 && t.splice(i, 1); - } - this.session.selectionMarkerCount = t.length; - }), - (this.$onAddRange = function(e) { - this.addSelectionMarker(e.range), - this.renderer.updateCursor(), - this.renderer.updateBackMarkers(); - }), - (this.$onRemoveRange = function(e) { - this.removeSelectionMarkers(e.ranges), - this.renderer.updateCursor(), - this.renderer.updateBackMarkers(); - }), - (this.$onMultiSelect = function(e) { - if (this.inMultiSelectMode) return; - (this.inMultiSelectMode = !0), - this.setStyle("ace_multiselect"), - this.keyBinding.addKeyboardHandler(f.keyboardHandler), - this.commands.setDefaultHandler("exec", this.$onMultiSelectExec), - this.renderer.updateCursor(), - this.renderer.updateBackMarkers(); - }), - (this.$onSingleSelect = function(e) { - if (this.session.multiSelect.inVirtualMode) return; - (this.inMultiSelectMode = !1), - this.unsetStyle("ace_multiselect"), - this.keyBinding.removeKeyboardHandler(f.keyboardHandler), - this.commands.removeDefaultHandler("exec", this.$onMultiSelectExec), - this.renderer.updateCursor(), - this.renderer.updateBackMarkers(), - this._emit("changeSelection"); - }), - (this.$onMultiSelectExec = function(e) { - var t = e.command, - n = e.editor; - if (!n.multiSelect) return; - if (!t.multiSelectAction) { - var r = t.exec(n, e.args || {}); - n.multiSelect.addRange(n.multiSelect.toOrientedRange()), - n.multiSelect.mergeOverlappingRanges(); - } else - t.multiSelectAction == "forEach" - ? (r = n.forEachSelection(t, e.args)) - : t.multiSelectAction == "forEachLine" - ? (r = n.forEachSelection(t, e.args, !0)) - : t.multiSelectAction == "single" - ? (n.exitMultiSelectMode(), (r = t.exec(n, e.args || {}))) - : (r = t.multiSelectAction(n, e.args || {})); - return r; - }), - (this.forEachSelection = function(e, t, n) { - if (this.inVirtualSelectionMode) return; - var r = n && n.keepOrder, - i = n == 1 || (n && n.$byLines), - o = this.session, - u = this.selection, - a = u.rangeList, - f = (r ? u : a).ranges, - l; - if (!f.length) - return e.exec ? e.exec(this, t || {}) : e(this, t || {}); - var c = u._eventRegistry; - u._eventRegistry = {}; - var h = new s(o); - this.inVirtualSelectionMode = !0; - for (var p = f.length; p--; ) { - if (i) while (p > 0 && f[p].start.row == f[p - 1].end.row) p--; - h.fromOrientedRange(f[p]), - (h.index = p), - (this.selection = o.selection = h); - var d = e.exec ? e.exec(this, t || {}) : e(this, t || {}); - !l && d !== undefined && (l = d), h.toOrientedRange(f[p]); - } - h.detach(), - (this.selection = o.selection = u), - (this.inVirtualSelectionMode = !1), - (u._eventRegistry = c), - u.mergeOverlappingRanges(); - var v = this.renderer.$scrollAnimation; - return ( - this.onCursorChange(), - this.onSelectionChange(), - v && v.from == v.to && this.renderer.animateScrolling(v.from), - l - ); - }), - (this.exitMultiSelectMode = function() { - if (!this.inMultiSelectMode || this.inVirtualSelectionMode) return; - this.multiSelect.toSingleRange(); - }), - (this.getSelectedText = function() { - var e = ""; - if (this.inMultiSelectMode && !this.inVirtualSelectionMode) { - var t = this.multiSelect.rangeList.ranges, - n = []; - for (var r = 0; r < t.length; r++) - n.push(this.session.getTextRange(t[r])); - var i = this.session.getDocument().getNewLineCharacter(); - (e = n.join(i)), e.length == (n.length - 1) * i.length && (e = ""); - } else - this.selection.isEmpty() || - (e = this.session.getTextRange(this.getSelectionRange())); - return e; - }), - (this.$checkMultiselectChange = function(e, t) { - if (this.inMultiSelectMode && !this.inVirtualSelectionMode) { - var n = this.multiSelect.ranges[0]; - if (this.multiSelect.isEmpty() && t == this.multiSelect.anchor) - return; - var r = - t == this.multiSelect.anchor - ? n.cursor == n.start - ? n.end - : n.start - : n.cursor; - (r.row != t.row || - this.session.$clipPositionToDocument(r.row, r.column).column != - t.column) && - this.multiSelect.toSingleRange( - this.multiSelect.toOrientedRange() - ); - } - }), - (this.findAll = function(e, t, n) { - (t = t || {}), (t.needle = e || t.needle); - if (t.needle == undefined) { - var r = this.selection.isEmpty() - ? this.selection.getWordRange() - : this.selection.getRange(); - t.needle = this.session.getTextRange(r); - } - this.$search.set(t); - var i = this.$search.findAll(this.session); - if (!i.length) return 0; - this.$blockScrolling += 1; - var s = this.multiSelect; - n || s.toSingleRange(i[0]); - for (var o = i.length; o--; ) s.addRange(i[o], !0); - return ( - r && s.rangeList.rangeAtPoint(r.start) && s.addRange(r, !0), - (this.$blockScrolling -= 1), - i.length - ); - }), - (this.selectMoreLines = function(e, t) { - var n = this.selection.toOrientedRange(), - r = n.cursor == n.end, - s = this.session.documentToScreenPosition(n.cursor); - this.selection.$desiredColumn && - (s.column = this.selection.$desiredColumn); - var o = this.session.screenToDocumentPosition(s.row + e, s.column); - if (!n.isEmpty()) - var u = this.session.documentToScreenPosition(r ? n.end : n.start), - a = this.session.screenToDocumentPosition(u.row + e, u.column); - else var a = o; - if (r) { - var f = i.fromPoints(o, a); - f.cursor = f.start; - } else { - var f = i.fromPoints(a, o); - f.cursor = f.end; - } - f.desiredColumn = s.column; - if (!this.selection.inMultiSelectMode) this.selection.addRange(n); - else if (t) var l = n.cursor; - this.selection.addRange(f), l && this.selection.substractPoint(l); - }), - (this.transposeSelections = function(e) { - var t = this.session, - n = t.multiSelect, - r = n.ranges; - for (var i = r.length; i--; ) { - var s = r[i]; - if (s.isEmpty()) { - var o = t.getWordRange(s.start.row, s.start.column); - (s.start.row = o.start.row), - (s.start.column = o.start.column), - (s.end.row = o.end.row), - (s.end.column = o.end.column); + function l(e) { + return e[2] + ? u(i + s - e[2].length) + + e[2] + + u(o, " ") + + e[4].replace(/^([=:])\s+/, "$1 ") + : e[0]; } - } - n.mergeOverlappingRanges(); - var u = []; - for (var i = r.length; i--; ) { - var s = r[i]; - u.unshift(t.getTextRange(s)); - } - e < 0 ? u.unshift(u.pop()) : u.push(u.shift()); - for (var i = r.length; i--; ) { - var s = r[i], - o = s.clone(); - t.replace(s, u[i]), - (s.start.row = o.start.row), - (s.start.column = o.start.column); - } - }), - (this.selectMore = function(e, t, n) { - var r = this.session, - i = r.multiSelect, - s = i.toOrientedRange(); - if (s.isEmpty()) { - (s = r.getWordRange(s.start.row, s.start.column)), - (s.cursor = e == -1 ? s.start : s.end), - this.multiSelect.addRange(s); - if (n) return; - } - var o = r.getTextRange(s), - u = h(r, o, e); - u && - ((u.cursor = e == -1 ? u.start : u.end), - (this.$blockScrolling += 1), - this.session.unfold(u), - this.multiSelect.addRange(u), - (this.$blockScrolling -= 1), - this.renderer.scrollCursorIntoView(null, 0.5)), - t && this.multiSelect.substractPoint(s.cursor); - }), - (this.alignCursors = function() { - var e = this.session, - t = e.multiSelect, - n = t.ranges, - r = -1, - s = n.filter(function(e) { - if (e.cursor.row == r) return !0; - r = e.cursor.row; - }); - if (!n.length || s.length == n.length - 1) { - var o = this.selection.getRange(), - u = o.start.row, - f = o.end.row, - l = u == f; - if (l) { - var c = this.session.getLength(), - h; - do h = this.session.getLine(f); - while (/[=:]/.test(h) && ++f < c); - do h = this.session.getLine(u); - while (/[=:]/.test(h) && --u > 0); - u < 0 && (u = 0), f >= c && (f = c - 1); - } - var p = this.session.removeFullLines(u, f); - (p = this.$reAlignText(p, l)), - this.session.insert({ row: u, column: 0 }, p.join("\n") + "\n"), - l || - ((o.start.column = 0), (o.end.column = p[p.length - 1].length)), - this.selection.setRange(o); - } else { - s.forEach(function(e) { - t.substractPoint(e.cursor); - }); - var d = 0, - v = Infinity, - m = n.map(function(t) { - var n = t.cursor, - r = e.getLine(n.row), - i = r.substr(n.column).search(/\S/g); - return ( - i == -1 && (i = 0), - n.column > d && (d = n.column), - i < v && (v = i), - i - ); - }); - n.forEach(function(t, n) { - var r = t.cursor, - s = d - r.column, - o = m[n] - v; - s > o - ? e.insert(r, a.stringRepeat(" ", s - o)) - : e.remove(new i(r.row, r.column, r.row, r.column - s + o)), - (t.start.column = t.end.column = d), - (t.start.row = t.end.row = r.row), - (t.cursor = t.end); - }), - t.fromOrientedRange(n[0]), - this.renderer.updateCursor(), - this.renderer.updateBackMarkers(); - } - }), - (this.$reAlignText = function(e, t) { - function u(e) { - return a.stringRepeat(" ", e); - } - function f(e) { - return e[2] - ? u(i) + - e[2] + - u(s - e[2].length + o) + - e[4].replace(/^([=:])\s+/, "$1 ") - : e[0]; - } - function l(e) { - return e[2] - ? u(i + s - e[2].length) + - e[2] + - u(o, " ") + - e[4].replace(/^([=:])\s+/, "$1 ") - : e[0]; - } - function c(e) { - return e[2] - ? u(i) + e[2] + u(o) + e[4].replace(/^([=:])\s+/, "$1 ") - : e[0]; - } - var n = !0, - r = !0, - i, - s, - o; - return e - .map(function(e) { - var t = e.match(/(\s*)(.*?)(\s*)([=:].*)/); - return t - ? i == null - ? ((i = t[1].length), (s = t[2].length), (o = t[3].length), t) - : (i + s + o != t[1].length + t[2].length + t[3].length && - (r = !1), - i != t[1].length && (n = !1), - i > t[1].length && (i = t[1].length), - s < t[2].length && (s = t[2].length), - o > t[3].length && (o = t[3].length), - t) - : [e]; - }) - .map(t ? f : n ? (r ? l : f) : c); - }); - }.call(d.prototype), - (t.onSessionChange = function(e) { - var t = e.session; - t && - !t.multiSelect && - ((t.$selectionMarkers = []), - t.selection.$initRangeList(), - (t.multiSelect = t.selection)), - (this.multiSelect = t && t.multiSelect); - var n = e.oldSession; - n && - (n.multiSelect.off("addRange", this.$onAddRange), - n.multiSelect.off("removeRange", this.$onRemoveRange), - n.multiSelect.off("multiSelect", this.$onMultiSelect), - n.multiSelect.off("singleSelect", this.$onSingleSelect), - n.multiSelect.lead.off("change", this.$checkMultiselectChange), - n.multiSelect.anchor.off("change", this.$checkMultiselectChange)), - t && - (t.multiSelect.on("addRange", this.$onAddRange), - t.multiSelect.on("removeRange", this.$onRemoveRange), - t.multiSelect.on("multiSelect", this.$onMultiSelect), - t.multiSelect.on("singleSelect", this.$onSingleSelect), - t.multiSelect.lead.on("change", this.$checkMultiselectChange), - t.multiSelect.anchor.on("change", this.$checkMultiselectChange)), - t && - this.inMultiSelectMode != t.selection.inMultiSelectMode && - (t.selection.inMultiSelectMode - ? this.$onMultiSelect() - : this.$onSingleSelect()); - }), - (t.MultiSelect = m), - e("./config").defineOptions(d.prototype, "editor", { - enableMultiselect: { - set: function(e) { - m(this), - e - ? (this.on("changeSession", this.$multiselectOnSessionChange), - this.on("mousedown", o)) - : (this.off("changeSession", this.$multiselectOnSessionChange), - this.off("mousedown", o)); - }, - value: !0 - }, - enableBlockSelect: { - set: function(e) { - this.$blockSelectEnabled = e; + function c(e) { + return e[2] + ? u(i) + e[2] + u(o) + e[4].replace(/^([=:])\s+/, "$1 ") + : e[0]; + } + var n = !0, + r = !0, + i, + s, + o; + return e + .map(function (e) { + var t = e.match(/(\s*)(.*?)(\s*)([=:].*)/); + return t + ? i == null + ? ((i = t[1].length), + (s = t[2].length), + (o = t[3].length), + t) + : (i + s + o != t[1].length + t[2].length + t[3].length && + (r = !1), + i != t[1].length && (n = !1), + i > t[1].length && (i = t[1].length), + s < t[2].length && (s = t[2].length), + o > t[3].length && (o = t[3].length), + t) + : [e]; + }) + .map(t ? f : n ? (r ? l : f) : c); + })); + }).call(d.prototype), + (t.onSessionChange = function (e) { + var t = e.session; + (t && + !t.multiSelect && + ((t.$selectionMarkers = []), + t.selection.$initRangeList(), + (t.multiSelect = t.selection)), + (this.multiSelect = t && t.multiSelect)); + var n = e.oldSession; + (n && + (n.multiSelect.off("addRange", this.$onAddRange), + n.multiSelect.off("removeRange", this.$onRemoveRange), + n.multiSelect.off("multiSelect", this.$onMultiSelect), + n.multiSelect.off("singleSelect", this.$onSingleSelect), + n.multiSelect.lead.off("change", this.$checkMultiselectChange), + n.multiSelect.anchor.off("change", this.$checkMultiselectChange)), + t && + (t.multiSelect.on("addRange", this.$onAddRange), + t.multiSelect.on("removeRange", this.$onRemoveRange), + t.multiSelect.on("multiSelect", this.$onMultiSelect), + t.multiSelect.on("singleSelect", this.$onSingleSelect), + t.multiSelect.lead.on("change", this.$checkMultiselectChange), + t.multiSelect.anchor.on("change", this.$checkMultiselectChange)), + t && + this.inMultiSelectMode != t.selection.inMultiSelectMode && + (t.selection.inMultiSelectMode + ? this.$onMultiSelect() + : this.$onSingleSelect())); + }), + (t.MultiSelect = m), + e("./config").defineOptions(d.prototype, "editor", { + enableMultiselect: { + set: function (e) { + (m(this), + e + ? (this.on("changeSession", this.$multiselectOnSessionChange), + this.on("mousedown", o)) + : (this.off( + "changeSession", + this.$multiselectOnSessionChange + ), + this.off("mousedown", o))); + }, + value: !0 }, - value: !0 - } - })); - }), - define("ace/mode/folding/fold_mode", [ - "require", - "exports", - "module", - "ace/range" - ], function(e, t, n) { - "use strict"; - var r = e("../../range").Range, - i = (t.FoldMode = function() {}); - (function() { - (this.foldingStartMarker = null), - (this.foldingStopMarker = null), - (this.getFoldWidget = function(e, t, n) { - var r = e.getLine(n); - return this.foldingStartMarker.test(r) - ? "start" - : t == "markbeginend" && - this.foldingStopMarker && - this.foldingStopMarker.test(r) - ? "end" - : ""; - }), - (this.getFoldWidgetRange = function(e, t, n) { - return null; - }), - (this.indentationBlock = function(e, t, n) { - var i = /\S/, - s = e.getLine(t), - o = s.search(i); - if (o == -1) return; - var u = n || s.length, - a = e.getLength(), - f = t, - l = t; - while (++t < a) { - var c = e.getLine(t).search(i); - if (c == -1) continue; - if (c <= o) break; - l = t; - } - if (l > f) { - var h = e.getLine(l).length; - return new r(f, u, l, h); + enableBlockSelect: { + set: function (e) { + this.$blockSelectEnabled = e; + }, + value: !0 } - }), - (this.openingBracketBlock = function(e, t, n, i, s) { - var o = { row: n, column: i + 1 }, - u = e.$findClosingBracket(t, o, s); - if (!u) return; - var a = e.foldWidgets[u.row]; - return ( - a == null && (a = e.getFoldWidget(u.row)), - a == "start" && - u.row > o.row && - (u.row--, (u.column = e.getLine(u.row).length)), - r.fromPoints(o, u) - ); - }), - (this.closingBracketBlock = function(e, t, n, i, s) { - var o = { row: n, column: i }, - u = e.$findOpeningBracket(t, o); - if (!u) return; - return u.column++, o.column--, r.fromPoints(u, o); - }); - }.call(i.prototype)); - }), - define("ace/theme/textmate", [ - "require", - "exports", - "module", - "ace/lib/dom" - ], function(e, t, n) { - "use strict"; - (t.isDark = !1), - (t.cssClass = "ace-tm"), - (t.cssText = - '.ace-tm .ace_gutter {background: #f0f0f0;color: #333;}.ace-tm .ace_print-margin {width: 1px;background: #e8e8e8;}.ace-tm .ace_fold {background-color: #6B72E6;}.ace-tm {background-color: #FFFFFF;color: black;}.ace-tm .ace_cursor {color: black;}.ace-tm .ace_invisible {color: rgb(191, 191, 191);}.ace-tm .ace_storage,.ace-tm .ace_keyword {color: blue;}.ace-tm .ace_constant {color: rgb(197, 6, 11);}.ace-tm .ace_constant.ace_buildin {color: rgb(88, 72, 246);}.ace-tm .ace_constant.ace_language {color: rgb(88, 92, 246);}.ace-tm .ace_constant.ace_library {color: rgb(6, 150, 14);}.ace-tm .ace_invalid {background-color: rgba(255, 0, 0, 0.1);color: red;}.ace-tm .ace_support.ace_function {color: rgb(60, 76, 114);}.ace-tm .ace_support.ace_constant {color: rgb(6, 150, 14);}.ace-tm .ace_support.ace_type,.ace-tm .ace_support.ace_class {color: rgb(109, 121, 222);}.ace-tm .ace_keyword.ace_operator {color: rgb(104, 118, 135);}.ace-tm .ace_string {color: rgb(3, 106, 7);}.ace-tm .ace_comment {color: rgb(76, 136, 107);}.ace-tm .ace_comment.ace_doc {color: rgb(0, 102, 255);}.ace-tm .ace_comment.ace_doc.ace_tag {color: rgb(128, 159, 191);}.ace-tm .ace_constant.ace_numeric {color: rgb(0, 0, 205);}.ace-tm .ace_variable {color: rgb(49, 132, 149);}.ace-tm .ace_xml-pe {color: rgb(104, 104, 91);}.ace-tm .ace_entity.ace_name.ace_function {color: #0000A2;}.ace-tm .ace_heading {color: rgb(12, 7, 255);}.ace-tm .ace_list {color:rgb(185, 6, 144);}.ace-tm .ace_meta.ace_tag {color:rgb(0, 22, 142);}.ace-tm .ace_string.ace_regex {color: rgb(255, 0, 0)}.ace-tm .ace_marker-layer .ace_selection {background: rgb(181, 213, 255);}.ace-tm.ace_multiselect .ace_selection.ace_start {box-shadow: 0 0 3px 0px white;}.ace-tm .ace_marker-layer .ace_step {background: rgb(252, 255, 0);}.ace-tm .ace_marker-layer .ace_stack {background: rgb(164, 229, 101);}.ace-tm .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid rgb(192, 192, 192);}.ace-tm .ace_marker-layer .ace_active-line {background: rgba(0, 0, 0, 0.07);}.ace-tm .ace_gutter-active-line {background-color : #dcdcdc;}.ace-tm .ace_marker-layer .ace_selected-word {background: rgb(250, 250, 255);border: 1px solid rgb(200, 200, 250);}.ace-tm .ace_indent-guide {background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==") right repeat-y;}'); - var r = e("../lib/dom"); - r.importCssString(t.cssText, t.cssClass); - }), - define("ace/line_widgets", [ - "require", - "exports", - "module", - "ace/lib/oop", - "ace/lib/dom", - "ace/range" - ], function(e, t, n) { - "use strict"; - function o(e) { - (this.session = e), - (this.session.widgetManager = this), - (this.session.getRowLength = this.getRowLength), - (this.session.$getWidgetScreenLength = this.$getWidgetScreenLength), - (this.updateOnChange = this.updateOnChange.bind(this)), - (this.renderWidgets = this.renderWidgets.bind(this)), - (this.measureWidgets = this.measureWidgets.bind(this)), - (this.session._changedWidgets = []), - (this.$onChangeEditor = this.$onChangeEditor.bind(this)), - this.session.on("change", this.updateOnChange), - this.session.on("changeFold", this.updateOnFold), - this.session.on("changeEditor", this.$onChangeEditor); + })); } - var r = e("./lib/oop"), - i = e("./lib/dom"), - s = e("./range").Range; - (function() { - (this.getRowLength = function(e) { - var t; - return ( - this.lineWidgets - ? (t = (this.lineWidgets[e] && this.lineWidgets[e].rowCount) || 0) - : (t = 0), - !this.$useWrapMode || !this.$wrapData[e] - ? 1 + t - : this.$wrapData[e].length + 1 + t - ); - }), - (this.$getWidgetScreenLength = function() { - var e = 0; + ), + define( + "ace/mode/folding/fold_mode", + ["require", "exports", "module", "ace/range"], + function (e, t, n) { + "use strict"; + var r = e("../../range").Range, + i = (t.FoldMode = function () {}); + (function () { + ((this.foldingStartMarker = null), + (this.foldingStopMarker = null), + (this.getFoldWidget = function (e, t, n) { + var r = e.getLine(n); + return this.foldingStartMarker.test(r) + ? "start" + : t == "markbeginend" && + this.foldingStopMarker && + this.foldingStopMarker.test(r) + ? "end" + : ""; + }), + (this.getFoldWidgetRange = function (e, t, n) { + return null; + }), + (this.indentationBlock = function (e, t, n) { + var i = /\S/, + s = e.getLine(t), + o = s.search(i); + if (o == -1) return; + var u = n || s.length, + a = e.getLength(), + f = t, + l = t; + while (++t < a) { + var c = e.getLine(t).search(i); + if (c == -1) continue; + if (c <= o) break; + l = t; + } + if (l > f) { + var h = e.getLine(l).length; + return new r(f, u, l, h); + } + }), + (this.openingBracketBlock = function (e, t, n, i, s) { + var o = { row: n, column: i + 1 }, + u = e.$findClosingBracket(t, o, s); + if (!u) return; + var a = e.foldWidgets[u.row]; + return ( + a == null && (a = e.getFoldWidget(u.row)), + a == "start" && + u.row > o.row && + (u.row--, (u.column = e.getLine(u.row).length)), + r.fromPoints(o, u) + ); + }), + (this.closingBracketBlock = function (e, t, n, i, s) { + var o = { row: n, column: i }, + u = e.$findOpeningBracket(t, o); + if (!u) return; + return (u.column++, o.column--, r.fromPoints(u, o)); + })); + }).call(i.prototype); + } + ), + define( + "ace/theme/textmate", + ["require", "exports", "module", "ace/lib/dom"], + function (e, t, n) { + "use strict"; + ((t.isDark = !1), + (t.cssClass = "ace-tm"), + (t.cssText = + '.ace-tm .ace_gutter {background: #f0f0f0;color: #333;}.ace-tm .ace_print-margin {width: 1px;background: #e8e8e8;}.ace-tm .ace_fold {background-color: #6B72E6;}.ace-tm {background-color: #FFFFFF;color: black;}.ace-tm .ace_cursor {color: black;}.ace-tm .ace_invisible {color: rgb(191, 191, 191);}.ace-tm .ace_storage,.ace-tm .ace_keyword {color: blue;}.ace-tm .ace_constant {color: rgb(197, 6, 11);}.ace-tm .ace_constant.ace_buildin {color: rgb(88, 72, 246);}.ace-tm .ace_constant.ace_language {color: rgb(88, 92, 246);}.ace-tm .ace_constant.ace_library {color: rgb(6, 150, 14);}.ace-tm .ace_invalid {background-color: rgba(255, 0, 0, 0.1);color: red;}.ace-tm .ace_support.ace_function {color: rgb(60, 76, 114);}.ace-tm .ace_support.ace_constant {color: rgb(6, 150, 14);}.ace-tm .ace_support.ace_type,.ace-tm .ace_support.ace_class {color: rgb(109, 121, 222);}.ace-tm .ace_keyword.ace_operator {color: rgb(104, 118, 135);}.ace-tm .ace_string {color: rgb(3, 106, 7);}.ace-tm .ace_comment {color: rgb(76, 136, 107);}.ace-tm .ace_comment.ace_doc {color: rgb(0, 102, 255);}.ace-tm .ace_comment.ace_doc.ace_tag {color: rgb(128, 159, 191);}.ace-tm .ace_constant.ace_numeric {color: rgb(0, 0, 205);}.ace-tm .ace_variable {color: rgb(49, 132, 149);}.ace-tm .ace_xml-pe {color: rgb(104, 104, 91);}.ace-tm .ace_entity.ace_name.ace_function {color: #0000A2;}.ace-tm .ace_heading {color: rgb(12, 7, 255);}.ace-tm .ace_list {color:rgb(185, 6, 144);}.ace-tm .ace_meta.ace_tag {color:rgb(0, 22, 142);}.ace-tm .ace_string.ace_regex {color: rgb(255, 0, 0)}.ace-tm .ace_marker-layer .ace_selection {background: rgb(181, 213, 255);}.ace-tm.ace_multiselect .ace_selection.ace_start {box-shadow: 0 0 3px 0px white;}.ace-tm .ace_marker-layer .ace_step {background: rgb(252, 255, 0);}.ace-tm .ace_marker-layer .ace_stack {background: rgb(164, 229, 101);}.ace-tm .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid rgb(192, 192, 192);}.ace-tm .ace_marker-layer .ace_active-line {background: rgba(0, 0, 0, 0.07);}.ace-tm .ace_gutter-active-line {background-color : #dcdcdc;}.ace-tm .ace_marker-layer .ace_selected-word {background: rgb(250, 250, 255);border: 1px solid rgb(200, 200, 250);}.ace-tm .ace_indent-guide {background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==") right repeat-y;}')); + var r = e("../lib/dom"); + r.importCssString(t.cssText, t.cssClass); + } + ), + define( + "ace/line_widgets", + ["require", "exports", "module", "ace/lib/oop", "ace/lib/dom", "ace/range"], + function (e, t, n) { + "use strict"; + function o(e) { + ((this.session = e), + (this.session.widgetManager = this), + (this.session.getRowLength = this.getRowLength), + (this.session.$getWidgetScreenLength = this.$getWidgetScreenLength), + (this.updateOnChange = this.updateOnChange.bind(this)), + (this.renderWidgets = this.renderWidgets.bind(this)), + (this.measureWidgets = this.measureWidgets.bind(this)), + (this.session._changedWidgets = []), + (this.$onChangeEditor = this.$onChangeEditor.bind(this)), + this.session.on("change", this.updateOnChange), + this.session.on("changeFold", this.updateOnFold), + this.session.on("changeEditor", this.$onChangeEditor)); + } + var r = e("./lib/oop"), + i = e("./lib/dom"), + s = e("./range").Range; + ((function () { + ((this.getRowLength = function (e) { + var t; return ( - this.lineWidgets.forEach(function(t) { - t && t.rowCount && !t.hidden && (e += t.rowCount); - }), - e + this.lineWidgets + ? (t = (this.lineWidgets[e] && this.lineWidgets[e].rowCount) || 0) + : (t = 0), + !this.$useWrapMode || !this.$wrapData[e] + ? 1 + t + : this.$wrapData[e].length + 1 + t ); }), - (this.$onChangeEditor = function(e) { - this.attach(e.editor); - }), - (this.attach = function(e) { - e && - e.widgetManager && - e.widgetManager != this && - e.widgetManager.detach(); - if (this.editor == e) return; - this.detach(), - (this.editor = e), + (this.$getWidgetScreenLength = function () { + var e = 0; + return ( + this.lineWidgets.forEach(function (t) { + t && t.rowCount && !t.hidden && (e += t.rowCount); + }), + e + ); + }), + (this.$onChangeEditor = function (e) { + this.attach(e.editor); + }), + (this.attach = function (e) { e && - ((e.widgetManager = this), - e.renderer.on("beforeRender", this.measureWidgets), - e.renderer.on("afterRender", this.renderWidgets)); - }), - (this.detach = function(e) { - var t = this.editor; - if (!t) return; - (this.editor = null), - (t.widgetManager = null), - t.renderer.off("beforeRender", this.measureWidgets), - t.renderer.off("afterRender", this.renderWidgets); - var n = this.session.lineWidgets; - n && - n.forEach(function(e) { + e.widgetManager && + e.widgetManager != this && + e.widgetManager.detach(); + if (this.editor == e) return; + (this.detach(), + (this.editor = e), e && - e.el && - e.el.parentNode && - ((e._inDocument = !1), e.el.parentNode.removeChild(e.el)); - }); - }), - (this.updateOnFold = function(e, t) { - var n = t.lineWidgets; - if (!n || !e.action) return; - var r = e.data, - i = r.start.row, - s = r.end.row, - o = e.action == "add"; - for (var u = i + 1; u < s; u++) n[u] && (n[u].hidden = o); - n[s] && - (o - ? n[i] - ? (n[s].hidden = o) - : (n[i] = n[s]) - : (n[i] == n[s] && (n[i] = undefined), (n[s].hidden = o))); - }), - (this.updateOnChange = function(e) { - var t = this.session.lineWidgets; - if (!t) return; - var n = e.start.row, - r = e.end.row - n; - if (r !== 0) - if (e.action == "remove") { - var i = t.splice(n + 1, r); - i.forEach(function(e) { - e && this.removeLineWidget(e); - }, this), - this.$updateRows(); - } else { - var s = new Array(r); - s.unshift(n, 0), t.splice.apply(t, s), this.$updateRows(); - } - }), - (this.$updateRows = function() { - var e = this.session.lineWidgets; - if (!e) return; - var t = !0; - e.forEach(function(e, n) { - if (e) { - (t = !1), (e.row = n); - while (e.$oldWidget) (e.$oldWidget.row = n), (e = e.$oldWidget); + ((e.widgetManager = this), + e.renderer.on("beforeRender", this.measureWidgets), + e.renderer.on("afterRender", this.renderWidgets))); + }), + (this.detach = function (e) { + var t = this.editor; + if (!t) return; + ((this.editor = null), + (t.widgetManager = null), + t.renderer.off("beforeRender", this.measureWidgets), + t.renderer.off("afterRender", this.renderWidgets)); + var n = this.session.lineWidgets; + n && + n.forEach(function (e) { + e && + e.el && + e.el.parentNode && + ((e._inDocument = !1), e.el.parentNode.removeChild(e.el)); + }); + }), + (this.updateOnFold = function (e, t) { + var n = t.lineWidgets; + if (!n || !e.action) return; + var r = e.data, + i = r.start.row, + s = r.end.row, + o = e.action == "add"; + for (var u = i + 1; u < s; u++) n[u] && (n[u].hidden = o); + n[s] && + (o + ? n[i] + ? (n[s].hidden = o) + : (n[i] = n[s]) + : (n[i] == n[s] && (n[i] = undefined), (n[s].hidden = o))); + }), + (this.updateOnChange = function (e) { + var t = this.session.lineWidgets; + if (!t) return; + var n = e.start.row, + r = e.end.row - n; + if (r !== 0) + if (e.action == "remove") { + var i = t.splice(n + 1, r); + (i.forEach(function (e) { + e && this.removeLineWidget(e); + }, this), + this.$updateRows()); + } else { + var s = new Array(r); + (s.unshift(n, 0), t.splice.apply(t, s), this.$updateRows()); + } + }), + (this.$updateRows = function () { + var e = this.session.lineWidgets; + if (!e) return; + var t = !0; + (e.forEach(function (e, n) { + if (e) { + ((t = !1), (e.row = n)); + while (e.$oldWidget) + ((e.$oldWidget.row = n), (e = e.$oldWidget)); + } + }), + t && (this.session.lineWidgets = null)); + }), + (this.addLineWidget = function (e) { + this.session.lineWidgets || + (this.session.lineWidgets = new Array(this.session.getLength())); + var t = this.session.lineWidgets[e.row]; + (t && + ((e.$oldWidget = t), + t.el && + t.el.parentNode && + (t.el.parentNode.removeChild(t.el), (t._inDocument = !1))), + (this.session.lineWidgets[e.row] = e), + (e.session = this.session)); + var n = this.editor.renderer; + (e.html && + !e.el && + ((e.el = i.createElement("div")), (e.el.innerHTML = e.html)), + e.el && + (i.addCssClass(e.el, "ace_lineWidgetContainer"), + (e.el.style.position = "absolute"), + (e.el.style.zIndex = 5), + n.container.appendChild(e.el), + (e._inDocument = !0)), + e.coverGutter || (e.el.style.zIndex = 3), + e.pixelHeight == null && (e.pixelHeight = e.el.offsetHeight), + e.rowCount == null && + (e.rowCount = e.pixelHeight / n.layerConfig.lineHeight)); + var r = this.session.getFoldAt(e.row, 0); + e.$fold = r; + if (r) { + var s = this.session.lineWidgets; + e.row == r.end.row && !s[r.start.row] + ? (s[r.start.row] = e) + : (e.hidden = !0); } + return ( + this.session._emit("changeFold", { + data: { start: { row: e.row } } + }), + this.$updateRows(), + this.renderWidgets(null, n), + this.onWidgetChanged(e), + e + ); }), - t && (this.session.lineWidgets = null); - }), - (this.addLineWidget = function(e) { - this.session.lineWidgets || - (this.session.lineWidgets = new Array(this.session.getLength())); - var t = this.session.lineWidgets[e.row]; - t && - ((e.$oldWidget = t), - t.el && - t.el.parentNode && - (t.el.parentNode.removeChild(t.el), (t._inDocument = !1))), - (this.session.lineWidgets[e.row] = e), - (e.session = this.session); - var n = this.editor.renderer; - e.html && - !e.el && - ((e.el = i.createElement("div")), (e.el.innerHTML = e.html)), - e.el && - (i.addCssClass(e.el, "ace_lineWidgetContainer"), - (e.el.style.position = "absolute"), - (e.el.style.zIndex = 5), - n.container.appendChild(e.el), - (e._inDocument = !0)), - e.coverGutter || (e.el.style.zIndex = 3), - e.pixelHeight == null && (e.pixelHeight = e.el.offsetHeight), - e.rowCount == null && - (e.rowCount = e.pixelHeight / n.layerConfig.lineHeight); - var r = this.session.getFoldAt(e.row, 0); - e.$fold = r; - if (r) { - var s = this.session.lineWidgets; - e.row == r.end.row && !s[r.start.row] - ? (s[r.start.row] = e) - : (e.hidden = !0); - } - return ( - this.session._emit("changeFold", { + (this.removeLineWidget = function (e) { + ((e._inDocument = !1), + (e.session = null), + e.el && e.el.parentNode && e.el.parentNode.removeChild(e.el)); + if (e.editor && e.editor.destroy) + try { + e.editor.destroy(); + } catch (t) {} + if (this.session.lineWidgets) { + var n = this.session.lineWidgets[e.row]; + if (n == e) + ((this.session.lineWidgets[e.row] = e.$oldWidget), + e.$oldWidget && this.onWidgetChanged(e.$oldWidget)); + else + while (n) { + if (n.$oldWidget == e) { + n.$oldWidget = e.$oldWidget; + break; + } + n = n.$oldWidget; + } + } + (this.session._emit("changeFold", { data: { start: { row: e.row } } }), - this.$updateRows(), - this.renderWidgets(null, n), - this.onWidgetChanged(e), - e - ); - }), - (this.removeLineWidget = function(e) { - (e._inDocument = !1), - (e.session = null), - e.el && e.el.parentNode && e.el.parentNode.removeChild(e.el); - if (e.editor && e.editor.destroy) - try { - e.editor.destroy(); - } catch (t) {} - if (this.session.lineWidgets) { - var n = this.session.lineWidgets[e.row]; - if (n == e) - (this.session.lineWidgets[e.row] = e.$oldWidget), - e.$oldWidget && this.onWidgetChanged(e.$oldWidget); - else - while (n) { - if (n.$oldWidget == e) { - n.$oldWidget = e.$oldWidget; - break; - } - n = n.$oldWidget; + this.$updateRows()); + }), + (this.getWidgetsAtRow = function (e) { + var t = this.session.lineWidgets, + n = t && t[e], + r = []; + while (n) (r.push(n), (n = n.$oldWidget)); + return r; + }), + (this.onWidgetChanged = function (e) { + (this.session._changedWidgets.push(e), + this.editor && this.editor.renderer.updateFull()); + }), + (this.measureWidgets = function (e, t) { + var n = this.session._changedWidgets, + r = t.layerConfig; + if (!n || !n.length) return; + var i = Infinity; + for (var s = 0; s < n.length; s++) { + var o = n[s]; + if (!o || !o.el) continue; + if (o.session != this.session) continue; + if (!o._inDocument) { + if (this.session.lineWidgets[o.row] != o) continue; + ((o._inDocument = !0), t.container.appendChild(o.el)); } - } - this.session._emit("changeFold", { data: { start: { row: e.row } } }), - this.$updateRows(); - }), - (this.getWidgetsAtRow = function(e) { - var t = this.session.lineWidgets, - n = t && t[e], - r = []; - while (n) r.push(n), (n = n.$oldWidget); - return r; - }), - (this.onWidgetChanged = function(e) { - this.session._changedWidgets.push(e), - this.editor && this.editor.renderer.updateFull(); - }), - (this.measureWidgets = function(e, t) { - var n = this.session._changedWidgets, - r = t.layerConfig; - if (!n || !n.length) return; - var i = Infinity; - for (var s = 0; s < n.length; s++) { - var o = n[s]; - if (!o || !o.el) continue; - if (o.session != this.session) continue; - if (!o._inDocument) { - if (this.session.lineWidgets[o.row] != o) continue; - (o._inDocument = !0), t.container.appendChild(o.el); - } - (o.h = o.el.offsetHeight), - o.fixedWidth || - ((o.w = o.el.offsetWidth), - (o.screenWidth = Math.ceil(o.w / r.characterWidth))); - var u = o.h / r.lineHeight; - o.coverLine && - ((u -= this.session.getRowLineCount(o.row)), u < 0 && (u = 0)), - o.rowCount != u && ((o.rowCount = u), o.row < i && (i = o.row)); - } - i != Infinity && - (this.session._emit("changeFold", { data: { start: { row: i } } }), - (this.session.lineWidgetWidth = null)), - (this.session._changedWidgets = []); - }), - (this.renderWidgets = function(e, t) { - var n = t.layerConfig, - r = this.session.lineWidgets; - if (!r) return; - var i = Math.min(this.firstRow, n.firstRow), - s = Math.max(this.lastRow, n.lastRow, r.length); - while (i > 0 && !r[i]) i--; - (this.firstRow = n.firstRow), - (this.lastRow = n.lastRow), - (t.$cursorLayer.config = n); - for (var o = i; o <= s; o++) { - var u = r[o]; - if (!u || !u.el) continue; - if (u.hidden) { - u.el.style.top = -100 - (u.pixelHeight || 0) + "px"; - continue; + ((o.h = o.el.offsetHeight), + o.fixedWidth || + ((o.w = o.el.offsetWidth), + (o.screenWidth = Math.ceil(o.w / r.characterWidth)))); + var u = o.h / r.lineHeight; + (o.coverLine && + ((u -= this.session.getRowLineCount(o.row)), u < 0 && (u = 0)), + o.rowCount != u && + ((o.rowCount = u), o.row < i && (i = o.row))); + } + (i != Infinity && + (this.session._emit("changeFold", { + data: { start: { row: i } } + }), + (this.session.lineWidgetWidth = null)), + (this.session._changedWidgets = [])); + }), + (this.renderWidgets = function (e, t) { + var n = t.layerConfig, + r = this.session.lineWidgets; + if (!r) return; + var i = Math.min(this.firstRow, n.firstRow), + s = Math.max(this.lastRow, n.lastRow, r.length); + while (i > 0 && !r[i]) i--; + ((this.firstRow = n.firstRow), + (this.lastRow = n.lastRow), + (t.$cursorLayer.config = n)); + for (var o = i; o <= s; o++) { + var u = r[o]; + if (!u || !u.el) continue; + if (u.hidden) { + u.el.style.top = -100 - (u.pixelHeight || 0) + "px"; + continue; + } + u._inDocument || + ((u._inDocument = !0), t.container.appendChild(u.el)); + var a = t.$cursorLayer.getPixelPosition( + { row: o, column: 0 }, + !0 + ).top; + (u.coverLine || + (a += n.lineHeight * this.session.getRowLineCount(u.row)), + (u.el.style.top = a - n.offset + "px")); + var f = u.coverGutter ? 0 : t.gutterWidth; + (u.fixedWidth || (f -= t.scrollLeft), + (u.el.style.left = f + "px"), + u.fullWidth && + u.screenWidth && + (u.el.style.minWidth = n.width + 2 * n.padding + "px"), + u.fixedWidth + ? (u.el.style.right = t.scrollBar.getWidth() + "px") + : (u.el.style.right = "")); } - u._inDocument || - ((u._inDocument = !0), t.container.appendChild(u.el)); - var a = t.$cursorLayer.getPixelPosition({ row: o, column: 0 }, !0) - .top; - u.coverLine || - (a += n.lineHeight * this.session.getRowLineCount(u.row)), - (u.el.style.top = a - n.offset + "px"); - var f = u.coverGutter ? 0 : t.gutterWidth; - u.fixedWidth || (f -= t.scrollLeft), - (u.el.style.left = f + "px"), - u.fullWidth && - u.screenWidth && - (u.el.style.minWidth = n.width + 2 * n.padding + "px"), - u.fixedWidth - ? (u.el.style.right = t.scrollBar.getWidth() + "px") - : (u.el.style.right = ""); + })); + }).call(o.prototype), + (t.LineWidgets = o)); + } + ), + define( + "ace/ext/error_marker", + [ + "require", + "exports", + "module", + "ace/line_widgets", + "ace/lib/dom", + "ace/range" + ], + function (e, t, n) { + "use strict"; + function o(e, t, n) { + var r = 0, + i = e.length - 1; + while (r <= i) { + var s = (r + i) >> 1, + o = n(t, e[s]); + if (o > 0) r = s + 1; + else { + if (!(o < 0)) return s; + i = s - 1; } - }); - }.call(o.prototype), - (t.LineWidgets = o)); - }), - define("ace/ext/error_marker", [ - "require", - "exports", - "module", - "ace/line_widgets", - "ace/lib/dom", - "ace/range" - ], function(e, t, n) { - "use strict"; - function o(e, t, n) { - var r = 0, - i = e.length - 1; - while (r <= i) { - var s = (r + i) >> 1, - o = n(t, e[s]); - if (o > 0) r = s + 1; - else { - if (!(o < 0)) return s; - i = s - 1; } + return -(r + 1); } - return -(r + 1); - } - function u(e, t, n) { - var r = e.getAnnotations().sort(s.comparePoints); - if (!r.length) return; - var i = o(r, { row: t, column: -1 }, s.comparePoints); - i < 0 && (i = -i - 1), - i >= r.length - ? (i = n > 0 ? 0 : r.length - 1) - : i === 0 && n < 0 && (i = r.length - 1); - var u = r[i]; - if (!u || !n) return; - if (u.row === t) { - do u = r[(i += n)]; - while (u && u.row === t); - if (!u) return r.slice(); - } - var a = []; - t = u.row; - do a[n < 0 ? "unshift" : "push"](u), (u = r[(i += n)]); - while (u && u.row == t); - return a.length && a; - } - var r = e("../line_widgets").LineWidgets, - i = e("../lib/dom"), - s = e("../range").Range; - (t.showErrorMarker = function(e, t) { - var n = e.session; - n.widgetManager || - ((n.widgetManager = new r(n)), n.widgetManager.attach(e)); - var s = e.getCursorPosition(), - o = s.row, - a = n.widgetManager.getWidgetsAtRow(o).filter(function(e) { - return e.type == "errorMarker"; - })[0]; - a ? a.destroy() : (o -= t); - var f = u(n, o, t), - l; - if (f) { - var c = f[0]; - (s.column = - (c.pos && typeof c.column != "number" ? c.pos.sc : c.column) || 0), - (s.row = c.row), - (l = e.renderer.$gutterLayer.$annotations[s.row]); - } else { - if (a) return; - l = { text: ["Looks good!"], className: "ace_ok" }; + function u(e, t, n) { + var r = e.getAnnotations().sort(s.comparePoints); + if (!r.length) return; + var i = o(r, { row: t, column: -1 }, s.comparePoints); + (i < 0 && (i = -i - 1), + i >= r.length + ? (i = n > 0 ? 0 : r.length - 1) + : i === 0 && n < 0 && (i = r.length - 1)); + var u = r[i]; + if (!u || !n) return; + if (u.row === t) { + do u = r[(i += n)]; + while (u && u.row === t); + if (!u) return r.slice(); + } + var a = []; + t = u.row; + do (a[n < 0 ? "unshift" : "push"](u), (u = r[(i += n)])); + while (u && u.row == t); + return a.length && a; } - e.session.unfold(s.row), e.selection.moveToPosition(s); - var h = { - row: s.row, - fixedWidth: !0, - coverGutter: !0, - el: i.createElement("div"), - type: "errorMarker" - }, - p = h.el.appendChild(i.createElement("div")), - d = h.el.appendChild(i.createElement("div")); - d.className = "error_widget_arrow " + l.className; - var v = e.renderer.$cursorLayer.getPixelPosition(s).left; - (d.style.left = v + e.renderer.gutterWidth - 5 + "px"), - (h.el.className = "error_widget_wrapper"), - (p.className = "error_widget " + l.className), - (p.innerHTML = l.text.join("
")), - p.appendChild(i.createElement("div")); - var m = function(e, t, n) { - if (t === 0 && (n === "esc" || n === "return")) - return h.destroy(), { command: "null" }; - }; - (h.destroy = function() { - if (e.$mouseHandler.isMousePressed) return; - e.keyBinding.removeKeyboardHandler(m), - n.widgetManager.removeLineWidget(h), - e.off("changeSelection", h.destroy), - e.off("changeSession", h.destroy), - e.off("mouseup", h.destroy), - e.off("change", h.destroy); - }), - e.keyBinding.addKeyboardHandler(m), - e.on("changeSelection", h.destroy), - e.on("changeSession", h.destroy), - e.on("mouseup", h.destroy), - e.on("change", h.destroy), - e.session.widgetManager.addLineWidget(h), - (h.el.onmousedown = e.focus.bind(e)), - e.renderer.scrollCursorIntoView(null, 0.5, { - bottom: h.el.offsetHeight - }); - }), - i.importCssString( - " .error_widget_wrapper { background: inherit; color: inherit; border:none } .error_widget { border-top: solid 2px; border-bottom: solid 2px; margin: 5px 0; padding: 10px 40px; white-space: pre-wrap; } .error_widget.ace_error, .error_widget_arrow.ace_error{ border-color: #ff5a5a } .error_widget.ace_warning, .error_widget_arrow.ace_warning{ border-color: #F1D817 } .error_widget.ace_info, .error_widget_arrow.ace_info{ border-color: #5a5a5a } .error_widget.ace_ok, .error_widget_arrow.ace_ok{ border-color: #5aaa5a } .error_widget_arrow { position: absolute; border: solid 5px; border-top-color: transparent!important; border-right-color: transparent!important; border-left-color: transparent!important; top: -5px; }", - "" - ); - }), - define("ace/ace", [ - "require", - "exports", - "module", - "ace/lib/fixoldbrowsers", - "ace/lib/dom", - "ace/lib/event", - "ace/editor", - "ace/edit_session", - "ace/undomanager", - "ace/virtual_renderer", - "ace/worker/worker_client", - "ace/keyboard/hash_handler", - "ace/placeholder", - "ace/multi_select", - "ace/mode/folding/fold_mode", - "ace/theme/textmate", - "ace/ext/error_marker", - "ace/config" - ], function(e, t, n) { - "use strict"; - e("./lib/fixoldbrowsers"); - var r = e("./lib/dom"), - i = e("./lib/event"), - s = e("./editor").Editor, - o = e("./edit_session").EditSession, - u = e("./undomanager").UndoManager, - a = e("./virtual_renderer").VirtualRenderer; - e("./worker/worker_client"), - e("./keyboard/hash_handler"), - e("./placeholder"), - e("./multi_select"), - e("./mode/folding/fold_mode"), - e("./theme/textmate"), - e("./ext/error_marker"), - (t.config = e("./config")), - (t.require = e), - typeof define == "function" && (t.define = define), - (t.edit = function(e) { - if (typeof e == "string") { - var n = e; - e = document.getElementById(n); - if (!e) throw new Error("ace.edit can't find div #" + n); + var r = e("../line_widgets").LineWidgets, + i = e("../lib/dom"), + s = e("../range").Range; + ((t.showErrorMarker = function (e, t) { + var n = e.session; + n.widgetManager || + ((n.widgetManager = new r(n)), n.widgetManager.attach(e)); + var s = e.getCursorPosition(), + o = s.row, + a = n.widgetManager.getWidgetsAtRow(o).filter(function (e) { + return e.type == "errorMarker"; + })[0]; + a ? a.destroy() : (o -= t); + var f = u(n, o, t), + l; + if (f) { + var c = f[0]; + ((s.column = + (c.pos && typeof c.column != "number" ? c.pos.sc : c.column) || 0), + (s.row = c.row), + (l = e.renderer.$gutterLayer.$annotations[s.row])); + } else { + if (a) return; + l = { text: ["Looks good!"], className: "ace_ok" }; } - if (e && e.env && e.env.editor instanceof s) return e.env.editor; - var o = ""; - if (e && /input|textarea/i.test(e.tagName)) { - var u = e; - (o = u.value), - (e = r.createElement("pre")), - u.parentNode.replaceChild(e, u); - } else e && ((o = r.getInnerText(e)), (e.innerHTML = "")); - var f = t.createEditSession(o), - l = new s(new a(e)); - l.setSession(f); - var c = { document: f, editor: l, onResize: l.resize.bind(l, null) }; - return ( - u && (c.textarea = u), - i.addListener(window, "resize", c.onResize), - l.on("destroy", function() { - i.removeListener(window, "resize", c.onResize), - (c.editor.container.env = null); - }), - (l.container.env = l.env = c), - l - ); - }), - (t.createEditSession = function(e, t) { - var n = new o(e, t); - return n.setUndoManager(new u()), n; + (e.session.unfold(s.row), e.selection.moveToPosition(s)); + var h = { + row: s.row, + fixedWidth: !0, + coverGutter: !0, + el: i.createElement("div"), + type: "errorMarker" + }, + p = h.el.appendChild(i.createElement("div")), + d = h.el.appendChild(i.createElement("div")); + d.className = "error_widget_arrow " + l.className; + var v = e.renderer.$cursorLayer.getPixelPosition(s).left; + ((d.style.left = v + e.renderer.gutterWidth - 5 + "px"), + (h.el.className = "error_widget_wrapper"), + (p.className = "error_widget " + l.className), + (p.innerHTML = l.text.join("
")), + p.appendChild(i.createElement("div"))); + var m = function (e, t, n) { + if (t === 0 && (n === "esc" || n === "return")) + return (h.destroy(), { command: "null" }); + }; + ((h.destroy = function () { + if (e.$mouseHandler.isMousePressed) return; + (e.keyBinding.removeKeyboardHandler(m), + n.widgetManager.removeLineWidget(h), + e.off("changeSelection", h.destroy), + e.off("changeSession", h.destroy), + e.off("mouseup", h.destroy), + e.off("change", h.destroy)); + }), + e.keyBinding.addKeyboardHandler(m), + e.on("changeSelection", h.destroy), + e.on("changeSession", h.destroy), + e.on("mouseup", h.destroy), + e.on("change", h.destroy), + e.session.widgetManager.addLineWidget(h), + (h.el.onmousedown = e.focus.bind(e)), + e.renderer.scrollCursorIntoView(null, 0.5, { + bottom: h.el.offsetHeight + })); }), - (t.EditSession = o), - (t.UndoManager = u), - (t.version = "1.2.5"); - }); -(function() { - window.require(["ace/ace"], function(a) { + i.importCssString( + " .error_widget_wrapper { background: inherit; color: inherit; border:none } .error_widget { border-top: solid 2px; border-bottom: solid 2px; margin: 5px 0; padding: 10px 40px; white-space: pre-wrap; } .error_widget.ace_error, .error_widget_arrow.ace_error{ border-color: #ff5a5a } .error_widget.ace_warning, .error_widget_arrow.ace_warning{ border-color: #F1D817 } .error_widget.ace_info, .error_widget_arrow.ace_info{ border-color: #5a5a5a } .error_widget.ace_ok, .error_widget_arrow.ace_ok{ border-color: #5aaa5a } .error_widget_arrow { position: absolute; border: solid 5px; border-top-color: transparent!important; border-right-color: transparent!important; border-left-color: transparent!important; top: -5px; }", + "" + )); + } + ), + define( + "ace/ace", + [ + "require", + "exports", + "module", + "ace/lib/fixoldbrowsers", + "ace/lib/dom", + "ace/lib/event", + "ace/editor", + "ace/edit_session", + "ace/undomanager", + "ace/virtual_renderer", + "ace/worker/worker_client", + "ace/keyboard/hash_handler", + "ace/placeholder", + "ace/multi_select", + "ace/mode/folding/fold_mode", + "ace/theme/textmate", + "ace/ext/error_marker", + "ace/config" + ], + function (e, t, n) { + "use strict"; + e("./lib/fixoldbrowsers"); + var r = e("./lib/dom"), + i = e("./lib/event"), + s = e("./editor").Editor, + o = e("./edit_session").EditSession, + u = e("./undomanager").UndoManager, + a = e("./virtual_renderer").VirtualRenderer; + (e("./worker/worker_client"), + e("./keyboard/hash_handler"), + e("./placeholder"), + e("./multi_select"), + e("./mode/folding/fold_mode"), + e("./theme/textmate"), + e("./ext/error_marker"), + (t.config = e("./config")), + (t.require = e), + typeof define == "function" && (t.define = define), + (t.edit = function (e) { + if (typeof e == "string") { + var n = e; + e = document.getElementById(n); + if (!e) throw new Error("ace.edit can't find div #" + n); + } + if (e && e.env && e.env.editor instanceof s) return e.env.editor; + var o = ""; + if (e && /input|textarea/i.test(e.tagName)) { + var u = e; + ((o = u.value), + (e = r.createElement("pre")), + u.parentNode.replaceChild(e, u)); + } else e && ((o = r.getInnerText(e)), (e.innerHTML = "")); + var f = t.createEditSession(o), + l = new s(new a(e)); + l.setSession(f); + var c = { document: f, editor: l, onResize: l.resize.bind(l, null) }; + return ( + u && (c.textarea = u), + i.addListener(window, "resize", c.onResize), + l.on("destroy", function () { + (i.removeListener(window, "resize", c.onResize), + (c.editor.container.env = null)); + }), + (l.container.env = l.env = c), + l + ); + }), + (t.createEditSession = function (e, t) { + var n = new o(e, t); + return (n.setUndoManager(new u()), n); + }), + (t.EditSession = o), + (t.UndoManager = u), + (t.version = "1.2.5")); + } + )); +(function () { + window.require(["ace/ace"], function (a) { if (a) { a.config.init(true); a.define = window.define; diff --git a/examples/js/basic.js b/examples/js/basic.js index 709de4beb..9b9f93fff 100644 --- a/examples/js/basic.js +++ b/examples/js/basic.js @@ -216,7 +216,7 @@ function demoImages() { // security restrictions that prevent it from loading images // when running local files. Run with: chromium --allow-file-access-from-files --allow-file-access // to temporarily get around this issue. - var getImageFromUrl = function(url, callback) { + var getImageFromUrl = function (url, callback) { var img = new Image(), data, ret = { @@ -224,10 +224,10 @@ function demoImages() { pending: true }; - img.onError = function() { + img.onError = function () { throw new Error('Cannot load image: "' + url + '"'); }; - img.onload = function() { + img.onload = function () { var canvas = document.createElement("canvas"); document.body.appendChild(canvas); canvas.width = img.width; @@ -258,7 +258,7 @@ function demoImages() { // the pdf until we actually have the image data. // If we already had the jpeg image binary data loaded into // a string, we create the pdf without delay. - var createPDF = function(imgData) { + var createPDF = function (imgData) { var doc = new jsPDF(); doc.addImage(imgData, "JPEG", 10, 10, 50, 50); diff --git a/examples/js/cell.js b/examples/js/cell.js index ec124deba..9bbcd3164 100644 --- a/examples/js/cell.js +++ b/examples/js/cell.js @@ -1,4 +1,4 @@ -var generateData = function(amount) { +var generateData = function (amount) { var result = []; var data = { coin: "100", diff --git a/examples/js/editor.js b/examples/js/editor.js index 872a4230d..c350abbed 100644 --- a/examples/js/editor.js +++ b/examples/js/editor.js @@ -3,7 +3,7 @@ * jsPDFEditor * @return {[type]} [description] */ -var jsPDFEditor = (function() { +var jsPDFEditor = (function () { var editor, demos = { "images.js": "Images", @@ -28,7 +28,7 @@ var jsPDFEditor = (function() { "password.js": "Password" }; - var aceEditor = function() { + var aceEditor = function () { editor = ace.edit("editor"); editor.setTheme("ace/theme/github"); editor.setOptions({ @@ -39,31 +39,29 @@ var jsPDFEditor = (function() { editor.getSession().setUseWorker(false); // prevent "SecurityError: DOM Exception 18" var timeout; - editor.getSession().on("change", function() { + editor.getSession().on("change", function () { // Hacky workaround to disable auto refresh on user input if ( $("#auto-refresh").is(":checked") && $("#template").val() != "user-input.js" ) { if (timeout) clearTimeout(timeout); - timeout = setTimeout(function() { + timeout = setTimeout(function () { jsPDFEditor.update(); }, 200); } }); }; - var populateDropdown = function() { + var populateDropdown = function () { var options = ""; for (var demo in demos) { options += '"; } - $("#template") - .html(options) - .on("change", loadSelectedFile); + $("#template").html(options).on("change", loadSelectedFile); }; - var loadSelectedFile = function() { + var loadSelectedFile = function () { if ($("#template").val() == "user-input.js") { $(".controls .checkbox").hide(); $(".controls .alert").show(); @@ -75,7 +73,7 @@ var jsPDFEditor = (function() { $.get( "examples/js/" + $("#template").val(), - function(response) { + function (response) { editor.setValue(response); editor.gotoLine(0); @@ -85,7 +83,7 @@ var jsPDFEditor = (function() { } }, "text" - ).fail(function() { + ).fail(function () { $(".template-picker").html( '

More examples in examples/js/. We can\'t load them in automatically because of local filesystem security precautions.

' ); @@ -106,8 +104,8 @@ var jsPDFEditor = (function() { }); }; - var initAutoRefresh = function() { - $("#auto-refresh").on("change", function() { + var initAutoRefresh = function () { + $("#auto-refresh").on("change", function () { if ($("#auto-refresh").is(":checked")) { $(".run-code").hide(); jsPDFEditor.update(); @@ -116,14 +114,14 @@ var jsPDFEditor = (function() { } }); - $(".run-code").click(function() { + $(".run-code").click(function () { jsPDFEditor.update(); return false; }); }; - var initDownloadPDF = function() { - $(".download-pdf").click(function() { + var initDownloadPDF = function () { + $(".download-pdf").click(function () { eval( "try{" + editor.getValue() + @@ -137,7 +135,7 @@ var jsPDFEditor = (function() { if (typeof doc !== "undefined") { doc.save(file + ".pdf"); } else if (typeof pdf !== "undefined") { - setTimeout(function() { + setTimeout(function () { pdf.save(file + ".pdf"); }, 2000); } else { @@ -152,7 +150,7 @@ var jsPDFEditor = (function() { * Start the editor demo * @return {void} */ - init: function() { + init: function () { // Init the ACE editor aceEditor(); @@ -171,8 +169,8 @@ var jsPDFEditor = (function() { * @param {boolean} skipEval If true, will skip evaluation of the code * @return */ - update: function(skipEval) { - setTimeout(function() { + update: function (skipEval) { + setTimeout(function () { if (!skipEval) { eval( "try{" + @@ -209,6 +207,6 @@ var jsPDFEditor = (function() { }; })(); -$(document).ready(function() { +$(document).ready(function () { jsPDFEditor.init(); }); diff --git a/examples/js/jquery/jquery-1.7.1.min.js b/examples/js/jquery/jquery-1.7.1.min.js index dd03bbc02..784f311c8 100644 --- a/examples/js/jquery/jquery-1.7.1.min.js +++ b/examples/js/jquery/jquery-1.7.1.min.js @@ -1,11 +1,11 @@ /*! jQuery v1.7.1 jquery.com | jquery.org/license */ -(function(a, b) { +(function (a, b) { function cy(a) { return f.isWindow(a) ? a : a.nodeType === 9 - ? a.defaultView || a.parentWindow - : !1; + ? a.defaultView || a.parentWindow + : !1; } function cv(a) { if (!ck[a]) { @@ -14,21 +14,21 @@ e = d.css("display"); d.remove(); if (e === "none" || e === "") { - cl || + (cl || ((cl = c.createElement("iframe")), (cl.frameBorder = cl.width = cl.height = 0)), - b.appendChild(cl); + b.appendChild(cl)); if (!cm || !cl.createElement) - (cm = (cl.contentWindow || cl.contentDocument).document), + ((cm = (cl.contentWindow || cl.contentDocument).document), cm.write( (c.compatMode === "CSS1Compat" ? "" : "") + "" ), - cm.close(); - (d = cm.createElement(a)), + cm.close()); + ((d = cm.createElement(a)), cm.body.appendChild(d), (e = f.css(d, "display")), - b.removeChild(cl); + b.removeChild(cl)); } ck[a] = e; } @@ -36,7 +36,7 @@ } function cu(a, b) { var c = {}; - f.each(cq.concat.apply([], cq.slice(0, b)), function() { + f.each(cq.concat.apply([], cq.slice(0, b)), function () { c[this] = a; }); return c; @@ -76,10 +76,10 @@ if (g === 1) for (h in a.converters) typeof h == "string" && (e[h.toLowerCase()] = a.converters[h]); - (l = k), (k = d[g]); + ((l = k), (k = d[g])); if (k === "*") k = l; else if (l !== "*" && l !== k) { - (m = l + " " + k), (n = e[m] || e["* " + k]); + ((m = l + " " + k), (n = e[m] || e["* " + k])); if (!n) { p = b; for (o in e) { @@ -87,14 +87,14 @@ if (j[0] === l || j[0] === "*") { p = e[j[1] + " " + k]; if (p) { - (o = e[o]), o === !0 ? (n = p) : p === !0 && (n = o); + ((o = e[o]), o === !0 ? (n = p) : p === !0 && (n = o)); break; } } } } - !n && !p && f.error("No conversion from " + m.replace(" ", " to ")), - n !== !0 && (c = n ? n(c) : p(o(c))); + (!n && !p && f.error("No conversion from " + m.replace(" ", " to ")), + n !== !0 && (c = n ? n(c) : p(o(c)))); } } return c; @@ -109,8 +109,8 @@ k; for (i in g) i in d && (c[g[i]] = d[i]); while (f[0] === "*") - f.shift(), - h === b && (h = a.mimeType || c.getResponseHeader("content-type")); + (f.shift(), + h === b && (h = a.mimeType || c.getResponseHeader("content-type"))); if (h) for (i in e) if (e[i] && e[i].test(h)) { @@ -135,7 +135,7 @@ } function ca(a, b, c, d) { if (f.isArray(b)) - f.each(b, function(b, e) { + f.each(b, function (b, e) { c || bE.test(a) ? d(a, e) : ca( @@ -157,23 +157,23 @@ e && f.extend(!0, a, e); } function b$(a, c, d, e, f, g) { - (f = f || c.dataTypes[0]), (g = g || {}), (g[f] = !0); + ((f = f || c.dataTypes[0]), (g = g || {}), (g[f] = !0)); var h = a[f], i = 0, j = h ? h.length : 0, k = a === bT, l; for (; i < j && (k || !l); i++) - (l = h[i](c, d, e)), + ((l = h[i](c, d, e)), typeof l == "string" && (!k || g[l] ? (l = b) - : (c.dataTypes.unshift(l), (l = b$(a, c, d, e, l, g)))); + : (c.dataTypes.unshift(l), (l = b$(a, c, d, e, l, g))))); (k || !l) && !g["*"] && (l = b$(a, c, d, e, "*", g)); return l; } function bZ(a) { - return function(b, c) { + return function (b, c) { typeof b != "string" && ((c = b), (b = "*")); if (f.isFunction(c)) { var d = b.toLowerCase().split(bP), @@ -183,11 +183,11 @@ i, j; for (; e < g; e++) - (h = d[e]), + ((h = d[e]), (j = /^\+/.test(h)), j && (h = h.substr(1) || "*"), (i = a[h] = a[h] || []), - i[j ? "unshift" : "push"](c); + i[j ? "unshift" : "push"](c)); } }; } @@ -199,10 +199,10 @@ if (d > 0) { if (c !== "border") for (; g < h; g++) - c || (d -= parseFloat(f.css(a, "padding" + e[g])) || 0), + (c || (d -= parseFloat(f.css(a, "padding" + e[g])) || 0), c === "margin" ? (d += parseFloat(f.css(a, c + e[g])) || 0) - : (d -= parseFloat(f.css(a, "border" + e[g] + "Width")) || 0); + : (d -= parseFloat(f.css(a, "border" + e[g] + "Width")) || 0)); return d + "px"; } d = bz(a, b, b); @@ -210,23 +210,23 @@ d = parseFloat(d) || 0; if (c) for (; g < h; g++) - (d += parseFloat(f.css(a, "padding" + e[g])) || 0), + ((d += parseFloat(f.css(a, "padding" + e[g])) || 0), c !== "padding" && (d += parseFloat(f.css(a, "border" + e[g] + "Width")) || 0), - c === "margin" && (d += parseFloat(f.css(a, c + e[g])) || 0); + c === "margin" && (d += parseFloat(f.css(a, c + e[g])) || 0)); return d + "px"; } function bp(a, b) { - b.src + (b.src ? f.ajax({ url: b.src, async: !1, dataType: "script" }) : f.globalEval( (b.text || b.textContent || b.innerHTML || "").replace(bf, "/*$0*/") ), - b.parentNode && b.parentNode.removeChild(b); + b.parentNode && b.parentNode.removeChild(b)); } function bo(a) { var b = c.createElement("div"); - bh.appendChild(b), (b.innerHTML = a.outerHTML); + (bh.appendChild(b), (b.innerHTML = a.outerHTML)); return b.firstChild; } function bn(a) { @@ -245,23 +245,23 @@ return typeof a.getElementsByTagName != "undefined" ? a.getElementsByTagName("*") : typeof a.querySelectorAll != "undefined" - ? a.querySelectorAll("*") - : []; + ? a.querySelectorAll("*") + : []; } function bk(a, b) { var c; if (b.nodeType === 1) { - b.clearAttributes && b.clearAttributes(), + (b.clearAttributes && b.clearAttributes(), b.mergeAttributes && b.mergeAttributes(a), - (c = b.nodeName.toLowerCase()); + (c = b.nodeName.toLowerCase())); if (c === "object") b.outerHTML = a.outerHTML; else if (c !== "input" || (a.type !== "checkbox" && a.type !== "radio")) { if (c === "option") b.selected = a.defaultSelected; else if (c === "input" || c === "textarea") b.defaultValue = a.defaultValue; } else - a.checked && (b.defaultChecked = b.checked = a.checked), - b.value !== a.value && (b.value = a.value); + (a.checked && (b.defaultChecked = b.checked = a.checked), + b.value !== a.value && (b.value = a.value)); b.removeAttribute(f.expando); } } @@ -274,7 +274,7 @@ h = f._data(b, g), i = g.events; if (i) { - delete h.handle, (h.events = {}); + (delete h.handle, (h.events = {})); for (c in i) for (d = 0, e = i[c].length; d < e; d++) f.event.add( @@ -302,22 +302,22 @@ function T(a, b, c) { b = b || 0; if (f.isFunction(b)) - return f.grep(a, function(a, d) { + return f.grep(a, function (a, d) { var e = !!b.call(a, d, a); return e === c; }); if (b.nodeType) - return f.grep(a, function(a, d) { + return f.grep(a, function (a, d) { return (a === b) === c; }); if (typeof b == "string") { - var d = f.grep(a, function(a) { + var d = f.grep(a, function (a) { return a.nodeType === 1; }); if (O.test(b)) return f.filter(b, d, !c); b = f.filter(b, d); } - return f.grep(a, function(a, d) { + return f.grep(a, function (a, d) { return f.inArray(a, b) >= 0 === c; }); } @@ -338,7 +338,7 @@ h && (c === "queue" || !f._data(a, e)) && (c === "mark" || !f._data(a, g)) && - setTimeout(function() { + setTimeout(function () { !f._data(a, e) && !f._data(a, g) && (f.removeData(a, d, !0), h.fire()); }, 0); } @@ -359,14 +359,14 @@ d === "true" ? !0 : d === "false" - ? !1 - : d === "null" - ? null - : f.isNumeric(d) - ? parseFloat(d) - : j.test(d) - ? f.parseJSON(d) - : d; + ? !1 + : d === "null" + ? null + : f.isNumeric(d) + ? parseFloat(d) + : j.test(d) + ? f.parseJSON(d) + : d; } catch (g) {} f.data(a, c, d); } else d = b; @@ -384,7 +384,7 @@ var c = a.document, d = a.navigator, e = a.location, - f = (function() { + f = (function () { function J() { if (!e.isReady) { try { @@ -396,7 +396,7 @@ e.ready(); } } - var e = function(a, b) { + var e = function (a, b) { return new e.fn.init(a, b, h); }, f = a.jQuery, @@ -417,7 +417,7 @@ u = /(mozilla)(?:.*? rv:([\w.]+))?/, v = /-([a-z]|[0-9])/gi, w = /^-ms-/, - x = function(a, b) { + x = function (a, b) { return (b + "").toUpperCase(); }, y = d.userAgent, @@ -431,185 +431,185 @@ G = String.prototype.trim, H = Array.prototype.indexOf, I = {}; - (e.fn = e.prototype = { - constructor: e, - init: function(a, d, f) { - var g, h, j, k; - if (!a) return this; - if (a.nodeType) { - (this.context = this[0] = a), (this.length = 1); - return this; - } - if (a === "body" && !d && c.body) { - (this.context = c), - (this[0] = c.body), - (this.selector = a), - (this.length = 1); - return this; - } - if (typeof a == "string") { - a.charAt(0) !== "<" || - a.charAt(a.length - 1) !== ">" || - a.length < 3 - ? (g = i.exec(a)) - : (g = [null, a, null]); - if (g && (g[1] || !d)) { - if (g[1]) { - (d = d instanceof e ? d[0] : d), - (k = d ? d.ownerDocument || d : c), - (j = m.exec(a)), - j - ? e.isPlainObject(d) - ? ((a = [c.createElement(j[1])]), - e.fn.attr.call(a, d, !0)) - : (a = [k.createElement(j[1])]) - : ((j = e.buildFragment([g[1]], [k])), - (a = (j.cacheable ? e.clone(j.fragment) : j.fragment) - .childNodes)); - return e.merge(this, a); - } - h = c.getElementById(g[2]); - if (h && h.parentNode) { - if (h.id !== g[2]) return f.find(a); - (this.length = 1), (this[0] = h); - } - (this.context = c), (this.selector = a); + ((e.fn = e.prototype = + { + constructor: e, + init: function (a, d, f) { + var g, h, j, k; + if (!a) return this; + if (a.nodeType) { + ((this.context = this[0] = a), (this.length = 1)); return this; } - return !d || d.jquery - ? (d || f).find(a) - : this.constructor(d).find(a); - } - if (e.isFunction(a)) return f.ready(a); - a.selector !== b && - ((this.selector = a.selector), (this.context = a.context)); - return e.makeArray(a, this); - }, - selector: "", - jquery: "1.7.1", - length: 0, - size: function() { - return this.length; - }, - toArray: function() { - return F.call(this, 0); - }, - get: function(a) { - return a == null - ? this.toArray() - : a < 0 - ? this[this.length + a] - : this[a]; - }, - pushStack: function(a, b, c) { - var d = this.constructor(); - e.isArray(a) ? E.apply(d, a) : e.merge(d, a), - (d.prevObject = this), - (d.context = this.context), - b === "find" - ? (d.selector = this.selector + (this.selector ? " " : "") + c) - : b && (d.selector = this.selector + "." + b + "(" + c + ")"); - return d; - }, - each: function(a, b) { - return e.each(this, a, b); - }, - ready: function(a) { - e.bindReady(), A.add(a); - return this; - }, - eq: function(a) { - a = +a; - return a === -1 ? this.slice(a) : this.slice(a, a + 1); - }, - first: function() { - return this.eq(0); - }, - last: function() { - return this.eq(-1); - }, - slice: function() { - return this.pushStack( - F.apply(this, arguments), - "slice", - F.call(arguments).join(",") - ); - }, - map: function(a) { - return this.pushStack( - e.map(this, function(b, c) { - return a.call(b, c, b); - }) - ); - }, - end: function() { - return this.prevObject || this.constructor(null); - }, - push: E, - sort: [].sort, - splice: [].splice - }), - (e.fn.init.prototype = e.fn), - (e.extend = e.fn.extend = function() { - var a, - c, - d, - f, - g, - h, - i = arguments[0] || {}, - j = 1, - k = arguments.length, - l = !1; - typeof i == "boolean" && ((l = i), (i = arguments[1] || {}), (j = 2)), - typeof i != "object" && !e.isFunction(i) && (i = {}), - k === j && ((i = this), --j); - for (; j < k; j++) - if ((a = arguments[j]) != null) - for (c in a) { - (d = i[c]), (f = a[c]); - if (i === f) continue; - l && f && (e.isPlainObject(f) || (g = e.isArray(f))) - ? (g - ? ((g = !1), (h = d && e.isArray(d) ? d : [])) - : (h = d && e.isPlainObject(d) ? d : {}), - (i[c] = e.extend(l, h, f))) - : f !== b && (i[c] = f); + if (a === "body" && !d && c.body) { + ((this.context = c), + (this[0] = c.body), + (this.selector = a), + (this.length = 1)); + return this; + } + if (typeof a == "string") { + a.charAt(0) !== "<" || + a.charAt(a.length - 1) !== ">" || + a.length < 3 + ? (g = i.exec(a)) + : (g = [null, a, null]); + if (g && (g[1] || !d)) { + if (g[1]) { + ((d = d instanceof e ? d[0] : d), + (k = d ? d.ownerDocument || d : c), + (j = m.exec(a)), + j + ? e.isPlainObject(d) + ? ((a = [c.createElement(j[1])]), + e.fn.attr.call(a, d, !0)) + : (a = [k.createElement(j[1])]) + : ((j = e.buildFragment([g[1]], [k])), + (a = (j.cacheable ? e.clone(j.fragment) : j.fragment) + .childNodes))); + return e.merge(this, a); + } + h = c.getElementById(g[2]); + if (h && h.parentNode) { + if (h.id !== g[2]) return f.find(a); + ((this.length = 1), (this[0] = h)); + } + ((this.context = c), (this.selector = a)); + return this; } - return i; + return !d || d.jquery + ? (d || f).find(a) + : this.constructor(d).find(a); + } + if (e.isFunction(a)) return f.ready(a); + a.selector !== b && + ((this.selector = a.selector), (this.context = a.context)); + return e.makeArray(a, this); + }, + selector: "", + jquery: "1.7.1", + length: 0, + size: function () { + return this.length; + }, + toArray: function () { + return F.call(this, 0); + }, + get: function (a) { + return a == null + ? this.toArray() + : a < 0 + ? this[this.length + a] + : this[a]; + }, + pushStack: function (a, b, c) { + var d = this.constructor(); + (e.isArray(a) ? E.apply(d, a) : e.merge(d, a), + (d.prevObject = this), + (d.context = this.context), + b === "find" + ? (d.selector = this.selector + (this.selector ? " " : "") + c) + : b && (d.selector = this.selector + "." + b + "(" + c + ")")); + return d; + }, + each: function (a, b) { + return e.each(this, a, b); + }, + ready: function (a) { + (e.bindReady(), A.add(a)); + return this; + }, + eq: function (a) { + a = +a; + return a === -1 ? this.slice(a) : this.slice(a, a + 1); + }, + first: function () { + return this.eq(0); + }, + last: function () { + return this.eq(-1); + }, + slice: function () { + return this.pushStack( + F.apply(this, arguments), + "slice", + F.call(arguments).join(",") + ); + }, + map: function (a) { + return this.pushStack( + e.map(this, function (b, c) { + return a.call(b, c, b); + }) + ); + }, + end: function () { + return this.prevObject || this.constructor(null); + }, + push: E, + sort: [].sort, + splice: [].splice }), + (e.fn.init.prototype = e.fn), + (e.extend = e.fn.extend = + function () { + var a, + c, + d, + f, + g, + h, + i = arguments[0] || {}, + j = 1, + k = arguments.length, + l = !1; + (typeof i == "boolean" && + ((l = i), (i = arguments[1] || {}), (j = 2)), + typeof i != "object" && !e.isFunction(i) && (i = {}), + k === j && ((i = this), --j)); + for (; j < k; j++) + if ((a = arguments[j]) != null) + for (c in a) { + ((d = i[c]), (f = a[c])); + if (i === f) continue; + l && f && (e.isPlainObject(f) || (g = e.isArray(f))) + ? (g + ? ((g = !1), (h = d && e.isArray(d) ? d : [])) + : (h = d && e.isPlainObject(d) ? d : {}), + (i[c] = e.extend(l, h, f))) + : f !== b && (i[c] = f); + } + return i; + }), e.extend({ - noConflict: function(b) { - a.$ === e && (a.$ = g), b && a.jQuery === e && (a.jQuery = f); + noConflict: function (b) { + (a.$ === e && (a.$ = g), b && a.jQuery === e && (a.jQuery = f)); return e; }, isReady: !1, readyWait: 1, - holdReady: function(a) { + holdReady: function (a) { a ? e.readyWait++ : e.ready(!0); }, - ready: function(a) { + ready: function (a) { if ((a === !0 && !--e.readyWait) || (a !== !0 && !e.isReady)) { if (!c.body) return setTimeout(e.ready, 1); e.isReady = !0; if (a !== !0 && --e.readyWait > 0) return; - A.fireWith(c, [e]), - e.fn.trigger && - e(c) - .trigger("ready") - .off("ready"); + (A.fireWith(c, [e]), + e.fn.trigger && e(c).trigger("ready").off("ready")); } }, - bindReady: function() { + bindReady: function () { if (!A) { A = e.Callbacks("once memory"); if (c.readyState === "complete") return setTimeout(e.ready, 1); if (c.addEventListener) - c.addEventListener("DOMContentLoaded", B, !1), - a.addEventListener("load", e.ready, !1); + (c.addEventListener("DOMContentLoaded", B, !1), + a.addEventListener("load", e.ready, !1)); else if (c.attachEvent) { - c.attachEvent("onreadystatechange", B), - a.attachEvent("onload", e.ready); + (c.attachEvent("onreadystatechange", B), + a.attachEvent("onload", e.ready)); var b = !1; try { b = a.frameElement == null; @@ -618,24 +618,24 @@ } } }, - isFunction: function(a) { + isFunction: function (a) { return e.type(a) === "function"; }, isArray: Array.isArray || - function(a) { + function (a) { return e.type(a) === "array"; }, - isWindow: function(a) { + isWindow: function (a) { return a && typeof a == "object" && "setInterval" in a; }, - isNumeric: function(a) { + isNumeric: function (a) { return !isNaN(parseFloat(a)) && isFinite(a); }, - type: function(a) { + type: function (a) { return a == null ? String(a) : I[C.call(a)] || "object"; }, - isPlainObject: function(a) { + isPlainObject: function (a) { if (!a || e.type(a) !== "object" || a.nodeType || e.isWindow(a)) return !1; try { @@ -652,29 +652,22 @@ for (d in a); return d === b || D.call(a, d); }, - isEmptyObject: function(a) { + isEmptyObject: function (a) { for (var b in a) return !1; return !0; }, - error: function(a) { + error: function (a) { throw new Error(a); }, - parseJSON: function(b) { + parseJSON: function (b) { if (typeof b != "string" || !b) return null; b = e.trim(b); if (a.JSON && a.JSON.parse) return a.JSON.parse(b); - if ( - n.test( - b - .replace(o, "@") - .replace(p, "]") - .replace(q, "") - ) - ) + if (n.test(b.replace(o, "@").replace(p, "]").replace(q, ""))) return new Function("return " + b)(); e.error("Invalid JSON: " + b); }, - parseXML: function(c) { + parseXML: function (c) { var d, f; try { a.DOMParser @@ -692,24 +685,24 @@ e.error("Invalid XML: " + c); return d; }, - noop: function() {}, - globalEval: function(b) { + noop: function () {}, + globalEval: function (b) { b && j.test(b) && ( a.execScript || - function(b) { + function (b) { a.eval.call(a, b); } )(b); }, - camelCase: function(a) { + camelCase: function (a) { return a.replace(w, "ms-").replace(v, x); }, - nodeName: function(a, b) { + nodeName: function (a, b) { return a.nodeName && a.nodeName.toUpperCase() === b.toUpperCase(); }, - each: function(a, c, d) { + each: function (a, c, d) { var f, g = 0, h = a.length, @@ -717,20 +710,20 @@ if (d) { if (i) { for (f in a) if (c.apply(a[f], d) === !1) break; - } else for (; g < h; ) if (c.apply(a[g++], d) === !1) break; + } else for (; g < h;) if (c.apply(a[g++], d) === !1) break; } else if (i) { for (f in a) if (c.call(a[f], f, a[f]) === !1) break; - } else for (; g < h; ) if (c.call(a[g], g, a[g++]) === !1) break; + } else for (; g < h;) if (c.call(a[g], g, a[g++]) === !1) break; return a; }, trim: G - ? function(a) { + ? function (a) { return a == null ? "" : G.call(a); } - : function(a) { + : function (a) { return a == null ? "" : (a + "").replace(k, "").replace(l, ""); }, - makeArray: function(a, b) { + makeArray: function (a, b) { var c = b || []; if (a != null) { var d = e.type(a); @@ -744,16 +737,16 @@ } return c; }, - inArray: function(a, b, c) { + inArray: function (a, b, c) { var d; if (b) { if (H) return H.call(b, a, c); - (d = b.length), (c = c ? (c < 0 ? Math.max(0, d + c) : c) : 0); + ((d = b.length), (c = c ? (c < 0 ? Math.max(0, d + c) : c) : 0)); for (; c < d; c++) if (c in b && b[c] === a) return c; } return -1; }, - merge: function(a, c) { + merge: function (a, c) { var d = a.length, e = 0; if (typeof c.length == "number") @@ -762,15 +755,15 @@ a.length = d; return a; }, - grep: function(a, b, c) { + grep: function (a, b, c) { var d = [], e; c = !!c; for (var f = 0, g = a.length; f < g; f++) - (e = !!b(a[f], f)), c !== e && d.push(a[f]); + ((e = !!b(a[f], f)), c !== e && d.push(a[f])); return d; }, - map: function(a, c, d) { + map: function (a, c, d) { var f, g, h = [], @@ -783,26 +776,27 @@ ((j > 0 && a[0] && a[j - 1]) || j === 0 || e.isArray(a))); if (k) for (; i < j; i++) - (f = c(a[i], i, d)), f != null && (h[h.length] = f); + ((f = c(a[i], i, d)), f != null && (h[h.length] = f)); else - for (g in a) (f = c(a[g], g, d)), f != null && (h[h.length] = f); + for (g in a) + ((f = c(a[g], g, d)), f != null && (h[h.length] = f)); return h.concat.apply([], h); }, guid: 1, - proxy: function(a, c) { + proxy: function (a, c) { if (typeof c == "string") { var d = a[c]; - (c = a), (a = d); + ((c = a), (a = d)); } if (!e.isFunction(a)) return b; var f = F.call(arguments, 2), - g = function() { + g = function () { return a.apply(c, f.concat(F.call(arguments))); }; g.guid = a.guid = a.guid || g.guid || e.guid++; return g; }, - access: function(a, c, d, f, g, h) { + access: function (a, c, d, f, g, h) { var i = a.length; if (typeof c == "object") { for (var j in c) e.access(a, j, c[j], f, g, d); @@ -816,10 +810,10 @@ } return i ? g(a[0], c) : b; }, - now: function() { + now: function () { return new Date().getTime(); }, - uaMatch: function(a) { + uaMatch: function (a) { a = a.toLowerCase(); var b = r.exec(a) || @@ -829,20 +823,20 @@ []; return { browser: b[1] || "", version: b[2] || "0" }; }, - sub: function() { + sub: function () { function a(b, c) { return new a.fn.init(b, c); } - e.extend(!0, a, this), + (e.extend(!0, a, this), (a.superclass = this), (a.fn = a.prototype = this()), (a.fn.constructor = a), (a.sub = this.sub), - (a.fn.init = function(d, f) { + (a.fn.init = function (d, f) { f && f instanceof e && !(f instanceof a) && (f = a(f)); return e.fn.init.call(this, d, f, b); }), - (a.fn.init.prototype = a.fn); + (a.fn.init.prototype = a.fn)); var b = a(c); return a; }, @@ -850,7 +844,7 @@ }), e.each( "Boolean Number String Function Array Date RegExp Object".split(" "), - function(a, b) { + function (a, b) { I["[object " + b + "]"] = b.toLowerCase(); } ), @@ -861,18 +855,18 @@ j.test(" ") && ((k = /^[\s\xA0]+/), (l = /[\s\xA0]+$/)), (h = e(c)), c.addEventListener - ? (B = function() { - c.removeEventListener("DOMContentLoaded", B, !1), e.ready(); + ? (B = function () { + (c.removeEventListener("DOMContentLoaded", B, !1), e.ready()); }) : c.attachEvent && - (B = function() { + (B = function () { c.readyState === "complete" && (c.detachEvent("onreadystatechange", B), e.ready()); - }); + })); return e; })(), g = {}; - f.Callbacks = function(a) { + f.Callbacks = function (a) { a = a ? g[a] || h(a) : {}; var c = [], d = [], @@ -881,45 +875,45 @@ j, k, l, - m = function(b) { + m = function (b) { var d, e, g, h, i; for (d = 0, e = b.length; d < e; d++) - (g = b[d]), + ((g = b[d]), (h = f.type(g)), h === "array" ? m(g) - : h === "function" && (!a.unique || !o.has(g)) && c.push(g); + : h === "function" && (!a.unique || !o.has(g)) && c.push(g)); }, - n = function(b, f) { - (f = f || []), + n = function (b, f) { + ((f = f || []), (e = !a.memory || [b, f]), (i = !0), (l = j || 0), (j = 0), - (k = c.length); + (k = c.length)); for (; c && l < k; l++) if (c[l].apply(b, f) === !1 && a.stopOnFalse) { e = !0; break; } - (i = !1), + ((i = !1), c && (a.once ? e === !0 ? o.disable() : (c = []) - : d && d.length && ((e = d.shift()), o.fireWith(e[0], e[1]))); + : d && d.length && ((e = d.shift()), o.fireWith(e[0], e[1])))); }, o = { - add: function() { + add: function () { if (c) { var a = c.length; - m(arguments), - i ? (k = c.length) : e && e !== !0 && ((j = a), n(e[0], e[1])); + (m(arguments), + i ? (k = c.length) : e && e !== !0 && ((j = a), n(e[0], e[1]))); } return this; }, - remove: function() { + remove: function () { if (c) { var b = arguments, d = 0, @@ -927,13 +921,13 @@ for (; d < e; d++) for (var f = 0; f < c.length; f++) if (b[d] === c[f]) { - i && f <= k && (k--, f <= l && l--), c.splice(f--, 1); + (i && f <= k && (k--, f <= l && l--), c.splice(f--, 1)); if (a.unique) break; } } return this; }, - has: function(a) { + has: function (a) { if (c) { var b = 0, d = c.length; @@ -941,41 +935,41 @@ } return !1; }, - empty: function() { + empty: function () { c = []; return this; }, - disable: function() { + disable: function () { c = d = e = b; return this; }, - disabled: function() { + disabled: function () { return !c; }, - lock: function() { - (d = b), (!e || e === !0) && o.disable(); + lock: function () { + ((d = b), (!e || e === !0) && o.disable()); return this; }, - locked: function() { + locked: function () { return !d; }, - fireWith: function(b, c) { + fireWith: function (b, c) { d && (i ? a.once || d.push([b, c]) : (!a.once || !e) && n(b, c)); return this; }, - fire: function() { + fire: function () { o.fireWith(this, arguments); return this; }, - fired: function() { + fired: function () { return !!e; } }; return o; }; var i = [].slice; - f.extend({ - Deferred: function(a) { + (f.extend({ + Deferred: function (a) { var b = f.Callbacks("once memory"), c = f.Callbacks("once memory"), d = f.Callbacks("memory"), @@ -985,40 +979,38 @@ done: b.add, fail: c.add, progress: d.add, - state: function() { + state: function () { return e; }, isResolved: b.fired, isRejected: c.fired, - then: function(a, b, c) { - i.done(a) - .fail(b) - .progress(c); + then: function (a, b, c) { + i.done(a).fail(b).progress(c); return this; }, - always: function() { + always: function () { i.done.apply(i, arguments).fail.apply(i, arguments); return this; }, - pipe: function(a, b, c) { + pipe: function (a, b, c) { return f - .Deferred(function(d) { + .Deferred(function (d) { f.each( { done: [a, "resolve"], fail: [b, "reject"], progress: [c, "notify"] }, - function(a, b) { + function (a, b) { var c = b[0], e = b[1], g; f.isFunction(c) - ? i[a](function() { - (g = c.apply(this, arguments)), + ? i[a](function () { + ((g = c.apply(this, arguments)), g && f.isFunction(g.promise) ? g.promise().then(d.resolve, d.reject, d.notify) - : d[e + "With"](this === i ? d : this, [g]); + : d[e + "With"](this === i ? d : this, [g])); }) : i[a](d[e]); } @@ -1026,7 +1018,7 @@ }) .promise(); }, - promise: function(a) { + promise: function (a) { if (a == null) a = h; else for (var b in h) a[b] = h[b]; return a; @@ -1034,36 +1026,36 @@ }, i = h.promise({}), j; - for (j in g) (i[j] = g[j].fire), (i[j + "With"] = g[j].fireWith); - i + for (j in g) ((i[j] = g[j].fire), (i[j + "With"] = g[j].fireWith)); + (i .done( - function() { + function () { e = "resolved"; }, c.disable, d.lock ) .fail( - function() { + function () { e = "rejected"; }, b.disable, d.lock ), - a && a.call(i, i); + a && a.call(i, i)); return i; }, - when: function(a) { + when: function (a) { function m(a) { - return function(b) { - (e[a] = arguments.length > 1 ? i.call(arguments, 0) : b), - j.notifyWith(k, e); + return function (b) { + ((e[a] = arguments.length > 1 ? i.call(arguments, 0) : b), + j.notifyWith(k, e)); }; } function l(a) { - return function(c) { - (b[a] = arguments.length > 1 ? i.call(arguments, 0) : c), - --g || j.resolveWith(j, b); + return function (c) { + ((b[a] = arguments.length > 1 ? i.call(arguments, 0) : c), + --g || j.resolveWith(j, b)); }; } var b = i.call(arguments, 0), @@ -1084,7 +1076,7 @@ return k; } }), - (f.support = (function() { + (f.support = (function () { var b, d, e, @@ -1100,13 +1092,13 @@ p, q = c.createElement("div"), r = c.documentElement; - q.setAttribute("className", "t"), + (q.setAttribute("className", "t"), (q.innerHTML = "
a"), (d = q.getElementsByTagName("*")), - (e = q.getElementsByTagName("a")[0]); + (e = q.getElementsByTagName("a")[0])); if (!d || !d.length || !e) return {}; - (g = c.createElement("select")), + ((g = c.createElement("select")), (h = g.appendChild(c.createElement("option"))), (i = q.getElementsByTagName("input")[0]), (b = { @@ -1135,16 +1127,16 @@ (i.checked = !0), (b.noCloneChecked = i.cloneNode(!0).checked), (g.disabled = !0), - (b.optDisabled = !h.disabled); + (b.optDisabled = !h.disabled)); try { delete q.test; } catch (s) { b.deleteExpando = !1; } - !q.addEventListener && + (!q.addEventListener && q.attachEvent && q.fireEvent && - (q.attachEvent("onclick", function() { + (q.attachEvent("onclick", function () { b.noCloneEvent = !1; }), q.cloneNode(!0).fireEvent("onclick")), @@ -1171,17 +1163,17 @@ (parseInt( (a.getComputedStyle(j, null) || { marginRight: 0 }).marginRight, 10 - ) || 0) === 0)); + ) || 0) === 0))); if (q.attachEvent) for (o in { submit: 1, change: 1, focusin: 1 }) - (n = "on" + o), + ((n = "on" + o), (p = n in q), p || (q.setAttribute(n, "return;"), (p = typeof q[n] == "function")), - (b[o + "Bubbles"] = p); - k.removeChild(q), + (b[o + "Bubbles"] = p)); + (k.removeChild(q), (k = g = h = j = q = i = null), - f(function() { + f(function () { var a, d, e, @@ -1254,12 +1246,12 @@ r.removeChild(a), (q = a = null), f.extend(b, i)); - }); + })); return b; - })()); + })())); var j = /^(?:\{.*\}|\[.*\])$/, k = /([A-Z])/g; - f.extend({ + (f.extend({ cache: {}, uuid: 0, expando: "jQuery" + (f.fn.jquery + Math.random()).replace(/\D/g, ""), @@ -1268,11 +1260,11 @@ object: "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", applet: !0 }, - hasData: function(a) { + hasData: function (a) { a = a.nodeType ? f.cache[a[f.expando]] : a[f.expando]; return !!a && !m(a); }, - data: function(a, c, d, e) { + data: function (a, c, d, e) { if (!!f.acceptData(a)) { var g, h, @@ -1284,19 +1276,19 @@ n = l ? a[j] : a[j] && j, o = c === "events"; if ((!n || !m[n] || (!o && !e && !m[n].data)) && k && d === b) return; - n || (l ? (a[j] = n = ++f.uuid) : (n = j)), - m[n] || ((m[n] = {}), l || (m[n].toJSON = f.noop)); + (n || (l ? (a[j] = n = ++f.uuid) : (n = j)), + m[n] || ((m[n] = {}), l || (m[n].toJSON = f.noop))); if (typeof c == "object" || typeof c == "function") e ? (m[n] = f.extend(m[n], c)) : (m[n].data = f.extend(m[n].data, c)); - (g = h = m[n]), + ((g = h = m[n]), e || (h.data || (h.data = {}), (h = h.data)), - d !== b && (h[f.camelCase(c)] = d); + d !== b && (h[f.camelCase(c)] = d)); if (o && !h[c]) return g.events; k ? ((i = h[c]), i == null && (i = h[f.camelCase(c)])) : (i = h); return i; } }, - removeData: function(a, b, c) { + removeData: function (a, b, c) { if (!!f.acceptData(a)) { var d, e, @@ -1322,19 +1314,21 @@ delete j[k].data; if (!m(j[k])) return; } - f.support.deleteExpando || !j.setInterval ? delete j[k] : (j[k] = null), + (f.support.deleteExpando || !j.setInterval + ? delete j[k] + : (j[k] = null), i && (f.support.deleteExpando ? delete a[h] : a.removeAttribute - ? a.removeAttribute(h) - : (a[h] = null)); + ? a.removeAttribute(h) + : (a[h] = null))); } }, - _data: function(a, b, c) { + _data: function (a, b, c) { return f.data(a, b, c, !0); }, - acceptData: function(a) { + acceptData: function (a) { if (a.nodeName) { var b = f.noData[a.nodeName.toLowerCase()]; if (b) return b !== !0 && a.getAttribute("classid") === b; @@ -1343,7 +1337,7 @@ } }), f.fn.extend({ - data: function(a, c) { + data: function (a, c) { var d, e, g, @@ -1354,46 +1348,46 @@ if (this[0].nodeType === 1 && !f._data(this[0], "parsedAttrs")) { e = this[0].attributes; for (var i = 0, j = e.length; i < j; i++) - (g = e[i].name), + ((g = e[i].name), g.indexOf("data-") === 0 && - ((g = f.camelCase(g.substring(5))), l(this[0], g, h[g])); + ((g = f.camelCase(g.substring(5))), l(this[0], g, h[g]))); f._data(this[0], "parsedAttrs", !0); } } return h; } if (typeof a == "object") - return this.each(function() { + return this.each(function () { f.data(this, a); }); - (d = a.split(".")), (d[1] = d[1] ? "." + d[1] : ""); + ((d = a.split(".")), (d[1] = d[1] ? "." + d[1] : "")); if (c === b) { - (h = this.triggerHandler("getData" + d[1] + "!", [d[0]])), + ((h = this.triggerHandler("getData" + d[1] + "!", [d[0]])), h === b && this.length && - ((h = f.data(this[0], a)), (h = l(this[0], a, h))); + ((h = f.data(this[0], a)), (h = l(this[0], a, h)))); return h === b && d[1] ? this.data(d[0]) : h; } - return this.each(function() { + return this.each(function () { var b = f(this), e = [d[0], c]; - b.triggerHandler("setData" + d[1] + "!", e), + (b.triggerHandler("setData" + d[1] + "!", e), f.data(this, a, c), - b.triggerHandler("changeData" + d[1] + "!", e); + b.triggerHandler("changeData" + d[1] + "!", e)); }); }, - removeData: function(a) { - return this.each(function() { + removeData: function (a) { + return this.each(function () { f.removeData(this, a); }); } }), f.extend({ - _mark: function(a, b) { + _mark: function (a, b) { a && ((b = (b || "fx") + "mark"), f._data(a, b, (f._data(a, b) || 0) + 1)); }, - _unmark: function(a, b, c) { + _unmark: function (a, b, c) { a !== !0 && ((c = b), (b = a), (a = !1)); if (b) { c = c || "fx"; @@ -1402,69 +1396,69 @@ e ? f._data(b, d, e) : (f.removeData(b, d, !0), n(b, c, "mark")); } }, - queue: function(a, b, c) { + queue: function (a, b, c) { var d; if (a) { - (b = (b || "fx") + "queue"), + ((b = (b || "fx") + "queue"), (d = f._data(a, b)), c && (!d || f.isArray(c) ? (d = f._data(a, b, f.makeArray(c))) - : d.push(c)); + : d.push(c))); return d || []; } }, - dequeue: function(a, b) { + dequeue: function (a, b) { b = b || "fx"; var c = f.queue(a, b), d = c.shift(), e = {}; - d === "inprogress" && (d = c.shift()), + (d === "inprogress" && (d = c.shift()), d && (b === "fx" && c.unshift("inprogress"), f._data(a, b + ".run", e), d.call( a, - function() { + function () { f.dequeue(a, b); }, e )), c.length || - (f.removeData(a, b + "queue " + b + ".run", !0), n(a, b, "queue")); + (f.removeData(a, b + "queue " + b + ".run", !0), n(a, b, "queue"))); } }), f.fn.extend({ - queue: function(a, c) { + queue: function (a, c) { typeof a != "string" && ((c = a), (a = "fx")); if (c === b) return f.queue(this[0], a); - return this.each(function() { + return this.each(function () { var b = f.queue(this, a, c); a === "fx" && b[0] !== "inprogress" && f.dequeue(this, a); }); }, - dequeue: function(a) { - return this.each(function() { + dequeue: function (a) { + return this.each(function () { f.dequeue(this, a); }); }, - delay: function(a, b) { - (a = f.fx ? f.fx.speeds[a] || a : a), (b = b || "fx"); - return this.queue(b, function(b, c) { + delay: function (a, b) { + ((a = f.fx ? f.fx.speeds[a] || a : a), (b = b || "fx")); + return this.queue(b, function (b, c) { var d = setTimeout(b, a); - c.stop = function() { + c.stop = function () { clearTimeout(d); }; }); }, - clearQueue: function(a) { + clearQueue: function (a) { return this.queue(a || "fx", []); }, - promise: function(a, c) { + promise: function (a, c) { function m() { --h || d.resolveWith(e, [e]); } - typeof a != "string" && ((c = a), (a = b)), (a = a || "fx"); + (typeof a != "string" && ((c = a), (a = b)), (a = a || "fx")); var d = f.Deferred(), e = this, g = e.length, @@ -1480,46 +1474,47 @@ ((f.data(e[g], j, b, !0) || f.data(e[g], k, b, !0)) && f.data(e[g], i, f.Callbacks("once memory"), !0))) ) - h++, l.add(m); + (h++, l.add(m)); m(); return d.promise(); } - }); + })); var o = /[\n\t\r]/g, p = /\s+/, q = /\r/g, r = /^(?:button|input)$/i, s = /^(?:button|input|object|select|textarea)$/i, t = /^a(?:rea)?$/i, - u = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, + u = + /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, v = f.support.getSetAttribute, w, x, y; - f.fn.extend({ - attr: function(a, b) { + (f.fn.extend({ + attr: function (a, b) { return f.access(this, a, b, !0, f.attr); }, - removeAttr: function(a) { - return this.each(function() { + removeAttr: function (a) { + return this.each(function () { f.removeAttr(this, a); }); }, - prop: function(a, b) { + prop: function (a, b) { return f.access(this, a, b, !0, f.prop); }, - removeProp: function(a) { + removeProp: function (a) { a = f.propFix[a] || a; - return this.each(function() { + return this.each(function () { try { - (this[a] = b), delete this[a]; + ((this[a] = b), delete this[a]); } catch (c) {} }); }, - addClass: function(a) { + addClass: function (a) { var b, c, d, e, g, h, i; if (f.isFunction(a)) - return this.each(function(b) { + return this.each(function (b) { f(this).addClass(a.call(this, b, this.className)); }); if (a && typeof a == "string") { @@ -1538,10 +1533,10 @@ } return this; }, - removeClass: function(a) { + removeClass: function (a) { var c, d, e, g, h, i, j; if (f.isFunction(a)) - return this.each(function(b) { + return this.each(function (b) { f(this).removeClass(a.call(this, b, this.className)); }); if ((a && typeof a == "string") || a === b) { @@ -1559,14 +1554,14 @@ } return this; }, - toggleClass: function(a, b) { + toggleClass: function (a, b) { var c = typeof a, d = typeof b == "boolean"; if (f.isFunction(a)) - return this.each(function(c) { + return this.each(function (c) { f(this).toggleClass(a.call(this, c, this.className, b), b); }); - return this.each(function() { + return this.each(function () { if (c === "string") { var e, g = 0, @@ -1574,11 +1569,17 @@ i = b, j = a.split(p); while ((e = j[g++])) - (i = d ? i : !h.hasClass(e)), h[i ? "addClass" : "removeClass"](e); - } else if (c === "undefined" || c === "boolean") this.className && f._data(this, "__className__", this.className), (this.className = this.className || a === !1 ? "" : f._data(this, "__className__") || ""); + ((i = d ? i : !h.hasClass(e)), + h[i ? "addClass" : "removeClass"](e)); + } else if (c === "undefined" || c === "boolean") + (this.className && f._data(this, "__className__", this.className), + (this.className = + this.className || a === !1 + ? "" + : f._data(this, "__className__") || "")); }); }, - hasClass: function(a) { + hasClass: function (a) { var b = " " + a + " ", c = 0, d = this.length; @@ -1590,7 +1591,7 @@ return !0; return !1; }, - val: function(a) { + val: function (a) { var c, d, e, @@ -1598,22 +1599,22 @@ { if (!!arguments.length) { e = f.isFunction(a); - return this.each(function(d) { + return this.each(function (d) { var g = f(this), h; if (this.nodeType === 1) { - e ? (h = a.call(this, d, g.val())) : (h = a), + (e ? (h = a.call(this, d, g.val())) : (h = a), h == null ? (h = "") : typeof h == "number" - ? (h += "") - : f.isArray(h) && - (h = f.map(h, function(a) { - return a == null ? "" : a + ""; - })), + ? (h += "") + : f.isArray(h) && + (h = f.map(h, function (a) { + return a == null ? "" : a + ""; + })), (c = f.valHooks[this.nodeName.toLowerCase()] || - f.valHooks[this.type]); + f.valHooks[this.type])); if (!c || !("set" in c) || c.set(this, h, "value") === b) this.value = h; } @@ -1631,13 +1632,13 @@ f.extend({ valHooks: { option: { - get: function(a) { + get: function (a) { var b = a.attributes.value; return !b || b.specified ? a.value : a.text; } }, select: { - get: function(a) { + get: function (a) { var b, c, d, @@ -1647,7 +1648,7 @@ i = a.options, j = a.type === "select-one"; if (g < 0) return null; - (c = j ? g : 0), (d = j ? g + 1 : i.length); + ((c = j ? g : 0), (d = j ? g + 1 : i.length)); for (; c < d; c++) { e = i[c]; if ( @@ -1666,14 +1667,14 @@ if (j && !h.length && i.length) return f(i[g]).val(); return h; }, - set: function(a, b) { + set: function (a, b) { var c = f.makeArray(b); - f(a) + (f(a) .find("option") - .each(function() { + .each(function () { this.selected = f.inArray(f(this).val(), c) >= 0; }), - c.length || (a.selectedIndex = -1); + c.length || (a.selectedIndex = -1)); return c; } } @@ -1688,7 +1689,7 @@ height: !0, offset: !0 }, - attr: function(a, c, d, e) { + attr: function (a, c, d, e) { var g, h, i, @@ -1696,10 +1697,10 @@ if (!!a && j !== 3 && j !== 8 && j !== 2) { if (e && c in f.attrFn) return f(a)[c](d); if (typeof a.getAttribute == "undefined") return f.prop(a, c, d); - (i = j !== 1 || !f.isXMLDoc(a)), + ((i = j !== 1 || !f.isXMLDoc(a)), i && ((c = c.toLowerCase()), - (h = f.attrHooks[c] || (u.test(c) ? x : w))); + (h = f.attrHooks[c] || (u.test(c) ? x : w)))); if (d !== b) { if (d === null) { f.removeAttr(a, c); @@ -1714,26 +1715,26 @@ return g === null ? b : g; } }, - removeAttr: function(a, b) { + removeAttr: function (a, b) { var c, d, e, g, h = 0; if (b && a.nodeType === 1) { - (d = b.toLowerCase().split(p)), (g = d.length); + ((d = b.toLowerCase().split(p)), (g = d.length)); for (; h < g; h++) - (e = d[h]), + ((e = d[h]), e && ((c = f.propFix[e] || e), f.attr(a, e, ""), a.removeAttribute(v ? e : c), - u.test(e) && c in a && (a[c] = !1)); + u.test(e) && c in a && (a[c] = !1))); } }, attrHooks: { type: { - set: function(a, b) { + set: function (a, b) { if (r.test(a.nodeName) && a.parentNode) f.error("type property can't be changed"); else if ( @@ -1742,17 +1743,17 @@ f.nodeName(a, "input") ) { var c = a.value; - a.setAttribute("type", b), c && (a.value = c); + (a.setAttribute("type", b), c && (a.value = c)); return b; } } }, value: { - get: function(a, b) { + get: function (a, b) { if (w && f.nodeName(a, "button")) return w.get(a, b); return b in a ? a.value : null; }, - set: function(a, b, c) { + set: function (a, b, c) { if (w && f.nodeName(a, "button")) return w.set(a, b, c); a.value = b; } @@ -1772,39 +1773,39 @@ frameborder: "frameBorder", contenteditable: "contentEditable" }, - prop: function(a, c, d) { + prop: function (a, c, d) { var e, g, h, i = a.nodeType; if (!!a && i !== 3 && i !== 8 && i !== 2) { - (h = i !== 1 || !f.isXMLDoc(a)), - h && ((c = f.propFix[c] || c), (g = f.propHooks[c])); + ((h = i !== 1 || !f.isXMLDoc(a)), + h && ((c = f.propFix[c] || c), (g = f.propHooks[c]))); return d !== b ? g && "set" in g && (e = g.set(a, d, c)) !== b ? e : (a[c] = d) : g && "get" in g && (e = g.get(a, c)) !== null - ? e - : a[c]; + ? e + : a[c]; } }, propHooks: { tabIndex: { - get: function(a) { + get: function (a) { var c = a.getAttributeNode("tabindex"); return c && c.specified ? parseInt(c.value, 10) : s.test(a.nodeName) || (t.test(a.nodeName) && a.href) - ? 0 - : b; + ? 0 + : b; } } } }), (f.attrHooks.tabindex = f.propHooks.tabIndex), (x = { - get: function(a, c) { + get: function (a, c) { var d, e = f.prop(a, c); return e === !0 || @@ -1814,7 +1815,7 @@ ? c.toLowerCase() : b; }, - set: function(a, b, c) { + set: function (a, b, c) { var d; b === !1 ? f.removeAttr(a, c) @@ -1826,24 +1827,25 @@ }), v || ((y = { name: !0, id: !0 }), - (w = f.valHooks.button = { - get: function(a, c) { - var d; - d = a.getAttributeNode(c); - return d && (y[c] ? d.nodeValue !== "" : d.specified) - ? d.nodeValue - : b; - }, - set: function(a, b, d) { - var e = a.getAttributeNode(d); - e || ((e = c.createAttribute(d)), a.setAttributeNode(e)); - return (e.nodeValue = b + ""); - } - }), + (w = f.valHooks.button = + { + get: function (a, c) { + var d; + d = a.getAttributeNode(c); + return d && (y[c] ? d.nodeValue !== "" : d.specified) + ? d.nodeValue + : b; + }, + set: function (a, b, d) { + var e = a.getAttributeNode(d); + e || ((e = c.createAttribute(d)), a.setAttributeNode(e)); + return (e.nodeValue = b + ""); + } + }), (f.attrHooks.tabindex.set = w.set), - f.each(["width", "height"], function(a, b) { + f.each(["width", "height"], function (a, b) { f.attrHooks[b] = f.extend(f.attrHooks[b], { - set: function(a, c) { + set: function (a, c) { if (c === "") { a.setAttribute(b, "auto"); return c; @@ -1853,14 +1855,14 @@ }), (f.attrHooks.contenteditable = { get: w.get, - set: function(a, b, c) { - b === "" && (b = "false"), w.set(a, b, c); + set: function (a, b, c) { + (b === "" && (b = "false"), w.set(a, b, c)); } })), f.support.hrefNormalized || - f.each(["href", "src", "width", "height"], function(a, c) { + f.each(["href", "src", "width", "height"], function (a, c) { f.attrHooks[c] = f.extend(f.attrHooks[c], { - get: function(a) { + get: function (a) { var d = a.getAttribute(c, 2); return d === null ? b : d; } @@ -1868,16 +1870,16 @@ }), f.support.style || (f.attrHooks.style = { - get: function(a) { + get: function (a) { return a.style.cssText.toLowerCase() || b; }, - set: function(a, b) { + set: function (a, b) { return (a.style.cssText = "" + b); } }), f.support.optSelected || (f.propHooks.selected = f.extend(f.propHooks.selected, { - get: function(a) { + get: function (a) { var b = a.parentNode; b && (b.selectedIndex, b.parentNode && b.parentNode.selectedIndex); return null; @@ -1885,20 +1887,20 @@ })), f.support.enctype || (f.propFix.enctype = "encoding"), f.support.checkOn || - f.each(["radio", "checkbox"], function() { + f.each(["radio", "checkbox"], function () { f.valHooks[this] = { - get: function(a) { + get: function (a) { return a.getAttribute("value") === null ? "on" : a.value; } }; }), - f.each(["radio", "checkbox"], function() { + f.each(["radio", "checkbox"], function () { f.valHooks[this] = f.extend(f.valHooks[this], { - set: function(a, b) { + set: function (a, b) { if (f.isArray(b)) return (a.checked = f.inArray(f(a).val(), b) >= 0); } }); - }); + })); var z = /^(?:textarea|input|select)$/i, A = /^([^\.]*)?(?:\.(.+))?$/, B = /\bhover(\.\S+)?\b/, @@ -1906,14 +1908,14 @@ D = /^(?:mouse|contextmenu)|click/, E = /^(?:focusinfocus|focusoutblur)$/, F = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/, - G = function(a) { + G = function (a) { var b = F.exec(a); b && ((b[1] = (b[1] || "").toLowerCase()), (b[3] = b[3] && new RegExp("(?:^|\\s)" + b[3] + "(?:\\s|$)"))); return b; }, - H = function(a, b) { + H = function (a, b) { var c = a.attributes || {}; return ( (!b[1] || a.nodeName.toLowerCase() === b[1]) && @@ -1921,33 +1923,38 @@ (!b[3] || b[3].test((c["class"] || {}).value)) ); }, - I = function(a) { + I = function (a) { return f.event.special.hover ? a : a.replace(B, "mouseenter$1 mouseleave$1"); }; - (f.event = { - add: function(a, c, d, e, g) { + ((f.event = { + add: function (a, c, d, e, g) { var h, i, j, k, l, m, n, o, p, q, r, s; - if ( - !(a.nodeType === 3 || a.nodeType === 8 || !c || !d || !(h = f._data(a))) - ) { - d.handler && ((p = d), (d = p.handler)), + if (!( + a.nodeType === 3 || + a.nodeType === 8 || + !c || + !d || + !(h = f._data(a)) + )) { + (d.handler && ((p = d), (d = p.handler)), d.guid || (d.guid = f.guid++), (j = h.events), j || (h.events = j = {}), (i = h.handle), i || - ((h.handle = i = function(a) { - return typeof f != "undefined" && - (!a || f.event.triggered !== a.type) - ? f.event.dispatch.apply(i.elem, arguments) - : b; - }), + ((h.handle = i = + function (a) { + return typeof f != "undefined" && + (!a || f.event.triggered !== a.type) + ? f.event.dispatch.apply(i.elem, arguments) + : b; + }), (i.elem = a)), - (c = f.trim(I(c)).split(" ")); + (c = f.trim(I(c)).split(" "))); for (k = 0; k < c.length; k++) { - (l = A.exec(c[k]) || []), + ((l = A.exec(c[k]) || []), (m = l[1]), (n = (l[2] || "").split(".").sort()), (s = f.event.special[m] || {}), @@ -1966,24 +1973,24 @@ }, p )), - (r = j[m]); + (r = j[m])); if (!r) { - (r = j[m] = []), (r.delegateCount = 0); + ((r = j[m] = []), (r.delegateCount = 0)); if (!s.setup || s.setup.call(a, e, n, i) === !1) a.addEventListener ? a.addEventListener(m, i, !1) : a.attachEvent && a.attachEvent("on" + m, i); } - s.add && + (s.add && (s.add.call(a, o), o.handler.guid || (o.handler.guid = d.guid)), g ? r.splice(r.delegateCount++, 0, o) : r.push(o), - (f.event.global[m] = !0); + (f.event.global[m] = !0)); } a = null; } }, global: {}, - remove: function(a, b, c, d, e) { + remove: function (a, b, c, d, e) { var g = f.hasData(a) && f._data(a), h, i, @@ -2000,34 +2007,31 @@ if (!!g && !!(o = g.events)) { b = f.trim(I(b || "")).split(" "); for (h = 0; h < b.length; h++) { - (i = A.exec(b[h]) || []), (j = k = i[1]), (l = i[2]); + ((i = A.exec(b[h]) || []), (j = k = i[1]), (l = i[2])); if (!j) { for (j in o) f.event.remove(a, j + b[h], c, d, !0); continue; } - (p = f.event.special[j] || {}), + ((p = f.event.special[j] || {}), (j = (d ? p.delegateType : p.bindType) || j), (r = o[j] || []), (m = r.length), (l = l ? new RegExp( "(^|\\.)" + - l - .split(".") - .sort() - .join("\\.(?:.*\\.)?") + + l.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)" ) - : null); + : null)); for (n = 0; n < r.length; n++) - (s = r[n]), + ((s = r[n]), (e || k === s.origType) && (!c || c.guid === s.guid) && (!l || l.test(s.namespace)) && (!d || d === s.selector || (d === "**" && s.selector)) && (r.splice(n--, 1), s.selector && r.delegateCount--, - p.remove && p.remove.call(a, s)); + p.remove && p.remove.call(a, s))); r.length === 0 && m !== r.length && ((!p.teardown || p.teardown.call(a, l) === !1) && @@ -2041,7 +2045,7 @@ } }, customEvent: { getData: !0, setData: !0, changeData: !0 }, - trigger: function(c, d, e, g) { + trigger: function (c, d, e, g) { if (!e || (e.nodeType !== 3 && e.nodeType !== 8)) { var h = c.type || c, i = [], @@ -2056,11 +2060,11 @@ r, s; if (E.test(h + f.event.triggered)) return; - h.indexOf("!") >= 0 && ((h = h.slice(0, -1)), (k = !0)), + (h.indexOf("!") >= 0 && ((h = h.slice(0, -1)), (k = !0)), h.indexOf(".") >= 0 && - ((i = h.split(".")), (h = i.shift()), i.sort()); + ((i = h.split(".")), (h = i.shift()), i.sort())); if ((!e || f.event.customEvent[h]) && !f.event.global[h]) return; - (c = + ((c = typeof c == "object" ? c[f.expando] ? c @@ -2073,7 +2077,7 @@ (c.namespace_re = c.namespace ? new RegExp("(^|\\.)" + i.join("\\.(?:.*\\.)?") + "(\\.|$)") : null), - (o = h.indexOf(":") < 0 ? "on" + h : ""); + (o = h.indexOf(":") < 0 ? "on" + h : "")); if (!e) { j = f.cache; for (l in j) @@ -2082,30 +2086,30 @@ f.event.trigger(c, d, j[l].handle.elem, !0); return; } - (c.result = b), + ((c.result = b), c.target || (c.target = e), (d = d != null ? f.makeArray(d) : []), d.unshift(c), - (p = f.event.special[h] || {}); + (p = f.event.special[h] || {})); if (p.trigger && p.trigger.apply(e, d) === !1) return; r = [[e, p.bindType || h]]; if (!g && !p.noBubble && !f.isWindow(e)) { - (s = p.delegateType || h), + ((s = p.delegateType || h), (m = E.test(s + h) ? e : e.parentNode), - (n = null); - for (; m; m = m.parentNode) r.push([m, s]), (n = m); + (n = null)); + for (; m; m = m.parentNode) (r.push([m, s]), (n = m)); n && n === e.ownerDocument && r.push([n.defaultView || n.parentWindow || a, s]); } for (l = 0; l < r.length && !c.isPropagationStopped(); l++) - (m = r[l][0]), + ((m = r[l][0]), (c.type = r[l][1]), (q = (f._data(m, "events") || {})[c.type] && f._data(m, "handle")), q && q.apply(m, d), (q = o && m[o]), - q && f.acceptData(m) && q.apply(m, d) === !1 && c.preventDefault(); - (c.type = h), + q && f.acceptData(m) && q.apply(m, d) === !1 && c.preventDefault()); + ((c.type = h), !g && !c.isDefaultPrevented() && (!p._default || p._default.apply(e.ownerDocument, d) === !1) && @@ -2120,11 +2124,11 @@ (f.event.triggered = h), e[h](), (f.event.triggered = b), - n && (e[o] = n)); + n && (e[o] = n))); return c.result; } }, - dispatch: function(c) { + dispatch: function (c) { c = f.event.fix(c || a.event); var d = (f._data(this, "events") || {})[c.type] || [], e = d.delegateCount, @@ -2142,22 +2146,22 @@ r, s, t; - (g[0] = c), (c.delegateTarget = this); + ((g[0] = c), (c.delegateTarget = this)); if (e && !c.target.disabled && (!c.button || c.type !== "click")) { - (m = f(this)), (m.context = this.ownerDocument || this); + ((m = f(this)), (m.context = this.ownerDocument || this)); for (l = c.target; l != this; l = l.parentNode || this) { - (o = {}), (q = []), (m[0] = l); + ((o = {}), (q = []), (m[0] = l)); for (j = 0; j < e; j++) - (r = d[j]), + ((r = d[j]), (s = r.selector), o[s] === b && (o[s] = r.quick ? H(l, r.quick) : m.is(s)), - o[s] && q.push(r); + o[s] && q.push(r)); q.length && i.push({ elem: l, matches: q }); } } d.length > e && i.push({ elem: this, matches: d.slice(e) }); for (j = 0; j < i.length && !c.isPropagationStopped(); j++) { - (p = i[j]), (c.currentTarget = p.elem); + ((p = i[j]), (c.currentTarget = p.elem)); for ( k = 0; k < p.matches.length && !c.isImmediatePropagationStopped(); @@ -2169,41 +2173,43 @@ (!c.namespace && !r.namespace) || (c.namespace_re && c.namespace_re.test(r.namespace)) ) - (c.data = r.data), + ((c.data = r.data), (c.handleObj = r), (n = ( (f.event.special[r.origType] || {}).handle || r.handler ).apply(p.elem, g)), n !== b && ((c.result = n), - n === !1 && (c.preventDefault(), c.stopPropagation())); + n === !1 && (c.preventDefault(), c.stopPropagation()))); } } return c.result; }, - props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split( - " " - ), + props: + "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split( + " " + ), fixHooks: {}, keyHooks: { props: "char charCode key keyCode".split(" "), - filter: function(a, b) { + filter: function (a, b) { a.which == null && (a.which = b.charCode != null ? b.charCode : b.keyCode); return a; } }, mouseHooks: { - props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split( - " " - ), - filter: function(a, d) { + props: + "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split( + " " + ), + filter: function (a, d) { var e, f, g, h = d.button, i = d.fromElement; - a.pageX == null && + (a.pageX == null && d.clientX != null && ((e = a.target.ownerDocument || c), (f = e.documentElement), @@ -2221,11 +2227,11 @@ (a.relatedTarget = i === a.target ? d.toElement : i), !a.which && h !== b && - (a.which = h & 1 ? 1 : h & 2 ? 3 : h & 4 ? 2 : 0); + (a.which = h & 1 ? 1 : h & 2 ? 3 : h & 4 ? 2 : 0)); return a; } }, - fix: function(a) { + fix: function (a) { if (a[f.expando]) return a; var d, e, @@ -2233,10 +2239,10 @@ h = f.event.fixHooks[a.type] || {}, i = h.props ? this.props.concat(h.props) : this.props; a = f.Event(g); - for (d = i.length; d; ) (e = i[--d]), (a[e] = g[e]); - a.target || (a.target = g.srcElement || c), + for (d = i.length; d;) ((e = i[--d]), (a[e] = g[e])); + (a.target || (a.target = g.srcElement || c), a.target.nodeType === 3 && (a.target = a.target.parentNode), - a.metaKey === b && (a.metaKey = a.ctrlKey); + a.metaKey === b && (a.metaKey = a.ctrlKey)); return h.filter ? h.filter(a, g) : a; }, special: { @@ -2245,35 +2251,35 @@ focus: { delegateType: "focusin" }, blur: { delegateType: "focusout" }, beforeunload: { - setup: function(a, b, c) { + setup: function (a, b, c) { f.isWindow(this) && (this.onbeforeunload = c); }, - teardown: function(a, b) { + teardown: function (a, b) { this.onbeforeunload === b && (this.onbeforeunload = null); } } }, - simulate: function(a, b, c, d) { + simulate: function (a, b, c, d) { var e = f.extend(new f.Event(), c, { type: a, isSimulated: !0, originalEvent: {} }); - d ? f.event.trigger(e, null, b) : f.event.dispatch.call(b, e), - e.isDefaultPrevented() && c.preventDefault(); + (d ? f.event.trigger(e, null, b) : f.event.dispatch.call(b, e), + e.isDefaultPrevented() && c.preventDefault()); } }), (f.event.handle = f.event.dispatch), (f.removeEvent = c.removeEventListener - ? function(a, b, c) { + ? function (a, b, c) { a.removeEventListener && a.removeEventListener(b, c, !1); } - : function(a, b, c) { + : function (a, b, c) { a.detachEvent && a.detachEvent("on" + b, c); }), - (f.Event = function(a, b) { + (f.Event = function (a, b) { if (!(this instanceof f.Event)) return new f.Event(a, b); - a && a.type + (a && a.type ? ((this.originalEvent = a), (this.type = a.type), (this.isDefaultPrevented = @@ -2285,55 +2291,58 @@ : (this.type = a), b && f.extend(this, b), (this.timeStamp = (a && a.timeStamp) || f.now()), - (this[f.expando] = !0); + (this[f.expando] = !0)); }), (f.Event.prototype = { - preventDefault: function() { + preventDefault: function () { this.isDefaultPrevented = K; var a = this.originalEvent; !a || (a.preventDefault ? a.preventDefault() : (a.returnValue = !1)); }, - stopPropagation: function() { + stopPropagation: function () { this.isPropagationStopped = K; var a = this.originalEvent; !a || (a.stopPropagation && a.stopPropagation(), (a.cancelBubble = !0)); }, - stopImmediatePropagation: function() { - (this.isImmediatePropagationStopped = K), this.stopPropagation(); + stopImmediatePropagation: function () { + ((this.isImmediatePropagationStopped = K), this.stopPropagation()); }, isDefaultPrevented: J, isPropagationStopped: J, isImmediatePropagationStopped: J }), - f.each({ mouseenter: "mouseover", mouseleave: "mouseout" }, function(a, b) { - f.event.special[a] = { - delegateType: b, - bindType: b, - handle: function(a) { - var c = this, - d = a.relatedTarget, - e = a.handleObj, - g = e.selector, - h; - if (!d || (d !== c && !f.contains(c, d))) - (a.type = e.origType), - (h = e.handler.apply(this, arguments)), - (a.type = b); - return h; - } - }; - }), + f.each( + { mouseenter: "mouseover", mouseleave: "mouseout" }, + function (a, b) { + f.event.special[a] = { + delegateType: b, + bindType: b, + handle: function (a) { + var c = this, + d = a.relatedTarget, + e = a.handleObj, + g = e.selector, + h; + if (!d || (d !== c && !f.contains(c, d))) + ((a.type = e.origType), + (h = e.handler.apply(this, arguments)), + (a.type = b)); + return h; + } + }; + } + ), f.support.submitBubbles || (f.event.special.submit = { - setup: function() { + setup: function () { if (f.nodeName(this, "form")) return !1; - f.event.add(this, "click._submit keypress._submit", function(a) { + f.event.add(this, "click._submit keypress._submit", function (a) { var c = a.target, d = f.nodeName(c, "input") || f.nodeName(c, "button") ? c.form : b; d && !d._submit_attached && - (f.event.add(d, "submit._submit", function(a) { + (f.event.add(d, "submit._submit", function (a) { this.parentNode && !a.isTrigger && f.event.simulate("submit", this.parentNode, a, !0); @@ -2341,33 +2350,33 @@ (d._submit_attached = !0)); }); }, - teardown: function() { + teardown: function () { if (f.nodeName(this, "form")) return !1; f.event.remove(this, "._submit"); } }), f.support.changeBubbles || (f.event.special.change = { - setup: function() { + setup: function () { if (z.test(this.nodeName)) { if (this.type === "checkbox" || this.type === "radio") - f.event.add(this, "propertychange._change", function(a) { + (f.event.add(this, "propertychange._change", function (a) { a.originalEvent.propertyName === "checked" && (this._just_changed = !0); }), - f.event.add(this, "click._change", function(a) { + f.event.add(this, "click._change", function (a) { this._just_changed && !a.isTrigger && ((this._just_changed = !1), f.event.simulate("change", this, a, !0)); - }); + })); return !1; } - f.event.add(this, "beforeactivate._change", function(a) { + f.event.add(this, "beforeactivate._change", function (a) { var b = a.target; z.test(b.nodeName) && !b._change_attached && - (f.event.add(b, "change._change", function(a) { + (f.event.add(b, "change._change", function (a) { this.parentNode && !a.isSimulated && !a.isTrigger && @@ -2376,7 +2385,7 @@ (b._change_attached = !0)); }); }, - handle: function(a) { + handle: function (a) { var b = a.target; if ( this !== b || @@ -2386,28 +2395,28 @@ ) return a.handleObj.handler.apply(this, arguments); }, - teardown: function() { + teardown: function () { f.event.remove(this, "._change"); return z.test(this.nodeName); } }), f.support.focusinBubbles || - f.each({ focus: "focusin", blur: "focusout" }, function(a, b) { + f.each({ focus: "focusin", blur: "focusout" }, function (a, b) { var d = 0, - e = function(a) { + e = function (a) { f.event.simulate(b, a.target, f.event.fix(a), !0); }; f.event.special[b] = { - setup: function() { + setup: function () { d++ === 0 && c.addEventListener(a, e, !0); }, - teardown: function() { + teardown: function () { --d === 0 && c.removeEventListener(a, e, !0); } }; }), f.fn.extend({ - on: function(a, c, d, e, g) { + on: function (a, c, d, e, g) { var h, i; if (typeof a == "object") { typeof c != "string" && ((d = c), (c = b)); @@ -2424,19 +2433,19 @@ else if (!e) return this; g === 1 && ((h = e), - (e = function(a) { + (e = function (a) { f().off(a); return h.apply(this, arguments); }), (e.guid = h.guid || (h.guid = f.guid++))); - return this.each(function() { + return this.each(function () { f.event.add(this, a, e, d, c); }); }, - one: function(a, b, c, d) { + one: function (a, b, c, d) { return this.on.call(this, a, b, c, d, 1); }, - off: function(a, c, d) { + off: function (a, c, d) { if (a && a.preventDefault && a.handleObj) { var e = a.handleObj; f(a.delegateTarget).off( @@ -2450,54 +2459,54 @@ for (var g in a) this.off(g, c, a[g]); return this; } - if (c === !1 || typeof c == "function") (d = c), (c = b); + if (c === !1 || typeof c == "function") ((d = c), (c = b)); d === !1 && (d = J); - return this.each(function() { + return this.each(function () { f.event.remove(this, a, d, c); }); }, - bind: function(a, b, c) { + bind: function (a, b, c) { return this.on(a, null, b, c); }, - unbind: function(a, b) { + unbind: function (a, b) { return this.off(a, null, b); }, - live: function(a, b, c) { + live: function (a, b, c) { f(this.context).on(a, this.selector, b, c); return this; }, - die: function(a, b) { + die: function (a, b) { f(this.context).off(a, this.selector || "**", b); return this; }, - delegate: function(a, b, c, d) { + delegate: function (a, b, c, d) { return this.on(b, a, c, d); }, - undelegate: function(a, b, c) { + undelegate: function (a, b, c) { return arguments.length == 1 ? this.off(a, "**") : this.off(b, a, c); }, - trigger: function(a, b) { - return this.each(function() { + trigger: function (a, b) { + return this.each(function () { f.event.trigger(a, b, this); }); }, - triggerHandler: function(a, b) { + triggerHandler: function (a, b) { if (this[0]) return f.event.trigger(a, b, this[0], !0); }, - toggle: function(a) { + toggle: function (a) { var b = arguments, c = a.guid || f.guid++, d = 0, - e = function(c) { + e = function (c) { var e = (f._data(this, "lastToggle" + a.guid) || 0) % d; - f._data(this, "lastToggle" + a.guid, e + 1), c.preventDefault(); + (f._data(this, "lastToggle" + a.guid, e + 1), c.preventDefault()); return b[e].apply(this, arguments) || !1; }; e.guid = c; while (d < b.length) b[d++].guid = c; return this.click(e); }, - hover: function(a, b) { + hover: function (a, b) { return this.mouseenter(a).mouseleave(b || a); } }), @@ -2505,8 +2514,8 @@ "blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split( " " ), - function(a, b) { - (f.fn[b] = function(a, c) { + function (a, b) { + ((f.fn[b] = function (a, c) { c == null && ((c = a), (a = null)); return arguments.length > 0 ? this.on(b, null, a, c) @@ -2514,10 +2523,10 @@ }), f.attrFn && (f.attrFn[b] = !0), C.test(b) && (f.event.fixHooks[b] = f.event.keyHooks), - D.test(b) && (f.event.fixHooks[b] = f.event.mouseHooks); + D.test(b) && (f.event.fixHooks[b] = f.event.mouseHooks)); } ), - (function() { + (function () { function x(a, b, c, e, f, g) { for (var h = 0, i = e.length; h < i; h++) { var j = e[h]; @@ -2569,7 +2578,8 @@ } } } - var a = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, + var a = + /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, d = "sizcache" + (Math.random() + "").replace(".", ""), e = 0, g = Object.prototype.toString, @@ -2578,12 +2588,12 @@ j = /\\/g, k = /\r\n/g, l = /\W/; - [0, 0].sort(function() { + [0, 0].sort(function () { i = !1; return 0; }); - var m = function(b, d, e, f) { - (e = e || []), (d = d || c); + var m = function (b, d, e, f) { + ((e = e || []), (d = d || c)); var h = d; if (d.nodeType !== 1 && d.nodeType !== 9) return []; if (!b || typeof b != "string") return e; @@ -2600,9 +2610,9 @@ w = [], x = b; do { - a.exec(""), (i = a.exec(x)); + (a.exec(""), (i = a.exec(x))); if (i) { - (x = i[3]), w.push(i[1]); + ((x = i[3]), w.push(i[1])); if (i[2]) { l = i[3]; break; @@ -2614,9 +2624,9 @@ else { j = o.relative[w[0]] ? [d] : m(w.shift(), d); while (w.length) - (b = w.shift()), + ((b = w.shift()), o.relative[b] && (b += w.shift()), - (j = y(b, j, f)); + (j = y(b, j, f))); } else { !f && @@ -2628,7 +2638,7 @@ ((n = m.find(w.shift(), d, v)), (d = n.expr ? m.filter(n.expr, n.set)[0] : n.set[0])); if (d) { - (n = f + ((n = f ? { expr: w.pop(), set: s(f) } : m.find( w.pop(), @@ -2640,16 +2650,16 @@ v )), (j = n.expr ? m.filter(n.expr, n.set) : n.set), - w.length > 0 ? (k = s(j)) : (u = !1); + w.length > 0 ? (k = s(j)) : (u = !1)); while (w.length) - (q = w.pop()), + ((q = w.pop()), (r = q), o.relative[q] ? (r = w.pop()) : (q = ""), r == null && (r = d), - o.relative[q](k, r, v); + o.relative[q](k, r, v)); } else k = w = []; } - k || (k = j), k || m.error(q || b); + (k || (k = j), k || m.error(q || b)); if (g.call(k) === "[object Array]") if (!u) e.push.apply(e, k); else if (d && d.nodeType === 1) @@ -2664,30 +2674,31 @@ l && (m(l, h, e, f), m.uniqueSort(e)); return e; }; - (m.uniqueSort = function(a) { + ((m.uniqueSort = function (a) { if (u) { - (h = i), a.sort(u); + ((h = i), a.sort(u)); if (h) for (var b = 1; b < a.length; b++) a[b] === a[b - 1] && a.splice(b--, 1); } return a; }), - (m.matches = function(a, b) { + (m.matches = function (a, b) { return m(a, null, null, b); }), - (m.matchesSelector = function(a, b) { + (m.matchesSelector = function (a, b) { return m(b, null, null, [a]).length > 0; }), - (m.find = function(a, b, c) { + (m.find = function (a, b, c) { var d, e, f, g, h, i; if (!a) return []; for (e = 0, f = o.order.length; e < f; e++) { h = o.order[e]; if ((g = o.leftMatch[h].exec(a))) { - (i = g[1]), g.splice(1, 1); + ((i = g[1]), g.splice(1, 1)); if (i.substr(i.length - 1) !== "\\") { - (g[1] = (g[1] || "").replace(j, "")), (d = o.find[h](g, b, c)); + ((g[1] = (g[1] || "").replace(j, "")), + (d = o.find[h](g, b, c))); if (d != null) { a = a.replace(o.match[h], ""); break; @@ -2702,7 +2713,7 @@ : []); return { set: d, expr: a }; }), - (m.filter = function(a, c, d, e) { + (m.filter = function (a, c, d, e) { var f, g, h, @@ -2719,7 +2730,7 @@ while (a && c.length) { for (h in o.filter) if ((f = o.leftMatch[h].exec(a)) != null && f[2]) { - (k = o.filter[h]), (l = f[1]), (g = !1), f.splice(1, 1); + ((k = o.filter[h]), (l = f[1]), (g = !1), f.splice(1, 1)); if (l.substr(l.length - 1) === "\\") continue; s === r && (r = []); if (o.preFilter[h]) { @@ -2738,7 +2749,7 @@ : (s[n] = !1) : p && (r.push(j), (g = !0))); if (i !== b) { - d || (s = r), (a = a.replace(o.match[h], "")); + (d || (s = r), (a = a.replace(o.match[h], ""))); if (!g) return []; break; } @@ -2750,10 +2761,10 @@ } return s; }), - (m.error = function(a) { + (m.error = function (a) { throw new Error("Syntax error, unrecognized expression: " + a); - }); - var n = (m.getText = function(a) { + })); + var n = (m.getText = function (a) { var b, c, d = a.nodeType, @@ -2776,22 +2787,24 @@ NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, - CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, + CHILD: + /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, - PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ + PSEUDO: + /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ }, leftMatch: {}, attrMap: { class: "className", for: "htmlFor" }, attrHandle: { - href: function(a) { + href: function (a) { return a.getAttribute("href"); }, - type: function(a) { + type: function (a) { return a.getAttribute("type"); } }, relative: { - "+": function(a, b) { + "+": function (a, b) { var c = typeof b == "string", d = c && !l.test(b), e = c && !d; @@ -2806,7 +2819,7 @@ } e && m.filter(b, a, !0); }, - ">": function(a, b) { + ">": function (a, b) { var c, d = typeof b == "string", e = 0, @@ -2822,38 +2835,38 @@ } } else { for (; e < f; e++) - (c = a[e]), - c && (a[e] = d ? c.parentNode : c.parentNode === b); + ((c = a[e]), + c && (a[e] = d ? c.parentNode : c.parentNode === b)); d && m.filter(b, a, !0); } }, - "": function(a, b, c) { + "": function (a, b, c) { var d, f = e++, g = x; - typeof b == "string" && + (typeof b == "string" && !l.test(b) && ((b = b.toLowerCase()), (d = b), (g = w)), - g("parentNode", b, f, a, d, c); + g("parentNode", b, f, a, d, c)); }, - "~": function(a, b, c) { + "~": function (a, b, c) { var d, f = e++, g = x; - typeof b == "string" && + (typeof b == "string" && !l.test(b) && ((b = b.toLowerCase()), (d = b), (g = w)), - g("previousSibling", b, f, a, d, c); + g("previousSibling", b, f, a, d, c)); } }, find: { - ID: function(a, b, c) { + ID: function (a, b, c) { if (typeof b.getElementById != "undefined" && !c) { var d = b.getElementById(a[1]); return d && d.parentNode ? [d] : []; } }, - NAME: function(a, b) { + NAME: function (a, b) { if (typeof b.getElementsByName != "undefined") { var c = [], d = b.getElementsByName(a[1]); @@ -2862,13 +2875,13 @@ return c.length === 0 ? null : c; } }, - TAG: function(a, b) { + TAG: function (a, b) { if (typeof b.getElementsByTagName != "undefined") return b.getElementsByTagName(a[1]); } }, preFilter: { - CLASS: function(a, b, c, d, e, f) { + CLASS: function (a, b, c, d, e, f) { a = " " + a[1].replace(j, "") + " "; if (f) return a; for (var g = 0, h; (h = b[g]) != null; g++) @@ -2882,34 +2895,34 @@ : c && (b[g] = !1)); return !1; }, - ID: function(a) { + ID: function (a) { return a[1].replace(j, ""); }, - TAG: function(a, b) { + TAG: function (a, b) { return a[1].replace(j, "").toLowerCase(); }, - CHILD: function(a) { + CHILD: function (a) { if (a[1] === "nth") { - a[2] || m.error(a[0]), (a[2] = a[2].replace(/^\+|\s*/g, "")); + (a[2] || m.error(a[0]), (a[2] = a[2].replace(/^\+|\s*/g, ""))); var b = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( (a[2] === "even" && "2n") || (a[2] === "odd" && "2n+1") || (!/\D/.test(a[2]) && "0n+" + a[2]) || a[2] ); - (a[2] = b[1] + (b[2] || 1) - 0), (a[3] = b[3] - 0); + ((a[2] = b[1] + (b[2] || 1) - 0), (a[3] = b[3] - 0)); } else a[2] && m.error(a[0]); a[0] = e++; return a; }, - ATTR: function(a, b, c, d, e, f) { + ATTR: function (a, b, c, d, e, f) { var g = (a[1] = a[1].replace(j, "")); - !f && o.attrMap[g] && (a[1] = o.attrMap[g]), + (!f && o.attrMap[g] && (a[1] = o.attrMap[g]), (a[4] = (a[4] || a[5] || "").replace(j, "")), - a[2] === "~=" && (a[4] = " " + a[4] + " "); + a[2] === "~=" && (a[4] = " " + a[4] + " ")); return a; }, - PSEUDO: function(b, c, d, e, f) { + PSEUDO: function (b, c, d, e, f) { if (b[1] === "not") if ((a.exec(b[3]) || "").length > 1 || /^\w/.test(b[3])) b[3] = m(b[3], null, null, c); @@ -2922,38 +2935,38 @@ return !0; return b; }, - POS: function(a) { + POS: function (a) { a.unshift(!0); return a; } }, filters: { - enabled: function(a) { + enabled: function (a) { return a.disabled === !1 && a.type !== "hidden"; }, - disabled: function(a) { + disabled: function (a) { return a.disabled === !0; }, - checked: function(a) { + checked: function (a) { return a.checked === !0; }, - selected: function(a) { + selected: function (a) { a.parentNode && a.parentNode.selectedIndex; return a.selected === !0; }, - parent: function(a) { + parent: function (a) { return !!a.firstChild; }, - empty: function(a) { + empty: function (a) { return !a.firstChild; }, - has: function(a, b, c) { + has: function (a, b, c) { return !!m(c[3], a).length; }, - header: function(a) { + header: function (a) { return /h\d/i.test(a.nodeName); }, - text: function(a) { + text: function (a) { var b = a.getAttribute("type"), c = a.type; return ( @@ -2962,72 +2975,72 @@ (b === c || b === null) ); }, - radio: function(a) { + radio: function (a) { return a.nodeName.toLowerCase() === "input" && "radio" === a.type; }, - checkbox: function(a) { + checkbox: function (a) { return ( a.nodeName.toLowerCase() === "input" && "checkbox" === a.type ); }, - file: function(a) { + file: function (a) { return a.nodeName.toLowerCase() === "input" && "file" === a.type; }, - password: function(a) { + password: function (a) { return ( a.nodeName.toLowerCase() === "input" && "password" === a.type ); }, - submit: function(a) { + submit: function (a) { var b = a.nodeName.toLowerCase(); return (b === "input" || b === "button") && "submit" === a.type; }, - image: function(a) { + image: function (a) { return a.nodeName.toLowerCase() === "input" && "image" === a.type; }, - reset: function(a) { + reset: function (a) { var b = a.nodeName.toLowerCase(); return (b === "input" || b === "button") && "reset" === a.type; }, - button: function(a) { + button: function (a) { var b = a.nodeName.toLowerCase(); return (b === "input" && "button" === a.type) || b === "button"; }, - input: function(a) { + input: function (a) { return /input|select|textarea|button/i.test(a.nodeName); }, - focus: function(a) { + focus: function (a) { return a === a.ownerDocument.activeElement; } }, setFilters: { - first: function(a, b) { + first: function (a, b) { return b === 0; }, - last: function(a, b, c, d) { + last: function (a, b, c, d) { return b === d.length - 1; }, - even: function(a, b) { + even: function (a, b) { return b % 2 === 0; }, - odd: function(a, b) { + odd: function (a, b) { return b % 2 === 1; }, - lt: function(a, b, c) { + lt: function (a, b, c) { return b < c[3] - 0; }, - gt: function(a, b, c) { + gt: function (a, b, c) { return b > c[3] - 0; }, - nth: function(a, b, c) { + nth: function (a, b, c) { return c[3] - 0 === b; }, - eq: function(a, b, c) { + eq: function (a, b, c) { return c[3] - 0 === b; } }, filter: { - PSEUDO: function(a, b, c, d) { + PSEUDO: function (a, b, c, d) { var e = b[1], f = o.filters[e]; if (f) return f(a, c, b, d); @@ -3045,7 +3058,7 @@ } m.error(e); }, - CHILD: function(a, b) { + CHILD: function (a, b) { var c, e, f, @@ -3066,9 +3079,9 @@ while ((l = l.nextSibling)) if (l.nodeType === 1) return !1; return !0; case "nth": - (c = b[2]), (e = b[3]); + ((c = b[2]), (e = b[3])); if (c === 1 && e === 0) return !0; - (f = b[0]), (g = a.parentNode); + ((f = b[0]), (g = a.parentNode)); if (g && (g[d] !== f || !a.nodeIndex)) { i = 0; for (l = g.firstChild; l; l = l.nextSibling) @@ -3079,57 +3092,58 @@ return c === 0 ? j === 0 : j % c === 0 && j / c >= 0; } }, - ID: function(a, b) { + ID: function (a, b) { return a.nodeType === 1 && a.getAttribute("id") === b; }, - TAG: function(a, b) { + TAG: function (a, b) { return ( (b === "*" && a.nodeType === 1) || (!!a.nodeName && a.nodeName.toLowerCase() === b) ); }, - CLASS: function(a, b) { + CLASS: function (a, b) { return ( (" " + (a.className || a.getAttribute("class")) + " ").indexOf( b ) > -1 ); }, - ATTR: function(a, b) { + ATTR: function (a, b) { var c = b[1], d = m.attr ? m.attr(a, c) : o.attrHandle[c] - ? o.attrHandle[c](a) - : a[c] != null - ? a[c] - : a.getAttribute(c), + ? o.attrHandle[c](a) + : a[c] != null + ? a[c] + : a.getAttribute(c), e = d + "", f = b[2], g = b[4]; return d == null ? f === "!=" : !f && m.attr - ? d != null - : f === "=" - ? e === g - : f === "*=" - ? e.indexOf(g) >= 0 - : f === "~=" - ? (" " + e + " ").indexOf(g) >= 0 - : g - ? f === "!=" - ? e !== g - : f === "^=" - ? e.indexOf(g) === 0 - : f === "$=" - ? e.substr(e.length - g.length) === g - : f === "|=" - ? e === g || e.substr(0, g.length + 1) === g + "-" - : !1 - : e && d !== !1; + ? d != null + : f === "=" + ? e === g + : f === "*=" + ? e.indexOf(g) >= 0 + : f === "~=" + ? (" " + e + " ").indexOf(g) >= 0 + : g + ? f === "!=" + ? e !== g + : f === "^=" + ? e.indexOf(g) === 0 + : f === "$=" + ? e.substr(e.length - g.length) === g + : f === "|=" + ? e === g || + e.substr(0, g.length + 1) === g + "-" + : !1 + : e && d !== !1; }, - POS: function(a, b, c, d) { + POS: function (a, b, c, d) { var e = b[2], f = o.setFilters[e]; if (f) return f(a, c, b, d); @@ -3137,17 +3151,17 @@ } }), p = o.match.POS, - q = function(a, b) { + q = function (a, b) { return "\\" + (b - 0 + 1); }; for (var r in o.match) - (o.match[r] = new RegExp( + ((o.match[r] = new RegExp( o.match[r].source + /(?![^\[]*\])(?![^\(]*\))/.source )), (o.leftMatch[r] = new RegExp( /(^(?:.|\r|\n)*?)/.source + o.match[r].source.replace(/\\(\d+)/g, q) - )); - var s = function(a, b) { + ))); + var s = function (a, b) { a = Array.prototype.slice.call(a, 0); if (b) { b.push.apply(b, a); @@ -3158,7 +3172,7 @@ try { Array.prototype.slice.call(c.documentElement.childNodes, 0)[0].nodeType; } catch (t) { - s = function(a, b) { + s = function (a, b) { var c = 0, d = b || []; if (g.call(a) === "[object Array]") Array.prototype.push.apply(d, a); @@ -3169,8 +3183,8 @@ }; } var u, v; - c.documentElement.compareDocumentPosition - ? (u = function(a, b) { + (c.documentElement.compareDocumentPosition + ? (u = function (a, b) { if (a === b) { h = !0; return 0; @@ -3179,7 +3193,7 @@ return a.compareDocumentPosition ? -1 : 1; return a.compareDocumentPosition(b) & 4 ? -1 : 1; }) - : ((u = function(a, b) { + : ((u = function (a, b) { if (a === b) { h = !0; return 0; @@ -3196,15 +3210,15 @@ if (g === i) return v(a, b); if (!g) return -1; if (!i) return 1; - while (j) e.unshift(j), (j = j.parentNode); + while (j) (e.unshift(j), (j = j.parentNode)); j = i; - while (j) f.unshift(j), (j = j.parentNode); - (c = e.length), (d = f.length); + while (j) (f.unshift(j), (j = j.parentNode)); + ((c = e.length), (d = f.length)); for (var k = 0; k < c && k < d; k++) if (e[k] !== f[k]) return v(e[k], f[k]); return k === c ? v(a, f[k], -1) : v(e[k], b, 1); }), - (v = function(a, b, c) { + (v = function (a, b, c) { if (a === b) return c; var d = a.nextSibling; while (d) { @@ -3213,14 +3227,14 @@ } return 1; })), - (function() { + (function () { var a = c.createElement("div"), d = "script" + new Date().getTime(), e = c.documentElement; - (a.innerHTML = ""), + ((a.innerHTML = ""), e.insertBefore(a, e.firstChild), c.getElementById(d) && - ((o.find.ID = function(a, c, d) { + ((o.find.ID = function (a, c, d) { if (typeof c.getElementById != "undefined" && !d) { var e = c.getElementById(a[1]); return e @@ -3232,20 +3246,20 @@ : []; } }), - (o.filter.ID = function(a, b) { + (o.filter.ID = function (a, b) { var c = typeof a.getAttributeNode != "undefined" && a.getAttributeNode("id"); return a.nodeType === 1 && c && c.nodeValue === b; })), e.removeChild(a), - (e = a = null); + (e = a = null)); })(), - (function() { + (function () { var a = c.createElement("div"); - a.appendChild(c.createComment("")), + (a.appendChild(c.createComment("")), a.getElementsByTagName("*").length > 0 && - (o.find.TAG = function(a, b) { + (o.find.TAG = function (a, b) { var c = b.getElementsByTagName(a[1]); if (a[1] === "*") { var d = []; @@ -3259,13 +3273,13 @@ a.firstChild && typeof a.firstChild.getAttribute != "undefined" && a.firstChild.getAttribute("href") !== "#" && - (o.attrHandle.href = function(a) { + (o.attrHandle.href = function (a) { return a.getAttribute("href", 2); }), - (a = null); + (a = null)); })(), c.querySelectorAll && - (function() { + (function () { var a = m, b = c.createElement("div"), d = "__sizzle__"; @@ -3274,7 +3288,7 @@ !b.querySelectorAll || b.querySelectorAll(".TEST").length !== 0 ) { - m = function(b, e, f, g) { + m = function (b, e, f, g) { e = e || c; if (!g && !m.isXML(e)) { var h = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b); @@ -3302,8 +3316,10 @@ n = l || d, p = e.parentNode, q = /^\s*[+~]/.test(b); - l ? (n = n.replace(/'/g, "\\$&")) : e.setAttribute("id", n), - q && p && (e = e.parentNode); + (l + ? (n = n.replace(/'/g, "\\$&")) + : e.setAttribute("id", n), + q && p && (e = e.parentNode)); try { if (!q || p) return s( @@ -3322,7 +3338,7 @@ b = null; } })(), - (function() { + (function () { var a = c.documentElement, b = a.matchesSelector || @@ -3337,7 +3353,7 @@ } catch (f) { e = !0; } - m.matchesSelector = function(a, c) { + m.matchesSelector = function (a, c) { c = c.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); if (!m.isXML(a)) try { @@ -3351,7 +3367,7 @@ }; } })(), - (function() { + (function () { var a = c.createElement("div"); a.innerHTML = "
"; if ( @@ -3360,41 +3376,41 @@ ) { a.lastChild.className = "e"; if (a.getElementsByClassName("e").length === 1) return; - o.order.splice(1, 0, "CLASS"), - (o.find.CLASS = function(a, b, c) { + (o.order.splice(1, 0, "CLASS"), + (o.find.CLASS = function (a, b, c) { if (typeof b.getElementsByClassName != "undefined" && !c) return b.getElementsByClassName(a[1]); }), - (a = null); + (a = null)); } })(), c.documentElement.contains - ? (m.contains = function(a, b) { + ? (m.contains = function (a, b) { return a !== b && (a.contains ? a.contains(b) : !0); }) : c.documentElement.compareDocumentPosition - ? (m.contains = function(a, b) { - return !!(a.compareDocumentPosition(b) & 16); - }) - : (m.contains = function() { - return !1; - }), - (m.isXML = function(a) { + ? (m.contains = function (a, b) { + return !!(a.compareDocumentPosition(b) & 16); + }) + : (m.contains = function () { + return !1; + }), + (m.isXML = function (a) { var b = (a ? a.ownerDocument || a : 0).documentElement; return b ? b.nodeName !== "HTML" : !1; - }); - var y = function(a, b, c) { + })); + var y = function (a, b, c) { var d, e = [], f = "", g = b.nodeType ? [b] : b; while ((d = o.match.PSEUDO.exec(a))) - (f += d[0]), (a = a.replace(o.match.PSEUDO, "")); + ((f += d[0]), (a = a.replace(o.match.PSEUDO, ""))); a = o.relative[a] ? a + "*" : a; for (var h = 0, i = g.length; h < i; h++) m(a, g[h], e, c); return m.filter(f, e); }; - (m.attr = f.attr), + ((m.attr = f.attr), (m.selectors.attrMap = {}), (f.find = m), (f.expr = m.selectors), @@ -3402,8 +3418,8 @@ (f.unique = m.uniqueSort), (f.text = m.getText), (f.isXMLDoc = m.isXML), - (f.contains = m.contains); - })(); + (f.contains = m.contains)); + })()); var L = /Until$/, M = /^(?:parents|prevUntil|prevAll)/, N = /,/, @@ -3411,13 +3427,13 @@ P = Array.prototype.slice, Q = f.expr.match.POS, R = { children: !0, contents: !0, next: !0, prev: !0 }; - f.fn.extend({ - find: function(a) { + (f.fn.extend({ + find: function (a) { var b = this, c, d; if (typeof a != "string") - return f(a).filter(function() { + return f(a).filter(function () { for (c = 0, d = b.length; c < d; c++) if (f.contains(b[c], this)) return !0; }); @@ -3426,7 +3442,7 @@ h, i; for (c = 0, d = this.length; c < d; c++) { - (g = e.length), f.find(a, this[c], e); + ((g = e.length), f.find(a, this[c], e)); if (c > 0) for (h = g; h < e.length; h++) for (i = 0; i < g; i++) @@ -3437,20 +3453,20 @@ } return e; }, - has: function(a) { + has: function (a) { var b = f(a); - return this.filter(function() { + return this.filter(function () { for (var a = 0, c = b.length; a < c; a++) if (f.contains(this, b[a])) return !0; }); }, - not: function(a) { + not: function (a) { return this.pushStack(T(this, a, !1), "not", a); }, - filter: function(a) { + filter: function (a) { return this.pushStack(T(this, a, !0), "filter", a); }, - is: function(a) { + is: function (a) { return ( !!a && (typeof a == "string" @@ -3460,7 +3476,7 @@ : this.filter(a).length > 0) ); }, - closest: function(a, b) { + closest: function (a, b) { var c = [], d, e, @@ -3470,7 +3486,7 @@ while (g && g.ownerDocument && g !== b) { for (d = 0; d < a.length; d++) f(g).is(a[d]) && c.push({ selector: a[d], elem: g, level: h }); - (g = g.parentNode), h++; + ((g = g.parentNode), h++); } return c; } @@ -3489,12 +3505,12 @@ c = c.length > 1 ? f.unique(c) : c; return this.pushStack(c, "closest", a); }, - index: function(a) { + index: function (a) { if (!a) return this[0] && this[0].parentNode ? this.prevAll().length : -1; if (typeof a == "string") return f.inArray(this[0], f(a)); return f.inArray(a.jquery ? a[0] : a, this); }, - add: function(a, b) { + add: function (a, b) { var c = typeof a == "string" ? f(a, b) @@ -3502,65 +3518,65 @@ d = f.merge(this.get(), c); return this.pushStack(S(c[0]) || S(d[0]) ? d : f.unique(d)); }, - andSelf: function() { + andSelf: function () { return this.add(this.prevObject); } }), f.each( { - parent: function(a) { + parent: function (a) { var b = a.parentNode; return b && b.nodeType !== 11 ? b : null; }, - parents: function(a) { + parents: function (a) { return f.dir(a, "parentNode"); }, - parentsUntil: function(a, b, c) { + parentsUntil: function (a, b, c) { return f.dir(a, "parentNode", c); }, - next: function(a) { + next: function (a) { return f.nth(a, 2, "nextSibling"); }, - prev: function(a) { + prev: function (a) { return f.nth(a, 2, "previousSibling"); }, - nextAll: function(a) { + nextAll: function (a) { return f.dir(a, "nextSibling"); }, - prevAll: function(a) { + prevAll: function (a) { return f.dir(a, "previousSibling"); }, - nextUntil: function(a, b, c) { + nextUntil: function (a, b, c) { return f.dir(a, "nextSibling", c); }, - prevUntil: function(a, b, c) { + prevUntil: function (a, b, c) { return f.dir(a, "previousSibling", c); }, - siblings: function(a) { + siblings: function (a) { return f.sibling(a.parentNode.firstChild, a); }, - children: function(a) { + children: function (a) { return f.sibling(a.firstChild); }, - contents: function(a) { + contents: function (a) { return f.nodeName(a, "iframe") ? a.contentDocument || a.contentWindow.document : f.makeArray(a.childNodes); } }, - function(a, b) { - f.fn[a] = function(c, d) { + function (a, b) { + f.fn[a] = function (c, d) { var e = f.map(this, b, c); - L.test(a) || (d = c), + (L.test(a) || (d = c), d && typeof d == "string" && (e = f.filter(d, e)), (e = this.length > 1 && !R[a] ? f.unique(e) : e), - (this.length > 1 || N.test(d)) && M.test(a) && (e = e.reverse()); + (this.length > 1 || N.test(d)) && M.test(a) && (e = e.reverse())); return this.pushStack(e, a, P.call(arguments).join(",")); }; } ), f.extend({ - filter: function(a, b, c) { + filter: function (a, b, c) { c && (a = ":not(" + a + ")"); return b.length === 1 ? f.find.matchesSelector(b[0], a) @@ -3568,7 +3584,7 @@ : [] : f.find.matches(a, b); }, - dir: function(a, c, d) { + dir: function (a, c, d) { var e = [], g = a[c]; while ( @@ -3576,26 +3592,27 @@ g.nodeType !== 9 && (d === b || g.nodeType !== 1 || !f(g).is(d)) ) - g.nodeType === 1 && e.push(g), (g = g[c]); + (g.nodeType === 1 && e.push(g), (g = g[c])); return e; }, - nth: function(a, b, c, d) { + nth: function (a, b, c, d) { b = b || 1; var e = 0; for (; a; a = a[c]) if (a.nodeType === 1 && ++e === b) break; return a; }, - sibling: function(a, b) { + sibling: function (a, b) { var c = []; for (; a; a = a.nextSibling) a.nodeType === 1 && a !== b && c.push(a); return c; } - }); + })); var V = "abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", W = / jQuery\d+="(?:\d+|null)"/g, X = /^\s+/, - Y = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, + Y = + /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, Z = /<([\w:]+)/, $ = /", "
"]), f.fn.extend({ - text: function(a) { + text: function (a) { if (f.isFunction(a)) - return this.each(function(b) { + return this.each(function (b) { var c = f(this); c.text(a.call(this, b, c.text())); }); @@ -3633,64 +3650,62 @@ ); return f.text(this); }, - wrapAll: function(a) { + wrapAll: function (a) { if (f.isFunction(a)) - return this.each(function(b) { + return this.each(function (b) { f(this).wrapAll(a.call(this, b)); }); if (this[0]) { - var b = f(a, this[0].ownerDocument) - .eq(0) - .clone(!0); - this[0].parentNode && b.insertBefore(this[0]), + var b = f(a, this[0].ownerDocument).eq(0).clone(!0); + (this[0].parentNode && b.insertBefore(this[0]), b - .map(function() { + .map(function () { var a = this; while (a.firstChild && a.firstChild.nodeType === 1) a = a.firstChild; return a; }) - .append(this); + .append(this)); } return this; }, - wrapInner: function(a) { + wrapInner: function (a) { if (f.isFunction(a)) - return this.each(function(b) { + return this.each(function (b) { f(this).wrapInner(a.call(this, b)); }); - return this.each(function() { + return this.each(function () { var b = f(this), c = b.contents(); c.length ? c.wrapAll(a) : b.append(a); }); }, - wrap: function(a) { + wrap: function (a) { var b = f.isFunction(a); - return this.each(function(c) { + return this.each(function (c) { f(this).wrapAll(b ? a.call(this, c) : a); }); }, - unwrap: function() { + unwrap: function () { return this.parent() - .each(function() { + .each(function () { f.nodeName(this, "body") || f(this).replaceWith(this.childNodes); }) .end(); }, - append: function() { - return this.domManip(arguments, !0, function(a) { + append: function () { + return this.domManip(arguments, !0, function (a) { this.nodeType === 1 && this.appendChild(a); }); }, - prepend: function() { - return this.domManip(arguments, !0, function(a) { + prepend: function () { + return this.domManip(arguments, !0, function (a) { this.nodeType === 1 && this.insertBefore(a, this.firstChild); }); }, - before: function() { + before: function () { if (this[0] && this[0].parentNode) - return this.domManip(arguments, !1, function(a) { + return this.domManip(arguments, !1, function (a) { this.parentNode.insertBefore(a, this); }); if (arguments.length) { @@ -3699,9 +3714,9 @@ return this.pushStack(a, "before", arguments); } }, - after: function() { + after: function () { if (this[0] && this[0].parentNode) - return this.domManip(arguments, !1, function(a) { + return this.domManip(arguments, !1, function (a) { this.parentNode.insertBefore(a, this.nextSibling); }); if (arguments.length) { @@ -3710,29 +3725,29 @@ return a; } }, - remove: function(a, b) { + remove: function (a, b) { for (var c = 0, d; (d = this[c]) != null; c++) if (!a || f.filter(a, [d]).length) - !b && + (!b && d.nodeType === 1 && (f.cleanData(d.getElementsByTagName("*")), f.cleanData([d])), - d.parentNode && d.parentNode.removeChild(d); + d.parentNode && d.parentNode.removeChild(d)); return this; }, - empty: function() { + empty: function () { for (var a = 0, b; (b = this[a]) != null; a++) { b.nodeType === 1 && f.cleanData(b.getElementsByTagName("*")); while (b.firstChild) b.removeChild(b.firstChild); } return this; }, - clone: function(a, b) { - (a = a == null ? !1 : a), (b = b == null ? a : b); - return this.map(function() { + clone: function (a, b) { + ((a = a == null ? !1 : a), (b = b == null ? a : b)); + return this.map(function () { return f.clone(this, a, b); }); }, - html: function(a) { + html: function (a) { if (a === b) return this[0] && this[0].nodeType === 1 ? this[0].innerHTML.replace(W, "") @@ -3754,36 +3769,36 @@ } } else f.isFunction(a) - ? this.each(function(b) { + ? this.each(function (b) { var c = f(this); c.html(a.call(this, b, c.html())); }) : this.empty().append(a); return this; }, - replaceWith: function(a) { + replaceWith: function (a) { if (this[0] && this[0].parentNode) { if (f.isFunction(a)) - return this.each(function(b) { + return this.each(function (b) { var c = f(this), d = c.html(); c.replaceWith(a.call(this, b, d)); }); typeof a != "string" && (a = f(a).detach()); - return this.each(function() { + return this.each(function () { var b = this.nextSibling, c = this.parentNode; - f(this).remove(), b ? f(b).before(a) : f(c).append(a); + (f(this).remove(), b ? f(b).before(a) : f(c).append(a)); }); } return this.length ? this.pushStack(f(f.isFunction(a) ? a() : a), "replaceWith", a) : this; }, - detach: function(a) { + detach: function (a) { return this.remove(a, !0); }, - domManip: function(a, c, d) { + domManip: function (a, c, d) { var e, g, h, @@ -3796,16 +3811,16 @@ typeof j == "string" && bd.test(j) ) - return this.each(function() { + return this.each(function () { f(this).domManip(a, c, d, !0); }); if (f.isFunction(j)) - return this.each(function(e) { + return this.each(function (e) { var g = f(this); - (a[0] = j.call(this, e, c ? g.html() : b)), g.domManip(a, c, d); + ((a[0] = j.call(this, e, c ? g.html() : b)), g.domManip(a, c, d)); }); if (this[0]) { - (i = j && j.parentNode), + ((i = j && j.parentNode), f.support.parentNode && i && i.nodeType === 11 && @@ -3815,7 +3830,7 @@ (h = e.fragment), h.childNodes.length === 1 ? (g = h = h.firstChild) - : (g = h.firstChild); + : (g = h.firstChild)); if (g) { c = c && f.nodeName(g, "tr"); for (var l = 0, m = this.length, n = m - 1; l < m; l++) @@ -3829,13 +3844,13 @@ return this; } }), - (f.buildFragment = function(a, b, d) { + (f.buildFragment = function (a, b, d) { var e, g, h, i, j = a[0]; - b && b[0] && (i = b[0].ownerDocument || b[0]), + (b && b[0] && (i = b[0].ownerDocument || b[0]), i.createDocumentFragment || (i = c), a.length === 1 && typeof j == "string" && @@ -3847,7 +3862,7 @@ (f.support.html5Clone || !bc.test(j)) && ((g = !0), (h = f.fragments[j]), h && h !== 1 && (e = h)), e || ((e = i.createDocumentFragment()), f.clean(a, i, e, d)), - g && (f.fragments[j] = h ? e : 1); + g && (f.fragments[j] = h ? e : 1)); return { fragment: e, cacheable: g }; }), (f.fragments = {}), @@ -3859,8 +3874,8 @@ insertAfter: "after", replaceAll: "replaceWith" }, - function(a, b) { - f.fn[a] = function(c) { + function (a, b) { + f.fn[a] = function (c) { var d = [], e = f(c), g = this.length === 1 && this[0].parentNode; @@ -3875,14 +3890,14 @@ } for (var h = 0, i = e.length; h < i; h++) { var j = (h > 0 ? this.clone(!0) : this).get(); - f(e[h])[b](j), (d = d.concat(j)); + (f(e[h])[b](j), (d = d.concat(j))); } return this.pushStack(d, a, e.selector); }; } ), f.extend({ - clone: function(a, b, c) { + clone: function (a, b, c) { var d, e, g, @@ -3895,24 +3910,24 @@ (a.nodeType === 1 || a.nodeType === 11) && !f.isXMLDoc(a) ) { - bk(a, h), (d = bl(a)), (e = bl(h)); + (bk(a, h), (d = bl(a)), (e = bl(h))); for (g = 0; d[g]; ++g) e[g] && bk(d[g], e[g]); } if (b) { bj(a, h); if (c) { - (d = bl(a)), (e = bl(h)); + ((d = bl(a)), (e = bl(h))); for (g = 0; d[g]; ++g) bj(d[g], e[g]); } } d = e = null; return h; }, - clean: function(a, b, d, e) { + clean: function (a, b, d, e) { var g; - (b = b || c), + ((b = b || c), typeof b.createElement == "undefined" && - (b = b.ownerDocument || (b[0] && b[0].ownerDocument) || c); + (b = b.ownerDocument || (b[0] && b[0].ownerDocument) || c)); var h = [], i; for (var j = 0, k; (k = a[j]) != null; j++) { @@ -3926,8 +3941,8 @@ m = bg[l] || bg._default, n = m[0], o = b.createElement("div"); - b === c ? bh.appendChild(o) : U(b).appendChild(o), - (o.innerHTML = m[1] + k + m[2]); + (b === c ? bh.appendChild(o) : U(b).appendChild(o), + (o.innerHTML = m[1] + k + m[2])); while (n--) o = o.lastChild; if (!f.support.tbody) { var p = $.test(k), @@ -3935,17 +3950,17 @@ l === "table" && !p ? o.firstChild && o.firstChild.childNodes : m[1] === "" && !p - ? o.childNodes - : []; + ? o.childNodes + : []; for (i = q.length - 1; i >= 0; --i) f.nodeName(q[i], "tbody") && !q[i].childNodes.length && q[i].parentNode.removeChild(q[i]); } - !f.support.leadingWhitespace && + (!f.support.leadingWhitespace && X.test(k) && o.insertBefore(b.createTextNode(X.exec(k)[0]), o.firstChild), - (k = o.childNodes); + (k = o.childNodes)); } var r; if (!f.support.appendChecked) @@ -3955,7 +3970,7 @@ k.nodeType ? h.push(k) : (h = f.merge(h, k)); } if (d) { - g = function(a) { + g = function (a) { return !a.type || be.test(a.type); }; for (j = 0; h[j]; j++) @@ -3977,7 +3992,7 @@ } return h; }, - cleanData: function(a) { + cleanData: function (a) { var b, c, d = f.cache, @@ -3993,14 +4008,14 @@ e[j] ? f.event.remove(i, j) : f.removeEvent(i, j, b.handle); b.handle && (b.handle.elem = null); } - g + (g ? delete i[f.expando] : i.removeAttribute && i.removeAttribute(f.expando), - delete d[c]; + delete d[c]); } } } - }); + })); var bq = /alpha\([^)]*\)/i, br = /opacity=([^)]*)/, bs = /([A-Z]|^ms)/g, @@ -4013,16 +4028,16 @@ bz, bA, bB; - (f.fn.css = function(a, c) { + ((f.fn.css = function (a, c) { if (arguments.length === 2 && c === b) return this; - return f.access(this, a, c, !0, function(a, c, d) { + return f.access(this, a, c, !0, function (a, c, d) { return d !== b ? f.style(a, c, d) : f.css(a, c); }); }), f.extend({ cssHooks: { opacity: { - get: function(a, b) { + get: function (a, b) { if (b) { var c = bz(a, "opacity", "opacity"); return c === "" ? "1" : c; @@ -4042,7 +4057,7 @@ zoom: !0 }, cssProps: { float: f.support.cssFloat ? "cssFloat" : "styleFloat" }, - style: function(a, c, d, e) { + style: function (a, c, d, e) { if (!!a && a.nodeType !== 3 && a.nodeType !== 8 && !!a.style) { var g, h, @@ -4054,11 +4069,11 @@ if (k && "get" in k && (g = k.get(a, !1, e)) !== b) return g; return j[c]; } - (h = typeof d), + ((h = typeof d), h === "string" && (g = bv.exec(d)) && ((d = +(g[1] + 1) * +g[2] + parseFloat(f.css(a, c))), - (h = "number")); + (h = "number"))); if (d == null || (h === "number" && isNaN(d))) return; h === "number" && !f.cssNumber[i] && (d += "px"); if (!k || !("set" in k) || (d = k.set(a, d)) !== b) @@ -4067,36 +4082,36 @@ } catch (l) {} } }, - css: function(a, c, d) { + css: function (a, c, d) { var e, g; - (c = f.camelCase(c)), + ((c = f.camelCase(c)), (g = f.cssHooks[c]), (c = f.cssProps[c] || c), - c === "cssFloat" && (c = "float"); + c === "cssFloat" && (c = "float")); if (g && "get" in g && (e = g.get(a, !0, d)) !== b) return e; if (bz) return bz(a, c); }, - swap: function(a, b, c) { + swap: function (a, b, c) { var d = {}; - for (var e in b) (d[e] = a.style[e]), (a.style[e] = b[e]); + for (var e in b) ((d[e] = a.style[e]), (a.style[e] = b[e])); c.call(a); for (e in b) a.style[e] = d[e]; } }), (f.curCSS = f.css), - f.each(["height", "width"], function(a, b) { + f.each(["height", "width"], function (a, b) { f.cssHooks[b] = { - get: function(a, c, d) { + get: function (a, c, d) { var e; if (c) { if (a.offsetWidth !== 0) return bC(a, b, d); - f.swap(a, bw, function() { + f.swap(a, bw, function () { e = bC(a, b, d); }); return e; } }, - set: function(a, b) { + set: function (a, b) { if (!bt.test(b)) return b; b = parseFloat(b); if (b >= 0) return b + "px"; @@ -4105,16 +4120,16 @@ }), f.support.opacity || (f.cssHooks.opacity = { - get: function(a, b) { + get: function (a, b) { return br.test( (b && a.currentStyle ? a.currentStyle.filter : a.style.filter) || "" ) ? parseFloat(RegExp.$1) / 100 + "" : b - ? "1" - : ""; + ? "1" + : ""; }, - set: function(a, b) { + set: function (a, b) { var c = a.style, d = a.currentStyle, e = f.isNumeric(b) ? "alpha(opacity=" + b * 100 + ")" : "", @@ -4127,12 +4142,12 @@ c.filter = bq.test(g) ? g.replace(bq, e) : g + " " + e; } }), - f(function() { + f(function () { f.support.reliableMarginRight || (f.cssHooks.marginRight = { - get: function(a, b) { + get: function (a, b) { var c; - f.swap(a, { display: "inline-block" }, function() { + f.swap(a, { display: "inline-block" }, function () { b ? (c = bz(a, "margin-right", "marginRight")) : (c = a.style.marginRight); @@ -4143,25 +4158,25 @@ }), c.defaultView && c.defaultView.getComputedStyle && - (bA = function(a, b) { + (bA = function (a, b) { var c, d, e; - (b = b.replace(bs, "-$1").toLowerCase()), + ((b = b.replace(bs, "-$1").toLowerCase()), (d = a.ownerDocument.defaultView) && (e = d.getComputedStyle(a, null)) && ((c = e.getPropertyValue(b)), c === "" && !f.contains(a.ownerDocument.documentElement, a) && - (c = f.style(a, b))); + (c = f.style(a, b)))); return c; }), c.documentElement.currentStyle && - (bB = function(a, b) { + (bB = function (a, b) { var c, d, e, f = a.currentStyle && a.currentStyle[b], g = a.style; - f === null && g && (e = g[b]) && (f = e), + (f === null && g && (e = g[b]) && (f = e), !bt.test(f) && bu.test(f) && ((c = g.left), @@ -4170,13 +4185,13 @@ (g.left = b === "fontSize" ? "1em" : f || 0), (f = g.pixelLeft + "px"), (g.left = c), - d && (a.runtimeStyle.left = d)); + d && (a.runtimeStyle.left = d))); return f === "" ? "auto" : f; }), (bz = bA || bB), f.expr && f.expr.filters && - ((f.expr.filters.hidden = function(a) { + ((f.expr.filters.hidden = function (a) { var b = a.offsetWidth, c = a.offsetHeight; return ( @@ -4185,15 +4200,16 @@ ((a.style && a.style.display) || f.css(a, "display")) === "none") ); }), - (f.expr.filters.visible = function(a) { + (f.expr.filters.visible = function (a) { return !f.expr.filters.hidden(a); - })); + }))); var bD = /%20/g, bE = /\[\]$/, bF = /\r?\n/g, bG = /#.*$/, bH = /^(.*?):[ \t]*([^\r\n]*)\r?$/gm, - bI = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i, + bI = + /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i, bJ = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/, bK = /^(?:GET|HEAD)$/, bL = /^\/\//, @@ -4212,11 +4228,11 @@ try { bV = e.href; } catch (bY) { - (bV = c.createElement("a")), (bV.href = ""), (bV = bV.href); + ((bV = c.createElement("a")), (bV.href = ""), (bV = bV.href)); } - (bW = bR.exec(bV.toLowerCase()) || []), + ((bW = bR.exec(bV.toLowerCase()) || []), f.fn.extend({ - load: function(a, c, d) { + load: function (a, c, d) { if (typeof a != "string" && bS) return bS.apply(this, arguments); if (!this.length) return this; var e = a.indexOf(" "); @@ -4236,47 +4252,41 @@ type: h, dataType: "html", data: c, - complete: function(a, b, c) { - (c = a.responseText), + complete: function (a, b, c) { + ((c = a.responseText), a.isResolved() && - (a.done(function(a) { + (a.done(function (a) { c = a; }), - i.html( - g - ? f("
") - .append(c.replace(bN, "")) - .find(g) - : c - )), - d && i.each(d, [c, b, a]); + i.html(g ? f("
").append(c.replace(bN, "")).find(g) : c)), + d && i.each(d, [c, b, a])); } }); return this; }, - serialize: function() { + serialize: function () { return f.param(this.serializeArray()); }, - serializeArray: function() { - return this.map(function() { + serializeArray: function () { + return this.map(function () { return this.elements ? f.makeArray(this.elements) : this; }) - .filter(function() { + .filter(function () { return ( this.name && !this.disabled && (this.checked || bO.test(this.nodeName) || bI.test(this.type)) ); }) - .map(function(a, b) { + .map(function (a, b) { var c = f(this).val(); return c == null ? null : f.isArray(c) - ? f.map(c, function(a, c) { - return { name: b.name, value: a.replace(bF, "\r\n") }; - }) - : { name: b.name, value: c.replace(bF, "\r\n") }; + ? f.map(c, function (a, c) { + return { name: b.name, value: a.replace(bF, "\r\n") }; + }) + : { name: b.name, value: c.replace(bF, "\r\n") }; }) .get(); } @@ -4285,27 +4295,27 @@ "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), - function(a, b) { - f.fn[b] = function(a) { + function (a, b) { + f.fn[b] = function (a) { return this.on(b, a); }; } ), - f.each(["get", "post"], function(a, c) { - f[c] = function(a, d, e, g) { + f.each(["get", "post"], function (a, c) { + f[c] = function (a, d, e, g) { f.isFunction(d) && ((g = g || e), (e = d), (d = b)); return f.ajax({ type: c, url: a, data: d, success: e, dataType: g }); }; }), f.extend({ - getScript: function(a, c) { + getScript: function (a, c) { return f.get(a, b, c, "script"); }, - getJSON: function(a, b, c) { + getJSON: function (a, b, c) { return f.get(a, b, c, "json"); }, - ajaxSetup: function(a, b) { - b ? b_(a, f.ajaxSettings) : ((b = a), (a = f.ajaxSettings)), b_(a, b); + ajaxSetup: function (a, b) { + (b ? b_(a, f.ajaxSettings) : ((b = a), (a = f.ajaxSettings)), b_(a, b)); return a; }, ajaxSettings: { @@ -4335,14 +4345,14 @@ }, ajaxPrefilter: bZ(bT), ajaxTransport: bZ(bU), - ajax: function(a, c) { + ajax: function (a, c) { function w(a, c, l, m) { if (s !== 2) { - (s = 2), + ((s = 2), q && clearTimeout(q), (p = b), (n = m || ""), - (v.readyState = a > 0 ? 4 : 0); + (v.readyState = a > 0 ? 4 : 0)); var o, r, u, @@ -4356,18 +4366,18 @@ f.lastModified[k] = y; if ((z = v.getResponseHeader("Etag"))) f.etag[k] = z; } - if (a === 304) (w = "notmodified"), (o = !0); + if (a === 304) ((w = "notmodified"), (o = !0)); else try { - (r = cc(d, x)), (w = "success"), (o = !0); + ((r = cc(d, x)), (w = "success"), (o = !0)); } catch (A) { - (w = "parsererror"), (u = A); + ((w = "parsererror"), (u = A)); } } else { u = w; - if (!w || a) (w = "error"), a < 0 && (a = 0); + if (!w || a) ((w = "error"), a < 0 && (a = 0)); } - (v.status = a), + ((v.status = a), (v.statusText = "" + (c || w)), o ? h.resolveWith(e, [r, w, v]) : h.rejectWith(e, [v, w, u]), v.statusCode(j), @@ -4381,10 +4391,10 @@ i.fireWith(e, [v, w]), t && (g.trigger("ajaxComplete", [v, d]), - --f.active || f.event.trigger("ajaxStop")); + --f.active || f.event.trigger("ajaxStop"))); } } - typeof a == "object" && ((c = a), (a = b)), (c = c || {}); + (typeof a == "object" && ((c = a), (a = b)), (c = c || {})); var d = f.ajaxSetup({}, c), e = d.context || d, g = e !== d && (e.nodeType || e instanceof f) ? f(e) : f.event, @@ -4404,17 +4414,17 @@ u, v = { readyState: 0, - setRequestHeader: function(a, b) { + setRequestHeader: function (a, b) { if (!s) { var c = a.toLowerCase(); - (a = m[c] = m[c] || a), (l[a] = b); + ((a = m[c] = m[c] || a), (l[a] = b)); } return this; }, - getAllResponseHeaders: function() { + getAllResponseHeaders: function () { return s === 2 ? n : null; }, - getResponseHeader: function(a) { + getResponseHeader: function (a) { var c; if (s === 2) { if (!o) { @@ -4425,24 +4435,24 @@ } return c === b ? null : c; }, - overrideMimeType: function(a) { + overrideMimeType: function (a) { s || (d.mimeType = a); return this; }, - abort: function(a) { - (a = a || "abort"), p && p.abort(a), w(0, a); + abort: function (a) { + ((a = a || "abort"), p && p.abort(a), w(0, a)); return this; } }; - h.promise(v), + (h.promise(v), (v.success = v.done), (v.error = v.fail), (v.complete = i.add), - (v.statusCode = function(a) { + (v.statusCode = function (a) { if (a) { var b; if (s < 2) for (b in a) j[b] = [j[b], a[b]]; - else (b = a[v.status]), v.then(b, b); + else ((b = a[v.status]), v.then(b, b)); } return this; }), @@ -4466,16 +4476,16 @@ d.processData && typeof d.data != "string" && (d.data = f.param(d.data, d.traditional)), - b$(bT, d, c, v); + b$(bT, d, c, v)); if (s === 2) return !1; - (t = d.global), + ((t = d.global), (d.type = d.type.toUpperCase()), (d.hasContent = !bK.test(d.type)), - t && f.active++ === 0 && f.event.trigger("ajaxStart"); + t && f.active++ === 0 && f.event.trigger("ajaxStart")); if (!d.hasContent) { - d.data && + (d.data && ((d.url += (bM.test(d.url) ? "&" : "?") + d.data), delete d.data), - (k = d.url); + (k = d.url)); if (d.cache === !1) { var x = f.now(), y = d.url.replace(bQ, "$1_=" + x); @@ -4483,7 +4493,7 @@ y + (y === d.url ? (bM.test(d.url) ? "&" : "?") + "_=" + x : ""); } } - ((d.data && d.hasContent && d.contentType !== !1) || c.contentType) && + (((d.data && d.hasContent && d.contentType !== !1) || c.contentType) && v.setRequestHeader("Content-Type", d.contentType), d.ifModified && ((k = k || d.url), @@ -4496,7 +4506,7 @@ ? d.accepts[d.dataTypes[0]] + (d.dataTypes[0] !== "*" ? ", " + bX + "; q=0.01" : "") : d.accepts["*"] - ); + )); for (u in d.headers) v.setRequestHeader(u, d.headers[u]); if (d.beforeSend && (d.beforeSend.call(e, v, d) === !1 || s === 2)) { v.abort(); @@ -4506,15 +4516,15 @@ p = b$(bU, d, c, v); if (!p) w(-1, "No Transport"); else { - (v.readyState = 1), + ((v.readyState = 1), t && g.trigger("ajaxSend", [v, d]), d.async && d.timeout > 0 && - (q = setTimeout(function() { + (q = setTimeout(function () { v.abort("timeout"); - }, d.timeout)); + }, d.timeout))); try { - (s = 1), p.send(l, w); + ((s = 1), p.send(l, w)); } catch (z) { if (s < 2) w(-1, z); else throw z; @@ -4522,32 +4532,32 @@ } return v; }, - param: function(a, c) { + param: function (a, c) { var d = [], - e = function(a, b) { - (b = f.isFunction(b) ? b() : b), + e = function (a, b) { + ((b = f.isFunction(b) ? b() : b), (d[d.length] = - encodeURIComponent(a) + "=" + encodeURIComponent(b)); + encodeURIComponent(a) + "=" + encodeURIComponent(b))); }; c === b && (c = f.ajaxSettings.traditional); if (f.isArray(a) || (a.jquery && !f.isPlainObject(a))) - f.each(a, function() { + f.each(a, function () { e(this.name, this.value); }); else for (var g in a) ca(g, a[g], c, e); return d.join("&").replace(bD, "+"); } }), - f.extend({ active: 0, lastModified: {}, etag: {} }); + f.extend({ active: 0, lastModified: {}, etag: {} })); var cd = f.now(), ce = /(\=)\?(&|$)|\?\?/i; - f.ajaxSetup({ + (f.ajaxSetup({ jsonp: "callback", - jsonpCallback: function() { + jsonpCallback: function () { return f.expando + "_" + cd++; } }), - f.ajaxPrefilter("json jsonp", function(b, c, d) { + f.ajaxPrefilter("json jsonp", function (b, c, d) { var e = b.contentType === "application/x-www-form-urlencoded" && typeof b.data == "string"; @@ -4563,7 +4573,7 @@ j = b.url, k = b.data, l = "$1" + h + "$2"; - b.jsonp !== !1 && + (b.jsonp !== !1 && ((j = j.replace(ce, l)), b.url === j && (e && (k = k.replace(ce, l)), @@ -4571,17 +4581,17 @@ (j += (/\?/.test(j) ? "&" : "?") + b.jsonp + "=" + h))), (b.url = j), (b.data = k), - (a[h] = function(a) { + (a[h] = function (a) { g = [a]; }), - d.always(function() { - (a[h] = i), g && f.isFunction(i) && a[h](g[0]); + d.always(function () { + ((a[h] = i), g && f.isFunction(i) && a[h](g[0])); }), - (b.converters["script json"] = function() { + (b.converters["script json"] = function () { g || f.error(h + " was not called"); return g[0]; }), - (b.dataTypes[0] = "json"); + (b.dataTypes[0] = "json")); return "script"; } }), @@ -4592,62 +4602,67 @@ }, contents: { script: /javascript|ecmascript/ }, converters: { - "text script": function(a) { + "text script": function (a) { f.globalEval(a); return a; } } }), - f.ajaxPrefilter("script", function(a) { - a.cache === b && (a.cache = !1), - a.crossDomain && ((a.type = "GET"), (a.global = !1)); + f.ajaxPrefilter("script", function (a) { + (a.cache === b && (a.cache = !1), + a.crossDomain && ((a.type = "GET"), (a.global = !1))); }), - f.ajaxTransport("script", function(a) { + f.ajaxTransport("script", function (a) { if (a.crossDomain) { var d, e = c.head || c.getElementsByTagName("head")[0] || c.documentElement; return { - send: function(f, g) { - (d = c.createElement("script")), + send: function (f, g) { + ((d = c.createElement("script")), (d.async = "async"), a.scriptCharset && (d.charset = a.scriptCharset), (d.src = a.url), - (d.onload = d.onreadystatechange = function(a, c) { - if (c || !d.readyState || /loaded|complete/.test(d.readyState)) - (d.onload = d.onreadystatechange = null), - e && d.parentNode && e.removeChild(d), - (d = b), - c || g(200, "success"); - }), - e.insertBefore(d, e.firstChild); + (d.onload = d.onreadystatechange = + function (a, c) { + if ( + c || + !d.readyState || + /loaded|complete/.test(d.readyState) + ) + ((d.onload = d.onreadystatechange = null), + e && d.parentNode && e.removeChild(d), + (d = b), + c || g(200, "success")); + }), + e.insertBefore(d, e.firstChild)); }, - abort: function() { + abort: function () { d && d.onload(0, 1); } }; } - }); + })); var cf = a.ActiveXObject - ? function() { + ? function () { for (var a in ch) ch[a](0, 1); } : !1, cg = 0, ch; - (f.ajaxSettings.xhr = a.ActiveXObject - ? function() { + ((f.ajaxSettings.xhr = a.ActiveXObject + ? function () { return (!this.isLocal && ci()) || cj(); } : ci), - (function(a) { + (function (a) { f.extend(f.support, { ajax: !!a, cors: !!a && "withCredentials" in a }); })(f.ajaxSettings.xhr()), f.support.ajax && - f.ajaxTransport(function(c) { + f.ajaxTransport(function (c) { if (!c.crossDomain || f.support.cors) { var d; return { - send: function(e, g) { + send: function (e, g) { var h = c.xhr(), i, j; @@ -4655,31 +4670,32 @@ ? h.open(c.type, c.url, c.async, c.username, c.password) : h.open(c.type, c.url, c.async); if (c.xhrFields) for (j in c.xhrFields) h[j] = c.xhrFields[j]; - c.mimeType && + (c.mimeType && h.overrideMimeType && h.overrideMimeType(c.mimeType), !c.crossDomain && !e["X-Requested-With"] && - (e["X-Requested-With"] = "XMLHttpRequest"); + (e["X-Requested-With"] = "XMLHttpRequest")); try { for (j in e) h.setRequestHeader(j, e[j]); } catch (k) {} - h.send((c.hasContent && c.data) || null), - (d = function(a, e) { + (h.send((c.hasContent && c.data) || null), + (d = function (a, e) { var j, k, l, m, n; try { if (d && (e || h.readyState === 4)) { - (d = b), + ((d = b), i && - ((h.onreadystatechange = f.noop), cf && delete ch[i]); + ((h.onreadystatechange = f.noop), + cf && delete ch[i])); if (e) h.readyState !== 4 && h.abort(); else { - (j = h.status), + ((j = h.status), (l = h.getAllResponseHeaders()), (m = {}), (n = h.responseXML), n && n.documentElement && (m.xml = n), - (m.text = h.responseText); + (m.text = h.responseText)); try { k = h.statusText; } catch (o) { @@ -4699,14 +4715,14 @@ ? d() : ((i = ++cg), cf && (ch || ((ch = {}), f(a).unload(cf)), (ch[i] = d)), - (h.onreadystatechange = d)); + (h.onreadystatechange = d))); }, - abort: function() { + abort: function () { d && d(0, 1); } }; } - }); + })); var ck = {}, cl, cm, @@ -4719,12 +4735,12 @@ ["opacity"] ], cr; - f.fn.extend({ - show: function(a, b, c) { + (f.fn.extend({ + show: function (a, b, c) { var d, e; if (a || a === 0) return this.animate(cu("show", 3), a, b, c); for (var g = 0, h = this.length; g < h; g++) - (d = this[g]), + ((d = this[g]), d.style && ((e = d.style.display), !f._data(d, "olddisplay") && @@ -4732,7 +4748,7 @@ (e = d.style.display = ""), e === "" && f.css(d, "display") === "none" && - f._data(d, "olddisplay", cv(d.nodeName))); + f._data(d, "olddisplay", cv(d.nodeName)))); for (g = 0; g < h; g++) { d = this[g]; if (d.style) { @@ -4743,43 +4759,43 @@ } return this; }, - hide: function(a, b, c) { + hide: function (a, b, c) { if (a || a === 0) return this.animate(cu("hide", 3), a, b, c); var d, e, g = 0, h = this.length; for (; g < h; g++) - (d = this[g]), + ((d = this[g]), d.style && ((e = f.css(d, "display")), e !== "none" && !f._data(d, "olddisplay") && - f._data(d, "olddisplay", e)); + f._data(d, "olddisplay", e))); for (g = 0; g < h; g++) this[g].style && (this[g].style.display = "none"); return this; }, _toggle: f.fn.toggle, - toggle: function(a, b, c) { + toggle: function (a, b, c) { var d = typeof a == "boolean"; f.isFunction(a) && f.isFunction(b) ? this._toggle.apply(this, arguments) : a == null || d - ? this.each(function() { - var b = d ? a : f(this).is(":hidden"); - f(this)[b ? "show" : "hide"](); - }) - : this.animate(cu("toggle", 3), a, b, c); + ? this.each(function () { + var b = d ? a : f(this).is(":hidden"); + f(this)[b ? "show" : "hide"](); + }) + : this.animate(cu("toggle", 3), a, b, c); return this; }, - fadeTo: function(a, b, c, d) { + fadeTo: function (a, b, c, d) { return this.filter(":hidden") .css("opacity", 0) .show() .end() .animate({ opacity: b }, a, c, d); }, - animate: function(a, b, c, d) { + animate: function (a, b, c, d) { function g() { e.queue === !1 && f._mark(this); var b = f.extend({}, e), @@ -4796,7 +4812,7 @@ o; b.animatedProperties = {}; for (i in a) { - (g = f.camelCase(i)), + ((g = f.camelCase(i)), i !== g && ((a[g] = a[i]), delete a[i]), (h = a[g]), f.isArray(h) @@ -4804,7 +4820,7 @@ : (b.animatedProperties[g] = (b.specialEasing && b.specialEasing[g]) || b.easing || - "swing"); + "swing")); if ((h === "hide" && d) || (h === "show" && !d)) return b.complete.call(this); c && @@ -4823,7 +4839,7 @@ } b.overflow != null && (this.style.overflow = "hidden"); for (i in a) - (j = new f.fx(this, b, i)), + ((j = new f.fx(this, b, i)), (h = a[i]), cn.test(h) ? ((o = @@ -4848,7 +4864,7 @@ f.style(this, i, l + n)), k[1] && (m = (k[1] === "-=" ? -1 : 1) * m + l), j.custom(l, m, n)) - : j.custom(l, h, "")); + : j.custom(l, h, ""))); return !0; } var e = f.speed(b, c, d); @@ -4856,13 +4872,13 @@ a = f.extend({}, a); return e.queue === !1 ? this.each(g) : this.queue(e.queue, g); }, - stop: function(a, c, d) { - typeof a != "string" && ((d = c), (c = a), (a = b)), - c && a !== !1 && this.queue(a || "fx", []); - return this.each(function() { + stop: function (a, c, d) { + (typeof a != "string" && ((d = c), (c = a), (a = b)), + c && a !== !1 && this.queue(a || "fx", [])); + return this.each(function () { function h(a, b, c) { var e = b[c]; - f.removeData(a, c, !0), e.stop(d); + (f.removeData(a, c, !0), e.stop(d)); } var b, c = !1, @@ -4876,7 +4892,7 @@ b.indexOf(".run") === b.length - 4 && h(this, g, b); else g[(b = a + ".run")] && g[b].stop && h(this, g, b); - for (b = e.length; b--; ) + for (b = e.length; b--;) e[b].elem === this && (a == null || e[b].queue === a) && (d ? e[b](!0) : e[b].saveState(), (c = !0), e.splice(b, 1)); @@ -4893,14 +4909,14 @@ fadeOut: { opacity: "hide" }, fadeToggle: { opacity: "toggle" } }, - function(a, b) { - f.fn[a] = function(a, c, d) { + function (a, b) { + f.fn[a] = function (a, c, d) { return this.animate(b, a, c, d); }; } ), f.extend({ - speed: function(a, b, c) { + speed: function (a, b, c) { var d = a && typeof a == "object" ? f.extend({}, a) @@ -4912,40 +4928,40 @@ d.duration = f.fx.off ? 0 : typeof d.duration == "number" - ? d.duration - : d.duration in f.fx.speeds - ? f.fx.speeds[d.duration] - : f.fx.speeds._default; + ? d.duration + : d.duration in f.fx.speeds + ? f.fx.speeds[d.duration] + : f.fx.speeds._default; if (d.queue == null || d.queue === !0) d.queue = "fx"; - (d.old = d.complete), - (d.complete = function(a) { - f.isFunction(d.old) && d.old.call(this), - d.queue ? f.dequeue(this, d.queue) : a !== !1 && f._unmark(this); - }); + ((d.old = d.complete), + (d.complete = function (a) { + (f.isFunction(d.old) && d.old.call(this), + d.queue ? f.dequeue(this, d.queue) : a !== !1 && f._unmark(this)); + })); return d; }, easing: { - linear: function(a, b, c, d) { + linear: function (a, b, c, d) { return c + d * a; }, - swing: function(a, b, c, d) { + swing: function (a, b, c, d) { return (-Math.cos(a * Math.PI) / 2 + 0.5) * d + c; } }, timers: [], - fx: function(a, b, c) { - (this.options = b), + fx: function (a, b, c) { + ((this.options = b), (this.elem = a), (this.prop = c), - (b.orig = b.orig || {}); + (b.orig = b.orig || {})); } }), (f.fx.prototype = { - update: function() { - this.options.step && this.options.step.call(this.elem, this.now, this), - (f.fx.step[this.prop] || f.fx.step._default)(this); + update: function () { + (this.options.step && this.options.step.call(this.elem, this.now, this), + (f.fx.step[this.prop] || f.fx.step._default)(this)); }, - cur: function() { + cur: function () { if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) @@ -4955,20 +4971,20 @@ b = f.css(this.elem, this.prop); return isNaN((a = parseFloat(b))) ? (!b || b === "auto" ? 0 : b) : a; }, - custom: function(a, c, d) { + custom: function (a, c, d) { function h(a) { return e.step(a); } var e = this, g = f.fx; - (this.startTime = cr || cs()), + ((this.startTime = cr || cs()), (this.end = c), (this.now = this.start = a), (this.pos = this.state = 0), (this.unit = d || this.unit || (f.cssNumber[this.prop] ? "" : "px")), (h.queue = this.options.queue), (h.elem = this.elem), - (h.saveState = function() { + (h.saveState = function () { e.options.hide && f._data(e.elem, "fxshow" + e.prop) === b && f._data(e.elem, "fxshow" + e.prop, e.start); @@ -4976,11 +4992,11 @@ h() && f.timers.push(h) && !cp && - (cp = setInterval(g.tick, g.interval)); + (cp = setInterval(g.tick, g.interval))); }, - show: function() { + show: function () { var a = f._data(this.elem, "fxshow" + this.prop); - (this.options.orig[this.prop] = a || f.style(this.elem, this.prop)), + ((this.options.orig[this.prop] = a || f.style(this.elem, this.prop)), (this.options.show = !0), a !== b ? this.custom(this.cur(), a) @@ -4988,16 +5004,16 @@ this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur() ), - f(this.elem).show(); + f(this.elem).show()); }, - hide: function() { - (this.options.orig[this.prop] = + hide: function () { + ((this.options.orig[this.prop] = f._data(this.elem, "fxshow" + this.prop) || f.style(this.elem, this.prop)), (this.options.hide = !0), - this.custom(this.cur(), 0); + this.custom(this.cur(), 0)); }, - step: function(a) { + step: function (a) { var b, c, d, @@ -5006,29 +5022,29 @@ h = this.elem, i = this.options; if (a || e >= i.duration + this.startTime) { - (this.now = this.end), + ((this.now = this.end), (this.pos = this.state = 1), this.update(), - (i.animatedProperties[this.prop] = !0); + (i.animatedProperties[this.prop] = !0)); for (b in i.animatedProperties) i.animatedProperties[b] !== !0 && (g = !1); if (g) { - i.overflow != null && + (i.overflow != null && !f.support.shrinkWrapBlocks && - f.each(["", "X", "Y"], function(a, b) { + f.each(["", "X", "Y"], function (a, b) { h.style["overflow" + b] = i.overflow[a]; }), - i.hide && f(h).hide(); + i.hide && f(h).hide()); if (i.hide || i.show) for (b in i.animatedProperties) - f.style(h, b, i.orig[b]), + (f.style(h, b, i.orig[b]), f.removeData(h, "fxshow" + b, !0), - f.removeData(h, "toggle" + b, !0); - (d = i.complete), d && ((i.complete = !1), d.call(h)); + f.removeData(h, "toggle" + b, !0)); + ((d = i.complete), d && ((i.complete = !1), d.call(h))); } return !1; } - i.duration == Infinity + (i.duration == Infinity ? (this.now = e) : ((c = e - this.startTime), (this.state = c / i.duration), @@ -5040,55 +5056,55 @@ i.duration )), (this.now = this.start + (this.end - this.start) * this.pos)), - this.update(); + this.update()); return !0; } }), f.extend(f.fx, { - tick: function() { + tick: function () { var a, b = f.timers, c = 0; for (; c < b.length; c++) - (a = b[c]), !a() && b[c] === a && b.splice(c--, 1); + ((a = b[c]), !a() && b[c] === a && b.splice(c--, 1)); b.length || f.fx.stop(); }, interval: 13, - stop: function() { - clearInterval(cp), (cp = null); + stop: function () { + (clearInterval(cp), (cp = null)); }, speeds: { slow: 600, fast: 200, _default: 400 }, step: { - opacity: function(a) { + opacity: function (a) { f.style(a.elem, "opacity", a.now); }, - _default: function(a) { + _default: function (a) { a.elem.style && a.elem.style[a.prop] != null ? (a.elem.style[a.prop] = a.now + a.unit) : (a.elem[a.prop] = a.now); } } }), - f.each(["width", "height"], function(a, b) { - f.fx.step[b] = function(a) { + f.each(["width", "height"], function (a, b) { + f.fx.step[b] = function (a) { f.style(a.elem, b, Math.max(0, a.now) + a.unit); }; }), f.expr && f.expr.filters && - (f.expr.filters.animated = function(a) { - return f.grep(f.timers, function(b) { + (f.expr.filters.animated = function (a) { + return f.grep(f.timers, function (b) { return a === b.elem; }).length; - }); + })); var cw = /^t(?:able|d|h)$/i, cx = /^(?:body|html)$/i; - "getBoundingClientRect" in c.documentElement - ? (f.fn.offset = function(a) { + ("getBoundingClientRect" in c.documentElement + ? (f.fn.offset = function (a) { var b = this[0], c; if (a) - return this.each(function(b) { + return this.each(function (b) { f.offset.setOffset(this, a, b); }); if (!b || !b.ownerDocument) return null; @@ -5114,10 +5130,10 @@ o = c.left + m - k; return { top: n, left: o }; }) - : (f.fn.offset = function(a) { + : (f.fn.offset = function (a) { var b = this[0]; if (a) - return this.each(function(b) { + return this.each(function (b) { f.offset.setOffset(this, a, b); }); if (!b || !b.ownerDocument) return null; @@ -5134,7 +5150,7 @@ m = b.offsetLeft; while ((b = b.parentNode) && b !== i && b !== h) { if (f.support.fixedPosition && k.position === "fixed") break; - (c = j ? j.getComputedStyle(b, null) : b.currentStyle), + ((c = j ? j.getComputedStyle(b, null) : b.currentStyle), (l -= b.scrollTop), (m -= b.scrollLeft), b === d && @@ -5151,10 +5167,10 @@ c.overflow !== "visible" && ((l += parseFloat(c.borderTopWidth) || 0), (m += parseFloat(c.borderLeftWidth) || 0)), - (k = c); + (k = c)); } if (k.position === "relative" || k.position === "static") - (l += i.offsetTop), (m += i.offsetLeft); + ((l += i.offsetTop), (m += i.offsetLeft)); f.support.fixedPosition && k.position === "fixed" && ((l += Math.max(h.scrollTop, i.scrollTop)), @@ -5162,7 +5178,7 @@ return { top: l, left: m }; }), (f.offset = { - bodyOffset: function(a) { + bodyOffset: function (a) { var b = a.offsetTop, c = a.offsetLeft; f.support.doesNotIncludeMarginInBodyOffset && @@ -5170,7 +5186,7 @@ (c += parseFloat(f.css(a, "marginLeft")) || 0)); return { top: b, left: c }; }, - setOffset: function(a, b, c) { + setOffset: function (a, b, c) { var d = f.css(a, "position"); d === "static" && (a.style.position = "relative"); var e = f(a), @@ -5184,30 +5200,30 @@ l = {}, m, n; - j + (j ? ((l = e.position()), (m = l.top), (n = l.left)) : ((m = parseFloat(h) || 0), (n = parseFloat(i) || 0)), f.isFunction(b) && (b = b.call(a, c, g)), b.top != null && (k.top = b.top - g.top + m), b.left != null && (k.left = b.left - g.left + n), - "using" in b ? b.using.call(a, k) : e.css(k); + "using" in b ? b.using.call(a, k) : e.css(k)); } }), f.fn.extend({ - position: function() { + position: function () { if (!this[0]) return null; var a = this[0], b = this.offsetParent(), c = this.offset(), d = cx.test(b[0].nodeName) ? { top: 0, left: 0 } : b.offset(); - (c.top -= parseFloat(f.css(a, "marginTop")) || 0), + ((c.top -= parseFloat(f.css(a, "marginTop")) || 0), (c.left -= parseFloat(f.css(a, "marginLeft")) || 0), (d.top += parseFloat(f.css(b[0], "borderTopWidth")) || 0), - (d.left += parseFloat(f.css(b[0], "borderLeftWidth")) || 0); + (d.left += parseFloat(f.css(b[0], "borderLeftWidth")) || 0)); return { top: c.top - d.top, left: c.left - d.left }; }, - offsetParent: function() { - return this.map(function() { + offsetParent: function () { + return this.map(function () { var a = this.offsetParent || c.body; while (a && !cx.test(a.nodeName) && f.css(a, "position") === "static") a = a.offsetParent; @@ -5215,9 +5231,9 @@ }); } }), - f.each(["Left", "Top"], function(a, c) { + f.each(["Left", "Top"], function (a, c) { var d = "scroll" + c; - f.fn[d] = function(c) { + f.fn[d] = function (c) { var e, g; if (c === b) { e = this[0]; @@ -5230,17 +5246,17 @@ g.document.body[d] : e[d]; } - return this.each(function() { - (g = cy(this)), + return this.each(function () { + ((g = cy(this)), g ? g.scrollTo(a ? f(g).scrollLeft() : c, a ? c : f(g).scrollTop()) - : (this[d] = c); + : (this[d] = c)); }); }; }), - f.each(["Height", "Width"], function(a, c) { + f.each(["Height", "Width"], function (a, c) { var d = c.toLowerCase(); - (f.fn["inner" + c] = function() { + ((f.fn["inner" + c] = function () { var a = this[0]; return a ? a.style @@ -5248,7 +5264,7 @@ : this[d]() : null; }), - (f.fn["outer" + c] = function(a) { + (f.fn["outer" + c] = function (a) { var b = this[0]; return b ? b.style @@ -5256,11 +5272,11 @@ : this[d]() : null; }), - (f.fn[d] = function(a) { + (f.fn[d] = function (a) { var e = this[0]; if (!e) return a == null ? null : this; if (f.isFunction(a)) - return this.each(function(b) { + return this.each(function (b) { var c = f(this); c[d](a.call(this, b, c[d]())); }); @@ -5287,13 +5303,13 @@ return f.isNumeric(j) ? j : i; } return this.css(d, typeof a == "string" ? a : a + "px"); - }); + })); }), (a.jQuery = a.$ = f), typeof define == "function" && define.amd && define.amd.jQuery && - define("jquery", [], function() { + define("jquery", [], function () { return f; - }); + })); })(window); diff --git a/examples/js/jquery/jquery-ui-1.8.17.custom.min.js b/examples/js/jquery/jquery-ui-1.8.17.custom.min.js index 652865f0f..ae09eceba 100644 --- a/examples/js/jquery/jquery-ui-1.8.17.custom.min.js +++ b/examples/js/jquery/jquery-ui-1.8.17.custom.min.js @@ -6,12 +6,12 @@ * http://jquery.org/license * * http://docs.jquery.com/UI - */ (function(a, b) { + */ (function (a, b) { function d(b) { return !a(b) .parents() .andSelf() - .filter(function() { + .filter(function () { return ( a.curCSS(this, "visibility") === "hidden" || a.expr.filters.hidden(this) @@ -32,8 +32,8 @@ (/input|select|textarea|button|object/.test(e) ? !b.disabled : "a" == e - ? b.href || c - : c) && d(b) + ? b.href || c + : c) && d(b) ); } a.ui = a.ui || {}; @@ -78,22 +78,22 @@ a.fn.extend({ propAttr: a.fn.prop || a.fn.attr, _focus: a.fn.focus, - focus: function(b, c) { + focus: function (b, c) { return typeof b == "number" - ? this.each(function() { + ? this.each(function () { var d = this; - setTimeout(function() { - a(d).focus(), c && c.call(d); + setTimeout(function () { + (a(d).focus(), c && c.call(d)); }, b); }) : this._focus.apply(this, arguments); }, - scrollParent: function() { + scrollParent: function () { var b; (a.browser.msie && /(static|relative)/.test(this.css("position"))) || /absolute/.test(this.css("position")) ? (b = this.parents() - .filter(function() { + .filter(function () { return ( /(relative|absolute|fixed)/.test( a.curCSS(this, "position", 1) @@ -107,7 +107,7 @@ }) .eq(0)) : (b = this.parents() - .filter(function() { + .filter(function () { return /(auto|scroll)/.test( a.curCSS(this, "overflow", 1) + a.curCSS(this, "overflow-y", 1) + @@ -119,7 +119,7 @@ ? a(document) : b; }, - zIndex: function(c) { + zIndex: function (c) { if (c !== b) return this.css("zIndex", c); if (this.length) { var d = a(this[0]), @@ -136,27 +136,27 @@ } return 0; }, - disableSelection: function() { + disableSelection: function () { return this.bind( (a.support.selectstart ? "selectstart" : "mousedown") + ".ui-disableSelection", - function(a) { + function (a) { a.preventDefault(); } ); }, - enableSelection: function() { + enableSelection: function () { return this.unbind(".ui-disableSelection"); } }), - a.each(["Width", "Height"], function(c, d) { + a.each(["Width", "Height"], function (c, d) { function h(b, c, d, f) { - a.each(e, function() { - (c -= parseFloat(a.curCSS(b, "padding" + this, !0)) || 0), + a.each(e, function () { + ((c -= parseFloat(a.curCSS(b, "padding" + this, !0)) || 0), d && (c -= parseFloat(a.curCSS(b, "border" + this + "Width", !0)) || 0), - f && (c -= parseFloat(a.curCSS(b, "margin" + this, !0)) || 0); + f && (c -= parseFloat(a.curCSS(b, "margin" + this, !0)) || 0)); }); return c; } @@ -168,36 +168,36 @@ outerWidth: a.fn.outerWidth, outerHeight: a.fn.outerHeight }; - (a.fn["inner" + d] = function(c) { + ((a.fn["inner" + d] = function (c) { if (c === b) return g["inner" + d].call(this); - return this.each(function() { + return this.each(function () { a(this).css(f, h(this, c) + "px"); }); }), - (a.fn["outer" + d] = function(b, c) { + (a.fn["outer" + d] = function (b, c) { if (typeof b != "number") return g["outer" + d].call(this, b); - return this.each(function() { + return this.each(function () { a(this).css(f, h(this, b, !0, c) + "px"); }); - }); + })); }), a.extend(a.expr[":"], { - data: function(b, c, d) { + data: function (b, c, d) { return !!a.data(b, d[3]); }, - focusable: function(b) { + focusable: function (b) { return c(b, !isNaN(a.attr(b, "tabindex"))); }, - tabbable: function(b) { + tabbable: function (b) { var d = a.attr(b, "tabindex"), e = isNaN(d); return (e || d >= 0) && c(b, !e); } }), - a(function() { + a(function () { var b = document.body, c = b.appendChild((c = document.createElement("div"))); - a.extend(c.style, { + (a.extend(c.style, { minHeight: "100px", height: "auto", padding: 0, @@ -205,39 +205,39 @@ }), (a.support.minHeight = c.offsetHeight === 100), (a.support.selectstart = "onselectstart" in c), - (b.removeChild(c).style.display = "none"); + (b.removeChild(c).style.display = "none")); }), a.extend(a.ui, { plugin: { - add: function(b, c, d) { + add: function (b, c, d) { var e = a.ui[b].prototype; for (var f in d) - (e.plugins[f] = e.plugins[f] || []), e.plugins[f].push([c, d[f]]); + ((e.plugins[f] = e.plugins[f] || []), e.plugins[f].push([c, d[f]])); }, - call: function(a, b, c) { + call: function (a, b, c) { var d = a.plugins[b]; if (!!d && !!a.element[0].parentNode) for (var e = 0; e < d.length; e++) a.options[d[e][0]] && d[e][1].apply(a.element, c); } }, - contains: function(a, b) { + contains: function (a, b) { return document.compareDocumentPosition ? a.compareDocumentPosition(b) & 16 : a !== b && a.contains(b); }, - hasScroll: function(b, c) { + hasScroll: function (b, c) { if (a(b).css("overflow") === "hidden") return !1; var d = c && c === "left" ? "scrollLeft" : "scrollTop", e = !1; if (b[d] > 0) return !0; - (b[d] = 1), (e = b[d] > 0), (b[d] = 0); + ((b[d] = 1), (e = b[d] > 0), (b[d] = 0)); return e; }, - isOverAxis: function(a, b, c) { + isOverAxis: function (a, b, c) { return a > b && a < b + c; }, - isOver: function(b, c, d, e, f, g) { + isOver: function (b, c, d, e, f, g) { return a.ui.isOverAxis(b, d, f) && a.ui.isOverAxis(c, e, g); } })); @@ -250,10 +250,10 @@ * http://jquery.org/license * * http://docs.jquery.com/UI/Widget - */ (function(a, b) { + */ (function (a, b) { if (a.cleanData) { var c = a.cleanData; - a.cleanData = function(b) { + a.cleanData = function (b) { for (var d = 0, e; (e = b[d]) != null; d++) try { a(e).triggerHandler("remove"); @@ -262,13 +262,13 @@ }; } else { var d = a.fn.remove; - a.fn.remove = function(b, c) { - return this.each(function() { + a.fn.remove = function (b, c) { + return this.each(function () { c || ((!b || a.filter(b, [this]).length) && a("*", this) .add([this]) - .each(function() { + .each(function () { try { a(this).triggerHandler("remove"); } catch (b) {} @@ -277,21 +277,21 @@ }); }; } - (a.widget = function(b, c, d) { + ((a.widget = function (b, c, d) { var e = b.split(".")[0], f; - (b = b.split(".")[1]), + ((b = b.split(".")[1]), (f = e + "-" + b), d || ((d = c), (c = a.Widget)), - (a.expr[":"][f] = function(c) { + (a.expr[":"][f] = function (c) { return !!a.data(c, b); }), (a[e] = a[e] || {}), - (a[e][b] = function(a, b) { + (a[e][b] = function (a, b) { arguments.length && this._createWidget(a, b); - }); + })); var g = new c(); - (g.options = a.extend(!0, {}, g.options)), + ((g.options = a.extend(!0, {}, g.options)), (a[e][b].prototype = a.extend( !0, g, @@ -303,17 +303,17 @@ }, d )), - a.widget.bridge(b, a[e][b]); + a.widget.bridge(b, a[e][b])); }), - (a.widget.bridge = function(c, d) { - a.fn[c] = function(e) { + (a.widget.bridge = function (c, d) { + a.fn[c] = function (e) { var f = typeof e == "string", g = Array.prototype.slice.call(arguments, 1), h = this; e = !f && g.length ? a.extend.apply(null, [!0, e].concat(g)) : e; if (f && e.charAt(0) === "_") return h; f - ? this.each(function() { + ? this.each(function () { var d = a.data(this, c), f = d && a.isFunction(d[e]) ? d[e].apply(d, g) : d; if (f !== d && f !== b) { @@ -321,22 +321,22 @@ return !1; } }) - : this.each(function() { + : this.each(function () { var b = a.data(this, c); b ? b.option(e || {})._init() : a.data(this, c, new d(e, this)); }); return h; }; }), - (a.Widget = function(a, b) { + (a.Widget = function (a, b) { arguments.length && this._createWidget(a, b); }), (a.Widget.prototype = { widgetName: "widget", widgetEventPrefix: "", options: { disabled: !1 }, - _createWidget: function(b, c) { - a.data(c, this.widgetName, this), + _createWidget: function (b, c) { + (a.data(c, this.widgetName, this), (this.element = a(c)), (this.options = a.extend( !0, @@ -344,77 +344,76 @@ this.options, this._getCreateOptions(), b - )); + ))); var d = this; - this.element.bind("remove." + this.widgetName, function() { + (this.element.bind("remove." + this.widgetName, function () { d.destroy(); }), this._create(), this._trigger("create"), - this._init(); + this._init()); }, - _getCreateOptions: function() { + _getCreateOptions: function () { return a.metadata && a.metadata.get(this.element[0])[this.widgetName]; }, - _create: function() {}, - _init: function() {}, - destroy: function() { - this.element.unbind("." + this.widgetName).removeData(this.widgetName), + _create: function () {}, + _init: function () {}, + destroy: function () { + (this.element.unbind("." + this.widgetName).removeData(this.widgetName), this.widget() .unbind("." + this.widgetName) .removeAttr("aria-disabled") .removeClass( this.widgetBaseClass + "-disabled " + "ui-state-disabled" - ); + )); }, - widget: function() { + widget: function () { return this.element; }, - option: function(c, d) { + option: function (c, d) { var e = c; if (arguments.length === 0) return a.extend({}, this.options); if (typeof c == "string") { if (d === b) return this.options[c]; - (e = {}), (e[c] = d); + ((e = {}), (e[c] = d)); } this._setOptions(e); return this; }, - _setOptions: function(b) { + _setOptions: function (b) { var c = this; - a.each(b, function(a, b) { + a.each(b, function (a, b) { c._setOption(a, b); }); return this; }, - _setOption: function(a, b) { - (this.options[a] = b), + _setOption: function (a, b) { + ((this.options[a] = b), a === "disabled" && this.widget() [b ? "addClass" : "removeClass"]( this.widgetBaseClass + "-disabled" + " " + "ui-state-disabled" ) - .attr("aria-disabled", b); + .attr("aria-disabled", b)); return this; }, - enable: function() { + enable: function () { return this._setOption("disabled", !1); }, - disable: function() { + disable: function () { return this._setOption("disabled", !0); }, - _trigger: function(b, c, d) { + _trigger: function (b, c, d) { var e, f, g = this.options[b]; - (d = d || {}), + ((d = d || {}), (c = a.Event(c)), - (c.type = (b === this.widgetEventPrefix - ? b - : this.widgetEventPrefix + b + (c.type = ( + b === this.widgetEventPrefix ? b : this.widgetEventPrefix + b ).toLowerCase()), (c.target = this.element[0]), - (f = c.originalEvent); + (f = c.originalEvent)); if (f) for (e in f) e in c || (c[e] = f[e]); this.element.trigger(c, d); return !( @@ -422,7 +421,7 @@ c.isDefaultPrevented() ); } - }); + })); })(jQuery); /*! * jQuery UI Mouse 1.8.17 @@ -435,34 +434,34 @@ * * Depends: * jquery.ui.widget.js - */ (function(a, b) { + */ (function (a, b) { var c = !1; - a(document).mouseup(function(a) { + (a(document).mouseup(function (a) { c = !1; }), a.widget("ui.mouse", { options: { cancel: ":input,option", distance: 1, delay: 0 }, - _mouseInit: function() { + _mouseInit: function () { var b = this; - this.element - .bind("mousedown." + this.widgetName, function(a) { + (this.element + .bind("mousedown." + this.widgetName, function (a) { return b._mouseDown(a); }) - .bind("click." + this.widgetName, function(c) { + .bind("click." + this.widgetName, function (c) { if (!0 === a.data(c.target, b.widgetName + ".preventClickEvent")) { - a.removeData(c.target, b.widgetName + ".preventClickEvent"), - c.stopImmediatePropagation(); + (a.removeData(c.target, b.widgetName + ".preventClickEvent"), + c.stopImmediatePropagation()); return !1; } }), - (this.started = !1); + (this.started = !1)); }, - _mouseDestroy: function() { + _mouseDestroy: function () { this.element.unbind("." + this.widgetName); }, - _mouseDown: function(b) { + _mouseDown: function (b) { if (!c) { - this._mouseStarted && this._mouseUp(b), (this._mouseDownEvent = b); + (this._mouseStarted && this._mouseUp(b), (this._mouseDownEvent = b)); var d = this, e = b.which == 1, f = @@ -470,11 +469,11 @@ ? a(b.target).closest(this.options.cancel).length : !1; if (!e || f || !this._mouseCapture(b)) return !0; - (this.mouseDelayMet = !this.options.delay), + ((this.mouseDelayMet = !this.options.delay), this.mouseDelayMet || - (this._mouseDelayTimer = setTimeout(function() { + (this._mouseDelayTimer = setTimeout(function () { d.mouseDelayMet = !0; - }, this.options.delay)); + }, this.options.delay))); if (this._mouseDistanceMet(b) && this._mouseDelayMet(b)) { this._mouseStarted = this._mouseStart(b) !== !1; if (!this._mouseStarted) { @@ -482,23 +481,23 @@ return !0; } } - !0 === a.data(b.target, this.widgetName + ".preventClickEvent") && + (!0 === a.data(b.target, this.widgetName + ".preventClickEvent") && a.removeData(b.target, this.widgetName + ".preventClickEvent"), - (this._mouseMoveDelegate = function(a) { + (this._mouseMoveDelegate = function (a) { return d._mouseMove(a); }), - (this._mouseUpDelegate = function(a) { + (this._mouseUpDelegate = function (a) { return d._mouseUp(a); }), a(document) .bind("mousemove." + this.widgetName, this._mouseMoveDelegate) .bind("mouseup." + this.widgetName, this._mouseUpDelegate), b.preventDefault(), - (c = !0); + (c = !0)); return !0; } }, - _mouseMove: function(b) { + _mouseMove: function (b) { if (a.browser.msie && !(document.documentMode >= 9) && !b.button) return this._mouseUp(b); if (this._mouseStarted) { @@ -512,18 +511,18 @@ this._mouseStarted ? this._mouseDrag(b) : this._mouseUp(b)); return !this._mouseStarted; }, - _mouseUp: function(b) { - a(document) + _mouseUp: function (b) { + (a(document) .unbind("mousemove." + this.widgetName, this._mouseMoveDelegate) .unbind("mouseup." + this.widgetName, this._mouseUpDelegate), this._mouseStarted && ((this._mouseStarted = !1), b.target == this._mouseDownEvent.target && a.data(b.target, this.widgetName + ".preventClickEvent", !0), - this._mouseStop(b)); + this._mouseStop(b))); return !1; }, - _mouseDistanceMet: function(a) { + _mouseDistanceMet: function (a) { return ( Math.max( Math.abs(this._mouseDownEvent.pageX - a.pageX), @@ -531,16 +530,16 @@ ) >= this.options.distance ); }, - _mouseDelayMet: function(a) { + _mouseDelayMet: function (a) { return this.mouseDelayMet; }, - _mouseStart: function(a) {}, - _mouseDrag: function(a) {}, - _mouseStop: function(a) {}, - _mouseCapture: function(a) { + _mouseStart: function (a) {}, + _mouseDrag: function (a) {}, + _mouseStop: function (a) {}, + _mouseCapture: function (a) { return !0; } - }); + })); })(jQuery); /* * jQuery UI Position 1.8.17 @@ -550,7 +549,7 @@ * http://jquery.org/license * * http://docs.jquery.com/UI/Position - */ (function(a, b) { + */ (function (a, b) { a.ui = a.ui || {}; var c = /left|center|right/, d = /top|center|bottom/, @@ -558,7 +557,7 @@ f = {}, g = a.fn.position, h = a.fn.offset; - (a.fn.position = function(b) { + ((a.fn.position = function (b) { if (!b || !b.of) return g.apply(this, arguments); b = a.extend({}, b); var h = a(b.of), @@ -568,28 +567,28 @@ l, m, n; - i.nodeType === 9 + (i.nodeType === 9 ? ((l = h.width()), (m = h.height()), (n = { top: 0, left: 0 })) : i.setTimeout - ? ((l = h.width()), - (m = h.height()), - (n = { top: h.scrollTop(), left: h.scrollLeft() })) - : i.preventDefault - ? ((b.at = "left top"), - (l = m = 0), - (n = { top: b.of.pageY, left: b.of.pageX })) - : ((l = h.outerWidth()), (m = h.outerHeight()), (n = h.offset())), - a.each(["my", "at"], function() { + ? ((l = h.width()), + (m = h.height()), + (n = { top: h.scrollTop(), left: h.scrollLeft() })) + : i.preventDefault + ? ((b.at = "left top"), + (l = m = 0), + (n = { top: b.of.pageY, left: b.of.pageX })) + : ((l = h.outerWidth()), (m = h.outerHeight()), (n = h.offset())), + a.each(["my", "at"], function () { var a = (b[this] || "").split(" "); - a.length === 1 && + (a.length === 1 && (a = c.test(a[0]) ? a.concat([e]) : d.test(a[0]) - ? [e].concat(a) - : [e, e]), + ? [e].concat(a) + : [e, e]), (a[0] = c.test(a[0]) ? a[0] : e), (a[1] = d.test(a[1]) ? a[1] : e), - (b[this] = a); + (b[this] = a)); }), j.length === 1 && (j[1] = j[0]), (k[0] = parseInt(k[0], 10) || 0), @@ -598,8 +597,8 @@ b.at[0] === "right" ? (n.left += l) : b.at[0] === e && (n.left += l / 2), b.at[1] === "bottom" ? (n.top += m) : b.at[1] === e && (n.top += m / 2), (n.left += k[0]), - (n.top += k[1]); - return this.each(function() { + (n.top += k[1])); + return this.each(function () { var c = a(this), d = c.outerWidth(), g = c.outerHeight(), @@ -609,12 +608,12 @@ p = g + i + (parseInt(a.curCSS(this, "marginBottom", !0)) || 0), q = a.extend({}, n), r; - b.my[0] === "right" ? (q.left -= d) : b.my[0] === e && (q.left -= d / 2), + (b.my[0] === "right" ? (q.left -= d) : b.my[0] === e && (q.left -= d / 2), b.my[1] === "bottom" ? (q.top -= g) : b.my[1] === e && (q.top -= g / 2), f.fractions || ((q.left = Math.round(q.left)), (q.top = Math.round(q.top))), (r = { left: q.left - h, top: q.top - i }), - a.each(["left", "top"], function(c, e) { + a.each(["left", "top"], function (c, e) { a.ui.position[j[c]] && a.ui.position[j[c]][e](q, { targetWidth: l, @@ -630,12 +629,12 @@ }); }), a.fn.bgiframe && c.bgiframe(), - c.offset(a.extend(q, { using: b.using })); + c.offset(a.extend(q, { using: b.using }))); }); }), (a.ui.position = { fit: { - left: function(b, c) { + left: function (b, c) { var d = a(window), e = c.collisionPosition.left + @@ -647,7 +646,7 @@ ? b.left - e : Math.max(b.left - c.collisionPosition.left, b.left); }, - top: function(b, c) { + top: function (b, c) { var d = a(window), e = c.collisionPosition.top + @@ -661,7 +660,7 @@ } }, flip: { - left: function(b, c) { + left: function (b, c) { if (c.at[0] !== e) { var d = a(window), f = @@ -673,15 +672,15 @@ c.my[0] === "left" ? -c.elemWidth : c.my[0] === "right" - ? c.elemWidth - : 0, + ? c.elemWidth + : 0, h = c.at[0] === "left" ? c.targetWidth : -c.targetWidth, i = -2 * c.offset[0]; b.left += c.collisionPosition.left < 0 ? g + h + i : f > 0 ? g + h + i : 0; } }, - top: function(b, c) { + top: function (b, c) { if (c.at[1] !== e) { var d = a(window), f = @@ -693,8 +692,8 @@ c.my[1] === "top" ? -c.elemHeight : c.my[1] === "bottom" - ? c.elemHeight - : 0, + ? c.elemHeight + : 0, h = c.at[1] === "top" ? c.targetHeight : -c.targetHeight, i = -2 * c.offset[1]; b.top += @@ -704,7 +703,7 @@ } }), a.offset.setOffset || - ((a.offset.setOffset = function(b, c) { + ((a.offset.setOffset = function (b, c) { /static/.test(a.curCSS(b, "position")) && (b.style.position = "relative"); var d = a(b), @@ -714,16 +713,16 @@ h = { top: c.top - e.top + f, left: c.left - e.left + g }; "using" in c ? c.using.call(b, h) : d.css(h); }), - (a.fn.offset = function(b) { + (a.fn.offset = function (b) { var c = this[0]; if (!c || !c.ownerDocument) return null; if (b) - return this.each(function() { + return this.each(function () { a.offset.setOffset(this, b); }); return h.call(this); })), - (function() { + (function () { var b = document.getElementsByTagName("body")[0], c = document.createElement("div"), d, @@ -731,7 +730,7 @@ g, h, i; - (d = document.createElement(b ? "div" : "body")), + ((d = document.createElement(b ? "div" : "body")), (g = { visibility: "hidden", width: 0, @@ -745,23 +744,23 @@ position: "absolute", left: "-1000px", top: "-1000px" - }); + })); for (var j in g) d.style[j] = g[j]; - d.appendChild(c), + (d.appendChild(c), (e = b || document.documentElement), e.insertBefore(d, e.firstChild), (c.style.cssText = "position: absolute; left: 10.7432222px; top: 10.432325px; height: 30px; width: 201px;"), (h = a(c) - .offset(function(a, b) { + .offset(function (a, b) { return b; }) .offset()), (d.innerHTML = ""), e.removeChild(d), (i = h.top + h.left + (b ? 2e3 : 0)), - (f.fractions = i > 21 && i < 22); - })(); + (f.fractions = i > 21 && i < 22)); + })()); })(jQuery); /* * jQuery UI Draggable 1.8.17 @@ -776,8 +775,8 @@ * jquery.ui.core.js * jquery.ui.mouse.js * jquery.ui.widget.js - */ (function(a, b) { - a.widget("ui.draggable", a.ui.mouse, { + */ (function (a, b) { + (a.widget("ui.draggable", a.ui.mouse, { widgetEventPrefix: "drag", options: { addClasses: !0, @@ -805,34 +804,34 @@ stack: !1, zIndex: !1 }, - _create: function() { - this.options.helper == "original" && + _create: function () { + (this.options.helper == "original" && !/^(?:r|a|f)/.test(this.element.css("position")) && (this.element[0].style.position = "relative"), this.options.addClasses && this.element.addClass("ui-draggable"), this.options.disabled && this.element.addClass("ui-draggable-disabled"), - this._mouseInit(); + this._mouseInit()); }, - destroy: function() { + destroy: function () { if (!!this.element.data("draggable")) { - this.element + (this.element .removeData("draggable") .unbind(".draggable") .removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" ), - this._mouseDestroy(); + this._mouseDestroy()); return this; } }, - _mouseCapture: function(b) { + _mouseCapture: function (b) { var c = this.options; if (this.helper || c.disabled || a(b.target).is(".ui-resizable-handle")) return !1; this.handle = this._getHandle(b); if (!this.handle) return !1; c.iframeFix && - a(c.iframeFix === !0 ? "iframe" : c.iframeFix).each(function() { + a(c.iframeFix === !0 ? "iframe" : c.iframeFix).each(function () { a( '
' ) @@ -848,9 +847,9 @@ }); return !0; }, - _mouseStart: function(b) { + _mouseStart: function (b) { var c = this.options; - (this.helper = this._createHelper(b)), + ((this.helper = this._createHelper(b)), this._cacheHelperProportions(), a.ui.ddmanager && (a.ui.ddmanager.current = this), this._cacheMargins(), @@ -873,23 +872,23 @@ (this.originalPageX = b.pageX), (this.originalPageY = b.pageY), c.cursorAt && this._adjustOffsetFromHelper(c.cursorAt), - c.containment && this._setContainment(); + c.containment && this._setContainment()); if (this._trigger("start", b) === !1) { this._clear(); return !1; } - this._cacheHelperProportions(), + (this._cacheHelperProportions(), a.ui.ddmanager && !c.dropBehaviour && a.ui.ddmanager.prepareOffsets(this, b), this.helper.addClass("ui-draggable-dragging"), this._mouseDrag(b, !0), - a.ui.ddmanager && a.ui.ddmanager.dragStart(this, b); + a.ui.ddmanager && a.ui.ddmanager.dragStart(this, b)); return !0; }, - _mouseDrag: function(b, c) { - (this.position = this._generatePosition(b)), - (this.positionAbs = this._convertPositionTo("absolute")); + _mouseDrag: function (b, c) { + ((this.position = this._generatePosition(b)), + (this.positionAbs = this._convertPositionTo("absolute"))); if (!c) { var d = this._uiHash(); if (this._trigger("drag", b, d) === !1) { @@ -905,12 +904,12 @@ a.ui.ddmanager && a.ui.ddmanager.drag(this, b); return !1; }, - _mouseStop: function(b) { + _mouseStop: function (b) { var c = !1; - a.ui.ddmanager && + (a.ui.ddmanager && !this.options.dropBehaviour && (c = a.ui.ddmanager.drop(this, b)), - this.dropped && ((c = this.dropped), (this.dropped = !1)); + this.dropped && ((c = this.dropped), (this.dropped = !1))); if ( (!this.element[0] || !this.element[0].parentNode) && this.options.helper == "original" @@ -927,28 +926,28 @@ a(this.helper).animate( this.originalPosition, parseInt(this.options.revertDuration, 10), - function() { + function () { d._trigger("stop", b) !== !1 && d._clear(); } ); } else this._trigger("stop", b) !== !1 && this._clear(); return !1; }, - _mouseUp: function(b) { - this.options.iframeFix === !0 && - a("div.ui-draggable-iframeFix").each(function() { + _mouseUp: function (b) { + (this.options.iframeFix === !0 && + a("div.ui-draggable-iframeFix").each(function () { this.parentNode.removeChild(this); }), - a.ui.ddmanager && a.ui.ddmanager.dragStop(this, b); + a.ui.ddmanager && a.ui.ddmanager.dragStop(this, b)); return a.ui.mouse.prototype._mouseUp.call(this, b); }, - cancel: function() { + cancel: function () { this.helper.is(".ui-draggable-dragging") ? this._mouseUp({}) : this._clear(); return this; }, - _getHandle: function(b) { + _getHandle: function (b) { var c = !this.options.handle || !a(this.options.handle, this.element).length ? !0 @@ -956,29 +955,29 @@ a(this.options.handle, this.element) .find("*") .andSelf() - .each(function() { + .each(function () { this == b.target && (c = !0); }); return c; }, - _createHelper: function(b) { + _createHelper: function (b) { var c = this.options, d = a.isFunction(c.helper) ? a(c.helper.apply(this.element[0], [b])) : c.helper == "clone" - ? this.element.clone().removeAttr("id") - : this.element; - d.parents("body").length || + ? this.element.clone().removeAttr("id") + : this.element; + (d.parents("body").length || d.appendTo( c.appendTo == "parent" ? this.element[0].parentNode : c.appendTo ), d[0] != this.element[0] && !/(fixed|absolute)/.test(d.css("position")) && - d.css("position", "absolute"); + d.css("position", "absolute")); return d; }, - _adjustOffsetFromHelper: function(b) { - typeof b == "string" && (b = b.split(" ")), + _adjustOffsetFromHelper: function (b) { + (typeof b == "string" && (b = b.split(" ")), a.isArray(b) && (b = { left: +b[0], top: +b[1] || 0 }), "left" in b && (this.offset.click.left = b.left + this.margins.left), "right" in b && @@ -987,9 +986,9 @@ "top" in b && (this.offset.click.top = b.top + this.margins.top), "bottom" in b && (this.offset.click.top = - this.helperProportions.height - b.bottom + this.margins.top); + this.helperProportions.height - b.bottom + this.margins.top)); }, - _getParentOffset: function() { + _getParentOffset: function () { this.offsetParent = this.helper.offsetParent(); var b = this.offsetParent.offset(); this.cssPosition == "absolute" && @@ -1011,7 +1010,7 @@ b.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0) }; }, - _getRelativeOffset: function() { + _getRelativeOffset: function () { if (this.cssPosition == "relative") { var a = this.element.position(); return { @@ -1027,7 +1026,7 @@ } return { top: 0, left: 0 }; }, - _cacheMargins: function() { + _cacheMargins: function () { this.margins = { left: parseInt(this.element.css("marginLeft"), 10) || 0, top: parseInt(this.element.css("marginTop"), 10) || 0, @@ -1035,13 +1034,13 @@ bottom: parseInt(this.element.css("marginBottom"), 10) || 0 }; }, - _cacheHelperProportions: function() { + _cacheHelperProportions: function () { this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() }; }, - _setContainment: function() { + _setContainment: function () { var b = this.options; b.containment == "parent" && (b.containment = this.helper[0].parentNode); if (b.containment == "document" || b.containment == "window") @@ -1075,7 +1074,7 @@ if (!d) return; var e = c.offset(), f = a(d).css("overflow") != "hidden"; - (this.containment = [ + ((this.containment = [ (parseInt(a(d).css("borderLeftWidth"), 10) || 0) + (parseInt(a(d).css("paddingLeft"), 10) || 0), (parseInt(a(d).css("borderTopWidth"), 10) || 0) + @@ -1093,12 +1092,12 @@ this.margins.top - this.margins.bottom ]), - (this.relative_container = c); + (this.relative_container = c)); } else b.containment.constructor == Array && (this.containment = b.containment); }, - _convertPositionTo: function(b, c) { + _convertPositionTo: function (b, c) { c || (c = this.position); var d = b == "absolute" ? 1 : -1, e = this.options, @@ -1121,8 +1120,8 @@ : (this.cssPosition == "fixed" ? -this.scrollParent.scrollTop() : g - ? 0 - : f.scrollTop()) * d), + ? 0 + : f.scrollTop()) * d), left: c.left + this.offset.relative.left * d + @@ -1134,11 +1133,11 @@ : (this.cssPosition == "fixed" ? -this.scrollParent.scrollLeft() : g - ? 0 - : f.scrollLeft()) * d) + ? 0 + : f.scrollLeft()) * d) }; }, - _generatePosition: function(b) { + _generatePosition: function (b) { var c = this.options, d = this.cssPosition == "absolute" && @@ -1161,14 +1160,14 @@ this.containment[3] + i.top ]; } else h = this.containment; - b.pageX - this.offset.click.left < h[0] && + (b.pageX - this.offset.click.left < h[0] && (f = h[0] + this.offset.click.left), b.pageY - this.offset.click.top < h[1] && (g = h[1] + this.offset.click.top), b.pageX - this.offset.click.left > h[2] && (f = h[2] + this.offset.click.left), b.pageY - this.offset.click.top > h[3] && - (g = h[3] + this.offset.click.top); + (g = h[3] + this.offset.click.top)); } if (c.grid) { var j = c.grid[1] @@ -1208,10 +1207,10 @@ this.cssPosition == "fixed" ? 0 : this.cssPosition == "fixed" - ? -this.scrollParent.scrollTop() - : e - ? 0 - : d.scrollTop()), + ? -this.scrollParent.scrollTop() + : e + ? 0 + : d.scrollTop()), left: f - this.offset.click.left - @@ -1222,28 +1221,29 @@ this.cssPosition == "fixed" ? 0 : this.cssPosition == "fixed" - ? -this.scrollParent.scrollLeft() - : e - ? 0 - : d.scrollLeft()) + ? -this.scrollParent.scrollLeft() + : e + ? 0 + : d.scrollLeft()) }; }, - _clear: function() { - this.helper.removeClass("ui-draggable-dragging"), + _clear: function () { + (this.helper.removeClass("ui-draggable-dragging"), this.helper[0] != this.element[0] && !this.cancelHelperRemoval && this.helper.remove(), (this.helper = null), - (this.cancelHelperRemoval = !1); + (this.cancelHelperRemoval = !1)); }, - _trigger: function(b, c, d) { - (d = d || this._uiHash()), + _trigger: function (b, c, d) { + ((d = d || this._uiHash()), a.ui.plugin.call(this, b, [c, d]), - b == "drag" && (this.positionAbs = this._convertPositionTo("absolute")); + b == "drag" && + (this.positionAbs = this._convertPositionTo("absolute"))); return a.Widget.prototype._trigger.call(this, b, c, d); }, plugins: {}, - _uiHash: function(a) { + _uiHash: function (a) { return { helper: this.helper, position: this.position, @@ -1254,12 +1254,12 @@ }), a.extend(a.ui.draggable, { version: "1.8.17" }), a.ui.plugin.add("draggable", "connectToSortable", { - start: function(b, c) { + start: function (b, c) { var d = a(this).data("draggable"), e = d.options, f = a.extend({}, c, { item: d.element }); - (d.sortables = []), - a(e.connectToSortable).each(function() { + ((d.sortables = []), + a(e.connectToSortable).each(function () { var c = a.data(this, "sortable"); c && !c.options.disabled && @@ -1269,12 +1269,12 @@ }), c.refreshPositions(), c._trigger("activate", b, f)); - }); + })); }, - stop: function(b, c) { + stop: function (b, c) { var d = a(this).data("draggable"), e = a.extend({}, c, { item: d.element }); - a.each(d.sortables, function() { + a.each(d.sortables, function () { this.instance.isOver ? ((this.instance.isOver = 0), (d.cancelHelperRemoval = !0), @@ -1288,10 +1288,10 @@ this.instance._trigger("deactivate", b, e)); }); }, - drag: function(b, c) { + drag: function (b, c) { var d = a(this).data("draggable"), e = this, - f = function(b) { + f = function (b) { var c = this.offset.click.top, d = this.offset.click.left, e = this.positionAbs.top, @@ -1302,8 +1302,8 @@ j = b.left; return a.ui.isOver(e + c, f + d, i, j, g, h); }; - a.each(d.sortables, function(f) { - (this.instance.positionAbs = d.positionAbs), + a.each(d.sortables, function (f) { + ((this.instance.positionAbs = d.positionAbs), (this.instance.helperProportions = d.helperProportions), (this.instance.offset.click = d.offset.click), this.instance._intersectsWith(this.instance.containerCache) @@ -1314,8 +1314,9 @@ .removeAttr("id") .appendTo(this.instance.element) .data("sortable-item", !0)), - (this.instance.options._helper = this.instance.options.helper), - (this.instance.options.helper = function() { + (this.instance.options._helper = + this.instance.options.helper), + (this.instance.options.helper = function () { return c.helper[0]; }), (b.target = this.instance.currentItem[0]), @@ -1346,42 +1347,42 @@ this.instance.currentItem.remove(), this.instance.placeholder && this.instance.placeholder.remove(), d._trigger("fromSortable", b), - (d.dropped = !1)); + (d.dropped = !1))); }); } }), a.ui.plugin.add("draggable", "cursor", { - start: function(b, c) { + start: function (b, c) { var d = a("body"), e = a(this).data("draggable").options; - d.css("cursor") && (e._cursor = d.css("cursor")), - d.css("cursor", e.cursor); + (d.css("cursor") && (e._cursor = d.css("cursor")), + d.css("cursor", e.cursor)); }, - stop: function(b, c) { + stop: function (b, c) { var d = a(this).data("draggable").options; d._cursor && a("body").css("cursor", d._cursor); } }), a.ui.plugin.add("draggable", "opacity", { - start: function(b, c) { + start: function (b, c) { var d = a(c.helper), e = a(this).data("draggable").options; - d.css("opacity") && (e._opacity = d.css("opacity")), - d.css("opacity", e.opacity); + (d.css("opacity") && (e._opacity = d.css("opacity")), + d.css("opacity", e.opacity)); }, - stop: function(b, c) { + stop: function (b, c) { var d = a(this).data("draggable").options; d._opacity && a(c.helper).css("opacity", d._opacity); } }), a.ui.plugin.add("draggable", "scroll", { - start: function(b, c) { + start: function (b, c) { var d = a(this).data("draggable"); d.scrollParent[0] != document && d.scrollParent[0].tagName != "HTML" && (d.overflowOffset = d.scrollParent.offset()); }, - drag: function(b, c) { + drag: function (b, c) { var d = a(this).data("draggable"), e = d.options, f = !1; @@ -1434,15 +1435,15 @@ } }), a.ui.plugin.add("draggable", "snap", { - start: function(b, c) { + start: function (b, c) { var d = a(this).data("draggable"), e = d.options; - (d.snapElements = []), + ((d.snapElements = []), a( e.snap.constructor != String ? e.snap.items || ":data(draggable)" : e.snap - ).each(function() { + ).each(function () { var b = a(this), c = b.offset(); this != d.element[0] && @@ -1453,9 +1454,9 @@ top: c.top, left: c.left }); - }); + })); }, - drag: function(b, c) { + drag: function (b, c) { var d = a(this).data("draggable"), e = d.options, f = e.snapTolerance, @@ -1468,22 +1469,20 @@ m = l + d.snapElements[k].width, n = d.snapElements[k].top, o = n + d.snapElements[k].height; - if ( - !( - (l - f < g && g < m + f && n - f < i && i < o + f) || - (l - f < g && g < m + f && n - f < j && j < o + f) || - (l - f < h && h < m + f && n - f < i && i < o + f) || - (l - f < h && h < m + f && n - f < j && j < o + f) - ) - ) { - d.snapElements[k].snapping && + if (!( + (l - f < g && g < m + f && n - f < i && i < o + f) || + (l - f < g && g < m + f && n - f < j && j < o + f) || + (l - f < h && h < m + f && n - f < i && i < o + f) || + (l - f < h && h < m + f && n - f < j && j < o + f) + )) { + (d.snapElements[k].snapping && d.options.snap.release && d.options.snap.release.call( d.element, b, a.extend(d._uiHash(), { snapItem: d.snapElements[k].item }) ), - (d.snapElements[k].snapping = !1); + (d.snapElements[k].snapping = !1)); continue; } if (e.snapMode != "inner") { @@ -1491,7 +1490,7 @@ q = Math.abs(o - i) <= f, r = Math.abs(l - h) <= f, s = Math.abs(m - g) <= f; - p && + (p && (c.position.top = d._convertPositionTo("relative", { top: n - d.helperProportions.height, @@ -1510,7 +1509,7 @@ s && (c.position.left = d._convertPositionTo("relative", { top: 0, left: m }).left - - d.margins.left); + d.margins.left)); } var t = p || q || r || s; if (e.snapMode != "outer") { @@ -1518,7 +1517,7 @@ q = Math.abs(o - j) <= f, r = Math.abs(l - g) <= f, s = Math.abs(m - h) <= f; - p && + (p && (c.position.top = d._convertPositionTo("relative", { top: n, left: 0 }).top - d.margins.top), @@ -1537,9 +1536,9 @@ d._convertPositionTo("relative", { top: 0, left: m - d.helperProportions.width - }).left - d.margins.left); + }).left - d.margins.left)); } - !d.snapElements[k].snapping && + (!d.snapElements[k].snapping && (p || q || r || s || t) && d.options.snap.snap && d.options.snap.snap.call( @@ -1547,14 +1546,14 @@ b, a.extend(d._uiHash(), { snapItem: d.snapElements[k].item }) ), - (d.snapElements[k].snapping = p || q || r || s || t); + (d.snapElements[k].snapping = p || q || r || s || t)); } } }), a.ui.plugin.add("draggable", "stack", { - start: function(b, c) { + start: function (b, c) { var d = a(this).data("draggable").options, - e = a.makeArray(a(d.stack)).sort(function(b, c) { + e = a.makeArray(a(d.stack)).sort(function (b, c) { return ( (parseInt(a(b).css("zIndex"), 10) || 0) - (parseInt(a(c).css("zIndex"), 10) || 0) @@ -1562,25 +1561,25 @@ }); if (!!e.length) { var f = parseInt(e[0].style.zIndex) || 0; - a(e).each(function(a) { + (a(e).each(function (a) { this.style.zIndex = f + a; }), - (this[0].style.zIndex = f + e.length); + (this[0].style.zIndex = f + e.length)); } } }), a.ui.plugin.add("draggable", "zIndex", { - start: function(b, c) { + start: function (b, c) { var d = a(c.helper), e = a(this).data("draggable").options; - d.css("zIndex") && (e._zIndex = d.css("zIndex")), - d.css("zIndex", e.zIndex); + (d.css("zIndex") && (e._zIndex = d.css("zIndex")), + d.css("zIndex", e.zIndex)); }, - stop: function(b, c) { + stop: function (b, c) { var d = a(this).data("draggable").options; d._zIndex && a(c.helper).css("zIndex", d._zIndex); } - }); + })); })(jQuery); /* * jQuery UI Droppable 1.8.17 @@ -1596,8 +1595,8 @@ * jquery.ui.widget.js * jquery.ui.mouse.js * jquery.ui.draggable.js - */ (function(a, b) { - a.widget("ui.droppable", { + */ (function (a, b) { + (a.widget("ui.droppable", { widgetEventPrefix: "drop", options: { accept: "*", @@ -1608,14 +1607,14 @@ scope: "default", tolerance: "intersect" }, - _create: function() { + _create: function () { var b = this.options, c = b.accept; - (this.isover = 0), + ((this.isover = 0), (this.isout = 1), (this.accept = a.isFunction(c) ? c - : function(a) { + : function (a) { return a.is(c); }), (this.proportions = { @@ -1625,9 +1624,9 @@ (a.ui.ddmanager.droppables[b.scope] = a.ui.ddmanager.droppables[b.scope] || []), a.ui.ddmanager.droppables[b.scope].push(this), - b.addClasses && this.element.addClass("ui-droppable"); + b.addClasses && this.element.addClass("ui-droppable")); }, - destroy: function() { + destroy: function () { var b = a.ui.ddmanager.droppables[this.options.scope]; for (var c = 0; c < b.length; c++) b[c] == this && b.splice(c, 1); this.element @@ -1636,28 +1635,28 @@ .unbind(".droppable"); return this; }, - _setOption: function(b, c) { - b == "accept" && + _setOption: function (b, c) { + (b == "accept" && (this.accept = a.isFunction(c) ? c - : function(a) { + : function (a) { return a.is(c); }), - a.Widget.prototype._setOption.apply(this, arguments); + a.Widget.prototype._setOption.apply(this, arguments)); }, - _activate: function(b) { + _activate: function (b) { var c = a.ui.ddmanager.current; - this.options.activeClass && + (this.options.activeClass && this.element.addClass(this.options.activeClass), - c && this._trigger("activate", b, this.ui(c)); + c && this._trigger("activate", b, this.ui(c))); }, - _deactivate: function(b) { + _deactivate: function (b) { var c = a.ui.ddmanager.current; - this.options.activeClass && + (this.options.activeClass && this.element.removeClass(this.options.activeClass), - c && this._trigger("deactivate", b, this.ui(c)); + c && this._trigger("deactivate", b, this.ui(c))); }, - _over: function(b) { + _over: function (b) { var c = a.ui.ddmanager.current; !!c && (c.currentItem || c.element)[0] != this.element[0] && @@ -1666,7 +1665,7 @@ this.element.addClass(this.options.hoverClass), this._trigger("over", b, this.ui(c))); }, - _out: function(b) { + _out: function (b) { var c = a.ui.ddmanager.current; !!c && (c.currentItem || c.element)[0] != this.element[0] && @@ -1675,14 +1674,14 @@ this.element.removeClass(this.options.hoverClass), this._trigger("out", b, this.ui(c))); }, - _drop: function(b, c) { + _drop: function (b, c) { var d = c || a.ui.ddmanager.current; if (!d || (d.currentItem || d.element)[0] == this.element[0]) return !1; var e = !1; this.element .find(":data(droppable)") .not(".ui-draggable-dragging") - .each(function() { + .each(function () { var b = a.data(this, "droppable"); if ( b.options.greedy && @@ -1701,16 +1700,16 @@ }); if (e) return !1; if (this.accept.call(this.element[0], d.currentItem || d.element)) { - this.options.activeClass && + (this.options.activeClass && this.element.removeClass(this.options.activeClass), this.options.hoverClass && this.element.removeClass(this.options.hoverClass), - this._trigger("drop", b, this.ui(d)); + this._trigger("drop", b, this.ui(d))); return this.element; } return !1; }, - ui: function(a) { + ui: function (a) { return { draggable: a.currentItem || a.element, helper: a.helper, @@ -1720,7 +1719,7 @@ } }), a.extend(a.ui.droppable, { version: "1.8.17" }), - (a.ui.intersect = function(b, c, d) { + (a.ui.intersect = function (b, c, d) { if (!c.offset) return !1; var e = (b.positionAbs || b.position.absolute).left, f = e + b.helperProportions.width, @@ -1768,7 +1767,7 @@ (a.ui.ddmanager = { current: null, droppables: { default: [] }, - prepareOffsets: function(b, c) { + prepareOffsets: function (b, c) { var d = a.ui.ddmanager.droppables[b.options.scope] || [], e = c ? c.type : null, f = (b.currentItem || b.element).find(":data(droppable)").andSelf(); @@ -1786,17 +1785,17 @@ } d[g].visible = d[g].element.css("display") != "none"; if (!d[g].visible) continue; - e == "mousedown" && d[g]._activate.call(d[g], c), + (e == "mousedown" && d[g]._activate.call(d[g], c), (d[g].offset = d[g].element.offset()), (d[g].proportions = { width: d[g].element[0].offsetWidth, height: d[g].element[0].offsetHeight - }); + })); } }, - drop: function(b, c) { + drop: function (b, c) { var d = !1; - a.each(a.ui.ddmanager.droppables[b.options.scope] || [], function() { + a.each(a.ui.ddmanager.droppables[b.options.scope] || [], function () { !this.options || (!this.options.disabled && this.visible && @@ -1811,24 +1810,24 @@ }); return d; }, - dragStart: function(b, c) { + dragStart: function (b, c) { b.element .parents(":not(body,html)") - .bind("scroll.droppable", function() { + .bind("scroll.droppable", function () { b.options.refreshPositions || a.ui.ddmanager.prepareOffsets(b, c); }); }, - drag: function(b, c) { - b.options.refreshPositions && a.ui.ddmanager.prepareOffsets(b, c), - a.each(a.ui.ddmanager.droppables[b.options.scope] || [], function() { + drag: function (b, c) { + (b.options.refreshPositions && a.ui.ddmanager.prepareOffsets(b, c), + a.each(a.ui.ddmanager.droppables[b.options.scope] || [], function () { if (!(this.options.disabled || this.greedyChild || !this.visible)) { var d = a.ui.intersect(b, this, this.options.tolerance), e = !d && this.isover == 1 ? "isout" : d && this.isover == 0 - ? "isover" - : null; + ? "isover" + : null; if (!e) return; var f; if (this.options.greedy) { @@ -1837,7 +1836,7 @@ ((f = a.data(g[0], "droppable")), (f.greedyChild = e == "isover" ? 1 : 0)); } - f && + (f && e == "isover" && ((f.isover = 0), (f.isout = 1), f._out.call(f, c)), (this[e] = 1), @@ -1845,15 +1844,15 @@ this[e == "isover" ? "_over" : "_out"].call(this, c), f && e == "isout" && - ((f.isout = 0), (f.isover = 1), f._over.call(f, c)); + ((f.isout = 0), (f.isover = 1), f._over.call(f, c))); } - }); + })); }, - dragStop: function(b, c) { - b.element.parents(":not(body,html)").unbind("scroll.droppable"), - b.options.refreshPositions || a.ui.ddmanager.prepareOffsets(b, c); + dragStop: function (b, c) { + (b.element.parents(":not(body,html)").unbind("scroll.droppable"), + b.options.refreshPositions || a.ui.ddmanager.prepareOffsets(b, c)); } - }); + })); })(jQuery); /* * jQuery UI Resizable 1.8.17 @@ -1868,8 +1867,8 @@ * jquery.ui.core.js * jquery.ui.mouse.js * jquery.ui.widget.js - */ (function(a, b) { - a.widget("ui.resizable", a.ui.mouse, { + */ (function (a, b) { + (a.widget("ui.resizable", a.ui.mouse, { widgetEventPrefix: "resize", options: { alsoResize: !1, @@ -1889,10 +1888,10 @@ minWidth: 10, zIndex: 1e3 }, - _create: function() { + _create: function () { var b = this, c = this.options; - this.element.addClass("ui-resizable"), + (this.element.addClass("ui-resizable"), a.extend(this, { _aspectRatio: !!c.aspectRatio, aspectRatio: c.aspectRatio, @@ -1964,7 +1963,7 @@ ne: ".ui-resizable-ne", nw: ".ui-resizable-nw" } - : "e,s,se")); + : "e,s,se"))); if (this.handles.constructor == String) { this.handles == "all" && (this.handles = "n,e,s,w,se,sw,ne,nw"); var d = this.handles.split(","); @@ -1973,13 +1972,13 @@ var f = a.trim(d[e]), g = "ui-resizable-" + f, h = a('
'); - /sw|se|ne|nw/.test(f) && h.css({ zIndex: ++c.zIndex }), + (/sw|se|ne|nw/.test(f) && h.css({ zIndex: ++c.zIndex }), "se" == f && h.addClass("ui-icon ui-icon-gripsmall-diagonal-se"), (this.handles[f] = ".ui-resizable-" + f), - this.element.append(h); + this.element.append(h)); } } - (this._renderAxis = function(b) { + ((this._renderAxis = function (b) { b = b || this.element; for (var c in this.handles) { this.handles[c].constructor == String && @@ -1998,12 +1997,12 @@ /ne|nw|n/.test(c) ? "Top" : /se|sw|s/.test(c) - ? "Bottom" - : /^e$/.test(c) - ? "Right" - : "Left" + ? "Bottom" + : /^e$/.test(c) + ? "Right" + : "Left" ].join(""); - b.css(f, e), this._proportionallyResize(); + (b.css(f, e), this._proportionallyResize()); } if (!a(this.handles[c]).length) continue; } @@ -2013,7 +2012,7 @@ ".ui-resizable-handle", this.element ).disableSelection()), - this._handles.mouseover(function() { + this._handles.mouseover(function () { if (!b.resizing) { if (this.className) var a = this.className.match( @@ -2027,23 +2026,23 @@ a(this.element) .addClass("ui-resizable-autohide") .hover( - function() { + function () { c.disabled || (a(this).removeClass("ui-resizable-autohide"), b._handles.show()); }, - function() { + function () { c.disabled || b.resizing || (a(this).addClass("ui-resizable-autohide"), b._handles.hide()); } )), - this._mouseInit(); + this._mouseInit()); }, - destroy: function() { + destroy: function () { this._mouseDestroy(); - var b = function(b) { + var b = function (b) { a(b) .removeClass( "ui-resizable ui-resizable-disabled ui-resizable-resizing" @@ -2066,20 +2065,20 @@ }) ).remove(); } - this.originalElement.css("resize", this.originalResizeStyle), - b(this.originalElement); + (this.originalElement.css("resize", this.originalResizeStyle), + b(this.originalElement)); return this; }, - _mouseCapture: function(b) { + _mouseCapture: function (b) { var c = !1; for (var d in this.handles) a(this.handles[d])[0] == b.target && (c = !0); return !this.options.disabled && c; }, - _mouseStart: function(b) { + _mouseStart: function (b) { var d = this.options, e = this.element.position(), f = this.element; - (this.resizing = !0), + ((this.resizing = !0), (this.documentScroll = { top: a(document).scrollTop(), left: a(document).scrollLeft() @@ -2089,10 +2088,10 @@ a.browser.opera && /relative/.test(f.css("position")) && f.css({ position: "relative", top: "auto", left: "auto" }), - this._renderProxy(); + this._renderProxy()); var g = c(this.helper.css("left")), h = c(this.helper.css("top")); - d.containment && + (d.containment && ((g += a(d.containment).scrollLeft() || 0), (h += a(d.containment).scrollTop() || 0)), (this.offset = this.helper.offset()), @@ -2112,14 +2111,14 @@ (this.aspectRatio = typeof d.aspectRatio == "number" ? d.aspectRatio - : this.originalSize.width / this.originalSize.height || 1); + : this.originalSize.width / this.originalSize.height || 1)); var i = a(".ui-resizable-" + this.axis).css("cursor"); - a("body").css("cursor", i == "auto" ? this.axis + "-resize" : i), + (a("body").css("cursor", i == "auto" ? this.axis + "-resize" : i), f.addClass("ui-resizable-resizing"), - this._propagate("start", b); + this._propagate("start", b)); return !0; }, - _mouseDrag: function(b) { + _mouseDrag: function (b) { var c = this.helper, d = this.options, e = {}, @@ -2135,7 +2134,7 @@ n = this.sizeDiff; this._updateVirtualBoundaries(b.shiftKey); if (this._aspectRatio || b.shiftKey) l = this._updateRatio(l, b); - (l = this._respectSize(l, b)), + ((l = this._respectSize(l, b)), this._propagate("resize", b), c.css({ top: this.position.top + "px", @@ -2147,10 +2146,10 @@ this._proportionallyResizeElements.length && this._proportionallyResize(), this._updateCache(l), - this._trigger("resize", b, this.ui()); + this._trigger("resize", b, this.ui())); return !1; }, - _mouseStop: function(b) { + _mouseStop: function (b) { this.resizing = !1; var c = this.options, d = this; @@ -2166,18 +2165,18 @@ k = parseInt(d.element.css("top"), 10) + (d.position.top - d.originalPosition.top) || null; - c.animate || this.element.css(a.extend(i, { top: k, left: j })), + (c.animate || this.element.css(a.extend(i, { top: k, left: j })), d.helper.height(d.size.height), d.helper.width(d.size.width), - this._helper && !c.animate && this._proportionallyResize(); + this._helper && !c.animate && this._proportionallyResize()); } - a("body").css("cursor", "auto"), + (a("body").css("cursor", "auto"), this.element.removeClass("ui-resizable-resizing"), this._propagate("stop", b), - this._helper && this.helper.remove(); + this._helper && this.helper.remove()); return !1; }, - _updateVirtualBoundaries: function(a) { + _updateVirtualBoundaries: function (a) { var b = this.options, c, e, @@ -2191,39 +2190,39 @@ maxHeight: d(b.maxHeight) ? b.maxHeight : Infinity }; if (this._aspectRatio || a) - (c = h.minHeight * this.aspectRatio), + ((c = h.minHeight * this.aspectRatio), (f = h.minWidth / this.aspectRatio), (e = h.maxHeight * this.aspectRatio), (g = h.maxWidth / this.aspectRatio), c > h.minWidth && (h.minWidth = c), f > h.minHeight && (h.minHeight = f), e < h.maxWidth && (h.maxWidth = e), - g < h.maxHeight && (h.maxHeight = g); + g < h.maxHeight && (h.maxHeight = g)); this._vBoundaries = h; }, - _updateCache: function(a) { + _updateCache: function (a) { var b = this.options; - (this.offset = this.helper.offset()), + ((this.offset = this.helper.offset()), d(a.left) && (this.position.left = a.left), d(a.top) && (this.position.top = a.top), d(a.height) && (this.size.height = a.height), - d(a.width) && (this.size.width = a.width); + d(a.width) && (this.size.width = a.width)); }, - _updateRatio: function(a, b) { + _updateRatio: function (a, b) { var c = this.options, e = this.position, f = this.size, g = this.axis; - d(a.height) + (d(a.height) ? (a.width = a.height * this.aspectRatio) : d(a.width) && (a.height = a.width / this.aspectRatio), g == "sw" && ((a.left = e.left + (f.width - a.width)), (a.top = null)), g == "nw" && ((a.top = e.top + (f.height - a.height)), - (a.left = e.left + (f.width - a.width))); + (a.left = e.left + (f.width - a.width)))); return a; }, - _respectSize: function(a, b) { + _respectSize: function (a, b) { var c = this.helper, e = this._vBoundaries, f = this._aspectRatio || b.shiftKey, @@ -2232,25 +2231,25 @@ i = d(a.height) && e.maxHeight && e.maxHeight < a.height, j = d(a.width) && e.minWidth && e.minWidth > a.width, k = d(a.height) && e.minHeight && e.minHeight > a.height; - j && (a.width = e.minWidth), + (j && (a.width = e.minWidth), k && (a.height = e.minHeight), h && (a.width = e.maxWidth), - i && (a.height = e.maxHeight); + i && (a.height = e.maxHeight)); var l = this.originalPosition.left + this.originalSize.width, m = this.position.top + this.size.height, n = /sw|nw|w/.test(g), o = /nw|ne|n/.test(g); - j && n && (a.left = l - e.minWidth), + (j && n && (a.left = l - e.minWidth), h && n && (a.left = l - e.maxWidth), k && o && (a.top = m - e.minHeight), - i && o && (a.top = m - e.maxHeight); + i && o && (a.top = m - e.maxHeight)); var p = !a.width && !a.height; p && !a.left && a.top ? (a.top = null) : p && !a.top && a.left && (a.left = null); return a; }, - _proportionallyResize: function() { + _proportionallyResize: function () { var b = this.options; if (!!this._proportionallyResizeElements.length) { var c = this.helper || this.element; @@ -2269,7 +2268,7 @@ e.css("paddingBottom"), e.css("paddingLeft") ]; - this.borderDif = a.map(f, function(a, b) { + this.borderDif = a.map(f, function (a, b) { var c = parseInt(a, 10) || 0, d = parseInt(g[b], 10) || 0; return c + d; @@ -2287,7 +2286,7 @@ } } }, - _renderProxy: function() { + _renderProxy: function () { var b = this.element, c = this.options; this.elementOffset = b.offset(); @@ -2296,7 +2295,7 @@ var d = a.browser.msie && a.browser.version < 7, e = d ? 1 : 0, f = d ? 2 : -1; - this.helper.addClass(this._helper).css({ + (this.helper.addClass(this._helper).css({ width: this.element.outerWidth() + f, height: this.element.outerHeight() + f, position: "absolute", @@ -2304,59 +2303,59 @@ top: this.elementOffset.top - e + "px", zIndex: ++c.zIndex }), - this.helper.appendTo("body").disableSelection(); + this.helper.appendTo("body").disableSelection()); } else this.helper = this.element; }, _change: { - e: function(a, b, c) { + e: function (a, b, c) { return { width: this.originalSize.width + b }; }, - w: function(a, b, c) { + w: function (a, b, c) { var d = this.options, e = this.originalSize, f = this.originalPosition; return { left: f.left + b, width: e.width - b }; }, - n: function(a, b, c) { + n: function (a, b, c) { var d = this.options, e = this.originalSize, f = this.originalPosition; return { top: f.top + c, height: e.height - c }; }, - s: function(a, b, c) { + s: function (a, b, c) { return { height: this.originalSize.height + c }; }, - se: function(b, c, d) { + se: function (b, c, d) { return a.extend( this._change.s.apply(this, arguments), this._change.e.apply(this, [b, c, d]) ); }, - sw: function(b, c, d) { + sw: function (b, c, d) { return a.extend( this._change.s.apply(this, arguments), this._change.w.apply(this, [b, c, d]) ); }, - ne: function(b, c, d) { + ne: function (b, c, d) { return a.extend( this._change.n.apply(this, arguments), this._change.e.apply(this, [b, c, d]) ); }, - nw: function(b, c, d) { + nw: function (b, c, d) { return a.extend( this._change.n.apply(this, arguments), this._change.w.apply(this, [b, c, d]) ); } }, - _propagate: function(b, c) { - a.ui.plugin.call(this, b, [c, this.ui()]), - b != "resize" && this._trigger(b, c, this.ui()); + _propagate: function (b, c) { + (a.ui.plugin.call(this, b, [c, this.ui()]), + b != "resize" && this._trigger(b, c, this.ui())); }, plugins: {}, - ui: function() { + ui: function () { return { originalElement: this.originalElement, element: this.element, @@ -2370,11 +2369,11 @@ }), a.extend(a.ui.resizable, { version: "1.8.17" }), a.ui.plugin.add("resizable", "alsoResize", { - start: function(b, c) { + start: function (b, c) { var d = a(this).data("resizable"), e = d.options, - f = function(b) { - a(b).each(function() { + f = function (b) { + a(b).each(function () { var b = a(this); b.data("resizable-alsoresize", { width: parseInt(b.width(), 10), @@ -2388,12 +2387,12 @@ typeof e.alsoResize == "object" && !e.alsoResize.parentNode ? e.alsoResize.length ? ((e.alsoResize = e.alsoResize[0]), f(e.alsoResize)) - : a.each(e.alsoResize, function(a) { + : a.each(e.alsoResize, function (a) { f(a); }) : f(e.alsoResize); }, - resize: function(b, c) { + resize: function (b, c) { var d = a(this).data("resizable"), e = d.options, f = d.originalSize, @@ -2404,8 +2403,8 @@ top: d.position.top - g.top || 0, left: d.position.left - g.left || 0 }, - i = function(b, e) { - a(b).each(function() { + i = function (b, e) { + a(b).each(function () { var b = a(this), f = a(this).data("resizable-alsoresize"), g = {}, @@ -2413,9 +2412,9 @@ e && e.length ? e : b.parents(c.originalElement[0]).length - ? ["width", "height"] - : ["width", "height", "top", "left"]; - a.each(i, function(a, b) { + ? ["width", "height"] + : ["width", "height", "top", "left"]; + (a.each(i, function (a, b) { var c = (f[b] || 0) + (h[b] || 0); c && c >= 0 && (g[b] = c || null); }), @@ -2423,36 +2422,36 @@ /relative/.test(b.css("position")) && ((d._revertToRelativePosition = !0), b.css({ position: "absolute", top: "auto", left: "auto" })), - b.css(g); + b.css(g)); }); }; typeof e.alsoResize == "object" && !e.alsoResize.nodeType - ? a.each(e.alsoResize, function(a, b) { + ? a.each(e.alsoResize, function (a, b) { i(a, b); }) : i(e.alsoResize); }, - stop: function(b, c) { + stop: function (b, c) { var d = a(this).data("resizable"), e = d.options, - f = function(b) { - a(b).each(function() { + f = function (b) { + a(b).each(function () { var b = a(this); b.css({ position: b.data("resizable-alsoresize").position }); }); }; - d._revertToRelativePosition && + (d._revertToRelativePosition && ((d._revertToRelativePosition = !1), typeof e.alsoResize == "object" && !e.alsoResize.nodeType - ? a.each(e.alsoResize, function(a) { + ? a.each(e.alsoResize, function (a) { f(a); }) : f(e.alsoResize)), - a(this).removeData("resizable-alsoresize"); + a(this).removeData("resizable-alsoresize")); } }), a.ui.plugin.add("resizable", "animate", { - stop: function(b, c) { + stop: function (b, c) { var d = a(this).data("resizable"), e = d.options, f = d._proportionallyResizeElements, @@ -2469,22 +2468,22 @@ d.element.animate(a.extend(j, l && k ? { top: l, left: k } : {}), { duration: e.animateDuration, easing: e.animateEasing, - step: function() { + step: function () { var c = { width: parseInt(d.element.css("width"), 10), height: parseInt(d.element.css("height"), 10), top: parseInt(d.element.css("top"), 10), left: parseInt(d.element.css("left"), 10) }; - f && f.length && a(f[0]).css({ width: c.width, height: c.height }), + (f && f.length && a(f[0]).css({ width: c.width, height: c.height }), d._updateCache(c), - d._propagate("resize", b); + d._propagate("resize", b)); } }); } }), a.ui.plugin.add("resizable", "containment", { - start: function(b, d) { + start: function (b, d) { var e = a(this).data("resizable"), f = e.options, g = e.element, @@ -2493,12 +2492,12 @@ h instanceof a ? h.get(0) : /parent/.test(h) - ? g.parent().get(0) - : h; + ? g.parent().get(0) + : h; if (!!i) { e.containerElement = a(i); if (/document/.test(h) || h == document) - (e.containerOffset = { left: 0, top: 0 }), + ((e.containerOffset = { left: 0, top: 0 }), (e.containerPosition = { left: 0, top: 0 }), (e.parentData = { element: a(document), @@ -2507,11 +2506,11 @@ width: a(document).width(), height: a(document).height() || document.body.parentNode.scrollHeight - }); + })); else { var j = a(i), k = []; - a(["Top", "Right", "Left", "Bottom"]).each(function(a, b) { + (a(["Top", "Right", "Left", "Bottom"]).each(function (a, b) { k[a] = c(j.css("padding" + b)); }), (e.containerOffset = j.offset()), @@ -2519,7 +2518,7 @@ (e.containerSize = { height: j.innerHeight() - k[3], width: j.innerWidth() - k[1] - }); + })); var l = e.containerOffset, m = e.containerSize.height, n = e.containerSize.width, @@ -2535,7 +2534,7 @@ } } }, - resize: function(b, c) { + resize: function (b, c) { var d = a(this).data("resizable"), e = d.options, f = d.containerSize, @@ -2545,7 +2544,7 @@ j = d._aspectRatio || b.shiftKey, k = { top: 0, left: 0 }, l = d.containerElement; - l[0] != document && /static/.test(l.css("position")) && (k = g), + (l[0] != document && /static/.test(l.css("position")) && (k = g), i.left < (d._helper ? g.left : 0) && ((d.size.width = d.size.width + @@ -2561,7 +2560,7 @@ j && (d.size.width = d.size.height * e.aspectRatio), (d.position.top = d._helper ? g.top : 0)), (d.offset.left = d.parentData.left + d.position.left), - (d.offset.top = d.parentData.top + d.position.top); + (d.offset.top = d.parentData.top + d.position.top)); var m = Math.abs( (d._helper ? d.offset.left - k.left : d.offset.left - k.left) + d.sizeDiff.width @@ -2572,15 +2571,15 @@ ), o = d.containerElement.get(0) == d.element.parent().get(0), p = /relative|absolute/.test(d.containerElement.css("position")); - o && p && (m -= d.parentData.left), + (o && p && (m -= d.parentData.left), m + d.size.width >= d.parentData.width && ((d.size.width = d.parentData.width - m), j && (d.size.height = d.size.width / d.aspectRatio)), n + d.size.height >= d.parentData.height && ((d.size.height = d.parentData.height - n), - j && (d.size.width = d.size.height * d.aspectRatio)); + j && (d.size.width = d.size.height * d.aspectRatio))); }, - stop: function(b, c) { + stop: function (b, c) { var d = a(this).data("resizable"), e = d.options, f = d.position, @@ -2591,7 +2590,7 @@ k = j.offset(), l = j.outerWidth() - d.sizeDiff.width, m = j.outerHeight() - d.sizeDiff.height; - d._helper && + (d._helper && !e.animate && /relative/.test(i.css("position")) && a(this).css({ left: k.left - h.left - g.left, width: l, height: m }), @@ -2602,15 +2601,15 @@ left: k.left - h.left - g.left, width: l, height: m - }); + })); } }), a.ui.plugin.add("resizable", "ghost", { - start: function(b, c) { + start: function (b, c) { var d = a(this).data("resizable"), e = d.options, f = d.size; - (d.ghost = d.originalElement.clone()), + ((d.ghost = d.originalElement.clone()), d.ghost .css({ opacity: 0.25, @@ -2624,9 +2623,9 @@ }) .addClass("ui-resizable-ghost") .addClass(typeof e.ghost == "string" ? e.ghost : ""), - d.ghost.appendTo(d.helper); + d.ghost.appendTo(d.helper)); }, - resize: function(b, c) { + resize: function (b, c) { var d = a(this).data("resizable"), e = d.options; d.ghost && @@ -2636,14 +2635,14 @@ width: d.size.width }); }, - stop: function(b, c) { + stop: function (b, c) { var d = a(this).data("resizable"), e = d.options; d.ghost && d.helper && d.helper.get(0).removeChild(d.ghost.get(0)); } }), a.ui.plugin.add("resizable", "grid", { - resize: function(b, c) { + resize: function (b, c) { var d = a(this).data("resizable"), e = d.options, f = d.size, @@ -2661,23 +2660,23 @@ /^(se|s|e)$/.test(i) ? ((d.size.width = g.width + k), (d.size.height = g.height + l)) : /^(ne)$/.test(i) - ? ((d.size.width = g.width + k), - (d.size.height = g.height + l), - (d.position.top = h.top - l)) - : /^(sw)$/.test(i) - ? ((d.size.width = g.width + k), - (d.size.height = g.height + l), - (d.position.left = h.left - k)) - : ((d.size.width = g.width + k), - (d.size.height = g.height + l), - (d.position.top = h.top - l), - (d.position.left = h.left - k)); + ? ((d.size.width = g.width + k), + (d.size.height = g.height + l), + (d.position.top = h.top - l)) + : /^(sw)$/.test(i) + ? ((d.size.width = g.width + k), + (d.size.height = g.height + l), + (d.position.left = h.left - k)) + : ((d.size.width = g.width + k), + (d.size.height = g.height + l), + (d.position.top = h.top - l), + (d.position.left = h.left - k)); } - }); - var c = function(a) { + })); + var c = function (a) { return parseInt(a, 10) || 0; }, - d = function(a) { + d = function (a) { return !isNaN(parseInt(a, 10)); }; })(jQuery); @@ -2694,8 +2693,8 @@ * jquery.ui.core.js * jquery.ui.mouse.js * jquery.ui.widget.js - */ (function(a, b) { - a.widget("ui.selectable", a.ui.mouse, { + */ (function (a, b) { + (a.widget("ui.selectable", a.ui.mouse, { options: { appendTo: "body", autoRefresh: !0, @@ -2703,14 +2702,14 @@ filter: "*", tolerance: "touch" }, - _create: function() { + _create: function () { var b = this; - this.element.addClass("ui-selectable"), (this.dragged = !1); + (this.element.addClass("ui-selectable"), (this.dragged = !1)); var c; - (this.refresh = function() { - (c = a(b.options.filter, b.element[0])), + ((this.refresh = function () { + ((c = a(b.options.filter, b.element[0])), c.addClass("ui-selectee"), - c.each(function() { + c.each(function () { var b = a(this), c = b.offset(); a.data(this, "selectable-item", { @@ -2725,28 +2724,28 @@ selecting: b.hasClass("ui-selecting"), unselecting: b.hasClass("ui-unselecting") }); - }); + })); }), this.refresh(), (this.selectees = c.addClass("ui-selectee")), this._mouseInit(), - (this.helper = a("
")); + (this.helper = a("
"))); }, - destroy: function() { - this.selectees.removeClass("ui-selectee").removeData("selectable-item"), + destroy: function () { + (this.selectees.removeClass("ui-selectee").removeData("selectable-item"), this.element .removeClass("ui-selectable ui-selectable-disabled") .removeData("selectable") .unbind(".selectable"), - this._mouseDestroy(); + this._mouseDestroy()); return this; }, - _mouseStart: function(b) { + _mouseStart: function (b) { var c = this; this.opos = [b.pageX, b.pageY]; if (!this.options.disabled) { var d = this.options; - (this.selectees = a(d.filter, this.element[0])), + ((this.selectees = a(d.filter, this.element[0])), this._trigger("start", b), a(d.appendTo).append(this.helper), this.helper.css({ @@ -2756,27 +2755,27 @@ height: 0 }), d.autoRefresh && this.refresh(), - this.selectees.filter(".ui-selected").each(function() { + this.selectees.filter(".ui-selected").each(function () { var d = a.data(this, "selectable-item"); - (d.startselected = !0), + ((d.startselected = !0), !b.metaKey && !b.ctrlKey && (d.$element.removeClass("ui-selected"), (d.selected = !1), d.$element.addClass("ui-unselecting"), (d.unselecting = !0), - c._trigger("unselecting", b, { unselecting: d.element })); + c._trigger("unselecting", b, { unselecting: d.element }))); }), a(b.target) .parents() .andSelf() - .each(function() { + .each(function () { var d = a.data(this, "selectable-item"); if (d) { var e = (!b.metaKey && !b.ctrlKey) || !d.$element.hasClass("ui-selected"); - d.$element + (d.$element .removeClass(e ? "ui-unselecting" : "ui-selected") .addClass(e ? "ui-selecting" : "ui-unselecting"), (d.unselecting = !e), @@ -2784,13 +2783,13 @@ (d.selected = e), e ? c._trigger("selecting", b, { selecting: d.element }) - : c._trigger("unselecting", b, { unselecting: d.element }); + : c._trigger("unselecting", b, { unselecting: d.element })); return !1; } - }); + })); } }, - _mouseDrag: function(b) { + _mouseDrag: function (b) { var c = this; this.dragged = !0; if (!this.options.disabled) { @@ -2801,18 +2800,18 @@ h = b.pageY; if (e > g) { var i = g; - (g = e), (e = i); + ((g = e), (e = i)); } if (f > h) { var i = h; - (h = f), (f = i); + ((h = f), (f = i)); } - this.helper.css({ left: e, top: f, width: g - e, height: h - f }), - this.selectees.each(function() { + (this.helper.css({ left: e, top: f, width: g - e, height: h - f }), + this.selectees.each(function () { var i = a.data(this, "selectable-item"); if (!!i && i.element != c.element[0]) { var j = !1; - d.tolerance == "touch" + (d.tolerance == "touch" ? (j = !( i.left > g || i.right < e || @@ -2856,37 +2855,37 @@ (i.unselecting = !0), c._trigger("unselecting", b, { unselecting: i.element - }))); + })))); } - }); + })); return !1; } }, - _mouseStop: function(b) { + _mouseStop: function (b) { var c = this; this.dragged = !1; var d = this.options; - a(".ui-unselecting", this.element[0]).each(function() { + (a(".ui-unselecting", this.element[0]).each(function () { var d = a.data(this, "selectable-item"); - d.$element.removeClass("ui-unselecting"), + (d.$element.removeClass("ui-unselecting"), (d.unselecting = !1), (d.startselected = !1), - c._trigger("unselected", b, { unselected: d.element }); + c._trigger("unselected", b, { unselected: d.element })); }), - a(".ui-selecting", this.element[0]).each(function() { + a(".ui-selecting", this.element[0]).each(function () { var d = a.data(this, "selectable-item"); - d.$element.removeClass("ui-selecting").addClass("ui-selected"), + (d.$element.removeClass("ui-selecting").addClass("ui-selected"), (d.selecting = !1), (d.selected = !0), (d.startselected = !0), - c._trigger("selected", b, { selected: d.element }); + c._trigger("selected", b, { selected: d.element })); }), this._trigger("stop", b), - this.helper.remove(); + this.helper.remove()); return !1; } }), - a.extend(a.ui.selectable, { version: "1.8.17" }); + a.extend(a.ui.selectable, { version: "1.8.17" })); })(jQuery); /* * jQuery UI Sortable 1.8.17 @@ -2901,8 +2900,8 @@ * jquery.ui.core.js * jquery.ui.mouse.js * jquery.ui.widget.js - */ (function(a, b) { - a.widget("ui.sortable", a.ui.mouse, { + */ (function (a, b) { + (a.widget("ui.sortable", a.ui.mouse, { widgetEventPrefix: "sort", options: { appendTo: "parent", @@ -2928,9 +2927,9 @@ tolerance: "intersect", zIndex: 1e3 }, - _create: function() { + _create: function () { var a = this.options; - (this.containerCache = {}), + ((this.containerCache = {}), this.element.addClass("ui-sortable"), this.refresh(), (this.floating = this.items.length @@ -2939,22 +2938,22 @@ /inline|table-cell/.test(this.items[0].item.css("display")) : !1), (this.offset = this.element.offset()), - this._mouseInit(); + this._mouseInit()); }, - destroy: function() { - this.element.removeClass("ui-sortable ui-sortable-disabled"), - this._mouseDestroy(); + destroy: function () { + (this.element.removeClass("ui-sortable ui-sortable-disabled"), + this._mouseDestroy()); for (var a = this.items.length - 1; a >= 0; a--) this.items[a].item.removeData(this.widgetName + "-item"); return this; }, - _setOption: function(b, c) { + _setOption: function (b, c) { b === "disabled" ? ((this.options[b] = c), this.widget()[c ? "addClass" : "removeClass"]("ui-sortable-disabled")) : a.Widget.prototype._setOption.apply(this, arguments); }, - _mouseCapture: function(b, c) { + _mouseCapture: function (b, c) { var d = this; if (this.reverting) return !1; if (this.options.disabled || this.options.type == "static") return !1; @@ -2963,7 +2962,7 @@ f = this, g = a(b.target) .parents() - .each(function() { + .each(function () { if (a.data(this, d.widgetName + "-item") == f) { e = a(this); return !1; @@ -2976,18 +2975,18 @@ a(this.options.handle, e) .find("*") .andSelf() - .each(function() { + .each(function () { this == b.target && (h = !0); }); if (!h) return !1; } - (this.currentItem = e), this._removeCurrentsFromItems(); + ((this.currentItem = e), this._removeCurrentsFromItems()); return !0; }, - _mouseStart: function(b, c, d) { + _mouseStart: function (b, c, d) { var e = this.options, f = this; - (this.currentContainer = this), + ((this.currentContainer = this), this.refreshPositions(), (this.helper = this._createHelper(b)), this._cacheHelperProportions(), @@ -3035,27 +3034,27 @@ this.scrollParent[0].tagName != "HTML" && (this.overflowOffset = this.scrollParent.offset()), this._trigger("start", b, this._uiHash()), - this._preserveHelperProportions || this._cacheHelperProportions(); + this._preserveHelperProportions || this._cacheHelperProportions()); if (!d) for (var g = this.containers.length - 1; g >= 0; g--) this.containers[g]._trigger("activate", b, f._uiHash(this)); - a.ui.ddmanager && (a.ui.ddmanager.current = this), + (a.ui.ddmanager && (a.ui.ddmanager.current = this), a.ui.ddmanager && !e.dropBehaviour && a.ui.ddmanager.prepareOffsets(this, b), (this.dragging = !0), this.helper.addClass("ui-sortable-helper"), - this._mouseDrag(b); + this._mouseDrag(b)); return !0; }, - _mouseDrag: function(b) { - (this.position = this._generatePosition(b)), + _mouseDrag: function (b) { + ((this.position = this._generatePosition(b)), (this.positionAbs = this._convertPositionTo("absolute")), - this.lastPositionAbs || (this.lastPositionAbs = this.positionAbs); + this.lastPositionAbs || (this.lastPositionAbs = this.positionAbs)); if (this.options.scroll) { var c = this.options, d = !1; - this.scrollParent[0] != document && + (this.scrollParent[0] != document && this.scrollParent[0].tagName != "HTML" ? (this.overflowOffset.top + this.scrollParent[0].offsetHeight - @@ -3096,7 +3095,7 @@ d !== !1 && a.ui.ddmanager && !c.dropBehaviour && - a.ui.ddmanager.prepareOffsets(this, b); + a.ui.ddmanager.prepareOffsets(this, b)); } this.positionAbs = this._convertPositionTo("absolute"); if (!this.options.axis || this.options.axis != "y") @@ -3127,13 +3126,13 @@ break; } } - this._contactContainers(b), + (this._contactContainers(b), a.ui.ddmanager && a.ui.ddmanager.drag(this, b), this._trigger("sort", b, this._uiHash()), - (this.lastPositionAbs = this.positionAbs); + (this.lastPositionAbs = this.positionAbs)); return !1; }, - _mouseStop: function(b, c) { + _mouseStop: function (b, c) { if (!!b) { a.ui.ddmanager && !this.options.dropBehaviour && @@ -3141,7 +3140,7 @@ if (this.options.revert) { var d = this, e = d.placeholder.offset(); - (d.reverting = !0), + ((d.reverting = !0), a(this.helper).animate( { left: @@ -3160,28 +3159,28 @@ : this.offsetParent[0].scrollTop) }, parseInt(this.options.revert, 10) || 500, - function() { + function () { d._clear(b); } - ); + )); } else this._clear(b, c); return !1; } }, - cancel: function() { + cancel: function () { var b = this; if (this.dragging) { - this._mouseUp({ target: null }), + (this._mouseUp({ target: null }), this.options.helper == "original" ? this.currentItem .css(this._storedCSS) .removeClass("ui-sortable-helper") - : this.currentItem.show(); + : this.currentItem.show()); for (var c = this.containers.length - 1; c >= 0; c--) - this.containers[c]._trigger("deactivate", null, b._uiHash(this)), + (this.containers[c]._trigger("deactivate", null, b._uiHash(this)), this.containers[c].containerCache.over && (this.containers[c]._trigger("out", null, b._uiHash(this)), - (this.containers[c].containerCache.over = 0)); + (this.containers[c].containerCache.over = 0))); } this.placeholder && (this.placeholder[0].parentNode && @@ -3201,11 +3200,11 @@ : a(this.domPosition.parent).prepend(this.currentItem)); return this; }, - serialize: function(b) { + serialize: function (b) { var c = this._getItemsAsjQuery(b && b.connected), d = []; - (b = b || {}), - a(c).each(function() { + ((b = b || {}), + a(c).each(function () { var c = (a(b.item || this).attr(b.attribute || "id") || "").match( b.expression || /(.+)[-=_](.+)/ ); @@ -3216,19 +3215,19 @@ (b.key && b.expression ? c[1] : c[2]) ); }), - !d.length && b.key && d.push(b.key + "="); + !d.length && b.key && d.push(b.key + "=")); return d.join("&"); }, - toArray: function(b) { + toArray: function (b) { var c = this._getItemsAsjQuery(b && b.connected), d = []; - (b = b || {}), - c.each(function() { + ((b = b || {}), + c.each(function () { d.push(a(b.item || this).attr(b.attribute || "id") || ""); - }); + })); return d; }, - _intersectsWith: function(a) { + _intersectsWith: function (a) { var b = this.positionAbs.left, c = b + this.helperProportions.width, d = this.positionAbs.top, @@ -3251,7 +3250,7 @@ h < d + this.helperProportions.height / 2 && e - this.helperProportions.height / 2 < i; }, - _intersectsWithPointer: function(b) { + _intersectsWithPointer: function (b) { var c = a.ui.isOverAxis( this.positionAbs.top + this.offset.click.top, b.top, @@ -3272,7 +3271,7 @@ : 1 : f && (f == "down" ? 2 : 1); }, - _intersectsWithSides: function(b) { + _intersectsWithSides: function (b) { var c = a.ui.isOverAxis( this.positionAbs.top + this.offset.click.top, b.top + b.height / 2, @@ -3289,25 +3288,25 @@ ? (f == "right" && d) || (f == "left" && !d) : e && ((e == "down" && c) || (e == "up" && !c)); }, - _getDragVerticalDirection: function() { + _getDragVerticalDirection: function () { var a = this.positionAbs.top - this.lastPositionAbs.top; return a != 0 && (a > 0 ? "down" : "up"); }, - _getDragHorizontalDirection: function() { + _getDragHorizontalDirection: function () { var a = this.positionAbs.left - this.lastPositionAbs.left; return a != 0 && (a > 0 ? "right" : "left"); }, - refresh: function(a) { - this._refreshItems(a), this.refreshPositions(); + refresh: function (a) { + (this._refreshItems(a), this.refreshPositions()); return this; }, - _connectWith: function() { + _connectWith: function () { var a = this.options; return a.connectWith.constructor == String ? [a.connectWith] : a.connectWith; }, - _getItemsAsjQuery: function(b) { + _getItemsAsjQuery: function (b) { var c = this, d = [], e = [], @@ -3342,19 +3341,19 @@ this ]); for (var g = e.length - 1; g >= 0; g--) - e[g][0].each(function() { + e[g][0].each(function () { d.push(this); }); return a(d); }, - _removeCurrentsFromItems: function() { + _removeCurrentsFromItems: function () { var a = this.currentItem.find(":data(" + this.widgetName + "-item)"); for (var b = 0; b < this.items.length; b++) for (var c = 0; c < a.length; c++) a[c] == this.items[b].item[0] && this.items.splice(b, 1); }, - _refreshItems: function(b) { - (this.items = []), (this.containers = [this]); + _refreshItems: function (b) { + ((this.items = []), (this.containers = [this])); var c = this.items, d = this, e = [ @@ -3392,7 +3391,7 @@ l = e[g][0]; for (var i = 0, m = l.length; i < m; i++) { var n = a(l[i]); - n.data(this.widgetName + "-item", k), + (n.data(this.widgetName + "-item", k), c.push({ item: n, instance: k, @@ -3400,11 +3399,11 @@ height: 0, left: 0, top: 0 - }); + })); } } }, - refreshPositions: function(b) { + refreshPositions: function (b) { this.offsetParent && this.helper && (this.offset.parent = this._getParentOffset()); @@ -3421,31 +3420,29 @@ : d.item; b || ((d.width = e.outerWidth()), (d.height = e.outerHeight())); var f = e.offset(); - (d.left = f.left), (d.top = f.top); + ((d.left = f.left), (d.top = f.top)); } if (this.options.custom && this.options.custom.refreshContainers) this.options.custom.refreshContainers.call(this); else for (var c = this.containers.length - 1; c >= 0; c--) { var f = this.containers[c].element.offset(); - (this.containers[c].containerCache.left = f.left), + ((this.containers[c].containerCache.left = f.left), (this.containers[c].containerCache.top = f.top), - (this.containers[c].containerCache.width = this.containers[ - c - ].element.outerWidth()), - (this.containers[c].containerCache.height = this.containers[ - c - ].element.outerHeight()); + (this.containers[c].containerCache.width = + this.containers[c].element.outerWidth()), + (this.containers[c].containerCache.height = + this.containers[c].element.outerHeight())); } return this; }, - _createPlaceholder: function(b) { + _createPlaceholder: function (b) { var c = b || this, d = c.options; if (!d.placeholder || d.placeholder.constructor == String) { var e = d.placeholder; d.placeholder = { - element: function() { + element: function () { var b = a(document.createElement(c.currentItem[0].nodeName)) .addClass( e || c.currentItem[0].className + " ui-sortable-placeholder" @@ -3454,9 +3451,9 @@ e || (b.style.visibility = "hidden"); return b; }, - update: function(a, b) { + update: function (a, b) { if (!e || !!d.forcePlaceholderSize) - b.height() || + (b.height() || b.height( c.currentItem.innerHeight() - parseInt(c.currentItem.css("paddingTop") || 0, 10) - @@ -3467,15 +3464,17 @@ c.currentItem.innerWidth() - parseInt(c.currentItem.css("paddingLeft") || 0, 10) - parseInt(c.currentItem.css("paddingRight") || 0, 10) - ); + )); } }; } - (c.placeholder = a(d.placeholder.element.call(c.element, c.currentItem))), + ((c.placeholder = a( + d.placeholder.element.call(c.element, c.currentItem) + )), c.currentItem.after(c.placeholder), - d.placeholder.update(c, c.placeholder); + d.placeholder.update(c, c.placeholder)); }, - _contactContainers: function(b) { + _contactContainers: function (b) { var c = null, d = null; for (var e = this.containers.length - 1; e >= 0; e--) { @@ -3484,7 +3483,7 @@ if (this._intersectsWith(this.containers[e].containerCache)) { if (c && a.ui.contains(this.containers[e].element[0], c.element[0])) continue; - (c = this.containers[e]), (d = e); + ((c = this.containers[e]), (d = e)); } else this.containers[e].containerCache.over && (this.containers[e]._trigger("out", b, this._uiHash(this)), @@ -3492,8 +3491,8 @@ } if (!!c) if (this.containers.length === 1) - this.containers[d]._trigger("over", b, this._uiHash(this)), - (this.containers[d].containerCache.over = 1); + (this.containers[d]._trigger("over", b, this._uiHash(this)), + (this.containers[d].containerCache.over = 1)); else if (this.currentContainer != this.containers[d]) { var f = 1e4, g = null, @@ -3510,7 +3509,7 @@ Math.abs(j - h) < f && ((f = Math.abs(j - h)), (g = this.items[i])); } if (!g && !this.options.dropOnEmpty) return; - (this.currentContainer = this.containers[d]), + ((this.currentContainer = this.containers[d]), g ? this._rearrange(b, g, null, !0) : this._rearrange(b, null, this.containers[d].element, !0), @@ -3521,17 +3520,17 @@ this.placeholder ), this.containers[d]._trigger("over", b, this._uiHash(this)), - (this.containers[d].containerCache.over = 1); + (this.containers[d].containerCache.over = 1)); } }, - _createHelper: function(b) { + _createHelper: function (b) { var c = this.options, d = a.isFunction(c.helper) ? a(c.helper.apply(this.element[0], [b, this.currentItem])) : c.helper == "clone" - ? this.currentItem.clone() - : this.currentItem; - d.parents("body").length || + ? this.currentItem.clone() + : this.currentItem; + (d.parents("body").length || a( c.appendTo != "parent" ? c.appendTo : this.currentItem[0].parentNode )[0].appendChild(d[0]), @@ -3546,11 +3545,11 @@ (d[0].style.width == "" || c.forceHelperSize) && d.width(this.currentItem.width()), (d[0].style.height == "" || c.forceHelperSize) && - d.height(this.currentItem.height()); + d.height(this.currentItem.height())); return d; }, - _adjustOffsetFromHelper: function(b) { - typeof b == "string" && (b = b.split(" ")), + _adjustOffsetFromHelper: function (b) { + (typeof b == "string" && (b = b.split(" ")), a.isArray(b) && (b = { left: +b[0], top: +b[1] || 0 }), "left" in b && (this.offset.click.left = b.left + this.margins.left), "right" in b && @@ -3559,9 +3558,9 @@ "top" in b && (this.offset.click.top = b.top + this.margins.top), "bottom" in b && (this.offset.click.top = - this.helperProportions.height - b.bottom + this.margins.top); + this.helperProportions.height - b.bottom + this.margins.top)); }, - _getParentOffset: function() { + _getParentOffset: function () { this.offsetParent = this.helper.offsetParent(); var b = this.offsetParent.offset(); this.cssPosition == "absolute" && @@ -3583,7 +3582,7 @@ b.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0) }; }, - _getRelativeOffset: function() { + _getRelativeOffset: function () { if (this.cssPosition == "relative") { var a = this.currentItem.position(); return { @@ -3599,19 +3598,19 @@ } return { top: 0, left: 0 }; }, - _cacheMargins: function() { + _cacheMargins: function () { this.margins = { left: parseInt(this.currentItem.css("marginLeft"), 10) || 0, top: parseInt(this.currentItem.css("marginTop"), 10) || 0 }; }, - _cacheHelperProportions: function() { + _cacheHelperProportions: function () { this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() }; }, - _setContainment: function() { + _setContainment: function () { var b = this.options; b.containment == "parent" && (b.containment = this.helper[0].parentNode); if (b.containment == "document" || b.containment == "window") @@ -3654,7 +3653,7 @@ ]; } }, - _convertPositionTo: function(b, c) { + _convertPositionTo: function (b, c) { c || (c = this.position); var d = b == "absolute" ? 1 : -1, e = this.options, @@ -3675,8 +3674,8 @@ : (this.cssPosition == "fixed" ? -this.scrollParent.scrollTop() : g - ? 0 - : f.scrollTop()) * d), + ? 0 + : f.scrollTop()) * d), left: c.left + this.offset.relative.left * d + @@ -3686,11 +3685,11 @@ : (this.cssPosition == "fixed" ? -this.scrollParent.scrollLeft() : g - ? 0 - : f.scrollLeft()) * d) + ? 0 + : f.scrollLeft()) * d) }; }, - _generatePosition: function(b) { + _generatePosition: function (b) { var c = this.options, d = this.cssPosition == "absolute" && @@ -3749,10 +3748,10 @@ (a.browser.safari && this.cssPosition == "fixed" ? 0 : this.cssPosition == "fixed" - ? -this.scrollParent.scrollTop() - : e - ? 0 - : d.scrollTop()), + ? -this.scrollParent.scrollTop() + : e + ? 0 + : d.scrollTop()), left: f - this.offset.click.left - @@ -3761,43 +3760,43 @@ (a.browser.safari && this.cssPosition == "fixed" ? 0 : this.cssPosition == "fixed" - ? -this.scrollParent.scrollLeft() - : e - ? 0 - : d.scrollLeft()) + ? -this.scrollParent.scrollLeft() + : e + ? 0 + : d.scrollLeft()) }; }, - _rearrange: function(a, b, c, d) { - c + _rearrange: function (a, b, c, d) { + (c ? c[0].appendChild(this.placeholder[0]) : b.item[0].parentNode.insertBefore( this.placeholder[0], this.direction == "down" ? b.item[0] : b.item[0].nextSibling ), - (this.counter = this.counter ? ++this.counter : 1); + (this.counter = this.counter ? ++this.counter : 1)); var e = this, f = this.counter; - window.setTimeout(function() { + window.setTimeout(function () { f == e.counter && e.refreshPositions(!d); }, 0); }, - _clear: function(b, c) { + _clear: function (b, c) { this.reverting = !1; var d = [], e = this; - !this._noFinalSort && + (!this._noFinalSort && this.currentItem.parent().length && this.placeholder.before(this.currentItem), - (this._noFinalSort = null); + (this._noFinalSort = null)); if (this.helper[0] == this.currentItem[0]) { for (var f in this._storedCSS) if (this._storedCSS[f] == "auto" || this._storedCSS[f] == "static") this._storedCSS[f] = ""; this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"); } else this.currentItem.show(); - this.fromOutside && + (this.fromOutside && !c && - d.push(function(a) { + d.push(function (a) { this._trigger("receive", a, this._uiHash(this.fromOutside)); }), (this.fromOutside || @@ -3805,58 +3804,58 @@ this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) && !c && - d.push(function(a) { + d.push(function (a) { this._trigger("update", a, this._uiHash()); - }); + })); if (!a.ui.contains(this.element[0], this.currentItem[0])) { c || - d.push(function(a) { + d.push(function (a) { this._trigger("remove", a, this._uiHash()); }); for (var f = this.containers.length - 1; f >= 0; f--) a.ui.contains(this.containers[f].element[0], this.currentItem[0]) && !c && (d.push( - function(a) { - return function(b) { + function (a) { + return function (b) { a._trigger("receive", b, this._uiHash(this)); }; }.call(this, this.containers[f]) ), d.push( - function(a) { - return function(b) { + function (a) { + return function (b) { a._trigger("update", b, this._uiHash(this)); }; }.call(this, this.containers[f]) )); } for (var f = this.containers.length - 1; f >= 0; f--) - c || + (c || d.push( - function(a) { - return function(b) { + function (a) { + return function (b) { a._trigger("deactivate", b, this._uiHash(this)); }; }.call(this, this.containers[f]) ), this.containers[f].containerCache.over && (d.push( - function(a) { - return function(b) { + function (a) { + return function (b) { a._trigger("out", b, this._uiHash(this)); }; }.call(this, this.containers[f]) ), - (this.containers[f].containerCache.over = 0)); - this._storedCursor && a("body").css("cursor", this._storedCursor), + (this.containers[f].containerCache.over = 0))); + (this._storedCursor && a("body").css("cursor", this._storedCursor), this._storedOpacity && this.helper.css("opacity", this._storedOpacity), this._storedZIndex && this.helper.css( "zIndex", this._storedZIndex == "auto" ? "" : this._storedZIndex ), - (this.dragging = !1); + (this.dragging = !1)); if (this.cancelHelperRemoval) { if (!c) { this._trigger("beforeStop", b, this._uiHash()); @@ -3865,10 +3864,10 @@ } return !1; } - c || this._trigger("beforeStop", b, this._uiHash()), + (c || this._trigger("beforeStop", b, this._uiHash()), this.placeholder[0].parentNode.removeChild(this.placeholder[0]), this.helper[0] != this.currentItem[0] && this.helper.remove(), - (this.helper = null); + (this.helper = null)); if (!c) { for (var f = 0; f < d.length; f++) d[f].call(this, b); this._trigger("stop", b, this._uiHash()); @@ -3876,11 +3875,11 @@ this.fromOutside = !1; return !0; }, - _trigger: function() { + _trigger: function () { a.Widget.prototype._trigger.apply(this, arguments) === !1 && this.cancel(); }, - _uiHash: function(b) { + _uiHash: function (b) { var c = b || this; return { helper: c.helper, @@ -3893,7 +3892,7 @@ }; } }), - a.extend(a.ui.sortable, { version: "1.8.17" }); + a.extend(a.ui.sortable, { version: "1.8.17" })); })(jQuery); /* * jQuery UI Accordion 1.8.17 @@ -3907,8 +3906,8 @@ * Depends: * jquery.ui.core.js * jquery.ui.widget.js - */ (function(a, b) { - a.widget("ui.accordion", { + */ (function (a, b) { + (a.widget("ui.accordion", { options: { active: 0, animated: "slide", @@ -3923,14 +3922,14 @@ headerSelected: "ui-icon-triangle-1-s" }, navigation: !1, - navigationFilter: function() { + navigationFilter: function () { return this.href.toLowerCase() === location.href.toLowerCase(); } }, - _create: function() { + _create: function () { var b = this, c = b.options; - (b.running = 0), + ((b.running = 0), b.element .addClass("ui-accordion ui-widget ui-helper-reset") .children("li") @@ -3940,28 +3939,25 @@ .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" ) - .bind("mouseenter.accordion", function() { + .bind("mouseenter.accordion", function () { c.disabled || a(this).addClass("ui-state-hover"); }) - .bind("mouseleave.accordion", function() { + .bind("mouseleave.accordion", function () { c.disabled || a(this).removeClass("ui-state-hover"); }) - .bind("focus.accordion", function() { + .bind("focus.accordion", function () { c.disabled || a(this).addClass("ui-state-focus"); }) - .bind("blur.accordion", function() { + .bind("blur.accordion", function () { c.disabled || a(this).removeClass("ui-state-focus"); })), b.headers .next() .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" - ); + )); if (c.navigation) { - var d = b.element - .find("a") - .filter(c.navigationFilter) - .eq(0); + var d = b.element.find("a").filter(c.navigationFilter).eq(0); if (d.length) { var e = d.closest(".ui-accordion-header"); e.length @@ -3969,7 +3965,7 @@ : (b.active = d.closest(".ui-accordion-content").prev()); } } - (b.active = b + ((b.active = b ._findActive(b.active || c.active) .addClass("ui-state-default ui-state-active") .toggleClass("ui-corner-all") @@ -3980,7 +3976,7 @@ b.element.attr("role", "tablist"), b.headers .attr("role", "tab") - .bind("keydown.accordion", function(a) { + .bind("keydown.accordion", function (a) { return b._keydown(a); }) .next() @@ -4005,12 +4001,12 @@ c.event && b.headers.bind( c.event.split(" ").join(".accordion ") + ".accordion", - function(a) { - b._clickHandler.call(b, a, this), a.preventDefault(); + function (a) { + (b._clickHandler.call(b, a, this), a.preventDefault()); } - ); + )); }, - _createIcons: function() { + _createIcons: function () { var b = this.options; b.icons && (a("") @@ -4022,13 +4018,13 @@ .toggleClass(b.icons.headerSelected), this.element.addClass("ui-accordion-icons")); }, - _destroyIcons: function() { - this.headers.children(".ui-icon").remove(), - this.element.removeClass("ui-accordion-icons"); + _destroyIcons: function () { + (this.headers.children(".ui-icon").remove(), + this.element.removeClass("ui-accordion-icons")); }, - destroy: function() { + destroy: function () { var b = this.options; - this.element + (this.element .removeClass("ui-accordion ui-widget ui-helper-reset") .removeAttr("role"), this.headers @@ -4041,7 +4037,7 @@ .removeAttr("aria-selected") .removeAttr("tabIndex"), this.headers.find("a").removeAttr("tabIndex"), - this._destroyIcons(); + this._destroyIcons()); var c = this.headers .next() .css("display", "") @@ -4052,8 +4048,8 @@ (b.autoHeight || b.fillHeight) && c.css("height", ""); return a.Widget.prototype.destroy.call(this); }, - _setOption: function(b, c) { - a.Widget.prototype._setOption.apply(this, arguments), + _setOption: function (b, c) { + (a.Widget.prototype._setOption.apply(this, arguments), b == "active" && this.activate(c), b == "icons" && (this._destroyIcons(), c && this._createIcons()), b == "disabled" && @@ -4061,9 +4057,9 @@ .add(this.headers.next()) [c ? "addClass" : "removeClass"]( "ui-accordion-disabled ui-state-disabled" - ); + )); }, - _keydown: function(b) { + _keydown: function (b) { if (!(this.options.disabled || b.altKey || b.ctrlKey)) { var c = a.ui.keyCode, d = this.headers.length, @@ -4080,17 +4076,19 @@ break; case c.SPACE: case c.ENTER: - this._clickHandler({ target: b.target }, b.target), - b.preventDefault(); + (this._clickHandler({ target: b.target }, b.target), + b.preventDefault()); } if (f) { - a(b.target).attr("tabIndex", -1), a(f).attr("tabIndex", 0), f.focus(); + (a(b.target).attr("tabIndex", -1), + a(f).attr("tabIndex", 0), + f.focus()); return !1; } return !0; } }, - resize: function() { + resize: function () { var b = this.options, c; if (b.fillSpace) { @@ -4098,62 +4096,57 @@ var d = this.element.parent().css("overflow"); this.element.parent().css("overflow", "hidden"); } - (c = this.element.parent().height()), + ((c = this.element.parent().height()), a.browser.msie && this.element.parent().css("overflow", d), - this.headers.each(function() { + this.headers.each(function () { c -= a(this).outerHeight(!0); }), this.headers .next() - .each(function() { + .each(function () { a(this).height( Math.max(0, c - a(this).innerHeight() + a(this).height()) ); }) - .css("overflow", "auto"); + .css("overflow", "auto")); } else b.autoHeight && ((c = 0), this.headers .next() - .each(function() { - c = Math.max( - c, - a(this) - .height("") - .height() - ); + .each(function () { + c = Math.max(c, a(this).height("").height()); }) .height(c)); return this; }, - activate: function(a) { + activate: function (a) { this.options.active = a; var b = this._findActive(a)[0]; this._clickHandler({ target: b }, b); return this; }, - _findActive: function(b) { + _findActive: function (b) { return b ? typeof b == "number" ? this.headers.filter(":eq(" + b + ")") : this.headers.not(this.headers.not(b)) : b === !1 - ? a([]) - : this.headers.filter(":eq(0)"); + ? a([]) + : this.headers.filter(":eq(0)"); }, - _clickHandler: function(b, c) { + _clickHandler: function (b, c) { var d = this.options; if (!d.disabled) { if (!b.target) { if (!d.collapsible) return; - this.active + (this.active .removeClass("ui-state-active ui-corner-top") .addClass("ui-state-default ui-corner-all") .children(".ui-icon") .removeClass(d.icons.headerSelected) .addClass(d.icons.header), - this.active.next().addClass("ui-accordion-content-active"); + this.active.next().addClass("ui-accordion-content-active")); var e = this.active.next(), f = { options: d, @@ -4181,7 +4174,7 @@ oldContent: e }, k = this.headers.index(this.active[0]) > this.headers.index(h[0]); - (this.active = i ? a([]) : h), + ((this.active = i ? a([]) : h), this._toggle(g, e, f, i, k), j .removeClass("ui-state-active ui-corner-top") @@ -4196,22 +4189,22 @@ .children(".ui-icon") .removeClass(d.icons.header) .addClass(d.icons.headerSelected), - h.next().addClass("ui-accordion-content-active")); + h.next().addClass("ui-accordion-content-active"))); return; } }, - _toggle: function(b, c, d, e, f) { + _toggle: function (b, c, d, e, f) { var g = this, h = g.options; - (g.toShow = b), (g.toHide = c), (g.data = d); - var i = function() { + ((g.toShow = b), (g.toHide = c), (g.data = d)); + var i = function () { if (!!g) return g._completed.apply(g, arguments); }; - g._trigger("changestart", null, g.data), - (g.running = c.size() === 0 ? b.size() : c.size()); + (g._trigger("changestart", null, g.data), + (g.running = c.size() === 0 ? b.size() : c.size())); if (h.animated) { var j = {}; - h.collapsible && e + (h.collapsible && e ? (j = { toShow: a([]), toHide: c, @@ -4231,18 +4224,18 @@ (h.animated = a.isFunction(h.proxied) ? h.proxied(j) : h.proxied), (h.duration = a.isFunction(h.proxiedDuration) ? h.proxiedDuration(j) - : h.proxiedDuration); + : h.proxiedDuration)); var k = a.ui.accordion.animations, l = h.duration, m = h.animated; - m && !k[m] && !a.easing[m] && (m = "slide"), + (m && !k[m] && !a.easing[m] && (m = "slide"), k[m] || - (k[m] = function(a) { + (k[m] = function (a) { this.slide(a, { easing: m, duration: l || 700 }); }), - k[m](j); - } else h.collapsible && e ? b.toggle() : (c.hide(), b.show()), i(!0); - c + k[m](j)); + } else (h.collapsible && e ? b.toggle() : (c.hide(), b.show()), i(!0)); + (c .prev() .attr({ "aria-expanded": "false", @@ -4257,23 +4250,24 @@ "aria-selected": "true", tabIndex: 0 }) - .focus(); + .focus()); }, - _completed: function(a) { + _completed: function (a) { this.running = a ? 0 : --this.running; this.running || (this.options.clearStyle && this.toShow.add(this.toHide).css({ height: "", overflow: "" }), this.toHide.removeClass("ui-accordion-content-active"), this.toHide.length && - (this.toHide.parent()[0].className = this.toHide.parent()[0].className), + (this.toHide.parent()[0].className = + this.toHide.parent()[0].className), this._trigger("change", null, this.data)); } }), a.extend(a.ui.accordion, { version: "1.8.17", animations: { - slide: function(b, c) { + slide: function (b, c) { b = a.extend({ easing: "swing", duration: 300 }, b, c); if (!b.toHide.size()) b.toShow.animate( @@ -4295,7 +4289,7 @@ h = ["height", "paddingTop", "paddingBottom"], i, j = b.toShow; - (i = j[0].style.width), + ((i = j[0].style.width), j.width( j.parent().width() - parseFloat(j.css("paddingLeft")) - @@ -4303,7 +4297,7 @@ (parseFloat(j.css("borderLeftWidth")) || 0) - (parseFloat(j.css("borderRightWidth")) || 0) ), - a.each(h, function(c, d) { + a.each(h, function (c, d) { g[d] = "hide"; var e = ("" + a.css(b.toShow[0], d)).match(/^([\d+-.]+)(.*)$/); f[d] = { value: e[1], unit: e[2] || "px" }; @@ -4315,33 +4309,33 @@ .end() .filter(":visible") .animate(g, { - step: function(a, c) { - c.prop == "height" && + step: function (a, c) { + (c.prop == "height" && (e = c.end - c.start === 0 ? 0 : (c.now - c.start) / (c.end - c.start)), (b.toShow[0].style[c.prop] = - e * f[c.prop].value + f[c.prop].unit); + e * f[c.prop].value + f[c.prop].unit)); }, duration: b.duration, easing: b.easing, - complete: function() { - b.autoHeight || b.toShow.css("height", ""), + complete: function () { + (b.autoHeight || b.toShow.css("height", ""), b.toShow.css({ width: i, overflow: d }), - b.complete(); + b.complete()); } - }); + })); } }, - bounceslide: function(a) { + bounceslide: function (a) { this.slide(a, { easing: a.down ? "easeOutBounce" : "swing", duration: a.down ? 1e3 : 200 }); } } - }); + })); })(jQuery); /* * jQuery UI Autocomplete 1.8.17 @@ -4356,9 +4350,9 @@ * jquery.ui.core.js * jquery.ui.widget.js * jquery.ui.position.js - */ (function(a, b) { + */ ((function (a, b) { var c = 0; - a.widget("ui.autocomplete", { + (a.widget("ui.autocomplete", { options: { appendTo: "body", autoFocus: !1, @@ -4368,11 +4362,11 @@ source: null }, pending: 0, - _create: function() { + _create: function () { var b = this, c = this.element[0].ownerDocument, d; - this.element + (this.element .addClass("ui-autocomplete-input") .attr("autocomplete", "off") .attr({ @@ -4380,7 +4374,7 @@ "aria-autocomplete": "list", "aria-haspopup": "true" }) - .bind("keydown.autocomplete", function(c) { + .bind("keydown.autocomplete", function (c) { if (!b.options.disabled && !b.element.propAttr("readOnly")) { d = !1; var e = a.ui.keyCode; @@ -4392,10 +4386,10 @@ b._move("nextPage", c); break; case e.UP: - b._move("previous", c), c.preventDefault(); + (b._move("previous", c), c.preventDefault()); break; case e.DOWN: - b._move("next", c), c.preventDefault(); + (b._move("next", c), c.preventDefault()); break; case e.ENTER: case e.NUMPAD_ENTER: @@ -4405,76 +4399,76 @@ b.menu.select(c); break; case e.ESCAPE: - b.element.val(b.term), b.close(c); + (b.element.val(b.term), b.close(c)); break; default: - clearTimeout(b.searching), - (b.searching = setTimeout(function() { + (clearTimeout(b.searching), + (b.searching = setTimeout(function () { b.term != b.element.val() && ((b.selectedItem = null), b.search(null, c)); - }, b.options.delay)); + }, b.options.delay))); } } }) - .bind("keypress.autocomplete", function(a) { + .bind("keypress.autocomplete", function (a) { d && ((d = !1), a.preventDefault()); }) - .bind("focus.autocomplete", function() { + .bind("focus.autocomplete", function () { b.options.disabled || ((b.selectedItem = null), (b.previous = b.element.val())); }) - .bind("blur.autocomplete", function(a) { + .bind("blur.autocomplete", function (a) { b.options.disabled || (clearTimeout(b.searching), - (b.closing = setTimeout(function() { - b.close(a), b._change(a); + (b.closing = setTimeout(function () { + (b.close(a), b._change(a)); }, 150))); }), this._initSource(), - (this.response = function() { + (this.response = function () { return b._response.apply(b, arguments); }), (this.menu = a("
    ") .addClass("ui-autocomplete") .appendTo(a(this.options.appendTo || "body", c)[0]) - .mousedown(function(c) { + .mousedown(function (c) { var d = b.menu.element[0]; - a(c.target).closest(".ui-menu-item").length || - setTimeout(function() { - a(document).one("mousedown", function(c) { + (a(c.target).closest(".ui-menu-item").length || + setTimeout(function () { + a(document).one("mousedown", function (c) { c.target !== b.element[0] && c.target !== d && !a.ui.contains(d, c.target) && b.close(); }); }, 1), - setTimeout(function() { + setTimeout(function () { clearTimeout(b.closing); - }, 13); + }, 13)); }) .menu({ - focus: function(a, c) { + focus: function (a, c) { var d = c.item.data("item.autocomplete"); !1 !== b._trigger("focus", a, { item: d }) && /^key/.test(a.originalEvent.type) && b.element.val(d.value); }, - selected: function(a, d) { + selected: function (a, d) { var e = d.item.data("item.autocomplete"), f = b.previous; - b.element[0] !== c.activeElement && + (b.element[0] !== c.activeElement && (b.element.focus(), (b.previous = f), - setTimeout(function() { - (b.previous = f), (b.selectedItem = e); + setTimeout(function () { + ((b.previous = f), (b.selectedItem = e)); }, 1)), !1 !== b._trigger("select", a, { item: e }) && b.element.val(e.value), (b.term = b.element.val()), b.close(a), - (b.selectedItem = e); + (b.selectedItem = e)); }, - blur: function(a, c) { + blur: function (a, c) { b.menu.element.is(":visible") && b.element.val() !== b.term && b.element.val(b.term); @@ -4485,13 +4479,13 @@ .hide() .data("menu")), a.fn.bgiframe && this.menu.element.bgiframe(), - (b.beforeunloadHandler = function() { + (b.beforeunloadHandler = function () { b.element.removeAttr("autocomplete"); }), - a(window).bind("beforeunload", b.beforeunloadHandler); + a(window).bind("beforeunload", b.beforeunloadHandler)); }, - destroy: function() { - this.element + destroy: function () { + (this.element .removeClass("ui-autocomplete-input") .removeAttr("autocomplete") .removeAttr("role") @@ -4499,78 +4493,78 @@ .removeAttr("aria-haspopup"), this.menu.element.remove(), a(window).unbind("beforeunload", this.beforeunloadHandler), - a.Widget.prototype.destroy.call(this); + a.Widget.prototype.destroy.call(this)); }, - _setOption: function(b, c) { - a.Widget.prototype._setOption.apply(this, arguments), + _setOption: function (b, c) { + (a.Widget.prototype._setOption.apply(this, arguments), b === "source" && this._initSource(), b === "appendTo" && this.menu.element.appendTo( a(c || "body", this.element[0].ownerDocument)[0] ), - b === "disabled" && c && this.xhr && this.xhr.abort(); + b === "disabled" && c && this.xhr && this.xhr.abort()); }, - _initSource: function() { + _initSource: function () { var b = this, d, e; a.isArray(this.options.source) ? ((d = this.options.source), - (this.source = function(b, c) { + (this.source = function (b, c) { c(a.ui.autocomplete.filter(d, b.term)); })) : typeof this.options.source == "string" - ? ((e = this.options.source), - (this.source = function(d, f) { - b.xhr && b.xhr.abort(), - (b.xhr = a.ajax({ - url: e, - data: d, - dataType: "json", - autocompleteRequest: ++c, - success: function(a, b) { - this.autocompleteRequest === c && f(a); - }, - error: function() { - this.autocompleteRequest === c && f([]); - } - })); - })) - : (this.source = this.options.source); + ? ((e = this.options.source), + (this.source = function (d, f) { + (b.xhr && b.xhr.abort(), + (b.xhr = a.ajax({ + url: e, + data: d, + dataType: "json", + autocompleteRequest: ++c, + success: function (a, b) { + this.autocompleteRequest === c && f(a); + }, + error: function () { + this.autocompleteRequest === c && f([]); + } + }))); + })) + : (this.source = this.options.source); }, - search: function(a, b) { - (a = a != null ? a : this.element.val()), - (this.term = this.element.val()); + search: function (a, b) { + ((a = a != null ? a : this.element.val()), + (this.term = this.element.val())); if (a.length < this.options.minLength) return this.close(b); clearTimeout(this.closing); if (this._trigger("search", b) !== !1) return this._search(a); }, - _search: function(a) { - this.pending++, + _search: function (a) { + (this.pending++, this.element.addClass("ui-autocomplete-loading"), - this.source({ term: a }, this.response); + this.source({ term: a }, this.response)); }, - _response: function(a) { - !this.options.disabled && a && a.length + _response: function (a) { + (!this.options.disabled && a && a.length ? ((a = this._normalize(a)), this._suggest(a), this._trigger("open")) : this.close(), this.pending--, - this.pending || this.element.removeClass("ui-autocomplete-loading"); + this.pending || this.element.removeClass("ui-autocomplete-loading")); }, - close: function(a) { - clearTimeout(this.closing), + close: function (a) { + (clearTimeout(this.closing), this.menu.element.is(":visible") && (this.menu.element.hide(), this.menu.deactivate(), - this._trigger("close", a)); + this._trigger("close", a))); }, - _change: function(a) { + _change: function (a) { this.previous !== this.element.val() && this._trigger("change", a, { item: this.selectedItem }); }, - _normalize: function(b) { + _normalize: function (b) { if (b.length && b[0].label && b[0].value) return b; - return a.map(b, function(b) { + return a.map(b, function (b) { if (typeof b == "string") return { label: b, value: b }; return a.extend( { label: b.label || b.value, value: b.value || b.label }, @@ -4578,80 +4572,80 @@ ); }); }, - _suggest: function(b) { + _suggest: function (b) { var c = this.menu.element.empty().zIndex(this.element.zIndex() + 1); - this._renderMenu(c, b), + (this._renderMenu(c, b), this.menu.deactivate(), this.menu.refresh(), c.show(), this._resizeMenu(), c.position(a.extend({ of: this.element }, this.options.position)), - this.options.autoFocus && this.menu.next(new a.Event("mouseover")); + this.options.autoFocus && this.menu.next(new a.Event("mouseover"))); }, - _resizeMenu: function() { + _resizeMenu: function () { var a = this.menu.element; a.outerWidth( Math.max(a.width("").outerWidth() + 1, this.element.outerWidth()) ); }, - _renderMenu: function(b, c) { + _renderMenu: function (b, c) { var d = this; - a.each(c, function(a, c) { + a.each(c, function (a, c) { d._renderItem(b, c); }); }, - _renderItem: function(b, c) { + _renderItem: function (b, c) { return a("
  • ") .data("item.autocomplete", c) .append(a("").text(c.label)) .appendTo(b); }, - _move: function(a, b) { + _move: function (a, b) { if (!this.menu.element.is(":visible")) this.search(null, b); else { if ( (this.menu.first() && /^previous/.test(a)) || (this.menu.last() && /^next/.test(a)) ) { - this.element.val(this.term), this.menu.deactivate(); + (this.element.val(this.term), this.menu.deactivate()); return; } this.menu[a](b); } }, - widget: function() { + widget: function () { return this.menu.element; } }), a.extend(a.ui.autocomplete, { - escapeRegex: function(a) { + escapeRegex: function (a) { return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); }, - filter: function(b, c) { + filter: function (b, c) { var d = new RegExp(a.ui.autocomplete.escapeRegex(c), "i"); - return a.grep(b, function(a) { + return a.grep(b, function (a) { return d.test(a.label || a.value || a); }); } - }); + })); })(jQuery), - (function(a) { + (function (a) { a.widget("ui.menu", { - _create: function() { + _create: function () { var b = this; - this.element + (this.element .addClass("ui-menu ui-widget ui-widget-content ui-corner-all") .attr({ role: "listbox", "aria-activedescendant": "ui-active-menuitem" }) - .click(function(c) { + .click(function (c) { !a(c.target).closest(".ui-menu-item a").length || (c.preventDefault(), b.select(c)); }), - this.refresh(); + this.refresh()); }, - refresh: function() { + refresh: function () { var b = this, c = this.element .children("li:not(.ui-menu-item):has(a)") @@ -4660,14 +4654,14 @@ c.children("a") .addClass("ui-corner-all") .attr("tabindex", -1) - .mouseenter(function(c) { + .mouseenter(function (c) { b.activate(c, a(this).parent()); }) - .mouseleave(function() { + .mouseleave(function () { b.deactivate(); }); }, - activate: function(a, b) { + activate: function (a, b) { this.deactivate(); if (this.hasScroll()) { var c = b.offset().top - this.element.offset().top, @@ -4677,15 +4671,15 @@ ? this.element.scrollTop(d + c) : c >= e && this.element.scrollTop(d + c - e + b.height()); } - (this.active = b + ((this.active = b .eq(0) .children("a") .addClass("ui-state-hover") .attr("id", "ui-active-menuitem") .end()), - this._trigger("focus", a, { item: b }); + this._trigger("focus", a, { item: b })); }, - deactivate: function() { + deactivate: function () { !this.active || (this.active .children("a") @@ -4694,19 +4688,19 @@ this._trigger("blur"), (this.active = null)); }, - next: function(a) { + next: function (a) { this.move("next", ".ui-menu-item:first", a); }, - previous: function(a) { + previous: function (a) { this.move("prev", ".ui-menu-item:last", a); }, - first: function() { + first: function () { return this.active && !this.active.prevAll(".ui-menu-item").length; }, - last: function() { + last: function () { return this.active && !this.active.nextAll(".ui-menu-item").length; }, - move: function(a, b, c) { + move: function (a, b, c) { if (!this.active) this.activate(c, this.element.children(b)); else { var d = this.active[a + "All"](".ui-menu-item").eq(0); @@ -4715,7 +4709,7 @@ : this.activate(c, this.element.children(b)); } }, - nextPage: function(b) { + nextPage: function (b) { if (this.hasScroll()) { if (!this.active || this.last()) { this.activate(b, this.element.children(".ui-menu-item:first")); @@ -4723,12 +4717,12 @@ } var c = this.active.offset().top, d = this.element.height(), - e = this.element.children(".ui-menu-item").filter(function() { + e = this.element.children(".ui-menu-item").filter(function () { var b = a(this).offset().top - c - d + a(this).height(); return b < 10 && b > -10; }); - e.length || (e = this.element.children(".ui-menu-item:last")), - this.activate(b, e); + (e.length || (e = this.element.children(".ui-menu-item:last")), + this.activate(b, e)); } else this.activate( b, @@ -4737,7 +4731,7 @@ .filter(!this.active || this.last() ? ":first" : ":last") ); }, - previousPage: function(b) { + previousPage: function (b) { if (this.hasScroll()) { if (!this.active || this.first()) { this.activate(b, this.element.children(".ui-menu-item:last")); @@ -4745,13 +4739,13 @@ } var c = this.active.offset().top, d = this.element.height(); - (result = this.element.children(".ui-menu-item").filter(function() { + ((result = this.element.children(".ui-menu-item").filter(function () { var b = a(this).offset().top - c + d - a(this).height(); return b < 10 && b > -10; })), result.length || (result = this.element.children(".ui-menu-item:first")), - this.activate(b, result); + this.activate(b, result)); } else this.activate( b, @@ -4760,17 +4754,17 @@ .filter(!this.active || this.first() ? ":last" : ":first") ); }, - hasScroll: function() { + hasScroll: function () { return ( this.element.height() < this.element[a.fn.prop ? "prop" : "attr"]("scrollHeight") ); }, - select: function(a) { + select: function (a) { this._trigger("selected", a, { item: this.active }); } }); - })(jQuery); + })(jQuery)); /* * jQuery UI Button 1.8.17 * @@ -4783,7 +4777,7 @@ * Depends: * jquery.ui.core.js * jquery.ui.widget.js - */ (function(a, b) { + */ (function (a, b) { var c, d, e, @@ -4792,164 +4786,164 @@ h = "ui-state-hover ui-state-active ", i = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only", - j = function() { + j = function () { var b = a(this).find(":ui-button"); - setTimeout(function() { + setTimeout(function () { b.button("refresh"); }, 1); }, - k = function(b) { + k = function (b) { var c = b.name, d = b.form, e = a([]); c && (d ? (e = a(d).find("[name='" + c + "']")) - : (e = a("[name='" + c + "']", b.ownerDocument).filter(function() { + : (e = a("[name='" + c + "']", b.ownerDocument).filter(function () { return !this.form; }))); return e; }; - a.widget("ui.button", { + (a.widget("ui.button", { options: { disabled: null, text: !0, label: null, icons: { primary: null, secondary: null } }, - _create: function() { - this.element + _create: function () { + (this.element .closest("form") .unbind("reset.button") .bind("reset.button", j), typeof this.options.disabled != "boolean" && (this.options.disabled = this.element.propAttr("disabled")), this._determineButtonType(), - (this.hasTitle = !!this.buttonElement.attr("title")); + (this.hasTitle = !!this.buttonElement.attr("title"))); var b = this, h = this.options, i = this.type === "checkbox" || this.type === "radio", l = "ui-state-hover" + (i ? "" : " ui-state-active"), m = "ui-state-focus"; - h.label === null && (h.label = this.buttonElement.html()), + (h.label === null && (h.label = this.buttonElement.html()), this.element.is(":disabled") && (h.disabled = !0), this.buttonElement .addClass(g) .attr("role", "button") - .bind("mouseenter.button", function() { + .bind("mouseenter.button", function () { h.disabled || (a(this).addClass("ui-state-hover"), this === c && a(this).addClass("ui-state-active")); }) - .bind("mouseleave.button", function() { + .bind("mouseleave.button", function () { h.disabled || a(this).removeClass(l); }) - .bind("click.button", function(a) { + .bind("click.button", function (a) { h.disabled && (a.preventDefault(), a.stopImmediatePropagation()); }), this.element - .bind("focus.button", function() { + .bind("focus.button", function () { b.buttonElement.addClass(m); }) - .bind("blur.button", function() { + .bind("blur.button", function () { b.buttonElement.removeClass(m); }), i && - (this.element.bind("change.button", function() { + (this.element.bind("change.button", function () { f || b.refresh(); }), this.buttonElement - .bind("mousedown.button", function(a) { + .bind("mousedown.button", function (a) { h.disabled || ((f = !1), (d = a.pageX), (e = a.pageY)); }) - .bind("mouseup.button", function(a) { + .bind("mouseup.button", function (a) { !h.disabled && (d !== a.pageX || e !== a.pageY) && (f = !0); })), this.type === "checkbox" - ? this.buttonElement.bind("click.button", function() { + ? this.buttonElement.bind("click.button", function () { if (h.disabled || f) return !1; - a(this).toggleClass("ui-state-active"), - b.buttonElement.attr("aria-pressed", b.element[0].checked); + (a(this).toggleClass("ui-state-active"), + b.buttonElement.attr("aria-pressed", b.element[0].checked)); }) : this.type === "radio" - ? this.buttonElement.bind("click.button", function() { - if (h.disabled || f) return !1; - a(this).addClass("ui-state-active"), - b.buttonElement.attr("aria-pressed", "true"); - var c = b.element[0]; - k(c) - .not(c) - .map(function() { - return a(this).button("widget")[0]; - }) - .removeClass("ui-state-active") - .attr("aria-pressed", "false"); - }) - : (this.buttonElement - .bind("mousedown.button", function() { - if (h.disabled) return !1; - a(this).addClass("ui-state-active"), - (c = this), - a(document).one("mouseup", function() { - c = null; - }); - }) - .bind("mouseup.button", function() { - if (h.disabled) return !1; - a(this).removeClass("ui-state-active"); - }) - .bind("keydown.button", function(b) { - if (h.disabled) return !1; - (b.keyCode == a.ui.keyCode.SPACE || - b.keyCode == a.ui.keyCode.ENTER) && - a(this).addClass("ui-state-active"); + ? this.buttonElement.bind("click.button", function () { + if (h.disabled || f) return !1; + (a(this).addClass("ui-state-active"), + b.buttonElement.attr("aria-pressed", "true")); + var c = b.element[0]; + k(c) + .not(c) + .map(function () { + return a(this).button("widget")[0]; + }) + .removeClass("ui-state-active") + .attr("aria-pressed", "false"); }) - .bind("keyup.button", function() { - a(this).removeClass("ui-state-active"); - }), - this.buttonElement.is("a") && - this.buttonElement.keyup(function(b) { - b.keyCode === a.ui.keyCode.SPACE && a(this).click(); - })), + : (this.buttonElement + .bind("mousedown.button", function () { + if (h.disabled) return !1; + (a(this).addClass("ui-state-active"), + (c = this), + a(document).one("mouseup", function () { + c = null; + })); + }) + .bind("mouseup.button", function () { + if (h.disabled) return !1; + a(this).removeClass("ui-state-active"); + }) + .bind("keydown.button", function (b) { + if (h.disabled) return !1; + (b.keyCode == a.ui.keyCode.SPACE || + b.keyCode == a.ui.keyCode.ENTER) && + a(this).addClass("ui-state-active"); + }) + .bind("keyup.button", function () { + a(this).removeClass("ui-state-active"); + }), + this.buttonElement.is("a") && + this.buttonElement.keyup(function (b) { + b.keyCode === a.ui.keyCode.SPACE && a(this).click(); + })), this._setOption("disabled", h.disabled), - this._resetButton(); + this._resetButton()); }, - _determineButtonType: function() { + _determineButtonType: function () { this.element.is(":checkbox") ? (this.type = "checkbox") : this.element.is(":radio") - ? (this.type = "radio") - : this.element.is("input") - ? (this.type = "input") - : (this.type = "button"); + ? (this.type = "radio") + : this.element.is("input") + ? (this.type = "input") + : (this.type = "button"); if (this.type === "checkbox" || this.type === "radio") { var a = this.element.parents().filter(":last"), b = "label[for='" + this.element.attr("id") + "']"; - (this.buttonElement = a.find(b)), + ((this.buttonElement = a.find(b)), this.buttonElement.length || ((a = a.length ? a.siblings() : this.element.siblings()), (this.buttonElement = a.filter(b)), this.buttonElement.length || (this.buttonElement = a.find(b))), - this.element.addClass("ui-helper-hidden-accessible"); + this.element.addClass("ui-helper-hidden-accessible")); var c = this.element.is(":checked"); - c && this.buttonElement.addClass("ui-state-active"), - this.buttonElement.attr("aria-pressed", c); + (c && this.buttonElement.addClass("ui-state-active"), + this.buttonElement.attr("aria-pressed", c)); } else this.buttonElement = this.element; }, - widget: function() { + widget: function () { return this.buttonElement; }, - destroy: function() { - this.element.removeClass("ui-helper-hidden-accessible"), + destroy: function () { + (this.element.removeClass("ui-helper-hidden-accessible"), this.buttonElement .removeClass(g + " " + h + " " + i) .removeAttr("role") .removeAttr("aria-pressed") .html(this.buttonElement.find(".ui-button-text").html()), this.hasTitle || this.buttonElement.removeAttr("title"), - a.Widget.prototype.destroy.call(this); + a.Widget.prototype.destroy.call(this)); }, - _setOption: function(b, c) { + _setOption: function (b, c) { a.Widget.prototype._setOption.apply(this, arguments); b === "disabled" ? c @@ -4957,11 +4951,11 @@ : this.element.propAttr("disabled", !1) : this._resetButton(); }, - refresh: function() { + refresh: function () { var b = this.element.is(":disabled"); - b !== this.options.disabled && this._setOption("disabled", b), + (b !== this.options.disabled && this._setOption("disabled", b), this.type === "radio" - ? k(this.element[0]).each(function() { + ? k(this.element[0]).each(function () { a(this).is(":checked") ? a(this) .button("widget") @@ -4979,9 +4973,9 @@ .attr("aria-pressed", "true") : this.buttonElement .removeClass("ui-state-active") - .attr("aria-pressed", "false")); + .attr("aria-pressed", "false"))); }, - _resetButton: function() { + _resetButton: function () { if (this.type === "input") this.options.label && this.element.val(this.options.label); else { @@ -4994,7 +4988,7 @@ d = this.options.icons, e = d.primary && d.secondary, f = []; - d.primary || d.secondary + (d.primary || d.secondary ? (this.options.text && f.push( "ui-button-text-icon" + @@ -5016,7 +5010,7 @@ (f.push(e ? "ui-button-icons-only" : "ui-button-icon-only"), this.hasTitle || b.attr("title", c))) : f.push("ui-button-text-only"), - b.addClass(f.join(" ")); + b.addClass(f.join(" "))); } } }), @@ -5024,17 +5018,17 @@ options: { items: ":button, :submit, :reset, :checkbox, :radio, a, :data(button)" }, - _create: function() { + _create: function () { this.element.addClass("ui-buttonset"); }, - _init: function() { + _init: function () { this.refresh(); }, - _setOption: function(b, c) { - b === "disabled" && this.buttons.button("option", b, c), - a.Widget.prototype._setOption.apply(this, arguments); + _setOption: function (b, c) { + (b === "disabled" && this.buttons.button("option", b, c), + a.Widget.prototype._setOption.apply(this, arguments)); }, - refresh: function() { + refresh: function () { var b = this.element.css("direction") === "rtl"; this.buttons = this.element .find(this.options.items) @@ -5044,7 +5038,7 @@ .not(":ui-button") .button() .end() - .map(function() { + .map(function () { return a(this).button("widget")[0]; }) .removeClass("ui-corner-all ui-corner-left ui-corner-right") @@ -5056,18 +5050,18 @@ .end() .end(); }, - destroy: function() { - this.element.removeClass("ui-buttonset"), + destroy: function () { + (this.element.removeClass("ui-buttonset"), this.buttons - .map(function() { + .map(function () { return a(this).button("widget")[0]; }) .removeClass("ui-corner-left ui-corner-right") .end() .button("destroy"), - a.Widget.prototype.destroy.call(this); + a.Widget.prototype.destroy.call(this)); } - }); + })); })(jQuery); /* * jQuery UI Dialog 1.8.17 @@ -5086,7 +5080,7 @@ * jquery.ui.mouse.js * jquery.ui.position.js * jquery.ui.resizable.js - */ (function(a, b) { + */ (function (a, b) { var c = "ui-dialog ui-widget ui-widget-content ui-corner-all ", d = { buttons: !0, @@ -5109,7 +5103,7 @@ offset: !0, click: !0 }; - a.widget("ui.dialog", { + (a.widget("ui.dialog", { options: { autoOpen: !0, buttons: {}, @@ -5128,10 +5122,8 @@ my: "center", at: "center", collision: "fit", - using: function(b) { - var c = a(this) - .css(b) - .offset().top; + using: function (b) { + var c = a(this).css(b).offset().top; c < 0 && a(this).css("top", b.top - c); } }, @@ -5142,10 +5134,10 @@ width: 300, zIndex: 1e3 }, - _create: function() { - (this.originalTitle = this.element.attr("title")), + _create: function () { + ((this.originalTitle = this.element.attr("title")), typeof this.originalTitle != "string" && (this.originalTitle = ""), - (this.options.title = this.options.title || this.originalTitle); + (this.options.title = this.options.title || this.originalTitle)); var b = this, d = b.options, e = d.title || " ", @@ -5157,7 +5149,7 @@ .css({ zIndex: d.zIndex }) .attr("tabIndex", -1) .css("outline", 0) - .keydown(function(c) { + .keydown(function (c) { d.closeOnEscape && !c.isDefaultPrevented() && c.keyCode && @@ -5165,7 +5157,7 @@ (b.close(c), c.preventDefault()); }) .attr({ role: "dialog", "aria-labelledby": f }) - .mousedown(function(a) { + .mousedown(function (a) { b.moveToTop(!1, a); }), h = b.element @@ -5182,20 +5174,20 @@ .addClass("ui-dialog-titlebar-close ui-corner-all") .attr("role", "button") .hover( - function() { + function () { j.addClass("ui-state-hover"); }, - function() { + function () { j.removeClass("ui-state-hover"); } ) - .focus(function() { + .focus(function () { j.addClass("ui-state-focus"); }) - .blur(function() { + .blur(function () { j.removeClass("ui-state-focus"); }) - .click(function(a) { + .click(function (a) { b.close(a); return !1; }) @@ -5209,25 +5201,22 @@ .attr("id", f) .html(e) .prependTo(i); - a.isFunction(d.beforeclose) && + (a.isFunction(d.beforeclose) && !a.isFunction(d.beforeClose) && (d.beforeClose = d.beforeclose), - i - .find("*") - .add(i) - .disableSelection(), + i.find("*").add(i).disableSelection(), d.draggable && a.fn.draggable && b._makeDraggable(), d.resizable && a.fn.resizable && b._makeResizable(), b._createButtons(d.buttons), (b._isOpen = !1), - a.fn.bgiframe && g.bgiframe(); + a.fn.bgiframe && g.bgiframe()); }, - _init: function() { + _init: function () { this.options.autoOpen && this.open(); }, - destroy: function() { + destroy: function () { var a = this; - a.overlay && a.overlay.destroy(), + (a.overlay && a.overlay.destroy(), a.uiDialog.hide(), a.element .unbind(".dialog") @@ -5236,47 +5225,47 @@ .hide() .appendTo("body"), a.uiDialog.remove(), - a.originalTitle && a.element.attr("title", a.originalTitle); + a.originalTitle && a.element.attr("title", a.originalTitle)); return a; }, - widget: function() { + widget: function () { return this.uiDialog; }, - close: function(b) { + close: function (b) { var c = this, d, e; if (!1 !== c._trigger("beforeClose", b)) { - c.overlay && c.overlay.destroy(), + (c.overlay && c.overlay.destroy(), c.uiDialog.unbind("keypress.ui-dialog"), (c._isOpen = !1), c.options.hide - ? c.uiDialog.hide(c.options.hide, function() { + ? c.uiDialog.hide(c.options.hide, function () { c._trigger("close", b); }) : (c.uiDialog.hide(), c._trigger("close", b)), a.ui.dialog.overlay.resize(), c.options.modal && ((d = 0), - a(".ui-dialog").each(function() { + a(".ui-dialog").each(function () { this !== c.uiDialog[0] && ((e = a(this).css("z-index")), isNaN(e) || (d = Math.max(d, e))); }), - (a.ui.dialog.maxZ = d)); + (a.ui.dialog.maxZ = d))); return c; } }, - isOpen: function() { + isOpen: function () { return this._isOpen; }, - moveToTop: function(b, c) { + moveToTop: function (b, c) { var d = this, e = d.options, f; if ((e.modal && !b) || (!e.stack && !e.modal)) return d._trigger("focus", c); - e.zIndex > a.ui.dialog.maxZ && (a.ui.dialog.maxZ = e.zIndex), + (e.zIndex > a.ui.dialog.maxZ && (a.ui.dialog.maxZ = e.zIndex), d.overlay && ((a.ui.dialog.maxZ += 1), d.overlay.$el.css( @@ -5290,21 +5279,21 @@ (a.ui.dialog.maxZ += 1), d.uiDialog.css("z-index", a.ui.dialog.maxZ), d.element.attr(f), - d._trigger("focus", c); + d._trigger("focus", c)); return d; }, - open: function() { + open: function () { if (!this._isOpen) { var b = this, c = b.options, d = b.uiDialog; - (b.overlay = c.modal ? new a.ui.dialog.overlay(b) : null), + ((b.overlay = c.modal ? new a.ui.dialog.overlay(b) : null), b._size(), b._position(c.position), d.show(c.show), b.moveToTop(!0), c.modal && - d.bind("keydown.ui-dialog", function(b) { + d.bind("keydown.ui-dialog", function (b) { if (b.keyCode === a.ui.keyCode.TAB) { var c = a(":tabbable", this), d = c.filter(":first"), @@ -5324,50 +5313,45 @@ .find(":tabbable") .get() .concat( - d - .find(".ui-dialog-buttonpane :tabbable") - .get() - .concat(d.get()) + d.find(".ui-dialog-buttonpane :tabbable").get().concat(d.get()) ) ) .eq(0) .focus(), (b._isOpen = !0), - b._trigger("open"); + b._trigger("open")); return b; } }, - _createButtons: function(b) { + _createButtons: function (b) { var c = this, d = !1, e = a("
    ").addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" ), - g = a("
    ") - .addClass("ui-dialog-buttonset") - .appendTo(e); - c.uiDialog.find(".ui-dialog-buttonpane").remove(), + g = a("
    ").addClass("ui-dialog-buttonset").appendTo(e); + (c.uiDialog.find(".ui-dialog-buttonpane").remove(), typeof b == "object" && b !== null && - a.each(b, function() { + a.each(b, function () { return !(d = !0); }), d && - (a.each(b, function(b, d) { + (a.each(b, function (b, d) { d = a.isFunction(d) ? { click: d, text: b } : d; var e = a('') - .click(function() { + .click(function () { d.click.apply(c.element[0], arguments); }) .appendTo(g); - a.each(d, function(a, b) { + (a.each(d, function (a, b) { a !== "click" && (a in f ? e[a](b) : e.attr(a, b)); }), - a.fn.button && e.button(); + a.fn.button && e.button()); }), - e.appendTo(c.uiDialog)); + e.appendTo(c.uiDialog))); }, - _makeDraggable: function() { + _makeDraggable: function () { function f(a) { return { position: a.position, offset: a.offset }; } @@ -5379,30 +5363,26 @@ cancel: ".ui-dialog-content, .ui-dialog-titlebar-close", handle: ".ui-dialog-titlebar", containment: "document", - start: function(d, g) { - (e = c.height === "auto" ? "auto" : a(this).height()), - a(this) - .height(a(this).height()) - .addClass("ui-dialog-dragging"), - b._trigger("dragStart", d, f(g)); + start: function (d, g) { + ((e = c.height === "auto" ? "auto" : a(this).height()), + a(this).height(a(this).height()).addClass("ui-dialog-dragging"), + b._trigger("dragStart", d, f(g))); }, - drag: function(a, c) { + drag: function (a, c) { b._trigger("drag", a, f(c)); }, - stop: function(g, h) { - (c.position = [ + stop: function (g, h) { + ((c.position = [ h.position.left - d.scrollLeft(), h.position.top - d.scrollTop() ]), - a(this) - .removeClass("ui-dialog-dragging") - .height(e), + a(this).removeClass("ui-dialog-dragging").height(e), b._trigger("dragStop", g, f(h)), - a.ui.dialog.overlay.resize(); + a.ui.dialog.overlay.resize()); } }); }, - _makeResizable: function(c) { + _makeResizable: function (c) { function h(a) { return { originalPosition: a.originalPosition, @@ -5426,64 +5406,64 @@ minWidth: e.minWidth, minHeight: d._minHeight(), handles: g, - start: function(b, c) { - a(this).addClass("ui-dialog-resizing"), - d._trigger("resizeStart", b, h(c)); + start: function (b, c) { + (a(this).addClass("ui-dialog-resizing"), + d._trigger("resizeStart", b, h(c))); }, - resize: function(a, b) { + resize: function (a, b) { d._trigger("resize", a, h(b)); }, - stop: function(b, c) { - a(this).removeClass("ui-dialog-resizing"), + stop: function (b, c) { + (a(this).removeClass("ui-dialog-resizing"), (e.height = a(this).height()), (e.width = a(this).width()), d._trigger("resizeStop", b, h(c)), - a.ui.dialog.overlay.resize(); + a.ui.dialog.overlay.resize()); } }) .css("position", f) .find(".ui-resizable-se") .addClass("ui-icon ui-icon-grip-diagonal-se"); }, - _minHeight: function() { + _minHeight: function () { var a = this.options; return a.height === "auto" ? a.minHeight : Math.min(a.minHeight, a.height); }, - _position: function(b) { + _position: function (b) { var c = [], d = [0, 0], e; if (b) { if (typeof b == "string" || (typeof b == "object" && "0" in b)) - (c = b.split ? b.split(" ") : [b[0], b[1]]), + ((c = b.split ? b.split(" ") : [b[0], b[1]]), c.length === 1 && (c[1] = c[0]), - a.each(["left", "top"], function(a, b) { + a.each(["left", "top"], function (a, b) { +c[a] === c[a] && ((d[a] = c[a]), (c[a] = b)); }), - (b = { my: c.join(" "), at: c.join(" "), offset: d.join(" ") }); + (b = { my: c.join(" "), at: c.join(" "), offset: d.join(" ") })); b = a.extend({}, a.ui.dialog.prototype.options.position, b); } else b = a.ui.dialog.prototype.options.position; - (e = this.uiDialog.is(":visible")), + ((e = this.uiDialog.is(":visible")), e || this.uiDialog.show(), this.uiDialog .css({ top: 0, left: 0 }) .position(a.extend({ of: window }, b)), - e || this.uiDialog.hide(); + e || this.uiDialog.hide()); }, - _setOptions: function(b) { + _setOptions: function (b) { var c = this, f = {}, g = !1; - a.each(b, function(a, b) { - c._setOption(a, b), a in d && (g = !0), a in e && (f[a] = b); + (a.each(b, function (a, b) { + (c._setOption(a, b), a in d && (g = !0), a in e && (f[a] = b)); }), g && this._size(), this.uiDialog.is(":data(resizable)") && - this.uiDialog.resizable("option", f); + this.uiDialog.resizable("option", f)); }, - _setOption: function(b, d) { + _setOption: function (b, d) { var e = this, f = e.uiDialog; switch (b) { @@ -5506,38 +5486,38 @@ break; case "draggable": var g = f.is(":data(draggable)"); - g && !d && f.draggable("destroy"), !g && d && e._makeDraggable(); + (g && !d && f.draggable("destroy"), !g && d && e._makeDraggable()); break; case "position": e._position(d); break; case "resizable": var h = f.is(":data(resizable)"); - h && !d && f.resizable("destroy"), + (h && !d && f.resizable("destroy"), h && typeof d == "string" && f.resizable("option", "handles", d), - !h && d !== !1 && e._makeResizable(d); + !h && d !== !1 && e._makeResizable(d)); break; case "title": a(".ui-dialog-title", e.uiDialogTitlebar).html("" + (d || " ")); } a.Widget.prototype._setOption.apply(e, arguments); }, - _size: function() { + _size: function () { var b = this.options, c, d, e = this.uiDialog.is(":visible"); - this.element.show().css({ width: "auto", minHeight: 0, height: 0 }), + (this.element.show().css({ width: "auto", minHeight: 0, height: 0 }), b.minWidth > b.width && (b.width = b.minWidth), (c = this.uiDialog.css({ height: "auto", width: b.width }).height()), - (d = Math.max(0, b.minHeight - c)); + (d = Math.max(0, b.minHeight - c))); if (b.height === "auto") if (a.support.minHeight) this.element.css({ minHeight: d, height: "auto" }); else { this.uiDialog.show(); var f = this.element.css("height", "auto").height(); - e || this.uiDialog.hide(), this.element.height(Math.max(f, d)); + (e || this.uiDialog.hide(), this.element.height(Math.max(f, d))); } else this.element.height(Math.max(b.height - c, 0)); this.uiDialog.is(":data(resizable)") && @@ -5548,12 +5528,12 @@ version: "1.8.17", uuid: 0, maxZ: 0, - getTitleId: function(a) { + getTitleId: function (a) { var b = a.attr("id"); b || ((this.uuid += 1), (b = this.uuid)); return "ui-dialog-title-" + b; }, - overlay: function(b) { + overlay: function (b) { this.$el = a.ui.dialog.overlay.create(b); } }), @@ -5564,20 +5544,20 @@ events: a .map( "focus,mousedown,mouseup,keydown,keypress,click".split(","), - function(a) { + function (a) { return a + ".dialog-overlay"; } ) .join(" "), - create: function(b) { + create: function (b) { this.instances.length === 0 && - (setTimeout(function() { + (setTimeout(function () { a.ui.dialog.overlay.instances.length && - a(document).bind(a.ui.dialog.overlay.events, function(b) { + a(document).bind(a.ui.dialog.overlay.events, function (b) { if (a(b.target).zIndex() < a.ui.dialog.overlay.maxZ) return !1; }); }, 1), - a(document).bind("keydown.dialog-overlay", function(c) { + a(document).bind("keydown.dialog-overlay", function (c) { b.options.closeOnEscape && !c.isDefaultPrevented() && c.keyCode && @@ -5591,67 +5571,67 @@ ) .appendTo(document.body) .css({ width: this.width(), height: this.height() }); - a.fn.bgiframe && c.bgiframe(), this.instances.push(c); + (a.fn.bgiframe && c.bgiframe(), this.instances.push(c)); return c; }, - destroy: function(b) { + destroy: function (b) { var c = a.inArray(b, this.instances); - c != -1 && this.oldInstances.push(this.instances.splice(c, 1)[0]), + (c != -1 && this.oldInstances.push(this.instances.splice(c, 1)[0]), this.instances.length === 0 && a([document, window]).unbind(".dialog-overlay"), - b.remove(); + b.remove()); var d = 0; - a.each(this.instances, function() { + (a.each(this.instances, function () { d = Math.max(d, this.css("z-index")); }), - (this.maxZ = d); + (this.maxZ = d)); }, - height: function() { + height: function () { var b, c; if (a.browser.msie && a.browser.version < 7) { - (b = Math.max( + ((b = Math.max( document.documentElement.scrollHeight, document.body.scrollHeight )), (c = Math.max( document.documentElement.offsetHeight, document.body.offsetHeight - )); + ))); return b < c ? a(window).height() + "px" : b + "px"; } return a(document).height() + "px"; }, - width: function() { + width: function () { var b, c; if (a.browser.msie) { - (b = Math.max( + ((b = Math.max( document.documentElement.scrollWidth, document.body.scrollWidth )), (c = Math.max( document.documentElement.offsetWidth, document.body.offsetWidth - )); + ))); return b < c ? a(window).width() + "px" : b + "px"; } return a(document).width() + "px"; }, - resize: function() { + resize: function () { var b = a([]); - a.each(a.ui.dialog.overlay.instances, function() { + (a.each(a.ui.dialog.overlay.instances, function () { b = b.add(this); }), b.css({ width: 0, height: 0 }).css({ width: a.ui.dialog.overlay.width(), height: a.ui.dialog.overlay.height() - }); + })); } }), a.extend(a.ui.dialog.overlay.prototype, { - destroy: function() { + destroy: function () { a.ui.dialog.overlay.destroy(this.$el); } - }); + })); })(jQuery); /* * jQuery UI Slider 1.8.17 @@ -5666,9 +5646,9 @@ * jquery.ui.core.js * jquery.ui.mouse.js * jquery.ui.widget.js - */ (function(a, b) { + */ (function (a, b) { var c = 5; - a.widget("ui.slider", a.ui.mouse, { + (a.widget("ui.slider", a.ui.mouse, { widgetEventPrefix: "slide", options: { animate: !1, @@ -5681,7 +5661,7 @@ value: 0, values: null }, - _create: function() { + _create: function () { var b = this, d = this.options, e = this.element @@ -5691,7 +5671,7 @@ "", g = (d.values && d.values.length) || 1, h = []; - (this._keySliding = !1), + ((this._keySliding = !1), (this._mouseSliding = !1), (this._animateOff = !0), (this._handleIndex = null), @@ -5719,38 +5699,38 @@ (d.range === "min" || d.range === "max" ? " ui-slider-range-" + d.range : "") - ))); + )))); for (var i = e.length; i < g; i += 1) h.push(f); - (this.handles = e.add(a(h.join("")).appendTo(b.element))), + ((this.handles = e.add(a(h.join("")).appendTo(b.element))), (this.handle = this.handles.eq(0)), this.handles .add(this.range) .filter("a") - .click(function(a) { + .click(function (a) { a.preventDefault(); }) .hover( - function() { + function () { d.disabled || a(this).addClass("ui-state-hover"); }, - function() { + function () { a(this).removeClass("ui-state-hover"); } ) - .focus(function() { + .focus(function () { d.disabled ? a(this).blur() : (a(".ui-slider .ui-state-focus").removeClass("ui-state-focus"), a(this).addClass("ui-state-focus")); }) - .blur(function() { + .blur(function () { a(this).removeClass("ui-state-focus"); }), - this.handles.each(function(b) { + this.handles.each(function (b) { a(this).data("index.ui-slider-handle", b); }), this.handles - .keydown(function(d) { + .keydown(function (d) { var e = !0, f = a(this).data("index.ui-slider-handle"), g, @@ -5769,16 +5749,16 @@ case a.ui.keyCode.LEFT: e = !1; if (!b._keySliding) { - (b._keySliding = !0), + ((b._keySliding = !0), a(this).addClass("ui-state-active"), - (g = b._start(d, f)); + (g = b._start(d, f))); if (g === !1) return; } } - (j = b.options.step), + ((j = b.options.step), b.options.values && b.options.values.length ? (h = i = b.values(f)) - : (h = i = b.value()); + : (h = i = b.value())); switch (d.keyCode) { case a.ui.keyCode.HOME: i = b._valueMin(); @@ -5810,7 +5790,7 @@ return e; } }) - .keyup(function(c) { + .keyup(function (c) { var d = a(this).data("index.ui-slider-handle"); b._keySliding && ((b._keySliding = !1), @@ -5819,10 +5799,10 @@ a(this).removeClass("ui-state-active")); }), this._refreshValue(), - (this._animateOff = !1); + (this._animateOff = !1)); }, - destroy: function() { - this.handles.remove(), + destroy: function () { + (this.handles.remove(), this.range.remove(), this.element .removeClass( @@ -5830,10 +5810,10 @@ ) .removeData("slider") .unbind(".slider"), - this._mouseDestroy(); + this._mouseDestroy()); return this; }, - _mouseCapture: function(b) { + _mouseCapture: function (b) { var c = this.options, d, e, @@ -5845,7 +5825,7 @@ k, l; if (c.disabled) return !1; - (this.elementSize = { + ((this.elementSize = { width: this.element.outerWidth(), height: this.element.outerHeight() }), @@ -5854,23 +5834,20 @@ (e = this._normValueFromMouse(d)), (f = this._valueMax() - this._valueMin() + 1), (h = this), - this.handles.each(function(b) { + this.handles.each(function (b) { var c = Math.abs(e - h.values(b)); f > c && ((f = c), (g = a(this)), (i = b)); }), c.range === !0 && this.values(1) === c.min && ((i += 1), (g = a(this.handles[i]))), - (j = this._start(b, i)); + (j = this._start(b, i))); if (j === !1) return !1; - (this._mouseSliding = !0), + ((this._mouseSliding = !0), (h._handleIndex = i), g.addClass("ui-state-active").focus(), (k = g.offset()), - (l = !a(b.target) - .parents() - .andSelf() - .is(".ui-slider-handle")), + (l = !a(b.target).parents().andSelf().is(".ui-slider-handle")), (this._clickOffset = l ? { left: 0, top: 0 } : { @@ -5884,35 +5861,35 @@ (parseInt(g.css("marginTop"), 10) || 0) }), this.handles.hasClass("ui-state-hover") || this._slide(b, i, e), - (this._animateOff = !0); + (this._animateOff = !0)); return !0; }, - _mouseStart: function(a) { + _mouseStart: function (a) { return !0; }, - _mouseDrag: function(a) { + _mouseDrag: function (a) { var b = { x: a.pageX, y: a.pageY }, c = this._normValueFromMouse(b); this._slide(a, this._handleIndex, c); return !1; }, - _mouseStop: function(a) { - this.handles.removeClass("ui-state-active"), + _mouseStop: function (a) { + (this.handles.removeClass("ui-state-active"), (this._mouseSliding = !1), this._stop(a, this._handleIndex), this._change(a, this._handleIndex), (this._handleIndex = null), (this._clickOffset = null), - (this._animateOff = !1); + (this._animateOff = !1)); return !1; }, - _detectOrientation: function() { + _detectOrientation: function () { this.orientation = this.options.orientation === "vertical" ? "vertical" : "horizontal"; }, - _normValueFromMouse: function(a) { + _normValueFromMouse: function (a) { var b, c, d, e, f; - this.orientation === "horizontal" + (this.orientation === "horizontal" ? ((b = this.elementSize.width), (c = a.x - @@ -5928,17 +5905,17 @@ d < 0 && (d = 0), this.orientation === "vertical" && (d = 1 - d), (e = this._valueMax() - this._valueMin()), - (f = this._valueMin() + d * e); + (f = this._valueMin() + d * e)); return this._trimAlignValue(f); }, - _start: function(a, b) { + _start: function (a, b) { var c = { handle: this.handles[b], value: this.value() }; this.options.values && this.options.values.length && ((c.value = this.values(b)), (c.values = this.values())); return this._trigger("start", a, c); }, - _slide: function(a, b, c) { + _slide: function (a, b, c) { var d, e, f; this.options.values && this.options.values.length ? ((d = this.values(b ? 0 : 1)), @@ -5963,52 +5940,52 @@ })), f !== !1 && this.value(c)); }, - _stop: function(a, b) { + _stop: function (a, b) { var c = { handle: this.handles[b], value: this.value() }; - this.options.values && + (this.options.values && this.options.values.length && ((c.value = this.values(b)), (c.values = this.values())), - this._trigger("stop", a, c); + this._trigger("stop", a, c)); }, - _change: function(a, b) { + _change: function (a, b) { if (!this._keySliding && !this._mouseSliding) { var c = { handle: this.handles[b], value: this.value() }; - this.options.values && + (this.options.values && this.options.values.length && ((c.value = this.values(b)), (c.values = this.values())), - this._trigger("change", a, c); + this._trigger("change", a, c)); } }, - value: function(a) { + value: function (a) { if (arguments.length) - (this.options.value = this._trimAlignValue(a)), + ((this.options.value = this._trimAlignValue(a)), this._refreshValue(), - this._change(null, 0); + this._change(null, 0)); else return this._value(); }, - values: function(b, c) { + values: function (b, c) { var d, e, f; if (arguments.length > 1) - (this.options.values[b] = this._trimAlignValue(c)), + ((this.options.values[b] = this._trimAlignValue(c)), this._refreshValue(), - this._change(null, b); + this._change(null, b)); else { if (!arguments.length) return this._values(); if (!a.isArray(arguments[0])) return this.options.values && this.options.values.length ? this._values(b) : this.value(); - (d = this.options.values), (e = arguments[0]); + ((d = this.options.values), (e = arguments[0])); for (f = 0; f < d.length; f += 1) - (d[f] = this._trimAlignValue(e[f])), this._change(null, f); + ((d[f] = this._trimAlignValue(e[f])), this._change(null, f)); this._refreshValue(); } }, - _setOption: function(b, c) { + _setOption: function (b, c) { var d, e = 0; - a.isArray(this.options.values) && (e = this.options.values.length), - a.Widget.prototype._setOption.apply(this, arguments); + (a.isArray(this.options.values) && (e = this.options.values.length), + a.Widget.prototype._setOption.apply(this, arguments)); switch (b) { case "disabled": c @@ -6020,40 +5997,40 @@ this.element.removeClass("ui-disabled")); break; case "orientation": - this._detectOrientation(), + (this._detectOrientation(), this.element .removeClass("ui-slider-horizontal ui-slider-vertical") .addClass("ui-slider-" + this.orientation), - this._refreshValue(); + this._refreshValue()); break; case "value": - (this._animateOff = !0), + ((this._animateOff = !0), this._refreshValue(), this._change(null, 0), - (this._animateOff = !1); + (this._animateOff = !1)); break; case "values": - (this._animateOff = !0), this._refreshValue(); + ((this._animateOff = !0), this._refreshValue()); for (d = 0; d < e; d += 1) this._change(null, d); this._animateOff = !1; } }, - _value: function() { + _value: function () { var a = this.options.value; a = this._trimAlignValue(a); return a; }, - _values: function(a) { + _values: function (a) { var b, c, d; if (arguments.length) { - (b = this.options.values[a]), (b = this._trimAlignValue(b)); + ((b = this.options.values[a]), (b = this._trimAlignValue(b))); return b; } c = this.options.values.slice(); for (d = 0; d < c.length; d += 1) c[d] = this._trimAlignValue(c[d]); return c; }, - _trimAlignValue: function(a) { + _trimAlignValue: function (a) { if (a <= this._valueMin()) return this._valueMin(); if (a >= this._valueMax()) return this._valueMax(); var b = this.options.step > 0 ? this.options.step : 1, @@ -6062,13 +6039,13 @@ Math.abs(c) * 2 >= b && (d += c > 0 ? b : -b); return parseFloat(d.toFixed(5)); }, - _valueMin: function() { + _valueMin: function () { return this.options.min; }, - _valueMax: function() { + _valueMax: function () { return this.options.max; }, - _refreshValue: function() { + _refreshValue: function () { var b = this.options.range, c = this.options, d = this, @@ -6080,15 +6057,13 @@ j, k; this.options.values && this.options.values.length - ? this.handles.each(function(b, i) { - (f = + ? this.handles.each(function (b, i) { + ((f = ((d.values(b) - d._valueMin()) / (d._valueMax() - d._valueMin())) * 100), (g[d.orientation === "horizontal" ? "left" : "bottom"] = f + "%"), - a(this) - .stop(1, 1) - [e ? "animate" : "css"](g, c.animate), + a(this).stop(1, 1)[e ? "animate" : "css"](g, c.animate), d.options.range === !0 && (d.orientation === "horizontal" ? (b === 0 && @@ -6109,7 +6084,7 @@ { height: f - h + "%" }, { queue: !1, duration: c.animate } ))), - (h = f); + (h = f)); }) : ((i = this.value()), (j = this._valueMin()), @@ -6141,7 +6116,7 @@ )); } }), - a.extend(a.ui.slider, { version: "1.8.17" }); + a.extend(a.ui.slider, { version: "1.8.17" })); })(jQuery); /* * jQuery UI Tabs 1.8.17 @@ -6155,7 +6130,7 @@ * Depends: * jquery.ui.core.js * jquery.ui.widget.js - */ (function(a, b) { + */ (function (a, b) { function f() { return ++d; } @@ -6164,7 +6139,7 @@ } var c = 0, d = 0; - a.widget("ui.tabs", { + (a.widget("ui.tabs", { options: { add: null, ajaxOptions: null, @@ -6185,61 +6160,61 @@ spinner: "Loading…", tabTemplate: "
  • #{label}
  • " }, - _create: function() { + _create: function () { this._tabify(!0); }, - _setOption: function(a, b) { + _setOption: function (a, b) { if (a == "selected") { if (this.options.collapsible && b == this.options.selected) return; this.select(b); - } else (this.options[a] = b), this._tabify(); + } else ((this.options[a] = b), this._tabify()); }, - _tabId: function(a) { + _tabId: function (a) { return ( (a.title && a.title.replace(/\s/g, "_").replace(/[^\w\u00c0-\uFFFF-]/g, "")) || this.options.idPrefix + e() ); }, - _sanitizeSelector: function(a) { + _sanitizeSelector: function (a) { return a.replace(/:/g, "\\:"); }, - _cookie: function() { + _cookie: function () { var b = this.cookie || (this.cookie = this.options.cookie.name || "ui-tabs-" + f()); return a.cookie.apply(null, [b].concat(a.makeArray(arguments))); }, - _ui: function(a, b) { + _ui: function (a, b) { return { tab: a, panel: b, index: this.anchors.index(a) }; }, - _cleanup: function() { + _cleanup: function () { this.lis .filter(".ui-state-processing") .removeClass("ui-state-processing") .find("span:data(label.tabs)") - .each(function() { + .each(function () { var b = a(this); b.html(b.data("label.tabs")).removeData("label.tabs"); }); }, - _tabify: function(c) { + _tabify: function (c) { function m(b, c) { - b.css("display", ""), + (b.css("display", ""), !a.support.opacity && c.opacity && - b[0].style.removeAttribute("filter"); + b[0].style.removeAttribute("filter")); } var d = this, e = this.options, f = /^#.+/; - (this.list = this.element.find("ol,ul").eq(0)), + ((this.list = this.element.find("ol,ul").eq(0)), (this.lis = a(" > li:has(a[href])", this.list)), - (this.anchors = this.lis.map(function() { + (this.anchors = this.lis.map(function () { return a("a", this)[0]; })), (this.panels = a([])), - this.anchors.each(function(b, c) { + this.anchors.each(function (b, c) { var g = a(c).attr("href"), h = g.split("#")[0], i; @@ -6250,18 +6225,18 @@ if (f.test(g)) d.panels = d.panels.add(d.element.find(d._sanitizeSelector(g))); else if (g && g !== "#") { - a.data(c, "href.tabs", g), - a.data(c, "load.tabs", g.replace(/#.*$/, "")); + (a.data(c, "href.tabs", g), + a.data(c, "load.tabs", g.replace(/#.*$/, ""))); var j = d._tabId(c); c.href = "#" + j; var k = d.element.find("#" + j); - k.length || + (k.length || ((k = a(e.panelTemplate) .attr("id", j) .addClass("ui-tabs-panel ui-widget-content ui-corner-bottom") .insertAfter(d.panels[b - 1] || d.list)), k.data("destroy.tabs", !0)), - (d.panels = d.panels.add(k)); + (d.panels = d.panels.add(k))); } else e.disabled.push(b); }), c @@ -6277,7 +6252,7 @@ ), e.selected === b ? (location.hash && - this.anchors.each(function(a, b) { + this.anchors.each(function (a, b) { if (b.hash == location.hash) { e.selected = a; return !1; @@ -6300,7 +6275,7 @@ (e.disabled = a .unique( e.disabled.concat( - a.map(this.lis.filter(".ui-state-disabled"), function(a, b) { + a.map(this.lis.filter(".ui-state-disabled"), function (a, b) { return d.lis.index(a); }) ) @@ -6318,7 +6293,7 @@ this.lis .eq(e.selected) .addClass("ui-tabs-selected ui-state-active"), - d.element.queue("tabs", function() { + d.element.queue("tabs", function () { d._trigger( "show", null, @@ -6331,80 +6306,76 @@ ); }), this.load(e.selected)), - a(window).bind("unload", function() { - d.lis.add(d.anchors).unbind(".tabs"), - (d.lis = d.anchors = d.panels = null); + a(window).bind("unload", function () { + (d.lis.add(d.anchors).unbind(".tabs"), + (d.lis = d.anchors = d.panels = null)); })) : (e.selected = this.lis.index(this.lis.filter(".ui-tabs-selected"))), this.element[e.collapsible ? "addClass" : "removeClass"]( "ui-tabs-collapsible" ), - e.cookie && this._cookie(e.selected, e.cookie); + e.cookie && this._cookie(e.selected, e.cookie)); for (var g = 0, h; (h = this.lis[g]); g++) a(h)[ a.inArray(g, e.disabled) != -1 && !a(h).hasClass("ui-tabs-selected") ? "addClass" : "removeClass" ]("ui-state-disabled"); - e.cache === !1 && this.anchors.removeData("cache.tabs"), - this.lis.add(this.anchors).unbind(".tabs"); + (e.cache === !1 && this.anchors.removeData("cache.tabs"), + this.lis.add(this.anchors).unbind(".tabs")); if (e.event !== "mouseover") { - var i = function(a, b) { + var i = function (a, b) { b.is(":not(.ui-state-disabled)") && b.addClass("ui-state-" + a); }, - j = function(a, b) { + j = function (a, b) { b.removeClass("ui-state-" + a); }; - this.lis.bind("mouseover.tabs", function() { + (this.lis.bind("mouseover.tabs", function () { i("hover", a(this)); }), - this.lis.bind("mouseout.tabs", function() { + this.lis.bind("mouseout.tabs", function () { j("hover", a(this)); }), - this.anchors.bind("focus.tabs", function() { + this.anchors.bind("focus.tabs", function () { i("focus", a(this).closest("li")); }), - this.anchors.bind("blur.tabs", function() { + this.anchors.bind("blur.tabs", function () { j("focus", a(this).closest("li")); - }); + })); } var k, l; e.fx && (a.isArray(e.fx) ? ((k = e.fx[0]), (l = e.fx[1])) : (k = l = e.fx)); var n = l - ? function(b, c) { - a(b) - .closest("li") - .addClass("ui-tabs-selected ui-state-active"), + ? function (b, c) { + (a(b).closest("li").addClass("ui-tabs-selected ui-state-active"), c .hide() .removeClass("ui-tabs-hide") - .animate(l, l.duration || "normal", function() { - m(c, l), d._trigger("show", null, d._ui(b, c[0])); - }); + .animate(l, l.duration || "normal", function () { + (m(c, l), d._trigger("show", null, d._ui(b, c[0]))); + })); } - : function(b, c) { - a(b) - .closest("li") - .addClass("ui-tabs-selected ui-state-active"), + : function (b, c) { + (a(b).closest("li").addClass("ui-tabs-selected ui-state-active"), c.removeClass("ui-tabs-hide"), - d._trigger("show", null, d._ui(b, c[0])); + d._trigger("show", null, d._ui(b, c[0]))); }, o = k - ? function(a, b) { - b.animate(k, k.duration || "normal", function() { - d.lis.removeClass("ui-tabs-selected ui-state-active"), + ? function (a, b) { + b.animate(k, k.duration || "normal", function () { + (d.lis.removeClass("ui-tabs-selected ui-state-active"), b.addClass("ui-tabs-hide"), m(b, k), - d.element.dequeue("tabs"); + d.element.dequeue("tabs")); }); } - : function(a, b, c) { - d.lis.removeClass("ui-tabs-selected ui-state-active"), + : function (a, b, c) { + (d.lis.removeClass("ui-tabs-selected ui-state-active"), b.addClass("ui-tabs-hide"), - d.element.dequeue("tabs"); + d.element.dequeue("tabs")); }; - this.anchors.bind(e.event + ".tabs", function() { + (this.anchors.bind(e.event + ".tabs", function () { var b = this, c = a(b).closest("li"), f = d.panels.filter(":not(.ui-tabs-hide)"), @@ -6419,54 +6390,54 @@ this.blur(); return !1; } - (e.selected = d.anchors.index(this)), d.abort(); + ((e.selected = d.anchors.index(this)), d.abort()); if (e.collapsible) { if (c.hasClass("ui-tabs-selected")) { - (e.selected = -1), + ((e.selected = -1), e.cookie && d._cookie(e.selected, e.cookie), d.element - .queue("tabs", function() { + .queue("tabs", function () { o(b, f); }) .dequeue("tabs"), - this.blur(); + this.blur()); return !1; } if (!f.length) { - e.cookie && d._cookie(e.selected, e.cookie), - d.element.queue("tabs", function() { + (e.cookie && d._cookie(e.selected, e.cookie), + d.element.queue("tabs", function () { n(b, g); }), d.load(d.anchors.index(this)), - this.blur(); + this.blur()); return !1; } } e.cookie && d._cookie(e.selected, e.cookie); if (g.length) - f.length && - d.element.queue("tabs", function() { + (f.length && + d.element.queue("tabs", function () { o(b, f); }), - d.element.queue("tabs", function() { + d.element.queue("tabs", function () { n(b, g); }), - d.load(d.anchors.index(this)); + d.load(d.anchors.index(this))); else throw "jQuery UI Tabs: Mismatching fragment identifier."; a.browser.msie && this.blur(); }), - this.anchors.bind("click.tabs", function() { + this.anchors.bind("click.tabs", function () { return !1; - }); + })); }, - _getIndex: function(a) { + _getIndex: function (a) { typeof a == "string" && (a = this.anchors.index(this.anchors.filter("[href$=" + a + "]"))); return a; }, - destroy: function() { + destroy: function () { var b = this.options; - this.abort(), + (this.abort(), this.element .unbind(".tabs") .removeClass( @@ -6476,18 +6447,18 @@ this.list.removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" ), - this.anchors.each(function() { + this.anchors.each(function () { var b = a.data(this, "href.tabs"); b && (this.href = b); var c = a(this).unbind(".tabs"); - a.each(["href", "load", "cache"], function(a, b) { + a.each(["href", "load", "cache"], function (a, b) { c.removeData(b + ".tabs"); }); }), this.lis .unbind(".tabs") .add(this.panels) - .each(function() { + .each(function () { a.data(this, "destroy.tabs") ? a(this).remove() : a(this).removeClass( @@ -6506,10 +6477,10 @@ ].join(" ") ); }), - b.cookie && this._cookie(null, b.cookie); + b.cookie && this._cookie(null, b.cookie)); return this; }, - add: function(c, d, e) { + add: function (c, d, e) { e === b && (e = this.anchors.length); var f = this, g = this.options, @@ -6517,17 +6488,15 @@ i = c.indexOf("#") ? this._tabId(a("a", h)[0]) : c.replace("#", ""); h.addClass("ui-state-default ui-corner-top").data("destroy.tabs", !0); var j = f.element.find("#" + i); - j.length || - (j = a(g.panelTemplate) - .attr("id", i) - .data("destroy.tabs", !0)), + (j.length || + (j = a(g.panelTemplate).attr("id", i).data("destroy.tabs", !0)), j.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" ), e >= this.lis.length ? (h.appendTo(this.list), j.appendTo(this.list[0].parentNode)) : (h.insertBefore(this.lis[e]), j.insertBefore(this.panels[e])), - (g.disabled = a.map(g.disabled, function(a, b) { + (g.disabled = a.map(g.disabled, function (a, b) { return a >= e ? ++a : a; })), this._tabify(), @@ -6535,50 +6504,50 @@ ((g.selected = 0), h.addClass("ui-tabs-selected ui-state-active"), j.removeClass("ui-tabs-hide"), - this.element.queue("tabs", function() { + this.element.queue("tabs", function () { f._trigger("show", null, f._ui(f.anchors[0], f.panels[0])); }), this.load(0)), - this._trigger("add", null, this._ui(this.anchors[e], this.panels[e])); + this._trigger("add", null, this._ui(this.anchors[e], this.panels[e]))); return this; }, - remove: function(b) { + remove: function (b) { b = this._getIndex(b); var c = this.options, d = this.lis.eq(b).remove(), e = this.panels.eq(b).remove(); - d.hasClass("ui-tabs-selected") && + (d.hasClass("ui-tabs-selected") && this.anchors.length > 1 && this.select(b + (b + 1 < this.anchors.length ? 1 : -1)), (c.disabled = a.map( - a.grep(c.disabled, function(a, c) { + a.grep(c.disabled, function (a, c) { return a != b; }), - function(a, c) { + function (a, c) { return a >= b ? --a : a; } )), this._tabify(), - this._trigger("remove", null, this._ui(d.find("a")[0], e[0])); + this._trigger("remove", null, this._ui(d.find("a")[0], e[0]))); return this; }, - enable: function(b) { + enable: function (b) { b = this._getIndex(b); var c = this.options; if (a.inArray(b, c.disabled) != -1) { - this.lis.eq(b).removeClass("ui-state-disabled"), - (c.disabled = a.grep(c.disabled, function(a, c) { + (this.lis.eq(b).removeClass("ui-state-disabled"), + (c.disabled = a.grep(c.disabled, function (a, c) { return a != b; })), this._trigger( "enable", null, this._ui(this.anchors[b], this.panels[b]) - ); + )); return this; } }, - disable: function(a) { + disable: function (a) { a = this._getIndex(a); var b = this, c = this.options; @@ -6593,7 +6562,7 @@ )); return this; }, - select: function(a) { + select: function (a) { a = this._getIndex(a); if (a == -1) if (this.options.collapsible && this.options.selected != -1) @@ -6602,7 +6571,7 @@ this.anchors.eq(a).trigger(this.options.event + ".tabs"); return this; }, - load: function(b) { + load: function (b) { b = this._getIndex(b); var c = this, d = this.options, @@ -6620,73 +6589,70 @@ var g = a("span", e); g.data("label.tabs", g.html()).html(d.spinner); } - (this.xhr = a.ajax( + ((this.xhr = a.ajax( a.extend({}, d.ajaxOptions, { url: f, - success: function(f, g) { - c.element.find(c._sanitizeSelector(e.hash)).html(f), + success: function (f, g) { + (c.element.find(c._sanitizeSelector(e.hash)).html(f), c._cleanup(), d.cache && a.data(e, "cache.tabs", !0), - c._trigger("load", null, c._ui(c.anchors[b], c.panels[b])); + c._trigger("load", null, c._ui(c.anchors[b], c.panels[b]))); try { d.ajaxOptions.success(f, g); } catch (h) {} }, - error: function(a, f, g) { - c._cleanup(), - c._trigger("load", null, c._ui(c.anchors[b], c.panels[b])); + error: function (a, f, g) { + (c._cleanup(), + c._trigger("load", null, c._ui(c.anchors[b], c.panels[b]))); try { d.ajaxOptions.error(a, f, b, e); } catch (g) {} } }) )), - c.element.dequeue("tabs"); + c.element.dequeue("tabs")); return this; } }, - abort: function() { - this.element.queue([]), + abort: function () { + (this.element.queue([]), this.panels.stop(!1, !0), this.element.queue("tabs", this.element.queue("tabs").splice(-2, 2)), this.xhr && (this.xhr.abort(), delete this.xhr), - this._cleanup(); + this._cleanup()); return this; }, - url: function(a, b) { - this.anchors - .eq(a) - .removeData("cache.tabs") - .data("load.tabs", b); + url: function (a, b) { + this.anchors.eq(a).removeData("cache.tabs").data("load.tabs", b); return this; }, - length: function() { + length: function () { return this.anchors.length; } }), a.extend(a.ui.tabs, { version: "1.8.17" }), a.extend(a.ui.tabs.prototype, { rotation: null, - rotate: function(a, b) { + rotate: function (a, b) { var c = this, d = this.options, e = c._rotate || - (c._rotate = function(b) { - clearTimeout(c.rotation), - (c.rotation = setTimeout(function() { + (c._rotate = function (b) { + (clearTimeout(c.rotation), + (c.rotation = setTimeout(function () { var a = d.selected; c.select(++a < c.anchors.length ? a : 0); }, a)), - b && b.stopPropagation(); + b && b.stopPropagation()); }), f = c._unrotate || (c._unrotate = b - ? function(a) { - (t = d.selected), e(); + ? function (a) { + ((t = d.selected), e()); } - : function(a) { + : function (a) { a.clientX && c.rotate(null); }); a @@ -6700,7 +6666,7 @@ delete this._unrotate); return this; } - }); + })); })(jQuery); /* * jQuery UI Datepicker 1.8.17 @@ -6713,7 +6679,7 @@ * * Depends: * jquery.ui.core.js - */ (function($, undefined) { + */ (function ($, undefined) { function isArray(a) { return ( a && @@ -6730,14 +6696,14 @@ var b = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a"; return a - .bind("mouseout", function(a) { + .bind("mouseout", function (a) { var c = $(a.target).closest(b); !c.length || c.removeClass( "ui-state-hover ui-datepicker-prev-hover ui-datepicker-next-hover" ); }) - .bind("mouseover", function(c) { + .bind("mouseover", function (c) { var d = $(c.target).closest(b); !$.datepicker._isDisabledDatepicker( instActive.inline ? a.parent()[0] : instActive.input[0] @@ -6755,7 +6721,7 @@ }); } function Datepicker() { - (this.debug = !1), + ((this.debug = !1), (this._curInst = null), (this._keyEvent = !1), (this._disabledInputs = []), @@ -6868,26 +6834,26 @@ this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all">
    ' ) - )); + ))); } $.extend($.ui, { datepicker: { version: "1.8.17" } }); var PROP_NAME = "datepicker", dpuuid = new Date().getTime(), instActive; - $.extend(Datepicker.prototype, { + ($.extend(Datepicker.prototype, { markerClassName: "hasDatepicker", maxRows: 4, - log: function() { + log: function () { this.debug && console.log.apply("", arguments); }, - _widgetDatepicker: function() { + _widgetDatepicker: function () { return this.dpDiv; }, - setDefaults: function(a) { + setDefaults: function (a) { extendRemove(this._defaults, a || {}); return this; }, - _attachDatepicker: function(target, settings) { + _attachDatepicker: function (target, settings) { var inlineSettings = null; for (var attrName in this._defaults) { var attrValue = target.getAttribute("date:" + attrName); @@ -6904,12 +6870,12 @@ inline = nodeName == "div" || nodeName == "span"; target.id || ((this.uuid += 1), (target.id = "dp" + this.uuid)); var inst = this._newInst($(target), inline); - (inst.settings = $.extend({}, settings || {}, inlineSettings || {})), + ((inst.settings = $.extend({}, settings || {}, inlineSettings || {})), nodeName == "input" ? this._connectDatepicker(target, inst) - : inline && this._inlineDatepicker(target, inst); + : inline && this._inlineDatepicker(target, inst)); }, - _newInst: function(a, b) { + _newInst: function (a, b) { var c = a[0].id.replace(/([^A-Za-z0-9_-])/g, "\\\\$1"); return { id: c, @@ -6931,9 +6897,9 @@ : this.dpDiv }; }, - _connectDatepicker: function(a, b) { + _connectDatepicker: function (a, b) { var c = $(a); - (b.append = $([])), (b.trigger = $([])); + ((b.append = $([])), (b.trigger = $([]))); c.hasClass(this.markerClassName) || (this._attachments(c, b), c @@ -6941,33 +6907,33 @@ .keydown(this._doKeyDown) .keypress(this._doKeyPress) .keyup(this._doKeyUp) - .bind("setData.datepicker", function(a, c, d) { + .bind("setData.datepicker", function (a, c, d) { b.settings[c] = d; }) - .bind("getData.datepicker", function(a, c) { + .bind("getData.datepicker", function (a, c) { return this._get(b, c); }), this._autoSize(b), $.data(a, PROP_NAME, b), b.settings.disabled && this._disableDatepicker(a)); }, - _attachments: function(a, b) { + _attachments: function (a, b) { var c = this._get(b, "appendText"), d = this._get(b, "isRTL"); - b.append && b.append.remove(), + (b.append && b.append.remove(), c && ((b.append = $( '' + c + "" )), a[d ? "before" : "after"](b.append)), a.unbind("focus", this._showDatepicker), - b.trigger && b.trigger.remove(); + b.trigger && b.trigger.remove()); var e = this._get(b, "showOn"); (e == "focus" || e == "both") && a.focus(this._showDatepicker); if (e == "button" || e == "both") { var f = this._get(b, "buttonText"), g = this._get(b, "buttonImage"); - (b.trigger = $( + ((b.trigger = $( this._get(b, "buttonImageOnly") ? $("") .addClass(this._triggerClass) @@ -6979,48 +6945,48 @@ ) )), a[d ? "before" : "after"](b.trigger), - b.trigger.click(function() { + b.trigger.click(function () { $.datepicker._datepickerShowing && $.datepicker._lastInput == a[0] ? $.datepicker._hideDatepicker() : $.datepicker._showDatepicker(a[0]); return !1; - }); + })); } }, - _autoSize: function(a) { + _autoSize: function (a) { if (this._get(a, "autoSize") && !a.inline) { var b = new Date(2009, 11, 20), c = this._get(a, "dateFormat"); if (c.match(/[DM]/)) { - var d = function(a) { + var d = function (a) { var b = 0, c = 0; for (var d = 0; d < a.length; d++) a[d].length > b && ((b = a[d].length), (c = d)); return c; }; - b.setMonth( + (b.setMonth( d(this._get(a, c.match(/MM/) ? "monthNames" : "monthNamesShort")) ), b.setDate( d(this._get(a, c.match(/DD/) ? "dayNames" : "dayNamesShort")) + 20 - b.getDay() - ); + )); } a.input.attr("size", this._formatDate(a, b).length); } }, - _inlineDatepicker: function(a, b) { + _inlineDatepicker: function (a, b) { var c = $(a); c.hasClass(this.markerClassName) || (c .addClass(this.markerClassName) .append(b.dpDiv) - .bind("setData.datepicker", function(a, c, d) { + .bind("setData.datepicker", function (a, c, d) { b.settings[c] = d; }) - .bind("getData.datepicker", function(a, c) { + .bind("getData.datepicker", function (a, c) { return this._get(b, c); }), $.data(a, PROP_NAME, b), @@ -7030,12 +6996,12 @@ b.settings.disabled && this._disableDatepicker(a), b.dpDiv.css("display", "block")); }, - _dialogDatepicker: function(a, b, c, d, e) { + _dialogDatepicker: function (a, b, c, d, e) { var f = this._dialogInst; if (!f) { this.uuid += 1; var g = "dp" + this.uuid; - (this._dialogInput = $( + ((this._dialogInput = $( '' @@ -7044,12 +7010,12 @@ $("body").append(this._dialogInput), (f = this._dialogInst = this._newInst(this._dialogInput, !1)), (f.settings = {}), - $.data(this._dialogInput[0], PROP_NAME, f); + $.data(this._dialogInput[0], PROP_NAME, f)); } - extendRemove(f.settings, d || {}), + (extendRemove(f.settings, d || {}), (b = b && b.constructor == Date ? this._formatDate(f, b) : b), this._dialogInput.val(b), - (this._pos = e ? (e.length ? e : [e.pageX, e.pageY]) : null); + (this._pos = e ? (e.length ? e : [e.pageX, e.pageY]) : null)); if (!this._pos) { var h = document.documentElement.clientWidth, i = document.documentElement.clientHeight, @@ -7057,7 +7023,7 @@ k = document.documentElement.scrollTop || document.body.scrollTop; this._pos = [h / 2 - 100 + j, i / 2 - 150 + k]; } - this._dialogInput + (this._dialogInput .css("left", this._pos[0] + 20 + "px") .css("top", this._pos[1] + "px"), (f.settings.onSelect = c), @@ -7065,15 +7031,15 @@ this.dpDiv.addClass(this._dialogClass), this._showDatepicker(this._dialogInput[0]), $.blockUI && $.blockUI(this.dpDiv), - $.data(this._dialogInput[0], PROP_NAME, f); + $.data(this._dialogInput[0], PROP_NAME, f)); return this; }, - _destroyDatepicker: function(a) { + _destroyDatepicker: function (a) { var b = $(a), c = $.data(a, PROP_NAME); if (!!b.hasClass(this.markerClassName)) { var d = a.nodeName.toLowerCase(); - $.removeData(a, PROP_NAME), + ($.removeData(a, PROP_NAME), d == "input" ? (c.append.remove(), c.trigger.remove(), @@ -7084,87 +7050,87 @@ .unbind("keypress", this._doKeyPress) .unbind("keyup", this._doKeyUp)) : (d == "div" || d == "span") && - b.removeClass(this.markerClassName).empty(); + b.removeClass(this.markerClassName).empty()); } }, - _enableDatepicker: function(a) { + _enableDatepicker: function (a) { var b = $(a), c = $.data(a, PROP_NAME); if (!!b.hasClass(this.markerClassName)) { var d = a.nodeName.toLowerCase(); if (d == "input") - (a.disabled = !1), + ((a.disabled = !1), c.trigger .filter("button") - .each(function() { + .each(function () { this.disabled = !1; }) .end() .filter("img") - .css({ opacity: "1.0", cursor: "" }); + .css({ opacity: "1.0", cursor: "" })); else if (d == "div" || d == "span") { var e = b.children("." + this._inlineClass); - e.children().removeClass("ui-state-disabled"), + (e.children().removeClass("ui-state-disabled"), e .find("select.ui-datepicker-month, select.ui-datepicker-year") - .removeAttr("disabled"); + .removeAttr("disabled")); } - this._disabledInputs = $.map(this._disabledInputs, function(b) { + this._disabledInputs = $.map(this._disabledInputs, function (b) { return b == a ? null : b; }); } }, - _disableDatepicker: function(a) { + _disableDatepicker: function (a) { var b = $(a), c = $.data(a, PROP_NAME); if (!!b.hasClass(this.markerClassName)) { var d = a.nodeName.toLowerCase(); if (d == "input") - (a.disabled = !0), + ((a.disabled = !0), c.trigger .filter("button") - .each(function() { + .each(function () { this.disabled = !0; }) .end() .filter("img") - .css({ opacity: "0.5", cursor: "default" }); + .css({ opacity: "0.5", cursor: "default" })); else if (d == "div" || d == "span") { var e = b.children("." + this._inlineClass); - e.children().addClass("ui-state-disabled"), + (e.children().addClass("ui-state-disabled"), e .find("select.ui-datepicker-month, select.ui-datepicker-year") - .attr("disabled", "disabled"); + .attr("disabled", "disabled")); } - (this._disabledInputs = $.map(this._disabledInputs, function(b) { + ((this._disabledInputs = $.map(this._disabledInputs, function (b) { return b == a ? null : b; })), - (this._disabledInputs[this._disabledInputs.length] = a); + (this._disabledInputs[this._disabledInputs.length] = a)); } }, - _isDisabledDatepicker: function(a) { + _isDisabledDatepicker: function (a) { if (!a) return !1; for (var b = 0; b < this._disabledInputs.length; b++) if (this._disabledInputs[b] == a) return !0; return !1; }, - _getInst: function(a) { + _getInst: function (a) { try { return $.data(a, PROP_NAME); } catch (b) { throw "Missing instance data for this datepicker"; } }, - _optionDatepicker: function(a, b, c) { + _optionDatepicker: function (a, b, c) { var d = this._getInst(a); if (arguments.length == 2 && typeof b == "string") return b == "defaults" ? $.extend({}, $.datepicker._defaults) : d - ? b == "all" - ? $.extend({}, d.settings) - : this._get(d, b) - : null; + ? b == "all" + ? $.extend({}, d.settings) + : this._get(d, b) + : null; var e = b || {}; typeof b == "string" && ((e = {}), (e[b] = c)); if (d) { @@ -7172,7 +7138,7 @@ var f = this._getDateDatepicker(a, !0), g = this._getMinMaxDate(d, "min"), h = this._getMinMaxDate(d, "max"); - extendRemove(d.settings, e), + (extendRemove(d.settings, e), g !== null && e.dateFormat !== undefined && e.minDate === undefined && @@ -7185,29 +7151,29 @@ this._autoSize(d), this._setDate(d, f), this._updateAlternate(d), - this._updateDatepicker(d); + this._updateDatepicker(d)); } }, - _changeDatepicker: function(a, b, c) { + _changeDatepicker: function (a, b, c) { this._optionDatepicker(a, b, c); }, - _refreshDatepicker: function(a) { + _refreshDatepicker: function (a) { var b = this._getInst(a); b && this._updateDatepicker(b); }, - _setDateDatepicker: function(a, b) { + _setDateDatepicker: function (a, b) { var c = this._getInst(a); c && (this._setDate(c, b), this._updateDatepicker(c), this._updateAlternate(c)); }, - _getDateDatepicker: function(a, b) { + _getDateDatepicker: function (a, b) { var c = this._getInst(a); c && !c.inline && this._setDateFromField(c, b); return c ? this._getDate(c) : null; }, - _doKeyDown: function(a) { + _doKeyDown: function (a) { var b = $.datepicker._getInst(a.target), c = !0, d = b.dpDiv.is(".ui-datepicker-rtl"); @@ -7215,7 +7181,7 @@ if ($.datepicker._datepickerShowing) switch (a.keyCode) { case 9: - $.datepicker._hideDatepicker(), (c = !1); + ($.datepicker._hideDatepicker(), (c = !1)); break; case 13: var e = $( @@ -7261,15 +7227,15 @@ ); break; case 35: - (a.ctrlKey || a.metaKey) && $.datepicker._clearDate(a.target), - (c = a.ctrlKey || a.metaKey); + ((a.ctrlKey || a.metaKey) && $.datepicker._clearDate(a.target), + (c = a.ctrlKey || a.metaKey)); break; case 36: - (a.ctrlKey || a.metaKey) && $.datepicker._gotoToday(a.target), - (c = a.ctrlKey || a.metaKey); + ((a.ctrlKey || a.metaKey) && $.datepicker._gotoToday(a.target), + (c = a.ctrlKey || a.metaKey)); break; case 37: - (a.ctrlKey || a.metaKey) && + ((a.ctrlKey || a.metaKey) && $.datepicker._adjustDate(a.target, d ? 1 : -1, "D"), (c = a.ctrlKey || a.metaKey), a.originalEvent.altKey && @@ -7279,15 +7245,15 @@ ? -$.datepicker._get(b, "stepBigMonths") : -$.datepicker._get(b, "stepMonths"), "M" - ); + )); break; case 38: - (a.ctrlKey || a.metaKey) && + ((a.ctrlKey || a.metaKey) && $.datepicker._adjustDate(a.target, -7, "D"), - (c = a.ctrlKey || a.metaKey); + (c = a.ctrlKey || a.metaKey)); break; case 39: - (a.ctrlKey || a.metaKey) && + ((a.ctrlKey || a.metaKey) && $.datepicker._adjustDate(a.target, d ? -1 : 1, "D"), (c = a.ctrlKey || a.metaKey), a.originalEvent.altKey && @@ -7297,12 +7263,12 @@ ? +$.datepicker._get(b, "stepBigMonths") : +$.datepicker._get(b, "stepMonths"), "M" - ); + )); break; case 40: - (a.ctrlKey || a.metaKey) && + ((a.ctrlKey || a.metaKey) && $.datepicker._adjustDate(a.target, 7, "D"), - (c = a.ctrlKey || a.metaKey); + (c = a.ctrlKey || a.metaKey)); break; default: c = !1; @@ -7313,7 +7279,7 @@ : (c = !1); c && (a.preventDefault(), a.stopPropagation()); }, - _doKeyPress: function(a) { + _doKeyPress: function (a) { var b = $.datepicker._getInst(a.target); if ($.datepicker._get(b, "constrainInput")) { var c = $.datepicker._possibleChars($.datepicker._get(b, "dateFormat")), @@ -7323,7 +7289,7 @@ return a.ctrlKey || a.metaKey || d < " " || !c || c.indexOf(d) > -1; } }, - _doKeyUp: function(a) { + _doKeyUp: function (a) { var b = $.datepicker._getInst(a.target); if (b.input.val() != b.lastVal) try { @@ -7341,10 +7307,10 @@ } return !0; }, - _showDatepicker: function(a) { - (a = a.target || a), + _showDatepicker: function (a) { + ((a = a.target || a), a.nodeName.toLowerCase() != "input" && - (a = $("input", a.parentNode)[0]); + (a = $("input", a.parentNode)[0])); if ( !$.datepicker._isDisabledDatepicker(a) && $.datepicker._lastInput != a @@ -7359,27 +7325,27 @@ var c = $.datepicker._get(b, "beforeShow"), d = c ? c.apply(a, [a, b]) : {}; if (d === !1) return; - extendRemove(b.settings, d), + (extendRemove(b.settings, d), (b.lastVal = null), ($.datepicker._lastInput = a), $.datepicker._setDateFromField(b), $.datepicker._inDialog && (a.value = ""), $.datepicker._pos || (($.datepicker._pos = $.datepicker._findPos(a)), - ($.datepicker._pos[1] += a.offsetHeight)); + ($.datepicker._pos[1] += a.offsetHeight))); var e = !1; - $(a) + ($(a) .parents() - .each(function() { + .each(function () { e |= $(this).css("position") == "fixed"; return !e; }), e && $.browser.opera && (($.datepicker._pos[0] -= document.documentElement.scrollLeft), - ($.datepicker._pos[1] -= document.documentElement.scrollTop)); + ($.datepicker._pos[1] -= document.documentElement.scrollTop))); var f = { left: $.datepicker._pos[0], top: $.datepicker._pos[1] }; - ($.datepicker._pos = null), + (($.datepicker._pos = null), b.dpDiv.empty(), b.dpDiv.css({ position: "absolute", @@ -7393,16 +7359,16 @@ $.datepicker._inDialog && $.blockUI ? "static" : e - ? "fixed" - : "absolute", + ? "fixed" + : "absolute", display: "none", left: f.left + "px", top: f.top + "px" - }); + })); if (!b.inline) { var g = $.datepicker._get(b, "showAnim"), h = $.datepicker._get(b, "duration"), - i = function() { + i = function () { var a = b.dpDiv.find("iframe.ui-datepicker-cover"); if (!!a.length) { var c = $.datepicker._getBorders(b.dpDiv); @@ -7414,7 +7380,7 @@ }); } }; - b.dpDiv.zIndex($(a).zIndex() + 1), + (b.dpDiv.zIndex($(a).zIndex() + 1), ($.datepicker._datepickerShowing = !0), $.effects && $.effects[g] ? b.dpDiv.show(g, $.datepicker._get(b, "showOptions"), h, i) @@ -7423,28 +7389,28 @@ b.input.is(":visible") && !b.input.is(":disabled") && b.input.focus(), - ($.datepicker._curInst = b); + ($.datepicker._curInst = b)); } } }, - _updateDatepicker: function(a) { + _updateDatepicker: function (a) { var b = this; b.maxRows = 4; var c = $.datepicker._getBorders(a.dpDiv); - (instActive = a), a.dpDiv.empty().append(this._generateHTML(a)); + ((instActive = a), a.dpDiv.empty().append(this._generateHTML(a))); var d = a.dpDiv.find("iframe.ui-datepicker-cover"); - !d.length || + (!d.length || d.css({ left: -c[0], top: -c[1], width: a.dpDiv.outerWidth(), height: a.dpDiv.outerHeight() }), - a.dpDiv.find("." + this._dayOverClass + " a").mouseover(); + a.dpDiv.find("." + this._dayOverClass + " a").mouseover()); var e = this._getNumberOfMonths(a), f = e[1], g = 17; - a.dpDiv + (a.dpDiv .removeClass( "ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4" ) @@ -7465,21 +7431,21 @@ a.input.is(":visible") && !a.input.is(":disabled") && a.input[0] != document.activeElement && - a.input.focus(); + a.input.focus()); if (a.yearshtml) { var h = a.yearshtml; - setTimeout(function() { - h === a.yearshtml && + setTimeout(function () { + (h === a.yearshtml && a.yearshtml && a.dpDiv .find("select.ui-datepicker-year:first") .replaceWith(a.yearshtml), - (h = a.yearshtml = null); + (h = a.yearshtml = null)); }, 0); } }, - _getBorders: function(a) { - var b = function(a) { + _getBorders: function (a) { + var b = function (a) { return { thin: 1, medium: 2, thick: 3 }[a] || a; }; return [ @@ -7487,14 +7453,14 @@ parseFloat(b(a.css("border-top-width"))) ]; }, - _checkOffset: function(a, b, c) { + _checkOffset: function (a, b, c) { var d = a.dpDiv.outerWidth(), e = a.dpDiv.outerHeight(), f = a.input ? a.input.outerWidth() : 0, g = a.input ? a.input.outerHeight() : 0, h = document.documentElement.clientWidth + $(document).scrollLeft(), i = document.documentElement.clientHeight + $(document).scrollTop(); - (b.left -= this._get(a, "isRTL") ? d - f : 0), + ((b.left -= this._get(a, "isRTL") ? d - f : 0), (b.left -= c && b.left == a.input.offset().left ? $(document).scrollLeft() : 0), (b.top -= @@ -7506,10 +7472,10 @@ (b.top -= Math.min( b.top, b.top + e > i && i > e ? Math.abs(e + g) : 0 - )); + ))); return b; }, - _findPos: function(a) { + _findPos: function (a) { var b = this._getInst(a), c = this._get(b, "isRTL"); while ( @@ -7520,7 +7486,7 @@ var d = $(a).offset(); return [d.left, d.top]; }, - _hideDatepicker: function(a) { + _hideDatepicker: function (a) { var b = this._curInst; if ( !(!b || (a && b != $.data(a, PROP_NAME))) && @@ -7529,18 +7495,18 @@ var c = this._get(b, "showAnim"), d = this._get(b, "duration"), e = this, - f = function() { - $.datepicker._tidyDialog(b), (e._curInst = null); + f = function () { + ($.datepicker._tidyDialog(b), (e._curInst = null)); }; - $.effects && $.effects[c] + ($.effects && $.effects[c] ? b.dpDiv.hide(c, $.datepicker._get(b, "showOptions"), d, f) : b.dpDiv[ c == "slideDown" ? "slideUp" : c == "fadeIn" ? "fadeOut" : "hide" ](c ? d : null, f), c || f(), - (this._datepickerShowing = !1); + (this._datepickerShowing = !1)); var g = this._get(b, "onClose"); - g && + (g && g.apply(b.input ? b.input[0] : null, [ b.input ? b.input.val() : "", b @@ -7553,13 +7519,13 @@ top: "-100px" }), $.blockUI && ($.unblockUI(), $("body").append(this.dpDiv))), - (this._inDialog = !1); + (this._inDialog = !1)); } }, - _tidyDialog: function(a) { + _tidyDialog: function (a) { a.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar"); }, - _checkExternalClick: function(a) { + _checkExternalClick: function (a) { if (!!$.datepicker._curInst) { var b = $(a.target), c = $.datepicker._getInst(b[0]); @@ -7574,7 +7540,7 @@ $.datepicker._hideDatepicker(); } }, - _adjustDate: function(a, b, c) { + _adjustDate: function (a, b, c) { var d = $(a), e = this._getInst(d[0]); this._isDisabledDatepicker(d[0]) || @@ -7585,59 +7551,60 @@ ), this._updateDatepicker(e)); }, - _gotoToday: function(a) { + _gotoToday: function (a) { var b = $(a), c = this._getInst(b[0]); if (this._get(c, "gotoCurrent") && c.currentDay) - (c.selectedDay = c.currentDay), + ((c.selectedDay = c.currentDay), (c.drawMonth = c.selectedMonth = c.currentMonth), - (c.drawYear = c.selectedYear = c.currentYear); + (c.drawYear = c.selectedYear = c.currentYear)); else { var d = new Date(); - (c.selectedDay = d.getDate()), + ((c.selectedDay = d.getDate()), (c.drawMonth = c.selectedMonth = d.getMonth()), - (c.drawYear = c.selectedYear = d.getFullYear()); + (c.drawYear = c.selectedYear = d.getFullYear())); } - this._notifyChange(c), this._adjustDate(b); + (this._notifyChange(c), this._adjustDate(b)); }, - _selectMonthYear: function(a, b, c) { + _selectMonthYear: function (a, b, c) { var d = $(a), e = this._getInst(d[0]); - (e["selected" + (c == "M" ? "Month" : "Year")] = e[ + ((e["selected" + (c == "M" ? "Month" : "Year")] = e[ "draw" + (c == "M" ? "Month" : "Year") - ] = parseInt(b.options[b.selectedIndex].value, 10)), + ] = + parseInt(b.options[b.selectedIndex].value, 10)), this._notifyChange(e), - this._adjustDate(d); + this._adjustDate(d)); }, - _selectDay: function(a, b, c, d) { + _selectDay: function (a, b, c, d) { var e = $(a); if ( !$(d).hasClass(this._unselectableClass) && !this._isDisabledDatepicker(e[0]) ) { var f = this._getInst(e[0]); - (f.selectedDay = f.currentDay = $("a", d).html()), + ((f.selectedDay = f.currentDay = $("a", d).html()), (f.selectedMonth = f.currentMonth = b), (f.selectedYear = f.currentYear = c), this._selectDate( a, this._formatDate(f, f.currentDay, f.currentMonth, f.currentYear) - ); + )); } }, - _clearDate: function(a) { + _clearDate: function (a) { var b = $(a), c = this._getInst(b[0]); this._selectDate(b, ""); }, - _selectDate: function(a, b) { + _selectDate: function (a, b) { var c = $(a), d = this._getInst(c[0]); - (b = b != null ? b : this._formatDate(d)), + ((b = b != null ? b : this._formatDate(d)), d.input && d.input.val(b), - this._updateAlternate(d); + this._updateAlternate(d)); var e = this._get(d, "onSelect"); - e + (e ? e.apply(d.input ? d.input[0] : null, [b, d]) : d.input && d.input.trigger("change"), d.inline @@ -7645,31 +7612,31 @@ : (this._hideDatepicker(), (this._lastInput = d.input[0]), typeof d.input[0] != "object" && d.input.focus(), - (this._lastInput = null)); + (this._lastInput = null))); }, - _updateAlternate: function(a) { + _updateAlternate: function (a) { var b = this._get(a, "altField"); if (b) { var c = this._get(a, "altFormat") || this._get(a, "dateFormat"), d = this._getDate(a), e = this.formatDate(c, d, this._getFormatConfig(a)); - $(b).each(function() { + $(b).each(function () { $(this).val(e); }); } }, - noWeekends: function(a) { + noWeekends: function (a) { var b = a.getDay(); return [b > 0 && b < 6, ""]; }, - iso8601Week: function(a) { + iso8601Week: function (a) { var b = new Date(a.getTime()); b.setDate(b.getDate() + 4 - (b.getDay() || 7)); var c = b.getTime(); - b.setMonth(0), b.setDate(1); + (b.setMonth(0), b.setDate(1)); return Math.floor(Math.round((c - b) / 864e5) / 7) + 1; }, - parseDate: function(a, b, c) { + parseDate: function (a, b, c) { if (a == null || b == null) throw "Invalid arguments"; b = typeof b == "object" ? b.toString() : b + ""; if (b == "") return null; @@ -7687,47 +7654,47 @@ k = -1, l = -1, m = !1, - n = function(b) { + n = function (b) { var c = s + 1 < a.length && a.charAt(s + 1) == b; c && s++; return c; }, - o = function(a) { + o = function (a) { var c = n(a), d = a == "@" ? 14 : a == "!" - ? 20 - : a == "y" && c - ? 4 - : a == "o" - ? 3 - : 2, + ? 20 + : a == "y" && c + ? 4 + : a == "o" + ? 3 + : 2, e = new RegExp("^\\d{1," + d + "}"), f = b.substring(r).match(e); if (!f) throw "Missing number at position " + r; r += f[0].length; return parseInt(f[0], 10); }, - p = function(a, c, d) { - var e = $.map(n(a) ? d : c, function(a, b) { + p = function (a, c, d) { + var e = $.map(n(a) ? d : c, function (a, b) { return [[b, a]]; - }).sort(function(a, b) { + }).sort(function (a, b) { return -(a[1].length - b[1].length); }), f = -1; - $.each(e, function(a, c) { + $.each(e, function (a, c) { var d = c[1]; if (b.substr(r, d.length).toLowerCase() == d.toLowerCase()) { - (f = c[0]), (r += d.length); + ((f = c[0]), (r += d.length)); return !1; } }); if (f != -1) return f + 1; throw "Unknown name at position " + r; }, - q = function() { + q = function () { if (b.charAt(r) != a.charAt(s)) throw "Unexpected literal at position " + r; r++; @@ -7757,11 +7724,15 @@ break; case "@": var t = new Date(o("@")); - (i = t.getFullYear()), (j = t.getMonth() + 1), (k = t.getDate()); + ((i = t.getFullYear()), + (j = t.getMonth() + 1), + (k = t.getDate())); break; case "!": var t = new Date((o("!") - this._ticksTo1970) / 1e4); - (i = t.getFullYear()), (j = t.getMonth() + 1), (k = t.getDate()); + ((i = t.getFullYear()), + (j = t.getMonth() + 1), + (k = t.getDate())); break; case "'": n("'") ? q() : (m = !0); @@ -7779,11 +7750,11 @@ (new Date().getFullYear() % 100) + (i <= d ? 0 : -100)); if (l > -1) { - (j = 1), (k = l); + ((j = 1), (k = l)); for (;;) { var u = this._getDaysInMonth(i, j - 1); if (k <= u) break; - j++, (k -= u); + (j++, (k -= u)); } } var t = this._daylightSavingAdjust(new Date(i, j - 1, k)); @@ -7809,23 +7780,23 @@ 60 * 60 * 1e7, - formatDate: function(a, b, c) { + formatDate: function (a, b, c) { if (!b) return ""; var d = (c ? c.dayNamesShort : null) || this._defaults.dayNamesShort, e = (c ? c.dayNames : null) || this._defaults.dayNames, f = (c ? c.monthNamesShort : null) || this._defaults.monthNamesShort, g = (c ? c.monthNames : null) || this._defaults.monthNames, - h = function(b) { + h = function (b) { var c = m + 1 < a.length && a.charAt(m + 1) == b; c && m++; return c; }, - i = function(a, b, c) { + i = function (a, b, c) { var d = "" + b; if (h(a)) while (d.length < c) d = "0" + d; return d; }, - j = function(a, b, c, d) { + j = function (a, b, c, d) { return h(a) ? d[b] : c[b]; }, k = "", @@ -7881,10 +7852,10 @@ } return k; }, - _possibleChars: function(a) { + _possibleChars: function (a) { var b = "", c = !1, - d = function(b) { + d = function (b) { var c = e + 1 < a.length && a.charAt(e + 1) == b; c && e++; return c; @@ -7910,10 +7881,10 @@ } return b; }, - _get: function(a, b) { + _get: function (a, b) { return a.settings[b] !== undefined ? a.settings[b] : this._defaults[b]; }, - _setDateFromField: function(a, b) { + _setDateFromField: function (a, b) { if (a.input.val() != a.lastVal) { var c = this._get(a, "dateFormat"), d = (a.lastVal = a.input ? a.input.val() : null), @@ -7924,30 +7895,30 @@ try { e = this.parseDate(c, d, g) || f; } catch (h) { - this.log(h), (d = b ? "" : d); + (this.log(h), (d = b ? "" : d)); } - (a.selectedDay = e.getDate()), + ((a.selectedDay = e.getDate()), (a.drawMonth = a.selectedMonth = e.getMonth()), (a.drawYear = a.selectedYear = e.getFullYear()), (a.currentDay = d ? e.getDate() : 0), (a.currentMonth = d ? e.getMonth() : 0), (a.currentYear = d ? e.getFullYear() : 0), - this._adjustInstDate(a); + this._adjustInstDate(a)); } }, - _getDefaultDate: function(a) { + _getDefaultDate: function (a) { return this._restrictMinMax( a, this._determineDate(a, this._get(a, "defaultDate"), new Date()) ); }, - _determineDate: function(a, b, c) { - var d = function(a) { + _determineDate: function (a, b, c) { + var d = function (a) { var b = new Date(); b.setDate(b.getDate() + a); return b; }, - e = function(b) { + e = function (b) { try { return $.datepicker.parseDate( $.datepicker._get(a, "dateFormat"), @@ -7975,13 +7946,13 @@ break; case "m": case "M": - (f += parseInt(i[1], 10)), - (g = Math.min(g, $.datepicker._getDaysInMonth(e, f))); + ((f += parseInt(i[1], 10)), + (g = Math.min(g, $.datepicker._getDaysInMonth(e, f)))); break; case "y": case "Y": - (e += parseInt(i[1], 10)), - (g = Math.min(g, $.datepicker._getDaysInMonth(e, f))); + ((e += parseInt(i[1], 10)), + (g = Math.min(g, $.datepicker._getDaysInMonth(e, f)))); } i = h.exec(b); } @@ -7991,40 +7962,40 @@ b == null || b === "" ? c : typeof b == "string" - ? e(b) - : typeof b == "number" - ? isNaN(b) - ? c - : d(b) - : new Date(b.getTime()); - (f = f && f.toString() == "Invalid Date" ? c : f), + ? e(b) + : typeof b == "number" + ? isNaN(b) + ? c + : d(b) + : new Date(b.getTime()); + ((f = f && f.toString() == "Invalid Date" ? c : f), f && (f.setHours(0), f.setMinutes(0), f.setSeconds(0), - f.setMilliseconds(0)); + f.setMilliseconds(0))); return this._daylightSavingAdjust(f); }, - _daylightSavingAdjust: function(a) { + _daylightSavingAdjust: function (a) { if (!a) return null; a.setHours(a.getHours() > 12 ? a.getHours() + 2 : 0); return a; }, - _setDate: function(a, b, c) { + _setDate: function (a, b, c) { var d = !b, e = a.selectedMonth, f = a.selectedYear, g = this._restrictMinMax(a, this._determineDate(a, b, new Date())); - (a.selectedDay = a.currentDay = g.getDate()), + ((a.selectedDay = a.currentDay = g.getDate()), (a.drawMonth = a.selectedMonth = a.currentMonth = g.getMonth()), (a.drawYear = a.selectedYear = a.currentYear = g.getFullYear()), (e != a.selectedMonth || f != a.selectedYear) && !c && this._notifyChange(a), this._adjustInstDate(a), - a.input && a.input.val(d ? "" : this._formatDate(a)); + a.input && a.input.val(d ? "" : this._formatDate(a))); }, - _getDate: function(a) { + _getDate: function (a) { var b = !a.currentYear || (a.input && a.input.val() == "") ? null @@ -8033,7 +8004,7 @@ ); return b; }, - _generateHTML: function(a) { + _generateHTML: function (a) { var b = new Date(); b = this._daylightSavingAdjust( new Date(b.getFullYear(), b.getMonth(), b.getDate()) @@ -8062,9 +8033,9 @@ ); p = l && p < l ? l : p; while (this._daylightSavingAdjust(new Date(o, n, 1)) > p) - n--, n < 0 && ((n = 11), o--); + (n--, n < 0 && ((n = 11), o--)); } - (a.drawMonth = n), (a.drawYear = o); + ((a.drawMonth = n), (a.drawYear = o)); var q = this._get(a, "prevText"); q = f ? this.formatDate( @@ -8089,14 +8060,14 @@ q + "" : e - ? "" - : '' + - q + - "", + ? "" + : '' + + q + + "", s = this._get(a, "nextText"); s = f ? this.formatDate( @@ -8121,14 +8092,14 @@ s + "" : e - ? "" - : '' + - s + - "", + ? "" + : '' + + s + + "", u = this._get(a, "currentText"), v = this._get(a, "gotoCurrent") && a.currentDay ? k : b; u = f ? this.formatDate(u, v, this._getFormatConfig(a)) : u; @@ -8181,15 +8152,15 @@ if (g[1] > 1) switch (N) { case 0: - (Q += " ui-datepicker-group-first"), - (P = " ui-corner-" + (c ? "right" : "left")); + ((Q += " ui-datepicker-group-first"), + (P = " ui-corner-" + (c ? "right" : "left"))); break; case g[1] - 1: - (Q += " ui-datepicker-group-last"), - (P = " ui-corner-" + (c ? "left" : "right")); + ((Q += " ui-datepicker-group-last"), + (P = " ui-corner-" + (c ? "left" : "right"))); break; default: - (Q += " ui-datepicker-group-middle"), (P = ""); + ((Q += " ui-datepicker-group-middle"), (P = "")); } Q += '">'; } @@ -8240,7 +8211,7 @@ var ba = F ? F.apply(a.input ? a.input[0] : null, [Y]) : [!0, ""], bb = Y.getMonth() != n, bc = (bb && !H) || !ba[0] || (l && Y < l) || (m && Y > m); - (_ += + ((_ += '
    "), Y.setDate(Y.getDate() + 1), - (Y = this._daylightSavingAdjust(Y)); + (Y = this._daylightSavingAdjust(Y))); } Q += _ + ""; } - n++, + (n++, n > 11 && ((n = 0), o++), (Q += "
    ' + Y.getDate() + "" - : '' + - Y.getDate() + - "") + + ? '' + + Y.getDate() + + "" + : '' + + Y.getDate() + + "") + "
    " + @@ -8304,19 +8279,19 @@ ? '
    ' : "") : "")), - (M += Q); + (M += Q)); } K += M; } - (K += + ((K += x + ($.browser.msie && parseInt($.browser.version, 10) < 7 && !a.inline ? '' : "")), - (a._keyEvent = !1); + (a._keyEvent = !1)); return K; }, - _generateMonthYearHeader: function(a, b, c, d, e, f, g, h) { + _generateMonthYearHeader: function (a, b, c, d, e, f, g, h) { var i = this._get(a, "changeMonth"), j = this._get(a, "changeYear"), k = this._get(a, "showMonthAfterYear"), @@ -8353,17 +8328,17 @@ else { var q = this._get(a, "yearRange").split(":"), r = new Date().getFullYear(), - s = function(a) { + s = function (a) { var b = a.match(/c[+-].*/) ? c + parseInt(a.substring(1), 10) : a.match(/[+-].*/) - ? r + parseInt(a, 10) - : parseInt(a, 10); + ? r + parseInt(a, 10) + : parseInt(a, 10); return isNaN(b) ? r : b; }, t = s(q[0]), u = Math.max(t, s(q[1] || "")); - (t = d ? Math.max(t, d.getFullYear()) : t), + ((t = d ? Math.max(t, d.getFullYear()) : t), (u = e ? Math.min(u, e.getFullYear()) : u), (a.yearshtml += '"), + ((a.yearshtml += ""), (l += a.yearshtml), - (a.yearshtml = null); + (a.yearshtml = null)); } } - (l += this._get(a, "yearSuffix")), + ((l += this._get(a, "yearSuffix")), k && (l += (f || !i || !j ? " " : "") + m), - (l += ""); + (l += "")); return l; }, - _adjustInstDate: function(a, b, c) { + _adjustInstDate: function (a, b, c) { var d = a.drawYear + (c == "Y" ? b : 0), e = a.drawMonth + (c == "M" ? b : 0), f = @@ -8401,19 +8376,19 @@ a, this._daylightSavingAdjust(new Date(d, e, f)) ); - (a.selectedDay = g.getDate()), + ((a.selectedDay = g.getDate()), (a.drawMonth = a.selectedMonth = g.getMonth()), (a.drawYear = a.selectedYear = g.getFullYear()), - (c == "M" || c == "Y") && this._notifyChange(a); + (c == "M" || c == "Y") && this._notifyChange(a)); }, - _restrictMinMax: function(a, b) { + _restrictMinMax: function (a, b) { var c = this._getMinMaxDate(a, "min"), d = this._getMinMaxDate(a, "max"), e = c && b < c ? c : b; e = d && e > d ? d : e; return e; }, - _notifyChange: function(a) { + _notifyChange: function (a) { var b = this._get(a, "onChangeMonthYear"); b && b.apply(a.input ? a.input[0] : null, [ @@ -8422,20 +8397,20 @@ a ]); }, - _getNumberOfMonths: function(a) { + _getNumberOfMonths: function (a) { var b = this._get(a, "numberOfMonths"); return b == null ? [1, 1] : typeof b == "number" ? [1, b] : b; }, - _getMinMaxDate: function(a, b) { + _getMinMaxDate: function (a, b) { return this._determineDate(a, this._get(a, b + "Date"), null); }, - _getDaysInMonth: function(a, b) { + _getDaysInMonth: function (a, b) { return 32 - this._daylightSavingAdjust(new Date(a, b, 32)).getDate(); }, - _getFirstDayOfMonth: function(a, b) { + _getFirstDayOfMonth: function (a, b) { return new Date(a, b, 1).getDay(); }, - _canAdjustMonth: function(a, b, c, d) { + _canAdjustMonth: function (a, b, c, d) { var e = this._getNumberOfMonths(a), f = this._daylightSavingAdjust( new Date(c, d + (b < 0 ? b : e[0] * e[1]), 1) @@ -8443,14 +8418,14 @@ b < 0 && f.setDate(this._getDaysInMonth(f.getFullYear(), f.getMonth())); return this._isInRange(a, f); }, - _isInRange: function(a, b) { + _isInRange: function (a, b) { var c = this._getMinMaxDate(a, "min"), d = this._getMinMaxDate(a, "max"); return ( (!c || b.getTime() >= c.getTime()) && (!d || b.getTime() <= d.getTime()) ); }, - _getFormatConfig: function(a) { + _getFormatConfig: function (a) { var b = this._get(a, "shortYearCutoff"); b = typeof b != "string" @@ -8464,7 +8439,7 @@ monthNames: this._get(a, "monthNames") }; }, - _formatDate: function(a, b, c, d) { + _formatDate: function (a, b, c, d) { b || ((a.currentDay = a.selectedDay), (a.currentMonth = a.selectedMonth), @@ -8483,7 +8458,7 @@ ); } }), - ($.fn.datepicker = function(a) { + ($.fn.datepicker = function (a) { if (!this.length) return this; $.datepicker.initialized || ($(document) @@ -8509,7 +8484,7 @@ $.datepicker, [this[0]].concat(b) ); - return this.each(function() { + return this.each(function () { typeof a == "string" ? $.datepicker["_" + a + "Datepicker"].apply( $.datepicker, @@ -8522,7 +8497,7 @@ ($.datepicker.initialized = !1), ($.datepicker.uuid = new Date().getTime()), ($.datepicker.version = "1.8.17"), - (window["DP_jQuery_" + dpuuid] = $); + (window["DP_jQuery_" + dpuuid] = $)); })(jQuery); /* * jQuery UI Progressbar 1.8.17 @@ -8536,12 +8511,12 @@ * Depends: * jquery.ui.core.js * jquery.ui.widget.js - */ (function(a, b) { - a.widget("ui.progressbar", { + */ (function (a, b) { + (a.widget("ui.progressbar", { options: { value: 0, max: 100 }, min: 0, - _create: function() { - this.element + _create: function () { + (this.element .addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all") .attr({ role: "progressbar", @@ -8553,50 +8528,50 @@ "
    " ).appendTo(this.element)), (this.oldValue = this._value()), - this._refreshValue(); + this._refreshValue()); }, - destroy: function() { - this.element + destroy: function () { + (this.element .removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all") .removeAttr("role") .removeAttr("aria-valuemin") .removeAttr("aria-valuemax") .removeAttr("aria-valuenow"), this.valueDiv.remove(), - a.Widget.prototype.destroy.apply(this, arguments); + a.Widget.prototype.destroy.apply(this, arguments)); }, - value: function(a) { + value: function (a) { if (a === b) return this._value(); this._setOption("value", a); return this; }, - _setOption: function(b, c) { - b === "value" && + _setOption: function (b, c) { + (b === "value" && ((this.options.value = c), this._refreshValue(), this._value() === this.options.max && this._trigger("complete")), - a.Widget.prototype._setOption.apply(this, arguments); + a.Widget.prototype._setOption.apply(this, arguments)); }, - _value: function() { + _value: function () { var a = this.options.value; typeof a != "number" && (a = 0); return Math.min(this.options.max, Math.max(this.min, a)); }, - _percentage: function() { + _percentage: function () { return (100 * this._value()) / this.options.max; }, - _refreshValue: function() { + _refreshValue: function () { var a = this.value(), b = this._percentage(); - this.oldValue !== a && ((this.oldValue = a), this._trigger("change")), + (this.oldValue !== a && ((this.oldValue = a), this._trigger("change")), this.valueDiv .toggle(a > this.min) .toggleClass("ui-corner-right", a === this.options.max) .width(b.toFixed(0) + "%"), - this.element.attr("aria-valuenow", a); + this.element.attr("aria-valuenow", a)); } }), - a.extend(a.ui.progressbar, { version: "1.8.17" }); + a.extend(a.ui.progressbar, { version: "1.8.17" })); })(jQuery); /* * jQuery UI Effects 1.8.17 @@ -8607,27 +8582,27 @@ * * http://docs.jquery.com/UI/Effects/ */ jQuery.effects || - (function(a, b) { + (function (a, b) { function l(b) { if (!b || typeof b == "number" || a.fx.speeds[b]) return !0; if (typeof b == "string" && !a.effects[b]) return !0; return !1; } function k(b, c, d, e) { - typeof b == "object" && ((e = c), (d = null), (c = b), (b = c.effect)), - a.isFunction(c) && ((e = c), (d = null), (c = {})); - if (typeof c == "number" || a.fx.speeds[c]) (e = d), (d = c), (c = {}); - a.isFunction(d) && ((e = d), (d = null)), + (typeof b == "object" && ((e = c), (d = null), (c = b), (b = c.effect)), + a.isFunction(c) && ((e = c), (d = null), (c = {}))); + if (typeof c == "number" || a.fx.speeds[c]) ((e = d), (d = c), (c = {})); + (a.isFunction(d) && ((e = d), (d = null)), (c = c || {}), (d = d || c.duration), (d = a.fx.off ? 0 : typeof d == "number" - ? d - : d in a.fx.speeds - ? a.fx.speeds[d] - : a.fx.speeds._default), - (e = e || c.complete); + ? d + : d in a.fx.speeds + ? a.fx.speeds[d] + : a.fx.speeds._default), + (e = e || c.complete)); return [b, c, d, e]; } function j(a, b) { @@ -8639,13 +8614,13 @@ function i(b) { var c, d; for (c in b) - (d = b[c]), + ((d = b[c]), (d == null || a.isFunction(d) || c in g || /scrollbar/.test(c) || (!/color/i.test(c) && isNaN(parseFloat(d)))) && - delete b[c]; + delete b[c]); return b; } function h() { @@ -8658,12 +8633,12 @@ if (a && a.length && a[0] && a[a[0]]) { var e = a.length; while (e--) - (c = a[e]), + ((c = a[e]), typeof a[c] == "string" && - ((d = c.replace(/\-(\w)/g, function(a, b) { + ((d = c.replace(/\-(\w)/g, function (a, b) { return b.toUpperCase(); })), - (b[d] = a[c])); + (b[d] = a[c]))); } else for (c in a) typeof a[c] == "string" && (b[c] = a[c]); return b; } @@ -8680,15 +8655,17 @@ var c; if (b && b.constructor == Array && b.length == 3) return b; if ( - (c = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec( - b - )) + (c = + /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec( + b + )) ) return [parseInt(c[1], 10), parseInt(c[2], 10), parseInt(c[3], 10)]; if ( - (c = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec( - b - )) + (c = + /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec( + b + )) ) return [ parseFloat(c[1]) * 2.55, @@ -8706,7 +8683,7 @@ if ((c = /rgba\(0, 0, 0, 0\)/.exec(b))) return e.transparent; return e[a.trim(b).toLowerCase()]; } - (a.effects = {}), + ((a.effects = {}), a.each( [ "backgroundColor", @@ -8718,9 +8695,9 @@ "color", "outlineColor" ], - function(b, e) { - a.fx.step[e] = function(a) { - a.colorInit || + function (b, e) { + a.fx.step[e] = function (a) { + (a.colorInit || ((a.start = d(a.elem, e)), (a.end = c(a.end)), (a.colorInit = !0)), @@ -8749,10 +8726,10 @@ ), 0 ) + - ")"); + ")")); }; } - ); + )); var e = { aqua: [0, 255, 255], azure: [240, 255, 255], @@ -8811,15 +8788,15 @@ margin: 1, padding: 1 }; - (a.effects.animateClass = function(b, c, d, e) { + ((a.effects.animateClass = function (b, c, d, e) { a.isFunction(d) && ((e = d), (d = null)); - return this.queue(function() { + return this.queue(function () { var g = a(this), k = g.attr("style") || " ", l = i(h.call(this)), m, n = g.attr("class"); - a.each(f, function(a, c) { + (a.each(f, function (a, c) { b[c] && g[c + "Class"](b[c]); }), (m = i(h.call(this))), @@ -8828,8 +8805,8 @@ queue: !1, duration: c, easing: d, - complete: function() { - a.each(f, function(a, c) { + complete: function () { + (a.each(f, function (a, c) { b[c] && g[c + "Class"](b[c]); }), typeof g.attr("style") == "object" @@ -8837,26 +8814,26 @@ (g.attr("style").cssText = k)) : g.attr("style", k), e && e.apply(this, arguments), - a.dequeue(this); + a.dequeue(this)); } - }); + })); }); }), a.fn.extend({ _addClass: a.fn.addClass, - addClass: function(b, c, d, e) { + addClass: function (b, c, d, e) { return c ? a.effects.animateClass.apply(this, [{ add: b }, c, d, e]) : this._addClass(b); }, _removeClass: a.fn.removeClass, - removeClass: function(b, c, d, e) { + removeClass: function (b, c, d, e) { return c ? a.effects.animateClass.apply(this, [{ remove: b }, c, d, e]) : this._removeClass(b); }, _toggleClass: a.fn.toggleClass, - toggleClass: function(c, d, e, f, g) { + toggleClass: function (c, d, e, f, g) { return typeof d == "boolean" || d === b ? e ? a.effects.animateClass.apply(this, [ @@ -8868,7 +8845,7 @@ : this._toggleClass(c, d) : a.effects.animateClass.apply(this, [{ toggle: c }, d, e, f]); }, - switchClass: function(b, c, d, e, f) { + switchClass: function (b, c, d, e, f) { return a.effects.animateClass.apply(this, [ { add: c, remove: b }, d, @@ -8879,19 +8856,19 @@ }), a.extend(a.effects, { version: "1.8.17", - save: function(a, b) { + save: function (a, b) { for (var c = 0; c < b.length; c++) b[c] !== null && a.data("ec.storage." + b[c], a[0].style[b[c]]); }, - restore: function(a, b) { + restore: function (a, b) { for (var c = 0; c < b.length; c++) b[c] !== null && a.css(b[c], a.data("ec.storage." + b[c])); }, - setMode: function(a, b) { + setMode: function (a, b) { b == "toggle" && (b = a.is(":hidden") ? "show" : "hide"); return b; }, - getBaseline: function(a, b) { + getBaseline: function (a, b) { var c, d; switch (a[0]) { case "top": @@ -8921,24 +8898,22 @@ } return { x: d, y: c }; }, - createWrapper: function(b) { + createWrapper: function (b) { if (b.parent().is(".ui-effects-wrapper")) return b.parent(); var c = { width: b.outerWidth(!0), height: b.outerHeight(!0), float: b.css("float") }, - d = a("
    ") - .addClass("ui-effects-wrapper") - .css({ - fontSize: "100%", - background: "transparent", - border: "none", - margin: 0, - padding: 0 - }), + d = a("
    ").addClass("ui-effects-wrapper").css({ + fontSize: "100%", + background: "transparent", + border: "none", + margin: 0, + padding: 0 + }), e = document.activeElement; - b.wrap(d), + (b.wrap(d), (b[0] === e || a.contains(b[0], e)) && a(e).focus(), (d = b.parent()), b.css("position") == "static" @@ -8948,9 +8923,9 @@ position: b.css("position"), zIndex: b.css("z-index") }), - a.each(["top", "left", "bottom", "right"], function(a, d) { - (c[d] = b.css(d)), - isNaN(parseInt(c[d], 10)) && (c[d] = "auto"); + a.each(["top", "left", "bottom", "right"], function (a, d) { + ((c[d] = b.css(d)), + isNaN(parseInt(c[d], 10)) && (c[d] = "auto")); }), b.css({ position: "relative", @@ -8958,30 +8933,30 @@ left: 0, right: "auto", bottom: "auto" - })); + }))); return d.css(c).show(); }, - removeWrapper: function(b) { + removeWrapper: function (b) { var c, d = document.activeElement; if (b.parent().is(".ui-effects-wrapper")) { - (c = b.parent().replaceWith(b)), - (b[0] === d || a.contains(b[0], d)) && a(d).focus(); + ((c = b.parent().replaceWith(b)), + (b[0] === d || a.contains(b[0], d)) && a(d).focus()); return c; } return b; }, - setTransition: function(b, c, d, e) { - (e = e || {}), - a.each(c, function(a, c) { - (unit = b.cssUnit(c)), - unit[0] > 0 && (e[c] = unit[0] * d + unit[1]); - }); + setTransition: function (b, c, d, e) { + ((e = e || {}), + a.each(c, function (a, c) { + ((unit = b.cssUnit(c)), + unit[0] > 0 && (e[c] = unit[0] * d + unit[1])); + })); return e; } }), a.fn.extend({ - effect: function(b, c, d, e) { + effect: function (b, c, d, e) { var f = k.apply(this, arguments), g = { options: f[1], duration: f[2], callback: f[3] }, h = g.options.mode, @@ -8989,37 +8964,37 @@ if (a.fx.off || !i) return h ? this[h](g.duration, g.callback) - : this.each(function() { + : this.each(function () { g.callback && g.callback.call(this); }); return i.call(this, g); }, _show: a.fn.show, - show: function(a) { + show: function (a) { if (l(a)) return this._show.apply(this, arguments); var b = k.apply(this, arguments); b[1].mode = "show"; return this.effect.apply(this, b); }, _hide: a.fn.hide, - hide: function(a) { + hide: function (a) { if (l(a)) return this._hide.apply(this, arguments); var b = k.apply(this, arguments); b[1].mode = "hide"; return this.effect.apply(this, b); }, __toggle: a.fn.toggle, - toggle: function(b) { + toggle: function (b) { if (l(b) || typeof b == "boolean" || a.isFunction(b)) return this.__toggle.apply(this, arguments); var c = k.apply(this, arguments); c[1].mode = "toggle"; return this.effect.apply(this, c); }, - cssUnit: function(b) { + cssUnit: function (b) { var c = this.css(b), d = []; - a.each(["em", "px", "%", "pt"], function(a, b) { + a.each(["em", "px", "%", "pt"], function (a, b) { c.indexOf(b) > 0 && (d = [parseFloat(c), b]); }); return d; @@ -9028,82 +9003,82 @@ (a.easing.jswing = a.easing.swing), a.extend(a.easing, { def: "easeOutQuad", - swing: function(b, c, d, e, f) { + swing: function (b, c, d, e, f) { return a.easing[a.easing.def](b, c, d, e, f); }, - easeInQuad: function(a, b, c, d, e) { + easeInQuad: function (a, b, c, d, e) { return d * (b /= e) * b + c; }, - easeOutQuad: function(a, b, c, d, e) { + easeOutQuad: function (a, b, c, d, e) { return -d * (b /= e) * (b - 2) + c; }, - easeInOutQuad: function(a, b, c, d, e) { + easeInOutQuad: function (a, b, c, d, e) { if ((b /= e / 2) < 1) return (d / 2) * b * b + c; return (-d / 2) * (--b * (b - 2) - 1) + c; }, - easeInCubic: function(a, b, c, d, e) { + easeInCubic: function (a, b, c, d, e) { return d * (b /= e) * b * b + c; }, - easeOutCubic: function(a, b, c, d, e) { + easeOutCubic: function (a, b, c, d, e) { return d * ((b = b / e - 1) * b * b + 1) + c; }, - easeInOutCubic: function(a, b, c, d, e) { + easeInOutCubic: function (a, b, c, d, e) { if ((b /= e / 2) < 1) return (d / 2) * b * b * b + c; return (d / 2) * ((b -= 2) * b * b + 2) + c; }, - easeInQuart: function(a, b, c, d, e) { + easeInQuart: function (a, b, c, d, e) { return d * (b /= e) * b * b * b + c; }, - easeOutQuart: function(a, b, c, d, e) { + easeOutQuart: function (a, b, c, d, e) { return -d * ((b = b / e - 1) * b * b * b - 1) + c; }, - easeInOutQuart: function(a, b, c, d, e) { + easeInOutQuart: function (a, b, c, d, e) { if ((b /= e / 2) < 1) return (d / 2) * b * b * b * b + c; return (-d / 2) * ((b -= 2) * b * b * b - 2) + c; }, - easeInQuint: function(a, b, c, d, e) { + easeInQuint: function (a, b, c, d, e) { return d * (b /= e) * b * b * b * b + c; }, - easeOutQuint: function(a, b, c, d, e) { + easeOutQuint: function (a, b, c, d, e) { return d * ((b = b / e - 1) * b * b * b * b + 1) + c; }, - easeInOutQuint: function(a, b, c, d, e) { + easeInOutQuint: function (a, b, c, d, e) { if ((b /= e / 2) < 1) return (d / 2) * b * b * b * b * b + c; return (d / 2) * ((b -= 2) * b * b * b * b + 2) + c; }, - easeInSine: function(a, b, c, d, e) { + easeInSine: function (a, b, c, d, e) { return -d * Math.cos((b / e) * (Math.PI / 2)) + d + c; }, - easeOutSine: function(a, b, c, d, e) { + easeOutSine: function (a, b, c, d, e) { return d * Math.sin((b / e) * (Math.PI / 2)) + c; }, - easeInOutSine: function(a, b, c, d, e) { + easeInOutSine: function (a, b, c, d, e) { return (-d / 2) * (Math.cos((Math.PI * b) / e) - 1) + c; }, - easeInExpo: function(a, b, c, d, e) { + easeInExpo: function (a, b, c, d, e) { return b == 0 ? c : d * Math.pow(2, 10 * (b / e - 1)) + c; }, - easeOutExpo: function(a, b, c, d, e) { + easeOutExpo: function (a, b, c, d, e) { return b == e ? c + d : d * (-Math.pow(2, (-10 * b) / e) + 1) + c; }, - easeInOutExpo: function(a, b, c, d, e) { + easeInOutExpo: function (a, b, c, d, e) { if (b == 0) return c; if (b == e) return c + d; if ((b /= e / 2) < 1) return (d / 2) * Math.pow(2, 10 * (b - 1)) + c; return (d / 2) * (-Math.pow(2, -10 * --b) + 2) + c; }, - easeInCirc: function(a, b, c, d, e) { + easeInCirc: function (a, b, c, d, e) { return -d * (Math.sqrt(1 - (b /= e) * b) - 1) + c; }, - easeOutCirc: function(a, b, c, d, e) { + easeOutCirc: function (a, b, c, d, e) { return d * Math.sqrt(1 - (b = b / e - 1) * b) + c; }, - easeInOutCirc: function(a, b, c, d, e) { + easeInOutCirc: function (a, b, c, d, e) { if ((b /= e / 2) < 1) return (-d / 2) * (Math.sqrt(1 - b * b) - 1) + c; return (d / 2) * (Math.sqrt(1 - (b -= 2) * b) + 1) + c; }, - easeInElastic: function(a, b, c, d, e) { + easeInElastic: function (a, b, c, d, e) { var f = 1.70158, g = 0, h = d; @@ -9122,7 +9097,7 @@ ) + c ); }, - easeOutElastic: function(a, b, c, d, e) { + easeOutElastic: function (a, b, c, d, e) { var f = 1.70158, g = 0, h = d; @@ -9141,7 +9116,7 @@ c ); }, - easeInOutElastic: function(a, b, c, d, e) { + easeInOutElastic: function (a, b, c, d, e) { var f = 1.70158, g = 0, h = d; @@ -9169,15 +9144,15 @@ c ); }, - easeInBack: function(a, c, d, e, f, g) { + easeInBack: function (a, c, d, e, f, g) { g == b && (g = 1.70158); return e * (c /= f) * c * ((g + 1) * c - g) + d; }, - easeOutBack: function(a, c, d, e, f, g) { + easeOutBack: function (a, c, d, e, f, g) { g == b && (g = 1.70158); return e * ((c = c / f - 1) * c * ((g + 1) * c + g) + 1) + d; }, - easeInOutBack: function(a, c, d, e, f, g) { + easeInOutBack: function (a, c, d, e, f, g) { g == b && (g = 1.70158); if ((c /= f / 2) < 1) return (e / 2) * c * c * (((g *= 1.525) + 1) * c - g) + d; @@ -9185,26 +9160,26 @@ (e / 2) * ((c -= 2) * c * (((g *= 1.525) + 1) * c + g) + 2) + d ); }, - easeInBounce: function(b, c, d, e, f) { + easeInBounce: function (b, c, d, e, f) { return e - a.easing.easeOutBounce(b, f - c, 0, e, f) + d; }, - easeOutBounce: function(a, b, c, d, e) { + easeOutBounce: function (a, b, c, d, e) { return (b /= e) < 1 / 2.75 ? d * 7.5625 * b * b + c : b < 2 / 2.75 - ? d * (7.5625 * (b -= 1.5 / 2.75) * b + 0.75) + c - : b < 2.5 / 2.75 - ? d * (7.5625 * (b -= 2.25 / 2.75) * b + 0.9375) + c - : d * (7.5625 * (b -= 2.625 / 2.75) * b + 0.984375) + c; + ? d * (7.5625 * (b -= 1.5 / 2.75) * b + 0.75) + c + : b < 2.5 / 2.75 + ? d * (7.5625 * (b -= 2.25 / 2.75) * b + 0.9375) + c + : d * (7.5625 * (b -= 2.625 / 2.75) * b + 0.984375) + c; }, - easeInOutBounce: function(b, c, d, e, f) { + easeInOutBounce: function (b, c, d, e, f) { if (c < f / 2) return a.easing.easeInBounce(b, c * 2, 0, e, f) * 0.5 + d; return ( a.easing.easeOutBounce(b, c * 2 - f, 0, e, f) * 0.5 + e * 0.5 + d ); } - }); + })); })(jQuery); /* * jQuery UI Effects Blind 1.8.17 @@ -9217,27 +9192,27 @@ * * Depends: * jquery.effects.core.js - */ (function(a, b) { - a.effects.blind = function(b) { - return this.queue(function() { + */ (function (a, b) { + a.effects.blind = function (b) { + return this.queue(function () { var c = a(this), d = ["position", "top", "bottom", "left", "right"], e = a.effects.setMode(c, b.options.mode || "hide"), f = b.options.direction || "vertical"; - a.effects.save(c, d), c.show(); + (a.effects.save(c, d), c.show()); var g = a.effects.createWrapper(c).css({ overflow: "hidden" }), h = f == "vertical" ? "height" : "width", i = f == "vertical" ? g.height() : g.width(); e == "show" && g.css(h, 0); var j = {}; - (j[h] = e == "show" ? i : 0), - g.animate(j, b.duration, b.options.easing, function() { - e == "hide" && c.hide(), + ((j[h] = e == "show" ? i : 0), + g.animate(j, b.duration, b.options.easing, function () { + (e == "hide" && c.hide(), a.effects.restore(c, d), a.effects.removeWrapper(c), b.callback && b.callback.apply(c[0], arguments), - c.dequeue(); - }); + c.dequeue()); + })); }); }; })(jQuery); @@ -9252,9 +9227,9 @@ * * Depends: * jquery.effects.core.js - */ (function(a, b) { - a.effects.bounce = function(b) { - return this.queue(function() { + */ (function (a, b) { + a.effects.bounce = function (b) { + return this.queue(function () { var c = a(this), d = ["position", "top", "bottom", "left", "right"], e = a.effects.setMode(c, b.options.mode || "effect"), @@ -9262,10 +9237,10 @@ g = b.options.distance || 20, h = b.options.times || 5, i = b.duration || 250; - /show|hide/.test(e) && d.push("opacity"), + (/show|hide/.test(e) && d.push("opacity"), a.effects.save(c, d), c.show(), - a.effects.createWrapper(c); + a.effects.createWrapper(c)); var j = f == "up" || f == "down" ? "top" : "left", k = f == "up" || f == "left" ? "pos" : "neg", g = @@ -9273,52 +9248,52 @@ (j == "top" ? c.outerHeight({ margin: !0 }) / 3 : c.outerWidth({ margin: !0 }) / 3); - e == "show" && c.css("opacity", 0).css(j, k == "pos" ? -g : g), + (e == "show" && c.css("opacity", 0).css(j, k == "pos" ? -g : g), e == "hide" && (g = g / (h * 2)), - e != "hide" && h--; + e != "hide" && h--); if (e == "show") { var l = { opacity: 1 }; - (l[j] = (k == "pos" ? "+=" : "-=") + g), + ((l[j] = (k == "pos" ? "+=" : "-=") + g), c.animate(l, i / 2, b.options.easing), (g = g / 2), - h--; + h--); } for (var m = 0; m < h; m++) { var n = {}, p = {}; - (n[j] = (k == "pos" ? "-=" : "+=") + g), + ((n[j] = (k == "pos" ? "-=" : "+=") + g), (p[j] = (k == "pos" ? "+=" : "-=") + g), c .animate(n, i / 2, b.options.easing) .animate(p, i / 2, b.options.easing), - (g = e == "hide" ? g * 2 : g / 2); + (g = e == "hide" ? g * 2 : g / 2)); } if (e == "hide") { var l = { opacity: 0 }; - (l[j] = (k == "pos" ? "-=" : "+=") + g), - c.animate(l, i / 2, b.options.easing, function() { - c.hide(), + ((l[j] = (k == "pos" ? "-=" : "+=") + g), + c.animate(l, i / 2, b.options.easing, function () { + (c.hide(), a.effects.restore(c, d), a.effects.removeWrapper(c), - b.callback && b.callback.apply(this, arguments); - }); + b.callback && b.callback.apply(this, arguments)); + })); } else { var n = {}, p = {}; - (n[j] = (k == "pos" ? "-=" : "+=") + g), + ((n[j] = (k == "pos" ? "-=" : "+=") + g), (p[j] = (k == "pos" ? "+=" : "-=") + g), c .animate(n, i / 2, b.options.easing) - .animate(p, i / 2, b.options.easing, function() { - a.effects.restore(c, d), + .animate(p, i / 2, b.options.easing, function () { + (a.effects.restore(c, d), a.effects.removeWrapper(c), - b.callback && b.callback.apply(this, arguments); - }); + b.callback && b.callback.apply(this, arguments)); + })); } - c.queue("fx", function() { + (c.queue("fx", function () { c.dequeue(); }), - c.dequeue(); + c.dequeue()); }); }; })(jQuery); @@ -9333,14 +9308,14 @@ * * Depends: * jquery.effects.core.js - */ (function(a, b) { - a.effects.clip = function(b) { - return this.queue(function() { + */ (function (a, b) { + a.effects.clip = function (b) { + return this.queue(function () { var c = a(this), d = ["position", "top", "bottom", "left", "right", "height", "width"], e = a.effects.setMode(c, b.options.mode || "hide"), f = b.options.direction || "vertical"; - a.effects.save(c, d), c.show(); + (a.effects.save(c, d), c.show()); var g = a.effects.createWrapper(c).css({ overflow: "hidden" }), h = c[0].tagName == "IMG" ? g : c, i = { @@ -9350,20 +9325,20 @@ j = f == "vertical" ? h.height() : h.width(); e == "show" && (h.css(i.size, 0), h.css(i.position, j / 2)); var k = {}; - (k[i.size] = e == "show" ? j : 0), + ((k[i.size] = e == "show" ? j : 0), (k[i.position] = e == "show" ? 0 : j / 2), h.animate(k, { queue: !1, duration: b.duration, easing: b.options.easing, - complete: function() { - e == "hide" && c.hide(), + complete: function () { + (e == "hide" && c.hide(), a.effects.restore(c, d), a.effects.removeWrapper(c), b.callback && b.callback.apply(c[0], arguments), - c.dequeue(); + c.dequeue()); } - }); + })); }); }; })(jQuery); @@ -9378,14 +9353,14 @@ * * Depends: * jquery.effects.core.js - */ (function(a, b) { - a.effects.drop = function(b) { - return this.queue(function() { + */ (function (a, b) { + a.effects.drop = function (b) { + return this.queue(function () { var c = a(this), d = ["position", "top", "bottom", "left", "right", "opacity"], e = a.effects.setMode(c, b.options.mode || "hide"), f = b.options.direction || "left"; - a.effects.save(c, d), c.show(), a.effects.createWrapper(c); + (a.effects.save(c, d), c.show(), a.effects.createWrapper(c)); var g = f == "up" || f == "down" ? "top" : "left", h = f == "up" || f == "left" ? "pos" : "neg", i = @@ -9395,21 +9370,21 @@ : c.outerWidth({ margin: !0 }) / 2); e == "show" && c.css("opacity", 0).css(g, h == "pos" ? -i : i); var j = { opacity: e == "show" ? 1 : 0 }; - (j[g] = + ((j[g] = (e == "show" ? (h == "pos" ? "+=" : "-=") : h == "pos" ? "-=" : "+=") + i), c.animate(j, { queue: !1, duration: b.duration, easing: b.options.easing, - complete: function() { - e == "hide" && c.hide(), + complete: function () { + (e == "hide" && c.hide(), a.effects.restore(c, d), a.effects.removeWrapper(c), b.callback && b.callback.apply(this, arguments), - c.dequeue(); + c.dequeue()); } - }); + })); }); }; })(jQuery); @@ -9424,9 +9399,9 @@ * * Depends: * jquery.effects.core.js - */ (function(a, b) { - a.effects.explode = function(b) { - return this.queue(function() { + */ (function (a, b) { + a.effects.explode = function (b) { + return this.queue(function () { var c = b.options.pieces ? Math.round(Math.sqrt(b.options.pieces)) : 3, d = b.options.pieces ? Math.round(Math.sqrt(b.options.pieces)) : 3; b.options.mode = @@ -9435,12 +9410,10 @@ ? "hide" : "show" : b.options.mode; - var e = a(this) - .show() - .css("visibility", "hidden"), + var e = a(this).show().css("visibility", "hidden"), f = e.offset(); - (f.top -= parseInt(e.css("marginTop"), 10) || 0), - (f.left -= parseInt(e.css("marginLeft"), 10) || 0); + ((f.top -= parseInt(e.css("marginTop"), 10) || 0), + (f.left -= parseInt(e.css("marginLeft"), 10) || 0)); var g = e.outerWidth(!0), h = e.outerHeight(!0); for (var i = 0; i < c; i++) @@ -9493,13 +9466,13 @@ }, b.duration || 500 ); - setTimeout(function() { - b.options.mode == "show" + setTimeout(function () { + (b.options.mode == "show" ? e.css({ visibility: "visible" }) : e.css({ visibility: "visible" }).hide(), b.callback && b.callback.apply(e[0]), e.dequeue(), - a("div.ui-effects-explode").remove(); + a("div.ui-effects-explode").remove()); }, b.duration || 500); }); }; @@ -9515,9 +9488,9 @@ * * Depends: * jquery.effects.core.js - */ (function(a, b) { - a.effects.fade = function(b) { - return this.queue(function() { + */ (function (a, b) { + a.effects.fade = function (b) { + return this.queue(function () { var c = a(this), d = a.effects.setMode(c, b.options.mode || "hide"); c.animate( @@ -9526,8 +9499,8 @@ queue: !1, duration: b.duration, easing: b.options.easing, - complete: function() { - b.callback && b.callback.apply(this, arguments), c.dequeue(); + complete: function () { + (b.callback && b.callback.apply(this, arguments), c.dequeue()); } } ); @@ -9545,37 +9518,37 @@ * * Depends: * jquery.effects.core.js - */ (function(a, b) { - a.effects.fold = function(b) { - return this.queue(function() { + */ (function (a, b) { + a.effects.fold = function (b) { + return this.queue(function () { var c = a(this), d = ["position", "top", "bottom", "left", "right"], e = a.effects.setMode(c, b.options.mode || "hide"), f = b.options.size || 15, g = !!b.options.horizFirst, h = b.duration ? b.duration / 2 : a.fx.speeds._default / 2; - a.effects.save(c, d), c.show(); + (a.effects.save(c, d), c.show()); var i = a.effects.createWrapper(c).css({ overflow: "hidden" }), j = (e == "show") != g, k = j ? ["width", "height"] : ["height", "width"], l = j ? [i.width(), i.height()] : [i.height(), i.width()], m = /([0-9]+)%/.exec(f); - m && (f = (parseInt(m[1], 10) / 100) * l[e == "hide" ? 0 : 1]), + (m && (f = (parseInt(m[1], 10) / 100) * l[e == "hide" ? 0 : 1]), e == "show" && - i.css(g ? { height: 0, width: f } : { height: f, width: 0 }); + i.css(g ? { height: 0, width: f } : { height: f, width: 0 })); var n = {}, p = {}; - (n[k[0]] = e == "show" ? l[0] : f), + ((n[k[0]] = e == "show" ? l[0] : f), (p[k[1]] = e == "show" ? l[1] : 0), i .animate(n, h, b.options.easing) - .animate(p, h, b.options.easing, function() { - e == "hide" && c.hide(), + .animate(p, h, b.options.easing, function () { + (e == "hide" && c.hide(), a.effects.restore(c, d), a.effects.removeWrapper(c), b.callback && b.callback.apply(c[0], arguments), - c.dequeue(); - }); + c.dequeue()); + })); }); }; })(jQuery); @@ -9590,14 +9563,14 @@ * * Depends: * jquery.effects.core.js - */ (function(a, b) { - a.effects.highlight = function(b) { - return this.queue(function() { + */ (function (a, b) { + a.effects.highlight = function (b) { + return this.queue(function () { var c = a(this), d = ["backgroundImage", "backgroundColor", "opacity"], e = a.effects.setMode(c, b.options.mode || "show"), f = { backgroundColor: c.css("backgroundColor") }; - e == "hide" && (f.opacity = 0), + (e == "hide" && (f.opacity = 0), a.effects.save(c, d), c .show() @@ -9609,16 +9582,16 @@ queue: !1, duration: b.duration, easing: b.options.easing, - complete: function() { - e == "hide" && c.hide(), + complete: function () { + (e == "hide" && c.hide(), a.effects.restore(c, d), e == "show" && !a.support.opacity && this.style.removeAttribute("filter"), b.callback && b.callback.apply(this, arguments), - c.dequeue(); + c.dequeue()); } - }); + })); }); }; })(jQuery); @@ -9633,29 +9606,34 @@ * * Depends: * jquery.effects.core.js - */ (function(a, b) { - a.effects.pulsate = function(b) { - return this.queue(function() { + */ (function (a, b) { + a.effects.pulsate = function (b) { + return this.queue(function () { var c = a(this), d = a.effects.setMode(c, b.options.mode || "show"); - (times = (b.options.times || 5) * 2 - 1), + ((times = (b.options.times || 5) * 2 - 1), (duration = b.duration ? b.duration / 2 : a.fx.speeds._default / 2), (isVisible = c.is(":visible")), (animateTo = 0), isVisible || (c.css("opacity", 0).show(), (animateTo = 1)), - ((d == "hide" && isVisible) || (d == "show" && !isVisible)) && times--; + ((d == "hide" && isVisible) || (d == "show" && !isVisible)) && times--); for (var e = 0; e < times; e++) - c.animate({ opacity: animateTo }, duration, b.options.easing), - (animateTo = (animateTo + 1) % 2); - c.animate({ opacity: animateTo }, duration, b.options.easing, function() { - animateTo == 0 && c.hide(), - b.callback && b.callback.apply(this, arguments); - }), + (c.animate({ opacity: animateTo }, duration, b.options.easing), + (animateTo = (animateTo + 1) % 2)); + (c.animate( + { opacity: animateTo }, + duration, + b.options.easing, + function () { + (animateTo == 0 && c.hide(), + b.callback && b.callback.apply(this, arguments)); + } + ), c - .queue("fx", function() { + .queue("fx", function () { c.dequeue(); }) - .dequeue(); + .dequeue()); }); }; })(jQuery); @@ -9670,26 +9648,26 @@ * * Depends: * jquery.effects.core.js - */ (function(a, b) { - (a.effects.puff = function(b) { - return this.queue(function() { + */ (function (a, b) { + ((a.effects.puff = function (b) { + return this.queue(function () { var c = a(this), d = a.effects.setMode(c, b.options.mode || "hide"), e = parseInt(b.options.percent, 10) || 150, f = e / 100, g = { height: c.height(), width: c.width() }; - a.extend(b.options, { + (a.extend(b.options, { fade: !0, mode: d, percent: d == "hide" ? e : 100, from: d == "hide" ? g : { height: g.height * f, width: g.width * f } }), c.effect("scale", b.options, b.duration, b.callback), - c.dequeue(); + c.dequeue()); }); }), - (a.effects.scale = function(b) { - return this.queue(function() { + (a.effects.scale = function (b) { + return this.queue(function () { var c = a(this), d = a.extend(!0, {}, b.options), e = a.effects.setMode(c, b.options.mode || "effect"), @@ -9706,7 +9684,7 @@ y: g != "horizontal" ? f / 100 : 1, x: g != "vertical" ? f / 100 : 1 }; - (c.to = { height: i.height * j.y, width: i.width * j.x }), + ((c.to = { height: i.height * j.y, width: i.width * j.x }), b.options.fade && (e == "show" && ((c.from.opacity = 0), (c.to.opacity = 1)), e == "hide" && ((c.from.opacity = 1), (c.to.opacity = 0))), @@ -9714,11 +9692,11 @@ (d.to = c.to), (d.mode = e), c.effect("size", d, b.duration, b.callback), - c.dequeue(); + c.dequeue()); }); }), - (a.effects.size = function(b) { - return this.queue(function() { + (a.effects.size = function (b) { + return this.queue(function () { var c = a(this), d = [ "position", @@ -9759,28 +9737,28 @@ l = b.options.scale || "both", m = b.options.origin, n = { height: c.height(), width: c.width() }; - (c.from = b.options.from || n), (c.to = b.options.to || n); + ((c.from = b.options.from || n), (c.to = b.options.to || n)); if (m) { var p = a.effects.getBaseline(m, n); - (c.from.top = (n.height - c.from.height) * p.y), + ((c.from.top = (n.height - c.from.height) * p.y), (c.from.left = (n.width - c.from.width) * p.x), (c.to.top = (n.height - c.to.height) * p.y), - (c.to.left = (n.width - c.to.width) * p.x); + (c.to.left = (n.width - c.to.width) * p.x)); } var q = { from: { y: c.from.height / n.height, x: c.from.width / n.width }, to: { y: c.to.height / n.height, x: c.to.width / n.width } }; if (l == "box" || l == "both") - q.from.y != q.to.y && + (q.from.y != q.to.y && ((d = d.concat(h)), (c.from = a.effects.setTransition(c, h, q.from.y, c.from)), (c.to = a.effects.setTransition(c, h, q.to.y, c.to))), q.from.x != q.to.x && ((d = d.concat(i)), (c.from = a.effects.setTransition(c, i, q.from.x, c.from)), - (c.to = a.effects.setTransition(c, i, q.to.x, c.to))); - (l == "content" || l == "both") && + (c.to = a.effects.setTransition(c, i, q.to.x, c.to)))); + ((l == "content" || l == "both") && q.from.y != q.to.y && ((d = d.concat(g)), (c.from = a.effects.setTransition(c, g, q.from.y, c.from)), @@ -9788,15 +9766,15 @@ a.effects.save(c, k ? d : e), c.show(), a.effects.createWrapper(c), - c.css("overflow", "hidden").css(c.from); + c.css("overflow", "hidden").css(c.from)); if (l == "content" || l == "both") - (h = h.concat(["marginTop", "marginBottom"]).concat(g)), + ((h = h.concat(["marginTop", "marginBottom"]).concat(g)), (i = i.concat(["marginLeft", "marginRight"])), (f = d.concat(h).concat(i)), - c.find("*[width]").each(function() { - (child = a(this)), k && a.effects.save(child, f); + c.find("*[width]").each(function () { + ((child = a(this)), k && a.effects.save(child, f)); var c = { height: child.height(), width: child.width() }; - (child.from = { + ((child.from = { height: c.height * q.from.y, width: c.width * q.from.x }), @@ -9835,26 +9813,26 @@ child.to, b.duration, b.options.easing, - function() { + function () { k && a.effects.restore(child, f); } - ); - }); + )); + })); c.animate(c.to, { queue: !1, duration: b.duration, easing: b.options.easing, - complete: function() { - c.to.opacity === 0 && c.css("opacity", c.from.opacity), + complete: function () { + (c.to.opacity === 0 && c.css("opacity", c.from.opacity), j == "hide" && c.hide(), a.effects.restore(c, k ? d : e), a.effects.removeWrapper(c), b.callback && b.callback.apply(this, arguments), - c.dequeue(); + c.dequeue()); } }); }); - }); + })); })(jQuery); /* * jQuery UI Effects Shake 1.8.17 @@ -9867,9 +9845,9 @@ * * Depends: * jquery.effects.core.js - */ (function(a, b) { - a.effects.shake = function(b) { - return this.queue(function() { + */ (function (a, b) { + a.effects.shake = function (b) { + return this.queue(function () { var c = a(this), d = ["position", "top", "bottom", "left", "right"], e = a.effects.setMode(c, b.options.mode || "effect"), @@ -9877,29 +9855,29 @@ g = b.options.distance || 20, h = b.options.times || 3, i = b.duration || b.options.duration || 140; - a.effects.save(c, d), c.show(), a.effects.createWrapper(c); + (a.effects.save(c, d), c.show(), a.effects.createWrapper(c)); var j = f == "up" || f == "down" ? "top" : "left", k = f == "up" || f == "left" ? "pos" : "neg", l = {}, m = {}, n = {}; - (l[j] = (k == "pos" ? "-=" : "+=") + g), + ((l[j] = (k == "pos" ? "-=" : "+=") + g), (m[j] = (k == "pos" ? "+=" : "-=") + g * 2), (n[j] = (k == "pos" ? "-=" : "+=") + g * 2), - c.animate(l, i, b.options.easing); + c.animate(l, i, b.options.easing)); for (var p = 1; p < h; p++) c.animate(m, i, b.options.easing).animate(n, i, b.options.easing); - c + (c .animate(m, i, b.options.easing) - .animate(l, i / 2, b.options.easing, function() { - a.effects.restore(c, d), + .animate(l, i / 2, b.options.easing, function () { + (a.effects.restore(c, d), a.effects.removeWrapper(c), - b.callback && b.callback.apply(this, arguments); + b.callback && b.callback.apply(this, arguments)); }), - c.queue("fx", function() { + c.queue("fx", function () { c.dequeue(); }), - c.dequeue(); + c.dequeue()); }); }; })(jQuery); @@ -9914,16 +9892,16 @@ * * Depends: * jquery.effects.core.js - */ (function(a, b) { - a.effects.slide = function(b) { - return this.queue(function() { + */ (function (a, b) { + a.effects.slide = function (b) { + return this.queue(function () { var c = a(this), d = ["position", "top", "bottom", "left", "right"], e = a.effects.setMode(c, b.options.mode || "show"), f = b.options.direction || "left"; - a.effects.save(c, d), + (a.effects.save(c, d), c.show(), - a.effects.createWrapper(c).css({ overflow: "hidden" }); + a.effects.createWrapper(c).css({ overflow: "hidden" })); var g = f == "up" || f == "down" ? "top" : "left", h = f == "up" || f == "left" ? "pos" : "neg", i = @@ -9933,21 +9911,21 @@ : c.outerWidth({ margin: !0 })); e == "show" && c.css(g, h == "pos" ? (isNaN(i) ? "-" + i : -i) : i); var j = {}; - (j[g] = + ((j[g] = (e == "show" ? (h == "pos" ? "+=" : "-=") : h == "pos" ? "-=" : "+=") + i), c.animate(j, { queue: !1, duration: b.duration, easing: b.options.easing, - complete: function() { - e == "hide" && c.hide(), + complete: function () { + (e == "hide" && c.hide(), a.effects.restore(c, d), a.effects.removeWrapper(c), b.callback && b.callback.apply(this, arguments), - c.dequeue(); + c.dequeue()); } - }); + })); }); }; })(jQuery); @@ -9962,9 +9940,9 @@ * * Depends: * jquery.effects.core.js - */ (function(a, b) { - a.effects.transfer = function(b) { - return this.queue(function() { + */ (function (a, b) { + a.effects.transfer = function (b) { + return this.queue(function () { var c = a(this), d = a(b.options.to), e = d.offset(), @@ -9985,10 +9963,10 @@ width: c.innerWidth(), position: "absolute" }) - .animate(f, b.duration, b.options.easing, function() { - h.remove(), + .animate(f, b.duration, b.options.easing, function () { + (h.remove(), b.callback && b.callback.apply(c[0], arguments), - c.dequeue(); + c.dequeue()); }); }); }; diff --git a/examples/js/password.js b/examples/js/password.js index a85a0c506..b1e35fc3c 100644 --- a/examples/js/password.js +++ b/examples/js/password.js @@ -1,15 +1,15 @@ -var doc = new jsPDF({ - // jsPDF supports encryption of PDF version 1.3. - // Version 1.3 just uses RC4 40-bit which is kown to be weak and is NOT state of the art. - // Keep in mind that it is just a minimal protection. - encryption: { - userPassword: "user", - ownerPassword: "owner", - userPermissions: ["print", "modify", "copy", "annot-forms"] - // try changing the user permissions granted - } -}); - -doc.setFontSize(40); -doc.text("Octonyan loves jsPDF", 35, 25); -doc.addImage("examples/images/Octonyan.jpg", "JPEG", 15, 40, 180, 180); +var doc = new jsPDF({ + // jsPDF supports encryption of PDF version 1.3. + // Version 1.3 just uses RC4 40-bit which is kown to be weak and is NOT state of the art. + // Keep in mind that it is just a minimal protection. + encryption: { + userPassword: "user", + ownerPassword: "owner", + userPermissions: ["print", "modify", "copy", "annot-forms"] + // try changing the user permissions granted + } +}); + +doc.setFontSize(40); +doc.text("Octonyan loves jsPDF", 35, 25); +doc.addImage("examples/images/Octonyan.jpg", "JPEG", 15, 40, 180, 180); diff --git a/examples/js/pdfobject.min.js b/examples/js/pdfobject.min.js index b5a639653..8849ca4fe 100644 --- a/examples/js/pdfobject.min.js +++ b/examples/js/pdfobject.min.js @@ -6,7 +6,7 @@ UMD module pattern from https://github.com/umdjs/umd/blob/master/templates/returnExports.js */ -(function(root, factory) { +(function (root, factory) { if (typeof define === "function" && define.amd) { define([], factory); } else if (typeof module === "object" && module.exports) { @@ -14,7 +14,7 @@ } else { root.PDFObject = factory(); } -})(this, function() { +})(this, function () { "use strict"; if (typeof window === "undefined" || typeof navigator === "undefined") { return false; @@ -25,19 +25,19 @@ supportsPdfMimeType = typeof navigator.mimeTypes["application/pdf"] !== "undefined", supportsPdfActiveX, - isModernBrowser = (function() { + isModernBrowser = (function () { return typeof window.Promise !== "undefined"; })(), - isFirefox = (function() { + isFirefox = (function () { return ua.indexOf("irefox") !== -1; })(), - isFirefoxWithPDFJS = (function() { + isFirefoxWithPDFJS = (function () { if (!isFirefox) { return false; } return parseInt(ua.split("rv:")[1].split(".")[0], 10) > 18; })(), - isIOS = (function() { + isIOS = (function () { return /iphone|ipad|ipod/i.test(ua.toLowerCase()); })(), createAXO, @@ -48,7 +48,7 @@ getTargetElement, generatePDFJSiframe, generateEmbedElement; - createAXO = function(type) { + createAXO = function (type) { var ax; try { ax = new ActiveXObject(type); @@ -58,7 +58,7 @@ return ax; }; supportsPDFs = !isIOS && (isFirefoxWithPDFJS || supportsPdfMimeType); - buildFragmentString = function(pdfParams) { + buildFragmentString = function (pdfParams) { var string = "", prop; if (pdfParams) { @@ -78,16 +78,16 @@ } return string; }; - log = function(msg) { + log = function (msg) { if (typeof console !== "undefined" && console.log) { console.log("[PDFObject] " + msg); } }; - embedError = function(msg) { + embedError = function (msg) { log(msg); return false; }; - getTargetElement = function(targetSelector) { + getTargetElement = function (targetSelector) { var targetNode = document.body; if (typeof targetSelector === "string") { targetNode = document.querySelector(targetSelector); @@ -105,7 +105,7 @@ } return targetNode; }; - generatePDFJSiframe = function( + generatePDFJSiframe = function ( targetNode, url, pdfOpenFragment, @@ -131,7 +131,7 @@ targetNode.innerHTML = iframe; return targetNode.getElementsByTagName("iframe")[0]; }; - generateEmbedElement = function( + generateEmbedElement = function ( targetNode, targetSelector, url, @@ -159,7 +159,7 @@ "'/>"; return targetNode.getElementsByTagName("embed")[0]; }; - embed = function(url, targetSelector, options) { + embed = function (url, targetSelector, options) { if (typeof url !== "string") { return embedError("URL is not valid"); } @@ -235,13 +235,13 @@ } }; return { - embed: function(a, b, c) { + embed: function (a, b, c) { return embed(a, b, c); }, - pdfobjectversion: (function() { + pdfobjectversion: (function () { return pdfobjectversion; })(), - supportsPDFs: (function() { + supportsPDFs: (function () { return supportsPDFs; })() }; diff --git a/examples/js/test_harness.js b/examples/js/test_harness.js index f30e9e33f..868b6700b 100644 --- a/examples/js/test_harness.js +++ b/examples/js/test_harness.js @@ -9,7 +9,7 @@ /** * An easy way to view PDF and PDF source code side by side. */ -var pdf_test_harness_init = function(pdf, message) { +var pdf_test_harness_init = function (pdf, message) { var harness = new pdf_test_harness(); var body = document.body; @@ -88,7 +88,7 @@ var pdf_test_harness_init = function(pdf, message) { ); popup.innerHTML = message; body.appendChild(popup); - popup.onclick = function() { + popup.onclick = function () { popup.parentNode.removeChild(popup); }; } @@ -97,20 +97,20 @@ var pdf_test_harness_init = function(pdf, message) { harness.pdf = pdf; harness.render("pdf"); - btn1.onclick = function() { + btn1.onclick = function () { harness.render("pdf"); }; - btn2.onclick = function() { + btn2.onclick = function () { harness.render("source"); }; - btn3.onclick = function() { + btn3.onclick = function () { harness.render("both"); }; return harness; }; -var pdf_test_harness = function(pdf) { +var pdf_test_harness = function (pdf) { this.pdf = pdf; this.onload = undefined; this.iframe = undefined; @@ -124,16 +124,16 @@ var pdf_test_harness = function(pdf) { "/": "/" }; - this.escapeHtml = function(string) { + this.escapeHtml = function (string) { return String(string).replace( /[&<>"'\/]/g, - function(s) { + function (s) { return this.entityMap[s]; }.bind(this) ); }; - this.getParameterByName = function(name) { + this.getParameterByName = function (name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), results = regex.exec(location.search); @@ -142,14 +142,14 @@ var pdf_test_harness = function(pdf) { : decodeURIComponent(results[1].replace(/\+/g, " ")); }; - this.setPdf = function(pdf) { + this.setPdf = function (pdf) { this.pdf = pdf; this.rendered = undefined; this.render(this.view); }; // generate the pdf, the source code, or both - this.render = function(view) { + this.render = function (view) { this.view = view; //Current code only lets us render one time. if (!this.rendered) { diff --git a/examples/js/theme-ambiance.js b/examples/js/theme-ambiance.js index fc6349c5f..d8ea96a3c 100644 --- a/examples/js/theme-ambiance.js +++ b/examples/js/theme-ambiance.js @@ -26,7 +26,7 @@ define("ace/theme/ambiance", [ "exports", "module", "ace/lib/dom" -], function(require, exports, module) { +], function (require, exports, module) { exports.isDark = true; exports.cssClass = "ace-ambiance"; exports.cssText = diff --git a/examples/jspdf.PLUGINTEMPLATE.js b/examples/jspdf.PLUGINTEMPLATE.js index 9c9f43406..16f694c38 100644 --- a/examples/jspdf.PLUGINTEMPLATE.js +++ b/examples/jspdf.PLUGINTEMPLATE.js @@ -7,12 +7,12 @@ * http://opensource.org/licenses/mit-license */ -(function(jsPDFAPI) { +(function (jsPDFAPI) { "use strict"; var namespace = ""; //fill here - var _initialize = function(instance) { + var _initialize = function (instance) { if (typeof instance === "undefined") { return false; } @@ -23,7 +23,7 @@ return true; }; - jsPDFAPI.myFunction = function() { + jsPDFAPI.myFunction = function () { "use strict"; _initialize(this); diff --git a/package-lock.json b/package-lock.json index 84994b12b..04a4c6582 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,23 +15,21 @@ }, "devDependencies": { "@babel/core": "^7.10.4", + "@babel/plugin-transform-modules-commonjs": "^7.29.7", "@babel/plugin-transform-runtime": "^7.14.5", "@babel/preset-env": "^7.10.4", "@babel/preset-typescript": "^7.27.1", + "@babel/register": "^7.29.7", "@rollup/plugin-babel": "^5.3.0", "@rollup/plugin-replace": "^2.3.3", "@rollup/plugin-terser": "^1.0.0", "@types/jasmine": "^3.5.11", "@types/node": "^20.16.5", - "@typescript-eslint/eslint-plugin": "^3.6.0", - "@typescript-eslint/parser": "^3.6.0", "chalk": "^4.1.0", "codeclimate-test-reporter": "^0.5.1", "core-js": "^3.33.0", "diff": "^4.0.2", "docdash": "^1.2.0", - "eslint": "^7.4.0", - "eslint-plugin-jasmine": "^4.1.1", "folder-delete": "^1.0.4", "inquirer": "^13.2.2", "jasmine": "3.5.0", @@ -52,8 +50,9 @@ "local-web-server": "^5.4.0", "log-utils": "^1.0.0", "markdown": "0.5.0", + "oxlint": "^1.74.0", "preprocess": "^3.2.0", - "prettier": "^1.19.1", + "prettier": "^3.9.5", "regenerator-runtime": "^0.13.5", "requirejs": "^2.3.6", "rollup": "^2.18.2", @@ -1449,6 +1448,26 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/register": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/register/-/register-7.29.7.tgz", + "integrity": "sha512-AMGJoWuES861riy6pcB0fphE1YXybtQnBYQMuIyPv6mKLiosfa79BKTnAOyx215c/3RJPJpdQwoHZ3earVH7AA==", + "dev": true, + "license": "MIT", + "dependencies": { + "clone-deep": "^4.0.1", + "find-cache-dir": "^2.0.0", + "make-dir": "^2.1.0", + "pirates": "^4.0.6", + "source-map-support": "^0.5.16" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/runtime": { "version": "7.28.6", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.6.tgz", @@ -1956,6 +1975,353 @@ "node": ">= 14.0.0" } }, + "node_modules/@oxlint/binding-android-arm-eabi": { + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-android-arm-eabi/-/binding-android-arm-eabi-1.74.0.tgz", + "integrity": "sha512-+gHd12muVI9ZLBaWLPkHt3Fj7jihFjgQ1MGtBaRL8vWrWrI0P7dLUty/cHrHS0oqPYIRgQUJsPu2CExQuMcwNw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-android-arm64": { + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-android-arm64/-/binding-android-arm64-1.74.0.tgz", + "integrity": "sha512-xjKdoMB+H+RCOByv/7l7nfIGW9mlOisqYdcyC75UqYuQecLpReAeEYUf2CNeDEI3KtmUgxpRw/+c63y4AeF/Bw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-darwin-arm64": { + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-darwin-arm64/-/binding-darwin-arm64-1.74.0.tgz", + "integrity": "sha512-iUK7wvc6sejMKsC+Pt67mntoF5weFcyEunhZfLJceU6gL419mexz5wBkSx/EnkFBExMLNtOi9fnDSc5xfK0IzQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-darwin-x64": { + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-darwin-x64/-/binding-darwin-x64-1.74.0.tgz", + "integrity": "sha512-ggKc/tn5SJ1u2yG2izC6VKODfYKV8MQ2AicJlNzOjuyrC29udvOef6/JzK2r32xqCnBDLFouR1VCkjzEI0/N9Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-freebsd-x64": { + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-freebsd-x64/-/binding-freebsd-x64-1.74.0.tgz", + "integrity": "sha512-u++dH/43jy9hTLbneaWlS0gla/Bp1JdwJ2zgevCl8nDFUh6qRCGMxcL0f0lb7By3A9p/LfFr+7cG4HU1hG856g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm-gnueabihf": { + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.74.0.tgz", + "integrity": "sha512-Sj1zmtFDVTPeIbIz4ZfcXAbFHqCmKCXdCUlAJzvTF7I20NTH1RDpoF2PhkqNODutJzVhJYmm3oz0GwgY+tvE2g==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm-musleabihf": { + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm-musleabihf/-/binding-linux-arm-musleabihf-1.74.0.tgz", + "integrity": "sha512-//PKyQb/tQXcHArx2f7z+oVI/eMS2Jpv+edNuAtOrgIhWdGcpHxogveAxzmF2rpH1AIHp4Hq04RF/rgJdiICnQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm64-gnu": { + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.74.0.tgz", + "integrity": "sha512-/k1Me+aX2tjuH10K62mLS0y8cLkJBHX6Ce0xPK+eWeel4bSdEGZ8dv4+hYMzg0GrSmjwy4yAYsDPeEeKBft/2w==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm64-musl": { + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.74.0.tgz", + "integrity": "sha512-3tFSjBxc5D8/zvjEuLvOqcA8ZXKD0+6NuaVO/edeamNc49MoAsbfaC9s1UiwODwgF6slGaF8yJA2TPkukd77tg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-ppc64-gnu": { + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.74.0.tgz", + "integrity": "sha512-9QggtPkSPXOCTu8Szis7auOK/sC7KdQaN+/TujP7YVVhzCAOhgdRfgv8uEz0r2tk5xdgus5rLYUrCDoZNtiRUw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-riscv64-gnu": { + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-1.74.0.tgz", + "integrity": "sha512-VM5VPUJ4DJIWiK+AZn8FScUqMr6OFrCAYybMYjEEi7W13ParI64MByiXTkKMqZpBmvQ9zxl9Ebq2VUOiZRJYUg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-riscv64-musl": { + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-1.74.0.tgz", + "integrity": "sha512-SaDY1gh9rOA592J54g+gu5hkOFFQBZsMmIYHs+NRHG+Uq0OxtuuCXMWQ3vu1830Eugv5uMXyjG+bv2Z9y4IXjw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-s390x-gnu": { + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.74.0.tgz", + "integrity": "sha512-ZATQeHZCyr6MbDveg0obD5sxLHFOghtOdC5jwVwYlvFWqtFOxctgFEG6Ef/64hYvZrWyhyCckB10AelqLopeDA==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-x64-gnu": { + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.74.0.tgz", + "integrity": "sha512-+aIvJyrdeD7LwCQ2WYLMUWNmnbeDRSPb40aBYtPjD9+PTqUwgJnk+HK5yLfSMeqXrMrDhE9uTmtt2y50tvjhHw==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-x64-musl": { + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-x64-musl/-/binding-linux-x64-musl-1.74.0.tgz", + "integrity": "sha512-XyktaR8lhK2qWiCK0Tk8oYD+/cgn+oHA6ddRnxSSXUKkkojkV78CmShZUxQF+yrBFs0SuW+JBOPG6hecyc/iZg==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-openharmony-arm64": { + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-openharmony-arm64/-/binding-openharmony-arm64-1.74.0.tgz", + "integrity": "sha512-mzbjrPl4neaVUiJ1fUiEUxTGaSZBoiKtaoB6jmIpz9S+VOA2vDYmJpihQ82w6178V5jxziclTg8Cgj5yF6tTDg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-win32-arm64-msvc": { + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.74.0.tgz", + "integrity": "sha512-vUAe9okpS2Oa5+lX67lqHMuNUvfkleRKwrUDJ/WJBsgmddvZ1mrsh2HVmuFDRzqFELhaJhFaCNOuR6a7L3rtIA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-win32-ia32-msvc": { + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-1.74.0.tgz", + "integrity": "sha512-yyXXJyYYSXL4I8K8jAWjJs+J3fa9gH2JmEbo4f5adm+1tNC9itseicBNuwK7BDHvqQ5J534s+yDULu89vYL2ZQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-win32-x64-msvc": { + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.74.0.tgz", + "integrity": "sha512-VTC9IYTIMrVUk/i6Ms1ohzzDKZFkWn0KU2OBbPBzgmVZ2V30165T/zK4LztTr0Xgp9fZ1qQZ1rsZAu/rEmySlA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, "node_modules/@rollup/plugin-babel": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.3.0.tgz", @@ -2104,12 +2470,6 @@ "@types/node": "*" } }, - "node_modules/@types/eslint-visitor-keys": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", - "integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==", - "dev": true - }, "node_modules/@types/estree": { "version": "0.0.39", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", @@ -2122,12 +2482,6 @@ "integrity": "sha512-fg1rOd/DehQTIJTifGqGVY6q92lDgnLfs7C6t1ccSwQrMyoTGSoH6wWzhJDZb6ezhsdwAX4EIBLe8w5fXWmEng==", "dev": true }, - "node_modules/@types/json-schema": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.5.tgz", - "integrity": "sha512-7+2BITlgjgDhH0vvwZU/HZJVyk+2XUlvxXe8dFMedNX/aMkaOq++rMAFXc0tM7ij15QaWlbdQASBR9dihi+bDQ==", - "dev": true - }, "node_modules/@types/linkify-it": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-5.0.0.tgz", @@ -2191,170 +2545,6 @@ "license": "MIT", "optional": true }, - "node_modules/@typescript-eslint/eslint-plugin": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.6.0.tgz", - "integrity": "sha512-ubHlHVt1lsPQB/CZdEov9XuOFhNG9YRC//kuiS1cMQI6Bs1SsqKrEmZnpgRwthGR09/kEDtr9MywlqXyyYd8GA==", - "dev": true, - "dependencies": { - "@typescript-eslint/experimental-utils": "3.6.0", - "debug": "^4.1.1", - "functional-red-black-tree": "^1.0.1", - "regexpp": "^3.0.0", - "semver": "^7.3.2", - "tsutils": "^3.17.1" - }, - "engines": { - "node": "^10.12.0 || >=12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "@typescript-eslint/parser": "^3.0.0", - "eslint": "^5.0.0 || ^6.0.0 || ^7.0.0" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/eslint-plugin/node_modules/semver": { - "version": "7.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", - "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@typescript-eslint/experimental-utils": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.6.0.tgz", - "integrity": "sha512-4Vdf2hvYMUnTdkCNZu+yYlFtL2v+N2R7JOynIOkFbPjf9o9wQvRwRkzUdWlFd2YiiUwJLbuuLnl5civNg5ykOQ==", - "dev": true, - "dependencies": { - "@types/json-schema": "^7.0.3", - "@typescript-eslint/types": "3.6.0", - "@typescript-eslint/typescript-estree": "3.6.0", - "eslint-scope": "^5.0.0", - "eslint-utils": "^2.0.0" - }, - "engines": { - "node": "^10.12.0 || >=12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "*" - } - }, - "node_modules/@typescript-eslint/parser": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.6.0.tgz", - "integrity": "sha512-taghDxuLhbDAD1U5Fk8vF+MnR0yiFE9Z3v2/bYScFb0N1I9SK8eKHkdJl1DAD48OGFDMFTeOTX0z7g0W6SYUXw==", - "dev": true, - "dependencies": { - "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "3.6.0", - "@typescript-eslint/types": "3.6.0", - "@typescript-eslint/typescript-estree": "3.6.0", - "eslint-visitor-keys": "^1.1.0" - }, - "engines": { - "node": "^10.12.0 || >=12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^5.0.0 || ^6.0.0 || ^7.0.0" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/types": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.6.0.tgz", - "integrity": "sha512-JwVj74ohUSt0ZPG+LZ7hb95fW8DFOqBuR6gE7qzq55KDI3BepqsCtHfBIoa0+Xi1AI7fq5nCu2VQL8z4eYftqg==", - "dev": true, - "engines": { - "node": "^8.10.0 || ^10.13.0 || >=11.10.1" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/typescript-estree": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.6.0.tgz", - "integrity": "sha512-G57NDSABHjvob7zVV09ehWyD1K6/YUKjz5+AufObFyjNO4DVmKejj47MHjVHHlZZKgmpJD2yyH9lfCXHrPITFg==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "3.6.0", - "@typescript-eslint/visitor-keys": "3.6.0", - "debug": "^4.1.1", - "glob": "^7.1.6", - "is-glob": "^4.0.1", - "lodash": "^4.17.15", - "semver": "^7.3.2", - "tsutils": "^3.17.1" - }, - "engines": { - "node": "^10.12.0 || >=12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { - "version": "7.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", - "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@typescript-eslint/visitor-keys": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.6.0.tgz", - "integrity": "sha512-p1izllL2Ubwunite0ITjubuMQRBGgjdVYwyG7lXPX8GbrA6qF0uwSRz9MnXZaHMxID4948gX0Ez8v9tUDi/KfQ==", - "dev": true, - "dependencies": { - "eslint-visitor-keys": "^1.1.0" - }, - "engines": { - "node": "^8.10.0 || ^10.13.0 || >=11.10.1" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, "node_modules/@typescript/typescript-aix-ppc64": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/@typescript/typescript-aix-ppc64/-/typescript-aix-ppc64-7.0.2.tgz", @@ -2709,30 +2899,9 @@ "dependencies": { "mime-types": "~2.1.24", "negotiator": "0.6.2" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/acorn": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.3.1.tgz", - "integrity": "sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA==", - "dev": true, - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/acorn-jsx": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.2.0.tgz", - "integrity": "sha512-HiUX/+K2YpkpJ+SzBffkM/AQ2YE03S0U1kjTLVpoJdhZMOWy8qvXVN9JdLqv2QsaQ6MPYQIuNmwD8zOiYUofLQ==", - "dev": true, - "peerDependencies": { - "acorn": "^6.0.0 || ^7.0.0" + }, + "engines": { + "node": ">= 0.6" } }, "node_modules/add-matchers": { @@ -2770,15 +2939,6 @@ "url": "https://github.com/sponsors/epoberezkin" } }, - "node_modules/ansi-colors": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", - "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/ansi-escape-sequences": { "version": "6.2.4", "resolved": "https://registry.npmjs.org/ansi-escape-sequences/-/ansi-escape-sequences-6.2.4.tgz", @@ -2846,15 +3006,6 @@ "node": ">= 8" } }, - "node_modules/argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, - "dependencies": { - "sprintf-js": "~1.0.2" - } - }, "node_modules/array-back": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/array-back/-/array-back-4.0.1.tgz", @@ -2892,15 +3043,6 @@ "node": ">=0.8" } }, - "node_modules/astral-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", - "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/async": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", @@ -3295,15 +3437,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/callsites": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", - "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/caniuse-lite": { "version": "1.0.30001736", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001736.tgz", @@ -3591,6 +3724,21 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, + "node_modules/clone-deep": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-4.0.1.tgz", + "integrity": "sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-plain-object": "^2.0.4", + "kind-of": "^6.0.2", + "shallow-clone": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -3771,6 +3919,13 @@ "node": ">=8" } }, + "node_modules/commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", + "dev": true, + "license": "MIT" + }, "node_modules/compressible": { "version": "2.0.18", "resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.18.tgz", @@ -3958,21 +4113,6 @@ "node": ">=10" } }, - "node_modules/cross-spawn": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", - "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", - "dev": true, - "license": "MIT", - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/css-line-break": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/css-line-break/-/css-line-break-1.1.1.tgz", @@ -4061,12 +4201,6 @@ "node": ">=4.0.0" } }, - "node_modules/deep-is": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", - "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", - "dev": true - }, "node_modules/define-lazy-prop": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz", @@ -4147,18 +4281,6 @@ "integrity": "sha512-IYZbgYthPTspgqYeciRJNPhSwL51yer7HAwDXhF5p+H7mTDbPvY3PCk/QDjNxdPCpWkaJVFC4t7iCNB/t9E5Kw==", "dev": true }, - "node_modules/doctrine": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", - "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", - "dev": true, - "dependencies": { - "esutils": "^2.0.2" - }, - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/dom-serialize": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/dom-serialize/-/dom-serialize-2.2.1.tgz", @@ -4219,12 +4341,6 @@ "dev": true, "license": "ISC" }, - "node_modules/emoji-regex": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", - "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", - "dev": true - }, "node_modules/encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", @@ -4265,18 +4381,6 @@ "node": ">=10.0.0" } }, - "node_modules/enquirer": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", - "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==", - "dev": true, - "dependencies": { - "ansi-colors": "^4.1.1" - }, - "engines": { - "node": ">=8.6" - } - }, "node_modules/ent": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/ent/-/ent-2.2.0.tgz", @@ -4351,216 +4455,6 @@ "node": ">=0.8.0" } }, - "node_modules/eslint": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.4.0.tgz", - "integrity": "sha512-gU+lxhlPHu45H3JkEGgYhWhkR9wLHHEXC9FbWFnTlEkbKyZKWgWRLgf61E8zWmBuI6g5xKBph9ltg3NtZMVF8g==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.0.0", - "ajv": "^6.10.0", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", - "debug": "^4.0.1", - "doctrine": "^3.0.0", - "enquirer": "^2.3.5", - "eslint-scope": "^5.1.0", - "eslint-utils": "^2.0.0", - "eslint-visitor-keys": "^1.2.0", - "espree": "^7.1.0", - "esquery": "^1.2.0", - "esutils": "^2.0.2", - "file-entry-cache": "^5.0.1", - "functional-red-black-tree": "^1.0.1", - "glob-parent": "^5.0.0", - "globals": "^12.1.0", - "ignore": "^4.0.6", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "is-glob": "^4.0.0", - "js-yaml": "^3.13.1", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", - "lodash": "^4.17.14", - "minimatch": "^3.0.4", - "natural-compare": "^1.4.0", - "optionator": "^0.9.1", - "progress": "^2.0.0", - "regexpp": "^3.1.0", - "semver": "^7.2.1", - "strip-ansi": "^6.0.0", - "strip-json-comments": "^3.1.0", - "table": "^5.2.3", - "text-table": "^0.2.0", - "v8-compile-cache": "^2.0.3" - }, - "bin": { - "eslint": "bin/eslint.js" - }, - "engines": { - "node": "^10.12.0 || >=12.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/eslint-plugin-jasmine": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-jasmine/-/eslint-plugin-jasmine-4.1.1.tgz", - "integrity": "sha512-uS7kvt7RPUB/gLDwhJ/Ax0APrmkj7In8VJWkiZLYHafz2Ix74mMRJx82YZZ3zHRa/YOuTL+ig6dW/aKwdNzUuw==", - "dev": true, - "engines": { - "node": ">=8", - "npm": ">=6" - } - }, - "node_modules/eslint-scope": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.0.tgz", - "integrity": "sha512-iiGRvtxWqgtx5m8EyQUJihBloE4EnYeGE/bz1wSPwJE6tZuJUtHlhqDM4Xj2ukE8Dyy1+HCZ4hE0fzIVMzb58w==", - "dev": true, - "dependencies": { - "esrecurse": "^4.1.0", - "estraverse": "^4.1.1" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/eslint-utils": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", - "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", - "dev": true, - "dependencies": { - "eslint-visitor-keys": "^1.1.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - } - }, - "node_modules/eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/eslint/node_modules/globals": { - "version": "12.4.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", - "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", - "dev": true, - "dependencies": { - "type-fest": "^0.8.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/eslint/node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "dev": true, - "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/eslint/node_modules/semver": { - "version": "7.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", - "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/espree": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-7.1.0.tgz", - "integrity": "sha512-dcorZSyfmm4WTuTnE5Y7MEN1DyoPYy1ZR783QW1FJoenn7RailyWFsq/UL6ZAAA7uXurN9FIpYyUs3OfiIW+Qw==", - "dev": true, - "dependencies": { - "acorn": "^7.2.0", - "acorn-jsx": "^5.2.0", - "eslint-visitor-keys": "^1.2.0" - }, - "engines": { - "node": "^10.12.0 || >=12.0.0" - } - }, - "node_modules/esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true, - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/esquery": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.3.1.tgz", - "integrity": "sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ==", - "dev": true, - "dependencies": { - "estraverse": "^5.1.0" - }, - "engines": { - "node": ">=0.10" - } - }, - "node_modules/esquery/node_modules/estraverse": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.1.0.tgz", - "integrity": "sha512-FyohXK+R0vE+y1nHLoBM7ZTyqRpqAlhdZHCWIWEviFLiGB8b04H6bQs8G+XTthacvT8VuwvteiP7RJSxMs8UEw==", - "dev": true, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/esrecurse": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", - "dev": true, - "dependencies": { - "estraverse": "^4.1.0" - }, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true, - "engines": { - "node": ">=4.0" - } - }, "node_modules/estree-walker": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", @@ -4625,12 +4519,6 @@ "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", "dev": true }, - "node_modules/fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", - "dev": true - }, "node_modules/fast-png": { "version": "6.4.0", "resolved": "https://registry.npmjs.org/fast-png/-/fast-png-6.4.0.tgz", @@ -4647,18 +4535,6 @@ "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.1.tgz", "integrity": "sha512-/exOvEuc+/iaUm105QIiOt4LpBdMTWsXxqR0HDF35vx3fmaKzw7354gTilCh5rkzEt8WYyG//ku3h3nRmd7CHQ==" }, - "node_modules/file-entry-cache": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", - "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", - "dev": true, - "dependencies": { - "flat-cache": "^2.0.1" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/fill-range": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", @@ -4705,6 +4581,21 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, + "node_modules/find-cache-dir": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.1.0.tgz", + "integrity": "sha512-Tq6PixE0w/VMFfCgbONnkiQIVol/JJL7nRMi20fqzA4NRs9AfeqMGeRdPi3wIhYkxjeBaWh2rxwapn5Tu3IqOQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "commondir": "^1.0.1", + "make-dir": "^2.0.0", + "pkg-dir": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/find-replace": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/find-replace/-/find-replace-5.0.2.tgz", @@ -4723,26 +4614,19 @@ } } }, - "node_modules/flat-cache": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", - "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", + "node_modules/find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", "dev": true, + "license": "MIT", "dependencies": { - "flatted": "^2.0.0", - "rimraf": "2.6.3", - "write": "1.0.3" + "locate-path": "^3.0.0" }, "engines": { - "node": ">=4" + "node": ">=6" } }, - "node_modules/flatted": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz", - "integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==", - "dev": true - }, "node_modules/folder-delete": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/folder-delete/-/folder-delete-1.0.4.tgz", @@ -4855,12 +4739,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/functional-red-black-tree": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", - "dev": true - }, "node_modules/gensync": { "version": "1.0.0-beta.1", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.1.tgz", @@ -5198,37 +5076,6 @@ "node": ">=0.10.0" } }, - "node_modules/ignore": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", - "dev": true, - "engines": { - "node": ">= 4" - } - }, - "node_modules/import-fresh": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz", - "integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==", - "dev": true, - "dependencies": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/imurmurhash": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", - "dev": true, - "engines": { - "node": ">=0.8.19" - } - }, "node_modules/inflation": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/inflation/-/inflation-2.1.0.tgz", @@ -5335,15 +5182,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/is-generator-function": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.7.tgz", @@ -5381,6 +5219,19 @@ "node": ">=0.12.0" } }, + "node_modules/is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", + "dev": true, + "license": "MIT", + "dependencies": { + "isobject": "^3.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-reference": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", @@ -5427,6 +5278,16 @@ "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, + "node_modules/isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", @@ -5690,12 +5551,6 @@ "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, - "node_modules/json-stable-stringify-without-jsonify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", - "dev": true - }, "node_modules/json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", @@ -6037,7 +5892,17 @@ "tsscmp": "1.0.6" }, "engines": { - "node": ">= 0.6" + "node": ">= 0.6" + } + }, + "node_modules/kind-of": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" } }, "node_modules/klaw": { @@ -6270,19 +6135,6 @@ "node": ">= 6" } }, - "node_modules/levn": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", - "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", - "dev": true, - "dependencies": { - "prelude-ls": "^1.2.1", - "type-check": "~0.4.0" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/linkify-it": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-3.0.3.tgz", @@ -6348,6 +6200,20 @@ "node": ">=12.20" } }, + "node_modules/locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/lodash": { "version": "4.17.23", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz", @@ -6742,6 +6608,20 @@ "sourcemap-codec": "^1.4.4" } }, + "node_modules/make-dir": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", + "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "pify": "^4.0.1", + "semver": "^5.6.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/markdown": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/markdown/-/markdown-0.5.0.tgz", @@ -6971,12 +6851,6 @@ "node": "^20.17.0 || >=22.9.0" } }, - "node_modules/natural-compare": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", - "dev": true - }, "node_modules/negotiator": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", @@ -7125,21 +6999,92 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/optionator": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", - "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "node_modules/oxlint": { + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/oxlint/-/oxlint-1.74.0.tgz", + "integrity": "sha512-odGl2s2x5IOJoj3A0v1k0PGBXVFBZeZ2+AK/+K2MJur7Ghi3bkyX5NuLUWHKqa4js1wjep3hJeuTQJOlr+4+dA==", + "dev": true, + "license": "MIT", + "bin": { + "oxlint": "bin/oxlint" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/sponsors/Boshen" + }, + "optionalDependencies": { + "@oxlint/binding-android-arm-eabi": "1.74.0", + "@oxlint/binding-android-arm64": "1.74.0", + "@oxlint/binding-darwin-arm64": "1.74.0", + "@oxlint/binding-darwin-x64": "1.74.0", + "@oxlint/binding-freebsd-x64": "1.74.0", + "@oxlint/binding-linux-arm-gnueabihf": "1.74.0", + "@oxlint/binding-linux-arm-musleabihf": "1.74.0", + "@oxlint/binding-linux-arm64-gnu": "1.74.0", + "@oxlint/binding-linux-arm64-musl": "1.74.0", + "@oxlint/binding-linux-ppc64-gnu": "1.74.0", + "@oxlint/binding-linux-riscv64-gnu": "1.74.0", + "@oxlint/binding-linux-riscv64-musl": "1.74.0", + "@oxlint/binding-linux-s390x-gnu": "1.74.0", + "@oxlint/binding-linux-x64-gnu": "1.74.0", + "@oxlint/binding-linux-x64-musl": "1.74.0", + "@oxlint/binding-openharmony-arm64": "1.74.0", + "@oxlint/binding-win32-arm64-msvc": "1.74.0", + "@oxlint/binding-win32-ia32-msvc": "1.74.0", + "@oxlint/binding-win32-x64-msvc": "1.74.0" + }, + "peerDependencies": { + "oxlint-tsgolint": ">=0.24.0", + "vite-plus": "*" + }, + "peerDependenciesMeta": { + "oxlint-tsgolint": { + "optional": true + }, + "vite-plus": { + "optional": true + } + } + }, + "node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", "dev": true, + "license": "MIT", "dependencies": { - "deep-is": "^0.1.3", - "fast-levenshtein": "^2.0.6", - "levn": "^0.4.1", - "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.3" + "p-try": "^2.0.0" }, "engines": { - "node": ">= 0.8.0" + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^2.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" } }, "node_modules/package-name-regex": { @@ -7161,18 +7106,6 @@ "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==", "license": "(MIT AND Zlib)" }, - "node_modules/parent-module": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", - "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", - "dev": true, - "dependencies": { - "callsites": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -7182,6 +7115,16 @@ "node": ">= 0.8" } }, + "node_modules/path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -7191,15 +7134,6 @@ "node": ">=0.10.0" } }, - "node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/path-parse": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", @@ -7239,13 +7173,37 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/prelude-ls": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", - "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "node_modules/pify": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", + "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", "dev": true, + "license": "MIT", "engines": { - "node": ">= 0.8.0" + "node": ">=6" + } + }, + "node_modules/pirates": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.7.tgz", + "integrity": "sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/pkg-dir": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", + "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", + "dev": true, + "license": "MIT", + "dependencies": { + "find-up": "^3.0.0" + }, + "engines": { + "node": ">=6" } }, "node_modules/preprocess": { @@ -7267,15 +7225,19 @@ "dev": true }, "node_modules/prettier": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", - "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "version": "3.9.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.5.tgz", + "integrity": "sha512-/FVl766LpUfB5vXgCYOYa0MeV/441Ia99AeICQIQFTY/Nw0roZwULcXpku5i1/m5kt/baz+s4Zogspd839HSMg==", "dev": true, + "license": "MIT", "bin": { - "prettier": "bin-prettier.js" + "prettier": "bin/prettier.cjs" }, "engines": { - "node": ">=4" + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" } }, "node_modules/process-nextick-args": { @@ -7284,15 +7246,6 @@ "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", "dev": true }, - "node_modules/progress": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", - "dev": true, - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/pseudomap": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", @@ -7481,18 +7434,6 @@ "@babel/runtime": "^7.8.4" } }, - "node_modules/regexpp": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz", - "integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - } - }, "node_modules/regexpu-core": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.7.0.tgz", @@ -7620,15 +7561,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/resolve-from": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/resolve-path": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/resolve-path/-/resolve-path-1.4.0.tgz", @@ -7699,19 +7631,6 @@ "node": ">= 0.8.15" } }, - "node_modules/rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", - "deprecated": "Rimraf versions prior to v4 are no longer supported", - "dev": true, - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - } - }, "node_modules/rollup": { "version": "2.80.0", "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.80.0.tgz", @@ -7988,27 +7907,19 @@ "dev": true, "license": "ISC" }, - "node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "node_modules/shallow-clone": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz", + "integrity": "sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==", "dev": true, + "license": "MIT", "dependencies": { - "shebang-regex": "^3.0.0" + "kind-of": "^6.0.2" }, "engines": { "node": ">=8" } }, - "node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/side-channel": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", @@ -8098,20 +8009,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/slice-ansi": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", - "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", - "dev": true, - "dependencies": { - "ansi-styles": "^3.2.0", - "astral-regex": "^1.0.0", - "is-fullwidth-code-point": "^2.0.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/smob": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/smob/-/smob-1.5.0.tgz", @@ -8261,12 +8158,6 @@ "spdx-ranges": "^2.0.0" } }, - "node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true - }, "node_modules/sshpk": { "version": "1.16.1", "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", @@ -8436,42 +8327,6 @@ "safe-buffer": "~5.1.0" } }, - "node_modules/string-width": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", - "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", - "dev": true, - "dependencies": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/string-width/node_modules/ansi-regex": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", - "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/string-width/node_modules/strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "dev": true, - "dependencies": { - "ansi-regex": "^4.1.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -8515,21 +8370,6 @@ "node": ">=12.0.0" } }, - "node_modules/table": { - "version": "5.4.6", - "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", - "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", - "dev": true, - "dependencies": { - "ajv": "^6.10.2", - "lodash": "^4.17.14", - "slice-ansi": "^2.1.0", - "string-width": "^3.0.0" - }, - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/table-layout": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/table-layout/-/table-layout-4.1.1.tgz", @@ -8560,12 +8400,6 @@ "integrity": "sha512-y3JaeRSplks6NYQuCOj3ZFMO3j60rTwbuKCvZxsAraGYH2epusatvZ0baZYA01WsGqJBq/Dl6vOrMUJqyMj8kA==", "dev": true }, - "node_modules/text-table": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", - "dev": true - }, "node_modules/through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", @@ -8618,12 +8452,6 @@ "node": ">=0.8" } }, - "node_modules/tslib": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz", - "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==", - "dev": true - }, "node_modules/tsscmp": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/tsscmp/-/tsscmp-1.0.6.tgz", @@ -8634,21 +8462,6 @@ "node": ">=0.6.x" } }, - "node_modules/tsutils": { - "version": "3.17.1", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz", - "integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==", - "dev": true, - "dependencies": { - "tslib": "^1.8.1" - }, - "engines": { - "node": ">= 6" - }, - "peerDependencies": { - "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" - } - }, "node_modules/tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -8667,27 +8480,6 @@ "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", "dev": true }, - "node_modules/type-check": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", - "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", - "dev": true, - "dependencies": { - "prelude-ls": "^1.2.1" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/type-fest": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", - "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/type-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", @@ -8918,12 +8710,6 @@ "uuid": "bin/uuid" } }, - "node_modules/v8-compile-cache": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz", - "integrity": "sha512-8OQ9CL+VWyt3JStj7HX7/ciTL2V3Rl1Wf5OL+SNTm0yK1KvtReVulksyeRnCANHHuUxHlQig+JJDlUhBt1NQDQ==", - "dev": true - }, "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -8966,31 +8752,6 @@ "node": ">=12.17" } }, - "node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/word-wrap": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", - "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/wordwrapjs": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/wordwrapjs/-/wordwrapjs-5.1.1.tgz", @@ -9092,18 +8853,6 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, - "node_modules/write": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", - "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", - "dev": true, - "dependencies": { - "mkdirp": "^0.5.1" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/ws": { "version": "8.18.3", "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz", diff --git a/package.json b/package.json index b2341b5c9..861db9f0d 100644 --- a/package.json +++ b/package.json @@ -34,8 +34,8 @@ }, "dependencies": { "@babel/runtime": "^7.28.6", - "fflate": "^0.8.1", - "fast-png": "^6.2.0" + "fast-png": "^6.2.0", + "fflate": "^0.8.1" }, "optionalDependencies": { "canvg": "^3.0.11", @@ -45,23 +45,21 @@ }, "devDependencies": { "@babel/core": "^7.10.4", + "@babel/plugin-transform-modules-commonjs": "^7.29.7", "@babel/plugin-transform-runtime": "^7.14.5", "@babel/preset-env": "^7.10.4", "@babel/preset-typescript": "^7.27.1", + "@babel/register": "^7.29.7", "@rollup/plugin-babel": "^5.3.0", "@rollup/plugin-replace": "^2.3.3", "@rollup/plugin-terser": "^1.0.0", "@types/jasmine": "^3.5.11", "@types/node": "^20.16.5", - "@typescript-eslint/eslint-plugin": "^3.6.0", - "@typescript-eslint/parser": "^3.6.0", "chalk": "^4.1.0", "codeclimate-test-reporter": "^0.5.1", "core-js": "^3.33.0", "diff": "^4.0.2", "docdash": "^1.2.0", - "eslint": "^7.4.0", - "eslint-plugin-jasmine": "^4.1.1", "folder-delete": "^1.0.4", "inquirer": "^13.2.2", "jasmine": "3.5.0", @@ -82,8 +80,9 @@ "local-web-server": "^5.4.0", "log-utils": "^1.0.0", "markdown": "0.5.0", + "oxlint": "^1.74.0", "preprocess": "^3.2.0", - "prettier": "^1.19.1", + "prettier": "^3.9.5", "regenerator-runtime": "^0.13.5", "requirejs": "^2.3.6", "rollup": "^2.18.2", @@ -111,9 +110,10 @@ "test-node": "jasmine --config=test/deployment/node/jasmine.json", "test-training": "node test/utils/reference-server.js", "test-typings": "tsc -p types/tsconfig.json && tsc -p types/tsconfig-node.json", - "typecheck": "tsc --noEmit -p tsconfig.json", + "typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p test/tsconfig.json", "prettier": "prettier --write \"*.{js,ts,md,css,json}\" \"{spec,examples,src,types}/**/*.{js,ts,md,css,json}\"", - "lint": "prettier --check \"*.{js,ts,md,css,json}\" \"{spec,examples,src,types}/**/*.{js,ts,md,css,json}\"", + "lint": "prettier --check \"*.{js,ts,md,css,json}\" \"{spec,examples,src,types}/**/*.{js,ts,md,css,json}\" && yarpm run lint-no-any", + "lint-no-any": "oxlint -A all -D no-explicit-any -D no-ts-ignore src test/specs test/utils", "pregenerate-docs": "node deletedocs.js", "generate-docs": "jsdoc -c jsdoc.json --readme README.md" }, diff --git a/rollup.config.js b/rollup.config.js index 23782ac09..ace3de002 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -62,9 +62,7 @@ function replaceVersion() { function licenseBanner() { let commit = "00000000"; try { - commit = execSync("git rev-parse --short=10 HEAD") - .toString() - .trim(); + commit = execSync("git rev-parse --short=10 HEAD").toString().trim(); } catch (e) {} return license({ banner: { @@ -200,7 +198,7 @@ const node = { }; const umdPolyfills = { - input: "src/polyfills.js", + input: "src/polyfills.ts", output: [ { file: "dist/polyfills.umd.js", @@ -225,7 +223,7 @@ const umdPolyfills = { }; const esPolyfills = { - input: "src/polyfills.js", + input: "src/polyfills.ts", output: [ { file: "dist/polyfills.es.js", diff --git a/src/jspdf.ts b/src/jspdf.ts index 1b53c70b9..f3cda4d8b 100644 --- a/src/jspdf.ts +++ b/src/jspdf.ts @@ -7,13 +7,56 @@ import { globalObject } from "./libs/globalObject.js"; // Ambient declarations for the cjs-only branch kept inside the // "@if MODULE_FORMAT='cjs'" preprocess directive block in API.save below. -declare const require: any; -declare const Buffer: any; +interface NodeFSLike { + writeFileSync(path: string, data: unknown): void; + writeFile( + path: string, + data: unknown, + callback: (err: Error | null) => void + ): void; +} +declare const require: (id: string) => NodeFSLike; +declare const Buffer: { from(data: ArrayBuffer): unknown }; import { RGBColor } from "./libs/rgbcolor.js"; import { btoa } from "./libs/AtobBtoa.js"; import { console } from "./libs/console.js"; import { PDFSecurity } from "./libs/pdfsecurity.js"; import { toPDFName } from "./libs/pdfname.js"; +import type { + jsPDFOptions, + jsPDFDocument, + jsPDFInternal, + jsPDFPrivate, + jsPDFAPI, + PubSubInterface, + PubSubCallback, + PubSubTopics, + GStateOptions, + ShadingPatternType, + ShadingPatternStop, + Matrix as MatrixType, + PointType, + RectangleType, + PatternData, + PageFormat, + PageFormats, + PageContext, + PageInfo, + PageBox, + AdditionalObject, + Font, + FontMap, + FontDictionary, + EncryptionOptions, + PDFSecurityInterface, + Encryptor, + PutStreamOptions, + OutputType, + OutputOptions, + TextOptionsLight, + Unit, + ProcessedData +} from "./types.js"; /** * jsPDF's Internal PubSub Implementation. * Backward compatible rewritten on 2014 by @@ -23,163 +66,215 @@ import { toPDFName } from "./libs/pdfname.js"; * @name PubSub * @ignore */ -function PubSub(context) { - if (typeof context !== "object") { - throw new Error( - "Invalid Context passed to initialize PubSub (jsPDF-module)" - ); - } - var topics = {}; - - this.subscribe = function(topic, callback, once) { - once = once || false; - if ( - typeof topic !== "string" || - typeof callback !== "function" || - typeof once !== "boolean" - ) { +class PubSub implements PubSubInterface { + // The methods are assigned in the constructor (as closures over the + // private `topics` map) to keep them own, enumerable instance properties + // exactly like the previous function-constructor implementation. + declare subscribe: ( + topic: string, + callback: PubSubCallback, + once?: boolean + ) => string; + declare unsubscribe: (token: string) => boolean; + declare publish: (topic: string, ...args: unknown[]) => void; + declare getTopics: () => PubSubTopics; + + constructor(context: unknown) { + if (typeof context !== "object") { throw new Error( - "Invalid arguments passed to PubSub.subscribe (jsPDF-module)" + "Invalid Context passed to initialize PubSub (jsPDF-module)" ); } + var topics: PubSubTopics = {}; - if (!topics.hasOwnProperty(topic)) { - topics[topic] = {}; - } + this.subscribe = function (topic, callback, once) { + once = once || false; + if ( + typeof topic !== "string" || + typeof callback !== "function" || + typeof once !== "boolean" + ) { + throw new Error( + "Invalid arguments passed to PubSub.subscribe (jsPDF-module)" + ); + } - var token = Math.random().toString(35); - topics[topic][token] = [callback, !!once]; + if (!topics.hasOwnProperty(topic)) { + topics[topic] = {}; + } - return token; - }; + var token = Math.random().toString(35); + topics[topic][token] = [callback, !!once]; + + return token; + }; - this.unsubscribe = function(token) { - for (var topic in topics) { - if (topics[topic][token]) { - delete topics[topic][token]; - if (Object.keys(topics[topic]).length === 0) { - delete topics[topic]; + this.unsubscribe = function (token) { + for (var topic in topics) { + if (topics[topic][token]) { + delete topics[topic][token]; + if (Object.keys(topics[topic]).length === 0) { + delete topics[topic]; + } + return true; } - return true; } - } - return false; - }; - - this.publish = function(topic) { - if (topics.hasOwnProperty(topic)) { - var args = Array.prototype.slice.call(arguments, 1), - tokens = []; + return false; + }; - for (var token in topics[topic]) { - var sub = topics[topic][token]; - try { - sub[0].apply(context, args); - } catch (ex) { - if (globalObject.console) { - console.error("jsPDF PubSub Error", (ex as any).message, ex); + this.publish = (topic, ...args) => { + if (topics.hasOwnProperty(topic)) { + var tokens: string[] = []; + + for (var token in topics[topic]) { + var sub = topics[topic][token]; + try { + // The payload of each topic is dynamic and owned by the + // publisher, so the callback is invoked untyped. + (sub[0] as (...callbackArgs: unknown[]) => unknown).apply( + context, + args + ); + } catch (ex) { + if (globalObject.console) { + console.error("jsPDF PubSub Error", (ex as Error).message, ex); + } } + if (sub[1]) tokens.push(token); } - if (sub[1]) tokens.push(token); + if (tokens.length) tokens.forEach(this.unsubscribe); } - if (tokens.length) tokens.forEach(this.unsubscribe); - } - }; - - this.getTopics = function() { - return topics; - }; -} + }; -function GState(parameters) { - if (!(this instanceof GState)) { - return new (GState as any)(parameters); + this.getTopics = function () { + return topics; + }; } +} +class GState { /** * @name GState#opacity - * @type {any} + * @type {number} */ + declare opacity?: number; /** * @name GState#stroke-opacity - * @type {any} + * @type {number} */ - var supported = "opacity,stroke-opacity".split(","); - for (var p in parameters) { - if (parameters.hasOwnProperty(p) && supported.indexOf(p) >= 0) { - this[p] = parameters[p]; - } - } + // Quoted-name fields cannot take the `declare` modifier; the runtime + // property is assigned in the constructor. Its type lives on the merged + // interface below the class. /** * @name GState#id * @type {string} */ - this.id = ""; // set by addGState() + declare id: string; /** * @name GState#objectNumber * @type {number} */ - this.objectNumber = -1; // will be set by putGState() -} + declare objectNumber: number; -GState.prototype.equals = function equals(other) { - var ignore = "id,objectNumber,equals"; - var p; - if (!other || typeof other !== typeof this) return false; - var count = 0; - for (p in this) { - if (ignore.indexOf(p) >= 0) continue; - if (this.hasOwnProperty(p) && !other.hasOwnProperty(p)) return false; - if (this[p] !== other[p]) return false; - count++; - } - for (p in other) { - if (other.hasOwnProperty(p) && ignore.indexOf(p) < 0) count--; + constructor(parameters?: GStateOptions) { + var supported = "opacity,stroke-opacity".split(","); + for (var p in parameters) { + if (parameters.hasOwnProperty(p) && supported.indexOf(p) >= 0) { + this[p as keyof GStateOptions] = parameters[p as keyof GStateOptions]; + } + } + this.id = ""; // set by addGState() + this.objectNumber = -1; // will be set by putGState() } - return count === 0; -}; -function Pattern(gState, matrix) { - this.gState = gState; - this.matrix = matrix; + equals(other: GState): boolean { + var ignore = "id,objectNumber,equals"; + var p; + if (!other || typeof other !== typeof this) return false; + var count = 0; + // Reflective own-property comparison over dynamically attached + // graphics-state entries; the double assertion widens the class + // instances for generic string indexing. + var self = this as unknown as Record; + var that = other as unknown as Record; + for (p in self) { + if (ignore.indexOf(p) >= 0) continue; + if (self.hasOwnProperty(p) && !that.hasOwnProperty(p)) return false; + if (self[p] !== that[p]) return false; + count++; + } + for (p in that) { + if (that.hasOwnProperty(p) && ignore.indexOf(p) < 0) count--; + } + return count === 0; + } +} - this.id = ""; // set by addPattern() - this.objectNumber = -1; // will be set by putPattern() +// Declaration-merged home for the quoted-name field assigned in the constructor. +interface GState { + "stroke-opacity"?: number; } -function ShadingPattern(type, coords, colors, gState, matrix) { - if (!(this instanceof ShadingPattern)) { - return new (ShadingPattern as any)(type, coords, colors, gState, matrix); - } +class Pattern { + declare gState?: GState; + declare matrix?: MatrixType; + declare id: string; + declare objectNumber: number; - // see putPattern() for information how they are realized - this.type = type === "axial" ? 2 : 3; - this.coords = coords; - this.colors = colors; + constructor(gState?: GState, matrix?: MatrixType) { + this.gState = gState; + this.matrix = matrix; - Pattern.call(this, gState, matrix); + this.id = ""; // set by addPattern() + this.objectNumber = -1; // will be set by putPattern() + } } -function TilingPattern(boundingBox, xStep, yStep, gState, matrix) { - if (!(this instanceof TilingPattern)) { - return new (TilingPattern as any)( - boundingBox, - xStep, - yStep, - gState, - matrix - ); +class ShadingPattern extends Pattern { + declare type: 2 | 3; + declare coords: number[]; + declare colors: ShadingPatternStop[]; + + constructor( + type: ShadingPatternType, + coords: number[], + colors: ShadingPatternStop[], + gState?: GState, + matrix?: MatrixType + ) { + super(gState, matrix); + + // see putPattern() for information how they are realized + this.type = type === "axial" ? 2 : 3; + this.coords = coords; + this.colors = colors; } +} - this.boundingBox = boundingBox; - this.xStep = xStep; - this.yStep = yStep; +class TilingPattern extends Pattern { + declare boundingBox: number[]; + declare xStep: number; + declare yStep: number; + declare stream: string; + declare cloneIndex: number; + + constructor( + boundingBox: number[], + xStep: number, + yStep: number, + gState?: GState, + matrix?: MatrixType + ) { + super(gState, matrix); - this.stream = ""; // set by endTilingPattern(); + this.boundingBox = boundingBox; + this.xStep = xStep; + this.yStep = yStep; - this.cloneIndex = 0; + this.stream = ""; // set by endTilingPattern(); - Pattern.call(this, gState, matrix); + this.cloneIndex = 0; + } } /** @@ -217,17 +312,19 @@ function TilingPattern(boundingBox, xStep, yStep, gState, matrix) { * * @constructor */ -function jsPDF(options) { - var orientation = typeof arguments[0] === "string" ? arguments[0] : "p"; - var unit = arguments[1]; - var format = arguments[2]; - var compressPdf = arguments[3]; - var filters = []; +function jsPDF(options?: jsPDFOptions): jsPDFDocument { + // Legacy positional signature: jsPDF(orientation, unit, format, compressPdf). + var orientation: string = + typeof arguments[0] === "string" ? (arguments[0] as string) : "p"; + var unit: Unit | number = arguments[1] as Unit | number; + var format: PageFormat = arguments[2] as PageFormat; + var compressPdf: boolean = arguments[3] as boolean; + var filters: string[] = []; var userUnit = 1.0; - var precision; - var floatPrecision = 16; + var precision: number; + var floatPrecision: number | "smart" = 16; var defaultPathOperation = "S"; - var encryptionOptions = null; + var encryptionOptions: EncryptionOptions | null = null; options = options || {}; @@ -260,26 +357,29 @@ function jsPDF(options) { unit = unit || "mm"; orientation = ("" + (orientation || "P")).toLowerCase(); var putOnlyUsedFonts = options.putOnlyUsedFonts || false; - var usedFonts = {}; + var usedFonts: Record = {}; - var API: any = { - internal: {}, - __private__: {} - }; + // The document instance is built up incrementally throughout this whole + // constructor, so the initial literal only carries placeholders; the + // assertion is unavoidable for this legacy construction style. + var API = { + internal: {} as jsPDFInternal, + __private__: {} as jsPDFPrivate + } as jsPDFDocument; API.__private__.PubSub = PubSub; var pdfVersion = "1.3"; - var getPdfVersion = (API.__private__.getPdfVersion = function() { + var getPdfVersion = (API.__private__.getPdfVersion = function (): string { return pdfVersion; }); - API.__private__.setPdfVersion = function(value) { + API.__private__.setPdfVersion = function (value: string) { pdfVersion = value; }; // Size in pt of various paper formats - var pageFormats = { + var pageFormats: PageFormats = { a0: [2383.94, 3370.39], a1: [1683.78, 2383.94], a2: [1190.55, 1683.78], @@ -323,11 +423,13 @@ function jsPDF(options) { "credit-card": [153, 243] }; - API.__private__.getPageFormats = function() { + API.__private__.getPageFormats = function () { return pageFormats; }; - var getPageFormat = (API.__private__.getPageFormat = function(value) { + var getPageFormat = (API.__private__.getPageFormat = function ( + value: string + ) { return pageFormats[value]; }); @@ -339,7 +441,7 @@ function jsPDF(options) { }; var apiMode = ApiMode.COMPAT; - function advancedAPI() { + function advancedAPI(this: jsPDFDocument) { // prepend global change of basis matrix // (Now, instead of converting every coordinate to the pdf coordinate system, we apply a matrix // that does this job for us (however, texts, images and similar objects must be drawn bottom up)) @@ -363,7 +465,7 @@ function jsPDF(options) { apiMode = ApiMode.ADVANCED; } - function compatAPI() { + function compatAPI(this: jsPDFDocument) { this.restoreGraphicsState(); defaultPathOperation = "S"; apiMode = ApiMode.COMPAT; @@ -376,31 +478,32 @@ function jsPDF(options) { * @returns {string} * @private */ - var combineFontStyleAndFontWeight = (API.__private__.combineFontStyleAndFontWeight = function( - fontStyle, - fontWeight - ) { - if ( - (fontStyle == "bold" && fontWeight == "normal") || - (fontStyle == "bold" && fontWeight == 400) || - (fontStyle == "normal" && fontWeight == "italic") || - (fontStyle == "bold" && fontWeight == "italic") - ) { - throw new Error("Invalid Combination of fontweight and fontstyle"); - } - if (fontWeight) { - fontStyle = - fontWeight == 400 || fontWeight === "normal" - ? fontStyle === "italic" - ? "italic" - : "normal" - : (fontWeight == 700 || fontWeight === "bold") && - fontStyle === "normal" - ? "bold" - : (fontWeight == 700 ? "bold" : fontWeight) + "" + fontStyle; - } - return fontStyle; - }); + var combineFontStyleAndFontWeight = + (API.__private__.combineFontStyleAndFontWeight = function ( + fontStyle: string, + fontWeight?: string | number + ): string { + if ( + (fontStyle == "bold" && fontWeight == "normal") || + (fontStyle == "bold" && fontWeight == 400) || + (fontStyle == "normal" && fontWeight == "italic") || + (fontStyle == "bold" && fontWeight == "italic") + ) { + throw new Error("Invalid Combination of fontweight and fontstyle"); + } + if (fontWeight) { + fontStyle = + fontWeight == 400 || fontWeight === "normal" + ? fontStyle === "italic" + ? "italic" + : "normal" + : (fontWeight == 700 || fontWeight === "bold") && + fontStyle === "normal" + ? "bold" + : (fontWeight == 700 ? "bold" : fontWeight) + "" + fontStyle; + } + return fontStyle; + }); /** * @callback ApiSwitchBody @@ -428,7 +531,7 @@ function jsPDF(options) { * @memberof jsPDF# * @name advancedAPI */ - API.advancedAPI = function(body) { + API.advancedAPI = function (this: jsPDFDocument, body) { var doSwitch = apiMode === ApiMode.COMPAT; if (doSwitch) { @@ -457,7 +560,7 @@ function jsPDF(options) { * @memberof jsPDF# * @name compatApi */ - API.compatAPI = function(body) { + API.compatAPI = function (this: jsPDFDocument, body) { var doSwitch = apiMode === ApiMode.ADVANCED; if (doSwitch) { @@ -482,11 +585,11 @@ function jsPDF(options) { * @memberof jsPDF# * @name isAdvancedAPI */ - API.isAdvancedAPI = function() { + API.isAdvancedAPI = function () { return apiMode === ApiMode.ADVANCED; }; - var advancedApiModeTrap = function(methodName) { + var advancedApiModeTrap = function (methodName: string) { if (apiMode !== ApiMode.ADVANCED) { throw new Error( methodName + @@ -496,71 +599,86 @@ function jsPDF(options) { } }; - var roundToPrecision = (API.roundToPrecision = API.__private__.roundToPrecision = function( - number, - parmPrecision - ) { - var tmpPrecision = precision || parmPrecision; - if (isNaN(number) || isNaN(tmpPrecision)) { - throw new Error("Invalid argument passed to jsPDF.roundToPrecision"); - } - return number.toFixed(tmpPrecision).replace(/0+$/, ""); - }); + var roundToPrecision = + (API.roundToPrecision = + API.__private__.roundToPrecision = + function (number: number, parmPrecision: number): string { + var tmpPrecision = precision || parmPrecision; + if (isNaN(number) || isNaN(tmpPrecision)) { + throw new Error("Invalid argument passed to jsPDF.roundToPrecision"); + } + return number.toFixed(tmpPrecision).replace(/0+$/, ""); + }); // high precision float - var hpf; + var hpf: (number: number) => string; if (typeof floatPrecision === "number") { - hpf = API.hpf = API.__private__.hpf = function(number) { - if (isNaN(number)) { - throw new Error("Invalid argument passed to jsPDF.hpf"); - } - return roundToPrecision(number, floatPrecision); - }; + hpf = + API.hpf = + API.__private__.hpf = + function (number: number): string { + if (isNaN(number)) { + throw new Error("Invalid argument passed to jsPDF.hpf"); + } + return roundToPrecision(number, floatPrecision as number); + }; } else if (floatPrecision === "smart") { - hpf = API.hpf = API.__private__.hpf = function(number) { - if (isNaN(number)) { - throw new Error("Invalid argument passed to jsPDF.hpf"); - } - if (number > -1 && number < 1) { - return roundToPrecision(number, 16); - } else { - return roundToPrecision(number, 5); - } - }; + hpf = + API.hpf = + API.__private__.hpf = + function (number: number): string { + if (isNaN(number)) { + throw new Error("Invalid argument passed to jsPDF.hpf"); + } + if (number > -1 && number < 1) { + return roundToPrecision(number, 16); + } else { + return roundToPrecision(number, 5); + } + }; } else { - hpf = API.hpf = API.__private__.hpf = function(number) { - if (isNaN(number)) { - throw new Error("Invalid argument passed to jsPDF.hpf"); - } - return roundToPrecision(number, 16); - }; + hpf = + API.hpf = + API.__private__.hpf = + function (number: number): string { + if (isNaN(number)) { + throw new Error("Invalid argument passed to jsPDF.hpf"); + } + return roundToPrecision(number, 16); + }; } - var f2 = (API.f2 = API.__private__.f2 = function(number) { - if (isNaN(number)) { - throw new Error("Invalid argument passed to jsPDF.f2"); - } - return roundToPrecision(number, 2); - }); + var f2 = + (API.f2 = + API.__private__.f2 = + function (number: number): string { + if (isNaN(number)) { + throw new Error("Invalid argument passed to jsPDF.f2"); + } + return roundToPrecision(number, 2); + }); - var f3 = (API.__private__.f3 = function(number) { + var f3 = (API.__private__.f3 = function (number: number): string { if (isNaN(number)) { throw new Error("Invalid argument passed to jsPDF.f3"); } return roundToPrecision(number, 3); }); - var scale = (API.scale = API.__private__.scale = function(number) { - if (isNaN(number)) { - throw new Error("Invalid argument passed to jsPDF.scale"); - } - if (apiMode === ApiMode.COMPAT) { - return number * scaleFactor; - } else if (apiMode === ApiMode.ADVANCED) { - return number; - } - }); + var scale = + (API.scale = + API.__private__.scale = + function (number: number): number { + if (isNaN(number)) { + throw new Error("Invalid argument passed to jsPDF.scale"); + } + if (apiMode === ApiMode.COMPAT) { + return number * scaleFactor; + } else if (apiMode === ApiMode.ADVANCED) { + return number; + } + }); - var transformY = function(y) { + var transformY = function (y: number): number { if (apiMode === ApiMode.COMPAT) { return getPageHeight() - y; } else if (apiMode === ApiMode.ADVANCED) { @@ -568,7 +686,7 @@ function jsPDF(options) { } }; - var transformScaleY = function(y) { + var transformScaleY = function (y: number): number { return scale(transformY(y)); }; @@ -580,7 +698,7 @@ function jsPDF(options) { * @param {string} precision * @returns {jsPDF} */ - API.__private__.setPrecision = API.setPrecision = function(value) { + API.__private__.setPrecision = API.setPrecision = function (value: string) { if (typeof parseInt(value, 10) === "number") { precision = parseInt(value, 10); } @@ -588,17 +706,19 @@ function jsPDF(options) { var fileId = "00000000000000000000000000000000"; - var getFileId = (API.__private__.getFileId = function() { + var getFileId = (API.__private__.getFileId = function () { return fileId; }); - var setFileId = (API.__private__.setFileId = function(value?) { + var setFileId = (API.__private__.setFileId = function ( + value?: string + ): string { if (typeof value !== "undefined" && /^[a-fA-F0-9]{32}$/.test(value)) { fileId = value.toUpperCase(); } else { fileId = fileId .split("") - .map(function() { + .map(function () { return "ABCDEF0123456789".charAt(Math.floor(Math.random() * 16)); }) .join(""); @@ -623,7 +743,7 @@ function jsPDF(options) { * @param {string} value GUID. * @returns {jsPDF} */ - API.setFileId = function(value) { + API.setFileId = function (this: jsPDFDocument, value) { setFileId(value); return this; }; @@ -636,15 +756,15 @@ function jsPDF(options) { * * @returns {string} GUID. */ - API.getFileId = function() { + API.getFileId = function () { return getFileId(); }; - var creationDate; + var creationDate: string; - var convertDateToPDFDate = (API.__private__.convertDateToPDFDate = function( - parmDate - ) { + var convertDateToPDFDate = (API.__private__.convertDateToPDFDate = function ( + parmDate: Date + ): string { var result = ""; var tzoffset = parmDate.getTimezoneOffset(), tzsign = tzoffset < 0 ? "+" : "-", @@ -665,9 +785,9 @@ function jsPDF(options) { return result; }); - var convertPDFDateToDate = (API.__private__.convertPDFDateToDate = function( - parmPDFDate - ) { + var convertPDFDateToDate = (API.__private__.convertPDFDateToDate = function ( + parmPDFDate: string + ): Date { var year = parseInt(parmPDFDate.substr(2, 4), 10); var month = parseInt(parmPDFDate.substr(6, 2), 10) - 1; var date = parseInt(parmPDFDate.substr(8, 2), 10); @@ -681,9 +801,12 @@ function jsPDF(options) { return resultingDate; }); - var setCreationDate = (API.__private__.setCreationDate = function(date?) { + var setCreationDate = (API.__private__.setCreationDate = function ( + date?: Date | string + ): string { var tmpCreationDateString; - var regexPDFCreationDate = /^D:(20[0-2][0-9]|203[0-7]|19[7-9][0-9])(0[0-9]|1[0-2])([0-2][0-9]|3[0-1])(0[0-9]|1[0-9]|2[0-3])(0[0-9]|[1-5][0-9])(0[0-9]|[1-5][0-9])(\+0[0-9]|\+1[0-4]|-0[0-9]|-1[0-1])'(0[0-9]|[1-5][0-9])'?$/; + var regexPDFCreationDate = + /^D:(20[0-2][0-9]|203[0-7]|19[7-9][0-9])(0[0-9]|1[0-2])([0-2][0-9]|3[0-1])(0[0-9]|1[0-9]|2[0-3])(0[0-9]|[1-5][0-9])(0[0-9]|[1-5][0-9])(\+0[0-9]|\+1[0-4]|-0[0-9]|-1[0-1])'(0[0-9]|[1-5][0-9])'?$/; if (typeof date === "undefined") { date = new Date(); } @@ -699,8 +822,10 @@ function jsPDF(options) { return creationDate; }); - var getCreationDate = (API.__private__.getCreationDate = function(type) { - var result = creationDate; + var getCreationDate = (API.__private__.getCreationDate = function ( + type?: string + ): Date | string { + var result: Date | string = creationDate; if (type === "jsDate") { result = convertPDFDateToDate(creationDate); } @@ -715,7 +840,7 @@ function jsPDF(options) { * @param {Object} date * @returns {jsPDF} */ - API.setCreationDate = function(date) { + API.setCreationDate = function (this: jsPDFDocument, date) { setCreationDate(date); return this; }; @@ -728,31 +853,37 @@ function jsPDF(options) { * @param {Object} type * @returns {Object} */ - API.getCreationDate = function(type) { + // The cast reconciles the single implementation signature with the + // `(type: "jsDate") => Date` convenience overload declared in types.ts. + API.getCreationDate = function (type?: string) { return getCreationDate(type); - }; + } as unknown as jsPDFDocument["getCreationDate"]; - var padd2 = (API.__private__.padd2 = function(number) { - return ("0" + parseInt(number)).slice(-2); + var padd2 = (API.__private__.padd2 = function ( + number: number | string + ): string { + return ("0" + parseInt(number as string)).slice(-2); }); - var padd2Hex = (API.__private__.padd2Hex = function(hexString) { + var padd2Hex = (API.__private__.padd2Hex = function ( + hexString: string + ): string { hexString = hexString.toString(); return ("00" + hexString).substr(hexString.length); }); var objectNumber = 0; // 'n' Current object number - var offsets = []; // List of offsets. Activated and reset by buildDocument(). Pupulated by various calls buildDocument makes. - var content = []; + var offsets: Array number)> = []; // List of offsets. Activated and reset by buildDocument(). Pupulated by various calls buildDocument makes. + var content: string[] = []; var contentLength = 0; - var additionalObjects = []; + var additionalObjects: AdditionalObject[] = []; - var pages = []; - var currentPage; + var pages: string[][] = []; + var currentPage: number; var hasCustomDestination = false; var outputDestination = content; - var resetDocument = function() { + var resetDocument = function () { //reset fields relevant for objectNumber generation and xref. objectNumber = 0; contentLength = 0; @@ -764,22 +895,26 @@ function jsPDF(options) { resourceDictionaryObjId = newObjectDeferred(); }; - API.__private__.setCustomOutputDestination = function(destination) { + API.__private__.setCustomOutputDestination = function ( + destination: string[] + ) { hasCustomDestination = true; outputDestination = destination; }; - var setOutputDestination = function(destination) { + var setOutputDestination = function (destination: string[]) { if (!hasCustomDestination) { outputDestination = destination; } }; - API.__private__.resetCustomOutputDestination = function() { + API.__private__.resetCustomOutputDestination = function () { hasCustomDestination = false; outputDestination = content; }; - var out = (API.__private__.out = function(string) { + var out = (API.__private__.out = function ( + string: string | number + ): string[] { string = string.toString(); contentLength += string.length + 1; outputDestination.push(string); @@ -787,7 +922,9 @@ function jsPDF(options) { return outputDestination; }); - var write = (API.__private__.write = function(value) { + var write = (API.__private__.write = function ( + value: string | number + ): string[] { return out( arguments.length === 1 ? value.toString() @@ -795,7 +932,9 @@ function jsPDF(options) { ); }); - var getArrayBuffer = (API.__private__.getArrayBuffer = function(data) { + var getArrayBuffer = (API.__private__.getArrayBuffer = function ( + data: string + ): ArrayBuffer { var len = data.length, ab = new ArrayBuffer(len), u8 = new Uint8Array(ab); @@ -804,7 +943,7 @@ function jsPDF(options) { return ab; }); - var standardFonts = [ + var standardFonts: Array<[string, string, string, string | null]> = [ ["Helvetica", "helvetica", "normal", "WinAnsiEncoding"], ["Helvetica-Bold", "helvetica", "bold", "WinAnsiEncoding"], ["Helvetica-Oblique", "helvetica", "italic", "WinAnsiEncoding"], @@ -821,7 +960,7 @@ function jsPDF(options) { ["Symbol", "symbol", "normal", null] ]; - API.__private__.getStandardFonts = function() { + API.__private__.getStandardFonts = function () { return standardFonts; }; @@ -837,7 +976,10 @@ function jsPDF(options) { * @memberof jsPDF# * @name setFontSize */ - API.__private__.setFontSize = API.setFontSize = function(size) { + API.__private__.setFontSize = API.setFontSize = function ( + this: jsPDFDocument, + size: number + ) { if (apiMode === ApiMode.ADVANCED) { activeFontSize = size / scaleFactor; } else { @@ -855,13 +997,16 @@ function jsPDF(options) { * @memberof jsPDF# * @name getFontSize */ - var getFontSize = (API.__private__.getFontSize = API.getFontSize = function() { - if (apiMode === ApiMode.COMPAT) { - return activeFontSize; - } else { - return activeFontSize * scaleFactor; - } - }); + var getFontSize = + (API.__private__.getFontSize = + API.getFontSize = + function () { + if (apiMode === ApiMode.COMPAT) { + return activeFontSize; + } else { + return activeFontSize * scaleFactor; + } + }); var R2L = options.R2L || false; @@ -875,7 +1020,10 @@ function jsPDF(options) { * @memberof jsPDF# * @name setR2L */ - API.__private__.setR2L = API.setR2L = function(value) { + API.__private__.setR2L = API.setR2L = function ( + this: jsPDFDocument, + value: boolean + ) { R2L = value; return this; }; @@ -889,14 +1037,16 @@ function jsPDF(options) { * @memberof jsPDF# * @name getR2L */ - API.__private__.getR2L = API.getR2L = function() { + API.__private__.getR2L = API.getR2L = function () { return R2L; }; - var zoomMode; // default: 1; + var zoomMode: string | number; // default: 1; - var setZoomMode = (API.__private__.setZoomMode = function(zoom) { - var validZoomModes = [ + var setZoomMode = (API.__private__.setZoomMode = function ( + zoom: string | number + ) { + var validZoomModes: Array = [ undefined, null, "fullwidth", @@ -905,10 +1055,10 @@ function jsPDF(options) { "original" ]; - if (/^(?:\d+\.\d*|\d*\.\d+|\d+)%$/.test(zoom)) { + if (/^(?:\d+\.\d*|\d*\.\d+|\d+)%$/.test(zoom as string)) { zoomMode = zoom; - } else if (!isNaN(zoom)) { - zoomMode = parseInt(zoom, 10); + } else if (!isNaN(zoom as number)) { + zoomMode = parseInt(zoom as string, 10); } else if (validZoomModes.indexOf(zoom) !== -1) { zoomMode = zoom; } else { @@ -920,13 +1070,13 @@ function jsPDF(options) { } }); - API.__private__.getZoomMode = function() { + API.__private__.getZoomMode = function () { return zoomMode; }; - var pageMode; // default: 'UseOutlines'; - var setPageMode = (API.__private__.setPageMode = function(pmode) { - var validPageModes = [ + var pageMode: string; // default: 'UseOutlines'; + var setPageMode = (API.__private__.setPageMode = function (pmode: string) { + var validPageModes: Array = [ undefined, null, "UseNone", @@ -945,13 +1095,15 @@ function jsPDF(options) { pageMode = pmode; }); - API.__private__.getPageMode = function() { + API.__private__.getPageMode = function () { return pageMode; }; - var layoutMode; // default: 'continuous'; - var setLayoutMode = (API.__private__.setLayoutMode = function(layout) { - var validLayoutModes = [ + var layoutMode: string; // default: 'continuous'; + var setLayoutMode = (API.__private__.setLayoutMode = function ( + layout: string + ) { + var validLayoutModes: Array = [ undefined, null, "continuous", @@ -971,7 +1123,7 @@ function jsPDF(options) { layoutMode = layout; }); - API.__private__.getLayoutMode = function() { + API.__private__.getLayoutMode = function () { return layoutMode; }; @@ -1000,7 +1152,8 @@ function jsPDF(options) { * * @returns {jsPDF} */ - API.__private__.setDisplayMode = API.setDisplayMode = function( + API.__private__.setDisplayMode = API.setDisplayMode = function ( + this: jsPDFDocument, zoom, layout, pmode @@ -1011,7 +1164,7 @@ function jsPDF(options) { return this; }; - var documentProperties = { + var documentProperties: Record = { title: "", subject: "", author: "", @@ -1019,14 +1172,14 @@ function jsPDF(options) { creator: "" }; - API.__private__.getDocumentProperty = function(key) { + API.__private__.getDocumentProperty = function (key: string) { if (Object.keys(documentProperties).indexOf(key) === -1) { throw new Error("Invalid argument passed to jsPDF.getDocumentProperty"); } return documentProperties[key]; }; - API.__private__.getDocumentProperties = function() { + API.__private__.getDocumentProperties = function () { return documentProperties; }; @@ -1040,46 +1193,55 @@ function jsPDF(options) { * @memberof jsPDF# * @name setDocumentProperties */ - API.__private__.setDocumentProperties = API.setProperties = API.setDocumentProperties = function( - properties - ) { - // copying only those properties we can render. - for (var property in documentProperties) { - if (documentProperties.hasOwnProperty(property) && properties[property]) { - documentProperties[property] = properties[property]; - } - } - return this; - }; + API.__private__.setDocumentProperties = + API.setProperties = + API.setDocumentProperties = + function (this: jsPDFDocument, properties) { + // copying only those properties we can render. + var propertyMap = properties as Record; + for (var property in documentProperties) { + if ( + documentProperties.hasOwnProperty(property) && + propertyMap[property] + ) { + documentProperties[property] = propertyMap[property]; + } + } + return this; + }; - API.__private__.setDocumentProperty = function(key, value) { + API.__private__.setDocumentProperty = function (key: string, value: string) { if (Object.keys(documentProperties).indexOf(key) === -1) { throw new Error("Invalid arguments passed to jsPDF.setDocumentProperty"); } return (documentProperties[key] = value); }; - var fonts = {}; // collection of font objects, where key is fontKey - a dynamically created label for a given font. - var fontmap = {}; // mapping structure fontName > fontStyle > font key - performance layer. See addFont() - var activeFontKey; // will be string representing the KEY of the font as combination of fontName + fontStyle - var fontStateStack = []; // - var patterns = {}; // collection of pattern objects - var patternMap = {}; // see fonts - var gStates = {}; // collection of graphic state objects - var gStatesMap = {}; // see fonts - var activeGState = null; - var scaleFactor; // Scale factor + var fonts: FontMap = {}; // collection of font objects, where key is fontKey - a dynamically created label for a given font. + var fontmap: FontDictionary = {}; // mapping structure fontName > fontStyle > font key - performance layer. See addFont() + var activeFontKey: string; // will be string representing the KEY of the font as combination of fontName + fontStyle + var fontStateStack: Array<{ + key: string; + size: number; + color: string; + }> = []; // + var patterns: Record = {}; // collection of pattern objects + var patternMap: Record = {}; // see fonts + var gStates: Record = {}; // collection of graphic state objects + var gStatesMap: Record = {}; // see fonts + var activeGState: GState | null = null; + var scaleFactor: number; // Scale factor var page = 0; - var pagesContext = []; + var pagesContext: PageContext[] = []; var events = new PubSub(API); var hotfixes = options.hotfixes || []; - var renderTargets = {}; - var renderTargetMap = {}; - var renderTargetStack = []; - var pageX; - var pageY; - var pageMatrix; // only used for FormObjects + var renderTargets: Record = {}; + var renderTargetMap: Record = {}; + var renderTargetStack: RenderTarget[] = []; + var pageX: number; + var pageY: number; + var pageMatrix: MatrixType; // only used for FormObjects /** * A matrix object for 2D homogenous transformations:
    @@ -1098,189 +1260,164 @@ function jsPDF(options) { * @param {number} ty * @constructor */ - var Matrix: any = function(sx, shy, shx, sy, tx, ty) { - if (!(this instanceof Matrix)) { - return new Matrix(sx, shy, shx, sy, tx, ty); - } - - if (isNaN(sx)) sx = 1; - if (isNaN(shy)) shy = 0; - if (isNaN(shx)) shx = 0; - if (isNaN(sy)) sy = 1; - if (isNaN(tx)) tx = 0; - if (isNaN(ty)) ty = 0; + class Matrix { + declare _matrix: number[]; + + constructor( + sx?: number, + shy?: number, + shx?: number, + sy?: number, + tx?: number, + ty?: number + ) { + if (isNaN(sx)) sx = 1; + if (isNaN(shy)) shy = 0; + if (isNaN(shx)) shx = 0; + if (isNaN(sy)) sy = 1; + if (isNaN(tx)) tx = 0; + if (isNaN(ty)) ty = 0; - this._matrix = [sx, shy, shx, sy, tx, ty]; - }; + this._matrix = [sx, shy, shx, sy, tx, ty]; + } - /** - * @name sx - * @memberof Matrix# - */ - Object.defineProperty(Matrix.prototype, "sx", { - get: function() { + /** + * @name sx + * @memberof Matrix# + */ + get sx(): number { return this._matrix[0]; - }, - set: function(value) { + } + set sx(value: number) { this._matrix[0] = value; } - }); - /** - * @name shy - * @memberof Matrix# - */ - Object.defineProperty(Matrix.prototype, "shy", { - get: function() { + /** + * @name shy + * @memberof Matrix# + */ + get shy(): number { return this._matrix[1]; - }, - set: function(value) { + } + set shy(value: number) { this._matrix[1] = value; } - }); - /** - * @name shx - * @memberof Matrix# - */ - Object.defineProperty(Matrix.prototype, "shx", { - get: function() { + /** + * @name shx + * @memberof Matrix# + */ + get shx(): number { return this._matrix[2]; - }, - set: function(value) { + } + set shx(value: number) { this._matrix[2] = value; } - }); - /** - * @name sy - * @memberof Matrix# - */ - Object.defineProperty(Matrix.prototype, "sy", { - get: function() { + /** + * @name sy + * @memberof Matrix# + */ + get sy(): number { return this._matrix[3]; - }, - set: function(value) { + } + set sy(value: number) { this._matrix[3] = value; } - }); - /** - * @name tx - * @memberof Matrix# - */ - Object.defineProperty(Matrix.prototype, "tx", { - get: function() { + /** + * @name tx + * @memberof Matrix# + */ + get tx(): number { return this._matrix[4]; - }, - set: function(value) { + } + set tx(value: number) { this._matrix[4] = value; } - }); - /** - * @name ty - * @memberof Matrix# - */ - Object.defineProperty(Matrix.prototype, "ty", { - get: function() { + /** + * @name ty + * @memberof Matrix# + */ + get ty(): number { return this._matrix[5]; - }, - set: function(value) { + } + set ty(value: number) { this._matrix[5] = value; } - }); - Object.defineProperty(Matrix.prototype, "a", { - get: function() { + get a(): number { return this._matrix[0]; - }, - set: function(value) { + } + set a(value: number) { this._matrix[0] = value; } - }); - Object.defineProperty(Matrix.prototype, "b", { - get: function() { + get b(): number { return this._matrix[1]; - }, - set: function(value) { + } + set b(value: number) { this._matrix[1] = value; } - }); - Object.defineProperty(Matrix.prototype, "c", { - get: function() { + get c(): number { return this._matrix[2]; - }, - set: function(value) { + } + set c(value: number) { this._matrix[2] = value; } - }); - Object.defineProperty(Matrix.prototype, "d", { - get: function() { + get d(): number { return this._matrix[3]; - }, - set: function(value) { + } + set d(value: number) { this._matrix[3] = value; } - }); - Object.defineProperty(Matrix.prototype, "e", { - get: function() { + get e(): number { return this._matrix[4]; - }, - set: function(value) { + } + set e(value: number) { this._matrix[4] = value; } - }); - Object.defineProperty(Matrix.prototype, "f", { - get: function() { + get f(): number { return this._matrix[5]; - }, - set: function(value) { + } + set f(value: number) { this._matrix[5] = value; } - }); - /** - * @name rotation - * @memberof Matrix# - */ - Object.defineProperty(Matrix.prototype, "rotation", { - get: function() { + /** + * @name rotation + * @memberof Matrix# + */ + get rotation(): number { return Math.atan2(this.shx, this.sx); } - }); - /** - * @name scaleX - * @memberof Matrix# - */ - Object.defineProperty(Matrix.prototype, "scaleX", { - get: function() { + /** + * @name scaleX + * @memberof Matrix# + */ + get scaleX(): number { return this.decompose().scale.sx; } - }); - /** - * @name scaleY - * @memberof Matrix# - */ - Object.defineProperty(Matrix.prototype, "scaleY", { - get: function() { + /** + * @name scaleY + * @memberof Matrix# + */ + get scaleY(): number { return this.decompose().scale.sy; } - }); - /** - * @name isIdentity - * @memberof Matrix# - */ - Object.defineProperty(Matrix.prototype, "isIdentity", { - get: function() { + /** + * @name isIdentity + * @memberof Matrix# + */ + get isIdentity(): boolean { if (this.sx !== 1) { return false; } @@ -1301,151 +1438,156 @@ function jsPDF(options) { } return true; } - }); - /** - * Join the Matrix Values to a String - * - * @function join - * @param {string} separator Specifies a string to separate each pair of adjacent elements of the array. The separator is converted to a string if necessary. If omitted, the array elements are separated with a comma (","). If separator is an empty string, all elements are joined without any characters in between them. - * @returns {string} A string with all array elements joined. - * @memberof Matrix# - */ - Matrix.prototype.join = function(separator) { - return [this.sx, this.shy, this.shx, this.sy, this.tx, this.ty] - .map(hpf) - .join(separator); - }; + /** + * Join the Matrix Values to a String + * + * @function join + * @param {string} separator Specifies a string to separate each pair of adjacent elements of the array. The separator is converted to a string if necessary. If omitted, the array elements are separated with a comma (","). If separator is an empty string, all elements are joined without any characters in between them. + * @returns {string} A string with all array elements joined. + * @memberof Matrix# + */ + join(separator?: string): string { + return [this.sx, this.shy, this.shx, this.sy, this.tx, this.ty] + .map(hpf) + .join(separator); + } - /** - * Multiply the matrix with given Matrix - * - * @function multiply - * @param matrix - * @returns {Matrix} - * @memberof Matrix# - */ - Matrix.prototype.multiply = function(matrix) { - var sx = matrix.sx * this.sx + matrix.shy * this.shx; - var shy = matrix.sx * this.shy + matrix.shy * this.sy; - var shx = matrix.shx * this.sx + matrix.sy * this.shx; - var sy = matrix.shx * this.shy + matrix.sy * this.sy; - var tx = matrix.tx * this.sx + matrix.ty * this.shx + this.tx; - var ty = matrix.tx * this.shy + matrix.ty * this.sy + this.ty; - - return new Matrix(sx, shy, shx, sy, tx, ty); - }; + /** + * Multiply the matrix with given Matrix + * + * @function multiply + * @param matrix + * @returns {Matrix} + * @memberof Matrix# + */ + multiply(matrix: MatrixType): Matrix { + var sx = matrix.sx * this.sx + matrix.shy * this.shx; + var shy = matrix.sx * this.shy + matrix.shy * this.sy; + var shx = matrix.shx * this.sx + matrix.sy * this.shx; + var sy = matrix.shx * this.shy + matrix.sy * this.sy; + var tx = matrix.tx * this.sx + matrix.ty * this.shx + this.tx; + var ty = matrix.tx * this.shy + matrix.ty * this.sy + this.ty; - /** - * @function decompose - * @memberof Matrix# - */ - Matrix.prototype.decompose = function() { - var a = this.sx; - var b = this.shy; - var c = this.shx; - var d = this.sy; - var e = this.tx; - var f = this.ty; - - var scaleX = Math.sqrt(a * a + b * b); - a /= scaleX; - b /= scaleX; - - var shear = a * c + b * d; - c -= a * shear; - d -= b * shear; - - var scaleY = Math.sqrt(c * c + d * d); - c /= scaleY; - d /= scaleY; - shear /= scaleY; - - if (a * d < b * c) { - a = -a; - b = -b; - shear = -shear; - scaleX = -scaleX; + return new Matrix(sx, shy, shx, sy, tx, ty); } - return { - scale: new Matrix(scaleX, 0, 0, scaleY, 0, 0), - translate: new Matrix(1, 0, 0, 1, e, f), - rotate: new Matrix(a, b, -b, a, 0, 0), - skew: new Matrix(1, 0, shear, 1, 0, 0) - }; - }; + /** + * @function decompose + * @memberof Matrix# + */ + decompose(): { + scale: Matrix; + translate: Matrix; + rotate: Matrix; + skew: Matrix; + } { + var a = this.sx; + var b = this.shy; + var c = this.shx; + var d = this.sy; + var e = this.tx; + var f = this.ty; + + var scaleX = Math.sqrt(a * a + b * b); + a /= scaleX; + b /= scaleX; + + var shear = a * c + b * d; + c -= a * shear; + d -= b * shear; + + var scaleY = Math.sqrt(c * c + d * d); + c /= scaleY; + d /= scaleY; + shear /= scaleY; + + if (a * d < b * c) { + a = -a; + b = -b; + shear = -shear; + scaleX = -scaleX; + } - /** - * @function toString - * @memberof Matrix# - */ - Matrix.prototype.toString = function(parmPrecision) { - return this.join(" "); - }; + return { + scale: new Matrix(scaleX, 0, 0, scaleY, 0, 0), + translate: new Matrix(1, 0, 0, 1, e, f), + rotate: new Matrix(a, b, -b, a, 0, 0), + skew: new Matrix(1, 0, shear, 1, 0, 0) + }; + } - /** - * @function inversed - * @memberof Matrix# - */ - Matrix.prototype.inversed = function() { - var a = this.sx, - b = this.shy, - c = this.shx, - d = this.sy, - e = this.tx, - f = this.ty; - - var quot = 1 / (a * d - b * c); - - var aInv = d * quot; - var bInv = -b * quot; - var cInv = -c * quot; - var dInv = a * quot; - var eInv = -aInv * e - cInv * f; - var fInv = -bInv * e - dInv * f; - - return new Matrix(aInv, bInv, cInv, dInv, eInv, fInv); - }; + /** + * @function toString + * @memberof Matrix# + */ + toString(parmPrecision?: number): string { + return this.join(" "); + } - /** - * @function applyToPoint - * @memberof Matrix# - */ - Matrix.prototype.applyToPoint = function(pt) { - var x = pt.x * this.sx + pt.y * this.shx + this.tx; - var y = pt.x * this.shy + pt.y * this.sy + this.ty; - return new Point(x, y); - }; + /** + * @function inversed + * @memberof Matrix# + */ + inversed(): Matrix { + var a = this.sx, + b = this.shy, + c = this.shx, + d = this.sy, + e = this.tx, + f = this.ty; - /** - * @function applyToRectangle - * @memberof Matrix# - */ - Matrix.prototype.applyToRectangle = function(rect) { - var pt1 = this.applyToPoint(rect); - var pt2 = this.applyToPoint(new Point(rect.x + rect.w, rect.y + rect.h)); - return new Rectangle(pt1.x, pt1.y, pt2.x - pt1.x, pt2.y - pt1.y); - }; + var quot = 1 / (a * d - b * c); - /** - * Clone the Matrix - * - * @function clone - * @memberof Matrix# - * @name clone - * @instance - */ - Matrix.prototype.clone = function() { - var sx = this.sx; - var shy = this.shy; - var shx = this.shx; - var sy = this.sy; - var tx = this.tx; - var ty = this.ty; - - return new Matrix(sx, shy, shx, sy, tx, ty); - }; + var aInv = d * quot; + var bInv = -b * quot; + var cInv = -c * quot; + var dInv = a * quot; + var eInv = -aInv * e - cInv * f; + var fInv = -bInv * e - dInv * f; + + return new Matrix(aInv, bInv, cInv, dInv, eInv, fInv); + } + + /** + * @function applyToPoint + * @memberof Matrix# + */ + applyToPoint(pt: PointType): PointType { + var x = pt.x * this.sx + pt.y * this.shx + this.tx; + var y = pt.x * this.shy + pt.y * this.sy + this.ty; + return new Point(x, y); + } + + /** + * @function applyToRectangle + * @memberof Matrix# + */ + applyToRectangle(rect: RectangleType): RectangleType { + var pt1 = this.applyToPoint(rect); + var pt2 = this.applyToPoint(new Point(rect.x + rect.w, rect.y + rect.h)); + return new Rectangle(pt1.x, pt1.y, pt2.x - pt1.x, pt2.y - pt1.y); + } + + /** + * Clone the Matrix + * + * @function clone + * @memberof Matrix# + * @name clone + * @instance + */ + clone(): Matrix { + var sx = this.sx; + var shy = this.shy; + var shx = this.shx; + var sy = this.sy; + var tx = this.tx; + var ty = this.ty; + + return new Matrix(sx, shy, shx, sy, tx, ty); + } + } API.Matrix = Matrix; @@ -1456,7 +1598,7 @@ function jsPDF(options) { * @memberof jsPDF# * @name matrixMult */ - var matrixMult = (API.matrixMult = function(m1, m2) { + var matrixMult = (API.matrixMult = function (m1: MatrixType, m2: MatrixType) { return m2.multiply(m1); }); @@ -1474,7 +1616,7 @@ function jsPDF(options) { * @param {String} key The key by it can be referenced later. The keys must be unique! * @param {API.Pattern} pattern The pattern */ - var addPattern = function(key, pattern) { + var addPattern = function (key: string, pattern: Pattern) { // only add it if it is not already present (the keys provided by the user must be unique!) if (patternMap[key]) return; @@ -1531,7 +1673,7 @@ function jsPDF(options) { * @memberof jsPDF# * @name addPattern */ - API.addShadingPattern = function(key, pattern) { + API.addShadingPattern = function (this: jsPDFDocument, key, pattern) { advancedApiModeTrap("addShadingPattern()"); addPattern(key, pattern); @@ -1545,7 +1687,7 @@ function jsPDF(options) { * @memberof jsPDF# * @name beginTilingPattern */ - API.beginTilingPattern = function(pattern) { + API.beginTilingPattern = function (pattern) { advancedApiModeTrap("beginTilingPattern()"); beginNewRenderTarget( @@ -1567,7 +1709,7 @@ function jsPDF(options) { * @memberof jsPDF# * @name endTilingPattern */ - API.endTilingPattern = function(key, pattern) { + API.endTilingPattern = function (key, pattern) { advancedApiModeTrap("endTilingPattern()"); // retrieve the stream @@ -1581,22 +1723,22 @@ function jsPDF(options) { renderTargetStack.pop().restore(); }; - var newObject = (API.__private__.newObject = function() { + var newObject = (API.__private__.newObject = function () { var oid = newObjectDeferred(); newObjectDeferredBegin(oid, true); return oid; }); // Does not output the object. The caller must call newObjectDeferredBegin(oid) before outputing any data - var newObjectDeferred = (API.__private__.newObjectDeferred = function() { + var newObjectDeferred = (API.__private__.newObjectDeferred = function () { objectNumber++; - offsets[objectNumber] = function() { + offsets[objectNumber] = function () { return contentLength; }; return objectNumber; }); - var newObjectDeferredBegin = function(oid, doOutput) { + var newObjectDeferredBegin = function (oid: number, doOutput?: boolean) { doOutput = typeof doOutput === "boolean" ? doOutput : false; offsets[oid] = contentLength; if (doOutput) { @@ -1608,15 +1750,16 @@ function jsPDF(options) { // Returns an object containing the objectId and content. // All pages have been added so the object ID can be estimated to start right after. // This does not modify the current objectNumber; It must be updated after the newObjects are output. - var newAdditionalObject = (API.__private__.newAdditionalObject = function() { - var objId = newObjectDeferred(); - var obj = { - objId: objId, - content: "" - }; - additionalObjects.push(obj); - return obj; - }); + var newAdditionalObject = (API.__private__.newAdditionalObject = + function (): AdditionalObject { + var objId = newObjectDeferred(); + var obj = { + objId: objId, + content: "" + }; + additionalObjects.push(obj); + return obj; + }); var rootDictionaryObjId = newObjectDeferred(); var resourceDictionaryObjId = newObjectDeferred(); @@ -1625,36 +1768,45 @@ function jsPDF(options) { // Private functions ///////////////////// - var decodeColorString = (API.__private__.decodeColorString = function(color) { - var colorEncoded = color.split(" "); + var decodeColorString = (API.__private__.decodeColorString = function ( + color: string + ): string { + var colorEncoded: Array = color.split(" "); if ( colorEncoded.length === 2 && (colorEncoded[1] === "g" || colorEncoded[1] === "G") ) { // convert grayscale value to rgb so that it can be converted to hex for consistency - var floatVal = parseFloat(colorEncoded[0]); + var floatVal = parseFloat(colorEncoded[0] as string); colorEncoded = [floatVal, floatVal, floatVal, "r"]; } else if ( colorEncoded.length === 5 && (colorEncoded[4] === "k" || colorEncoded[4] === "K") ) { // convert CMYK values to rbg so that it can be converted to hex for consistency - var red = (1.0 - colorEncoded[0]) * (1.0 - colorEncoded[3]); - var green = (1.0 - colorEncoded[1]) * (1.0 - colorEncoded[3]); - var blue = (1.0 - colorEncoded[2]) * (1.0 - colorEncoded[3]); + var red = + (1.0 - (colorEncoded[0] as number)) * + (1.0 - (colorEncoded[3] as number)); + var green = + (1.0 - (colorEncoded[1] as number)) * + (1.0 - (colorEncoded[3] as number)); + var blue = + (1.0 - (colorEncoded[2] as number)) * + (1.0 - (colorEncoded[3] as number)); colorEncoded = [red, green, blue, "r"]; } var colorAsRGB = "#"; for (var i = 0; i < 3; i++) { colorAsRGB += ( - "0" + Math.floor(parseFloat(colorEncoded[i]) * 255).toString(16) + "0" + + Math.floor(parseFloat(colorEncoded[i] as string) * 255).toString(16) ).slice(-2); } return colorAsRGB; }); - var encodeColorString = (API.__private__.encodeColorString = function( + var encodeColorString = (API.__private__.encodeColorString = function ( options ) { var color; @@ -1664,12 +1816,22 @@ function jsPDF(options) { ch1: options }; } - var ch1 = options.ch1; - var ch2 = options.ch2; - var ch3 = options.ch3; - var ch4 = options.ch4; + // Arrays are not handled by this implementation; the channel object is + // the only supported non-string input (see the jsPDFPrivate declaration). + var channels = options as { + ch1: string | number; + ch2?: string | number; + ch3?: string | number; + ch4?: string | number | { a: number }; + pdfColorType?: "draw" | "fill" | "text"; + precision?: number; + }; + var ch1 = channels.ch1; + var ch2 = channels.ch2; + var ch3 = channels.ch3; + var ch4 = channels.ch4; var letterArray = - options.pdfColorType === "draw" ? ["G", "RG", "K"] : ["g", "rg", "k"]; + channels.pdfColorType === "draw" ? ["G", "RG", "K"] : ["g", "rg", "k"]; if (typeof ch1 === "string" && ch1.charAt(0) !== "#") { var rgbColor = new RGBColor(ch1); @@ -1701,7 +1863,7 @@ function jsPDF(options) { if (typeof ch1 === "string") { color = ch1 + " " + letterArray[0]; } else { - switch (options.precision) { + switch (channels.precision) { case 2: color = f2(ch1 / 255) + " " + letterArray[0]; break; @@ -1712,7 +1874,7 @@ function jsPDF(options) { } } else if (typeof ch4 === "undefined" || typeof ch4 === "object") { // assume RGBA - if (ch4 && !isNaN(ch4.a)) { + if (ch4 && !isNaN((ch4 as { a: number }).a)) { //TODO Implement transparency. //WORKAROUND use white for now, if transparent, otherwise handle as rgb if (ch4.a === 0) { @@ -1724,12 +1886,12 @@ function jsPDF(options) { if (typeof ch1 === "string") { color = [ch1, ch2, ch3, letterArray[1]].join(" "); } else { - switch (options.precision) { + switch (channels.precision) { case 2: color = [ f2(ch1 / 255), - f2(ch2 / 255), - f2(ch3 / 255), + f2((ch2 as number) / 255), + f2((ch3 as number) / 255), letterArray[1] ].join(" "); break; @@ -1737,8 +1899,8 @@ function jsPDF(options) { case 3: color = [ f3(ch1 / 255), - f3(ch2 / 255), - f3(ch3 / 255), + f3((ch2 as number) / 255), + f3((ch3 as number) / 255), letterArray[1] ].join(" "); } @@ -1748,28 +1910,38 @@ function jsPDF(options) { if (typeof ch1 === "string") { color = [ch1, ch2, ch3, ch4, letterArray[2]].join(" "); } else { - switch (options.precision) { + switch (channels.precision) { case 2: - color = [f2(ch1), f2(ch2), f2(ch3), f2(ch4), letterArray[2]].join( - " " - ); + color = [ + f2(ch1), + f2(ch2 as number), + f2(ch3 as number), + f2(ch4 as number), + letterArray[2] + ].join(" "); break; case 3: default: - color = [f3(ch1), f3(ch2), f3(ch3), f3(ch4), letterArray[2]].join( - " " - ); + color = [ + f3(ch1), + f3(ch2 as number), + f3(ch3 as number), + f3(ch4 as number), + letterArray[2] + ].join(" "); } } } return color; }); - var getFilters = (API.__private__.getFilters = function() { + var getFilters = (API.__private__.getFilters = function () { return filters; }); - var putStream = (API.__private__.putStream = function(options) { + var putStream = (API.__private__.putStream = function ( + options?: PutStreamOptions + ) { options = options || {}; var data = options.data || ""; var filters = options.filters || getFilters(); @@ -1777,7 +1949,7 @@ function jsPDF(options) { var addLength1 = options.addLength1 || false; var valueOfLength1 = data.length; var objectId = options.objectId; - var encryptor: any = function(data) { + var encryptor: Encryptor = function (data) { return data; }; if (encryptionOptions !== null && typeof objectId == "undefined") { @@ -1789,7 +1961,7 @@ function jsPDF(options) { encryptor = encryption.encryptor(objectId, 0); } - var processedData: any = {}; + var processedData: ProcessedData; if (filters === true) { filters = ["FlateEncode"]; } @@ -1797,7 +1969,12 @@ function jsPDF(options) { if (typeof jsPDF.API.processDataByFilters !== "undefined") { processedData = jsPDF.API.processDataByFilters(data, filters); } else { - processedData = { data: data, reverseChain: [] }; + // reverseChain is string-concatenated below, so the empty-array + // fallback behaves like "" at runtime (Array#toString). + processedData = { + data: data, + reverseChain: ([] as string[]).join("") + }; } var filterAsString = processedData.reverseChain + @@ -1861,7 +2038,24 @@ function jsPDF(options) { } }); - var putPage = (API.__private__.putPage = function(page) { + interface PageDescriptor { + number: number; + data: string[]; + objId: number; + contentsObjId: number; + mediaBox: PageBox; + cropBox: PageBox | null; + bleedBox: PageBox | null; + trimBox: PageBox | null; + artBox: PageBox | null; + userUnit: number; + rootDictionaryObjId: number; + resourceDictionaryObjId: number; + } + + var putPage = (API.__private__.putPage = function ( + page: PageDescriptor + ): number { var pageNumber = page.number; var data = page.data; var pageObjectNumber = page.objId; @@ -1969,10 +2163,10 @@ function jsPDF(options) { return pageObjectNumber; }); - var putPages = (API.__private__.putPages = function() { + var putPages = (API.__private__.putPages = function () { var n, i, - pageObjectNumbers = []; + pageObjectNumbers: number[] = []; for (n = 1; n <= page; n++) { pagesContext[n].objId = newObjectDeferred(); @@ -2010,7 +2204,7 @@ function jsPDF(options) { events.publish("postPutPages"); }); - var putFont = function(font) { + var putFont = function (font: Font & { isAlreadyPutted?: boolean }) { events.publish("putFont", { font: font, out: out, @@ -2034,7 +2228,7 @@ function jsPDF(options) { } }; - var putFonts = function() { + var putFonts = function () { for (var fontKey in fonts) { if (fonts.hasOwnProperty(fontKey)) { if ( @@ -2047,10 +2241,10 @@ function jsPDF(options) { } }; - var putXObject = function(xObject) { + var putXObject = function (xObject: RenderTarget) { xObject.objectNumber = newObject(); - var options = []; + var options: Array<{ key: string; value: string | number }> = []; options.push({ key: "Type", value: "/XObject" }); options.push({ key: "Subtype", value: "/Form" }); options.push({ @@ -2080,7 +2274,7 @@ function jsPDF(options) { out("endobj"); }; - var putXObjects = function() { + var putXObjects = function () { for (var xObjectKey in renderTargets) { if (renderTargets.hasOwnProperty(xObjectKey)) { putXObject(renderTargets[xObjectKey]); @@ -2088,8 +2282,11 @@ function jsPDF(options) { } }; - var interpolateAndEncodeRGBStream = function(colors, numberSamples) { - var tValues = []; + var interpolateAndEncodeRGBStream = function ( + colors: ShadingPatternStop[], + numberSamples: number + ): string { + var tValues: number[] = []; var t; var dT = 1.0 / (numberSamples - 1); for (t = 0.0; t < 1.0; t += dT) { @@ -2132,7 +2329,10 @@ function jsPDF(options) { return out.trim(); }; - var putShadingPattern = function(pattern, numberSamples?) { + var putShadingPattern = function ( + pattern: ShadingPattern, + numberSamples?: number + ) { /* Axial patterns shade between the two points specified in coords, radial patterns between the inner and outer circle. @@ -2145,7 +2345,7 @@ function jsPDF(options) { var funcObjectNumber = newObject(); var stream = interpolateAndEncodeRGBStream(pattern.colors, numberSamples); - var options = []; + var options: Array<{ key: string; value: string | number }> = []; options.push({ key: "FunctionType", value: "0" }); options.push({ key: "Domain", value: "[0.0 1.0]" }); options.push({ key: "Size", value: "[" + numberSamples + "]" }); @@ -2166,26 +2366,26 @@ function jsPDF(options) { out("/ColorSpace /DeviceRGB"); var coords = "/Coords [" + - hpf(parseFloat(pattern.coords[0])) + + hpf(parseFloat(String(pattern.coords[0]))) + " " + // x1 - hpf(parseFloat(pattern.coords[1])) + + hpf(parseFloat(String(pattern.coords[1]))) + " "; // y1 if (pattern.type === 2) { // axial coords += - hpf(parseFloat(pattern.coords[2])) + + hpf(parseFloat(String(pattern.coords[2]))) + " " + // x2 - hpf(parseFloat(pattern.coords[3])); // y2 + hpf(parseFloat(String(pattern.coords[3]))); // y2 } else { // radial coords += - hpf(parseFloat(pattern.coords[2])) + + hpf(parseFloat(String(pattern.coords[2]))) + " " + // r1 - hpf(parseFloat(pattern.coords[3])) + + hpf(parseFloat(String(pattern.coords[3]))) + " " + // x2 - hpf(parseFloat(pattern.coords[4])) + + hpf(parseFloat(String(pattern.coords[4]))) + " " + // y2 - hpf(parseFloat(pattern.coords[5])); // r2 + hpf(parseFloat(String(pattern.coords[5]))); // r2 } coords += "]"; out(coords); @@ -2199,7 +2399,15 @@ function jsPDF(options) { out("endobj"); }; - var putTilingPattern = function(pattern, deferredResourceDictionaryIds) { + interface DeferredResourceDictionaryIds { + resourcesOid: number; + objectOid: number; + } + + var putTilingPattern = function ( + pattern: TilingPattern, + deferredResourceDictionaryIds: DeferredResourceDictionaryIds[] + ) { var resourcesObjectId = newObjectDeferred(); var patternObjectId = newObject(); @@ -2209,7 +2417,7 @@ function jsPDF(options) { }); pattern.objectNumber = patternObjectId; - var options = []; + var options: Array<{ key: string; value: string | number }> = []; options.push({ key: "Type", value: "/Pattern" }); options.push({ key: "PatternType", value: "1" }); // tiling pattern options.push({ key: "PaintType", value: "1" }); // colored tiling pattern @@ -2236,20 +2444,25 @@ function jsPDF(options) { out("endobj"); }; - var putPatterns = function(deferredResourceDictionaryIds) { + var putPatterns = function ( + deferredResourceDictionaryIds: DeferredResourceDictionaryIds[] + ) { var patternKey; for (patternKey in patterns) { if (patterns.hasOwnProperty(patternKey)) { if (patterns[patternKey] instanceof ShadingPattern) { - putShadingPattern(patterns[patternKey]); + putShadingPattern(patterns[patternKey] as ShadingPattern); } else if (patterns[patternKey] instanceof TilingPattern) { - putTilingPattern(patterns[patternKey], deferredResourceDictionaryIds); + putTilingPattern( + patterns[patternKey] as TilingPattern, + deferredResourceDictionaryIds + ); } } } }; - var putGState = function(gState) { + var putGState = function (gState: GState) { gState.objectNumber = newObject(); out("<<"); for (var p in gState) { @@ -2258,7 +2471,7 @@ function jsPDF(options) { out("/ca " + f2(gState[p])); break; case "stroke-opacity": - out("/CA " + f2(gState[p])); + out("/CA " + f2(gState["stroke-opacity"])); break; } } @@ -2266,7 +2479,7 @@ function jsPDF(options) { out("endobj"); }; - var putGStates = function() { + var putGStates = function () { var gStateKey; for (gStateKey in gStates) { if (gStates.hasOwnProperty(gStateKey)) { @@ -2275,7 +2488,7 @@ function jsPDF(options) { } }; - var putXobjectDict = function() { + var putXobjectDict = function () { out("/XObject <<"); for (var xObjectKey in renderTargets) { if ( @@ -2297,7 +2510,7 @@ function jsPDF(options) { out(">>"); }; - var putEncryptionDict = function() { + var putEncryptionDict = function () { encryption.oid = newObject(); out("<<"); out("/Filter /Standard"); @@ -2310,7 +2523,7 @@ function jsPDF(options) { out("endobj"); }; - var putFontDict = function() { + var putFontDict = function () { out("/Font <<"); for (var fontKey in fonts) { @@ -2326,7 +2539,7 @@ function jsPDF(options) { out(">>"); }; - var putShadingPatternDict = function() { + var putShadingPatternDict = function () { if (Object.keys(patterns).length > 0) { out("/Shading <<"); for (var patternKey in patterns) { @@ -2346,7 +2559,7 @@ function jsPDF(options) { } }; - var putTilingPatternDict = function(objectOid) { + var putTilingPatternDict = function (objectOid: number) { if (Object.keys(patterns).length > 0) { out("/Pattern <<"); for (var patternKey in patterns) { @@ -2366,7 +2579,7 @@ function jsPDF(options) { } }; - var putGStatesDict = function() { + var putGStatesDict = function () { if (Object.keys(gStates).length > 0) { var gStateKey; out("/ExtGState <<"); @@ -2384,7 +2597,9 @@ function jsPDF(options) { } }; - var putResourceDictionary = function(objectIds) { + var putResourceDictionary = function ( + objectIds: DeferredResourceDictionaryIds + ) { newObjectDeferredBegin(objectIds.resourcesOid, true); out("<<"); out("/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]"); @@ -2397,7 +2612,7 @@ function jsPDF(options) { out("endobj"); }; - var putResources = function() { + var putResources = function () { // FormObjects, Patterns etc. might use other FormObjects/Patterns/Images // which means their resource dictionaries must contain the already resolved // object ids. For this reason we defer the serialization of the resource @@ -2410,7 +2625,7 @@ function jsPDF(options) { // earlier in their respective collection. // Currently, this only affects tiling patterns, but a (more) correct // implementation of FormObjects would also define their own resource dicts. - var deferredResourceDictionaryIds = []; + var deferredResourceDictionaryIds: DeferredResourceDictionaryIds[] = []; putFonts(); putGStates(); @@ -2426,7 +2641,7 @@ function jsPDF(options) { events.publish("postPutResources"); }; - var putAdditionalObjects = function() { + var putAdditionalObjects = function () { events.publish("putAdditionalObjects"); for (var i = 0; i < additionalObjects.length; i++) { var obj = additionalObjects[i]; @@ -2437,19 +2652,24 @@ function jsPDF(options) { events.publish("postPutAdditionalObjects"); }; - var addFontToFontDictionary = function(font) { + var addFontToFontDictionary = function (font: { + id: string; + fontName: string; + fontStyle: string; + }) { fontmap[font.fontName] = fontmap[font.fontName] || {}; fontmap[font.fontName][font.fontStyle] = font.id; }; - var addFont = function( - postScriptName, - fontName, - fontStyle, - encoding, - isStandardFont? - ) { - var font = { + var addFont = function ( + this: jsPDFDocument, + postScriptName: string, + fontName: string, + fontStyle: string, + encoding: string, + isStandardFont?: boolean + ): string { + var font: Font = { id: "F" + (Object.keys(fonts).length + 1).toString(10), postScriptName: postScriptName, fontName: fontName, @@ -2469,7 +2689,10 @@ function jsPDF(options) { return font.id; }; - var addFonts = function(arrayOfFonts) { + var addFonts = function ( + this: jsPDFDocument, + arrayOfFonts: Array<[string, string, string, string | null]> + ) { for (var i = 0, l = standardFonts.length; i < l; i++) { var fontKey = addFont.call( this, @@ -2497,18 +2720,28 @@ function jsPDF(options) { }); }; - var SAFE = function __safeCall(fn) { - fn.foo = function __safeCallWrapper() { + // Wraps a function so that runtime errors are reported instead of thrown + // (browser only). The wrapper is attached to the function itself, so the + // generic parameter/return relationship is intentionally loose. + type SafeWrappable = ((...args: never[]) => unknown) & { + foo?: ((...args: unknown[]) => unknown) & { bar?: unknown }; + }; + var SAFE = function __safeCall(fn: F): F { + fn.foo = function __safeCallWrapper(this: unknown) { try { - return fn.apply(this, arguments); + return (fn as unknown as (...args: unknown[]) => unknown).apply( + this, + // eslint-disable-next-line prefer-rest-params + Array.prototype.slice.call(arguments) + ); } catch (e) { - var stack = (e as any).stack || ""; + var stack = (e as Error).stack || ""; if (~stack.indexOf(" at ")) stack = stack.split(" at ")[1]; var m = "Error in function " + stack.split("\n")[0].split("<")[0] + ": " + - (e as any).message; + (e as Error).message; if (globalObject.console) { globalObject.console.error(m, e); if (globalObject.alert) alert(m); @@ -2518,10 +2751,27 @@ function jsPDF(options) { } }; fn.foo.bar = fn; - return fn.foo; + // The wrapper preserves the wrapped function's call behavior; the + // assertion restores its precise signature for callers. + return fn.foo as unknown as F; }; - var to8bitStream = function(text, flags) { + interface FontEncodingBlock { + codePages?: string[]; + [codePage: string]: Record | string[] | undefined; + } + + interface To8BitStreamFlags { + sourceEncoding?: string; + outputEncoding?: string | Record; + noBOM?: boolean; + autoencode?: boolean; + } + + var to8bitStream = function ( + text: string, + flags?: To8BitStreamFlags + ): string { /** * PDF 1.3 spec: * "For text strings encoded in Unicode, the first two bytes must be 254 followed by @@ -2572,13 +2822,13 @@ function jsPDF(options) { var i, l, - sourceEncoding, - encodingBlock, - outputEncoding, - newtext, - isUnicode, - ch, - bch; + sourceEncoding: string, + encodingBlock: FontEncodingBlock, + outputEncoding: string | Record, + newtext: Array, + isUnicode: boolean | undefined, + ch: number, + bch: number; flags = flags || {}; sourceEncoding = flags.sourceEncoding || "Unicode"; @@ -2593,13 +2843,19 @@ function jsPDF(options) { // .encoding = {'codePages':['WinANSI....'], 'WinANSI...':{code:code, ...}} // .widths = {0:width, code:width, ..., 'fof':divisor} // .kerning = {code:{previous_char_code:shift, ..., 'fof':-divisor},...} + // The metric tables are attached to font.metadata by the font plugins + // (see the comment above); their per-encoding shape is only known here. + var activeFontMetadata = fonts[activeFontKey].metadata as Record< + string, + { encoding?: FontEncodingBlock } | undefined + >; if ( (flags.autoencode || outputEncoding) && - fonts[activeFontKey].metadata && - fonts[activeFontKey].metadata[sourceEncoding] && - fonts[activeFontKey].metadata[sourceEncoding].encoding + activeFontMetadata && + activeFontMetadata[sourceEncoding] && + activeFontMetadata[sourceEncoding].encoding ) { - encodingBlock = fonts[activeFontKey].metadata[sourceEncoding].encoding; + encodingBlock = activeFontMetadata[sourceEncoding].encoding; // each font has default encoding. Some have it clearly defined. if (!outputEncoding && fonts[activeFontKey].encoding) { @@ -2612,7 +2868,10 @@ function jsPDF(options) { } if (typeof outputEncoding === "string") { - outputEncoding = encodingBlock[outputEncoding]; + outputEncoding = encodingBlock[outputEncoding] as Record< + number, + number + >; } // we want output encoding to be a JS Object, where // key = sourceEncoding's character code and @@ -2621,7 +2880,7 @@ function jsPDF(options) { isUnicode = false; newtext = []; for (i = 0, l = text.length; i < l; i++) { - ch = outputEncoding[text.charCodeAt(i)]; + ch = (outputEncoding as Record)[text.charCodeAt(i)]; if (ch) { newtext.push(String.fromCharCode(ch)); } else { @@ -2630,7 +2889,7 @@ function jsPDF(options) { // since we are looping over chars anyway, might as well // check for residual unicodeness - if (newtext[i].charCodeAt(0) >> 8) { + if ((newtext[i] as string).charCodeAt(0) >> 8) { /* more than 255 */ isUnicode = true; } @@ -2669,33 +2928,35 @@ function jsPDF(options) { newtext.push(bch); newtext.push(ch - (bch << 8)); } - return String.fromCharCode.apply(undefined, newtext); - }; + return String.fromCharCode.apply(undefined, newtext as number[]); + }; + + var pdfEscape = + (API.__private__.pdfEscape = + API.pdfEscape = + function (text: string, flags?: To8BitStreamFlags): string { + /** + * Replace '/', '(', and ')' with pdf-safe versions + * + * Doing to8bitStream does NOT make this PDF display unicode text. For that + * we also need to reference a unicode font and embed it - royal pain in the rear. + * + * There is still a benefit to to8bitStream - PDF simply cannot handle 16bit chars, + * which JavaScript Strings are happy to provide. So, while we still cannot display + * 2-byte characters property, at least CONDITIONALLY converting (entire string containing) + * 16bit chars to (USC-2-BE) 2-bytes per char + BOM streams we ensure that entire PDF + * is still parseable. + * This will allow immediate support for unicode in document properties strings. + */ + return to8bitStream(text, flags) + .replace(/\\/g, "\\\\") + .replace(/\(/g, "\\(") + .replace(/\)/g, "\\)"); + }); - var pdfEscape = (API.__private__.pdfEscape = API.pdfEscape = function( - text, - flags? + var beginPage = (API.__private__.beginPage = function ( + format: Array ) { - /** - * Replace '/', '(', and ')' with pdf-safe versions - * - * Doing to8bitStream does NOT make this PDF display unicode text. For that - * we also need to reference a unicode font and embed it - royal pain in the rear. - * - * There is still a benefit to to8bitStream - PDF simply cannot handle 16bit chars, - * which JavaScript Strings are happy to provide. So, while we still cannot display - * 2-byte characters property, at least CONDITIONALLY converting (entire string containing) - * 16bit chars to (USC-2-BE) 2-bytes per char + BOM streams we ensure that entire PDF - * is still parseable. - * This will allow immediate support for unicode in document properties strings. - */ - return to8bitStream(text, flags) - .replace(/\\/g, "\\\\") - .replace(/\(/g, "\\(") - .replace(/\)/g, "\\)"); - }); - - var beginPage = (API.__private__.beginPage = function(format) { pages[++page] = []; pagesContext[page] = { objId: 0, @@ -2716,8 +2977,8 @@ function jsPDF(options) { setOutputDestination(pages[currentPage]); }); - var _addPage = function(parmFormat, parmOrientation) { - var dimensions, width, height; + var _addPage = function (parmFormat?: PageFormat, parmOrientation?: string) { + var dimensions, width: number, height: number; orientation = parmOrientation || orientation; @@ -2735,8 +2996,8 @@ function jsPDF(options) { } if (isNaN(width)) { - width = format[0]; - height = format[1]; + width = format[0] as number; + height = format[1] as number; } if (width > 14400 || height > 14400) { @@ -2780,7 +3041,7 @@ function jsPDF(options) { }); }; - var _deletePage = function(n) { + var _deletePage = function (this: jsPDFDocument, n: number) { if (n > 0 && n <= page) { pages.splice(n, 1); pagesContext.splice(n, 1); @@ -2792,15 +3053,18 @@ function jsPDF(options) { } }; - var _setPage = function(n) { + var _setPage = function (n: number) { if (n > 0 && n <= page) { currentPage = n; } }; - var getNumberOfPages = (API.__private__.getNumberOfPages = API.getNumberOfPages = function() { - return pages.length - 1; - }); + var getNumberOfPages = + (API.__private__.getNumberOfPages = + API.getNumberOfPages = + function () { + return pages.length - 1; + }); /** * Returns a document-specific font key - a label assigned to a @@ -2816,8 +3080,12 @@ function jsPDF(options) { * @returns {string} Font key. * @ignore */ - var getFont = function(fontName, fontStyle, options) { - var key = undefined, + var getFont = function ( + fontName?: string, + fontStyle?: string, + options?: { disableWarning?: boolean; noFallback?: boolean } + ): string { + var key: string = undefined, fontNameLowerCase; options = options || {}; @@ -2858,9 +3126,9 @@ function jsPDF(options) { return key; }; - var putInfo = (API.__private__.putInfo = function() { + var putInfo = (API.__private__.putInfo = function () { var objectId = newObject(); - var encryptor: any = function(data) { + var encryptor: Encryptor = function (data) { return data; }; if (encryptionOptions !== null) { @@ -2885,7 +3153,9 @@ function jsPDF(options) { out("endobj"); }); - var putCatalog = (API.__private__.putCatalog = function(options?) { + var putCatalog = (API.__private__.putCatalog = function (options?: { + rootDictionaryObjId?: number; + }) { options = options || {}; var tmpRootDictionaryObjId = options.rootDictionaryObjId || rootDictionaryObjId; @@ -2911,7 +3181,7 @@ function jsPDF(options) { default: var pcn = "" + zoomMode; if (pcn.substr(pcn.length - 1) === "%") - zoomMode = parseInt(zoomMode) / 100; + zoomMode = parseInt(zoomMode as string) / 100; if (typeof zoomMode === "number") { out("/OpenAction [3 0 R /XYZ null null " + f2(zoomMode) + "]"); } @@ -2947,7 +3217,7 @@ function jsPDF(options) { out("endobj"); }); - var putTrailer = (API.__private__.putTrailer = function() { + var putTrailer = (API.__private__.putTrailer = function () { out("trailer"); out("<<"); out("/Size " + (objectNumber + 1)); @@ -2961,12 +3231,12 @@ function jsPDF(options) { out(">>"); }); - var putHeader = (API.__private__.putHeader = function() { + var putHeader = (API.__private__.putHeader = function () { out("%PDF-" + pdfVersion); out("%\xBA\xDF\xAC\xE0"); }); - var putXRef = (API.__private__.putXRef = function() { + var putXRef = (API.__private__.putXRef = function () { var p = "0000000000"; out("xref"); @@ -2975,7 +3245,7 @@ function jsPDF(options) { for (var i = 1; i <= objectNumber; i++) { var offset = offsets[i]; if (typeof offset === "function") { - out((p + offsets[i]()).slice(-10) + " 00000 n "); + out((p + (offsets[i] as () => number)()).slice(-10) + " 00000 n "); } else { if (typeof offsets[i] !== "undefined") { out((p + offsets[i]).slice(-10) + " 00000 n "); @@ -2986,7 +3256,7 @@ function jsPDF(options) { } }); - var buildDocument = (API.__private__.buildDocument = function() { + var buildDocument = (API.__private__.buildDocument = function () { resetDocument(); setOutputDestination(content); @@ -3012,19 +3282,19 @@ function jsPDF(options) { return content.join("\n"); }); - var getBlob = (API.__private__.getBlob = function(data) { + var getBlob = (API.__private__.getBlob = function (data: string): Blob { return new Blob([getArrayBuffer(data)], { type: "application/pdf" }); }); - var clearDomNode = function(node) { + var clearDomNode = function (node: Node) { while (node.firstChild) { node.removeChild(node.firstChild); } }; - var initializeNewWindow = function(window) { + var initializeNewWindow = function (window: Window) { var targetDocument = window.document; var html = targetDocument.documentElement; var head = targetDocument.head; @@ -3083,188 +3353,206 @@ function jsPDF(options) { * @memberof jsPDF# * @name output */ - var output = (API.output = API.__private__.output = SAFE(function output( - type, - options - ) { - options = options || {}; - - if (typeof options === "string") { - options = { - filename: options - }; - } else { - options.filename = options.filename || "generated.pdf"; - } - - switch (type) { - case undefined: - return buildDocument(); - case "save": - API.save(options.filename); - break; - case "arraybuffer": - return getArrayBuffer(buildDocument()); - case "blob": - return getBlob(buildDocument()); - case "bloburi": - case "bloburl": - // Developer is responsible of calling revokeObjectURL - if ( - typeof globalObject.URL !== "undefined" && - typeof globalObject.URL.createObjectURL === "function" - ) { - return ( - (globalObject.URL && - globalObject.URL.createObjectURL(getBlob(buildDocument()))) || - void 0 - ); - } else { - console.warn( - "bloburl is not supported by your system, because URL.createObjectURL is not supported by your browser." - ); - } - break; - case "datauristring": - case "dataurlstring": - var dataURI = ""; - var pdfDocument = buildDocument(); - try { - dataURI = btoa(pdfDocument); - } catch (e) { - dataURI = btoa(unescape(encodeURIComponent(pdfDocument))); - } - return ( - "data:application/pdf;filename=" + - encodeURIComponent(options.filename) + - ";base64," + - dataURI - ); - case "pdfobjectnewwindow": - if ( - Object.prototype.toString.call(globalObject) === "[object Window]" - ) { - var pdfObjectUrl = - "https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.1.1/pdfobject.min.js"; - var useDefaultPdfObjectUrl = !options.pdfObjectUrl; - - if (!useDefaultPdfObjectUrl) { - pdfObjectUrl = options.pdfObjectUrl; - } - - var nW = globalObject.open(); - - if (nW !== null) { - var initializedPdfObjectWindow = initializeNewWindow(nW); - var pdfObjectScript = initializedPdfObjectWindow.document.createElement( - "script" - ); - var scope = this; - - pdfObjectScript.src = pdfObjectUrl; - - if (useDefaultPdfObjectUrl) { - pdfObjectScript.integrity = - "sha512-4ze/a9/4jqu+tX9dfOqJYSvyYd5M6qum/3HpCLr+/Jqf0whc37VUbkpNGHR7/8pSnCFw47T1fmIpwBV7UySh3g=="; - pdfObjectScript.crossOrigin = "anonymous"; - } - - pdfObjectScript.onload = function() { - nW.PDFObject.embed(scope.output("dataurlstring"), options); - }; + // The output implementation accepts every OutputType and returns the + // corresponding union; the double assertion maps it onto the per-type + // overloads declared on jsPDFDocument. + var output = + (API.output = + API.__private__.output = + SAFE(function output( + this: jsPDFDocument, + type?: OutputType, + options?: OutputOptions | string + ) { + options = options || {}; - initializedPdfObjectWindow.body.appendChild(pdfObjectScript); - } - return nW; + if (typeof options === "string") { + options = { + filename: options + }; } else { - throw new Error( - "The option pdfobjectnewwindow just works in a browser-environment." - ); + options.filename = options.filename || "generated.pdf"; } - case "pdfjsnewwindow": - if ( - Object.prototype.toString.call(globalObject) === "[object Window]" - ) { - var pdfJsUrl = options.pdfJsUrl || "examples/PDF.js/web/viewer.html"; - var PDFjsNewWindow = globalObject.open(); - if (PDFjsNewWindow !== null) { - var initializedPdfJsWindow = initializeNewWindow(PDFjsNewWindow); - var pdfViewer = initializedPdfJsWindow.document.createElement( - "iframe" - ); - var pdfJsQueryChar = pdfJsUrl.indexOf("?") === -1 ? "?" : "&"; - var scope = this; - - pdfViewer.id = "pdfViewer"; - pdfViewer.width = "500px"; - pdfViewer.height = "400px"; - pdfViewer.src = - pdfJsUrl + - pdfJsQueryChar + - "file=&downloadName=" + - encodeURIComponent(options.filename); - - pdfViewer.onload = function() { - PDFjsNewWindow.document.title = options.filename; - pdfViewer.contentWindow.PDFViewerApplication.open( - scope.output("bloburl") + switch (type) { + case undefined: + return buildDocument(); + case "save": + API.save(options.filename); + break; + case "arraybuffer": + return getArrayBuffer(buildDocument()); + case "blob": + return getBlob(buildDocument()); + case "bloburi": + case "bloburl": + // Developer is responsible of calling revokeObjectURL + if ( + typeof globalObject.URL !== "undefined" && + typeof globalObject.URL.createObjectURL === "function" + ) { + return ( + (globalObject.URL && + globalObject.URL.createObjectURL(getBlob(buildDocument()))) || + void 0 ); - }; - - initializedPdfJsWindow.body.appendChild(pdfViewer); - } - return PDFjsNewWindow; - } else { - throw new Error( - "The option pdfjsnewwindow just works in a browser-environment." - ); - } - case "dataurlnewwindow": - if ( - Object.prototype.toString.call(globalObject) === "[object Window]" - ) { - var dataURLNewWindow = globalObject.open(); - if (dataURLNewWindow !== null) { - var initializedDataUrlWindow = initializeNewWindow( - dataURLNewWindow - ); - var dataUrlFrame = initializedDataUrlWindow.document.createElement( - "iframe" + } else { + console.warn( + "bloburl is not supported by your system, because URL.createObjectURL is not supported by your browser." + ); + } + break; + case "datauristring": + case "dataurlstring": + var dataURI = ""; + var pdfDocument = buildDocument(); + try { + dataURI = btoa(pdfDocument); + } catch (e) { + dataURI = btoa(unescape(encodeURIComponent(pdfDocument))); + } + return ( + "data:application/pdf;filename=" + + encodeURIComponent(options.filename) + + ";base64," + + dataURI ); - - dataUrlFrame.src = this.output("datauristring", options); - initializedDataUrlWindow.body.appendChild(dataUrlFrame); - dataURLNewWindow.document.title = options.filename; - } - if ( - dataURLNewWindow || - typeof (globalObject as any).safari === "undefined" - ) - return dataURLNewWindow; - } else { - throw new Error( - "The option dataurlnewwindow just works in a browser-environment." - ); + case "pdfobjectnewwindow": + if ( + Object.prototype.toString.call(globalObject) === "[object Window]" + ) { + var pdfObjectUrl = + "https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.1.1/pdfobject.min.js"; + var useDefaultPdfObjectUrl = !options.pdfObjectUrl; + + if (!useDefaultPdfObjectUrl) { + pdfObjectUrl = options.pdfObjectUrl; + } + + var nW = globalObject.open(); + + if (nW !== null) { + var initializedPdfObjectWindow = initializeNewWindow(nW); + var pdfObjectScript = + initializedPdfObjectWindow.document.createElement("script"); + var scope = this; + + pdfObjectScript.src = pdfObjectUrl; + + if (useDefaultPdfObjectUrl) { + pdfObjectScript.integrity = + "sha512-4ze/a9/4jqu+tX9dfOqJYSvyYd5M6qum/3HpCLr+/Jqf0whc37VUbkpNGHR7/8pSnCFw47T1fmIpwBV7UySh3g=="; + pdfObjectScript.crossOrigin = "anonymous"; + } + + pdfObjectScript.onload = function () { + // PDFObject is provided by the script injected right above. + ( + nW as Window & { + PDFObject: { + embed(url: string, options?: unknown): unknown; + }; + } + ).PDFObject.embed(scope.output("dataurlstring"), options); + }; + + initializedPdfObjectWindow.body.appendChild(pdfObjectScript); + } + return nW; + } else { + throw new Error( + "The option pdfobjectnewwindow just works in a browser-environment." + ); + } + case "pdfjsnewwindow": + if ( + Object.prototype.toString.call(globalObject) === "[object Window]" + ) { + var pdfJsUrl = + options.pdfJsUrl || "examples/PDF.js/web/viewer.html"; + var PDFjsNewWindow = globalObject.open(); + + if (PDFjsNewWindow !== null) { + var initializedPdfJsWindow = + initializeNewWindow(PDFjsNewWindow); + var pdfViewer = + initializedPdfJsWindow.document.createElement("iframe"); + var pdfJsQueryChar = pdfJsUrl.indexOf("?") === -1 ? "?" : "&"; + var scope = this; + + pdfViewer.id = "pdfViewer"; + pdfViewer.width = "500px"; + pdfViewer.height = "400px"; + pdfViewer.src = + pdfJsUrl + + pdfJsQueryChar + + "file=&downloadName=" + + encodeURIComponent(options.filename); + + pdfViewer.onload = function () { + PDFjsNewWindow.document.title = ( + options as OutputOptions + ).filename; + // PDFViewerApplication is provided by the embedded PDF.js viewer. + ( + pdfViewer.contentWindow as Window & { + PDFViewerApplication: { open(url: unknown): unknown }; + } + ).PDFViewerApplication.open(scope.output("bloburl")); + }; + + initializedPdfJsWindow.body.appendChild(pdfViewer); + } + return PDFjsNewWindow; + } else { + throw new Error( + "The option pdfjsnewwindow just works in a browser-environment." + ); + } + case "dataurlnewwindow": + if ( + Object.prototype.toString.call(globalObject) === "[object Window]" + ) { + var dataURLNewWindow = globalObject.open(); + if (dataURLNewWindow !== null) { + var initializedDataUrlWindow = + initializeNewWindow(dataURLNewWindow); + var dataUrlFrame = + initializedDataUrlWindow.document.createElement("iframe"); + + dataUrlFrame.src = this.output("datauristring", options); + initializedDataUrlWindow.body.appendChild(dataUrlFrame); + dataURLNewWindow.document.title = options.filename; + } + if ( + dataURLNewWindow || + typeof (globalObject as { safari?: unknown }).safari === + "undefined" + ) + return dataURLNewWindow; + } else { + throw new Error( + "The option dataurlnewwindow just works in a browser-environment." + ); + } + break; + case "datauri": + case "dataurl": + return (globalObject.document.location.href = this.output( + "datauristring", + options + )); + default: + return null; } - break; - case "datauri": - case "dataurl": - return (globalObject.document.location.href = this.output( - "datauristring", - options - )); - default: - return null; - } - })); + }) as unknown as jsPDFDocument["output"]); /** * Used to see if a supplied hotfix was requested when the pdf instance was created. * @param {string} hotfixName - The name of the hotfix to check. * @returns {boolean} */ - var hasHotfix = function(hotfixName) { + var hasHotfix = function (hotfixName: string): boolean { return ( Array.isArray(hotfixes) === true && hotfixes.indexOf(hotfixName) > -1 ); @@ -3307,15 +3595,15 @@ function jsPDF(options) { } } - var encryption = null; + var encryption: PDFSecurityInterface | null = null; setCreationDate(); setFileId(); - var getEncryptor = function(objectId) { + var getEncryptor = function (objectId: number): Encryptor { if (encryptionOptions !== null) { return encryption.encryptor(objectId, 0); } - return function(data) { + return function (data) { return data; }; }; @@ -3323,23 +3611,24 @@ function jsPDF(options) { //--------------------------------------- // Public API - var getPageInfo = (API.__private__.getPageInfo = API.getPageInfo = function( - pageNumberOneBased - ) { - if (isNaN(pageNumberOneBased) || pageNumberOneBased % 1 !== 0) { - throw new Error("Invalid argument passed to jsPDF.getPageInfo"); - } - var objId = pagesContext[pageNumberOneBased].objId; - return { - objId: objId, - pageNumber: pageNumberOneBased, - pageContext: pagesContext[pageNumberOneBased] - }; - }); + var getPageInfo = + (API.__private__.getPageInfo = + API.getPageInfo = + function (pageNumberOneBased: number): PageInfo { + if (isNaN(pageNumberOneBased) || pageNumberOneBased % 1 !== 0) { + throw new Error("Invalid argument passed to jsPDF.getPageInfo"); + } + var objId = pagesContext[pageNumberOneBased].objId; + return { + objId: objId, + pageNumber: pageNumberOneBased, + pageContext: pagesContext[pageNumberOneBased] + }; + }); - var getPageInfoByObjId = (API.__private__.getPageInfoByObjId = function( - objId - ) { + var getPageInfoByObjId = (API.__private__.getPageInfoByObjId = function ( + objId: number + ): PageInfo { if (isNaN(objId) || objId % 1 !== 0) { throw new Error("Invalid argument passed to jsPDF.getPageInfoByObjId"); } @@ -3348,16 +3637,21 @@ function jsPDF(options) { break; } } - return getPageInfo(pageNumber); + // for-in keys are strings; getPageInfo coerces via arithmetic checks, + // matching the original loose behavior. + return getPageInfo(pageNumber as unknown as number); }); - var getCurrentPageInfo = (API.__private__.getCurrentPageInfo = API.getCurrentPageInfo = function() { - return { - objId: pagesContext[currentPage].objId, - pageNumber: currentPage, - pageContext: pagesContext[currentPage] - }; - }); + var getCurrentPageInfo = + (API.__private__.getCurrentPageInfo = + API.getCurrentPageInfo = + function (): PageInfo { + return { + objId: pagesContext[currentPage].objId, + pageNumber: currentPage, + pageContext: pagesContext[currentPage] + }; + }); /** * Adds (and transfers the focus to) new page to the PDF document. @@ -3371,8 +3665,12 @@ function jsPDF(options) { * @memberof jsPDF# * @name addPage */ - API.addPage = function() { - _addPage.apply(this, arguments as any); + API.addPage = function (this: jsPDFDocument) { + _addPage.apply( + this, + // eslint-disable-next-line prefer-rest-params + Array.prototype.slice.call(arguments) as [PageFormat?, string?] + ); return this; }; /** @@ -3392,8 +3690,12 @@ function jsPDF(options) { * doc.setPage(1) * doc.text('I am on page 1', 10, 10) */ - API.setPage = function() { - _setPage.apply(this, arguments as any); + API.setPage = function (this: jsPDFDocument) { + _setPage.apply( + this, + // eslint-disable-next-line prefer-rest-params + Array.prototype.slice.call(arguments) as [number] + ); setOutputDestination.call(this, pages[currentPage]); return this; }; @@ -3407,7 +3709,7 @@ function jsPDF(options) { * @param {Object} beforePage * @returns {jsPDF} */ - API.insertPage = function(beforePage) { + API.insertPage = function (this: jsPDFDocument, beforePage) { this.addPage(); this.movePage(currentPage, beforePage); return this; @@ -3422,7 +3724,7 @@ function jsPDF(options) { * @param {number} beforePage * @returns {jsPDF} */ - API.movePage = function(targetPage, beforePage) { + API.movePage = function (this: jsPDFDocument, targetPage, beforePage) { var tmpPages, tmpPagesContext; if (targetPage > beforePage) { tmpPages = pages[targetPage]; @@ -3457,8 +3759,12 @@ function jsPDF(options) { * @instance * @returns {jsPDF} */ - API.deletePage = function() { - _deletePage.apply(this, arguments as any); + API.deletePage = function (this: jsPDFDocument) { + _deletePage.apply( + this, + // eslint-disable-next-line prefer-rest-params + Array.prototype.slice.call(arguments) as [number] + ); return this; }; @@ -3498,7 +3804,48 @@ function jsPDF(options) { * @memberof jsPDF# * @name text */ - API.__private__.text = API.text = function(text, x, y, options, transform) { + /** One entry of the text argument once the legacy reshaping is done. */ + type TextItem = string | number | Array; + + /** + * The public text options plus the undocumented legacy members the + * implementation still honors. + */ + type TextOptionsInternal = TextOptionsLight & { + scope?: jsPDFDocument; + TabLen?: number; + R2L?: boolean; + lang?: string; + stroke?: boolean | number | string; + }; + + interface TextMutex { + pdfEscape: typeof pdfEscape; + activeFontKey: string; + fonts: FontMap; + activeFontSize: number; + isHex?: boolean; + } + + interface TextPayload { + text: string | number | TextItem[]; + x: number; + y: number; + options: TextOptionsInternal; + mutex: TextMutex; + } + + // The trailing cast reconciles the single implementation signature with the + // overloads declared in types.ts (including the deprecated pre-2012 + // `text(x, y, text, ...)` argument order handled by the swap shim below). + API.__private__.text = API.text = function ( + this: jsPDFDocument, + text: string | number | TextItem[], + x: number, + y: number, + options?: TextOptionsInternal, + transform?: number | Matrix + ) { /* * Inserts something like this into PDF * BT @@ -3513,7 +3860,14 @@ function jsPDF(options) { */ options = options || {}; var scope = options.scope || this; - var payload, da, angle, align, charSpace, maxWidth, flags, horizontalScale; + var payload: TextPayload, + da: Array>, + angle: number | MatrixType | string, + align: string, + charSpace: number, + maxWidth: number, + flags: To8BitStreamFlags, + horizontalScale: number; // Pre-August-2012 the order of arguments was function(x, y, text, flags) // in effort to make all calls have similar signature like @@ -3523,15 +3877,16 @@ function jsPDF(options) { if ( typeof text === "number" && typeof x === "number" && - (typeof y === "string" || Array.isArray(y)) + ((typeof y as string) === "string" || Array.isArray(y)) ) { - var tmp = y; + // Legacy argument order: the string/array content arrived in `y`. + var tmp = y as unknown as string | TextItem[]; y = x; x = text; text = tmp; } - var transformationMatrix; + var transformationMatrix: MatrixType; if (arguments[3] instanceof Matrix === false) { flags = arguments[3]; @@ -3552,23 +3907,23 @@ function jsPDF(options) { flags = null; } options = { - flags: flags, - angle: angle, - align: align + flags: flags as { noBOM: boolean; autoencode: boolean }, + angle: angle as number, + align: align as TextOptionsLight["align"] }; } } else { advancedApiModeTrap( "The transform parameter of text() with a Matrix value" ); - transformationMatrix = transform; + transformationMatrix = transform as MatrixType; } if (isNaN(x) || isNaN(y) || typeof text === "undefined" || text === null) { throw new Error("Invalid arguments passed to jsPDF.text"); } - if (text.length === 0) { + if ((text as string | TextItem[]).length === 0) { return scope; } @@ -3580,21 +3935,25 @@ function jsPDF(options) { : lineHeightFactor; var scaleFactor = scope.internal.scaleFactor; - function ESC(s) { + function ESC(s: string): string { s = s.split("\t").join(Array(options.TabLen || 9).join(" ")); return pdfEscape(s, flags); } - function transformTextToSpecialArray(text) { + function transformTextToSpecialArray( + text: TextItem[] + ): Array> { //we don't want to destroy original text array, so cloning it var sa = text.concat(); - var da = []; + var da: Array> = []; var len = sa.length; var curDa; //we do array.join('text that must not be PDFescaped") //thus, pdfEscape each component separately while (len--) { - curDa = sa.shift(); + // Numeric char codes never appear at this stage; entries are either + // strings or [text, x, y] arrays. + curDa = sa.shift() as string | Array; if (typeof curDa === "string") { da.push(curDa); } else { @@ -3603,7 +3962,7 @@ function jsPDF(options) { (curDa.length === 1 || (curDa[1] === undefined && curDa[2] === undefined)) ) { - da.push(curDa[0]); + da.push(curDa[0] as string); } else { da.push([curDa[0], curDa[1], curDa[2]]); } @@ -3612,14 +3971,21 @@ function jsPDF(options) { return da; } - function processTextByFunction(text, processingFunction) { + function processTextByFunction( + text: string | number | TextItem[], + processingFunction: ( + text: string, + posX?: string | number, + posY?: string | number + ) => Array + ): string | number | TextItem[] { var result; if (typeof text === "string") { result = processingFunction(text)[0]; } else if (Array.isArray(text)) { //we don't want to destroy original text array, so cloning it var sa = text.concat(); - var da = []; + var da: TextItem[] = []; var len = sa.length; var curDa; var tmpResult; @@ -3647,7 +4013,7 @@ function jsPDF(options) { textIsOfTypeString = true; } else if (Array.isArray(text)) { //we don't want to destroy original text array, so cloning it - var sa = text.concat(); + var sa: TextItem[] = text.concat(); da = []; var len = sa.length; var curDa; @@ -3718,7 +4084,10 @@ function jsPDF(options) { if (typeof text === "string") { text = scope.splitTextToSize(text, maxWidth); } else if (Object.prototype.toString.call(text) === "[object Array]") { - text = text.reduce(function(acc, textLine) { + text = (text as string[]).reduce(function ( + acc: string[], + textLine + ): string[] { return acc.concat(scope.splitTextToSize(textLine, maxWidth)); }, []); } @@ -3865,11 +4234,11 @@ function jsPDF(options) { charSpace = options.charSpace || activeCharSpace; maxWidth = options.maxWidth || 0; - var lineWidths; + var lineWidths: number[]; flags = Object.assign({ autoencode: true, noBOM: true }, options.flags); - var wordSpacingPerLine = []; - var findWidth = function(v) { + var wordSpacingPerLine: Array = []; + var findWidth = function (v: string): number { return ( (scope.getStringUnitWidth(v, { font: activeFont, @@ -3882,10 +4251,10 @@ function jsPDF(options) { ); }; if (Object.prototype.toString.call(text) === "[object Array]") { - da = transformTextToSpecialArray(text); + da = transformTextToSpecialArray(text as TextItem[]); var newY; if (align !== "left") { - lineWidths = da.map(findWidth); + lineWidths = (da as string[]).map(findWidth); } //The first line uses the "main" Td setting, //and the subsequent lines are offset by the @@ -3896,7 +4265,7 @@ function jsPDF(options) { //The passed in x coordinate defines the //rightmost point of the text. x -= lineWidths[0]; - text = []; + text = [] as TextItem[]; len = da.length; for (var i = 0; i < len; i++) { if (i === 0) { @@ -3906,14 +4275,14 @@ function jsPDF(options) { newX = scale(prevWidth - lineWidths[i]); newY = -leading; } - text.push([da[i], newX, newY]); + text.push([da[i] as string, newX, newY]); prevWidth = lineWidths[i]; } } else if (align === "center") { //The passed in x coordinate defines //the center point. x -= lineWidths[0] / 2; - text = []; + text = [] as TextItem[]; len = da.length; for (var j = 0; j < len; j++) { if (j === 0) { @@ -3923,18 +4292,18 @@ function jsPDF(options) { newX = scale((prevWidth - lineWidths[j]) / 2); newY = -leading; } - text.push([da[j], newX, newY]); + text.push([da[j] as string, newX, newY]); prevWidth = lineWidths[j]; } } else if (align === "left") { - text = []; + text = [] as TextItem[]; len = da.length; for (var h = 0; h < len; h++) { text.push(da[h]); } } else if (align === "justify" && activeFont.encoding === "Identity-H") { // when using unicode fonts, wordSpacePerLine does not apply - text = []; + text = [] as TextItem[]; len = da.length; maxWidth = maxWidth !== 0 ? maxWidth : pageWidth; let backToStartX = 0; @@ -3943,9 +4312,10 @@ function jsPDF(options) { newX = l === 0 ? getHorizontalCoordinate(x) : backToStartX; if (l < len - 1) { let spacing = scale( - (maxWidth - lineWidths[l]) / (da[l].split(" ").length - 1) + (maxWidth - lineWidths[l]) / + ((da[l] as string).split(" ").length - 1) ); - let words = da[l].split(" "); + let words = (da[l] as string).split(" "); text.push([words[0] + " ", newX, newY]); backToStartX = 0; // distance to reset back to the left for (let i = 1; i < words.length; i++) { @@ -3959,19 +4329,19 @@ function jsPDF(options) { backToStartX -= shiftAmount; } } else { - text.push([da[l], newX, newY]); + text.push([da[l] as string, newX, newY]); } } text.push(["", backToStartX, 0]); } else if (align === "justify") { - text = []; + text = [] as TextItem[]; len = da.length; maxWidth = maxWidth !== 0 ? maxWidth : pageWidth; for (var l = 0; l < len; l++) { newY = l === 0 ? getVerticalCoordinate(y) : -leading; newX = l === 0 ? getHorizontalCoordinate(x) : 0; - const numSpaces = da[l].split(" ").length - 1; + const numSpaces = (da[l] as string).split(" ").length - 1; const spacing = numSpaces > 0 ? (maxWidth - lineWidths[l]) / numSpaces : 0; @@ -3980,7 +4350,7 @@ function jsPDF(options) { } else { wordSpacingPerLine.push(0); } - text.push([da[l], newX, newY]); + text.push([da[l] as string, newX, newY]); } } else { throw new Error( @@ -3992,14 +4362,13 @@ function jsPDF(options) { //R2L var doReversing = typeof options.R2L === "boolean" ? options.R2L : R2L; if (doReversing === true) { - text = processTextByFunction(text, function(text, posX, posY) { + text = processTextByFunction(text, function (text, posX, posY): Array< + string | number + > { return [ - text - .split("") - .reverse() - .join(""), - posX, - posY + text.split("").reverse().join(""), + posX as number, + posY as number ]; }); } @@ -4029,27 +4398,29 @@ function jsPDF(options) { activeFontEncoding === "WinAnsiEncoding" || activeFontEncoding === "StandardEncoding" ) { - text = processTextByFunction(text, function(text, posX, posY) { - return [ESC(text), posX, posY]; + text = processTextByFunction(text, function (text, posX, posY): Array< + string | number + > { + return [ESC(text), posX as number, posY as number]; }); } - da = transformTextToSpecialArray(text); + da = transformTextToSpecialArray(text as TextItem[]); - text = []; + text = [] as TextItem[]; var STRING = 0; var ARRAY = 1; var variant = Array.isArray(da[0]) ? ARRAY : STRING; - var posX; - var posY; - var content; + var posX: number; + var posY: number; + var content: string; var wordSpacing = ""; - var generatePosition = function( - parmPosX, - parmPosY, - parmTransformationMatrix - ) { + var generatePosition = function ( + parmPosX: number, + parmPosY: number, + parmTransformationMatrix?: number | MatrixType + ): string { var position = ""; if (parmTransformationMatrix instanceof Matrix) { // It is kind of more intuitive to apply a plain rotation around the text anchor set by x and y @@ -4087,9 +4458,15 @@ function jsPDF(options) { switch (variant) { case ARRAY: content = - (isHex ? "<" : "(") + da[lineIndex][0] + (isHex ? ">" : ")"); - posX = parseFloat(da[lineIndex][1]); - posY = parseFloat(da[lineIndex][2]); + (isHex ? "<" : "(") + + (da[lineIndex] as Array)[0] + + (isHex ? ">" : ")"); + posX = parseFloat( + String((da[lineIndex] as Array)[1]) + ); + posY = parseFloat( + String((da[lineIndex] as Array)[2]) + ); break; case STRING: content = (isHex ? "<" : "(") + da[lineIndex] + (isHex ? ">" : ")"); @@ -4106,15 +4483,15 @@ function jsPDF(options) { } if (lineIndex === 0) { - text.push( + (text as TextItem[]).push( wordSpacing + generatePosition(posX, posY, transformationMatrix) + content ); } else if (variant === STRING) { - text.push(wordSpacing + content); + (text as TextItem[]).push(wordSpacing + content); } else if (variant === ARRAY) { - text.push( + (text as TextItem[]).push( wordSpacing + generatePosition(posX, posY, transformationMatrix) + content @@ -4122,7 +4499,10 @@ function jsPDF(options) { } } - text = variant === STRING ? text.join(" Tj\nT* ") : text.join(" Tj\n"); + text = + variant === STRING + ? (text as TextItem[]).join(" Tj\nT* ") + : (text as TextItem[]).join(" Tj\n"); text += " Tj\n"; var result = "BT\n/"; @@ -4136,7 +4516,7 @@ function jsPDF(options) { out(result); usedFonts[activeFontKey] = true; return scope; - }; + } as unknown as jsPDFDocument["text"]; // PDF supports these path painting and clip path operators: // @@ -4164,16 +4544,21 @@ function jsPDF(options) { * @memberof jsPDF# * @description All .clip() after calling drawing ops with a style argument of null. */ - var clip = (API.__private__.clip = API.clip = function(rule) { - // Call .clip() after calling drawing ops with a style argument of null - // W is the PDF clipping op - if ("evenodd" === rule) { - out("W*"); - } else { - out("W"); - } - return this; - }); + var clip = + (API.__private__.clip = + API.clip = + function (this: jsPDFDocument | void, rule?: string) { + // Call .clip() after calling drawing ops with a style argument of null + // W is the PDF clipping op + if ("evenodd" === rule) { + out("W*"); + } else { + out("W"); + } + // `this` is the document on method calls; clipEvenOdd() forwards the + // bare-call result unchanged, matching the original loose behavior. + return this as jsPDFDocument; + }); /** * @name clipEvenOdd @@ -4185,7 +4570,7 @@ function jsPDF(options) { * that this will NOT consume the current path. In order to only use this path for clipping call * {@link API.discardPath} afterwards. */ - API.clipEvenOdd = function() { + API.clipEvenOdd = function () { return clip("evenodd"); }; @@ -4198,13 +4583,17 @@ function jsPDF(options) { * @returns {jsPDF} * @memberof jsPDF# */ - API.__private__.discardPath = API.discardPath = function() { + API.__private__.discardPath = API.discardPath = function ( + this: jsPDFDocument + ) { out("n"); return this; }; - var isValidStyle = (API.__private__.isValidStyle = function(style) { - var validStyleVariants = [ + var isValidStyle = (API.__private__.isValidStyle = function ( + style?: string | null + ): boolean { + var validStyleVariants: Array = [ undefined, null, "S", @@ -4225,47 +4614,49 @@ function jsPDF(options) { return result; }); - API.__private__.setDefaultPathOperation = API.setDefaultPathOperation = function( - operator - ) { - if (isValidStyle(operator)) { - defaultPathOperation = operator; - } - return this; - }; - - var getStyle = (API.__private__.getStyle = API.getStyle = function(style) { - // see path-painting operators in PDF spec - var op = defaultPathOperation; // stroke + API.__private__.setDefaultPathOperation = API.setDefaultPathOperation = + function (this: jsPDFDocument, operator: string) { + if (isValidStyle(operator)) { + defaultPathOperation = operator; + } + return this; + }; - switch (style) { - case "D": - case "S": - op = "S"; // stroke - break; - case "F": - op = "f"; // fill - break; - case "FD": - case "DF": - op = "B"; - break; - case "f": - case "f*": - case "B": - case "B*": - /* + var getStyle = + (API.__private__.getStyle = + API.getStyle = + function (style: string): string { + // see path-painting operators in PDF spec + var op = defaultPathOperation; // stroke + + switch (style) { + case "D": + case "S": + op = "S"; // stroke + break; + case "F": + op = "f"; // fill + break; + case "FD": + case "DF": + op = "B"; + break; + case "f": + case "f*": + case "B": + case "B*": + /* Allow direct use of these PDF path-painting operators: - f fill using nonzero winding number rule - f* fill using even-odd rule - B fill then stroke with fill using non-zero winding number rule - B* fill then stroke with fill using even-odd rule */ - op = style; - break; - } - return op; - }); + op = style; + break; + } + return op; + }); /** * Close the current path. The PDF "h" operator. @@ -4275,9 +4666,11 @@ function jsPDF(options) { * @returns {jsPDF} * @memberof jsPDF# */ - var close = (API.close = function() { + var close = (API.close = function (this: jsPDFDocument | void) { out("h"); - return this; + // Also invoked internally as a bare helper (no `this`), matching the + // original loose behavior. + return this as jsPDFDocument; }); /** @@ -4288,7 +4681,7 @@ function jsPDF(options) { * @returns {jsPDF} * @memberof jsPDF# */ - API.stroke = function() { + API.stroke = function (this: jsPDFDocument) { out("S"); return this; }; @@ -4303,7 +4696,7 @@ function jsPDF(options) { * @returns {jsPDF} * @memberof jsPDF# */ - API.fill = function(pattern) { + API.fill = function (this: jsPDFDocument, pattern) { fillWithOptionalPattern("f", pattern); return this; }; @@ -4318,7 +4711,7 @@ function jsPDF(options) { * @returns {jsPDF} * @memberof jsPDF# */ - API.fillEvenOdd = function(pattern) { + API.fillEvenOdd = function (this: jsPDFDocument, pattern) { fillWithOptionalPattern("f*", pattern); return this; }; @@ -4333,7 +4726,7 @@ function jsPDF(options) { * @returns {jsPDF} * @memberof jsPDF# */ - API.fillStroke = function(pattern) { + API.fillStroke = function (this: jsPDFDocument, pattern) { fillWithOptionalPattern("B", pattern); return this; }; @@ -4348,12 +4741,15 @@ function jsPDF(options) { * @returns {jsPDF} * @memberof jsPDF# */ - API.fillStrokeEvenOdd = function(pattern) { + API.fillStrokeEvenOdd = function (this: jsPDFDocument, pattern) { fillWithOptionalPattern("B*", pattern); return this; }; - var fillWithOptionalPattern = function(style, pattern) { + var fillWithOptionalPattern = function ( + style: string, + pattern?: PatternData + ) { if (typeof pattern === "object") { fillWithPattern(pattern, style); } else { @@ -4361,7 +4757,7 @@ function jsPDF(options) { } }; - var putStyle = function(style) { + var putStyle = function (style?: string | null) { if ( style === null || (apiMode === ApiMode.ADVANCED && style === undefined) @@ -4375,8 +4771,15 @@ function jsPDF(options) { out(style); }; - function cloneTilingPattern(patternKey, boundingBox, xStep, yStep, matrix) { - var clone = new (TilingPattern as any)( + function cloneTilingPattern( + this: TilingPattern, + patternKey: string, + boundingBox?: number[], + xStep?: number, + yStep?: number, + matrix?: Matrix + ): TilingPattern { + var clone = new TilingPattern( boundingBox || this.boundingBox, xStep || this.xStep, yStep || this.yStep, @@ -4389,7 +4792,7 @@ function jsPDF(options) { return clone; } - var fillWithPattern = function(patternData, style) { + var fillWithPattern = function (patternData: PatternData, style: string) { var patternId = patternMap[patternData.key]; var pattern = patterns[patternId]; @@ -4398,8 +4801,8 @@ function jsPDF(options) { out(clipRuleFromStyle(style)); - if ((pattern as any).gState) { - API.setGState((pattern as any).gState); + if (pattern.gState) { + API.setGState(pattern.gState); } out(patternData.matrix.toString() + " cm"); out("/" + patternId + " sh"); @@ -4427,8 +4830,8 @@ function jsPDF(options) { out("/Pattern cs"); out("/" + patternId + " scn"); - if ((pattern as any).gState) { - API.setGState((pattern as any).gState); + if (pattern.gState) { + API.setGState(pattern.gState); } out(style); @@ -4436,7 +4839,7 @@ function jsPDF(options) { } }; - var clipRuleFromStyle = function(style) { + var clipRuleFromStyle = function (style: string): string { switch (style) { case "f": case "F": @@ -4467,9 +4870,15 @@ function jsPDF(options) { * @memberof jsPDF# * @returns {jsPDF} */ - var moveTo = (API.moveTo = function(x, y) { + var moveTo = (API.moveTo = function ( + this: jsPDFDocument | void, + x: number, + y: number + ) { out(hpf(scale(x)) + " " + hpf(transformScaleY(y)) + " m"); - return this; + // Also invoked internally as a bare helper (no `this`), matching the + // original loose behavior. + return this as jsPDFDocument; }); /** @@ -4483,9 +4892,15 @@ function jsPDF(options) { * @memberof jsPDF# * @returns {jsPDF} */ - var lineTo = (API.lineTo = function(x, y) { + var lineTo = (API.lineTo = function ( + this: jsPDFDocument | void, + x: number, + y: number + ) { out(hpf(scale(x)) + " " + hpf(transformScaleY(y)) + " l"); - return this; + // Also invoked internally as a bare helper (no `this`), matching the + // original loose behavior. + return this as jsPDFDocument; }); /** @@ -4504,7 +4919,15 @@ function jsPDF(options) { * @memberof jsPDF# * @returns {jsPDF} */ - var curveTo = (API.curveTo = function(x1, y1, x2, y2, x3, y3) { + var curveTo = (API.curveTo = function ( + this: jsPDFDocument | void, + x1: number, + y1: number, + x2: number, + y2: number, + x3: number, + y3: number + ) { out( [ hpf(scale(x1)), @@ -4516,7 +4939,9 @@ function jsPDF(options) { "c" ].join(" ") ); - return this; + // Also invoked internally as a bare helper (no `this`), matching the + // original loose behavior. + return this as jsPDFDocument; }); /** @@ -4533,7 +4958,14 @@ function jsPDF(options) { * @returns {jsPDF} * @memberof jsPDF# */ - API.__private__.line = API.line = function(x1, y1, x2, y2, style) { + API.__private__.line = API.line = function ( + this: jsPDFDocument, + x1, + y1, + x2, + y2, + style + ) { if ( isNaN(x1) || isNaN(y1) || @@ -4585,13 +5017,14 @@ function jsPDF(options) { * @memberof jsPDF# * @name lines */ - API.__private__.lines = API.lines = function( - lines, - x, - y, - scale, - style, - closed + API.__private__.lines = API.lines = function ( + this: jsPDFDocument, + lines: Array | number, + x: number, + y: number, + scale?: number[], + style?: string | null, + closed?: boolean ) { var scalex, scaley, i, l, leg, x2, y2, x3, y3, x4, y4, tmp; @@ -4601,7 +5034,8 @@ function jsPDF(options) { // this method had its args flipped. // code below allows backward compatibility with old arg order. if (typeof lines === "number") { - tmp = y; + // Legacy argument order: the line data arrived in `y`. + tmp = y as unknown as Array; y = x; x = lines; lines = tmp; @@ -4626,7 +5060,7 @@ function jsPDF(options) { scalex = scale[0]; scaley = scale[1]; - l = lines.length; + l = (lines as Array).length; //, x2, y2 // bezier only. In page default measurement "units", *after* scaling //, x3, y3 // bezier only. In page default measurement "units", *after* scaling // ending point for all, lines and bezier. . In page default measurement "units", *after* scaling @@ -4634,7 +5068,7 @@ function jsPDF(options) { y4 = y; // last / ending point = starting point for first item. for (i = 0; i < l; i++) { - leg = lines[i]; + leg = (lines as Array)[i]; if (leg.length === 2) { // simple line x4 = leg[0] * scalex + x4; // here last x4 was prior ending point @@ -4670,7 +5104,7 @@ function jsPDF(options) { * @memberof jsPDF# * @name path */ - API.path = function(lines) { + API.path = function (this: jsPDFDocument, lines) { for (var i = 0; i < lines.length; i++) { var leg = lines[i]; var coords = leg.c; @@ -4682,7 +5116,10 @@ function jsPDF(options) { lineTo(coords[0], coords[1]); break; case "c": - curveTo.apply(this, coords); + curveTo.apply( + this, + coords as [number, number, number, number, number, number] + ); break; case "h": close(); @@ -4714,7 +5151,14 @@ function jsPDF(options) { * @memberof jsPDF# * @name rect */ - API.__private__.rect = API.rect = function(x, y, w, h, style) { + API.__private__.rect = API.rect = function ( + this: jsPDFDocument, + x, + y, + w, + h, + style + ) { if (isNaN(x) || isNaN(y) || isNaN(w) || isNaN(h) || !isValidStyle(style)) { throw new Error("Invalid arguments passed to jsPDF.rect"); } @@ -4759,7 +5203,8 @@ function jsPDF(options) { * @memberof jsPDF# * @name triangle */ - API.__private__.triangle = API.triangle = function( + API.__private__.triangle = API.triangle = function ( + this: jsPDFDocument, x1, y1, x2, @@ -4817,7 +5262,8 @@ function jsPDF(options) { * @memberof jsPDF# * @name roundedRect */ - API.__private__.roundedRect = API.roundedRect = function( + API.__private__.roundedRect = API.roundedRect = function ( + this: jsPDFDocument, x, y, w, @@ -4883,7 +5329,14 @@ function jsPDF(options) { * @memberof jsPDF# * @name ellipse */ - API.__private__.ellipse = API.ellipse = function(x, y, rx, ry, style) { + API.__private__.ellipse = API.ellipse = function ( + this: jsPDFDocument, + x, + y, + rx, + ry, + style + ) { if ( isNaN(x) || isNaN(y) || @@ -4926,7 +5379,13 @@ function jsPDF(options) { * @memberof jsPDF# * @name circle */ - API.__private__.circle = API.circle = function(x, y, r, style) { + API.__private__.circle = API.circle = function ( + this: jsPDFDocument, + x, + y, + r, + style + ) { if (isNaN(x) || isNaN(y) || isNaN(r) || !isValidStyle(style)) { throw new Error("Invalid arguments passed to jsPDF.circle"); } @@ -4946,7 +5405,12 @@ function jsPDF(options) { * @memberof jsPDF# * @name setFont */ - API.setFont = function(fontName, fontStyle, fontWeight) { + API.setFont = function ( + this: jsPDFDocument, + fontName, + fontStyle, + fontWeight + ) { if (fontWeight) { fontStyle = combineFontStyleAndFontWeight(fontStyle, fontWeight); } @@ -4965,9 +5429,28 @@ function jsPDF(options) { * @memberof jsPDF# * @name getFont */ - var getFontEntry = (API.__private__.getFont = API.getFont = function() { - return fonts[getFont.apply(API, arguments as any)]; - }); + var getFontEntry = + (API.__private__.getFont = + API.getFont = + function ( + // The parameters are consumed through `arguments` below; they are + // declared for the type surface only. + fontName?: string, + fontStyle?: string, + options?: { disableWarning?: boolean; noFallback?: boolean } + ): Font { + return fonts[ + getFont.apply( + API, + // eslint-disable-next-line prefer-rest-params + Array.prototype.slice.call(arguments) as [ + string?, + string?, + { disableWarning?: boolean; noFallback?: boolean }? + ] + ) + ]; + }); /** * Returns an object - a tree of fontName to fontStyle relationships available to @@ -4980,8 +5463,8 @@ function jsPDF(options) { * @memberof jsPDF# * @name getFontList */ - API.__private__.getFontList = API.getFontList = function() { - var list = {}, + API.__private__.getFontList = API.getFontList = function () { + var list: Record = {}, fontName, fontStyle; @@ -5012,12 +5495,13 @@ function jsPDF(options) { * @name addFont * @returns {string} fontId */ - API.addFont = function( - postScriptName, - fontName, - fontStyle, - fontWeight, - encoding + API.addFont = function ( + this: jsPDFDocument, + postScriptName: string | URL, + fontName: string, + fontStyle: string, + fontWeight?: string | number, + encoding?: string ) { var encodingOptions = [ "StandardEncoding", @@ -5032,7 +5516,15 @@ function jsPDF(options) { fontStyle = combineFontStyleAndFontWeight(fontStyle, fontWeight); } encoding = encoding || "Identity-H"; - return addFont.call(this, postScriptName, fontName, fontStyle, encoding); + // URL inputs are resolved by the ttfsupport plugin through the addFont + // event; the core stores the value as the font's postScriptName. + return addFont.call( + this, + postScriptName as string, + fontName, + fontStyle, + encoding + ); }; var lineWidth = options.lineWidth || 0.200025; // 2mm @@ -5045,9 +5537,12 @@ function jsPDF(options) { * @memberof jsPDF# * @name getLineWidth */ - var getLineWidth = (API.__private__.getLineWidth = API.getLineWidth = function() { - return lineWidth; - }); + var getLineWidth = + (API.__private__.getLineWidth = + API.getLineWidth = + function () { + return lineWidth; + }); /** * Sets line width for upcoming lines. @@ -5059,13 +5554,14 @@ function jsPDF(options) { * @memberof jsPDF# * @name setLineWidth */ - var setLineWidth = (API.__private__.setLineWidth = API.setLineWidth = function( - width - ) { - lineWidth = width; - out(hpf(scale(width)) + " w"); - return this; - }); + var setLineWidth = + (API.__private__.setLineWidth = + API.setLineWidth = + function (width) { + lineWidth = width; + out(hpf(scale(width)) + " w"); + return this; + }); /** * Sets the dash pattern for upcoming lines. @@ -5081,35 +5577,38 @@ function jsPDF(options) { * @memberof jsPDF# * @name setLineDashPattern */ - API.__private__.setLineDash = jsPDF.API.setLineDash = jsPDF.API.setLineDashPattern = function( - dashArray, - dashPhase - ) { - dashArray = dashArray || []; - dashPhase = dashPhase || 0; - - if (isNaN(dashPhase) || !Array.isArray(dashArray)) { - throw new Error("Invalid arguments passed to jsPDF.setLineDash"); - } + API.__private__.setLineDash = + jsPDF.API.setLineDash = + jsPDF.API.setLineDashPattern = + function (this: jsPDFDocument, dashArray?: number[], dashPhase?: number) { + dashArray = dashArray || []; + dashPhase = dashPhase || 0; + + if (isNaN(dashPhase) || !Array.isArray(dashArray)) { + throw new Error("Invalid arguments passed to jsPDF.setLineDash"); + } - dashArray = dashArray - .map(function(x) { - return hpf(scale(x)); - }) - .join(" "); - dashPhase = hpf(scale(dashPhase)); + var dashArrayString = dashArray + .map(function (x) { + return hpf(scale(x)); + }) + .join(" "); + var dashPhaseString = hpf(scale(dashPhase)); - out("[" + dashArray + "] " + dashPhase + " d"); - return this; - }; + out("[" + dashArrayString + "] " + dashPhaseString + " d"); + return this; + }; - var lineHeightFactor; + var lineHeightFactor: number; - var getLineHeight = (API.__private__.getLineHeight = API.getLineHeight = function() { - return activeFontSize * lineHeightFactor; - }); + var getLineHeight = + (API.__private__.getLineHeight = + API.getLineHeight = + function () { + return activeFontSize * lineHeightFactor; + }); - API.__private__.getLineHeight = API.getLineHeight = function() { + API.__private__.getLineHeight = API.getLineHeight = function () { return activeFontSize * lineHeightFactor; }; @@ -5123,15 +5622,18 @@ function jsPDF(options) { * @memberof jsPDF# * @name setLineHeightFactor */ - var setLineHeightFactor = (API.__private__.setLineHeightFactor = API.setLineHeightFactor = function( - value - ) { - value = value || 1.15; - if (typeof value === "number") { - lineHeightFactor = value; - } - return this; - }); + var setLineHeightFactor = + (API.__private__.setLineHeightFactor = + API.setLineHeightFactor = + function (this: jsPDFDocument | void, value: number) { + value = value || 1.15; + if (typeof value === "number") { + lineHeightFactor = value; + } + // Also invoked internally as a bare helper (no `this`), matching the + // original loose behavior. + return this as jsPDFDocument; + }); /** * Gets the LineHeightFactor, default: 1.15. @@ -5142,42 +5644,45 @@ function jsPDF(options) { * @memberof jsPDF# * @name getLineHeightFactor */ - var getLineHeightFactor = (API.__private__.getLineHeightFactor = API.getLineHeightFactor = function() { - return lineHeightFactor; - }); + var getLineHeightFactor = + (API.__private__.getLineHeightFactor = + API.getLineHeightFactor = + function () { + return lineHeightFactor; + }); setLineHeightFactor(options.lineHeight); - var getHorizontalCoordinate = (API.__private__.getHorizontalCoordinate = function( - value - ) { - return scale(value); - }); + var getHorizontalCoordinate = (API.__private__.getHorizontalCoordinate = + function (value: number): number { + return scale(value); + }); - var getVerticalCoordinate = (API.__private__.getVerticalCoordinate = function( - value - ) { - if (apiMode === ApiMode.ADVANCED) { - return value; - } else { - var pageHeight = - pagesContext[currentPage].mediaBox.topRightY - - pagesContext[currentPage].mediaBox.bottomLeftY; - return pageHeight - scale(value); - } - }); + var getVerticalCoordinate = (API.__private__.getVerticalCoordinate = + function (value: number): number { + if (apiMode === ApiMode.ADVANCED) { + return value; + } else { + var pageHeight = + pagesContext[currentPage].mediaBox.topRightY - + pagesContext[currentPage].mediaBox.bottomLeftY; + return pageHeight - scale(value); + } + }); - var getHorizontalCoordinateString = (API.__private__.getHorizontalCoordinateString = API.getHorizontalCoordinateString = function( - value - ) { - return hpf(getHorizontalCoordinate(value)); - }); + var getHorizontalCoordinateString = + (API.__private__.getHorizontalCoordinateString = + API.getHorizontalCoordinateString = + function (value: number): string { + return hpf(getHorizontalCoordinate(value)); + }); - var getVerticalCoordinateString = (API.__private__.getVerticalCoordinateString = API.getVerticalCoordinateString = function( - value - ) { - return hpf(getVerticalCoordinate(value)); - }); + var getVerticalCoordinateString = + (API.__private__.getVerticalCoordinateString = + API.getVerticalCoordinateString = + function (value: number): string { + return hpf(getVerticalCoordinate(value)); + }); var strokeColor = options.strokeColor || "0 G"; @@ -5190,7 +5695,7 @@ function jsPDF(options) { * @memberof jsPDF# * @name getDrawColor */ - API.__private__.getStrokeColor = API.getDrawColor = function() { + API.__private__.getStrokeColor = API.getDrawColor = function (): string { return decodeColorString(strokeColor); }; @@ -5232,7 +5737,8 @@ function jsPDF(options) { * @memberof jsPDF# * @name setDrawColor */ - API.__private__.setStrokeColor = API.setDrawColor = function( + API.__private__.setStrokeColor = API.setDrawColor = function ( + this: jsPDFDocument, ch1, ch2, ch3, @@ -5243,7 +5749,7 @@ function jsPDF(options) { ch2: ch2, ch3: ch3, ch4: ch4, - pdfColorType: "draw", + pdfColorType: "draw" as const, precision: 2 }; @@ -5263,7 +5769,7 @@ function jsPDF(options) { * @memberof jsPDF# * @name getFillColor */ - API.__private__.getFillColor = API.getFillColor = function() { + API.__private__.getFillColor = API.getFillColor = function (): string { return decodeColorString(fillColor); }; @@ -5305,7 +5811,8 @@ function jsPDF(options) { * @memberof jsPDF# * @name setFillColor */ - API.__private__.setFillColor = API.setFillColor = function( + API.__private__.setFillColor = API.setFillColor = function ( + this: jsPDFDocument, ch1, ch2, ch3, @@ -5316,7 +5823,7 @@ function jsPDF(options) { ch2: ch2, ch3: ch3, ch4: ch4, - pdfColorType: "fill", + pdfColorType: "fill" as const, precision: 2 }; @@ -5335,9 +5842,12 @@ function jsPDF(options) { * @memberof jsPDF# * @name getTextColor */ - var getTextColor = (API.__private__.getTextColor = API.getTextColor = function() { - return decodeColorString(textColor); - }); + var getTextColor = + (API.__private__.getTextColor = + API.getTextColor = + function () { + return decodeColorString(textColor); + }); /** * Sets the text color for upcoming elements. * @@ -5376,7 +5886,8 @@ function jsPDF(options) { * @memberof jsPDF# * @name setTextColor */ - API.__private__.setTextColor = API.setTextColor = function( + API.__private__.setTextColor = API.setTextColor = function ( + this: jsPDFDocument, ch1, ch2, ch3, @@ -5387,7 +5898,7 @@ function jsPDF(options) { ch2: ch2, ch3: ch3, ch4: ch4, - pdfColorType: "text", + pdfColorType: "text" as const, precision: 3 }; textColor = encodeColorString(options); @@ -5406,9 +5917,12 @@ function jsPDF(options) { * @memberof jsPDF# * @name getCharSpace */ - var getCharSpace = (API.__private__.getCharSpace = API.getCharSpace = function() { - return parseFloat(activeCharSpace || 0); - }); + var getCharSpace = + (API.__private__.getCharSpace = + API.getCharSpace = + function (): number { + return parseFloat(String(activeCharSpace || 0)); + }); /** * Set global value of CharSpace. @@ -5420,7 +5934,10 @@ function jsPDF(options) { * @memberof jsPDF# * @name setCharSpace */ - API.__private__.setCharSpace = API.setCharSpace = function(charSpace) { + API.__private__.setCharSpace = API.setCharSpace = function ( + this: jsPDFDocument, + charSpace + ) { if (isNaN(charSpace)) { throw new Error("Invalid argument passed to jsPDF.setCharSpace"); } @@ -5464,7 +5981,10 @@ function jsPDF(options) { * @memberof jsPDF# * @name setLineCap */ - API.__private__.setLineCap = API.setLineCap = function(style) { + API.__private__.setLineCap = API.setLineCap = function ( + this: jsPDFDocument, + style + ) { var id = API.CapJoinStyles[style]; if (id === undefined) { throw new Error( @@ -5491,7 +6011,10 @@ function jsPDF(options) { * @memberof jsPDF# * @name setLineJoin */ - API.__private__.setLineJoin = API.setLineJoin = function(style) { + API.__private__.setLineJoin = API.setLineJoin = function ( + this: jsPDFDocument, + style + ) { var id = API.CapJoinStyles[style]; if (id === undefined) { throw new Error( @@ -5506,7 +6029,7 @@ function jsPDF(options) { return this; }; - var miterLimit; + var miterLimit: number; /** * Sets the miterLimit property, which effects the maximum miter length. * @@ -5517,17 +6040,19 @@ function jsPDF(options) { * @memberof jsPDF# * @name setLineMiterLimit */ - API.__private__.setLineMiterLimit = API.__private__.setMiterLimit = API.setLineMiterLimit = API.setMiterLimit = function( - length - ) { - length = length || 0; - if (isNaN(length)) { - throw new Error("Invalid argument passed to jsPDF.setLineMiterLimit"); - } - out(hpf(scale(length)) + " M"); + API.__private__.setLineMiterLimit = + API.__private__.setMiterLimit = + API.setLineMiterLimit = + API.setMiterLimit = + function (this: jsPDFDocument, length: number) { + length = length || 0; + if (isNaN(length)) { + throw new Error("Invalid argument passed to jsPDF.setLineMiterLimit"); + } + out(hpf(scale(length)) + " M"); - return this; - }; + return this; + }; /** * An object representing a pdf graphics state. @@ -5551,16 +6076,17 @@ function jsPDF(options) { * @memberof jsPDF# * @name setGState */ - API.setGState = function(gState) { + API.setGState = function (this: jsPDFDocument, gState: string | GState) { + var resolvedGState: GState; if (typeof gState === "string") { - gState = gStates[gStatesMap[gState]]; + resolvedGState = gStates[gStatesMap[gState]]; } else { - gState = addGState(null, gState); + resolvedGState = addGState(null, gState); } - if (!gState.equals(activeGState)) { - out("/" + gState.id + " gs"); - activeGState = gState; + if (!resolvedGState.equals(activeGState)) { + out("/" + resolvedGState.id + " gs"); + activeGState = resolvedGState; } }; @@ -5569,7 +6095,7 @@ function jsPDF(options) { * @param {String} key Might also be null, if no later reference to this gState is needed * @param {Object} gState The gState object */ - var addGState = function(key, gState) { + var addGState = function (key: string | null, gState: GState): GState { // only add it if it is not already present (the keys provided by the user must be unique!) if (key && gStatesMap[key]) return; var duplicate = false; @@ -5609,7 +6135,7 @@ function jsPDF(options) { * @memberof jsPDF# * @name addGState */ - API.addGState = function(key, gState) { + API.addGState = function (this: jsPDFDocument, key, gState) { addGState(key, gState); return this; }; @@ -5623,7 +6149,7 @@ function jsPDF(options) { * @memberof jsPDF# * @name saveGraphicsState */ - API.saveGraphicsState = function() { + API.saveGraphicsState = function (this: jsPDFDocument) { out("q"); // as we cannot set font key and size independently we must keep track of both fontStateStack.push({ @@ -5641,7 +6167,7 @@ function jsPDF(options) { * @memberof jsPDF# * @name restoreGraphicsState */ - API.restoreGraphicsState = function() { + API.restoreGraphicsState = function (this: jsPDFDocument) { out("Q"); // restore previous font state @@ -5664,7 +6190,7 @@ function jsPDF(options) { * @memberof jsPDF# * @name setCurrentTransformationMatrix */ - API.setCurrentTransformationMatrix = function(matrix) { + API.setCurrentTransformationMatrix = function (this: jsPDFDocument, matrix) { out(matrix.toString() + " cm"); return this; }; @@ -5678,7 +6204,7 @@ function jsPDF(options) { * @memberof jsPDF# * @name comment */ - API.comment = function(text) { + API.comment = function (this: jsPDFDocument, text: string) { out("#" + text); return this; }; @@ -5686,116 +6212,148 @@ function jsPDF(options) { /** * Point */ - var Point: any = function(x, y) { - var _x = x || 0; - Object.defineProperty(this, "x", { - enumerable: true, - get: function() { - return _x; - }, - set: function(value) { - if (!isNaN(value)) { - _x = parseFloat(value); + class Point { + // The accessors are defined as own, enumerable instance properties in + // the constructor (matching the original function-constructor surface), + // so the fields are declare-only. + declare x: number; + declare y: number; + declare type: string; + + constructor(x?: number, y?: number) { + var _x = x || 0; + Object.defineProperty(this, "x", { + enumerable: true, + get: function () { + return _x; + }, + set: function (value: number | string) { + if (!isNaN(value as number)) { + _x = parseFloat(value as string); + } } - } - }); + }); - var _y = y || 0; - Object.defineProperty(this, "y", { - enumerable: true, - get: function() { - return _y; - }, - set: function(value) { - if (!isNaN(value)) { - _y = parseFloat(value); + var _y = y || 0; + Object.defineProperty(this, "y", { + enumerable: true, + get: function () { + return _y; + }, + set: function (value: number | string) { + if (!isNaN(value as number)) { + _y = parseFloat(value as string); + } } - } - }); + }); - var _type = "pt"; - Object.defineProperty(this, "type", { - enumerable: true, - get: function() { - return _type; - }, - set: function(value) { - _type = value.toString(); - } - }); - return this; - }; + var _type = "pt"; + Object.defineProperty(this, "type", { + enumerable: true, + get: function () { + return _type; + }, + set: function (value: string) { + _type = value.toString(); + } + }); + } + } /** * Rectangle */ - var Rectangle: any = function(x, y, w, h) { - Point.call(this, x, y); - this.type = "rect"; - - var _w = w || 0; - Object.defineProperty(this, "w", { - enumerable: true, - get: function() { - return _w; - }, - set: function(value) { - if (!isNaN(value)) { - _w = parseFloat(value); + class Rectangle extends Point { + declare w: number; + declare h: number; + + constructor(x?: number, y?: number, w?: number, h?: number) { + super(x, y); + this.type = "rect"; + + var _w = w || 0; + Object.defineProperty(this, "w", { + enumerable: true, + get: function () { + return _w; + }, + set: function (value: number | string) { + if (!isNaN(value as number)) { + _w = parseFloat(value as string); + } } - } - }); + }); - var _h = h || 0; - Object.defineProperty(this, "h", { - enumerable: true, - get: function() { - return _h; - }, - set: function(value) { - if (!isNaN(value)) { - _h = parseFloat(value); + var _h = h || 0; + Object.defineProperty(this, "h", { + enumerable: true, + get: function () { + return _h; + }, + set: function (value: number | string) { + if (!isNaN(value as number)) { + _h = parseFloat(value as string); + } } - } - }); - - return this; - }; + }); + } + } /** * FormObject/RenderTarget */ - var RenderTarget = function() { - this.page = page; - this.currentPage = currentPage; - this.pages = pages.slice(0); - this.pagesContext = pagesContext.slice(0); - this.x = pageX; - this.y = pageY; - this.matrix = pageMatrix; - this.width = getUnscaledPageWidth(currentPage); - this.height = getUnscaledPageHeight(currentPage); - this.outputDestination = outputDestination; - - this.id = ""; // set by endFormObject() - this.objectNumber = -1; // will be set by putXObject() - }; - - RenderTarget.prototype.restore = function() { - page = this.page; - currentPage = this.currentPage; - pagesContext = this.pagesContext; - pages = this.pages; - pageX = this.x; - pageY = this.y; - pageMatrix = this.matrix; - setPageWidthWithoutScaling(currentPage, this.width); - setPageHeightWithoutScaling(currentPage, this.height); - outputDestination = this.outputDestination; - }; + class RenderTarget { + declare page: number; + declare currentPage: number; + declare pages: string[][]; + declare pagesContext: PageContext[]; + declare x: number; + declare y: number; + declare matrix: MatrixType; + declare width: number; + declare height: number; + declare outputDestination: string[]; + declare id: string; + declare objectNumber: number; + + constructor() { + this.page = page; + this.currentPage = currentPage; + this.pages = pages.slice(0); + this.pagesContext = pagesContext.slice(0); + this.x = pageX; + this.y = pageY; + this.matrix = pageMatrix; + this.width = getUnscaledPageWidth(currentPage); + this.height = getUnscaledPageHeight(currentPage); + this.outputDestination = outputDestination; + + this.id = ""; // set by endFormObject() + this.objectNumber = -1; // will be set by putXObject() + } + + restore() { + page = this.page; + currentPage = this.currentPage; + pagesContext = this.pagesContext; + pages = this.pages; + pageX = this.x; + pageY = this.y; + pageMatrix = this.matrix; + setPageWidthWithoutScaling(currentPage, this.width); + setPageHeightWithoutScaling(currentPage, this.height); + outputDestination = this.outputDestination; + } + } - var beginNewRenderTarget = function(x, y, width, height, matrix) { + var beginNewRenderTarget = function ( + x: number, + y: number, + width: number, + height: number, + matrix: MatrixType + ) { // save current state renderTargetStack.push(new RenderTarget()); @@ -5810,7 +6368,7 @@ function jsPDF(options) { beginPage([width, height]); }; - var endFormObject = function(key) { + var endFormObject = function (key: string) { // only add it if it is not already present (the keys provided by the user must be unique!) if (renderTargetMap[key]) { renderTargetStack.pop().restore(); @@ -5849,7 +6407,14 @@ function jsPDF(options) { * @memberof jsPDF# * @name beginFormObject */ - API.beginFormObject = function(x, y, width, height, matrix) { + API.beginFormObject = function ( + this: jsPDFDocument, + x, + y, + width, + height, + matrix + ) { // The user can set the output target to a new form object. Nested form objects are possible. // Currently, they use the resource dictionary of the surrounding stream. This should be changed, as // the PDF-Spec states: @@ -5869,7 +6434,7 @@ function jsPDF(options) { * @memberof jsPDF# * @name endFormObject */ - API.endFormObject = function(key) { + API.endFormObject = function (this: jsPDFDocument, key) { endFormObject(key); return this; }; @@ -5886,7 +6451,7 @@ function jsPDF(options) { * @memberof jsPDF# * @name doFormObject */ - API.doFormObject = function(key, matrix) { + API.doFormObject = function (this: jsPDFDocument, key, matrix) { var xObject = renderTargets[renderTargetMap[key]]; out("q"); out(matrix.toString() + " cm"); @@ -5904,7 +6469,7 @@ function jsPDF(options) { * @memberof jsPDF# * @name getFormObject */ - API.getFormObject = function(key) { + API.getFormObject = function (key: string) { var xObject = renderTargets[renderTargetMap[key]]; return { x: xObject.x, @@ -5926,33 +6491,39 @@ function jsPDF(options) { * @param {string} filename The filename including extension. * @param {Object} options An Object with additional options, possible options: 'returnPromise'. * @returns {jsPDF|Promise} jsPDF-instance */ - API.save = function(filename, options) { + API.save = function ( + this: jsPDFDocument, + filename?: string, + options?: { returnPromise?: boolean } + ) { filename = filename || "generated.pdf"; options = options || {}; options.returnPromise = options.returnPromise || false; // @if MODULE_FORMAT!='cjs' + // The IE9 shim build attaches an `unload` cleanup hook to saveAs. + var saveAsWithUnload = saveAs as typeof saveAs & { unload?: () => void }; if (options.returnPromise === false) { saveAs(getBlob(buildDocument()), filename); - if (typeof saveAs.unload === "function") { + if (typeof saveAsWithUnload.unload === "function") { if (globalObject.setTimeout) { - setTimeout(saveAs.unload, 911); + setTimeout(saveAsWithUnload.unload, 911); } } return this; } else { - return new Promise(function(resolve, reject) { + return new Promise(function (resolve, reject) { try { var result = saveAs(getBlob(buildDocument()), filename); - if (typeof saveAs.unload === "function") { + if (typeof saveAsWithUnload.unload === "function") { if (globalObject.setTimeout) { - setTimeout(saveAs.unload, 911); + setTimeout(saveAsWithUnload.unload, 911); } } resolve(result); } catch (e) { - reject((e as any).message); + reject((e as Error).message); } }); } @@ -5965,8 +6536,8 @@ function jsPDF(options) { if (options.returnPromise === false) { fs.writeFileSync(filename, buffer); } else { - return new Promise(function(resolve, reject) { - fs.writeFile(filename, buffer, function(err) { + return new Promise(function (resolve, reject) { + fs.writeFile(filename, buffer, function (err) { if (err) { reject(err); } else { @@ -5976,7 +6547,9 @@ function jsPDF(options) { }); } // @endif - }; + // The per-overload return types (jsPDF vs Promise) are mapped through + // the double assertion below; the implementation returns the union. + } as unknown as jsPDFDocument["save"]; // applying plugins (more methods) ON TOP of built-in API. // this is intentional as we allow plugins to override @@ -5984,7 +6557,7 @@ function jsPDF(options) { for (var plugin in jsPDF.API) { if (jsPDF.API.hasOwnProperty(plugin)) { if (plugin === "events" && jsPDF.API.events.length) { - (function(events, newEvents) { + (function (events: PubSub, newEvents: typeof jsPDF.API.events) { // jsPDF.API.events is a JS Array of Arrays // where each Array is a pair of event name, handler // Events were added by plugins to the jsPDF instantiator. @@ -6002,59 +6575,69 @@ function jsPDF(options) { handler_and_args = newEvents[i][1]; events.subscribe.apply( events, - [eventname].concat( + ([eventname] as unknown[]).concat( typeof handler_and_args === "function" ? [handler_and_args] : handler_and_args - ) + ) as [string, PubSubCallback, boolean?] ); } })(events, jsPDF.API.events); } else { - API[plugin] = jsPDF.API[plugin]; + // Copy each plugin member onto the instance; the member set is only + // known through the jsPDFAPI augmentations, hence the generic view. + (API as unknown as Record)[plugin] = ( + jsPDF.API as unknown as Record + )[plugin]; } } } - function getUnscaledPageWidth(pageNumber) { + function getUnscaledPageWidth(pageNumber: number): number { return ( pagesContext[pageNumber].mediaBox.topRightX - pagesContext[pageNumber].mediaBox.bottomLeftX ); } - function setPageWidthWithoutScaling(pageNumber, value) { + function setPageWidthWithoutScaling(pageNumber: number, value: number) { pagesContext[pageNumber].mediaBox.topRightX = value + pagesContext[pageNumber].mediaBox.bottomLeftX; } - function getUnscaledPageHeight(pageNumber) { + function getUnscaledPageHeight(pageNumber: number): number { return ( pagesContext[pageNumber].mediaBox.topRightY - pagesContext[pageNumber].mediaBox.bottomLeftY ); } - function setPageHeightWithoutScaling(pageNumber, value) { + function setPageHeightWithoutScaling(pageNumber: number, value: number) { pagesContext[pageNumber].mediaBox.topRightY = value + pagesContext[pageNumber].mediaBox.bottomLeftY; } - var getPageWidth = (API.getPageWidth = function(pageNumber) { + var getPageWidth = (API.getPageWidth = function (pageNumber?: number) { pageNumber = pageNumber || currentPage; return getUnscaledPageWidth(pageNumber) / scaleFactor; }); - var setPageWidth = (API.setPageWidth = function(pageNumber, value) { + var setPageWidth = (API.setPageWidth = function ( + pageNumber: number, + value: number + ) { setPageWidthWithoutScaling(pageNumber, value * scaleFactor); }); - var getPageHeight = (API.getPageHeight = function(pageNumber?) { + var getPageHeight = (API.getPageHeight = function (pageNumber?) { pageNumber = pageNumber || currentPage; return getUnscaledPageHeight(pageNumber) / scaleFactor; }); - var setPageHeight = (API.setPageHeight = function(pageNumber, value) { + var setPageHeight = (API.setPageHeight = function ( + pageNumber: number, + value: number + ) { setPageHeightWithoutScaling(pageNumber, value * scaleFactor); }); @@ -6063,6 +6646,9 @@ function jsPDF(options) { * @public * @ignore */ + // Plugin modules augment jsPDFInternal with the members they stash on + // `internal` themselves (and `pageSize`'s width/height accessors are + // attached right below), so the literal is asserted onto the interface. API.internal = { pdfEscape: pdfEscape, getStyle: getStyle, @@ -6088,16 +6674,16 @@ function jsPDF(options) { events: events, scaleFactor: scaleFactor, pageSize: { - getWidth: function() { + getWidth: function () { return getPageWidth(currentPage); }, - setWidth: function(value) { + setWidth: function (value: number) { setPageWidth(currentPage, value); }, - getHeight: function() { + getHeight: function () { return getPageHeight(currentPage); }, - setHeight: function(value) { + setHeight: function (value: number) { setPageHeight(currentPage, value); } }, @@ -6120,23 +6706,26 @@ function jsPDF(options) { Rectangle: Rectangle, Matrix: Matrix, hasHotfix: hasHotfix //Expose the hasHotfix check so plugins can also check them. - }; + // The interface carries members merged in by plugin augmentations (and + // `pageSize` width/height accessors attached below), so a direct + // assertion cannot see enough overlap. + } as unknown as jsPDFInternal; Object.defineProperty(API.internal.pageSize, "width", { - get: function() { + get: function () { return getPageWidth(currentPage); }, - set: function(value) { + set: function (value: number) { setPageWidth(currentPage, value); }, enumerable: true, configurable: true }); Object.defineProperty(API.internal.pageSize, "height", { - get: function() { + get: function () { return getPageHeight(currentPage); }, - set: function(value) { + set: function (value: number) { setPageHeight(currentPage, value); }, enumerable: true, @@ -6178,9 +6767,11 @@ function jsPDF(options) { * var pdfdoc = new jsPDF() * pdfdoc.mymethod() // <- !!!!!! */ +// Plugins keep merging members into jsPDF.API through jsPDFAPI module +// augmentation; only the events list exists at this point. jsPDF.API = { events: [] -} as any; +} as jsPDFAPI; /** * The version of jsPDF. * @name version diff --git a/src/libs/BMPDecoder.ts b/src/libs/BMPDecoder.ts index 872c8d1b1..ec3302175 100644 --- a/src/libs/BMPDecoder.ts +++ b/src/libs/BMPDecoder.ts @@ -7,278 +7,312 @@ import { console } from "./console.js"; -function BmpDecoder(buffer, is_with_alpha) { - this.pos = 0; - this.buffer = buffer; - this.datav = new DataView(buffer.buffer); - this.is_with_alpha = !!is_with_alpha; - this.bottom_up = true; - this.flag = - String.fromCharCode(this.buffer[0]) + String.fromCharCode(this.buffer[1]); - this.pos += 2; - if (["BM", "BA", "CI", "CP", "IC", "PT"].indexOf(this.flag) === -1) - throw new Error("Invalid BMP File"); - this.parseHeader(); - this.parseBGR(); +interface PaletteEntry { + red: number; + green: number; + blue: number; + quad: number; } -BmpDecoder.prototype.parseHeader = function() { - this.fileSize = this.datav.getUint32(this.pos, true); - this.pos += 4; - this.reserved = this.datav.getUint32(this.pos, true); - this.pos += 4; - this.offset = this.datav.getUint32(this.pos, true); - this.pos += 4; - this.headerSize = this.datav.getUint32(this.pos, true); - this.pos += 4; - this.width = this.datav.getUint32(this.pos, true); - this.pos += 4; - this.height = this.datav.getInt32(this.pos, true); - this.pos += 4; - this.planes = this.datav.getUint16(this.pos, true); - this.pos += 2; - this.bitPP = this.datav.getUint16(this.pos, true); - this.pos += 2; - this.compress = this.datav.getUint32(this.pos, true); - this.pos += 4; - this.rawSize = this.datav.getUint32(this.pos, true); - this.pos += 4; - this.hr = this.datav.getUint32(this.pos, true); - this.pos += 4; - this.vr = this.datav.getUint32(this.pos, true); - this.pos += 4; - this.colors = this.datav.getUint32(this.pos, true); - this.pos += 4; - this.importantColors = this.datav.getUint32(this.pos, true); - this.pos += 4; +class BmpDecoder { + declare pos: number; + declare buffer: Uint8Array; + declare datav: DataView; + declare is_with_alpha: boolean; + declare bottom_up: boolean; + declare flag: string; + declare fileSize: number; + declare reserved: number; + declare offset: number; + declare headerSize: number; + declare width: number; + declare height: number; + declare planes: number; + declare bitPP: number; + declare compress: number; + declare rawSize: number; + declare hr: number; + declare vr: number; + declare colors: number; + declare importantColors: number; + declare palette: PaletteEntry[]; + declare data: Uint8Array; - if (this.bitPP === 16 && this.is_with_alpha) { - this.bitPP = 15; + constructor(buffer: Uint8Array, is_with_alpha?: boolean) { + this.pos = 0; + this.buffer = buffer; + this.datav = new DataView(buffer.buffer); + this.is_with_alpha = !!is_with_alpha; + this.bottom_up = true; + this.flag = + String.fromCharCode(this.buffer[0]) + String.fromCharCode(this.buffer[1]); + this.pos += 2; + if (["BM", "BA", "CI", "CP", "IC", "PT"].indexOf(this.flag) === -1) + throw new Error("Invalid BMP File"); + this.parseHeader(); + this.parseBGR(); } - if (this.bitPP < 15) { - var len = this.colors === 0 ? 1 << this.bitPP : this.colors; - this.palette = new Array(len); - for (var i = 0; i < len; i++) { - var blue = this.datav.getUint8(this.pos++, true); - var green = this.datav.getUint8(this.pos++, true); - var red = this.datav.getUint8(this.pos++, true); - var quad = this.datav.getUint8(this.pos++, true); - this.palette[i] = { - red: red, - green: green, - blue: blue, - quad: quad - }; + + parseHeader(): void { + this.fileSize = this.datav.getUint32(this.pos, true); + this.pos += 4; + this.reserved = this.datav.getUint32(this.pos, true); + this.pos += 4; + this.offset = this.datav.getUint32(this.pos, true); + this.pos += 4; + this.headerSize = this.datav.getUint32(this.pos, true); + this.pos += 4; + this.width = this.datav.getUint32(this.pos, true); + this.pos += 4; + this.height = this.datav.getInt32(this.pos, true); + this.pos += 4; + this.planes = this.datav.getUint16(this.pos, true); + this.pos += 2; + this.bitPP = this.datav.getUint16(this.pos, true); + this.pos += 2; + this.compress = this.datav.getUint32(this.pos, true); + this.pos += 4; + this.rawSize = this.datav.getUint32(this.pos, true); + this.pos += 4; + this.hr = this.datav.getUint32(this.pos, true); + this.pos += 4; + this.vr = this.datav.getUint32(this.pos, true); + this.pos += 4; + this.colors = this.datav.getUint32(this.pos, true); + this.pos += 4; + this.importantColors = this.datav.getUint32(this.pos, true); + this.pos += 4; + + if (this.bitPP === 16 && this.is_with_alpha) { + this.bitPP = 15; + } + if (this.bitPP < 15) { + const len = this.colors === 0 ? 1 << this.bitPP : this.colors; + this.palette = new Array(len); + for (let i = 0; i < len; i++) { + const blue = this.datav.getUint8(this.pos++); + const green = this.datav.getUint8(this.pos++); + const red = this.datav.getUint8(this.pos++); + const quad = this.datav.getUint8(this.pos++); + this.palette[i] = { + red: red, + green: green, + blue: blue, + quad: quad + }; + } + } + if (this.height < 0) { + this.height *= -1; + this.bottom_up = false; } } - if (this.height < 0) { - this.height *= -1; - this.bottom_up = false; - } -}; -BmpDecoder.prototype.parseBGR = function() { - this.pos = this.offset; - var bitn = "bit" + this.bitPP; - var len = this.width * this.height * 4; + parseBGR(): void { + this.pos = this.offset; + const bitn = "bit" + this.bitPP; + const len = this.width * this.height * 4; - if (len > 512 * 1024 * 1024) { - throw new Error("Image dimensions exceed 512MB, which is too large."); - } + if (len > 512 * 1024 * 1024) { + throw new Error("Image dimensions exceed 512MB, which is too large."); + } - this.data = new Uint8Array(len); + this.data = new Uint8Array(len); - try { - this[bitn](); - } catch (e) { - console.log("bit decode error:" + e); + try { + // Dispatch by bit depth ("bit1" ... "bit32"); unknown depths throw and + // are reported below, matching the original dynamic-lookup behavior. + (this as unknown as Record void>)[bitn](); + } catch (e) { + console.log("bit decode error:" + e); + } } -}; -BmpDecoder.prototype.bit1 = function() { - var xlen = Math.ceil(this.width / 8); - var mode = xlen % 4; - var y; - for (y = this.height - 1; y >= 0; y--) { - var line = this.bottom_up ? y : this.height - 1 - y; - for (var x = 0; x < xlen; x++) { - var b = this.datav.getUint8(this.pos++, true); - var location = line * this.width * 4 + x * 8 * 4; - for (var i = 0; i < 8; i++) { - if (x * 8 + i < this.width) { - var rgb = this.palette[(b >> (7 - i)) & 0x1]; - this.data[location + i * 4] = rgb.blue; - this.data[location + i * 4 + 1] = rgb.green; - this.data[location + i * 4 + 2] = rgb.red; - this.data[location + i * 4 + 3] = 0xff; - } else { - break; + bit1(): void { + const xlen = Math.ceil(this.width / 8); + const mode = xlen % 4; + let y; + for (y = this.height - 1; y >= 0; y--) { + const line = this.bottom_up ? y : this.height - 1 - y; + for (let x = 0; x < xlen; x++) { + const b = this.datav.getUint8(this.pos++); + const location = line * this.width * 4 + x * 8 * 4; + for (let i = 0; i < 8; i++) { + if (x * 8 + i < this.width) { + const rgb = this.palette[(b >> (7 - i)) & 0x1]; + this.data[location + i * 4] = rgb.blue; + this.data[location + i * 4 + 1] = rgb.green; + this.data[location + i * 4 + 2] = rgb.red; + this.data[location + i * 4 + 3] = 0xff; + } else { + break; + } } } - } - if (mode !== 0) { - this.pos += 4 - mode; + if (mode !== 0) { + this.pos += 4 - mode; + } } } -}; -BmpDecoder.prototype.bit4 = function() { - var xlen = Math.ceil(this.width / 2); - var mode = xlen % 4; - for (var y = this.height - 1; y >= 0; y--) { - var line = this.bottom_up ? y : this.height - 1 - y; - for (var x = 0; x < xlen; x++) { - var b = this.datav.getUint8(this.pos++, true); - var location = line * this.width * 4 + x * 2 * 4; + bit4(): void { + const xlen = Math.ceil(this.width / 2); + const mode = xlen % 4; + for (let y = this.height - 1; y >= 0; y--) { + const line = this.bottom_up ? y : this.height - 1 - y; + for (let x = 0; x < xlen; x++) { + const b = this.datav.getUint8(this.pos++); + const location = line * this.width * 4 + x * 2 * 4; - var before = b >> 4; - var after = b & 0x0f; + const before = b >> 4; + const after = b & 0x0f; - var rgb = this.palette[before]; - this.data[location] = rgb.blue; - this.data[location + 1] = rgb.green; - this.data[location + 2] = rgb.red; - this.data[location + 3] = 0xff; + let rgb = this.palette[before]; + this.data[location] = rgb.blue; + this.data[location + 1] = rgb.green; + this.data[location + 2] = rgb.red; + this.data[location + 3] = 0xff; - if (x * 2 + 1 >= this.width) break; + if (x * 2 + 1 >= this.width) break; - rgb = this.palette[after]; - this.data[location + 4] = rgb.blue; - this.data[location + 4 + 1] = rgb.green; - this.data[location + 4 + 2] = rgb.red; - this.data[location + 4 + 3] = 0xff; - } + rgb = this.palette[after]; + this.data[location + 4] = rgb.blue; + this.data[location + 4 + 1] = rgb.green; + this.data[location + 4 + 2] = rgb.red; + this.data[location + 4 + 3] = 0xff; + } - if (mode !== 0) { - this.pos += 4 - mode; + if (mode !== 0) { + this.pos += 4 - mode; + } } } -}; -BmpDecoder.prototype.bit8 = function() { - var mode = this.width % 4; - for (var y = this.height - 1; y >= 0; y--) { - var line = this.bottom_up ? y : this.height - 1 - y; - for (var x = 0; x < this.width; x++) { - var b = this.datav.getUint8(this.pos++, true); - var location = line * this.width * 4 + x * 4; - if (b < this.palette.length) { - var rgb = this.palette[b]; - this.data[location] = rgb.red; - this.data[location + 1] = rgb.green; - this.data[location + 2] = rgb.blue; - this.data[location + 3] = 0xff; - } else { - this.data[location] = 0xff; - this.data[location + 1] = 0xff; - this.data[location + 2] = 0xff; - this.data[location + 3] = 0xff; + bit8(): void { + const mode = this.width % 4; + for (let y = this.height - 1; y >= 0; y--) { + const line = this.bottom_up ? y : this.height - 1 - y; + for (let x = 0; x < this.width; x++) { + const b = this.datav.getUint8(this.pos++); + const location = line * this.width * 4 + x * 4; + if (b < this.palette.length) { + const rgb = this.palette[b]; + this.data[location] = rgb.red; + this.data[location + 1] = rgb.green; + this.data[location + 2] = rgb.blue; + this.data[location + 3] = 0xff; + } else { + this.data[location] = 0xff; + this.data[location + 1] = 0xff; + this.data[location + 2] = 0xff; + this.data[location + 3] = 0xff; + } + } + if (mode !== 0) { + this.pos += 4 - mode; } - } - if (mode !== 0) { - this.pos += 4 - mode; } } -}; -BmpDecoder.prototype.bit15 = function() { - var dif_w = this.width % 3; - var _11111 = parseInt("11111", 2), - _1_5 = _11111; - for (var y = this.height - 1; y >= 0; y--) { - var line = this.bottom_up ? y : this.height - 1 - y; - for (var x = 0; x < this.width; x++) { - var B = this.datav.getUint16(this.pos, true); - this.pos += 2; - var blue = (((B & _1_5) / _1_5) * 255) | 0; - var green = ((((B >> 5) & _1_5) / _1_5) * 255) | 0; - var red = ((((B >> 10) & _1_5) / _1_5) * 255) | 0; - var alpha = B >> 15 ? 0xff : 0x00; + bit15(): void { + const dif_w = this.width % 3; + const _11111 = parseInt("11111", 2), + _1_5 = _11111; + for (let y = this.height - 1; y >= 0; y--) { + const line = this.bottom_up ? y : this.height - 1 - y; + for (let x = 0; x < this.width; x++) { + const B = this.datav.getUint16(this.pos, true); + this.pos += 2; + const blue = (((B & _1_5) / _1_5) * 255) | 0; + const green = ((((B >> 5) & _1_5) / _1_5) * 255) | 0; + const red = ((((B >> 10) & _1_5) / _1_5) * 255) | 0; + const alpha = B >> 15 ? 0xff : 0x00; - var location = line * this.width * 4 + x * 4; - this.data[location] = red; - this.data[location + 1] = green; - this.data[location + 2] = blue; - this.data[location + 3] = alpha; + const location = line * this.width * 4 + x * 4; + this.data[location] = red; + this.data[location + 1] = green; + this.data[location + 2] = blue; + this.data[location + 3] = alpha; + } + //skip extra bytes + this.pos += dif_w; } - //skip extra bytes - this.pos += dif_w; } -}; -BmpDecoder.prototype.bit16 = function() { - var dif_w = this.width % 3; - var _11111 = parseInt("11111", 2), - _1_5 = _11111; - var _111111 = parseInt("111111", 2), - _1_6 = _111111; - for (var y = this.height - 1; y >= 0; y--) { - var line = this.bottom_up ? y : this.height - 1 - y; - for (var x = 0; x < this.width; x++) { - var B = this.datav.getUint16(this.pos, true); - this.pos += 2; - var alpha = 0xff; - var blue = (((B & _1_5) / _1_5) * 255) | 0; - var green = ((((B >> 5) & _1_6) / _1_6) * 255) | 0; - var red = (((B >> 11) / _1_5) * 255) | 0; + bit16(): void { + const dif_w = this.width % 3; + const _11111 = parseInt("11111", 2), + _1_5 = _11111; + const _111111 = parseInt("111111", 2), + _1_6 = _111111; + for (let y = this.height - 1; y >= 0; y--) { + const line = this.bottom_up ? y : this.height - 1 - y; + for (let x = 0; x < this.width; x++) { + const B = this.datav.getUint16(this.pos, true); + this.pos += 2; + const alpha = 0xff; + const blue = (((B & _1_5) / _1_5) * 255) | 0; + const green = ((((B >> 5) & _1_6) / _1_6) * 255) | 0; + const red = (((B >> 11) / _1_5) * 255) | 0; - var location = line * this.width * 4 + x * 4; - this.data[location] = red; - this.data[location + 1] = green; - this.data[location + 2] = blue; - this.data[location + 3] = alpha; + const location = line * this.width * 4 + x * 4; + this.data[location] = red; + this.data[location + 1] = green; + this.data[location + 2] = blue; + this.data[location + 3] = alpha; + } + //skip extra bytes + this.pos += dif_w; } - //skip extra bytes - this.pos += dif_w; } -}; -BmpDecoder.prototype.bit24 = function() { - //when height > 0 - for (var y = this.height - 1; y >= 0; y--) { - var line = this.bottom_up ? y : this.height - 1 - y; - for (var x = 0; x < this.width; x++) { - var blue = this.datav.getUint8(this.pos++, true); - var green = this.datav.getUint8(this.pos++, true); - var red = this.datav.getUint8(this.pos++, true); - var location = line * this.width * 4 + x * 4; - this.data[location] = red; - this.data[location + 1] = green; - this.data[location + 2] = blue; - this.data[location + 3] = 0xff; + bit24(): void { + //when height > 0 + for (let y = this.height - 1; y >= 0; y--) { + const line = this.bottom_up ? y : this.height - 1 - y; + for (let x = 0; x < this.width; x++) { + const blue = this.datav.getUint8(this.pos++); + const green = this.datav.getUint8(this.pos++); + const red = this.datav.getUint8(this.pos++); + const location = line * this.width * 4 + x * 4; + this.data[location] = red; + this.data[location + 1] = green; + this.data[location + 2] = blue; + this.data[location + 3] = 0xff; + } + //skip extra bytes + this.pos += this.width % 4; } - //skip extra bytes - this.pos += this.width % 4; } -}; -/** - * add 32bit decode func - * @author soubok - */ -BmpDecoder.prototype.bit32 = function() { - //when height > 0 - for (var y = this.height - 1; y >= 0; y--) { - var line = this.bottom_up ? y : this.height - 1 - y; - for (var x = 0; x < this.width; x++) { - var blue = this.datav.getUint8(this.pos++, true); - var green = this.datav.getUint8(this.pos++, true); - var red = this.datav.getUint8(this.pos++, true); - var alpha = this.datav.getUint8(this.pos++, true); - var location = line * this.width * 4 + x * 4; - this.data[location] = red; - this.data[location + 1] = green; - this.data[location + 2] = blue; - this.data[location + 3] = alpha; + /** + * add 32bit decode func + * @author soubok + */ + bit32(): void { + //when height > 0 + for (let y = this.height - 1; y >= 0; y--) { + const line = this.bottom_up ? y : this.height - 1 - y; + for (let x = 0; x < this.width; x++) { + const blue = this.datav.getUint8(this.pos++); + const green = this.datav.getUint8(this.pos++); + const red = this.datav.getUint8(this.pos++); + const alpha = this.datav.getUint8(this.pos++); + const location = line * this.width * 4 + x * 4; + this.data[location] = red; + this.data[location + 1] = green; + this.data[location + 2] = blue; + this.data[location + 3] = alpha; + } + //skip extra bytes + //this.pos += (this.width % 4); } - //skip extra bytes - //this.pos += (this.width % 4); } -}; -BmpDecoder.prototype.getData = function() { - return this.data; -}; + getData(): Uint8Array { + return this.data; + } +} export { BmpDecoder }; diff --git a/src/libs/Blob.ts b/src/libs/Blob.ts index 256e7f825..f102f5f14 100644 --- a/src/libs/Blob.ts +++ b/src/libs/Blob.ts @@ -10,27 +10,79 @@ * See https://github.com/eligrey/Blob.js/blob/master/LICENSE.md */ -import { globalObject as global } from "./globalObject.js"; +import { globalObject } from "./globalObject.js"; + +// The polyfill installs (and reads back) implementations on the global, +// including vendor-prefixed and pre-standard slots the DOM lib does not +// declare, and deliberately overwrites standard slots with fakes. A loose +// writable view at this single boundary keeps the rest of the file typed. +type PolyfillCtor = { + // Loose constructable/callable shape shared by the native constructors and + // the polyfill replacements this file installs. + new (...args: never[]): unknown; + prototype: Record; +} & Record; + +const global = globalObject as unknown as Record & { + URL: { + createObjectURL(obj: unknown): string; + revokeObjectURL(url: string): void; + } & Record; + webkitURL?: unknown; + Blob: PolyfillCtor; + File: PolyfillCtor; + FileReader: PolyfillCtor; + Symbol?: { toStringTag?: symbol } & Record; + ArrayBuffer?: unknown; + XMLHttpRequest?: PolyfillCtor; +}; + +/** Internal shape of the polyfilled Blob: raw bytes plus Blob metadata. */ +interface FakeBlob { + _buffer: number[]; + size: number; + type: string; +} + +interface FakeFile extends FakeBlob { + name: string; + lastModifiedDate: Date; + lastModified: number; +} -var BlobBuilder = - global.BlobBuilder || +interface FakeFileReader { + addEventListener: EventTarget["addEventListener"]; + removeEventListener: EventTarget["removeEventListener"]; + dispatchEvent: (evt: Event) => void; + result: string | number[]; + [handler: string]: unknown; +} + +// Vendor-prefixed pre-standard builders; constructable with no arguments. +var BlobBuilder = (global.BlobBuilder || global.WebKitBlobBuilder || global.MSBlobBuilder || - global.MozBlobBuilder; + global.MozBlobBuilder) as unknown as { + new (): { append(part: unknown): void; getBlob(type?: string): Blob }; + prototype: Record; +}; -global.URL = - global.URL || +global.URL = (global.URL || global.webkitURL || - function(href, a) { + function (href: string, a?: HTMLAnchorElement) { a = document.createElement("a"); a.href = href; return a; - }; + // the anchor-based fallback only ever has createObjectURL called on it + }) as typeof global.URL; -var origBlob = global.Blob; +// The native constructor captured before this file installs replacements. +var origBlob = global.Blob as unknown as { + new (parts: unknown[], options?: BlobPropertyBag): Blob; +}; var createObjectURL = URL.createObjectURL; var revokeObjectURL = URL.revokeObjectURL; -var strTag = global.Symbol && global.Symbol.toStringTag; +var strTag = (global.Symbol && global.Symbol.toStringTag) as symbol; var blobSupported = false; var blobSupportsArrayBufferView = false; var arrayBufferSupported = !!global.ArrayBuffer; @@ -51,16 +103,18 @@ try { * Used by BlobBuilder constructor and old browsers that didn't * support it in the Blob constructor. */ -function mapArrayBufferViews(ary) { - return ary.map(function(chunk) { - if (chunk.buffer instanceof ArrayBuffer) { - var buf = chunk.buffer; +function mapArrayBufferViews(ary: BlobPart[]): BlobPart[] { + return ary.map(function (chunk) { + // Structural probe: non-view parts simply fail the instanceof test below. + var view = chunk as ArrayBufferView; + if (view.buffer instanceof ArrayBuffer) { + var buf = view.buffer; // if this is a subarray, make a copy so we only // include the subarray region from the underlying buffer - if (chunk.byteLength !== buf.byteLength) { - var copy = new Uint8Array(chunk.byteLength); - copy.set(new Uint8Array(buf, chunk.byteOffset, chunk.byteLength)); + if (view.byteLength !== buf.byteLength) { + var copy = new Uint8Array(view.byteLength); + copy.set(new Uint8Array(buf, view.byteOffset, view.byteLength)); buf = copy.buffer; } @@ -71,18 +125,18 @@ function mapArrayBufferViews(ary) { }); } -function BlobBuilderConstructor(ary, options) { +function BlobBuilderConstructor(ary: BlobPart[], options?: BlobPropertyBag) { options = options || {}; var bb = new BlobBuilder(); - mapArrayBufferViews(ary).forEach(function(part) { + mapArrayBufferViews(ary).forEach(function (part) { bb.append(part); }); return options.type ? bb.getBlob(options.type) : bb.getBlob(); } -function BlobConstructor(ary, options) { +function BlobConstructor(ary: BlobPart[], options?: BlobPropertyBag) { return new origBlob(mapArrayBufferViews(ary), options || {}); } @@ -92,8 +146,8 @@ if (global.Blob) { } function FakeBlobBuilder() { - function toUTF8Array(str) { - var utf8 = []; + function toUTF8Array(str: string): number[] { + var utf8: number[] = []; for (var i = 0; i < str.length; i++) { var charcode = str.charCodeAt(i); if (charcode < 0x80) utf8.push(charcode); @@ -124,7 +178,7 @@ function FakeBlobBuilder() { } return utf8; } - function fromUtf8Array(array) { + function fromUtf8Array(array: number[]): string { var out, i, len, c; var char2, char3; @@ -163,10 +217,10 @@ function FakeBlobBuilder() { } return out; } - function isDataView(obj) { - return obj && DataView.prototype.isPrototypeOf(obj); + function isDataView(obj: unknown): boolean { + return !!obj && DataView.prototype.isPrototypeOf(obj as object); } - function bufferClone(buf) { + function bufferClone(buf: ArrayBufferLike): number[] { var view = new Array(buf.byteLength); var array = new Uint8Array(buf); var i = view.length; @@ -175,7 +229,7 @@ function FakeBlobBuilder() { } return view; } - function encodeByteArray(input) { + function encodeByteArray(input: number[]): string { var byteToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; @@ -214,10 +268,12 @@ function FakeBlobBuilder() { var create = Object.create || - function(a) { + function (a: object) { function c() {} c.prototype = a; - return new c(); + // ES5 constructor-function pattern: a plain function declaration has no + // construct signature, so cast to a constructor type for `new`. + return new (c as unknown as { new (): object })(); }; if (arrayBufferSupported) { @@ -235,9 +291,9 @@ function FakeBlobBuilder() { var isArrayBufferView = ArrayBuffer.isView || - function(obj) { + function (obj: unknown): boolean { return ( - obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1 + !!obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1 ); }; } @@ -245,46 +301,67 @@ function FakeBlobBuilder() { /********************************************************/ /* Blob constructor */ /********************************************************/ - function Blob(chunks, opts) { + function Blob(this: FakeBlob, chunks?: unknown[], opts?: BlobPropertyBag) { chunks = chunks || []; for (var i = 0, len = chunks.length; i < len; i++) { var chunk = chunks[i]; if (chunk instanceof Blob) { - chunks[i] = (chunk as any)._buffer; + chunks[i] = (chunk as unknown as FakeBlob)._buffer; } else if (typeof chunk === "string") { chunks[i] = toUTF8Array(chunk); } else if ( arrayBufferSupported && - (ArrayBuffer.prototype.isPrototypeOf(chunk) || isArrayBufferView(chunk)) + (ArrayBuffer.prototype.isPrototypeOf(chunk as object) || + isArrayBufferView(chunk)) ) { - chunks[i] = bufferClone(chunk); + // Guarded by the isPrototypeOf/isView checks on the previous lines. + chunks[i] = bufferClone(chunk as ArrayBufferLike); } else if (arrayBufferSupported && isDataView(chunk)) { - chunks[i] = bufferClone(chunk.buffer); + chunks[i] = bufferClone((chunk as DataView).buffer); } else { chunks[i] = toUTF8Array(String(chunk)); } } - this._buffer = [].concat.apply([], chunks); + // Every chunk has been normalized to number[] by the loop above. + this._buffer = ([] as number[]).concat.apply([], chunks as number[][]); this.size = this._buffer.length; this.type = opts ? opts.type || "" : ""; } - Blob.prototype.slice = function(start, end, type) { + // The fake constructors below are ES5 constructor functions; plain function + // declarations have no construct signature, so cast for `new` call sites. + var FakeBlobConstructor = Blob as unknown as { + new (chunks?: unknown[], opts?: BlobPropertyBag): FakeBlob; + }; + + Blob.prototype.slice = function ( + this: FakeBlob, + start?: number, + end?: number, + type?: string + ) { var slice = this._buffer.slice(start || 0, end || this._buffer.length); - return new Blob([slice], { type: type }); + return new FakeBlobConstructor([slice], { type: type }); }; - Blob.prototype.toString = function() { + Blob.prototype.toString = function () { return "[object Blob]"; }; /********************************************************/ /* File constructor */ /********************************************************/ - function File(chunks, name, opts) { + function File( + this: FakeFile, + chunks: unknown[], + name: string, + opts?: FilePropertyBag + ) { opts = opts || {}; - var a = (Blob as any).call(this, chunks, opts) || this; + // `Blob.call` returns void per its signature but may return an object at + // runtime; keep the original `|| this` fallback via a cast. + var a = (Blob.call(this, chunks, opts) as unknown as FakeFile) || this; a.name = name; a.lastModifiedDate = opts.lastModified ? new Date(opts.lastModified) @@ -300,18 +377,19 @@ function FakeBlobBuilder() { if (Object.setPrototypeOf) Object.setPrototypeOf(File, Blob); else { try { - File.__proto__ = Blob; + // Legacy engines without setPrototypeOf; __proto__ is not in lib.dom. + (File as unknown as { __proto__: unknown }).__proto__ = Blob; } catch (e) {} } - File.prototype.toString = function() { + File.prototype.toString = function () { return "[object File]"; }; /********************************************************/ /* FileReader constructor */ /********************************************************/ - function FileReader() { + function FileReader(this: FakeFileReader) { if (!(this instanceof FileReader)) throw new TypeError( "Failed to construct 'FileReader': Please use the 'new' operator, this DOM object constructor cannot be called as a function." @@ -319,7 +397,7 @@ function FakeBlobBuilder() { var delegate = document.createDocumentFragment(); this.addEventListener = delegate.addEventListener; - this.dispatchEvent = function(evt) { + this.dispatchEvent = function (this: FakeFileReader, evt: Event) { var local = this["on" + evt.type]; if (typeof local === "function") local(evt); delegate.dispatchEvent(evt); @@ -327,7 +405,7 @@ function FakeBlobBuilder() { this.removeEventListener = delegate.removeEventListener; } - function _read(fr, blob, kind) { + function _read(fr: FakeFileReader, blob: FakeBlob, kind: string) { if (!(blob instanceof Blob)) throw new TypeError( "Failed to execute '" + @@ -337,7 +415,7 @@ function FakeBlobBuilder() { fr.result = ""; - setTimeout(function() { + setTimeout(function (this: { readyState?: number }) { this.readyState = FileReader.LOADING; fr.dispatchEvent(new Event("load")); fr.dispatchEvent(new Event("loadend")); @@ -355,65 +433,92 @@ function FakeBlobBuilder() { FileReader.prototype.onloadstart = null; FileReader.prototype.onprogress = null; - FileReader.prototype.readAsDataURL = function(blob) { + FileReader.prototype.readAsDataURL = function ( + this: FakeFileReader, + blob: FakeBlob + ) { _read(this, blob, "readAsDataURL"); this.result = "data:" + blob.type + ";base64," + encodeByteArray(blob._buffer); }; - FileReader.prototype.readAsText = function(blob) { + FileReader.prototype.readAsText = function ( + this: FakeFileReader, + blob: FakeBlob + ) { _read(this, blob, "readAsText"); this.result = fromUtf8Array(blob._buffer); }; - FileReader.prototype.readAsArrayBuffer = function(blob) { + FileReader.prototype.readAsArrayBuffer = function ( + this: FakeFileReader, + blob: FakeBlob + ) { _read(this, blob, "readAsText"); this.result = blob._buffer.slice(); }; - FileReader.prototype.abort = function() {}; + FileReader.prototype.abort = function () {}; /********************************************************/ /* URL */ /********************************************************/ - URL.createObjectURL = function(blob: any) { + URL.createObjectURL = function (blob: Blob | MediaSource): string { return blob instanceof Blob ? "data:" + - (blob as any).type + + // The fake Blob polyfill stores its bytes on `_buffer`; the DOM + // Blob type has no such member, hence the cast. + (blob as unknown as FakeBlob).type + ";base64," + - encodeByteArray((blob as any)._buffer) + encodeByteArray((blob as unknown as FakeBlob)._buffer) : createObjectURL.call(URL, blob); }; - URL.revokeObjectURL = function(url) { + URL.revokeObjectURL = function (url: string) { revokeObjectURL && revokeObjectURL.call(URL, url); }; /********************************************************/ /* XHR */ /********************************************************/ - var _send = global.XMLHttpRequest && global.XMLHttpRequest.prototype.send; + var _send = (global.XMLHttpRequest && + global.XMLHttpRequest.prototype.send) as unknown as ( + this: XMLHttpRequest, + data?: Document | XMLHttpRequestBodyInit | null + ) => void; if (_send) { - XMLHttpRequest.prototype.send = function(data: any) { + XMLHttpRequest.prototype.send = function ( + this: XMLHttpRequest, + data?: Document | XMLHttpRequestBodyInit | null + ) { if (data instanceof Blob) { - this.setRequestHeader("Content-Type", (data as any).type); - _send.call(this, fromUtf8Array((data as any)._buffer)); + // The fake Blob polyfill stores its bytes on `_buffer`; the DOM + // Blob type has no such member, hence the cast. + this.setRequestHeader( + "Content-Type", + (data as unknown as FakeBlob).type + ); + _send.call(this, fromUtf8Array((data as unknown as FakeBlob)._buffer)); } else { _send.call(this, data); } }; } - global.FileReader = FileReader; - global.File = File; - global.Blob = Blob; + // Installing the fakes over the (differently-shaped) native slots. + global.FileReader = FileReader as unknown as PolyfillCtor; + global.File = File as unknown as PolyfillCtor; + global.Blob = Blob as unknown as PolyfillCtor; } if (strTag) { try { - File.prototype[strTag] = "File"; - Blob.prototype[strTag] = "Blob"; - FileReader.prototype[strTag] = "FileReader"; + // Symbol.toStringTag is not part of the declared Blob/File/FileReader + // prototype shapes in lib.dom, so widen via a symbol-keyed record. + (File.prototype as unknown as Record)[strTag] = "File"; + (Blob.prototype as unknown as Record)[strTag] = "Blob"; + (FileReader.prototype as unknown as Record)[strTag] = + "FileReader"; } catch (e) {} } @@ -433,10 +538,15 @@ function fixFileAndXHR() { "}};" + 'return new File([], ""), File' )(); - global.File = klass; + global.File = klass as unknown as PolyfillCtor; } catch (e) { - var klass: any = function(b, d, c) { - var blob: any = new Blob(b, c); + global.File = function (b: BlobPart[], d: string, c?: FilePropertyBag) { + var blob = new Blob(b, c) as Blob & { + name?: string; + lastModifiedDate?: Date; + lastModified?: number; + [key: symbol]: unknown; + }; var t = c && void 0 !== c.lastModified ? new Date(c.lastModified) @@ -445,25 +555,26 @@ function fixFileAndXHR() { blob.name = d; blob.lastModifiedDate = t; blob.lastModified = +t; - blob.toString = function() { + blob.toString = function () { return "[object File]"; }; if (strTag) blob[strTag] = "File"; return blob; - }; - global.File = klass; + } as unknown as PolyfillCtor; } } } if (blobSupported) { fixFileAndXHR(); - global.Blob = blobSupportsArrayBufferView ? global.Blob : BlobConstructor; + global.Blob = (blobSupportsArrayBufferView + ? global.Blob + : BlobConstructor) as unknown as PolyfillCtor; } else if (blobBuilderSupported) { fixFileAndXHR(); - global.Blob = BlobBuilderConstructor; + global.Blob = BlobBuilderConstructor as unknown as PolyfillCtor; } else { FakeBlobBuilder(); } diff --git a/src/libs/FileSaver.ts b/src/libs/FileSaver.ts index 001a664c9..75414076b 100644 --- a/src/libs/FileSaver.ts +++ b/src/libs/FileSaver.ts @@ -9,10 +9,33 @@ * source : http://purl.eligrey.com/github/FileSaver.js */ -import { globalObject as _global } from "./globalObject.js"; +import { globalObject } from "./globalObject.js"; + +// Loose view of the global for feature-detection of non-standard members +// (saveAs, webkitURL, safari, msSaveOrOpenBlob hosts). +const _global = globalObject as unknown as Record & { + URL?: typeof URL; + webkitURL?: typeof URL; + HTMLElement?: typeof HTMLElement; + saveAs?: unknown; + safari?: unknown; +}; import { console } from "./console.js"; -function bom(blob, opts) { +interface BomOptions { + autoBom: boolean; +} + +type SaveAsOptions = BomOptions | boolean; + +type SaveAsFunction = ( + blob?: Blob | string, + name?: string, + opts?: SaveAsOptions, + popup?: Window | null +) => void; + +function bom(blob: Blob, opts?: SaveAsOptions): Blob { if (typeof opts === "undefined") opts = { autoBom: false }; else if (typeof opts !== "object") { console.warn("Deprecated: Expected third argument to be a object"); @@ -32,20 +55,20 @@ function bom(blob, opts) { return blob; } -function download(url, name, opts) { +function download(url: string, name: string, opts?: SaveAsOptions) { var xhr = new XMLHttpRequest(); xhr.open("GET", url); xhr.responseType = "blob"; - xhr.onload = function() { + xhr.onload = function () { saveAs(xhr.response, name, opts); }; - xhr.onerror = function() { + xhr.onerror = function () { console.error("could not download file"); }; xhr.send(); } -function corsEnabled(url) { +function corsEnabled(url: string): boolean { var xhr = new XMLHttpRequest(); // use sync to avoid popup blocker xhr.open("HEAD", url, false); @@ -56,7 +79,7 @@ function corsEnabled(url) { } // `a.click()` doesn't work for all browsers (#465) -function click(node, _unused?: any) { +function click(node: HTMLElement, _unused?: unknown) { try { node.dispatchEvent(new MouseEvent("click")); } catch (e) { @@ -82,111 +105,144 @@ function click(node, _unused?: any) { } } -var saveAs = - _global.saveAs || +var saveAs: SaveAsFunction = + // a host-provided implementation wins (also how the worker shim injects one) + (_global.saveAs as SaveAsFunction | undefined) || // probably in some web worker - (typeof window !== "object" || window !== _global + (typeof window !== "object" || (window as unknown) !== (_global as unknown) ? function saveAs() { /* noop */ } : // Use download attribute first if possible (#193 Lumia mobile) unless this is a native app - typeof HTMLAnchorElement !== "undefined" && - "download" in HTMLAnchorElement.prototype - ? function saveAs(blob, name, opts) { - var URL = _global.URL || _global.webkitURL; - var a = document.createElement("a"); - name = name || blob.name || "download"; - - a.download = name; - a.rel = "noopener"; // tabnabbing - - // TODO: detect chrome extensions & packaged apps - // a.target = '_blank' - - if (typeof blob === "string") { - // Support regular links - a.href = blob; - if (a.origin !== location.origin) { - corsEnabled(a.href) - ? download(blob, name, opts) - : click(a, (a.target = "_blank")); - } else { - click(a); - } - } else { - // Support blobs - a.href = URL.createObjectURL(blob); - setTimeout(function() { - URL.revokeObjectURL(a.href); - }, 4e4); // 40s - setTimeout(function() { - click(a); - }, 0); - } - } - : // Use msSaveOrOpenBlob as a second approach - "msSaveOrOpenBlob" in navigator - ? function saveAs(blob, name, opts) { - name = name || blob.name || "download"; - - if (typeof blob === "string") { - if (corsEnabled(blob)) { - download(blob, name, opts); - } else { - var a = document.createElement("a"); + typeof HTMLAnchorElement !== "undefined" && + "download" in HTMLAnchorElement.prototype + ? function saveAs( + blob: Blob | string, + name?: string, + opts?: SaveAsOptions + ) { + var URL = _global.URL || _global.webkitURL; + var a = document.createElement("a"); + // `name` is only present on File instances, but the original code + // probes every Blob for it; string blobs simply yield undefined. + name = name || (blob as File).name || "download"; + + a.download = name; + a.rel = "noopener"; // tabnabbing + + // TODO: detect chrome extensions & packaged apps + // a.target = '_blank' + + if (typeof blob === "string") { + // Support regular links a.href = blob; - a.target = "_blank"; - setTimeout(function() { + if (a.origin !== location.origin) { + corsEnabled(a.href) + ? download(blob, name, opts) + : click(a, (a.target = "_blank")); + } else { click(a); - }); + } + } else { + // Support blobs + a.href = URL.createObjectURL(blob); + setTimeout(function () { + URL.revokeObjectURL(a.href); + }, 4e4); // 40s + setTimeout(function () { + click(a); + }, 0); } - } else { - (navigator as any).msSaveOrOpenBlob(bom(blob, opts), name); - } - } - : // Fallback to using FileReader and a popup - function saveAs(blob, name, opts, popup) { - // Open a popup immediately do go around popup blocker - // Mostly only available on user interaction and the fileReader is async so... - popup = popup || open("", "_blank"); - if (popup) { - popup.document.title = popup.document.body.innerText = - "downloading..."; } + : // Use msSaveOrOpenBlob as a second approach + "msSaveOrOpenBlob" in navigator + ? function saveAs( + blob: Blob | string, + name?: string, + opts?: SaveAsOptions + ) { + // `name` is only present on File instances (see above). + name = name || (blob as File).name || "download"; - if (typeof blob === "string") return download(blob, name, opts); + if (typeof blob === "string") { + if (corsEnabled(blob)) { + download(blob, name, opts); + } else { + var a = document.createElement("a"); + a.href = blob; + a.target = "_blank"; + setTimeout(function () { + click(a); + }); + } + } else { + // msSaveOrOpenBlob is an IE-only, nonstandard API absent from the + // DOM lib typings. + ( + navigator as unknown as { + msSaveOrOpenBlob: (blob: Blob, name: string) => void; + } + ).msSaveOrOpenBlob(bom(blob, opts), name); + } + } + : // Fallback to using FileReader and a popup + function saveAs( + blob: Blob | string, + name?: string, + opts?: SaveAsOptions, + popup?: Window | null + ) { + // Open a popup immediately do go around popup blocker + // Mostly only available on user interaction and the fileReader is async so... + popup = popup || open("", "_blank"); + if (popup) { + popup.document.title = popup.document.body.innerText = + "downloading..."; + } - var force = blob.type === "application/octet-stream"; - var isSafari = - /constructor/i.test(_global.HTMLElement) || _global.safari; - var isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent); + if (typeof blob === "string") return download(blob, name, opts); - if ( - (isChromeIOS || (force && isSafari)) && - typeof FileReader === "object" - ) { - // Safari doesn't allow downloading of blob URLs - var reader = new (FileReader as any)(); - reader.onloadend = function() { - var url = reader.result; - url = isChromeIOS - ? url - : url.replace(/^data:[^;]*;/, "data:attachment/file;"); - if (popup) popup.location.href = url; - else location = url; - popup = null; // reverse-tabnabbing #460 - }; - reader.readAsDataURL(blob); - } else { - var URL = _global.URL || _global.webkitURL; - var url = URL.createObjectURL(blob); - if (popup) popup.location = url; - else location.href = url; - popup = null; // reverse-tabnabbing #460 - setTimeout(function() { - URL.revokeObjectURL(url); - }, 4e4); // 40s - } - }); + var force = blob.type === "application/octet-stream"; + var isSafari = + // RegExp.prototype.test stringifies its argument; Safari's native-code + // constructor toString is what the sniff relies on. + /constructor/i.test(String(_global.HTMLElement)) || + _global.safari; + var isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent); + + if ( + (isChromeIOS || (force && isSafari)) && + typeof FileReader === "object" + ) { + // Safari doesn't allow downloading of blob URLs + // The `typeof FileReader === "object"` guard above narrows the + // constructor's declared function type away, so restore it. + var reader = new ( + FileReader as unknown as { + new (): FileReader; + } + )(); + reader.onloadend = function () { + // readAsDataURL always produces a string result. + var url = reader.result as string; + url = isChromeIOS + ? url + : url.replace(/^data:[^;]*;/, "data:attachment/file;"); + if (popup) popup.location.href = url; + else location.href = url; + popup = null; // reverse-tabnabbing #460 + }; + reader.readAsDataURL(blob); + } else { + var URL = _global.URL || _global.webkitURL; + var url = URL.createObjectURL(blob); + if (popup) popup.location = url; + else location.href = url; + popup = null; // reverse-tabnabbing #460 + setTimeout(function () { + URL.revokeObjectURL(url); + }, 4e4); // 40s + } + }); export { saveAs }; diff --git a/src/libs/JPEGEncoder.ts b/src/libs/JPEGEncoder.ts index 4b3af89e4..9cde819d4 100644 --- a/src/libs/JPEGEncoder.ts +++ b/src/libs/JPEGEncoder.ts @@ -36,573 +36,112 @@ JPEG encoder ported to JavaScript and optimized by Andreas Ritter, www.bytestrom Basic GUI blocking jpeg encoder */ -function JPEGEncoder(quality) { +/** + * Minimal structural stand-in for a canvas ImageData object: RGBA pixel + * bytes plus dimensions. + */ +interface ImageDataLike { + width: number; + height: number; + data: ArrayLike; +} + +interface JPEGEncoderInstance { + encode: ((image: ImageDataLike, quality?: number) => Uint8Array) & { + displayName?: string; + }; +} + +/** A Huffman table: sparse array mapping symbol -> [code value, code length]. */ +type HuffmanTable = number[][]; + +function JPEGEncoder(this: JPEGEncoderInstance, quality?: number) { var ffloor = Math.floor; - var YTable = new Array(64); - var UVTable = new Array(64); - var fdtbl_Y = new Array(64); - var fdtbl_UV = new Array(64); - var YDC_HT; - var UVDC_HT; - var YAC_HT; - var UVAC_HT; - - var bitcode = new Array(65535); - var category = new Array(65535); - var outputfDCTQuant = new Array(64); - var DU = new Array(64); - var byteout = []; + var YTable: number[] = new Array(64); + var UVTable: number[] = new Array(64); + var fdtbl_Y: number[] = new Array(64); + var fdtbl_UV: number[] = new Array(64); + var YDC_HT: HuffmanTable; + var UVDC_HT: HuffmanTable; + var YAC_HT: HuffmanTable; + var UVAC_HT: HuffmanTable; + + var bitcode: number[][] = new Array(65535); + var category: number[] = new Array(65535); + var outputfDCTQuant: number[] = new Array(64); + var DU: number[] = new Array(64); + var byteout: number[] = []; var bytenew = 0; var bytepos = 7; - var YDU = new Array(64); - var UDU = new Array(64); - var VDU = new Array(64); - var clt = new Array(256); - var RGB_YUV_TABLE = new Array(2048); - var currentQuality; + var YDU: number[] = new Array(64); + var UDU: number[] = new Array(64); + var VDU: number[] = new Array(64); + var clt: string[] = new Array(256); + var RGB_YUV_TABLE: number[] = new Array(2048); + var currentQuality: number; var ZigZag = [ - 0, - 1, - 5, - 6, - 14, - 15, - 27, - 28, - 2, - 4, - 7, - 13, - 16, - 26, - 29, - 42, - 3, - 8, - 12, - 17, - 25, - 30, - 41, - 43, - 9, - 11, - 18, - 24, - 31, - 40, - 44, - 53, - 10, - 19, - 23, - 32, - 39, - 45, - 52, - 54, - 20, - 22, - 33, - 38, - 46, - 51, - 55, - 60, - 21, - 34, - 37, - 47, - 50, - 56, - 59, - 61, - 35, - 36, - 48, - 49, - 57, - 58, - 62, - 63 + 0, 1, 5, 6, 14, 15, 27, 28, 2, 4, 7, 13, 16, 26, 29, 42, 3, 8, 12, 17, 25, + 30, 41, 43, 9, 11, 18, 24, 31, 40, 44, 53, 10, 19, 23, 32, 39, 45, 52, 54, + 20, 22, 33, 38, 46, 51, 55, 60, 21, 34, 37, 47, 50, 56, 59, 61, 35, 36, 48, + 49, 57, 58, 62, 63 ]; var std_dc_luminance_nrcodes = [ - 0, - 0, - 1, - 5, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0 + 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 ]; var std_dc_luminance_values = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; var std_ac_luminance_nrcodes = [ - 0, - 0, - 2, - 1, - 3, - 3, - 2, - 4, - 3, - 5, - 5, - 4, - 4, - 0, - 0, - 1, - 0x7d + 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d ]; var std_ac_luminance_values = [ - 0x01, - 0x02, - 0x03, - 0x00, - 0x04, - 0x11, - 0x05, - 0x12, - 0x21, - 0x31, - 0x41, - 0x06, - 0x13, - 0x51, - 0x61, - 0x07, - 0x22, - 0x71, - 0x14, - 0x32, - 0x81, - 0x91, - 0xa1, - 0x08, - 0x23, - 0x42, - 0xb1, - 0xc1, - 0x15, - 0x52, - 0xd1, - 0xf0, - 0x24, - 0x33, - 0x62, - 0x72, - 0x82, - 0x09, - 0x0a, - 0x16, - 0x17, - 0x18, - 0x19, - 0x1a, - 0x25, - 0x26, - 0x27, - 0x28, - 0x29, - 0x2a, - 0x34, - 0x35, - 0x36, - 0x37, - 0x38, - 0x39, - 0x3a, - 0x43, - 0x44, - 0x45, - 0x46, - 0x47, - 0x48, - 0x49, - 0x4a, - 0x53, - 0x54, - 0x55, - 0x56, - 0x57, - 0x58, - 0x59, - 0x5a, - 0x63, - 0x64, - 0x65, - 0x66, - 0x67, - 0x68, - 0x69, - 0x6a, - 0x73, - 0x74, - 0x75, - 0x76, - 0x77, - 0x78, - 0x79, - 0x7a, - 0x83, - 0x84, - 0x85, - 0x86, - 0x87, - 0x88, - 0x89, - 0x8a, - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9a, - 0xa2, - 0xa3, - 0xa4, - 0xa5, - 0xa6, - 0xa7, - 0xa8, - 0xa9, - 0xaa, - 0xb2, - 0xb3, - 0xb4, - 0xb5, - 0xb6, - 0xb7, - 0xb8, - 0xb9, - 0xba, - 0xc2, - 0xc3, - 0xc4, - 0xc5, - 0xc6, - 0xc7, - 0xc8, - 0xc9, - 0xca, - 0xd2, - 0xd3, - 0xd4, - 0xd5, - 0xd6, - 0xd7, - 0xd8, - 0xd9, - 0xda, - 0xe1, - 0xe2, - 0xe3, - 0xe4, - 0xe5, - 0xe6, - 0xe7, - 0xe8, - 0xe9, - 0xea, - 0xf1, - 0xf2, - 0xf3, - 0xf4, - 0xf5, - 0xf6, - 0xf7, - 0xf8, - 0xf9, - 0xfa + 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, + 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, + 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, + 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, + 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, + 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, + 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, + 0x76, 0x77, 0x78, 0x79, 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, + 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, + 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, + 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, + 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, + 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, + 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa ]; var std_dc_chrominance_nrcodes = [ - 0, - 0, - 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 0, - 0, - 0, - 0 + 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 ]; var std_dc_chrominance_values = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; var std_ac_chrominance_nrcodes = [ - 0, - 0, - 2, - 1, - 2, - 4, - 4, - 3, - 4, - 7, - 5, - 4, - 4, - 0, - 1, - 2, - 0x77 + 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 ]; var std_ac_chrominance_values = [ - 0x00, - 0x01, - 0x02, - 0x03, - 0x11, - 0x04, - 0x05, - 0x21, - 0x31, - 0x06, - 0x12, - 0x41, - 0x51, - 0x07, - 0x61, - 0x71, - 0x13, - 0x22, - 0x32, - 0x81, - 0x08, - 0x14, - 0x42, - 0x91, - 0xa1, - 0xb1, - 0xc1, - 0x09, - 0x23, - 0x33, - 0x52, - 0xf0, - 0x15, - 0x62, - 0x72, - 0xd1, - 0x0a, - 0x16, - 0x24, - 0x34, - 0xe1, - 0x25, - 0xf1, - 0x17, - 0x18, - 0x19, - 0x1a, - 0x26, - 0x27, - 0x28, - 0x29, - 0x2a, - 0x35, - 0x36, - 0x37, - 0x38, - 0x39, - 0x3a, - 0x43, - 0x44, - 0x45, - 0x46, - 0x47, - 0x48, - 0x49, - 0x4a, - 0x53, - 0x54, - 0x55, - 0x56, - 0x57, - 0x58, - 0x59, - 0x5a, - 0x63, - 0x64, - 0x65, - 0x66, - 0x67, - 0x68, - 0x69, - 0x6a, - 0x73, - 0x74, - 0x75, - 0x76, - 0x77, - 0x78, - 0x79, - 0x7a, - 0x82, - 0x83, - 0x84, - 0x85, - 0x86, - 0x87, - 0x88, - 0x89, - 0x8a, - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99, - 0x9a, - 0xa2, - 0xa3, - 0xa4, - 0xa5, - 0xa6, - 0xa7, - 0xa8, - 0xa9, - 0xaa, - 0xb2, - 0xb3, - 0xb4, - 0xb5, - 0xb6, - 0xb7, - 0xb8, - 0xb9, - 0xba, - 0xc2, - 0xc3, - 0xc4, - 0xc5, - 0xc6, - 0xc7, - 0xc8, - 0xc9, - 0xca, - 0xd2, - 0xd3, - 0xd4, - 0xd5, - 0xd6, - 0xd7, - 0xd8, - 0xd9, - 0xda, - 0xe2, - 0xe3, - 0xe4, - 0xe5, - 0xe6, - 0xe7, - 0xe8, - 0xe9, - 0xea, - 0xf2, - 0xf3, - 0xf4, - 0xf5, - 0xf6, - 0xf7, - 0xf8, - 0xf9, - 0xfa + 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, + 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, + 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15, 0x62, 0x72, 0xd1, + 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, + 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, + 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, + 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, + 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, + 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, + 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, + 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, + 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa ]; - function initQuantTables(sf) { + function initQuantTables(sf: number) { var YQT = [ - 16, - 11, - 10, - 16, - 24, - 40, - 51, - 61, - 12, - 12, - 14, - 19, - 26, - 58, - 60, - 55, - 14, - 13, - 16, - 24, - 40, - 57, - 69, - 56, - 14, - 17, - 22, - 29, - 51, - 87, - 80, - 62, - 18, - 22, - 37, - 56, - 68, - 109, - 103, - 77, - 24, - 35, - 55, - 64, - 81, - 104, - 113, - 92, - 49, - 64, - 78, - 87, - 103, - 121, - 120, - 101, - 72, - 92, - 95, - 98, - 112, - 100, - 103, - 99 + 16, 11, 10, 16, 24, 40, 51, 61, 12, 12, 14, 19, 26, 58, 60, 55, 14, 13, + 16, 24, 40, 57, 69, 56, 14, 17, 22, 29, 51, 87, 80, 62, 18, 22, 37, 56, + 68, 109, 103, 77, 24, 35, 55, 64, 81, 104, 113, 92, 49, 64, 78, 87, 103, + 121, 120, 101, 72, 92, 95, 98, 112, 100, 103, 99 ]; for (var i = 0; i < 64; i++) { @@ -611,70 +150,10 @@ function JPEGEncoder(quality) { YTable[ZigZag[i]] = t; } var UVQT = [ - 17, - 18, - 24, - 47, - 99, - 99, - 99, - 99, - 18, - 21, - 26, - 66, - 99, - 99, - 99, - 99, - 24, - 26, - 56, - 99, - 99, - 99, - 99, - 99, - 47, - 66, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99, - 99 + 17, 18, 24, 47, 99, 99, 99, 99, 18, 21, 26, 66, 99, 99, 99, 99, 24, 26, + 56, 99, 99, 99, 99, 99, 47, 66, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99 ]; for (var j = 0; j < 64; j++) { var u = ffloor((UVQT[j] * sf + 50) / 100); @@ -682,13 +161,7 @@ function JPEGEncoder(quality) { UVTable[ZigZag[j]] = u; } var aasf = [ - 1.0, - 1.387039845, - 1.306562965, - 1.175875602, - 1.0, - 0.785694958, - 0.5411961, + 1.0, 1.387039845, 1.306562965, 1.175875602, 1.0, 0.785694958, 0.5411961, 0.275899379 ]; var k = 0; @@ -701,10 +174,13 @@ function JPEGEncoder(quality) { } } - function computeHuffmanTbl(nrcodes, std_table) { + function computeHuffmanTbl( + nrcodes: number[], + std_table: number[] + ): HuffmanTable { var codevalue = 0; var pos_in_table = 0; - var HT = new Array(); + var HT: HuffmanTable = new Array(); for (var k = 1; k <= 16; k++) { for (var j = 1; j <= nrcodes[k]; j++) { HT[std_table[pos_in_table]] = []; @@ -774,7 +250,7 @@ function JPEGEncoder(quality) { } // IO functions - function writeBits(bs) { + function writeBits(bs: number[]) { var value = bs[0]; var posval = bs[1] - 1; while (posval >= 0) { @@ -796,18 +272,18 @@ function JPEGEncoder(quality) { } } - function writeByte(value) { + function writeByte(value: number) { //byteout.push(clt[value]); // write char directly instead of converting later byteout.push(value); } - function writeWord(value) { + function writeWord(value: number) { writeByte((value >> 8) & 0xff); writeByte(value & 0xff); } // DCT & quantization core - function fDCTQuant(data, fdtbl) { + function fDCTQuant(data: number[], fdtbl: number[]): number[] { var d0, d1, d2, d3, d4, d5, d6, d7; /* Pass 1: process rows. */ var dataOff = 0; @@ -925,7 +401,7 @@ function JPEGEncoder(quality) { } // Quantize/descale the coefficients - var fDCTQuant; + var fDCTQuant: number; for (i = 0; i < I64; ++i) { // Apply the quantization and scaling factor & Round to nearest integer fDCTQuant = data[i] * fdtbl[i]; @@ -953,7 +429,7 @@ function JPEGEncoder(quality) { writeByte(0); // thumbnheight } - function writeSOF0(width, height) { + function writeSOF0(width: number, height: number) { writeWord(0xffc0); // marker writeWord(17); // length, truecolor YUV JPG writeByte(8); // precision @@ -1036,7 +512,13 @@ function JPEGEncoder(quality) { writeByte(0); // Bf } - function processDU(CDU, fdtbl, DC, HTDC, HTAC) { + function processDU( + CDU: number[], + fdtbl: number[], + DC: number, + HTDC: HuffmanTable, + HTAC: HuffmanTable + ): number { var EOB = HTAC[0x00]; var M16zeroes = HTAC[0xf0]; var pos; @@ -1101,9 +583,9 @@ function JPEGEncoder(quality) { } } - this.encode = function( - image, - quality // image data object + this.encode = function ( + image: ImageDataLike, + quality?: number // image data object ) { if (quality) setQuality(quality); @@ -1205,7 +687,7 @@ function JPEGEncoder(quality) { // Do the bit alignment of the EOI marker if (bytepos >= 0) { - var fillbits = []; + var fillbits: number[] = []; fillbits[1] = bytepos + 1; fillbits[0] = (1 << (bytepos + 1)) - 1; writeBits(fillbits); @@ -1216,7 +698,7 @@ function JPEGEncoder(quality) { return new Uint8Array(byteout); }; - function setQuality(quality) { + function setQuality(quality: number) { quality = Math.min(Math.max(quality, 1), 100); if (currentQuality == quality) return; // don't recalc if unchanged @@ -1242,4 +724,10 @@ function JPEGEncoder(quality) { init(); } -export { JPEGEncoder }; +// ES5 constructor function: a plain function declaration carries no construct +// signature, so export it typed as a constructor for `new JPEGEncoder(...)`. +const JPEGEncoderConstructor = JPEGEncoder as unknown as { + new (quality?: number): JPEGEncoderInstance; +}; + +export { JPEGEncoderConstructor as JPEGEncoder }; diff --git a/src/libs/WebPDecoder.ts b/src/libs/WebPDecoder.ts index 3dc01ea7d..2a33de43d 100644 --- a/src/libs/WebPDecoder.ts +++ b/src/libs/WebPDecoder.ts @@ -82,18 +82,18 @@ function WebPDecoder(imageData) { J(H, 0, F); return H; } - var _WebPDecoder = function() { + var _WebPDecoder = function () { var self = this; function F() { V(55); } function L(a, b) { - for (var c = (1 << (b - 1)) >>> 0; a & c; ) c >>>= 1; + for (var c = (1 << (b - 1)) >>> 0; a & c;) c >>>= 1; return c ? (a & (c - 1)) + c : a; } function J(a, b, c, d, e) { x(!(d % c)); - do (d -= c), (a[b + d] = e); + do ((d -= c), (a[b + d] = e)); while (0 < d); } function H(a, b, c, d, e, f) { @@ -117,9 +117,15 @@ function WebPDecoder(imageData) { if (m[k] > 1 << k) return 0; n[k + 1] = n[k] + m[k]; } - for (l = 0; l < e; ++l) (k = d[l]), 0 < d[l] && (f[n[k]++] = l); + for (l = 0; l < e; ++l) ((k = d[l]), 0 < d[l] && (f[n[k]++] = l)); if (1 == n[15]) - return (d = new O()), (d.g = 0), (d.value = f[0]), J(a, g, 1, h, d), h; + return ( + (d = new O()), + (d.g = 0), + (d.value = f[0]), + J(a, g, 1, h, d), + h + ); var r = -1, q = h - 1, t = 0, @@ -135,11 +141,11 @@ function WebPDecoder(imageData) { p -= m[k]; if (0 > p) return 0; for (; 0 < m[k]; --m[k]) - (d = new O()), + ((d = new O()), (d.g = k), (d.value = f[l++]), J(a, g + t, e, w, d), - (t = L(t, k)); + (t = L(t, k))); } k = c + 1; for (e = 2; 15 >= k; ++k, e <<= 1) { @@ -152,7 +158,7 @@ function WebPDecoder(imageData) { if ((t & q) != r) { g += w; r = k; - for (u = 1 << (r - c); 15 > r; ) { + for (u = 1 << (r - c); 15 > r;) { u -= m[r]; if (0 >= u) break; ++r; @@ -207,7 +213,7 @@ function WebPDecoder(imageData) { Qa(a); } function na(a, b) { - for (var c = 0; 0 < b--; ) c |= K(a, 128) << b; + for (var c = 0; 0 < b--;) c |= K(a, 128) << b; return c; } function ca(a, b) { @@ -232,11 +238,11 @@ function WebPDecoder(imageData) { a.pa = c; } function Vb(a) { - for (; 8 <= a.u && a.bb < a.Sb; ) - (a.Ra >>>= 8), + for (; 8 <= a.u && a.bb < a.Sb;) + ((a.Ra >>>= 8), (a.Ra += (a.oa[a.pa + a.bb] << (ob - 8)) >>> 0), ++a.bb, - (a.u -= 8); + (a.u -= 8)); db(a) && ((a.h = 1), (a.u = 0)); } function D(a, b) { @@ -286,8 +292,8 @@ function WebPDecoder(imageData) { a.pa < a.Yc ? ((a.b += 8), (a.I = a.oa[a.pa++] | (a.I << 8))) : a.Ka - ? (a.b = 0) - : ((a.I <<= 8), (a.b += 8), (a.Ka = 1))); + ? (a.b = 0) + : ((a.I <<= 8), (a.b += 8), (a.Ka = 1))); } function G(a) { return na(a, 1); @@ -300,7 +306,7 @@ function WebPDecoder(imageData) { f = (a.I >>> d > e) + 0; f ? ((c -= e), (a.I -= ((e + 1) << d) >>> 0)) : (c = e + 1); d = c; - for (e = 0; 256 <= d; ) (e += 8), (d >>= 8); + for (e = 0; 256 <= d;) ((e += 8), (d >>= 8)); d = 7 ^ (e + Id[d]); a.b -= d; a.Ca = (c << d) - 1; @@ -364,7 +370,7 @@ function WebPDecoder(imageData) { ); } function X(a, b) { - self[b] = function(b, d, e, f, g, h, k) { + self[b] = function (b, d, e, f, g, h, k) { var c; for (c = 0; c < g; ++c) { var m = self[a](h[k + c - 1], e, f + c); @@ -425,11 +431,11 @@ function WebPDecoder(imageData) { } } function ec(a, b, c, d, e) { - self[b] = function(a, b, c, k, l, m, n, r, q) { + self[b] = function (a, b, c, k, l, m, n, r, q) { for (k = n; k < r; ++k) for (n = 0; n < q; ++n) l[m++] = e(c[d(a[b++])]); }; - self[a] = function(a, b, h, k, l, m, n) { + self[a] = function (a, b, h, k, l, m, n) { var f = 8 >> a.b, g = a.Ea, t = a.K[0], @@ -439,13 +445,13 @@ function WebPDecoder(imageData) { var p = 0, u; for (u = 0; u < g; ++u) - u & a || (p = d(k[l++])), (m[n++] = e(t[p & v])), (p >>= f); + (u & a || (p = d(k[l++])), (m[n++] = e(t[p & v])), (p >>= f)); } else self["VP8LMapColor" + c](k, l, t, v, m, n, b, h, g); }; } function Md(a, b, c, d, e) { - for (c = b + c; b < c; ) { + for (c = b + c; b < c;) { var f = a[b++]; d[e++] = (f >> 16) & 255; d[e++] = (f >> 8) & 255; @@ -453,7 +459,7 @@ function WebPDecoder(imageData) { } } function Nd(a, b, c, d, e) { - for (c = b + c; b < c; ) { + for (c = b + c; b < c;) { var f = a[b++]; d[e++] = (f >> 16) & 255; d[e++] = (f >> 8) & 255; @@ -462,7 +468,7 @@ function WebPDecoder(imageData) { } } function Od(a, b, c, d, e) { - for (c = b + c; b < c; ) { + for (c = b + c; b < c;) { var f = a[b++], g = ((f >> 16) & 240) | ((f >> 12) & 15), f = ((f >> 0) & 240) | ((f >> 28) & 15); @@ -471,7 +477,7 @@ function WebPDecoder(imageData) { } } function Pd(a, b, c, d, e) { - for (c = b + c; b < c; ) { + for (c = b + c; b < c;) { var f = a[b++], g = ((f >> 16) & 248) | ((f >> 13) & 7), f = ((f >> 5) & 224) | ((f >> 3) & 31); @@ -480,7 +486,7 @@ function WebPDecoder(imageData) { } } function Qd(a, b, c, d, e) { - for (c = b + c; b < c; ) { + for (c = b + c; b < c;) { var f = a[b++]; d[e++] = (f >> 0) & 255; d[e++] = (f >> 8) & 255; @@ -489,8 +495,8 @@ function WebPDecoder(imageData) { } function fb(a, b, c, d, e, f) { if (0 == f) - for (c = b + c; b < c; ) - (f = a[b++]), + for (c = b + c; b < c;) + ((f = a[b++]), ra( d, ((f[0] >> 24) | @@ -499,7 +505,7 @@ function WebPDecoder(imageData) { (f[3] << 24)) >>> 0 ), - (e += 32); + (e += 32)); else I(d, e, a, b, c); } function gb(a, b) { @@ -532,7 +538,19 @@ function WebPDecoder(imageData) { this.f = []; this.ea = []; this.F = []; - this.Tc = this.Ed = this.Cd = this.Fd = this.lb = this.Db = this.Ab = this.fa = this.J = this.W = this.N = this.O = 0; + this.Tc = + this.Ed = + this.Cd = + this.Fd = + this.lb = + this.Db = + this.Ab = + this.fa = + this.J = + this.W = + this.N = + this.O = + 0; } function Cb() { this.Rd = this.height = this.width = this.S = 0; @@ -549,7 +567,20 @@ function WebPDecoder(imageData) { this.format = [0]; } function Ud() { - this.Id = this.fd = this.Md = this.hb = this.ib = this.da = this.bd = this.cd = this.j = this.v = this.Da = this.Sd = this.ob = 0; + this.Id = + this.fd = + this.Md = + this.hb = + this.ib = + this.da = + this.bd = + this.cd = + this.j = + this.v = + this.Da = + this.Sd = + this.ob = + 0; } function Vd(a) { alert("todo:WebPSamplerProcessPlane"); @@ -580,7 +611,7 @@ function WebPDecoder(imageData) { : (g(b.ec, b.fc, h, k, q, t, v, p, l, m, n, r, e, f - d.A, e, f, y), ++c); for (; u + 2 < w; u += 2) - (q = l), + ((q = l), (t = m), (v = n), (p = r), @@ -588,7 +619,7 @@ function WebPDecoder(imageData) { (r += a.Rc), (f += 2 * d.A), (k += 2 * a.fa), - g(h, k - a.fa, h, k, q, t, v, p, l, m, n, r, e, f - d.A, e, f, y); + g(h, k - a.fa, h, k, q, t, v, p, l, m, n, r, e, f - d.A, e, f, y)); k += a.fa; a.j + w < a.o ? (I(b.ec, b.fc, h, k, y), @@ -671,14 +702,14 @@ function WebPDecoder(imageData) { } if (d && !jc) { for (a = 0; 256 > a; ++a) - (Yd[a] = (89858 * (a - 128) + Ba) >> Wa), + ((Yd[a] = (89858 * (a - 128) + Ba) >> Wa), (Zd[a] = -22014 * (a - 128) + Ba), ($d[a] = -45773 * (a - 128)), - (ae[a] = (113618 * (a - 128) + Ba) >> Wa); + (ae[a] = (113618 * (a - 128) + Ba) >> Wa)); for (a = ta; a < Eb; ++a) - (b = (76283 * (a - 16) + Ba) >> Wa), + ((b = (76283 * (a - 16) + Ba) >> Wa), (be[a - ta] = ga(b, 255)), - (ce[a - ta] = ga((b + 8) >> 4, 15)); + (ce[a - ta] = ga((b + 8) >> 4, 15))); jc = 1; } return 1; @@ -747,7 +778,7 @@ function WebPDecoder(imageData) { var h = c, k = d; d = a.Ta; - for (c = a.Ua; 0 < e--; ) { + for (c = a.Ua; 0 < e--;) { var l = a.gc[e], m = g, n = b, @@ -782,12 +813,11 @@ function WebPDecoder(imageData) { N = v.K, v = v.w + (p >> v.b) * C; p < u; - ) { var z = N, Q = v, S = 1; - for (fe(r, q, w, y - A, 1, w, y); S < A; ) { + for (fe(r, q, w, y - A, 1, w, y); S < A;) { var K = qc[(z[Q++] >> 8) & 15], D = (S & ~B) + E; D > A && (D = A); @@ -811,13 +841,13 @@ function WebPDecoder(imageData) { A = r - y; p = xa(r, l.b); E = l.K; - for (l = l.w + (m >> l.b) * p; m < n; ) { + for (l = l.w + (m >> l.b) * p; m < n;) { B = E; C = l; N = new Jd(); v = u + y; - for (z = u + r; u < v; ) - dc(B[C++], N), Fb(N, t, u, q, k, h), (u += q), (h += q); + for (z = u + r; u < v;) + (dc(B[C++], N), Fb(N, t, u, q, k, h), (u += q), (h += q)); u < z && (dc(B[C++], N), Fb(N, t, u, A, k, h), (u += A), (h += A)); ++m; @@ -889,7 +919,6 @@ function WebPDecoder(imageData) { r = f, m = m.fb + a.Ma * m.A; 0 < r--; - ) { var q = g, t = h, @@ -968,7 +997,7 @@ function WebPDecoder(imageData) { var g = a.qd, h = a.rd; for (x(null != ia[a.Z]); b < c; ++b) - ia[a.Z](g, h, d, e, d, e, f), (g = d), (h = e), (e += f); + (ia[a.Z](g, h, d, e, d, e, f), (g = d), (h = e), (e += f)); a.qd = g; a.rd = h; } @@ -1010,7 +1039,7 @@ function WebPDecoder(imageData) { x(q <= e); var y = !1; a: for (;;) { - for (; y || n < q; ) { + for (; y || n < q;) { var A = 0; if (h >= v) { var v = a, @@ -1059,9 +1088,9 @@ function WebPDecoder(imageData) { null != g && h <= f && !(h % 16) && g(a, h), null != p) ) - for (; r < n; ) - (A = b[r++]), - (p.X[((506832829 * A) & 4294967295) >>> p.Mb] = A); + for (; r < n;) + ((A = b[r++]), + (p.X[((506832829 * A) & 4294967295) >>> p.Mb] = A)); } else if (280 > A) { A = ib(A - 256, l); E = ua(w.G[4], w.H[4], l); @@ -1072,18 +1101,19 @@ function WebPDecoder(imageData) { if (n - c < E || e - n < A) break a; else for (B = 0; B < A; ++B) b[n + B] = b[n + B - E]; n += A; - for (k += A; k >= d; ) - (k -= d), ++h, null != g && h <= f && !(h % 16) && g(a, h); + for (k += A; k >= d;) + ((k -= d), ++h, null != g && h <= f && !(h % 16) && g(a, h)); x(n <= e); k & u && (w = ha(m, k, h)); if (null != p) - for (; r < n; ) - (A = b[r++]), - (p.X[((506832829 * A) & 4294967295) >>> p.Mb] = A); + for (; r < n;) + ((A = b[r++]), + (p.X[((506832829 * A) & 4294967295) >>> p.Mb] = A)); } else if (A < t) { y = A - 280; - for (x(null != p); r < n; ) - (A = b[r++]), (p.X[((506832829 * A) & 4294967295) >>> p.Mb] = A); + for (x(null != p); r < n;) + ((A = b[r++]), + (p.X[((506832829 * A) & 4294967295) >>> p.Mb] = A)); A = n; E = p; x(!(y >>> E.Xa)); @@ -1093,13 +1123,13 @@ function WebPDecoder(imageData) { y || x(l.h == db(l)); } if (a.Pb && l.h && n < e) - x(a.m.h), + (x(a.m.h), (a.a = 5), (a.m = a.wd), (a.$ = a.xd), - 0 < a.s.ua && $b(a.s.vb, a.s.Wa); + 0 < a.s.ua && $b(a.s.vb, a.s.Wa)); else if (l.h) break a; - else null != g && g(a, h > f ? f : h), (a.a = 0), (a.$ = n - c); + else (null != g && g(a, h > f ? f : h), (a.a = 0), (a.$ = n - c)); return 1; } a.a = 3; @@ -1145,7 +1175,7 @@ function WebPDecoder(imageData) { n = 0; a: for (;;) { if (c) - for (; f && D(k, 1); ) { + for (; f && D(k, 1);) { var r = g, q = h, t = d, @@ -1252,7 +1282,7 @@ function WebPDecoder(imageData) { var ua = W, va = wa(ua, Ub); if (null == va) var la = null; - else x(65536 >= ua), (la = va); + else (x(65536 >= ua), (la = va)); var ha = V(aa); if (null == la || null == ha || null == ma) { F.a = 1; @@ -1315,12 +1345,12 @@ function WebPDecoder(imageData) { Ba = 2 + D(La, kb); if (Ba > Ca) break e; } else Ba = Ca; - for (sb = 0; sb < Ca && Ba--; ) { + for (sb = 0; sb < Ca && Ba--;) { Sa(La); var $a = Za[0 + (pb(La) & 127)]; qb(La, La.u + $a.g); var jb = $a.value; - if (16 > jb) (Xa[sb++] = jb), 0 != jb && (Ya = jb); + if (16 > jb) ((Xa[sb++] = jb), 0 != jb && (Ya = jb)); else { var lb = 16 == jb, ab = jb - 16, @@ -1328,7 +1358,7 @@ function WebPDecoder(imageData) { bb = D(La, pe[ab]) + mb; if (sb + bb > Ca) break e; else - for (var nb = lb ? Ya : 0; 0 < bb--; ) + for (var nb = lb ? Ya : 0; 0 < bb--;) Xa[sb++] = nb; } } @@ -1435,7 +1465,7 @@ function WebPDecoder(imageData) { d = c + b + 16 * b; x(a.c <= b); a.V = V(d); - if (null == a.V) return (a.Ta = null), (a.Ua = 0), (a.a = 1), 0; + if (null == a.V) return ((a.Ta = null), (a.Ua = 0), (a.a = 1), 0); a.Ta = a.V; a.Ua = a.Ba + c + b; return 1; @@ -1445,7 +1475,7 @@ function WebPDecoder(imageData) { d = b - c, e = a.V, f = a.Ba + a.c * c; - for (x(b <= a.l.o); 0 < d; ) { + for (x(b <= a.l.o); 0 < d;) { var g = 16 < d ? 16 : d, h = a.l.ma, k = a.l.width, @@ -1470,7 +1500,7 @@ function WebPDecoder(imageData) { e = [0]; a: for (;;) { if (null == a) return 0; - if (null == b) return (a.a = 2), 0; + if (null == b) return ((a.a = 2), 0); a.l = b; a.a = 0; cb(a.m, b.data, b.w, b.ha); @@ -1606,7 +1636,17 @@ function WebPDecoder(imageData) { this.bc = "VP8IoTeardownHook"; this.ha = this.Kb = 0; this.data = []; - this.hb = this.ib = this.da = this.o = this.j = this.va = this.v = this.Da = this.ob = this.w = 0; + this.hb = + this.ib = + this.da = + this.o = + this.j = + this.va = + this.v = + this.Da = + this.ob = + this.w = + 0; this.F = []; this.J = 0; } @@ -1765,8 +1805,8 @@ function WebPDecoder(imageData) { for (e = 0; 8 > e; ++e) for (d = 0; 3 > d; ++d) for (h = 0; 11 > h; ++h) - (k = K(f, Ee[c][e][d][h]) ? na(f, 8) : Fe[c][e][d][h]), - (g.Wc[c][e].Yb[d][h] = k); + ((k = K(f, Ee[c][e][d][h]) ? na(f, 8) : Fe[c][e][d][h]), + (g.Wc[c][e].Yb[d][h] = k)); for (e = 0; 17 > e; ++e) g.Xc[c][e] = g.Wc[c][Ge[e]]; } a.kc = G(f); @@ -1777,7 +1817,7 @@ function WebPDecoder(imageData) { var h = b[e].Yb[c]; for (c = 0; 16 > e; ++e) { if (!K(a, h[c + 0])) return e; - for (; !K(a, h[c + 1]); ) + for (; !K(a, h[c + 1]);) if (((h = b[++e].Yb[0]), (c = 0), 16 == e)) return 16; var k = b[e + 1].Yb; if (K(a, h[c + 2])) { @@ -1800,7 +1840,7 @@ function WebPDecoder(imageData) { : (r = 5 + K(l, 159)); else K(l, m[n + 4]) ? (r = 3 + K(l, m[n + 5])) : (r = 2); h = k[2]; - } else (r = 1), (h = k[1]); + } else ((r = 1), (h = k[1])); k = g + Ie[e]; l = a; 0 > l.b && Qa(l); @@ -1850,8 +1890,7 @@ function WebPDecoder(imageData) { var v; for (v = 0; 4 > v; ++v) { t = Ke[k[l + v]][t]; - for (var p = Mc[K(g, t[0])]; 0 < p; ) - p = Mc[2 * p + K(g, t[p])]; + for (var p = Mc[K(g, t[0])]; 0 < p;) p = Mc[2 * p + K(g, t[p])]; t = -p; k[l + v] = t; } @@ -1860,10 +1899,10 @@ function WebPDecoder(imageData) { m[0 + h] = t; } } else - (t = K(g, 156) ? (K(g, 128) ? 1 : 3) : K(g, 163) ? 2 : 0), + ((t = K(g, 156) ? (K(g, 128) ? 1 : 3) : K(g, 163) ? 2 : 0), (n.Ob[0] = t), M(k, l, t, 4), - M(m, 0, t, 4); + M(m, 0, t, 4)); n.Dd = K(g, 142) ? (K(g, 114) ? (K(g, 183) ? 1 : 3) : 2) : 0; } if (e.m.Ka) return T(a, 7, "Premature end-of-partition0 encountered."); @@ -1874,11 +1913,11 @@ function WebPDecoder(imageData) { k = d.rb[d.sb + d.ja]; f = d.ya[d.aa + d.ja]; if ((l = d.kc ? f.Ad : 0)) - (g.la = k.la = 0), + ((g.la = k.la = 0), f.Za || (g.Na = k.Na = 0), (f.Hc = 0), (f.Gc = 0), - (f.ia = 0); + (f.ia = 0)); else { var u, w, @@ -1913,12 +1952,12 @@ function WebPDecoder(imageData) { for (p = 0; 4 > p; ++p) { var z = N & 1; for (B = w = 0; 4 > B; ++B) - (E = z + (C & 1)), + ((E = z + (C & 1)), (E = oa(k, A, E, n.Sc, y, h, r)), (z = E > y), (C = (C >> 1) | (z << 7)), (w = (w << 2) | (3 < E ? 3 : 1 < E ? 2 : 0 != h[r + 0])), - (r += 16); + (r += 16)); C >>= 4; N = (N >> 1) | (z << 7); v = ((v << 8) | w) >>> 0; @@ -1932,12 +1971,12 @@ function WebPDecoder(imageData) { for (p = 0; 2 > p; ++p) { z = N & 1; for (B = 0; 2 > B; ++B) - (E = z + (C & 1)), + ((E = z + (C & 1)), (E = oa(k, l[2], E, n.Qc, 0, h, r)), (z = 0 < E), (C = (C >> 1) | (z << 3)), (w = (w << 2) | (3 < E ? 3 : 1 < E ? 2 : 0 != h[r + 0])), - (r += 16); + (r += 16)); C >>= 2; N = (N >> 1) | (z << 5); } @@ -1965,7 +2004,7 @@ function WebPDecoder(imageData) { g = 0 < c.L && c.M >= c.zb && c.M <= c.Va; if (0 == c.Aa) a: { - (f.M = c.M), (f.uc = g), Oc(c, f), (e = 1); + ((f.M = c.M), (f.uc = g), Oc(c, f), (e = 1)); w = c.D; f = w.Nb; t = Ya[c.L]; @@ -1998,10 +2037,10 @@ function WebPDecoder(imageData) { G = S.tc; if (0 != G) if ((x(3 <= G), 1 == Q.L)) - 0 < y && Pc(F, H, u, G + 4), + (0 < y && Pc(F, H, u, G + 4), S.La && Qc(F, H, u, G), 0 < A && Rc(F, H, u, G + 4), - S.La && Sc(F, H, u, G); + S.La && Sc(F, H, u, G)); else { var L = Q.B, O = Q.qa, @@ -2126,7 +2165,7 @@ function WebPDecoder(imageData) { } } c = 0; - } else T(a, 6, "Frame setup failed"), (c = a.a); + } else (T(a, 6, "Frame setup failed"), (c = a.a)); if ((c = 0 == c)) { if (c) { a.$c = 0; @@ -2304,7 +2343,7 @@ function WebPDecoder(imageData) { b++; } for (f = e = 0; 4 > f; ++f) - (a = g[e + 0] + 4), + ((a = g[e + 0] + 4), (h = a + g[e + 8]), (k = a - g[e + 8]), (l = ((35468 * g[e + 4]) >> 16) - da(g[e + 12])), @@ -2314,7 +2353,7 @@ function WebPDecoder(imageData) { qa(c, d, 2, 0, k - l), qa(c, d, 3, 0, h - m), e++, - (d += 32); + (d += 32)); } function Te(a, b, c, d) { var e = a[b + 0] + 4, @@ -2360,7 +2399,7 @@ function WebPDecoder(imageData) { e[12 + f] = l - k; } for (f = 0; 4 > f; ++f) - (a = e[0 + 4 * f] + 3), + ((a = e[0 + 4 * f] + 3), (g = a + e[3 + 4 * f]), (h = e[1 + 4 * f] + e[2 + 4 * f]), (k = e[1 + 4 * f] - e[2 + 4 * f]), @@ -2369,7 +2408,7 @@ function WebPDecoder(imageData) { (c[d + 16] = (l + k) >> 3), (c[d + 32] = (g - h) >> 3), (c[d + 48] = (l - k) >> 3), - (d += 64); + (d += 64)); } function Pb(a, b, c) { var d = b - 32, @@ -2399,7 +2438,7 @@ function WebPDecoder(imageData) { } function rf(a, b) { var c; - for (c = 16; 0 < c; --c) M(a, b, a[b - 1], 16), (b += 32); + for (c = 16; 0 < c; --c) (M(a, b, a[b - 1], 16), (b += 32)); } function $a(a, b, c) { var d; @@ -2541,9 +2580,13 @@ function WebPDecoder(imageData) { a[b + 1 + 0] = z(c, d, e); a[b + 3 + 0] = a[b + 1 + 32] = z(d, e, f); a[b + 3 + 32] = a[b + 1 + 64] = z(e, f, f); - a[b + 3 + 64] = a[b + 2 + 64] = a[b + 0 + 96] = a[b + 1 + 96] = a[ - b + 2 + 96 - ] = a[b + 3 + 96] = f; + a[b + 3 + 64] = + a[b + 2 + 64] = + a[b + 0 + 96] = + a[b + 1 + 96] = + a[b + 2 + 96] = + a[b + 3 + 96] = + f; } function mf(a, b) { var c = a[b - 1 + 0], @@ -2571,7 +2614,7 @@ function WebPDecoder(imageData) { } function yf(a, b) { var c; - for (c = 0; 8 > c; ++c) M(a, b, a[b - 1], 8), (b += 32); + for (c = 0; 8 > c; ++c) (M(a, b, a[b - 1], 8), (b += 32)); } function lb(a, b, c) { var d; @@ -2643,14 +2686,14 @@ function WebPDecoder(imageData) { } function bf(a, b, c, d) { var e; - for (e = 3; 0 < e; --e) (b += 4 * c), gd(a, b, c, d); + for (e = 3; 0 < e; --e) ((b += 4 * c), gd(a, b, c, d)); } function cf(a, b, c, d) { var e; - for (e = 3; 0 < e; --e) (b += 4), hd(a, b, c, d); + for (e = 3; 0 < e; --e) ((b += 4), hd(a, b, c, d)); } function ea(a, b, c, d, e, f, g, h) { - for (f = 2 * f + 1; 0 < e--; ) { + for (f = 2 * f + 1; 0 < e--;) { if (ld(a, b, c, f, g)) if (jd(a, b, c, h)) ab(a, b, c); else { @@ -2677,7 +2720,7 @@ function WebPDecoder(imageData) { } } function Fa(a, b, c, d, e, f, g, h) { - for (f = 2 * f + 1; 0 < e--; ) { + for (f = 2 * f + 1; 0 < e--;) { if (ld(a, b, c, f, g)) if (jd(a, b, c, h)) ab(a, b, c); else { @@ -2707,11 +2750,11 @@ function WebPDecoder(imageData) { } function Ye(a, b, c, d, e, f) { var g; - for (g = 3; 0 < g; --g) (b += 4 * c), Fa(a, b, c, 1, 16, d, e, f); + for (g = 3; 0 < g; --g) ((b += 4 * c), Fa(a, b, c, 1, 16, d, e, f)); } function Ze(a, b, c, d, e, f) { var g; - for (g = 3; 0 < g; --g) (b += 4), Fa(a, b, 1, c, 16, d, e, f); + for (g = 3; 0 < g; --g) ((b += 4), Fa(a, b, 1, c, 16, d, e, f)); } function We(a, b, c, d, e, f, g, h) { ea(a, b, e, 1, 8, f, g, h); @@ -2790,7 +2833,8 @@ function WebPDecoder(imageData) { } function Rb(a, b, c, d, e, f, g) { a = null == a ? 0 : a[b + 0]; - for (b = 0; b < g; ++b) (e[f + b] = (a + c[d + b]) & 255), (a = e[f + b]); + for (b = 0; b < g; ++b) + ((e[f + b] = (a + c[d + b]) & 255), (a = e[f + b])); } function Gf(a, b, c, d, e, f, g) { if (null == a) Rb(null, null, c, d, e, f, g); @@ -2807,11 +2851,11 @@ function WebPDecoder(imageData) { l = h, m; for (m = 0; m < g; ++m) - (h = a[b + m]), + ((h = a[b + m]), (k = l + h - k), (l = (c[d + m] + (k & -256 ? (0 > k ? 0 : 255) : k)) & 255), (k = h), - (e[f + m] = l); + (e[f + m] = l)); } } function Le(a, b, c, d) { @@ -2876,7 +2920,7 @@ function WebPDecoder(imageData) { g.$a) ) b: { - x(1 == g.$a), (b = Bc()); + (x(1 == g.$a), (b = Bc())); c: for (;;) { if (null == b) { b = 0; @@ -2931,14 +2975,14 @@ function WebPDecoder(imageData) { x(k <= a.P + a.qc); if (0 != h.Z) for (x(null != ia[h.Z]), g = 0; g < d; ++g) - ia[h.Z](r, q, t, k, l, m, b), + (ia[h.Z](r, q, t, k, l, m, b), (r = l), (q = m), (m += b), - (k += b); + (k += b)); else for (g = 0; g < d; ++g) - I(l, m, t, k, b), (r = l), (q = m), (m += b), (k += b); + (I(l, m, t, k, b), (r = l), (q = m), (m += b), (k += b)); a.rc = r; a.Vc = q; } else { @@ -2967,16 +3011,17 @@ function WebPDecoder(imageData) { x(b <= v); x(yc(n)); c: for (;;) { - for (; !m.h && p < w; ) { + for (; !m.h && p < w;) { l & y || (A = ha(n, l, k)); x(null != A); Sa(m); v = ua(A.G[0], A.H[0], m); if (256 > v) - (h[r + p] = v), + ((h[r + p] = v), ++p, ++l, - l >= q && ((l = 0), ++k, k <= b && !(k % 16) && Ib(g, k)); + l >= q && + ((l = 0), ++k, k <= b && !(k % 16) && Ib(g, k))); else if (280 > v) { var v = ib(v - 256, m); var E = ua(A.G[4], A.H[4], m); @@ -2991,8 +3036,8 @@ function WebPDecoder(imageData) { break c; } p += v; - for (l += v; l >= q; ) - (l -= q), ++k, k <= b && !(k % 16) && Ib(g, k); + for (l += v; l >= q;) + ((l -= q), ++k, k <= b && !(k % 16) && Ib(g, k)); p < w && l & y && (A = ha(n, l, k)); } else { t = 0; @@ -3019,12 +3064,12 @@ function WebPDecoder(imageData) { a.Cc && ((d = a.ga), null != d && (d.mc = null), (a.ga = null), 0 < a.Ga) ) - return alert("todo:WebPDequantizeLevels"), null; + return (alert("todo:WebPDequantizeLevels"), null); } return a.nb + c * e; } function If(a, b, c, d, e, f) { - for (; 0 < e--; ) { + for (; 0 < e--;) { var g = a, h = b + (c ? 1 : 0), k = a, @@ -3042,7 +3087,7 @@ function WebPDecoder(imageData) { } } function Jf(a, b, c, d, e) { - for (; 0 < d--; ) { + for (; 0 < d--;) { var f; for (f = 0; f < c; ++f) { var g = a[b + 2 * f + 0], @@ -3084,7 +3129,7 @@ function WebPDecoder(imageData) { Fc = Lf; } function va(a, b, c) { - self[a] = function(a, e, f, g, h, k, l, m, n, r, q, t, v, p, u, w, y) { + self[a] = function (a, e, f, g, h, k, l, m, n, r, q, t, v, p, u, w, y) { var d, E = (y - 1) >> 1; var B = h[k + 0] | (l[m + 0] << 16); @@ -3182,14 +3227,14 @@ function WebPDecoder(imageData) { d[e + 3] = 255; } function la(a, b, c) { - self[a] = function(a, e, f, g, h, k, l, m, n) { - for (var d = m + (n & -2) * c; m != d; ) - b(a[e + 0], f[g + 0], h[k + 0], l, m), + self[a] = function (a, e, f, g, h, k, l, m, n) { + for (var d = m + (n & -2) * c; m != d;) + (b(a[e + 0], f[g + 0], h[k + 0], l, m), b(a[e + 1], f[g + 0], h[k + 0], l, m + c), (e += 2), ++g, ++k, - (m += 2 * c); + (m += 2 * c)); n & 1 && b(a[e + 0], f[g + 0], h[k + 0], l, m); }; } @@ -3221,7 +3266,7 @@ function WebPDecoder(imageData) { n = a.pc + 600; for (c = 0; 16 > c; ++c) g[h + 32 * c - 1] = 129; for (c = 0; 8 > c; ++c) - (k[l + 32 * c - 1] = 129), (m[n + 32 * c - 1] = 129); + ((k[l + 32 * c - 1] = 129), (m[n + 32 * c - 1] = 129)); 0 < e ? (g[h - 1 - 32] = k[l - 1 - 32] = m[n - 1 - 32] = 129) : (M(g, h - 32 - 1, 127, 21), @@ -3232,8 +3277,8 @@ function WebPDecoder(imageData) { if (0 < d) { for (c = -1; 16 > c; ++c) I(g, h + 32 * c - 4, g, h + 32 * c + 12, 4); for (c = -1; 8 > c; ++c) - I(k, l + 32 * c - 4, k, l + 32 * c + 4, 4), - I(m, n + 32 * c - 4, m, n + 32 * c + 4, 4); + (I(k, l + 32 * c - 4, k, l + 32 * c + 4, 4), + I(m, n + 32 * c - 4, m, n + 32 * c + 4, 4)); } var q = a.Gd, t = a.Hd + d, @@ -3253,7 +3298,10 @@ function WebPDecoder(imageData) { for (c = 0; 4 > c; c++) u[w + 128 + c] = u[w + 256 + c] = u[w + 384 + c] = u[w + 0 + c]; for (c = 0; 16 > c; ++c, p <<= 2) - (u = g), (w = h + zd[c]), W[r.Ob[c]](u, w), yd(p, v, 16 * +c, u, w); + ((u = g), + (w = h + zd[c]), + W[r.Ob[c]](u, w), + yd(p, v, 16 * +c, u, w)); } else if (((u = xd(d, e, r.Ob[0])), Y[u](g, h), 0 != p)) for (c = 0; 16 > c; ++c, p <<= 2) yd(p, v, 16 * +c, g, h + zd[c]); c = r.Gc; @@ -3282,8 +3330,8 @@ function WebPDecoder(imageData) { u = a.Ia + 8 * d + c; for (c = 0; 16 > c; ++c) I(q, t + c * a.R, g, h + 32 * c, 16); for (c = 0; 8 > c; ++c) - I(v, r + c * a.B, k, l + 32 * c, 8), - I(p, u + c * a.B, m, n + 32 * c, 8); + (I(v, r + c * a.B, k, l + 32 * c, 8), + I(p, u + c * a.B, m, n + 32 * c, 8)); } } function Ad(a, b, c, d, e, f, g, h, k) { @@ -3329,7 +3377,7 @@ function WebPDecoder(imageData) { } if (0 != p) return p; u = 0 < q.gb[0]; - for (c = c[0]; ; ) { + for (c = c[0]; ;) { t = [0]; n = [n]; a: { @@ -3409,7 +3457,7 @@ function WebPDecoder(imageData) { x(null != B); A[0] = null; z[0] = null; - for (B[0] = 0; ; ) { + for (B[0] = 0; ;) { p[0] = w; u[0] = F; if (8 > F) { @@ -3482,8 +3530,8 @@ function WebPDecoder(imageData) { u[0] -= 8; B[0] = D; } else - (B[0] = 5 <= u[0] && 47 == y[C + 0] && !(y[C + 4] >> 5)), - (z[0] = u[0]); + ((B[0] = 5 <= u[0] && 47 == y[C + 0] && !(y[C + 4] >> 5)), + (z[0] = u[0])); p = 0; } c = c[0]; @@ -3506,18 +3554,18 @@ function WebPDecoder(imageData) { null == a || 5 > c ? (a = 0) : 5 <= c && 47 == a[b + 0] && !(a[b + 4] >> 5) - ? ((u = [0]), - (y = [0]), - (A = [0]), - (z = new Ra()), - cb(z, a, b, c), - mc(z, u, y, A) - ? (null != h && (h[0] = u[0]), - null != r && (r[0] = y[0]), - null != v && (v[0] = A[0]), - (a = 1)) - : (a = 0)) - : (a = 0); + ? ((u = [0]), + (y = [0]), + (A = [0]), + (z = new Ra()), + cb(z, a, b, c), + mc(z, u, y, A) + ? (null != h && (h[0] = u[0]), + null != r && (r[0] = y[0]), + null != v && (v[0] = A[0]), + (a = 1)) + : (a = 0)) + : (a = 0); } else { if (10 > c) { p = 7; @@ -3600,7 +3648,7 @@ function WebPDecoder(imageData) { b.fb += (a.height - 1) * b.A; b.A = -b.A; } else - (b = a.f.kb), + ((b = a.f.kb), (a = a.height), (b.O += (a - 1) * b.fa), (b.fa = -b.fa), @@ -3608,7 +3656,7 @@ function WebPDecoder(imageData) { (b.Ab = -b.Ab), (b.W += ((a - 1) >> 1) * b.Db), (b.Db = -b.Db), - null != b.F && ((b.J += (a - 1) * b.lb), (b.lb = -b.lb)); + null != b.F && ((b.J += (a - 1) * b.lb), (b.lb = -b.lb))); return 0; } function Cd(a, b, c, d) { @@ -3683,11 +3731,11 @@ function WebPDecoder(imageData) { g = d.height; if (e >= Ca && 13 > e) if (11 > e) - (a = d.f.RGBA), + ((a = d.f.RGBA), (h = Math.abs(a.A)), (b &= h * (g - 1) + f <= a.size), (b &= h >= f * Dd[e]), - (b &= null != a.eb); + (b &= null != a.eb)); else { a = d.f.kb; h = (f + 1) / 2; @@ -3716,328 +3764,61 @@ function WebPDecoder(imageData) { } var xb = 64, Hd = [ - 0, - 1, - 3, - 7, - 15, - 31, - 63, - 127, - 255, - 511, - 1023, - 2047, - 4095, - 8191, - 16383, - 32767, - 65535, - 131071, - 262143, - 524287, - 1048575, - 2097151, - 4194303, - 8388607, - 16777215 + 0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, + 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, + 8388607, 16777215 ], Gd = 24, ob = 32, Xb = 8, Id = [ - 0, - 0, - 1, - 1, - 2, - 2, - 2, - 2, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 5, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 6, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7, - 7 + 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 ]; X("Predictor0", "PredictorAdd0"); - self.Predictor0 = function() { + self.Predictor0 = function () { return 4278190080; }; - self.Predictor1 = function(a) { + self.Predictor1 = function (a) { return a; }; - self.Predictor2 = function(a, b, c) { + self.Predictor2 = function (a, b, c) { return b[c + 0]; }; - self.Predictor3 = function(a, b, c) { + self.Predictor3 = function (a, b, c) { return b[c + 1]; }; - self.Predictor4 = function(a, b, c) { + self.Predictor4 = function (a, b, c) { return b[c - 1]; }; - self.Predictor5 = function(a, b, c) { + self.Predictor5 = function (a, b, c) { return aa(aa(a, b[c + 1]), b[c + 0]); }; - self.Predictor6 = function(a, b, c) { + self.Predictor6 = function (a, b, c) { return aa(a, b[c - 1]); }; - self.Predictor7 = function(a, b, c) { + self.Predictor7 = function (a, b, c) { return aa(a, b[c + 0]); }; - self.Predictor8 = function(a, b, c) { + self.Predictor8 = function (a, b, c) { return aa(b[c - 1], b[c + 0]); }; - self.Predictor9 = function(a, b, c) { + self.Predictor9 = function (a, b, c) { return aa(b[c + 0], b[c + 1]); }; - self.Predictor10 = function(a, b, c) { + self.Predictor10 = function (a, b, c) { return aa(aa(a, b[c - 1]), aa(b[c + 0], b[c + 1])); }; - self.Predictor11 = function(a, b, c) { + self.Predictor11 = function (a, b, c) { var d = b[c + 0]; b = b[c - 1]; return 0 >= @@ -4048,7 +3829,7 @@ function WebPDecoder(imageData) { ? d : a; }; - self.Predictor12 = function(a, b, c) { + self.Predictor12 = function (a, b, c) { var d = b[c + 0]; b = b[c - 1]; return ( @@ -4060,7 +3841,7 @@ function WebPDecoder(imageData) { 0 ); }; - self.Predictor13 = function(a, b, c) { + self.Predictor13 = function (a, b, c) { var d = b[c - 1]; a = aa(a, b[c + 0]); return ( @@ -4090,10 +3871,10 @@ function WebPDecoder(imageData) { "ColorIndexInverseTransform", "MapARGB", "32b", - function(a) { + function (a) { return (a >> 8) & 255; }, - function(a) { + function (a) { return a; } ); @@ -4101,10 +3882,10 @@ function WebPDecoder(imageData) { "VP8LColorIndexInverseTransformAlpha", "MapAlpha", "8b", - function(a) { + function (a) { return a; }, - function(a) { + function (a) { return (a >> 8) & 255; } ); @@ -4150,401 +3931,37 @@ function WebPDecoder(imageData) { qe = [0, 1, 1, 1, 0], ne = [17, 18, 0, 1, 2, 3, 4, 5, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], de = [ - 24, - 7, - 23, - 25, - 40, - 6, - 39, - 41, - 22, - 26, - 38, - 42, - 56, - 5, - 55, - 57, - 21, - 27, - 54, - 58, - 37, - 43, - 72, - 4, - 71, - 73, - 20, - 28, - 53, - 59, - 70, - 74, - 36, - 44, - 88, - 69, - 75, - 52, - 60, - 3, - 87, - 89, - 19, - 29, - 86, - 90, - 35, - 45, - 68, - 76, - 85, - 91, - 51, - 61, - 104, - 2, - 103, - 105, - 18, - 30, - 102, - 106, - 34, - 46, - 84, - 92, - 67, - 77, - 101, - 107, - 50, - 62, - 120, - 1, - 119, - 121, - 83, - 93, - 17, - 31, - 100, - 108, - 66, - 78, - 118, - 122, - 33, - 47, - 117, - 123, - 49, - 63, - 99, - 109, - 82, - 94, - 0, - 116, - 124, - 65, - 79, - 16, - 32, - 98, - 110, - 48, - 115, - 125, - 81, - 95, - 64, - 114, - 126, - 97, - 111, - 80, - 113, - 127, - 96, - 112 + 24, 7, 23, 25, 40, 6, 39, 41, 22, 26, 38, 42, 56, 5, 55, 57, 21, 27, 54, + 58, 37, 43, 72, 4, 71, 73, 20, 28, 53, 59, 70, 74, 36, 44, 88, 69, 75, + 52, 60, 3, 87, 89, 19, 29, 86, 90, 35, 45, 68, 76, 85, 91, 51, 61, 104, + 2, 103, 105, 18, 30, 102, 106, 34, 46, 84, 92, 67, 77, 101, 107, 50, 62, + 120, 1, 119, 121, 83, 93, 17, 31, 100, 108, 66, 78, 118, 122, 33, 47, + 117, 123, 49, 63, 99, 109, 82, 94, 0, 116, 124, 65, 79, 16, 32, 98, 110, + 48, 115, 125, 81, 95, 64, 114, 126, 97, 111, 80, 113, 127, 96, 112 ], me = [ - 2954, - 2956, - 2958, - 2962, - 2970, - 2986, - 3018, - 3082, - 3212, - 3468, - 3980, - 5004 + 2954, 2956, 2958, 2962, 2970, 2986, 3018, 3082, 3212, 3468, 3980, 5004 ], ie = 8, Lb = [ - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 17, - 18, - 19, - 20, - 20, - 21, - 21, - 22, - 22, - 23, - 23, - 24, - 25, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 76, - 77, - 78, - 79, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 91, - 93, - 95, - 96, - 98, - 100, - 101, - 102, - 104, - 106, - 108, - 110, - 112, - 114, - 116, - 118, - 122, - 124, - 126, - 128, - 130, - 132, - 134, - 136, - 138, - 140, - 143, - 145, - 148, - 151, - 154, - 157 + 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 17, 18, 19, 20, + 20, 21, 21, 22, 22, 23, 23, 24, 25, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 75, 76, 76, 77, 78, 79, 80, 81, 82, 83, 84, + 85, 86, 87, 88, 89, 91, 93, 95, 96, 98, 100, 101, 102, 104, 106, 108, + 110, 112, 114, 116, 118, 122, 124, 126, 128, 130, 132, 134, 136, 138, + 140, 143, 145, 148, 151, 154, 157 ], Mb = [ - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 60, - 62, - 64, - 66, - 68, - 70, - 72, - 74, - 76, - 78, - 80, - 82, - 84, - 86, - 88, - 90, - 92, - 94, - 96, - 98, - 100, - 102, - 104, - 106, - 108, - 110, - 112, - 114, - 116, - 119, - 122, - 125, - 128, - 131, - 134, - 137, - 140, - 143, - 146, - 149, - 152, - 155, - 158, - 161, - 164, - 167, - 170, - 173, - 177, - 181, - 185, - 189, - 193, - 197, - 201, - 205, - 209, - 213, - 217, - 221, - 225, - 229, - 234, - 239, - 245, - 249, - 254, - 259, - 264, - 269, - 274, - 279, - 284 + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, + 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 119, 122, 125, 128, + 131, 134, 137, 140, 143, 146, 149, 152, 155, 158, 161, 164, 167, 170, + 173, 177, 181, 185, 189, 193, 197, 201, 205, 209, 213, 217, 221, 225, + 229, 234, 239, 245, 249, 254, 259, 264, 269, 274, 279, 284 ], oa = null, He = [ @@ -5082,27 +4499,12 @@ function WebPDecoder(imageData) { la("YuvToRgba4444Row", td, 2); la("YuvToRgb565Row", sd, 2); var zd = [ - 0, - 4, - 8, - 12, - 128, - 132, - 136, - 140, - 256, - 260, - 264, - 268, - 384, - 388, - 392, - 396 + 0, 4, 8, 12, 128, 132, 136, 140, 256, 260, 264, 268, 384, 388, 392, 396 ], Ya = [0, 2, 8], Qf = [8, 7, 6, 4, 4, 2, 2, 2, 1, 1, 1, 1], Ne = 1; - this.WebPDecodeRGBA = function(a, b, c, d, e) { + this.WebPDecodeRGBA = function (a, b, c, d, e) { var f = Ua; var g = new Cf(), h = new Cb(); @@ -5115,8 +4517,8 @@ function WebPDecoder(imageData) { m = new Td(); if (null == m || null == a) var n = 2; else - x(null != m), - (n = Ad(a, b, c, m.width, m.height, m.Pd, m.Qd, m.format, null)); + (x(null != m), + (n = Ad(a, b, c, m.width, m.height, m.Pd, m.Qd, m.format, null))); 0 != n ? (k = 0) : (null != k && (k[0] = m.width[0]), @@ -5228,10 +4630,10 @@ function WebPDecoder(imageData) { k = 0 > k ? 0 : 100 < k ? 255 : (255 * k) / 100; if (0 < k) { for (l = m = 0; 4 > l; ++l) - (n = e.pb[l]), + ((n = e.pb[l]), 12 > n.lc && (n.ia = (k * Qf[0 > n.lc ? 0 : n.lc]) >> 3), - (m |= n.ia); + (m |= n.ia)); m && (alert("todo:VP8InitRandom"), (e.ia = 1)); } e.Ga = c.Id; @@ -5444,7 +4846,7 @@ WebPRiffParser dominikhlbg@gmail.com return this; } -WebPDecoder.prototype.getData = function() { +WebPDecoder.prototype.getData = function () { return this.data; }; diff --git a/src/libs/bidiEngine.ts b/src/libs/bidiEngine.ts index 5b262c061..364db46ca 100644 --- a/src/libs/bidiEngine.ts +++ b/src/libs/bidiEngine.ts @@ -6,7 +6,49 @@ import { jsPDF } from "../jspdf.js"; -(function(jsPDF) { +interface BidiEngineOptions { + isInputVisual?: boolean; + isInputRtl?: boolean; + isOutputVisual?: boolean; + isOutputRtl?: boolean; + isSymmetricSwapping?: boolean; +} + +interface BidiEngineInstance { + doBidiReorder( + text: string, + sourceToTargetMap?: number[], + levels?: number[] + ): string; + setOptions(options?: BidiEngineOptions): void; +} + +type BidiEngineConstructor = new ( + options?: BidiEngineOptions +) => BidiEngineInstance; + +/** + * Local view of the jsPDF constructor with the (undeclared) slots the bidi + * engine is attached to. Neither `jsPDF.__bidiEngine__` nor + * `jsPDF.prototype.__bidiEngine__` is part of the public jsPDF typings, so + * they are described here and applied via a single cast at the attachment + * boundary below. + */ +interface JsPDFWithBidiEngine { + __bidiEngine__: BidiEngineConstructor; + prototype: { __bidiEngine__: BidiEngineConstructor }; +} + +/** Shape of the `postProcessText` event payload handled by this plugin. */ +interface BidiEnginePostProcessTextArgs { + text: string | (string | (string | number)[])[]; + x: number; + y: number; + options: (BidiEngineOptions & { lang?: string }) | undefined; + mutex: Record | undefined; +} + +(function (jsPDF) { "use strict"; /** * Table of Unicode types. @@ -2106,562 +2148,634 @@ import { jsPDF } from "../jspdf.js"; * var ret = bidiEng.doBidiReorder(src, sourceToTarget, levels); */ - (jsPDF as any).__bidiEngine__ = (jsPDF as any).prototype.__bidiEngine__ = function( - options - ) { - var _UNICODE_TYPES = _bidiUnicodeTypes; + // Single documented cast at the attachment boundary: the bidi engine is + // stashed on both the jsPDF constructor and its prototype, neither of + // which declares the slot (see JsPDFWithBidiEngine above). + var jsPDFWithBidiEngine = jsPDF as unknown as JsPDFWithBidiEngine; - var _STATE_TABLE_LTR = [ - [0, 3, 0, 1, 0, 0, 0], - [0, 3, 0, 1, 2, 2, 0], - [0, 3, 0, 0x11, 2, 0, 1], - [0, 3, 5, 5, 4, 1, 0], - [0, 3, 0x15, 0x15, 4, 0, 1], - [0, 3, 5, 5, 4, 2, 0] - ]; + jsPDFWithBidiEngine.__bidiEngine__ = + jsPDFWithBidiEngine.prototype.__bidiEngine__ = function ( + this: { __bidiEngine__: BidiEngineInstance }, + options?: BidiEngineOptions + ): BidiEngineInstance { + var _UNICODE_TYPES = _bidiUnicodeTypes; - var _STATE_TABLE_RTL = [ - [2, 0, 1, 1, 0, 1, 0], - [2, 0, 1, 1, 0, 2, 0], - [2, 0, 2, 1, 3, 2, 0], - [2, 0, 2, 0x21, 3, 1, 1] - ]; + var _STATE_TABLE_LTR = [ + [0, 3, 0, 1, 0, 0, 0], + [0, 3, 0, 1, 2, 2, 0], + [0, 3, 0, 0x11, 2, 0, 1], + [0, 3, 5, 5, 4, 1, 0], + [0, 3, 0x15, 0x15, 4, 0, 1], + [0, 3, 5, 5, 4, 2, 0] + ]; - var _TYPE_NAMES_MAP = { L: 0, R: 1, EN: 2, AN: 3, N: 4, B: 5, S: 6 }; + var _STATE_TABLE_RTL = [ + [2, 0, 1, 1, 0, 1, 0], + [2, 0, 1, 1, 0, 2, 0], + [2, 0, 2, 1, 3, 2, 0], + [2, 0, 2, 0x21, 3, 1, 1] + ]; - var _UNICODE_RANGES_MAP = { - 0: 0, - 5: 1, - 6: 2, - 7: 3, - 0x20: 4, - 0xfb: 5, - 0xfe: 6, - 0xff: 7 - }; + var _TYPE_NAMES_MAP: Record = { + L: 0, + R: 1, + EN: 2, + AN: 3, + N: 4, + B: 5, + S: 6 + }; - var _SWAP_TABLE = [ - "\u0028", - "\u0029", - "\u0028", - "\u003C", - "\u003E", - "\u003C", - "\u005B", - "\u005D", - "\u005B", - "\u007B", - "\u007D", - "\u007B", - "\u00AB", - "\u00BB", - "\u00AB", - "\u2039", - "\u203A", - "\u2039", - "\u2045", - "\u2046", - "\u2045", - "\u207D", - "\u207E", - "\u207D", - "\u208D", - "\u208E", - "\u208D", - "\u2264", - "\u2265", - "\u2264", - "\u2329", - "\u232A", - "\u2329", - "\uFE59", - "\uFE5A", - "\uFE59", - "\uFE5B", - "\uFE5C", - "\uFE5B", - "\uFE5D", - "\uFE5E", - "\uFE5D", - "\uFE64", - "\uFE65", - "\uFE64" - ]; + var _UNICODE_RANGES_MAP: Record = { + 0: 0, + 5: 1, + 6: 2, + 7: 3, + 0x20: 4, + 0xfb: 5, + 0xfe: 6, + 0xff: 7 + }; - var _LTR_RANGES_REG_EXPR = new RegExp( - /^([1-4|9]|1[0-9]|2[0-9]|3[0168]|4[04589]|5[012]|7[78]|159|16[0-9]|17[0-2]|21[569]|22[03489]|250)$/ - ); + var _SWAP_TABLE = [ + "\u0028", + "\u0029", + "\u0028", + "\u003C", + "\u003E", + "\u003C", + "\u005B", + "\u005D", + "\u005B", + "\u007B", + "\u007D", + "\u007B", + "\u00AB", + "\u00BB", + "\u00AB", + "\u2039", + "\u203A", + "\u2039", + "\u2045", + "\u2046", + "\u2045", + "\u207D", + "\u207E", + "\u207D", + "\u208D", + "\u208E", + "\u208D", + "\u2264", + "\u2265", + "\u2264", + "\u2329", + "\u232A", + "\u2329", + "\uFE59", + "\uFE5A", + "\uFE59", + "\uFE5B", + "\uFE5C", + "\uFE5B", + "\uFE5D", + "\uFE5E", + "\uFE5D", + "\uFE64", + "\uFE65", + "\uFE64" + ]; - var _lastArabic = false, - _hasUbatAl, - _hasUbatB, - _hasUbatS, - DIR_LTR = 0, - DIR_RTL = 1, - _isInVisual, - _isInRtl, - _isOutVisual, - _isOutRtl, - _isSymmetricSwapping, - _dir = DIR_LTR; + var _LTR_RANGES_REG_EXPR = new RegExp( + /^([1-4|9]|1[0-9]|2[0-9]|3[0168]|4[04589]|5[012]|7[78]|159|16[0-9]|17[0-2]|21[569]|22[03489]|250)$/ + ); - this.__bidiEngine__ = {}; + var _lastArabic = false, + _hasUbatAl: boolean, + _hasUbatB: boolean, + _hasUbatS: boolean, + DIR_LTR = 0, + DIR_RTL = 1, + _isInVisual: boolean, + _isInRtl: boolean, + _isOutVisual: boolean, + _isOutRtl: boolean, + _isSymmetricSwapping: boolean, + _dir = DIR_LTR; - var _init = function(text, sourceToTargetMap) { - if (sourceToTargetMap) { - for (var i = 0; i < text.length; i++) { - sourceToTargetMap[i] = i; - } - } - if (_isInRtl === undefined) { - _isInRtl = _isContextualDirRtl(text); - } - if (_isOutRtl === undefined) { - _isOutRtl = _isContextualDirRtl(text); - } - }; + this.__bidiEngine__ = {} as BidiEngineInstance; - // for reference see 3.2 in http://unicode.org/reports/tr9/ - // - var _getCharType = function(ch) { - var charCode = ch.charCodeAt(), - range = charCode >> 8, - rangeIdx = _UNICODE_RANGES_MAP[range]; + var _init = function (text: string, sourceToTargetMap?: number[]): void { + if (sourceToTargetMap) { + for (var i = 0; i < text.length; i++) { + sourceToTargetMap[i] = i; + } + } + if (_isInRtl === undefined) { + _isInRtl = _isContextualDirRtl(text); + } + if (_isOutRtl === undefined) { + _isOutRtl = _isContextualDirRtl(text); + } + }; - if (rangeIdx !== undefined) { - return _UNICODE_TYPES[rangeIdx * 256 + (charCode & 0xff)]; - } else if (range === 0xfc || range === 0xfd) { - return "AL"; - } else if (_LTR_RANGES_REG_EXPR.test(range as any)) { - //unlikely case - return "L"; - } else if (range === 8) { - // even less likely - return "R"; - } - return "N"; //undefined type, mark as neutral - }; + // for reference see 3.2 in http://unicode.org/reports/tr9/ + // + var _getCharType = function (ch: string): string { + var charCode = ch.charCodeAt(0), + range = charCode >> 8, + rangeIdx = _UNICODE_RANGES_MAP[range]; - var _isContextualDirRtl = function(text) { - for (var i = 0, charType; i < text.length; i++) { - charType = _getCharType(text.charAt(i)); - if (charType === "L") { - return false; - } else if (charType === "R") { - return true; + if (rangeIdx !== undefined) { + return _UNICODE_TYPES[rangeIdx * 256 + (charCode & 0xff)]; + } else if (range === 0xfc || range === 0xfd) { + return "AL"; + } else if (_LTR_RANGES_REG_EXPR.test(String(range))) { + //unlikely case + return "L"; + } else if (range === 8) { + // even less likely + return "R"; } - } - return false; - }; - - // for reference see 3.3.4 & 3.3.5 in http://unicode.org/reports/tr9/ - // - var _resolveCharType = function(chars, types, resolvedTypes, index) { - var cType = types[index], - wType, - nType, - i, - len; - switch (cType) { - case "L": - case "R": - _lastArabic = false; - break; - case "N": - case "AN": - break; + return "N"; //undefined type, mark as neutral + }; - case "EN": - if (_lastArabic) { - cType = "AN"; + var _isContextualDirRtl = function (text: string): boolean { + for (var i = 0, charType; i < text.length; i++) { + charType = _getCharType(text.charAt(i)); + if (charType === "L") { + return false; + } else if (charType === "R") { + return true; } - break; + } + return false; + }; - case "AL": - _lastArabic = true; - _hasUbatAl = true; - cType = "R"; - break; + // for reference see 3.3.4 & 3.3.5 in http://unicode.org/reports/tr9/ + // + var _resolveCharType = function ( + chars: string[], + types: string[], + resolvedTypes: (string | number)[], + index: number + ): string | number { + var cType: string | number = types[index], + wType: string | number, + nType: string | number, + i, + len; + switch (cType) { + case "L": + case "R": + _lastArabic = false; + break; + case "N": + case "AN": + break; - case "WS": - cType = "N"; - break; + case "EN": + if (_lastArabic) { + cType = "AN"; + } + break; - case "CS": - if ( - index < 1 || - index + 1 >= types.length || - ((wType = resolvedTypes[index - 1]) !== "EN" && wType !== "AN") || - ((nType = types[index + 1]) !== "EN" && nType !== "AN") - ) { - cType = "N"; - } else if (_lastArabic) { - nType = "AN"; - } - cType = nType === wType ? nType : "N"; - break; + case "AL": + _lastArabic = true; + _hasUbatAl = true; + cType = "R"; + break; - case "ES": - wType = index > 0 ? resolvedTypes[index - 1] : "B"; - cType = - wType === "EN" && - index + 1 < types.length && - types[index + 1] === "EN" - ? "EN" - : "N"; - break; + case "WS": + cType = "N"; + break; - case "ET": - if (index > 0 && resolvedTypes[index - 1] === "EN") { - cType = "EN"; + case "CS": + if ( + index < 1 || + index + 1 >= types.length || + ((wType = resolvedTypes[index - 1]) !== "EN" && wType !== "AN") || + ((nType = types[index + 1]) !== "EN" && nType !== "AN") + ) { + cType = "N"; + } else if (_lastArabic) { + nType = "AN"; + } + cType = nType === wType ? nType : "N"; break; - } else if (_lastArabic) { - cType = "N"; + + case "ES": + wType = index > 0 ? resolvedTypes[index - 1] : "B"; + cType = + wType === "EN" && + index + 1 < types.length && + types[index + 1] === "EN" + ? "EN" + : "N"; break; - } - i = index + 1; - len = types.length; - while (i < len && types[i] === "ET") { - i++; - } - if (i < len && types[i] === "EN") { - cType = "EN"; - } else { - cType = "N"; - } - break; - case "NSM": - if (_isInVisual && !_isInRtl) { - //V->L - len = types.length; + case "ET": + if (index > 0 && resolvedTypes[index - 1] === "EN") { + cType = "EN"; + break; + } else if (_lastArabic) { + cType = "N"; + break; + } i = index + 1; - while (i < len && types[i] === "NSM") { + len = types.length; + while (i < len && types[i] === "ET") { i++; } - if (i < len) { - var c = chars[index]; - var rtlCandidate = (c >= 0x0591 && c <= 0x08ff) || c === 0xfb1e; - wType = types[i]; - if (rtlCandidate && (wType === "R" || wType === "AL")) { - cType = "R"; - break; + if (i < len && types[i] === "EN") { + cType = "EN"; + } else { + cType = "N"; + } + break; + + case "NSM": + if (_isInVisual && !_isInRtl) { + //V->L + len = types.length; + i = index + 1; + while (i < len && types[i] === "NSM") { + i++; + } + if (i < len) { + // Cast documented: latent upstream bug kept for parity — + // `chars` holds single-character strings, so this numeric + // range comparison never matches at runtime. The cast + // preserves the original behavior without an implicit any. + var c = chars[index] as unknown as number; + var rtlCandidate = (c >= 0x0591 && c <= 0x08ff) || c === 0xfb1e; + wType = types[i]; + if (rtlCandidate && (wType === "R" || wType === "AL")) { + cType = "R"; + break; + } } } - } - if (index < 1 || (wType = types[index - 1]) === "B") { - cType = "N"; - } else { - cType = resolvedTypes[index - 1]; - } - break; + if (index < 1 || (wType = types[index - 1]) === "B") { + cType = "N"; + } else { + cType = resolvedTypes[index - 1]; + } + break; - case "B": - _lastArabic = false; - _hasUbatB = true; - cType = _dir; - break; + case "B": + _lastArabic = false; + _hasUbatB = true; + cType = _dir; + break; - case "S": - _hasUbatS = true; - cType = "N"; - break; + case "S": + _hasUbatS = true; + cType = "N"; + break; - case "LRE": - case "RLE": - case "LRO": - case "RLO": - case "PDF": - _lastArabic = false; - break; - case "BN": - cType = "N"; - break; - } - return cType; - }; + case "LRE": + case "RLE": + case "LRO": + case "RLO": + case "PDF": + _lastArabic = false; + break; + case "BN": + cType = "N"; + break; + } + return cType; + }; - var _handleUbatS = function(types, levels, length) { - for (var i = 0; i < length; i++) { - if (types[i] === "S") { - levels[i] = _dir; - for (var j = i - 1; j >= 0; j--) { - if (types[j] === "WS") { - levels[j] = _dir; - } else { - break; + var _handleUbatS = function ( + types: string[], + levels: number[], + length: number + ): void { + for (var i = 0; i < length; i++) { + if (types[i] === "S") { + levels[i] = _dir; + for (var j = i - 1; j >= 0; j--) { + if (types[j] === "WS") { + levels[j] = _dir; + } else { + break; + } } } } - } - }; + }; - var _invertString = function(text, sourceToTargetMap, levels?) { - var charArray = text.split(""); - if (levels) { - _computeLevels(charArray, levels, { hiLevel: _dir }); - } - charArray.reverse(); - sourceToTargetMap && sourceToTargetMap.reverse(); - return charArray.join(""); - }; + var _invertString = function ( + text: string, + sourceToTargetMap?: number[], + levels?: number[] + ): string { + var charArray = text.split(""); + if (levels) { + _computeLevels(charArray, levels, { hiLevel: _dir }); + } + charArray.reverse(); + sourceToTargetMap && sourceToTargetMap.reverse(); + return charArray.join(""); + }; - // For reference see 3.3 in http://unicode.org/reports/tr9/ - // - var _computeLevels = function(chars, levels, params) { - var action, - condition, - i, - index, - newLevel, - prevState, - condPos = -1, - len = chars.length, - newState = 0, - resolvedTypes = [], - stateTable = _dir ? _STATE_TABLE_RTL : _STATE_TABLE_LTR, - types = []; + // For reference see 3.3 in http://unicode.org/reports/tr9/ + // + var _computeLevels = function ( + chars: string[], + levels: number[], + params: { hiLevel: number } + ): void { + var action, + condition, + i, + index, + newLevel, + prevState, + condPos = -1, + len = chars.length, + newState = 0, + resolvedTypes: (string | number)[] = [], + stateTable = _dir ? _STATE_TABLE_RTL : _STATE_TABLE_LTR, + types: string[] = []; - _lastArabic = false; - _hasUbatAl = false; - _hasUbatB = false; - _hasUbatS = false; - for (i = 0; i < len; i++) { - types[i] = _getCharType(chars[i]); - } - for (index = 0; index < len; index++) { - prevState = newState; - resolvedTypes[index] = _resolveCharType( - chars, - types, - resolvedTypes, - index - ); - newState = stateTable[prevState][_TYPE_NAMES_MAP[resolvedTypes[index]]]; - action = newState & 0xf0; - newState &= 0x0f; - levels[index] = newLevel = stateTable[newState][5]; - if (action > 0) { - if (action === 0x10) { - for (i = condPos; i < index; i++) { - levels[i] = 1; - } - condPos = -1; - } else { - condPos = -1; - } + _lastArabic = false; + _hasUbatAl = false; + _hasUbatB = false; + _hasUbatS = false; + for (i = 0; i < len; i++) { + types[i] = _getCharType(chars[i]); } - condition = stateTable[newState][6]; - if (condition) { - if (condPos === -1) { - condPos = index; + for (index = 0; index < len; index++) { + prevState = newState; + resolvedTypes[index] = _resolveCharType( + chars, + types, + resolvedTypes, + index + ); + newState = + stateTable[prevState][_TYPE_NAMES_MAP[resolvedTypes[index]]]; + action = newState & 0xf0; + newState &= 0x0f; + levels[index] = newLevel = stateTable[newState][5]; + if (action > 0) { + if (action === 0x10) { + for (i = condPos; i < index; i++) { + levels[i] = 1; + } + condPos = -1; + } else { + condPos = -1; + } } - } else { - if (condPos > -1) { - for (i = condPos; i < index; i++) { - levels[i] = newLevel; + condition = stateTable[newState][6]; + if (condition) { + if (condPos === -1) { + condPos = index; } - condPos = -1; + } else { + if (condPos > -1) { + for (i = condPos; i < index; i++) { + levels[i] = newLevel; + } + condPos = -1; + } + } + if (types[index] === "B") { + levels[index] = 0; } + params.hiLevel |= newLevel; } - if (types[index] === "B") { - levels[index] = 0; + if (_hasUbatS) { + _handleUbatS(types, levels, len); } - params.hiLevel |= newLevel; - } - if (_hasUbatS) { - _handleUbatS(types, levels, len); - } - }; + }; - // for reference see 3.4 in http://unicode.org/reports/tr9/ - // - var _invertByLevel = function( - level, - charArray, - sourceToTargetMap, - levels, - params - ) { - if (params.hiLevel < level) { - return; - } - if (level === 1 && _dir === DIR_RTL && !_hasUbatB) { - charArray.reverse(); - sourceToTargetMap && sourceToTargetMap.reverse(); - return; - } - var ch, - high, - end, - low, - len = charArray.length, - start = 0; + // for reference see 3.4 in http://unicode.org/reports/tr9/ + // + var _invertByLevel = function ( + level: number, + charArray: string[], + sourceToTargetMap: number[] | undefined, + levels: number[], + params: { hiLevel: number } + ): void { + if (params.hiLevel < level) { + return; + } + if (level === 1 && _dir === DIR_RTL && !_hasUbatB) { + charArray.reverse(); + sourceToTargetMap && sourceToTargetMap.reverse(); + return; + } + var ch, + high, + end, + low, + len = charArray.length, + start = 0; - while (start < len) { - if (levels[start] >= level) { - end = start + 1; - while (end < len && levels[end] >= level) { - end++; - } - for (low = start, high = end - 1; low < high; low++, high--) { - ch = charArray[low]; - charArray[low] = charArray[high]; - charArray[high] = ch; - if (sourceToTargetMap) { - ch = sourceToTargetMap[low]; - sourceToTargetMap[low] = sourceToTargetMap[high]; - sourceToTargetMap[high] = ch; + while (start < len) { + if (levels[start] >= level) { + end = start + 1; + while (end < len && levels[end] >= level) { + end++; } + for (low = start, high = end - 1; low < high; low++, high--) { + ch = charArray[low]; + charArray[low] = charArray[high]; + charArray[high] = ch; + if (sourceToTargetMap) { + ch = sourceToTargetMap[low]; + sourceToTargetMap[low] = sourceToTargetMap[high]; + sourceToTargetMap[high] = ch; + } + } + start = end; } - start = end; + start++; } - start++; - } - }; + }; - // for reference see 7 & BD16 in http://unicode.org/reports/tr9/ - // - var _symmetricSwap = function(charArray, levels, params) { - if (params.hiLevel !== 0 && _isSymmetricSwapping) { - for (var i = 0, index; i < charArray.length; i++) { - if (levels[i] === 1) { - index = _SWAP_TABLE.indexOf(charArray[i]); - if (index >= 0) { - charArray[i] = _SWAP_TABLE[index + 1]; + // for reference see 7 & BD16 in http://unicode.org/reports/tr9/ + // + var _symmetricSwap = function ( + charArray: string[], + levels: number[], + params: { hiLevel: number } + ): void { + if (params.hiLevel !== 0 && _isSymmetricSwapping) { + for (var i = 0, index; i < charArray.length; i++) { + if (levels[i] === 1) { + index = _SWAP_TABLE.indexOf(charArray[i]); + if (index >= 0) { + charArray[i] = _SWAP_TABLE[index + 1]; + } } } } - } - }; + }; - var _reorder = function(text, sourceToTargetMap, levels) { - var charArray = text.split(""), - params = { hiLevel: _dir }; + var _reorder = function ( + text: string, + sourceToTargetMap?: number[], + levels?: number[] + ): string { + var charArray = text.split(""), + params = { hiLevel: _dir }; - if (!levels) { - levels = []; - } - _computeLevels(charArray, levels, params); - _symmetricSwap(charArray, levels, params); - _invertByLevel(DIR_RTL + 1, charArray, sourceToTargetMap, levels, params); - _invertByLevel(DIR_RTL, charArray, sourceToTargetMap, levels, params); - return charArray.join(""); - }; + if (!levels) { + levels = []; + } + _computeLevels(charArray, levels, params); + _symmetricSwap(charArray, levels, params); + _invertByLevel( + DIR_RTL + 1, + charArray, + sourceToTargetMap, + levels, + params + ); + _invertByLevel(DIR_RTL, charArray, sourceToTargetMap, levels, params); + return charArray.join(""); + }; - // doBidiReorder( text, sourceToTargetMap, levels ) - // Performs Bidi reordering by implementing Unicode Bidi algorithm. - // Returns reordered string - // @text [String]: - // - input string to be reordered, this is input parameter - // $sourceToTargetMap [Array] (optional) - // - resultant mapping between input and output strings, this is output parameter - // $levels [Array] (optional) - // - array of calculated Bidi levels, , this is output parameter - this.__bidiEngine__.doBidiReorder = function( - text, - sourceToTargetMap, - levels - ) { - _init(text, sourceToTargetMap); - if (!_isInVisual && _isOutVisual && !_isOutRtl) { - // LLTR->VLTR, LRTL->VLTR - _dir = _isInRtl ? DIR_RTL : DIR_LTR; - text = _reorder(text, sourceToTargetMap, levels); - } else if (_isInVisual && _isOutVisual && _isInRtl ^ _isOutRtl) { - // VRTL->VLTR, VLTR->VRTL - _dir = _isInRtl ? DIR_RTL : DIR_LTR; - text = _invertString(text, sourceToTargetMap, levels); - } else if (!_isInVisual && _isOutVisual && _isOutRtl) { - // LLTR->VRTL, LRTL->VRTL - _dir = _isInRtl ? DIR_RTL : DIR_LTR; - text = _reorder(text, sourceToTargetMap, levels); - text = _invertString(text, sourceToTargetMap); - } else if (_isInVisual && !_isInRtl && !_isOutVisual && !_isOutRtl) { - // VLTR->LLTR - _dir = DIR_LTR; - text = _reorder(text, sourceToTargetMap, levels); - } else if (_isInVisual && !_isOutVisual && _isInRtl ^ _isOutRtl) { - // VLTR->LRTL, VRTL->LLTR - text = _invertString(text, sourceToTargetMap); - if (_isInRtl) { - //LLTR -> VLTR - _dir = DIR_LTR; + // doBidiReorder( text, sourceToTargetMap, levels ) + // Performs Bidi reordering by implementing Unicode Bidi algorithm. + // Returns reordered string + // @text [String]: + // - input string to be reordered, this is input parameter + // $sourceToTargetMap [Array] (optional) + // - resultant mapping between input and output strings, this is output parameter + // $levels [Array] (optional) + // - array of calculated Bidi levels, , this is output parameter + this.__bidiEngine__.doBidiReorder = function ( + text: string, + sourceToTargetMap?: number[], + levels?: number[] + ): string { + _init(text, sourceToTargetMap); + if (!_isInVisual && _isOutVisual && !_isOutRtl) { + // LLTR->VLTR, LRTL->VLTR + _dir = _isInRtl ? DIR_RTL : DIR_LTR; text = _reorder(text, sourceToTargetMap, levels); - } else { - //LRTL -> VRTL - _dir = DIR_RTL; + } else if ( + _isInVisual && + _isOutVisual && + Number(_isInRtl) ^ Number(_isOutRtl) + ) { + // VRTL->VLTR, VLTR->VRTL + _dir = _isInRtl ? DIR_RTL : DIR_LTR; + text = _invertString(text, sourceToTargetMap, levels); + } else if (!_isInVisual && _isOutVisual && _isOutRtl) { + // LLTR->VRTL, LRTL->VRTL + _dir = _isInRtl ? DIR_RTL : DIR_LTR; text = _reorder(text, sourceToTargetMap, levels); text = _invertString(text, sourceToTargetMap); - } - } else if (_isInVisual && _isInRtl && !_isOutVisual && _isOutRtl) { - // VRTL->LRTL - _dir = DIR_RTL; - text = _reorder(text, sourceToTargetMap, levels); - text = _invertString(text, sourceToTargetMap); - } else if (!_isInVisual && !_isOutVisual && _isInRtl ^ _isOutRtl) { - // LRTL->LLTR, LLTR->LRTL - var isSymmetricSwappingOrig = _isSymmetricSwapping; - if (_isInRtl) { - //LRTL->LLTR - _dir = DIR_RTL; - text = _reorder(text, sourceToTargetMap, levels); - _dir = DIR_LTR; - _isSymmetricSwapping = false; - text = _reorder(text, sourceToTargetMap, levels); - _isSymmetricSwapping = isSymmetricSwappingOrig; - } else { - //LLTR->LRTL + } else if (_isInVisual && !_isInRtl && !_isOutVisual && !_isOutRtl) { + // VLTR->LLTR _dir = DIR_LTR; text = _reorder(text, sourceToTargetMap, levels); + } else if ( + _isInVisual && + !_isOutVisual && + Number(_isInRtl) ^ Number(_isOutRtl) + ) { + // VLTR->LRTL, VRTL->LLTR text = _invertString(text, sourceToTargetMap); + if (_isInRtl) { + //LLTR -> VLTR + _dir = DIR_LTR; + text = _reorder(text, sourceToTargetMap, levels); + } else { + //LRTL -> VRTL + _dir = DIR_RTL; + text = _reorder(text, sourceToTargetMap, levels); + text = _invertString(text, sourceToTargetMap); + } + } else if (_isInVisual && _isInRtl && !_isOutVisual && _isOutRtl) { + // VRTL->LRTL _dir = DIR_RTL; - _isSymmetricSwapping = false; text = _reorder(text, sourceToTargetMap, levels); - _isSymmetricSwapping = isSymmetricSwappingOrig; text = _invertString(text, sourceToTargetMap); + } else if ( + !_isInVisual && + !_isOutVisual && + Number(_isInRtl) ^ Number(_isOutRtl) + ) { + // LRTL->LLTR, LLTR->LRTL + var isSymmetricSwappingOrig = _isSymmetricSwapping; + if (_isInRtl) { + //LRTL->LLTR + _dir = DIR_RTL; + text = _reorder(text, sourceToTargetMap, levels); + _dir = DIR_LTR; + _isSymmetricSwapping = false; + text = _reorder(text, sourceToTargetMap, levels); + _isSymmetricSwapping = isSymmetricSwappingOrig; + } else { + //LLTR->LRTL + _dir = DIR_LTR; + text = _reorder(text, sourceToTargetMap, levels); + text = _invertString(text, sourceToTargetMap); + _dir = DIR_RTL; + _isSymmetricSwapping = false; + text = _reorder(text, sourceToTargetMap, levels); + _isSymmetricSwapping = isSymmetricSwappingOrig; + text = _invertString(text, sourceToTargetMap); + } } - } - return text; - }; + return text; + }; - /** - * @name setOptions( options ) - * @function - * Sets options for Bidi conversion - * @param {Object}: - * - isInputVisual {boolean} (defaults to false): allowed values: true(Visual mode), false(Logical mode) - * - isInputRtl {boolean}: allowed values true(Right-to-left direction), false (Left-to-right directiion), undefined(Contectual direction, i.e.direction defined by first strong character of input string) - * - isOutputVisual {boolean} (defaults to false): allowed values: true(Visual mode), false(Logical mode) - * - isOutputRtl {boolean}: allowed values true(Right-to-left direction), false (Left-to-right directiion), undefined(Contectual direction, i.e.direction defined by first strong characterof input string) - * - isSymmetricSwapping {boolean} (defaults to false): allowed values true(needs symmetric swapping), false (no need in symmetric swapping), - */ - this.__bidiEngine__.setOptions = function(options) { - if (options) { - _isInVisual = options.isInputVisual; - _isOutVisual = options.isOutputVisual; - _isInRtl = options.isInputRtl; - _isOutRtl = options.isOutputRtl; - _isSymmetricSwapping = options.isSymmetricSwapping; - } - }; + /** + * @name setOptions( options ) + * @function + * Sets options for Bidi conversion + * @param {Object}: + * - isInputVisual {boolean} (defaults to false): allowed values: true(Visual mode), false(Logical mode) + * - isInputRtl {boolean}: allowed values true(Right-to-left direction), false (Left-to-right directiion), undefined(Contectual direction, i.e.direction defined by first strong character of input string) + * - isOutputVisual {boolean} (defaults to false): allowed values: true(Visual mode), false(Logical mode) + * - isOutputRtl {boolean}: allowed values true(Right-to-left direction), false (Left-to-right directiion), undefined(Contectual direction, i.e.direction defined by first strong characterof input string) + * - isSymmetricSwapping {boolean} (defaults to false): allowed values true(needs symmetric swapping), false (no need in symmetric swapping), + */ + this.__bidiEngine__.setOptions = function ( + options?: BidiEngineOptions + ): void { + if (options) { + _isInVisual = options.isInputVisual; + _isOutVisual = options.isOutputVisual; + _isInRtl = options.isInputRtl; + _isOutRtl = options.isOutputRtl; + _isSymmetricSwapping = options.isSymmetricSwapping; + } + }; - this.__bidiEngine__.setOptions(options); - return this.__bidiEngine__; - }; + this.__bidiEngine__.setOptions(options); + return this.__bidiEngine__; + // Cast documented: this is an ES5 function-constructor (invoked with + // `new` below); TypeScript cannot express new-ability on a plain + // function expression, so it is asserted to the construct signature. + } as unknown as BidiEngineConstructor; var _bidiUnicodeTypes = bidiUnicodeTypes; - var bidiEngine = new (jsPDF as any).__bidiEngine__({ isInputVisual: true }); + var bidiEngine = new jsPDFWithBidiEngine.__bidiEngine__({ + isInputVisual: true + }); - var bidiEngineFunction = function(args) { + var bidiEngineFunction = function ( + args: BidiEnginePostProcessTextArgs + ): void { var text = args.text; var x = args.x; var y = args.y; var options = args.options || {}; var mutex = args.mutex || {}; var lang = options.lang; - var tmpText = []; + var tmpText: (string | (string | number)[])[] = []; options.isInputVisual = typeof options.isInputVisual === "boolean" ? options.isInputVisual : true; @@ -2673,17 +2787,19 @@ import { jsPDF } from "../jspdf.js"; for (i = 0; i < text.length; i += 1) { if (Object.prototype.toString.call(text[i]) === "[object Array]") { tmpText.push([ - bidiEngine.doBidiReorder(text[i][0]), + // The toString check above guarantees text[i] is a text chunk + // array whose first entry is the string to reorder. + bidiEngine.doBidiReorder(text[i][0] as string), text[i][1], text[i][2] ]); } else { - tmpText.push([bidiEngine.doBidiReorder(text[i])]); + tmpText.push([bidiEngine.doBidiReorder(text[i] as string)]); } } args.text = tmpText; } else { - args.text = bidiEngine.doBidiReorder(text); + args.text = bidiEngine.doBidiReorder(text as string); } bidiEngine.setOptions({ isInputVisual: true }); }; diff --git a/src/libs/console.ts b/src/libs/console.ts index 4f18f44ff..b3d35da7f 100644 --- a/src/libs/console.ts +++ b/src/libs/console.ts @@ -1,27 +1,30 @@ import { globalObject } from "./globalObject.js"; -function consoleLog(..._args: any[]) { +function consoleLog(...args: unknown[]): void { if (globalObject.console && typeof globalObject.console.log === "function") { - globalObject.console.log.apply(globalObject.console, arguments); + globalObject.console.log.apply(globalObject.console, args); } } -function consoleWarn(str?: any, ..._rest: any[]) { +function consoleWarn(...args: unknown[]): void { if (globalObject.console) { if (typeof globalObject.console.warn === "function") { - globalObject.console.warn.apply(globalObject.console, arguments); + globalObject.console.warn.apply(globalObject.console, args); } else { - consoleLog.call(null, arguments); + // Note: forwards the whole argument list as a single array argument, + // preserved from the original implementation (which passed the + // `arguments` object). + consoleLog.call(null, args); } } } -function consoleError(str?: any, ..._rest: any[]) { +function consoleError(...args: unknown[]): void { if (globalObject.console) { if (typeof globalObject.console.error === "function") { - globalObject.console.error.apply(globalObject.console, arguments); + globalObject.console.error.apply(globalObject.console, args); } else { - consoleLog(str); + consoleLog(args[0]); } } } diff --git a/src/libs/fontFace.ts b/src/libs/fontFace.ts index 35b30eb76..5138850b2 100644 --- a/src/libs/fontFace.ts +++ b/src/libs/fontFace.ts @@ -1,12 +1,51 @@ -function toLookup(arr) { - return arr.reduce(function(lookup, name, index) { +export interface FontFaceSource { + url: string; + format?: string; +} + +export interface FontFaceRef { + name: string; + style: string; +} + +export interface FontFaceInput { + family: string; + style?: string; + weight?: string | number; + stretch?: string; + src?: FontFaceSource[]; + ref?: FontFaceRef; +} + +type FontStyle = "italic" | "oblique" | "normal"; + +export interface NormalizedFontFace { + family: string; + style: FontStyle; + weight: number; + stretch: string; + src: FontFaceSource[]; + ref: FontFaceRef; +} + +type WeightSet = { [weight: string]: NormalizedFontFace }; +type StyleSet = { [style: string]: WeightSet }; +type StretchSet = { [stretch: string]: StyleSet }; +export type FontFaceMap = { [family: string]: StretchSet }; + +function toLookup(arr: Array): { [key: string]: number } { + return arr.reduce(function ( + lookup: { [key: string]: number }, + name: string | number, + index: number + ) { lookup[name] = index; return lookup; }, {}); } -var fontStyleOrder = { +var fontStyleOrder: { [style: string]: FontStyle[] } = { italic: ["italic", "oblique", "normal"], oblique: ["oblique", "italic", "normal"], normal: ["normal", "oblique", "italic"] @@ -31,19 +70,21 @@ var fontStretchLookup = toLookup(fontStretchOrder); var fontWeights = [100, 200, 300, 400, 500, 600, 700, 800, 900]; var fontWeightsLookup = toLookup(fontWeights); -function normalizeFontStretch(stretch) { +function normalizeFontStretch(stretch?: string): string { stretch = stretch || "normal"; return typeof fontStretchLookup[stretch] === "number" ? stretch : "normal"; } -function normalizeFontStyle(style) { +function normalizeFontStyle(style?: string): FontStyle { style = style || "normal"; - return fontStyleOrder[style] ? style : "normal"; + // If the lookup succeeds, `style` is one of the keys of fontStyleOrder, + // i.e. a FontStyle. + return fontStyleOrder[style] ? (style as FontStyle) : "normal"; } -function normalizeFontWeight(weight) { +function normalizeFontWeight(weight?: string | number): number { if (!weight) { return 400; } @@ -67,7 +108,7 @@ function normalizeFontWeight(weight) { } } -export function normalizeFontFace(fontFace) { +export function normalizeFontFace(fontFace: FontFaceInput): NormalizedFontFace { var family = fontFace.family.replace(/"|'/g, "").toLowerCase(); var style = normalizeFontStyle(fontFace.style); @@ -95,8 +136,8 @@ export function normalizeFontFace(fontFace) { * fonts. * @private */ -export function buildFontFaceMap(fontFaces) { - var map = {}; +export function buildFontFaceMap(fontFaces: FontFaceInput[]): FontFaceMap { + var map: FontFaceMap = {}; for (var i = 0; i < fontFaces.length; ++i) { var normalized = normalizeFontFace(fontFaces[i]); @@ -127,7 +168,12 @@ export function buildFontFaceMap(fontFaces) { * @private */ -function searchFromPivot(matchingSet, order, pivot, dir) { +function searchFromPivot( + matchingSet: { [key: string]: T }, + order: ReadonlyArray, + pivot: number, + dir: number +): T | undefined { var i; for (i = pivot; i >= 0 && i < order.length; i += dir) { @@ -143,7 +189,10 @@ function searchFromPivot(matchingSet, order, pivot, dir) { } } -function resolveFontStretch(stretch, matchingSet) { +function resolveFontStretch( + stretch: string, + matchingSet: StretchSet +): StyleSet { if (matchingSet[stretch]) { return matchingSet[stretch]; } @@ -166,7 +215,10 @@ function resolveFontStretch(stretch, matchingSet) { return match; } -function resolveFontStyle(fontStyle, matchingSet) { +function resolveFontStyle( + fontStyle: FontStyle, + matchingSet: StyleSet +): WeightSet { if (matchingSet[fontStyle]) { return matchingSet[fontStyle]; } @@ -184,7 +236,10 @@ function resolveFontStyle(fontStyle, matchingSet) { throw new Error("Could not find a matching font-style for " + fontStyle); } -function resolveFontWeight(weight, matchingSet) { +function resolveFontWeight( + weight: number, + matchingSet: WeightSet +): NormalizedFontFace { if (matchingSet[weight]) { return matchingSet[weight]; } @@ -215,7 +270,7 @@ function resolveFontWeight(weight, matchingSet) { return match; } -var defaultGenericFontFamilies = { +var defaultGenericFontFamilies: { [family: string]: string } = { "sans-serif": "helvetica", fixed: "courier", monospace: "courier", @@ -225,7 +280,7 @@ var defaultGenericFontFamilies = { serif: "times" }; -var systemFonts = { +var systemFonts: { [font: string]: string } = { caption: "times", icon: "times", menu: "times", @@ -234,22 +289,31 @@ var systemFonts = { "status-bar": "times" }; -function ruleToString(rule) { +function ruleToString(rule: NormalizedFontFace): string { return [rule.stretch, rule.style, rule.weight, rule.family].join(" "); } -export function resolveFontFace(fontFaceMap, rules, opts?) { +export interface ResolveFontFaceOptions { + defaultFontFamily?: string; + genericFontFamilies?: { [family: string]: string }; +} + +export function resolveFontFace( + fontFaceMap: FontFaceMap, + rules: FontFaceInput[], + opts?: ResolveFontFaceOptions +): NormalizedFontFace { opts = opts || {}; var defaultFontFamily = opts.defaultFontFamily || "times"; - var genericFontFamilies = Object.assign( + var genericFontFamilies: { [family: string]: string } = Object.assign( {}, defaultGenericFontFamilies, opts.genericFontFamilies || {} ); - var rule = null; - var matches = null; + var rule: NormalizedFontFace = null; + var matches: StretchSet = null; for (var i = 0; i < rules.length; ++i) { rule = normalizeFontFace(rules[i]); @@ -280,18 +344,18 @@ export function resolveFontFace(fontFaceMap, rules, opts?) { ); } - matches = resolveFontStretch(rule.stretch, matches); - matches = resolveFontStyle(rule.style, matches); - matches = resolveFontWeight(rule.weight, matches); + var styleSet = resolveFontStretch(rule.stretch, matches); + var weightSet = resolveFontStyle(rule.style, styleSet); + var font = resolveFontWeight(rule.weight, weightSet); - if (!matches) { + if (!font) { // We should've fount throw new Error( "Failed to resolve a font for the rule '" + ruleToString(rule) + "'." ); } - return matches; + return font; } /** @@ -299,15 +363,19 @@ export function resolveFontFace(fontFaceMap, rules, opts?) { * @param {FontFace} font * @private */ -export function toStyleName(font) { +export function toStyleName(font: { + weight: string | number; + style: string; + stretch: string; +}): string { return [font.weight, font.style, font.stretch].join(" "); } -function eatWhiteSpace(input) { +function eatWhiteSpace(input: string): string { return input.trimLeft(); } -function parseQuotedFontFamily(input, quote) { +function parseQuotedFontFamily(input: string, quote: string): string[] | null { var index = 0; while (index < input.length) { @@ -324,7 +392,7 @@ function parseQuotedFontFamily(input, quote) { return null; } -function parseNonQuotedFontFamily(input) { +function parseNonQuotedFontFamily(input: string): string[] | null { // It implements part of the identifier parser here: https://www.w3.org/TR/CSS21/syndata.html#value-def-identifier // // NOTE: This parser pretty much ignores escaped identifiers and that there is a thing called unicode. @@ -345,9 +413,9 @@ function parseNonQuotedFontFamily(input) { var defaultFont = ["times"]; -export function parseFontFamily(input) { - var result = []; - var ch, parsed; +export function parseFontFamily(input: string): string[] { + var result: string[] = []; + var ch: string, parsed: string[] | null; var remaining = input.trim(); if (remaining === "") { diff --git a/src/libs/globalObject.ts b/src/libs/globalObject.ts index 21204efab..805f8832c 100644 --- a/src/libs/globalObject.ts +++ b/src/libs/globalObject.ts @@ -1,11 +1,18 @@ -declare const global: any; +declare const global: typeof globalThis; -export var globalObject = (function(this: any) { - return "undefined" !== typeof window - ? window - : "undefined" !== typeof global - ? global - : "undefined" !== typeof self - ? self - : this; +/** + * The runtime global object. The intersection with a string-indexed record + * reflects reality: plugins and polyfills read and install members that the + * standard `globalThis` type does not declare. + */ +export var globalObject = (function (this: unknown) { + return ( + "undefined" !== typeof window + ? window + : "undefined" !== typeof global + ? global + : "undefined" !== typeof self + ? self + : this + ) as typeof globalThis & Record; })(); diff --git a/src/libs/md5.ts b/src/libs/md5.ts index af75064b3..507d19e1e 100644 --- a/src/libs/md5.ts +++ b/src/libs/md5.ts @@ -8,7 +8,7 @@ * Modified by: Owen Leong */ -function md5cycle(x, k) { +function md5cycle(x: number[], k: number[]): void { var a = x[0], b = x[1], c = x[2], @@ -88,28 +88,67 @@ function md5cycle(x, k) { x[3] = add32(d, x[3]); } -function cmn(q, a, b, x, s, t) { +function cmn( + q: number, + a: number, + b: number, + x: number, + s: number, + t: number +): number { a = add32(add32(a, q), add32(x, t)); return add32((a << s) | (a >>> (32 - s)), b); } -function ff(a, b, c, d, x, s, t) { +function ff( + a: number, + b: number, + c: number, + d: number, + x: number, + s: number, + t: number +): number { return cmn((b & c) | (~b & d), a, b, x, s, t); } -function gg(a, b, c, d, x, s, t) { +function gg( + a: number, + b: number, + c: number, + d: number, + x: number, + s: number, + t: number +): number { return cmn((b & d) | (c & ~d), a, b, x, s, t); } -function hh(a, b, c, d, x, s, t) { +function hh( + a: number, + b: number, + c: number, + d: number, + x: number, + s: number, + t: number +): number { return cmn(b ^ c ^ d, a, b, x, s, t); } -function ii(a, b, c, d, x, s, t) { +function ii( + a: number, + b: number, + c: number, + d: number, + x: number, + s: number, + t: number +): number { return cmn(c ^ (b | ~d), a, b, x, s, t); } -function md51(s) { +function md51(s: string): number[] { // txt = ''; var n = s.length, state = [1732584193, -271733879, -1732584194, 271733878], @@ -120,8 +159,8 @@ function md51(s) { s = s.substring(i - 64); var tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; for (i = 0; i < s.length; i++) - tail[i >> 2] |= s.charCodeAt(i) << (i % 4 << 3); - tail[i >> 2] |= 0x80 << (i % 4 << 3); + tail[i >> 2] |= s.charCodeAt(i) << ((i % 4) << 3); + tail[i >> 2] |= 0x80 << ((i % 4) << 3); if (i > 55) { md5cycle(state, tail); for (i = 0; i < 16; i++) tail[i] = 0; @@ -146,7 +185,7 @@ function md51(s) { * providing access to strings as preformed UTF-8 * 8-bit unsigned value arrays. */ -function md5blk(s) { +function md5blk(s: string): number[] { /* I figured global was faster. */ var md5blks = [], i; /* Andy King said do it this way. */ @@ -162,7 +201,7 @@ function md5blk(s) { var hex_chr = "0123456789abcdef".split(""); -function rhex(n) { +function rhex(n: number): string { var s = "", j = 0; for (; j < 4; j++) @@ -170,13 +209,14 @@ function rhex(n) { return s; } -function hex(x) { - for (var i = 0; i < x.length; i++) x[i] = rhex(x[i]); +function hex(x: Array): string { + // The array starts out holding numbers and is converted to hex strings in place. + for (var i = 0; i < x.length; i++) x[i] = rhex(x[i] as number); return x.join(""); } // Converts a 4-byte number to byte string -function singleToByteString(n) { +function singleToByteString(n: number): string { return String.fromCharCode( (n & 0xff) >> 0, (n & 0xff00) >> 8, @@ -186,23 +226,23 @@ function singleToByteString(n) { } // Converts an array of numbers to a byte string -function toByteString(x) { +function toByteString(x: number[]): string { return x.map(singleToByteString).join(""); } // Returns the MD5 hash as a byte string -function md5Bin(s) { +function md5Bin(s: string): string { return toByteString(md51(s)); } // Returns MD5 hash as a hex string -function md5(s) { +function md5(s: string): string { return hex(md51(s)); } var md5Check = md5("hello") != "5d41402abc4b2a76b9719d911017c592"; -function add32(a, b) { +function add32(a: number, b: number): number { if (md5Check) { /* if the md5Check does not match the expected value, we're dealing diff --git a/src/libs/omggif.ts b/src/libs/omggif.ts index a9a60cf2f..9edbc1f24 100644 --- a/src/libs/omggif.ts +++ b/src/libs/omggif.ts @@ -31,243 +31,313 @@ import { console } from "./console.js"; -function GifWriter(buf, width, height, gopts) { - var p = 0; +/** Any byte-indexable buffer the encoder/decoder can read from / write to. */ +type GifBuffer = number[] | Uint8Array; - var gopts = gopts === undefined ? {} : gopts; - var loop_count = gopts.loop === undefined ? null : gopts.loop; - var global_palette = gopts.palette === undefined ? null : gopts.palette; +/** Buffer accepted as the pixel output of the frame blitting routines. */ +type GifPixelBuffer = number[] | Uint8Array | Uint8ClampedArray; - if (width <= 0 || height <= 0 || width > 65535 || height > 65535) - throw new Error("Width/Height invalid."); - - function check_palette_and_num_colors(palette) { - var num_colors = palette.length; - if (num_colors < 2 || num_colors > 256 || num_colors & (num_colors - 1)) { - throw new Error( - "Invalid code/color length, must be power of 2 and 2 .. 256." - ); - } - return num_colors; - } - - // - Header. - buf[p++] = 0x47; - buf[p++] = 0x49; - buf[p++] = 0x46; // GIF - buf[p++] = 0x38; - buf[p++] = 0x39; - buf[p++] = 0x61; // 89a - - // Handling of Global Color Table (palette) and background index. - var gp_num_colors_pow2 = 0; - var background = 0; - if (global_palette !== null) { - var gp_num_colors = check_palette_and_num_colors(global_palette); - while ((gp_num_colors >>= 1)) ++gp_num_colors_pow2; - gp_num_colors = 1 << gp_num_colors_pow2; - --gp_num_colors_pow2; - if (gopts.background !== undefined) { - background = gopts.background; - if (background >= gp_num_colors) - throw new Error("Background index out of range."); - // The GIF spec states that a background index of 0 should be ignored, so - // this is probably a mistake and you really want to set it to another - // slot in the palette. But actually in the end most browsers, etc end - // up ignoring this almost completely (including for dispose background). - if (background === 0) - throw new Error("Background index explicitly passed as 0."); - } - } - - // - Logical Screen Descriptor. - // NOTE(deanm): w/h apparently ignored by implementations, but set anyway. - buf[p++] = width & 0xff; - buf[p++] = (width >> 8) & 0xff; - buf[p++] = height & 0xff; - buf[p++] = (height >> 8) & 0xff; - // NOTE: Indicates 0-bpp original color resolution (unused?). - buf[p++] = (global_palette !== null ? 0x80 : 0) | gp_num_colors_pow2; // Global Color Table Flag. // NOTE: No sort flag (unused?). - buf[p++] = background; // Background Color Index. - buf[p++] = 0; // Pixel aspect ratio (unused?). - - // - Global Color Table - if (global_palette !== null) { - for (var i = 0, il = global_palette.length; i < il; ++i) { - var rgb = global_palette[i]; - buf[p++] = (rgb >> 16) & 0xff; - buf[p++] = (rgb >> 8) & 0xff; - buf[p++] = rgb & 0xff; - } - } - - if (loop_count !== null) { - // Netscape block for looping. - if (loop_count < 0 || loop_count > 65535) - throw new Error("Loop count invalid."); - // Extension code, label, and length. - buf[p++] = 0x21; - buf[p++] = 0xff; - buf[p++] = 0x0b; - // NETSCAPE2.0 - buf[p++] = 0x4e; - buf[p++] = 0x45; - buf[p++] = 0x54; - buf[p++] = 0x53; - buf[p++] = 0x43; - buf[p++] = 0x41; - buf[p++] = 0x50; - buf[p++] = 0x45; - buf[p++] = 0x32; - buf[p++] = 0x2e; - buf[p++] = 0x30; - // Sub-block - buf[p++] = 0x03; - buf[p++] = 0x01; - buf[p++] = loop_count & 0xff; - buf[p++] = (loop_count >> 8) & 0xff; - buf[p++] = 0x00; // Terminator. - } +interface GifWriterOptions { + loop?: number; + palette?: number[] | null; + background?: number; +} - var ended = false; +interface GifFrameOptions { + palette?: number[] | null; + delay?: number; + disposal?: number; + transparent?: number | null; +} - this.addFrame = function(x, y, w, h, indexed_pixels, opts) { - if (ended === true) { - --p; - ended = false; - } // Un-end. +interface GifFrameInfo { + x: number; + y: number; + width: number; + height: number; + has_local_palette: boolean; + palette_offset: number | null; + palette_size: number | null; + data_offset: number; + data_length: number; + transparent_index: number | null; + interlaced: boolean; + delay: number; + disposal: number; +} - opts = opts === undefined ? {} : opts; +class GifWriter { + // Methods are closures assigned in the constructor; `declare` keeps the + // field declarations type-only (no runtime class-field emit). + declare addFrame: ( + x: number, + y: number, + w: number, + h: number, + indexed_pixels: GifBuffer, + opts?: GifFrameOptions + ) => number; + declare end: () => number; + declare getOutputBuffer: () => GifBuffer; + declare setOutputBuffer: (v: GifBuffer) => void; + declare getOutputBufferPosition: () => number; + declare setOutputBufferPosition: (v: number) => void; + + constructor( + buf: GifBuffer, + width: number, + height: number, + gopts?: GifWriterOptions + ) { + var p = 0; - // TODO(deanm): Bounds check x, y. Do they need to be within the virtual - // canvas width/height, I imagine? - if (x < 0 || y < 0 || x > 65535 || y > 65535) - throw new Error("x/y invalid."); + gopts = gopts === undefined ? {} : gopts; + var loop_count = gopts.loop === undefined ? null : gopts.loop; + var global_palette = gopts.palette === undefined ? null : gopts.palette; - if (w <= 0 || h <= 0 || w > 65535 || h > 65535) + if (width <= 0 || height <= 0 || width > 65535 || height > 65535) throw new Error("Width/Height invalid."); - if (indexed_pixels.length < w * h) - throw new Error("Not enough pixels for the frame size."); - - var using_local_palette = true; - var palette = opts.palette; - if (palette === undefined || palette === null) { - using_local_palette = false; - palette = global_palette; - } - - if (palette === undefined || palette === null) - throw new Error("Must supply either a local or global palette."); - - var num_colors = check_palette_and_num_colors(palette); - - // Compute the min_code_size (power of 2), destroying num_colors. - var min_code_size = 0; - while ((num_colors >>= 1)) ++min_code_size; - num_colors = 1 << min_code_size; // Now we can easily get it back. - - var delay = opts.delay === undefined ? 0 : opts.delay; - - // From the spec: - // 0 - No disposal specified. The decoder is - // not required to take any action. - // 1 - Do not dispose. The graphic is to be left - // in place. - // 2 - Restore to background color. The area used by the - // graphic must be restored to the background color. - // 3 - Restore to previous. The decoder is required to - // restore the area overwritten by the graphic with - // what was there prior to rendering the graphic. - // 4-7 - To be defined. - // NOTE(deanm): Dispose background doesn't really work, apparently most - // browsers ignore the background palette index and clear to transparency. - var disposal = opts.disposal === undefined ? 0 : opts.disposal; - if (disposal < 0 || disposal > 3) - // 4-7 is reserved. - throw new Error("Disposal out of range."); - - var use_transparency = false; - var transparent_index = 0; - if (opts.transparent !== undefined && opts.transparent !== null) { - use_transparency = true; - transparent_index = opts.transparent; - if (transparent_index < 0 || transparent_index >= num_colors) - throw new Error("Transparent color index."); + function check_palette_and_num_colors(palette: number[]): number { + var num_colors = palette.length; + if (num_colors < 2 || num_colors > 256 || num_colors & (num_colors - 1)) { + throw new Error( + "Invalid code/color length, must be power of 2 and 2 .. 256." + ); + } + return num_colors; } - if (disposal !== 0 || use_transparency || delay !== 0) { - // - Graphics Control Extension - buf[p++] = 0x21; - buf[p++] = 0xf9; // Extension / Label. - buf[p++] = 4; // Byte size. - - buf[p++] = (disposal << 2) | (use_transparency === true ? 1 : 0); - buf[p++] = delay & 0xff; - buf[p++] = (delay >> 8) & 0xff; - buf[p++] = transparent_index; // Transparent color index. - buf[p++] = 0; // Block Terminator. + // - Header. + buf[p++] = 0x47; + buf[p++] = 0x49; + buf[p++] = 0x46; // GIF + buf[p++] = 0x38; + buf[p++] = 0x39; + buf[p++] = 0x61; // 89a + + // Handling of Global Color Table (palette) and background index. + var gp_num_colors_pow2 = 0; + var background = 0; + if (global_palette !== null) { + var gp_num_colors = check_palette_and_num_colors(global_palette); + while ((gp_num_colors >>= 1)) ++gp_num_colors_pow2; + gp_num_colors = 1 << gp_num_colors_pow2; + --gp_num_colors_pow2; + if (gopts.background !== undefined) { + background = gopts.background; + if (background >= gp_num_colors) + throw new Error("Background index out of range."); + // The GIF spec states that a background index of 0 should be ignored, so + // this is probably a mistake and you really want to set it to another + // slot in the palette. But actually in the end most browsers, etc end + // up ignoring this almost completely (including for dispose background). + if (background === 0) + throw new Error("Background index explicitly passed as 0."); + } } - // - Image Descriptor - buf[p++] = 0x2c; // Image Seperator. - buf[p++] = x & 0xff; - buf[p++] = (x >> 8) & 0xff; // Left. - buf[p++] = y & 0xff; - buf[p++] = (y >> 8) & 0xff; // Top. - buf[p++] = w & 0xff; - buf[p++] = (w >> 8) & 0xff; - buf[p++] = h & 0xff; - buf[p++] = (h >> 8) & 0xff; - // NOTE: No sort flag (unused?). - // TODO(deanm): Support interlace. - buf[p++] = using_local_palette === true ? 0x80 | (min_code_size - 1) : 0; - - // - Local Color Table - if (using_local_palette === true) { - for (var i = 0, il = palette.length; i < il; ++i) { - var rgb = palette[i]; + // - Logical Screen Descriptor. + // NOTE(deanm): w/h apparently ignored by implementations, but set anyway. + buf[p++] = width & 0xff; + buf[p++] = (width >> 8) & 0xff; + buf[p++] = height & 0xff; + buf[p++] = (height >> 8) & 0xff; + // NOTE: Indicates 0-bpp original color resolution (unused?). + buf[p++] = (global_palette !== null ? 0x80 : 0) | gp_num_colors_pow2; // Global Color Table Flag. // NOTE: No sort flag (unused?). + buf[p++] = background; // Background Color Index. + buf[p++] = 0; // Pixel aspect ratio (unused?). + + // - Global Color Table + if (global_palette !== null) { + for (var i = 0, il = global_palette.length; i < il; ++i) { + var rgb = global_palette[i]; buf[p++] = (rgb >> 16) & 0xff; buf[p++] = (rgb >> 8) & 0xff; buf[p++] = rgb & 0xff; } } - p = GifWriterOutputLZWCodeStream( - buf, - p, - min_code_size < 2 ? 2 : min_code_size, - indexed_pixels - ); + if (loop_count !== null) { + // Netscape block for looping. + if (loop_count < 0 || loop_count > 65535) + throw new Error("Loop count invalid."); + // Extension code, label, and length. + buf[p++] = 0x21; + buf[p++] = 0xff; + buf[p++] = 0x0b; + // NETSCAPE2.0 + buf[p++] = 0x4e; + buf[p++] = 0x45; + buf[p++] = 0x54; + buf[p++] = 0x53; + buf[p++] = 0x43; + buf[p++] = 0x41; + buf[p++] = 0x50; + buf[p++] = 0x45; + buf[p++] = 0x32; + buf[p++] = 0x2e; + buf[p++] = 0x30; + // Sub-block + buf[p++] = 0x03; + buf[p++] = 0x01; + buf[p++] = loop_count & 0xff; + buf[p++] = (loop_count >> 8) & 0xff; + buf[p++] = 0x00; // Terminator. + } + + var ended = false; + + this.addFrame = function ( + x: number, + y: number, + w: number, + h: number, + indexed_pixels: GifBuffer, + opts?: GifFrameOptions + ): number { + if (ended === true) { + --p; + ended = false; + } // Un-end. + + opts = opts === undefined ? {} : opts; + + // TODO(deanm): Bounds check x, y. Do they need to be within the virtual + // canvas width/height, I imagine? + if (x < 0 || y < 0 || x > 65535 || y > 65535) + throw new Error("x/y invalid."); + + if (w <= 0 || h <= 0 || w > 65535 || h > 65535) + throw new Error("Width/Height invalid."); + + if (indexed_pixels.length < w * h) + throw new Error("Not enough pixels for the frame size."); + + var using_local_palette = true; + var palette = opts.palette; + if (palette === undefined || palette === null) { + using_local_palette = false; + palette = global_palette; + } - return p; - }; + if (palette === undefined || palette === null) + throw new Error("Must supply either a local or global palette."); + + var num_colors = check_palette_and_num_colors(palette); + + // Compute the min_code_size (power of 2), destroying num_colors. + var min_code_size = 0; + while ((num_colors >>= 1)) ++min_code_size; + num_colors = 1 << min_code_size; // Now we can easily get it back. + + var delay = opts.delay === undefined ? 0 : opts.delay; + + // From the spec: + // 0 - No disposal specified. The decoder is + // not required to take any action. + // 1 - Do not dispose. The graphic is to be left + // in place. + // 2 - Restore to background color. The area used by the + // graphic must be restored to the background color. + // 3 - Restore to previous. The decoder is required to + // restore the area overwritten by the graphic with + // what was there prior to rendering the graphic. + // 4-7 - To be defined. + // NOTE(deanm): Dispose background doesn't really work, apparently most + // browsers ignore the background palette index and clear to transparency. + var disposal = opts.disposal === undefined ? 0 : opts.disposal; + if (disposal < 0 || disposal > 3) + // 4-7 is reserved. + throw new Error("Disposal out of range."); + + var use_transparency = false; + var transparent_index = 0; + if (opts.transparent !== undefined && opts.transparent !== null) { + use_transparency = true; + transparent_index = opts.transparent; + if (transparent_index < 0 || transparent_index >= num_colors) + throw new Error("Transparent color index."); + } - this.end = function() { - if (ended === false) { - buf[p++] = 0x3b; // Trailer. - ended = true; - } - return p; - }; - - this.getOutputBuffer = function() { - return buf; - }; - this.setOutputBuffer = function(v) { - buf = v; - }; - this.getOutputBufferPosition = function() { - return p; - }; - this.setOutputBufferPosition = function(v) { - p = v; - }; + if (disposal !== 0 || use_transparency || delay !== 0) { + // - Graphics Control Extension + buf[p++] = 0x21; + buf[p++] = 0xf9; // Extension / Label. + buf[p++] = 4; // Byte size. + + buf[p++] = (disposal << 2) | (use_transparency === true ? 1 : 0); + buf[p++] = delay & 0xff; + buf[p++] = (delay >> 8) & 0xff; + buf[p++] = transparent_index; // Transparent color index. + buf[p++] = 0; // Block Terminator. + } + + // - Image Descriptor + buf[p++] = 0x2c; // Image Seperator. + buf[p++] = x & 0xff; + buf[p++] = (x >> 8) & 0xff; // Left. + buf[p++] = y & 0xff; + buf[p++] = (y >> 8) & 0xff; // Top. + buf[p++] = w & 0xff; + buf[p++] = (w >> 8) & 0xff; + buf[p++] = h & 0xff; + buf[p++] = (h >> 8) & 0xff; + // NOTE: No sort flag (unused?). + // TODO(deanm): Support interlace. + buf[p++] = using_local_palette === true ? 0x80 | (min_code_size - 1) : 0; + + // - Local Color Table + if (using_local_palette === true) { + for (var i = 0, il = palette.length; i < il; ++i) { + var rgb = palette[i]; + buf[p++] = (rgb >> 16) & 0xff; + buf[p++] = (rgb >> 8) & 0xff; + buf[p++] = rgb & 0xff; + } + } + + p = GifWriterOutputLZWCodeStream( + buf, + p, + min_code_size < 2 ? 2 : min_code_size, + indexed_pixels + ); + + return p; + }; + + this.end = function (): number { + if (ended === false) { + buf[p++] = 0x3b; // Trailer. + ended = true; + } + return p; + }; + + this.getOutputBuffer = function (): GifBuffer { + return buf; + }; + this.setOutputBuffer = function (v: GifBuffer): void { + buf = v; + }; + this.getOutputBufferPosition = function (): number { + return p; + }; + this.setOutputBufferPosition = function (v: number): void { + p = v; + }; + } } // Main compression routine, palette indexes -> LZW code stream. // |index_stream| must have at least one entry. -function GifWriterOutputLZWCodeStream(buf, p, min_code_size, index_stream) { +function GifWriterOutputLZWCodeStream( + buf: GifBuffer, + p: number, + min_code_size: number, + index_stream: GifBuffer +): number { buf[p++] = min_code_size; var cur_subblock = p++; // Pointing at the length field. @@ -282,7 +352,7 @@ function GifWriterOutputLZWCodeStream(buf, p, min_code_size, index_stream) { // bits here (and then we would write out). var cur = 0; - function emit_bytes_to_buffer(bit_block_size) { + function emit_bytes_to_buffer(bit_block_size: number): void { while (cur_shift >= bit_block_size) { buf[p++] = cur & 0xff; cur >>= 8; @@ -295,7 +365,7 @@ function GifWriterOutputLZWCodeStream(buf, p, min_code_size, index_stream) { } } - function emit_code(c) { + function emit_code(c: number): void { cur |= c << cur_shift; cur_shift += cur_code_size; emit_bytes_to_buffer(8); @@ -340,7 +410,7 @@ function GifWriterOutputLZWCodeStream(buf, p, min_code_size, index_stream) { // Output code for the current contents of the index buffer. var ib_code = index_stream[0] & code_mask; // Load first input index. - var code_table = {}; // Key'd on our 20-bit "tuple". + var code_table: Record = {}; // Key'd on our 20-bit "tuple". emit_code(clear_code); // Spec says first code should be a clear code. @@ -417,351 +487,382 @@ function GifWriterOutputLZWCodeStream(buf, p, min_code_size, index_stream) { return p; } -function GifReader(buf) { - var p = 0; - - // - Header (GIF87a or GIF89a). - if ( - buf[p++] !== 0x47 || - buf[p++] !== 0x49 || - buf[p++] !== 0x46 || - buf[p++] !== 0x38 || - ((buf[p++] + 1) & 0xfd) !== 0x38 || - buf[p++] !== 0x61 - ) { - throw new Error("Invalid GIF 87a/89a header."); - } +class GifReader { + // Methods are closures assigned in the constructor; `declare` keeps the + // field declarations type-only (no runtime class-field emit). + declare width: number; + declare height: number; + declare numFrames: () => number; + declare loopCount: () => number | null; + declare frameInfo: (frame_num: number) => GifFrameInfo; + declare decodeAndBlitFrameBGRA: ( + frame_num: number, + pixels: GifPixelBuffer + ) => void; + declare decodeAndBlitFrameRGBA: ( + frame_num: number, + pixels: GifPixelBuffer + ) => void; + + constructor(buf: GifBuffer) { + var p = 0; + + // - Header (GIF87a or GIF89a). + if ( + buf[p++] !== 0x47 || + buf[p++] !== 0x49 || + buf[p++] !== 0x46 || + buf[p++] !== 0x38 || + ((buf[p++] + 1) & 0xfd) !== 0x38 || + buf[p++] !== 0x61 + ) { + throw new Error("Invalid GIF 87a/89a header."); + } - // - Logical Screen Descriptor. - var width = buf[p++] | (buf[p++] << 8); - var height = buf[p++] | (buf[p++] << 8); - var pf0 = buf[p++]; // . - var global_palette_flag = pf0 >> 7; - var num_global_colors_pow2 = pf0 & 0x7; - var num_global_colors = 1 << (num_global_colors_pow2 + 1); - var background = buf[p++]; - buf[p++]; // Pixel aspect ratio (unused?). - - var global_palette_offset = null; - var global_palette_size = null; - - if (global_palette_flag) { - global_palette_offset = p; - global_palette_size = num_global_colors; - p += num_global_colors * 3; // Seek past palette. - } + // - Logical Screen Descriptor. + var width = buf[p++] | (buf[p++] << 8); + var height = buf[p++] | (buf[p++] << 8); + var pf0 = buf[p++]; // . + var global_palette_flag = pf0 >> 7; + var num_global_colors_pow2 = pf0 & 0x7; + var num_global_colors = 1 << (num_global_colors_pow2 + 1); + var background = buf[p++]; + buf[p++]; // Pixel aspect ratio (unused?). + + var global_palette_offset: number | null = null; + var global_palette_size: number | null = null; + + if (global_palette_flag) { + global_palette_offset = p; + global_palette_size = num_global_colors; + p += num_global_colors * 3; // Seek past palette. + } - var no_eof = true; - - var frames = []; - - var delay = 0; - var transparent_index = null; - var disposal = 0; // 0 - No disposal specified. - var loop_count = null; - - this.width = width; - this.height = height; - - while (no_eof && p < buf.length) { - switch (buf[p++]) { - case 0x21: // Graphics Control Extension Block - switch (buf[p++]) { - case 0xff: // Application specific block - // Try if it's a Netscape block (with animation loop counter). - if ( - buf[p] !== 0x0b || // 21 FF already read, check block size. - // NETSCAPE2.0 - (buf[p + 1] == 0x4e && - buf[p + 2] == 0x45 && - buf[p + 3] == 0x54 && - buf[p + 4] == 0x53 && - buf[p + 5] == 0x43 && - buf[p + 6] == 0x41 && - buf[p + 7] == 0x50 && - buf[p + 8] == 0x45 && - buf[p + 9] == 0x32 && - buf[p + 10] == 0x2e && - buf[p + 11] == 0x30 && - // Sub-block - buf[p + 12] == 0x03 && - buf[p + 13] == 0x01 && - buf[p + 16] == 0) - ) { - p += 14; - loop_count = buf[p++] | (buf[p++] << 8); + var no_eof = true; + + var frames: GifFrameInfo[] = []; + + var delay = 0; + var transparent_index: number | null = null; + var disposal = 0; // 0 - No disposal specified. + var loop_count: number | null = null; + + this.width = width; + this.height = height; + + while (no_eof && p < buf.length) { + switch (buf[p++]) { + case 0x21: // Graphics Control Extension Block + switch (buf[p++]) { + case 0xff: // Application specific block + // Try if it's a Netscape block (with animation loop counter). + if ( + buf[p] !== 0x0b || // 21 FF already read, check block size. + // NETSCAPE2.0 + (buf[p + 1] == 0x4e && + buf[p + 2] == 0x45 && + buf[p + 3] == 0x54 && + buf[p + 4] == 0x53 && + buf[p + 5] == 0x43 && + buf[p + 6] == 0x41 && + buf[p + 7] == 0x50 && + buf[p + 8] == 0x45 && + buf[p + 9] == 0x32 && + buf[p + 10] == 0x2e && + buf[p + 11] == 0x30 && + // Sub-block + buf[p + 12] == 0x03 && + buf[p + 13] == 0x01 && + buf[p + 16] == 0) + ) { + p += 14; + loop_count = buf[p++] | (buf[p++] << 8); + p++; // Skip terminator. + } else { + // We don't know what it is, just try to get past it. + p += 12; + while (true) { + // Seek through subblocks. + var block_size = buf[p++]; + // Bad block size (ex: undefined from an out of bounds read). + if (!(block_size >= 0)) throw Error("Invalid block size"); + if (block_size === 0) break; // 0 size is terminator + p += block_size; + } + } + break; + + case 0xf9: // Graphics Control Extension + if (buf[p++] !== 0x4 || buf[p + 4] !== 0) + throw new Error("Invalid graphics extension block."); + var pf1 = buf[p++]; + delay = buf[p++] | (buf[p++] << 8); + transparent_index = buf[p++]; + if ((pf1 & 1) === 0) transparent_index = null; + disposal = (pf1 >> 2) & 0x7; p++; // Skip terminator. - } else { - // We don't know what it is, just try to get past it. - p += 12; + break; + + case 0xfe: // Comment Extension. while (true) { // Seek through subblocks. var block_size = buf[p++]; // Bad block size (ex: undefined from an out of bounds read). if (!(block_size >= 0)) throw Error("Invalid block size"); if (block_size === 0) break; // 0 size is terminator + // console.log(buf.slice(p, p+block_size).toString('ascii')); p += block_size; } - } - break; - - case 0xf9: // Graphics Control Extension - if (buf[p++] !== 0x4 || buf[p + 4] !== 0) - throw new Error("Invalid graphics extension block."); - var pf1 = buf[p++]; - delay = buf[p++] | (buf[p++] << 8); - transparent_index = buf[p++]; - if ((pf1 & 1) === 0) transparent_index = null; - disposal = (pf1 >> 2) & 0x7; - p++; // Skip terminator. - break; - - case 0xfe: // Comment Extension. - while (true) { - // Seek through subblocks. - var block_size = buf[p++]; - // Bad block size (ex: undefined from an out of bounds read). - if (!(block_size >= 0)) throw Error("Invalid block size"); - if (block_size === 0) break; // 0 size is terminator - // console.log(buf.slice(p, p+block_size).toString('ascii')); - p += block_size; - } - break; - - default: - throw new Error( - "Unknown graphic control label: 0x" + buf[p - 1].toString(16) - ); - } - break; - - case 0x2c: // Image Descriptor. - var x = buf[p++] | (buf[p++] << 8); - var y = buf[p++] | (buf[p++] << 8); - var w = buf[p++] | (buf[p++] << 8); - var h = buf[p++] | (buf[p++] << 8); - var pf2 = buf[p++]; - var local_palette_flag = pf2 >> 7; - var interlace_flag = (pf2 >> 6) & 1; - var num_local_colors_pow2 = pf2 & 0x7; - var num_local_colors = 1 << (num_local_colors_pow2 + 1); - var palette_offset = global_palette_offset; - var palette_size = global_palette_size; - var has_local_palette = false; - if (local_palette_flag) { - var has_local_palette = true; - palette_offset = p; // Override with local palette. - palette_size = num_local_colors; - p += num_local_colors * 3; // Seek past palette. - } - - var data_offset = p; - - p++; // codesize - while (true) { - var block_size = buf[p++]; - // Bad block size (ex: undefined from an out of bounds read). - if (!(block_size >= 0)) throw Error("Invalid block size"); - if (block_size === 0) break; // 0 size is terminator - p += block_size; - } - - frames.push({ - x: x, - y: y, - width: w, - height: h, - has_local_palette: has_local_palette, - palette_offset: palette_offset, - palette_size: palette_size, - data_offset: data_offset, - data_length: p - data_offset, - transparent_index: transparent_index, - interlaced: !!interlace_flag, - delay: delay, - disposal: disposal - }); - break; - - case 0x3b: // Trailer Marker (end of file). - no_eof = false; - break; - - default: - throw new Error("Unknown gif block: 0x" + buf[p - 1].toString(16)); - break; + break; + + default: + throw new Error( + "Unknown graphic control label: 0x" + buf[p - 1].toString(16) + ); + } + break; + + case 0x2c: // Image Descriptor. + var x = buf[p++] | (buf[p++] << 8); + var y = buf[p++] | (buf[p++] << 8); + var w = buf[p++] | (buf[p++] << 8); + var h = buf[p++] | (buf[p++] << 8); + var pf2 = buf[p++]; + var local_palette_flag = pf2 >> 7; + var interlace_flag = (pf2 >> 6) & 1; + var num_local_colors_pow2 = pf2 & 0x7; + var num_local_colors = 1 << (num_local_colors_pow2 + 1); + var palette_offset = global_palette_offset; + var palette_size = global_palette_size; + var has_local_palette = false; + if (local_palette_flag) { + var has_local_palette = true; + palette_offset = p; // Override with local palette. + palette_size = num_local_colors; + p += num_local_colors * 3; // Seek past palette. + } + + var data_offset = p; + + p++; // codesize + while (true) { + var block_size = buf[p++]; + // Bad block size (ex: undefined from an out of bounds read). + if (!(block_size >= 0)) throw Error("Invalid block size"); + if (block_size === 0) break; // 0 size is terminator + p += block_size; + } + + frames.push({ + x: x, + y: y, + width: w, + height: h, + has_local_palette: has_local_palette, + palette_offset: palette_offset, + palette_size: palette_size, + data_offset: data_offset, + data_length: p - data_offset, + transparent_index: transparent_index, + interlaced: !!interlace_flag, + delay: delay, + disposal: disposal + }); + break; + + case 0x3b: // Trailer Marker (end of file). + no_eof = false; + break; + + default: + throw new Error("Unknown gif block: 0x" + buf[p - 1].toString(16)); + break; + } } - } - this.numFrames = function() { - return frames.length; - }; - - this.loopCount = function() { - return loop_count; - }; - - this.frameInfo = function(frame_num) { - if (frame_num < 0 || frame_num >= frames.length) - throw new Error("Frame index out of range."); - return frames[frame_num]; - }; - - this.decodeAndBlitFrameBGRA = function(frame_num, pixels) { - var frame = this.frameInfo(frame_num); - var num_pixels = frame.width * frame.height; + this.numFrames = function (): number { + return frames.length; + }; + + this.loopCount = function (): number | null { + return loop_count; + }; + + this.frameInfo = function (frame_num: number): GifFrameInfo { + if (frame_num < 0 || frame_num >= frames.length) + throw new Error("Frame index out of range."); + return frames[frame_num]; + }; + + this.decodeAndBlitFrameBGRA = function ( + this: GifReader, + frame_num: number, + pixels: GifPixelBuffer + ): void { + var frame = this.frameInfo(frame_num); + var num_pixels = frame.width * frame.height; + + if (num_pixels > 512 * 1024 * 1024) { + throw new Error("Image dimensions exceed 512MB, which is too large."); + } - if (num_pixels > 512 * 1024 * 1024) { - throw new Error("Image dimensions exceed 512MB, which is too large."); - } + var index_stream = new Uint8Array(num_pixels); // At most 8-bit indices. + GifReaderLZWOutputIndexStream( + buf, + frame.data_offset, + index_stream, + num_pixels + ); + var palette_offset = frame.palette_offset; + + // NOTE(deanm): It seems to be much faster to compare index to 256 than + // to === null. Not sure why, but CompareStub_EQ_STRICT shows up high in + // the profile, not sure if it's related to using a Uint8Array. + var trans = frame.transparent_index; + if (trans === null) trans = 256; + + // We are possibly just blitting to a portion of the entire frame. + // That is a subrect within the framerect, so the additional pixels + // must be skipped over after we finished a scanline. + var framewidth = frame.width; + var framestride = width - framewidth; + var xleft = framewidth; // Number of subrect pixels left in scanline. + + // Output indices of the top left and bottom right corners of the subrect. + var opbeg = (frame.y * width + frame.x) * 4; + var opend = ((frame.y + frame.height) * width + frame.x) * 4; + var op = opbeg; + + var scanstride = framestride * 4; + + // Use scanstride to skip past the rows when interlacing. This is skipping + // 7 rows for the first two passes, then 3 then 1. + if (frame.interlaced === true) { + scanstride += width * 4 * 7; // Pass 1. + } - var index_stream = new Uint8Array(num_pixels); // At most 8-bit indices. - GifReaderLZWOutputIndexStream( - buf, - frame.data_offset, - index_stream, - num_pixels - ); - var palette_offset = frame.palette_offset; - - // NOTE(deanm): It seems to be much faster to compare index to 256 than - // to === null. Not sure why, but CompareStub_EQ_STRICT shows up high in - // the profile, not sure if it's related to using a Uint8Array. - var trans = frame.transparent_index; - if (trans === null) trans = 256; - - // We are possibly just blitting to a portion of the entire frame. - // That is a subrect within the framerect, so the additional pixels - // must be skipped over after we finished a scanline. - var framewidth = frame.width; - var framestride = width - framewidth; - var xleft = framewidth; // Number of subrect pixels left in scanline. - - // Output indices of the top left and bottom right corners of the subrect. - var opbeg = (frame.y * width + frame.x) * 4; - var opend = ((frame.y + frame.height) * width + frame.x) * 4; - var op = opbeg; - - var scanstride = framestride * 4; - - // Use scanstride to skip past the rows when interlacing. This is skipping - // 7 rows for the first two passes, then 3 then 1. - if (frame.interlaced === true) { - scanstride += width * 4 * 7; // Pass 1. - } + var interlaceskip = 8; // Tracking the row interval in the current pass. + + for (var i = 0, il = index_stream.length; i < il; ++i) { + var index = index_stream[i]; + + if (xleft === 0) { + // Beginning of new scan line + op += scanstride; + xleft = framewidth; + if (op >= opend) { + // Catch the wrap to switch passes when interlacing. + scanstride = framestride * 4 + width * 4 * (interlaceskip - 1); + // interlaceskip / 2 * 4 is interlaceskip << 1. + op = opbeg + (framewidth + framestride) * (interlaceskip << 1); + interlaceskip >>= 1; + } + } - var interlaceskip = 8; // Tracking the row interval in the current pass. - - for (var i = 0, il = index_stream.length; i < il; ++i) { - var index = index_stream[i]; - - if (xleft === 0) { - // Beginning of new scan line - op += scanstride; - xleft = framewidth; - if (op >= opend) { - // Catch the wrap to switch passes when interlacing. - scanstride = framestride * 4 + width * 4 * (interlaceskip - 1); - // interlaceskip / 2 * 4 is interlaceskip << 1. - op = opbeg + (framewidth + framestride) * (interlaceskip << 1); - interlaceskip >>= 1; + if (index === trans) { + op += 4; + } else { + var r = buf[palette_offset + index * 3]; + var g = buf[palette_offset + index * 3 + 1]; + var b = buf[palette_offset + index * 3 + 2]; + pixels[op++] = b; + pixels[op++] = g; + pixels[op++] = r; + pixels[op++] = 255; } + --xleft; } - - if (index === trans) { - op += 4; - } else { - var r = buf[palette_offset + index * 3]; - var g = buf[palette_offset + index * 3 + 1]; - var b = buf[palette_offset + index * 3 + 2]; - pixels[op++] = b; - pixels[op++] = g; - pixels[op++] = r; - pixels[op++] = 255; + }; + + // I will go to copy and paste hell one day... + this.decodeAndBlitFrameRGBA = function ( + this: GifReader, + frame_num: number, + pixels: GifPixelBuffer + ): void { + var frame = this.frameInfo(frame_num); + var num_pixels = frame.width * frame.height; + + if (num_pixels > 512 * 1024 * 1024) { + throw new Error("Image dimensions exceed 512MB, which is too large."); } - --xleft; - } - }; - // I will go to copy and paste hell one day... - this.decodeAndBlitFrameRGBA = function(frame_num, pixels) { - var frame = this.frameInfo(frame_num); - var num_pixels = frame.width * frame.height; - - if (num_pixels > 512 * 1024 * 1024) { - throw new Error("Image dimensions exceed 512MB, which is too large."); - } - - var index_stream = new Uint8Array(num_pixels); // At most 8-bit indices. - GifReaderLZWOutputIndexStream( - buf, - frame.data_offset, - index_stream, - num_pixels - ); - var palette_offset = frame.palette_offset; - - // NOTE(deanm): It seems to be much faster to compare index to 256 than - // to === null. Not sure why, but CompareStub_EQ_STRICT shows up high in - // the profile, not sure if it's related to using a Uint8Array. - var trans = frame.transparent_index; - if (trans === null) trans = 256; - - // We are possibly just blitting to a portion of the entire frame. - // That is a subrect within the framerect, so the additional pixels - // must be skipped over after we finished a scanline. - var framewidth = frame.width; - var framestride = width - framewidth; - var xleft = framewidth; // Number of subrect pixels left in scanline. - - // Output indices of the top left and bottom right corners of the subrect. - var opbeg = (frame.y * width + frame.x) * 4; - var opend = ((frame.y + frame.height) * width + frame.x) * 4; - var op = opbeg; - - var scanstride = framestride * 4; - - // Use scanstride to skip past the rows when interlacing. This is skipping - // 7 rows for the first two passes, then 3 then 1. - if (frame.interlaced === true) { - scanstride += width * 4 * 7; // Pass 1. - } + var index_stream = new Uint8Array(num_pixels); // At most 8-bit indices. + GifReaderLZWOutputIndexStream( + buf, + frame.data_offset, + index_stream, + num_pixels + ); + var palette_offset = frame.palette_offset; + + // NOTE(deanm): It seems to be much faster to compare index to 256 than + // to === null. Not sure why, but CompareStub_EQ_STRICT shows up high in + // the profile, not sure if it's related to using a Uint8Array. + var trans = frame.transparent_index; + if (trans === null) trans = 256; + + // We are possibly just blitting to a portion of the entire frame. + // That is a subrect within the framerect, so the additional pixels + // must be skipped over after we finished a scanline. + var framewidth = frame.width; + var framestride = width - framewidth; + var xleft = framewidth; // Number of subrect pixels left in scanline. + + // Output indices of the top left and bottom right corners of the subrect. + var opbeg = (frame.y * width + frame.x) * 4; + var opend = ((frame.y + frame.height) * width + frame.x) * 4; + var op = opbeg; + + var scanstride = framestride * 4; + + // Use scanstride to skip past the rows when interlacing. This is skipping + // 7 rows for the first two passes, then 3 then 1. + if (frame.interlaced === true) { + scanstride += width * 4 * 7; // Pass 1. + } - var interlaceskip = 8; // Tracking the row interval in the current pass. - - for (var i = 0, il = index_stream.length; i < il; ++i) { - var index = index_stream[i]; - - if (xleft === 0) { - // Beginning of new scan line - op += scanstride; - xleft = framewidth; - if (op >= opend) { - // Catch the wrap to switch passes when interlacing. - scanstride = framestride * 4 + width * 4 * (interlaceskip - 1); - // interlaceskip / 2 * 4 is interlaceskip << 1. - op = opbeg + (framewidth + framestride) * (interlaceskip << 1); - interlaceskip >>= 1; + var interlaceskip = 8; // Tracking the row interval in the current pass. + + for (var i = 0, il = index_stream.length; i < il; ++i) { + var index = index_stream[i]; + + if (xleft === 0) { + // Beginning of new scan line + op += scanstride; + xleft = framewidth; + if (op >= opend) { + // Catch the wrap to switch passes when interlacing. + scanstride = framestride * 4 + width * 4 * (interlaceskip - 1); + // interlaceskip / 2 * 4 is interlaceskip << 1. + op = opbeg + (framewidth + framestride) * (interlaceskip << 1); + interlaceskip >>= 1; + } } - } - if (index === trans) { - op += 4; - } else { - var r = buf[palette_offset + index * 3]; - var g = buf[palette_offset + index * 3 + 1]; - var b = buf[palette_offset + index * 3 + 2]; - pixels[op++] = r; - pixels[op++] = g; - pixels[op++] = b; - pixels[op++] = 255; + if (index === trans) { + op += 4; + } else { + var r = buf[palette_offset + index * 3]; + var g = buf[palette_offset + index * 3 + 1]; + var b = buf[palette_offset + index * 3 + 2]; + pixels[op++] = r; + pixels[op++] = g; + pixels[op++] = b; + pixels[op++] = 255; + } + --xleft; } - --xleft; - } - }; + }; + } } -function GifReaderLZWOutputIndexStream(code_stream, p, output, output_length) { +function GifReaderLZWOutputIndexStream( + code_stream: GifBuffer, + p: number, + output: GifPixelBuffer, + output_length: number +): GifPixelBuffer | undefined { var min_code_size = code_stream[p++]; var clear_code = 1 << min_code_size; @@ -784,7 +885,7 @@ function GifReaderLZWOutputIndexStream(code_stream, p, output, output_length) { // var code_table = Array(4096); var code_table = new Int32Array(4096); // Can be signed, we only use 20 bits. - var prev_code = null; // Track code-1. + var prev_code: number | null = null; // Track code-1. while (true) { // Read up to two bytes, making sure we always 12-bits for max sized code. @@ -848,7 +949,7 @@ function GifReaderLZWOutputIndexStream(code_stream, p, output, output_length) { // The code table stores the prefix entry in 12 bits and then the suffix // byte in 8 bits, so each entry is 20 bits. - var chase_code = code < next_code ? code : prev_code; + var chase_code: number | null = code < next_code ? code : prev_code; // Chase what we will output, either {CODE} or {CODE-1}. var chase_length = 0; diff --git a/src/libs/pdfsecurity.ts b/src/libs/pdfsecurity.ts index 1ddabacf2..9932ec80d 100644 --- a/src/libs/pdfsecurity.ts +++ b/src/libs/pdfsecurity.ts @@ -1,165 +1,152 @@ -/** - * @license - * Licensed under the MIT License. - * http://opensource.org/licenses/mit-license - * Author: Owen Leong (@owenl131) - * Date: 15 Oct 2020 - * References: - * https://www.cs.cmu.edu/~dst/Adobe/Gallery/anon21jul01-pdf-encryption.txt - * https://github.com/foliojs/pdfkit/blob/master/lib/security.js - * http://www.fpdf.org/en/script/script37.php - */ - -import { md5Bin } from "./md5.js"; -import { rc4 } from "./rc4.js"; - -var permissionOptions = { - print: 4, - modify: 8, - copy: 16, - "annot-forms": 32 -}; - -/** - * Initializes encryption settings - * - * @name constructor - * @function - * @param {Array} permissions Permissions allowed for user, "print", "modify", "copy" and "annot-forms". - * @param {String} userPassword Permissions apply to this user. Leaving this empty means the document - * is not password protected but viewer has the above permissions. - * @param {String} ownerPassword Owner has full functionalities to the file. - * @param {String} fileId As hex string, should be same as the file ID in the trailer. - * @example - * var security = new PDFSecurity(["print"]) - */ -function PDFSecurity(permissions, userPassword, ownerPassword, fileId) { - this.v = 1; // algorithm 1, future work can add in more recent encryption schemes - this.r = 2; // revision 2 - - // set flags for what functionalities the user can access - let protection = 192; - permissions.forEach(function(perm) { - // Note: this looks up the literal key "perm" (not the loop variable), so - // the check never throws. Preserved as-is from the original JS; fixing it - // would change runtime behavior for invalid permission names. - if (typeof (permissionOptions as any).perm !== "undefined") { - throw new Error("Invalid permission: " + perm); - } - protection += permissionOptions[perm]; - }); - - // padding is used to pad the passwords to 32 bytes, also is hashed and stored in the final PDF - this.padding = - "\x28\xBF\x4E\x5E\x4E\x75\x8A\x41\x64\x00\x4E\x56\xFF\xFA\x01\x08" + - "\x2E\x2E\x00\xB6\xD0\x68\x3E\x80\x2F\x0C\xA9\xFE\x64\x53\x69\x7A"; - let paddedUserPassword = (userPassword + this.padding).substr(0, 32); - let paddedOwnerPassword = (ownerPassword + this.padding).substr(0, 32); - - this.O = this.processOwnerPassword(paddedUserPassword, paddedOwnerPassword); - this.P = -((protection ^ 255) + 1); - this.encryptionKey = md5Bin( - paddedUserPassword + - this.O + - this.lsbFirstWord(this.P) + - this.hexToBytes(fileId) - ).substr(0, 5); - this.U = rc4(this.encryptionKey, this.padding); -} - -/** - * Breaks down a 4-byte number into its individual bytes, with the least significant bit first - * - * @name lsbFirstWord - * @function - * @param {number} data 32-bit number - * @returns {Array} - */ -PDFSecurity.prototype.lsbFirstWord = function(data) { - return String.fromCharCode( - (data >> 0) & 0xff, - (data >> 8) & 0xff, - (data >> 16) & 0xff, - (data >> 24) & 0xff - ); -}; - -/** - * Converts a byte string to a hex string - * - * @name toHexString - * @function - * @param {String} byteString Byte string - * @returns {String} - */ -PDFSecurity.prototype.toHexString = function(byteString) { - return byteString - .split("") - .map(function(byte) { - return ("0" + (byte.charCodeAt(0) & 0xff).toString(16)).slice(-2); - }) - .join(""); -}; - -/** - * Converts a hex string to a byte string - * - * @name hexToBytes - * @function - * @param {String} hex Hex string - * @returns {String} - */ -PDFSecurity.prototype.hexToBytes = function(hex) { - for (var bytes = [], c = 0; c < hex.length; c += 2) - bytes.push(String.fromCharCode(parseInt(hex.substr(c, 2), 16))); - return bytes.join(""); -}; - -/** - * Computes the 'O' field in the encryption dictionary - * - * @name processOwnerPassword - * @function - * @param {String} paddedUserPassword Byte string of padded user password - * @param {String} paddedOwnerPassword Byte string of padded owner password - * @returns {String} - */ -PDFSecurity.prototype.processOwnerPassword = function( - paddedUserPassword, - paddedOwnerPassword -) { - let key = md5Bin(paddedOwnerPassword).substr(0, 5); - return rc4(key, paddedUserPassword); -}; - -/** - * Returns an encryptor function which can take in a byte string and returns the encrypted version - * - * @name encryptor - * @function - * @param {number} objectId - * @param {number} generation Not sure what this is for, you can set it to 0 - * @returns {Function} - * @example - * out("stream"); - * encryptor = security.encryptor(object.id, 0); - * out(encryptor(data)); - * out("endstream"); - */ -PDFSecurity.prototype.encryptor = function(objectId, generation) { - let key = md5Bin( - this.encryptionKey + - String.fromCharCode( - objectId & 0xff, - (objectId >> 8) & 0xff, - (objectId >> 16) & 0xff, - generation & 0xff, - (generation >> 8) & 0xff - ) - ).substr(0, 10); - return function(data) { - return rc4(key, data); - }; -}; - -export { PDFSecurity }; +/** + * @license + * Licensed under the MIT License. + * http://opensource.org/licenses/mit-license + * Author: Owen Leong (@owenl131) + * Date: 15 Oct 2020 + * References: + * https://www.cs.cmu.edu/~dst/Adobe/Gallery/anon21jul01-pdf-encryption.txt + * https://github.com/foliojs/pdfkit/blob/master/lib/security.js + * http://www.fpdf.org/en/script/script37.php + */ + +import { md5Bin } from "./md5.js"; +import { rc4 } from "./rc4.js"; + +const permissionOptions: Record & { perm?: never } = { + print: 4, + modify: 8, + copy: 16, + "annot-forms": 32 +}; + +class PDFSecurity { + declare v: number; + declare r: number; + declare padding: string; + declare O: string; + declare P: number; + declare encryptionKey: string; + declare U: string; + + /** + * Initializes encryption settings + * + * @param permissions Permissions allowed for user, "print", "modify", "copy" and "annot-forms". + * @param userPassword Permissions apply to this user. Leaving this empty means the document + * is not password protected but viewer has the above permissions. + * @param ownerPassword Owner has full functionalities to the file. + * @param fileId As hex string, should be same as the file ID in the trailer. + * @example + * var security = new PDFSecurity(["print"]) + */ + constructor( + permissions: string[], + userPassword: string | undefined, + ownerPassword: string | undefined, + fileId: string + ) { + this.v = 1; // algorithm 1, future work can add in more recent encryption schemes + this.r = 2; // revision 2 + + // set flags for what functionalities the user can access + let protection = 192; + permissions.forEach(function (perm) { + // Note: this looks up the literal key "perm" (not the loop variable), so + // the check never throws. Preserved as-is from the original JS; fixing + // it would change runtime behavior for invalid permission names. + if (typeof permissionOptions.perm !== "undefined") { + throw new Error("Invalid permission: " + perm); + } + protection += permissionOptions[perm]; + }); + + // padding is used to pad the passwords to 32 bytes, also is hashed and stored in the final PDF + this.padding = + "\x28\xBF\x4E\x5E\x4E\x75\x8A\x41\x64\x00\x4E\x56\xFF\xFA\x01\x08" + + "\x2E\x2E\x00\xB6\xD0\x68\x3E\x80\x2F\x0C\xA9\xFE\x64\x53\x69\x7A"; + const paddedUserPassword = (userPassword + this.padding).substr(0, 32); + const paddedOwnerPassword = (ownerPassword + this.padding).substr(0, 32); + + this.O = this.processOwnerPassword(paddedUserPassword, paddedOwnerPassword); + this.P = -((protection ^ 255) + 1); + this.encryptionKey = md5Bin( + paddedUserPassword + + this.O + + this.lsbFirstWord(this.P) + + this.hexToBytes(fileId) + ).substr(0, 5); + this.U = rc4(this.encryptionKey, this.padding); + } + + /** + * Breaks down a 4-byte number into its individual bytes, with the least significant bit first + */ + lsbFirstWord(data: number): string { + return String.fromCharCode( + (data >> 0) & 0xff, + (data >> 8) & 0xff, + (data >> 16) & 0xff, + (data >> 24) & 0xff + ); + } + + /** + * Converts a byte string to a hex string + */ + toHexString(byteString: string): string { + return byteString + .split("") + .map(function (byte) { + return ("0" + (byte.charCodeAt(0) & 0xff).toString(16)).slice(-2); + }) + .join(""); + } + + /** + * Converts a hex string to a byte string + */ + hexToBytes(hex: string): string { + for (var bytes = [], c = 0; c < hex.length; c += 2) + bytes.push(String.fromCharCode(parseInt(hex.substr(c, 2), 16))); + return bytes.join(""); + } + + /** + * Computes the 'O' field in the encryption dictionary + */ + processOwnerPassword( + paddedUserPassword: string, + paddedOwnerPassword: string + ): string { + const key = md5Bin(paddedOwnerPassword).substr(0, 5); + return rc4(key, paddedUserPassword); + } + + /** + * Returns an encryptor function which can take in a byte string and returns the encrypted version + * + * @example + * out("stream"); + * encryptor = security.encryptor(object.id, 0); + * out(encryptor(data)); + * out("endstream"); + */ + encryptor(objectId: number, generation: number): (data: string) => string { + const key = md5Bin( + this.encryptionKey + + String.fromCharCode( + objectId & 0xff, + (objectId >> 8) & 0xff, + (objectId >> 16) & 0xff, + generation & 0xff, + (generation >> 8) & 0xff + ) + ).substr(0, 10); + return function (data: string): string { + return rc4(key, data); + }; + } +} + +export { PDFSecurity }; diff --git a/src/libs/rc4.ts b/src/libs/rc4.ts index 90950b77f..1a6c17724 100644 --- a/src/libs/rc4.ts +++ b/src/libs/rc4.ts @@ -1,61 +1,61 @@ -/** - * @license - * FPDF is released under a permissive license: there is no usage restriction. - * You may embed it freely in your application (commercial or not), with or - * without modifications. - * - * Reference: http://www.fpdf.org/en/script/script37.php - */ - -function repeat(str: string, num: number): string { - return new Array(num + 1).join(str); -} - -/** - * Converts a byte string to a hex string - * - * @name rc4 - * @function - * @param {string} key Byte string of encryption key - * @param {string} data Byte string of data to be encrypted - * @returns {string} Encrypted string - */ -function rc4(key: string, data: string): string { - var lastKey, lastState; - if (key !== lastKey) { - // "k" is reused below as a numeric state lookup, matching the original - // untyped implementation. - var k: any = repeat(key, ((256 / key.length) >> 0) + 1); - var state = []; - for (var i = 0; i < 256; i++) { - state[i] = i; - } - var j = 0; - for (var i = 0; i < 256; i++) { - var t = state[i]; - j = (j + t + k.charCodeAt(i)) % 256; - state[i] = state[j]; - state[j] = t; - } - lastKey = key; - lastState = state; - } else { - state = lastState; - } - var length = data.length; - var a = 0; - var b = 0; - var out = ""; - for (var i = 0; i < length; i++) { - a = (a + 1) % 256; - t = state[a]; - b = (b + t) % 256; - state[a] = state[b]; - state[b] = t; - k = state[(state[a] + state[b]) % 256]; - out += String.fromCharCode(data.charCodeAt(i) ^ k); - } - return out; -} - -export { rc4 }; +/** + * @license + * FPDF is released under a permissive license: there is no usage restriction. + * You may embed it freely in your application (commercial or not), with or + * without modifications. + * + * Reference: http://www.fpdf.org/en/script/script37.php + */ + +function repeat(str: string, num: number): string { + return new Array(num + 1).join(str); +} + +/** + * Converts a byte string to a hex string + * + * @name rc4 + * @function + * @param {string} key Byte string of encryption key + * @param {string} data Byte string of data to be encrypted + * @returns {string} Encrypted string + */ +function rc4(key: string, data: string): string { + var lastKey: string, lastState: number[]; + if (key !== lastKey) { + // "k" is reused below as a numeric state lookup; the union type plus + // narrowing matches the original untyped implementation. + var k: string | number = repeat(key, ((256 / key.length) >> 0) + 1); + var state: number[] = []; + for (var i = 0; i < 256; i++) { + state[i] = i; + } + var j = 0; + for (var i = 0; i < 256; i++) { + var t: number = state[i]; + j = (j + t + k.charCodeAt(i)) % 256; + state[i] = state[j]; + state[j] = t; + } + lastKey = key; + lastState = state; + } else { + state = lastState; + } + var length = data.length; + var a = 0; + var b = 0; + var out = ""; + for (var i = 0; i < length; i++) { + a = (a + 1) % 256; + t = state[a]; + b = (b + t) % 256; + state[a] = state[b]; + state[b] = t; + k = state[(state[a] + state[b]) % 256]; + out += String.fromCharCode(data.charCodeAt(i) ^ k); + } + return out; +} + +export { rc4 }; diff --git a/src/libs/rgbcolor.ts b/src/libs/rgbcolor.ts index ff93dc4d0..5db0237b1 100644 --- a/src/libs/rgbcolor.ts +++ b/src/libs/rgbcolor.ts @@ -5,227 +5,240 @@ * @license Use it if you like it */ -function RGBColor(color_string) { - color_string = color_string || ""; - this.ok = false; +interface ColorDefinition { + re: RegExp; + example: string[]; + process: (bits: RegExpExecArray) => number[]; +} - // strip any leading # - if (color_string.charAt(0) == "#") { - // remove # if any - color_string = color_string.substr(1, 6); - } +class RGBColor { + declare ok: boolean; + declare r: number; + declare g: number; + declare b: number; + + constructor(color_string?: string) { + color_string = color_string || ""; + this.ok = false; - color_string = color_string.replace(/ /g, ""); - color_string = color_string.toLowerCase(); + // strip any leading # + if (color_string.charAt(0) == "#") { + // remove # if any + color_string = color_string.substr(1, 6); + } - var channels; + color_string = color_string.replace(/ /g, ""); + color_string = color_string.toLowerCase(); - // before getting into regexps, try simple matches - // and overwrite the input - var simple_colors = { - aliceblue: "f0f8ff", - antiquewhite: "faebd7", - aqua: "00ffff", - aquamarine: "7fffd4", - azure: "f0ffff", - beige: "f5f5dc", - bisque: "ffe4c4", - black: "000000", - blanchedalmond: "ffebcd", - blue: "0000ff", - blueviolet: "8a2be2", - brown: "a52a2a", - burlywood: "deb887", - cadetblue: "5f9ea0", - chartreuse: "7fff00", - chocolate: "d2691e", - coral: "ff7f50", - cornflowerblue: "6495ed", - cornsilk: "fff8dc", - crimson: "dc143c", - cyan: "00ffff", - darkblue: "00008b", - darkcyan: "008b8b", - darkgoldenrod: "b8860b", - darkgray: "a9a9a9", - darkgreen: "006400", - darkkhaki: "bdb76b", - darkmagenta: "8b008b", - darkolivegreen: "556b2f", - darkorange: "ff8c00", - darkorchid: "9932cc", - darkred: "8b0000", - darksalmon: "e9967a", - darkseagreen: "8fbc8f", - darkslateblue: "483d8b", - darkslategray: "2f4f4f", - darkturquoise: "00ced1", - darkviolet: "9400d3", - deeppink: "ff1493", - deepskyblue: "00bfff", - dimgray: "696969", - dodgerblue: "1e90ff", - feldspar: "d19275", - firebrick: "b22222", - floralwhite: "fffaf0", - forestgreen: "228b22", - fuchsia: "ff00ff", - gainsboro: "dcdcdc", - ghostwhite: "f8f8ff", - gold: "ffd700", - goldenrod: "daa520", - gray: "808080", - green: "008000", - greenyellow: "adff2f", - honeydew: "f0fff0", - hotpink: "ff69b4", - indianred: "cd5c5c", - indigo: "4b0082", - ivory: "fffff0", - khaki: "f0e68c", - lavender: "e6e6fa", - lavenderblush: "fff0f5", - lawngreen: "7cfc00", - lemonchiffon: "fffacd", - lightblue: "add8e6", - lightcoral: "f08080", - lightcyan: "e0ffff", - lightgoldenrodyellow: "fafad2", - lightgrey: "d3d3d3", - lightgreen: "90ee90", - lightpink: "ffb6c1", - lightsalmon: "ffa07a", - lightseagreen: "20b2aa", - lightskyblue: "87cefa", - lightslateblue: "8470ff", - lightslategray: "778899", - lightsteelblue: "b0c4de", - lightyellow: "ffffe0", - lime: "00ff00", - limegreen: "32cd32", - linen: "faf0e6", - magenta: "ff00ff", - maroon: "800000", - mediumaquamarine: "66cdaa", - mediumblue: "0000cd", - mediumorchid: "ba55d3", - mediumpurple: "9370d8", - mediumseagreen: "3cb371", - mediumslateblue: "7b68ee", - mediumspringgreen: "00fa9a", - mediumturquoise: "48d1cc", - mediumvioletred: "c71585", - midnightblue: "191970", - mintcream: "f5fffa", - mistyrose: "ffe4e1", - moccasin: "ffe4b5", - navajowhite: "ffdead", - navy: "000080", - oldlace: "fdf5e6", - olive: "808000", - olivedrab: "6b8e23", - orange: "ffa500", - orangered: "ff4500", - orchid: "da70d6", - palegoldenrod: "eee8aa", - palegreen: "98fb98", - paleturquoise: "afeeee", - palevioletred: "d87093", - papayawhip: "ffefd5", - peachpuff: "ffdab9", - peru: "cd853f", - pink: "ffc0cb", - plum: "dda0dd", - powderblue: "b0e0e6", - purple: "800080", - red: "ff0000", - rosybrown: "bc8f8f", - royalblue: "4169e1", - saddlebrown: "8b4513", - salmon: "fa8072", - sandybrown: "f4a460", - seagreen: "2e8b57", - seashell: "fff5ee", - sienna: "a0522d", - silver: "c0c0c0", - skyblue: "87ceeb", - slateblue: "6a5acd", - slategray: "708090", - snow: "fffafa", - springgreen: "00ff7f", - steelblue: "4682b4", - tan: "d2b48c", - teal: "008080", - thistle: "d8bfd8", - tomato: "ff6347", - turquoise: "40e0d0", - violet: "ee82ee", - violetred: "d02090", - wheat: "f5deb3", - white: "ffffff", - whitesmoke: "f5f5f5", - yellow: "ffff00", - yellowgreen: "9acd32" - }; - color_string = simple_colors[color_string] || color_string; + var channels: number[]; - // array of color definition objects - var color_defs = [ - { - re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/, - example: ["rgb(123, 234, 45)", "rgb(255,234,245)"], - process: function(bits) { - return [parseInt(bits[1]), parseInt(bits[2]), parseInt(bits[3])]; - } - }, - { - re: /^(\w{2})(\w{2})(\w{2})$/, - example: ["#00ff00", "336699"], - process: function(bits) { - return [ - parseInt(bits[1], 16), - parseInt(bits[2], 16), - parseInt(bits[3], 16) - ]; + // before getting into regexps, try simple matches + // and overwrite the input + var simple_colors: Record = { + aliceblue: "f0f8ff", + antiquewhite: "faebd7", + aqua: "00ffff", + aquamarine: "7fffd4", + azure: "f0ffff", + beige: "f5f5dc", + bisque: "ffe4c4", + black: "000000", + blanchedalmond: "ffebcd", + blue: "0000ff", + blueviolet: "8a2be2", + brown: "a52a2a", + burlywood: "deb887", + cadetblue: "5f9ea0", + chartreuse: "7fff00", + chocolate: "d2691e", + coral: "ff7f50", + cornflowerblue: "6495ed", + cornsilk: "fff8dc", + crimson: "dc143c", + cyan: "00ffff", + darkblue: "00008b", + darkcyan: "008b8b", + darkgoldenrod: "b8860b", + darkgray: "a9a9a9", + darkgreen: "006400", + darkkhaki: "bdb76b", + darkmagenta: "8b008b", + darkolivegreen: "556b2f", + darkorange: "ff8c00", + darkorchid: "9932cc", + darkred: "8b0000", + darksalmon: "e9967a", + darkseagreen: "8fbc8f", + darkslateblue: "483d8b", + darkslategray: "2f4f4f", + darkturquoise: "00ced1", + darkviolet: "9400d3", + deeppink: "ff1493", + deepskyblue: "00bfff", + dimgray: "696969", + dodgerblue: "1e90ff", + feldspar: "d19275", + firebrick: "b22222", + floralwhite: "fffaf0", + forestgreen: "228b22", + fuchsia: "ff00ff", + gainsboro: "dcdcdc", + ghostwhite: "f8f8ff", + gold: "ffd700", + goldenrod: "daa520", + gray: "808080", + green: "008000", + greenyellow: "adff2f", + honeydew: "f0fff0", + hotpink: "ff69b4", + indianred: "cd5c5c", + indigo: "4b0082", + ivory: "fffff0", + khaki: "f0e68c", + lavender: "e6e6fa", + lavenderblush: "fff0f5", + lawngreen: "7cfc00", + lemonchiffon: "fffacd", + lightblue: "add8e6", + lightcoral: "f08080", + lightcyan: "e0ffff", + lightgoldenrodyellow: "fafad2", + lightgrey: "d3d3d3", + lightgreen: "90ee90", + lightpink: "ffb6c1", + lightsalmon: "ffa07a", + lightseagreen: "20b2aa", + lightskyblue: "87cefa", + lightslateblue: "8470ff", + lightslategray: "778899", + lightsteelblue: "b0c4de", + lightyellow: "ffffe0", + lime: "00ff00", + limegreen: "32cd32", + linen: "faf0e6", + magenta: "ff00ff", + maroon: "800000", + mediumaquamarine: "66cdaa", + mediumblue: "0000cd", + mediumorchid: "ba55d3", + mediumpurple: "9370d8", + mediumseagreen: "3cb371", + mediumslateblue: "7b68ee", + mediumspringgreen: "00fa9a", + mediumturquoise: "48d1cc", + mediumvioletred: "c71585", + midnightblue: "191970", + mintcream: "f5fffa", + mistyrose: "ffe4e1", + moccasin: "ffe4b5", + navajowhite: "ffdead", + navy: "000080", + oldlace: "fdf5e6", + olive: "808000", + olivedrab: "6b8e23", + orange: "ffa500", + orangered: "ff4500", + orchid: "da70d6", + palegoldenrod: "eee8aa", + palegreen: "98fb98", + paleturquoise: "afeeee", + palevioletred: "d87093", + papayawhip: "ffefd5", + peachpuff: "ffdab9", + peru: "cd853f", + pink: "ffc0cb", + plum: "dda0dd", + powderblue: "b0e0e6", + purple: "800080", + red: "ff0000", + rosybrown: "bc8f8f", + royalblue: "4169e1", + saddlebrown: "8b4513", + salmon: "fa8072", + sandybrown: "f4a460", + seagreen: "2e8b57", + seashell: "fff5ee", + sienna: "a0522d", + silver: "c0c0c0", + skyblue: "87ceeb", + slateblue: "6a5acd", + slategray: "708090", + snow: "fffafa", + springgreen: "00ff7f", + steelblue: "4682b4", + tan: "d2b48c", + teal: "008080", + thistle: "d8bfd8", + tomato: "ff6347", + turquoise: "40e0d0", + violet: "ee82ee", + violetred: "d02090", + wheat: "f5deb3", + white: "ffffff", + whitesmoke: "f5f5f5", + yellow: "ffff00", + yellowgreen: "9acd32" + }; + color_string = simple_colors[color_string] || color_string; + + // array of color definition objects + var color_defs: ColorDefinition[] = [ + { + re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/, + example: ["rgb(123, 234, 45)", "rgb(255,234,245)"], + process: function (bits: RegExpExecArray) { + return [parseInt(bits[1]), parseInt(bits[2]), parseInt(bits[3])]; + } + }, + { + re: /^(\w{2})(\w{2})(\w{2})$/, + example: ["#00ff00", "336699"], + process: function (bits: RegExpExecArray) { + return [ + parseInt(bits[1], 16), + parseInt(bits[2], 16), + parseInt(bits[3], 16) + ]; + } + }, + { + re: /^(\w{1})(\w{1})(\w{1})$/, + example: ["#fb0", "f0f"], + process: function (bits: RegExpExecArray) { + return [ + parseInt(bits[1] + bits[1], 16), + parseInt(bits[2] + bits[2], 16), + parseInt(bits[3] + bits[3], 16) + ]; + } } - }, - { - re: /^(\w{1})(\w{1})(\w{1})$/, - example: ["#fb0", "f0f"], - process: function(bits) { - return [ - parseInt(bits[1] + bits[1], 16), - parseInt(bits[2] + bits[2], 16), - parseInt(bits[3] + bits[3], 16) - ]; + ]; + + // search through the definitions to find a match + for (var i = 0; i < color_defs.length; i++) { + var re = color_defs[i].re; + var processor = color_defs[i].process; + var bits = re.exec(color_string); + if (bits) { + channels = processor(bits); + this.r = channels[0]; + this.g = channels[1]; + this.b = channels[2]; + this.ok = true; } } - ]; - // search through the definitions to find a match - for (var i = 0; i < color_defs.length; i++) { - var re = color_defs[i].re; - var processor = color_defs[i].process; - var bits = re.exec(color_string); - if (bits) { - channels = processor(bits); - this.r = channels[0]; - this.g = channels[1]; - this.b = channels[2]; - this.ok = true; - } + // validate/cleanup values + this.r = this.r < 0 || isNaN(this.r) ? 0 : this.r > 255 ? 255 : this.r; + this.g = this.g < 0 || isNaN(this.g) ? 0 : this.g > 255 ? 255 : this.g; + this.b = this.b < 0 || isNaN(this.b) ? 0 : this.b > 255 ? 255 : this.b; } - // validate/cleanup values - this.r = this.r < 0 || isNaN(this.r) ? 0 : this.r > 255 ? 255 : this.r; - this.g = this.g < 0 || isNaN(this.g) ? 0 : this.g > 255 ? 255 : this.g; - this.b = this.b < 0 || isNaN(this.b) ? 0 : this.b > 255 ? 255 : this.b; - - // some getters - this.toRGB = function() { + toRGB(): string { return "rgb(" + this.r + ", " + this.g + ", " + this.b + ")"; - }; - this.toHex = function() { + } + + toHex(): string { var r = this.r.toString(16); var g = this.g.toString(16); var b = this.b.toString(16); @@ -233,7 +246,7 @@ function RGBColor(color_string) { if (g.length == 1) g = "0" + g; if (b.length == 1) b = "0" + b; return "#" + r + g + b; - }; + } } export { RGBColor }; diff --git a/src/libs/ttffont.ts b/src/libs/ttffont.ts index 96cf5f276..4a45de61f 100644 --- a/src/libs/ttffont.ts +++ b/src/libs/ttffont.ts @@ -14,12 +14,12 @@ import { jsPDF } from "../jspdf.js"; -jsPDF.API.TTFFont = (function() { +jsPDF.API.TTFFont = (function () { /************************************************************************/ /* function : open */ /* comment : Decode the encoded ttf content and create a TTFFont object. */ /************************************************************************/ - TTFFont.open = function(file) { + TTFFont.open = function (file) { return new TTFFont(file); }; /***************************************************************/ @@ -45,7 +45,7 @@ jsPDF.API.TTFFont = (function() { /* function : parse */ /* comment : TTF Parses the file contents by each table.*/ /********************************************************/ - TTFFont.prototype.parse = function() { + TTFFont.prototype.parse = function () { this.directory = new Directory(this.contents); this.head = new HeadTable(this); this.name = new NameTable(this); @@ -74,10 +74,10 @@ jsPDF.API.TTFFont = (function() { /* function : registerTTF */ /* comment : Get the value to assign pdf font descriptors. */ /***************************************************************/ - TTFFont.prototype.registerTTF = function() { + TTFFont.prototype.registerTTF = function () { var e, hi, low, raw, _ref; this.scaleFactor = 1000.0 / this.head.unitsPerEm; - this.bbox = function() { + this.bbox = function () { var _i, _len, _ref, _results; _ref = this.bbox; _results = []; @@ -131,19 +131,19 @@ jsPDF.API.TTFFont = (function() { throw new Error("No unicode cmap for font"); } }; - TTFFont.prototype.characterToGlyph = function(character) { + TTFFont.prototype.characterToGlyph = function (character) { var _ref; return ( ((_ref = this.cmap.unicode) != null ? _ref.codeMap[character] : void 0) || 0 ); }; - TTFFont.prototype.widthOfGlyph = function(glyph) { + TTFFont.prototype.widthOfGlyph = function (glyph) { var scale; scale = 1000.0 / this.head.unitsPerEm; return this.hmtx.forGlyph(glyph).advance * scale; }; - TTFFont.prototype.widthOfString = function(string, size, charSpace) { + TTFFont.prototype.widthOfString = function (string, size, charSpace) { var charCode, i, scale, width, _ref; string = "" + string; width = 0; @@ -160,7 +160,7 @@ jsPDF.API.TTFFont = (function() { scale = size / 1000; return width * scale; }; - TTFFont.prototype.lineHeight = function(size, includeGap) { + TTFFont.prototype.lineHeight = function (size, includeGap) { var gap; if (includeGap == null) { includeGap = false; @@ -175,19 +175,19 @@ jsPDF.API.TTFFont = (function() { /* function : Data */ /* comment : The ttf data decoded and stored in an array is read and written to the Data object.*/ /************************************************************************************************/ -var Data = (function() { +var Data = (function () { function Data(data) { this.data = data != null ? data : []; this.pos = 0; this.length = this.data.length; } - Data.prototype.readByte = function() { + Data.prototype.readByte = function () { return this.data[this.pos++]; }; - Data.prototype.writeByte = function(byte) { + Data.prototype.writeByte = function (byte) { return (this.data[this.pos++] = byte); }; - Data.prototype.readUInt32 = function() { + Data.prototype.readUInt32 = function () { var b1, b2, b3, b4; b1 = this.readByte() * 0x1000000; b2 = this.readByte() << 16; @@ -195,13 +195,13 @@ var Data = (function() { b4 = this.readByte(); return b1 + b2 + b3 + b4; }; - Data.prototype.writeUInt32 = function(val) { + Data.prototype.writeUInt32 = function (val) { this.writeByte((val >>> 24) & 0xff); this.writeByte((val >> 16) & 0xff); this.writeByte((val >> 8) & 0xff); return this.writeByte(val & 0xff); }; - Data.prototype.readInt32 = function() { + Data.prototype.readInt32 = function () { var int; int = this.readUInt32(); if (int >= 0x80000000) { @@ -210,23 +210,23 @@ var Data = (function() { return int; } }; - Data.prototype.writeInt32 = function(val) { + Data.prototype.writeInt32 = function (val) { if (val < 0) { val += 0x100000000; } return this.writeUInt32(val); }; - Data.prototype.readUInt16 = function() { + Data.prototype.readUInt16 = function () { var b1, b2; b1 = this.readByte() << 8; b2 = this.readByte(); return b1 | b2; }; - Data.prototype.writeUInt16 = function(val) { + Data.prototype.writeUInt16 = function (val) { this.writeByte((val >> 8) & 0xff); return this.writeByte(val & 0xff); }; - Data.prototype.readInt16 = function() { + Data.prototype.readInt16 = function () { var int; int = this.readUInt16(); if (int >= 0x8000) { @@ -235,13 +235,13 @@ var Data = (function() { return int; } }; - Data.prototype.writeInt16 = function(val) { + Data.prototype.writeInt16 = function (val) { if (val < 0) { val += 0x10000; } return this.writeUInt16(val); }; - Data.prototype.readString = function(length) { + Data.prototype.readString = function (length) { var i, ret; ret = []; for ( @@ -253,7 +253,7 @@ var Data = (function() { } return ret.join(""); }; - Data.prototype.writeString = function(val) { + Data.prototype.writeString = function (val) { var i, _ref, _results; _results = []; for ( @@ -269,13 +269,13 @@ var Data = (function() { this.pos = pos; return this.readString(length); };*/ - Data.prototype.readShort = function() { + Data.prototype.readShort = function () { return this.readInt16(); }; - Data.prototype.writeShort = function(val) { + Data.prototype.writeShort = function (val) { return this.writeInt16(val); }; - Data.prototype.readLongLong = function() { + Data.prototype.readLongLong = function () { var b1, b2, b3, b4, b5, b6, b7, b8; b1 = this.readByte(); b2 = this.readByte(); @@ -310,7 +310,7 @@ var Data = (function() { b8 ); }; - Data.prototype.writeLongLong = function(val) { + Data.prototype.writeLongLong = function (val) { var high, low; high = Math.floor(val / 0x100000000); low = val & 0xffffffff; @@ -323,16 +323,16 @@ var Data = (function() { this.writeByte((low >> 8) & 0xff); return this.writeByte(low & 0xff); }; - Data.prototype.readInt = function() { + Data.prototype.readInt = function () { return this.readInt32(); }; - Data.prototype.writeInt = function(val) { + Data.prototype.writeInt = function (val) { return this.writeInt32(val); }; /*Data.prototype.slice = function (start, end) { return this.data.slice(start, end); };*/ - Data.prototype.read = function(bytes) { + Data.prototype.read = function (bytes) { var buf, i; buf = []; for ( @@ -344,7 +344,7 @@ var Data = (function() { } return buf; }; - Data.prototype.write = function(bytes) { + Data.prototype.write = function (bytes) { var byte, i, _len, _results; _results = []; for (i = 0, _len = bytes.length; i < _len; i++) { @@ -356,7 +356,7 @@ var Data = (function() { return Data; })(); -var Directory = (function() { +var Directory = (function () { var checksum; /*****************************************************************************************************/ @@ -389,7 +389,7 @@ var Directory = (function() { /* function : encode */ /* comment : It encodes and stores the font table object and information used for the directory object. */ /********************************************************************************************************/ - Directory.prototype.encode = function(tables) { + Directory.prototype.encode = function (tables) { var adjustment, directory, directoryLength, @@ -446,7 +446,7 @@ var Directory = (function() { /* function : checksum */ /* comment : Duplicate the table for the tag. */ /***************************************************************/ - checksum = function(data) { + checksum = function (data) { var i, sum, tmp, _ref; data = __slice.call(data); while (data.length % 4) { @@ -464,7 +464,7 @@ var Directory = (function() { var Table, __hasProp = {}.hasOwnProperty, - __extends = function(child, parent) { + __extends = function (child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } @@ -482,20 +482,20 @@ var Table, /* function : Table */ /* comment : Save info for each table, and parse the table. */ /***************************************************************/ -Table = (function() { +Table = (function () { function Table(file) { var info; this.file = file; info = this.file.directory.tables[this.tag]; this.exists = !!info; if (info) { - (this.offset = info.offset), (this.length = info.length); + ((this.offset = info.offset), (this.length = info.length)); this.parse(this.file.contents); } } - Table.prototype.parse = function() {}; - Table.prototype.encode = function() {}; - Table.prototype.raw = function() { + Table.prototype.parse = function () {}; + Table.prototype.encode = function () {}; + Table.prototype.raw = function () { if (!this.exists) { return null; } @@ -505,14 +505,14 @@ Table = (function() { return Table; })(); -var HeadTable = (function(_super) { +var HeadTable = (function (_super) { __extends(HeadTable, _super); function HeadTable() { return HeadTable.__super__.constructor.apply(this, arguments); } HeadTable.prototype.tag = "head"; - HeadTable.prototype.parse = function(data) { + HeadTable.prototype.parse = function (data) { data.pos = this.offset; this.version = data.readInt(); this.revision = data.readInt(); @@ -532,7 +532,7 @@ var HeadTable = (function(_super) { this.indexToLocFormat = data.readShort(); return (this.glyphDataFormat = data.readShort()); }; - HeadTable.prototype.encode = function(indexToLocFormat) { + HeadTable.prototype.encode = function (indexToLocFormat) { var table; table = new Data(); table.writeInt(this.version); @@ -561,7 +561,7 @@ var HeadTable = (function(_super) { /* function : CmapEntry */ /* comment : Cmap Initializes and encodes object information (required by pdf spec).*/ /************************************************************************************/ -var CmapEntry = (function() { +var CmapEntry = (function () { function CmapEntry(data, offset) { var code, count, @@ -603,7 +603,7 @@ var CmapEntry = (function() { segCountX2 = data.readUInt16(); segCount = segCountX2 / 2; data.pos += 6; - endCode = (function() { + endCode = (function () { var _j, _results; _results = []; for ( @@ -616,7 +616,7 @@ var CmapEntry = (function() { return _results; })(); data.pos += 2; - startCode = (function() { + startCode = (function () { var _j, _results; _results = []; for ( @@ -628,7 +628,7 @@ var CmapEntry = (function() { } return _results; })(); - idDelta = (function() { + idDelta = (function () { var _j, _results; _results = []; for ( @@ -640,7 +640,7 @@ var CmapEntry = (function() { } return _results; })(); - idRangeOffset = (function() { + idRangeOffset = (function () { var _j, _results; _results = []; for ( @@ -653,7 +653,7 @@ var CmapEntry = (function() { return _results; })(); count = (this.length - data.pos + this.offset) / 2; - glyphIds = (function() { + glyphIds = (function () { var _j, _results; _results = []; for ( @@ -688,7 +688,7 @@ var CmapEntry = (function() { } data.pos = saveOffset; } - CmapEntry.encode = function(charmap, encoding) { + CmapEntry.encode = function (charmap, encoding) { var charMap, code, codeMap, @@ -736,13 +736,13 @@ var CmapEntry = (function() { _p, _q; subtable = new Data(); - codes = Object.keys(charmap).sort(function(a, b) { + codes = Object.keys(charmap).sort(function (a, b) { return a - b; }); switch (encoding) { case "macroman": id = 0; - indexes = (function() { + indexes = (function () { var _results = []; for (i = 0; i < 256; ++i) { _results.push(0); @@ -881,14 +881,14 @@ var CmapEntry = (function() { return CmapEntry; })(); -var CmapTable = (function(_super) { +var CmapTable = (function (_super) { __extends(CmapTable, _super); function CmapTable() { return CmapTable.__super__.constructor.apply(this, arguments); } CmapTable.prototype.tag = "cmap"; - CmapTable.prototype.parse = function(data) { + CmapTable.prototype.parse = function (data) { var entry, i, tableCount; data.pos = this.offset; this.version = data.readUInt16(); @@ -914,7 +914,7 @@ var CmapTable = (function(_super) { /* function : encode */ /* comment : Encode the cmap table corresponding to the input character. */ /*************************************************************************/ - CmapTable.encode = function(charmap, encoding) { + CmapTable.encode = function (charmap, encoding) { var result, table; if (encoding == null) { encoding = "macroman"; @@ -929,14 +929,14 @@ var CmapTable = (function(_super) { return CmapTable; })(Table); -var HheaTable = (function(_super) { +var HheaTable = (function (_super) { __extends(HheaTable, _super); function HheaTable() { return HheaTable.__super__.constructor.apply(this, arguments); } HheaTable.prototype.tag = "hhea"; - HheaTable.prototype.parse = function(data) { + HheaTable.prototype.parse = function (data) { data.pos = this.offset; this.version = data.readInt(); this.ascender = data.readShort(); @@ -977,14 +977,14 @@ var HheaTable = (function(_super) { return HheaTable; })(Table); -var OS2Table = (function(_super) { +var OS2Table = (function (_super) { __extends(OS2Table, _super); function OS2Table() { return OS2Table.__super__.constructor.apply(this, arguments); } OS2Table.prototype.tag = "OS/2"; - OS2Table.prototype.parse = function(data) { + OS2Table.prototype.parse = function (data) { data.pos = this.offset; this.version = data.readUInt16(); this.averageCharWidth = data.readShort(); @@ -1002,7 +1002,7 @@ var OS2Table = (function(_super) { this.yStrikeoutSize = data.readShort(); this.yStrikeoutPosition = data.readShort(); this.familyClass = data.readShort(); - this.panose = (function() { + this.panose = (function () { var i, _results; _results = []; for (i = 0; i < 10; ++i) { @@ -1010,7 +1010,7 @@ var OS2Table = (function(_super) { } return _results; })(); - this.charRange = (function() { + this.charRange = (function () { var i, _results; _results = []; for (i = 0; i < 4; ++i) { @@ -1028,7 +1028,7 @@ var OS2Table = (function(_super) { this.lineGap = data.readShort(); this.winAscent = data.readShort(); this.winDescent = data.readShort(); - this.codePageRange = (function() { + this.codePageRange = (function () { var i, _results; _results = []; for (i = 0; i < 2; i = ++i) { @@ -1051,7 +1051,7 @@ var OS2Table = (function(_super) { return OS2Table; })(Table); -var PostTable = (function(_super) { +var PostTable = (function (_super) { var POSTSCRIPT_GLYPHS; __extends(PostTable, _super); @@ -1059,7 +1059,7 @@ var PostTable = (function(_super) { return PostTable.__super__.constructor.apply(this, arguments); } PostTable.prototype.tag = "post"; - PostTable.prototype.parse = function(data) { + PostTable.prototype.parse = function (data) { var length, numberOfGlyphs, _results; data.pos = this.offset; this.format = data.readInt(); @@ -1098,7 +1098,7 @@ var PostTable = (function(_super) { case 0x00030000: break; case 0x00040000: - return (this.map = function() { + return (this.map = function () { var _j, _ref, _results1; _results1 = []; for ( @@ -1172,9 +1172,10 @@ var PostTable = (function(_super) { } return table.data; };*/ - POSTSCRIPT_GLYPHS = ".notdef .null nonmarkingreturn space exclam quotedbl numbersign dollar percent\nampersand quotesingle parenleft parenright asterisk plus comma hyphen period slash\nzero one two three four five six seven eight nine colon semicolon less equal greater\nquestion at A B C D E F G H I J K L M N O P Q R S T U V W X Y Z\nbracketleft backslash bracketright asciicircum underscore grave\na b c d e f g h i j k l m n o p q r s t u v w x y z\nbraceleft bar braceright asciitilde Adieresis Aring Ccedilla Eacute Ntilde Odieresis\nUdieresis aacute agrave acircumflex adieresis atilde aring ccedilla eacute egrave\necircumflex edieresis iacute igrave icircumflex idieresis ntilde oacute ograve\nocircumflex odieresis otilde uacute ugrave ucircumflex udieresis dagger degree cent\nsterling section bullet paragraph germandbls registered copyright trademark acute\ndieresis notequal AE Oslash infinity plusminus lessequal greaterequal yen mu\npartialdiff summation product pi integral ordfeminine ordmasculine Omega ae oslash\nquestiondown exclamdown logicalnot radical florin approxequal Delta guillemotleft\nguillemotright ellipsis nonbreakingspace Agrave Atilde Otilde OE oe endash emdash\nquotedblleft quotedblright quoteleft quoteright divide lozenge ydieresis Ydieresis\nfraction currency guilsinglleft guilsinglright fi fl daggerdbl periodcentered\nquotesinglbase quotedblbase perthousand Acircumflex Ecircumflex Aacute Edieresis\nEgrave Iacute Icircumflex Idieresis Igrave Oacute Ocircumflex apple Ograve Uacute\nUcircumflex Ugrave dotlessi circumflex tilde macron breve dotaccent ring cedilla\nhungarumlaut ogonek caron Lslash lslash Scaron scaron Zcaron zcaron brokenbar Eth\neth Yacute yacute Thorn thorn minus multiply onesuperior twosuperior threesuperior\nonehalf onequarter threequarters franc Gbreve gbreve Idotaccent Scedilla scedilla\nCacute cacute Ccaron ccaron dcroat".split( - /\s+/g - ); + POSTSCRIPT_GLYPHS = + ".notdef .null nonmarkingreturn space exclam quotedbl numbersign dollar percent\nampersand quotesingle parenleft parenright asterisk plus comma hyphen period slash\nzero one two three four five six seven eight nine colon semicolon less equal greater\nquestion at A B C D E F G H I J K L M N O P Q R S T U V W X Y Z\nbracketleft backslash bracketright asciicircum underscore grave\na b c d e f g h i j k l m n o p q r s t u v w x y z\nbraceleft bar braceright asciitilde Adieresis Aring Ccedilla Eacute Ntilde Odieresis\nUdieresis aacute agrave acircumflex adieresis atilde aring ccedilla eacute egrave\necircumflex edieresis iacute igrave icircumflex idieresis ntilde oacute ograve\nocircumflex odieresis otilde uacute ugrave ucircumflex udieresis dagger degree cent\nsterling section bullet paragraph germandbls registered copyright trademark acute\ndieresis notequal AE Oslash infinity plusminus lessequal greaterequal yen mu\npartialdiff summation product pi integral ordfeminine ordmasculine Omega ae oslash\nquestiondown exclamdown logicalnot radical florin approxequal Delta guillemotleft\nguillemotright ellipsis nonbreakingspace Agrave Atilde Otilde OE oe endash emdash\nquotedblleft quotedblright quoteleft quoteright divide lozenge ydieresis Ydieresis\nfraction currency guilsinglleft guilsinglright fi fl daggerdbl periodcentered\nquotesinglbase quotedblbase perthousand Acircumflex Ecircumflex Aacute Edieresis\nEgrave Iacute Icircumflex Idieresis Igrave Oacute Ocircumflex apple Ograve Uacute\nUcircumflex Ugrave dotlessi circumflex tilde macron breve dotaccent ring cedilla\nhungarumlaut ogonek caron Lslash lslash Scaron scaron Zcaron zcaron brokenbar Eth\neth Yacute yacute Thorn thorn minus multiply onesuperior twosuperior threesuperior\nonehalf onequarter threequarters franc Gbreve gbreve Idotaccent Scedilla scedilla\nCacute cacute Ccaron ccaron dcroat".split( + /\s+/g + ); return PostTable; })(Table); @@ -1182,7 +1183,7 @@ var PostTable = (function(_super) { /* function : NameEntry */ /* comment : Store copyright information, platformID, encodingID, and languageID in the NameEntry object.*/ /*********************************************************************************************************/ -var NameEntry = (function() { +var NameEntry = (function () { function NameEntry(raw, entry) { this.raw = raw; this.length = raw.length; @@ -1193,7 +1194,7 @@ var NameEntry = (function() { return NameEntry; })(); -var NameTable = (function(_super) { +var NameTable = (function (_super) { var subsetTag; __extends(NameTable, _super); @@ -1201,7 +1202,7 @@ var NameTable = (function(_super) { return NameTable.__super__.constructor.apply(this, arguments); } NameTable.prototype.tag = "name"; - NameTable.prototype.parse = function(data) { + NameTable.prototype.parse = function (data) { var count, entries, entry, @@ -1325,14 +1326,14 @@ var NameTable = (function(_super) { return NameTable; })(Table); -var MaxpTable = (function(_super) { +var MaxpTable = (function (_super) { __extends(MaxpTable, _super); function MaxpTable() { return MaxpTable.__super__.constructor.apply(this, arguments); } MaxpTable.prototype.tag = "maxp"; - MaxpTable.prototype.parse = function(data) { + MaxpTable.prototype.parse = function (data) { data.pos = this.offset; this.version = data.readInt(); this.numGlyphs = data.readUInt16(); @@ -1373,14 +1374,14 @@ var MaxpTable = (function(_super) { return MaxpTable; })(Table); -var HmtxTable = (function(_super) { +var HmtxTable = (function (_super) { __extends(HmtxTable, _super); function HmtxTable() { return HmtxTable.__super__.constructor.apply(this, arguments); } HmtxTable.prototype.tag = "hmtx"; - HmtxTable.prototype.parse = function(data) { + HmtxTable.prototype.parse = function (data) { var i, last, lsbCount, m, _j, _ref, _results; data.pos = this.offset; this.metrics = []; @@ -1395,7 +1396,7 @@ var HmtxTable = (function(_super) { }); } lsbCount = this.file.maxp.numGlyphs - this.file.hhea.numberOfMetrics; - this.leftSideBearings = (function() { + this.leftSideBearings = (function () { var _j, _results; _results = []; for ( @@ -1407,7 +1408,7 @@ var HmtxTable = (function(_super) { } return _results; })(); - this.widths = function() { + this.widths = function () { var _j, _len, _ref1, _results; _ref1 = this.metrics; _results = []; @@ -1432,7 +1433,7 @@ var HmtxTable = (function(_super) { /* function : forGlyph */ /* comment : Returns the advance width and lsb for this glyph. */ /***************************************************************/ - HmtxTable.prototype.forGlyph = function(id) { + HmtxTable.prototype.forGlyph = function (id) { if (id in this.metrics) { return this.metrics[id]; } @@ -1457,17 +1458,17 @@ var HmtxTable = (function(_super) { var __slice = [].slice; -var GlyfTable = (function(_super) { +var GlyfTable = (function (_super) { __extends(GlyfTable, _super); function GlyfTable() { return GlyfTable.__super__.constructor.apply(this, arguments); } GlyfTable.prototype.tag = "glyf"; - GlyfTable.prototype.parse = function() { + GlyfTable.prototype.parse = function () { return (this.cache = {}); }; - GlyfTable.prototype.glyphFor = function(id) { + GlyfTable.prototype.glyphFor = function (id) { var data, index, length, @@ -1509,7 +1510,7 @@ var GlyfTable = (function(_super) { } return this.cache[id]; }; - GlyfTable.prototype.encode = function(glyphs, mapping, old2new) { + GlyfTable.prototype.encode = function (glyphs, mapping, old2new) { var glyph, id, offsets, table, _i, _len; table = []; offsets = []; @@ -1530,7 +1531,7 @@ var GlyfTable = (function(_super) { return GlyfTable; })(Table); -var SimpleGlyph = (function() { +var SimpleGlyph = (function () { /**************************************************************************/ /* function : SimpleGlyph */ /* comment : Stores raw, xMin, yMin, xMax, and yMax values for this glyph.*/ @@ -1544,13 +1545,13 @@ var SimpleGlyph = (function() { this.yMax = yMax; this.compound = false; } - SimpleGlyph.prototype.encode = function() { + SimpleGlyph.prototype.encode = function () { return this.raw.data; }; return SimpleGlyph; })(); -var CompoundGlyph = (function() { +var CompoundGlyph = (function () { var ARG_1_AND_2_ARE_WORDS, MORE_COMPONENTS, WE_HAVE_AN_X_AND_Y_SCALE, @@ -1604,7 +1605,7 @@ var CompoundGlyph = (function() { /* function : CompoundGlypg encode */ /* comment : After creating a table for the characters you typed, you call directory.encode to encode the table.*/ /****************************************************************************************************************/ - CompoundGlyph.prototype.encode = function() { + CompoundGlyph.prototype.encode = function () { var i, result, _len, _ref; result = new Data(__slice.call(this.raw.data)); _ref = this.glyphIDs; @@ -1616,19 +1617,19 @@ var CompoundGlyph = (function() { return CompoundGlyph; })(); -var LocaTable = (function(_super) { +var LocaTable = (function (_super) { __extends(LocaTable, _super); function LocaTable() { return LocaTable.__super__.constructor.apply(this, arguments); } LocaTable.prototype.tag = "loca"; - LocaTable.prototype.parse = function(data) { + LocaTable.prototype.parse = function (data) { var format, i; data.pos = this.offset; format = this.file.head.indexToLocFormat; if (format === 0) { - return (this.offsets = function() { + return (this.offsets = function () { var _ref, _results; _results = []; for (i = 0, _ref = this.length; i < _ref; i += 2) { @@ -1637,7 +1638,7 @@ var LocaTable = (function(_super) { return _results; }.call(this)); } else { - return (this.offsets = function() { + return (this.offsets = function () { var _ref, _results; _results = []; for (i = 0, _ref = this.length; i < _ref; i += 4) { @@ -1647,13 +1648,13 @@ var LocaTable = (function(_super) { }.call(this)); } }; - LocaTable.prototype.indexOf = function(id) { + LocaTable.prototype.indexOf = function (id) { return this.offsets[id]; }; - LocaTable.prototype.lengthOf = function(id) { + LocaTable.prototype.lengthOf = function (id) { return this.offsets[id + 1] - this.offsets[id]; }; - LocaTable.prototype.encode = function(offsets, activeGlyphs) { + LocaTable.prototype.encode = function (offsets, activeGlyphs) { var LocaTable = new Uint32Array(this.offsets.length); var glyfPtr = 0; var listGlyf = 0; @@ -1685,7 +1686,7 @@ var LocaTable = (function(_super) { /* function : invert */ /* comment : Change the object's (key: value) to create an object with (value: key).*/ /************************************************************************************/ -var invert = function(object) { +var invert = function (object) { var key, ret, val; ret = {}; for (key in object) { @@ -1742,7 +1743,7 @@ var invert = function(object) { return result; };*/ -var Subset = (function() { +var Subset = (function () { function Subset(font) { this.font = font; this.subset = {}; @@ -1775,7 +1776,7 @@ var Subset = (function() { /* function : generateCmap */ /* comment : Returns the unicode cmap for this font. */ /***************************************************************/ - Subset.prototype.generateCmap = function() { + Subset.prototype.generateCmap = function () { var mapping, roman, unicode, unicodeCmap, _ref; unicodeCmap = this.font.cmap.tables[0].codeMap; mapping = {}; @@ -1804,7 +1805,7 @@ var Subset = (function() { /* function : glyphsFor */ /* comment : Returns simple glyph objects for the input character.*/ /******************************************************************/ - Subset.prototype.glyphsFor = function(glyphIDs) { + Subset.prototype.glyphsFor = function (glyphIDs) { var additionalIDs, glyph, glyphs, id, _i, _len, _ref; glyphs = {}; for (_i = 0, _len = glyphIDs.length; _i < _len; _i++) { @@ -1831,7 +1832,7 @@ var Subset = (function() { /* function : encode */ /* comment : Encode various tables for the characters you use. */ /***************************************************************/ - Subset.prototype.encode = function(glyID, indexToLocFormat) { + Subset.prototype.encode = function (glyID, indexToLocFormat) { var cmap, code, glyf, @@ -1864,10 +1865,10 @@ var Subset = (function() { } } new2old = invert(old2new); - newIDs = Object.keys(new2old).sort(function(a, b) { + newIDs = Object.keys(new2old).sort(function (a, b) { return a - b; }); - oldIDs = (function() { + oldIDs = (function () { var _i, _len, _results; _results = []; for (_i = 0, _len = newIDs.length; _i < _len; _i++) { @@ -1897,21 +1898,21 @@ var Subset = (function() { return Subset; })(); -jsPDF.API.PDFObject = (function() { +jsPDF.API.PDFObject = (function () { var pad; function PDFObject() {} - pad = function(str, length) { + pad = function (str, length) { return (Array(length + 1).join("0") + str).slice(-length); }; /*****************************************************************************/ /* function : convert */ /* comment :Converts pdf tag's / FontBBox and array values in / W to strings */ /*****************************************************************************/ - PDFObject.convert = function(object) { + PDFObject.convert = function (object) { var e, items, key, out, val; if (Array.isArray(object)) { - items = (function() { + items = (function () { var _i, _len, _results; _results = []; for (_i = 0, _len = object.length; _i < _len; _i++) { diff --git a/src/modules/acroform.ts b/src/modules/acroform.ts index 622b982c1..5fd1ad9ab 100644 --- a/src/modules/acroform.ts +++ b/src/modules/acroform.ts @@ -13,17 +13,178 @@ */ import { jsPDF } from "../jspdf.js"; +import type { + Encryptor, + PageContext, + jsPDFAPI as JsPDFAPI, + jsPDFDocument +} from "../types.js"; -var jsPDFAPI = jsPDF.API; +// --------------------------------------------------------------------------- +// Internal types +// --------------------------------------------------------------------------- + +/** + * A single entry of an appearance (sub-)dictionary: either a finished + * FormXObject, a factory that produces one for a given field, or a raw string. + */ +type AppearanceStreamEntry = + | AcroFormXObject + | ((this: jsPDFDocument, formObject: AcroFormField) => AcroFormXObject) + | string; + +/** Appearance dictionary keyed by appearance type (N/R/D). */ +type AppearanceDict = Record< + string, + Record | AppearanceStreamEntry +>; + +/** Everything a field's `appearanceStreamContent` may hold. */ +type AppearanceStreamContent = string | AcroFormXObject | AppearanceDict; + +/** Element type of the deferred XObject list (`acroformPlugin.xForms`). */ +type AcroFormXFormEntry = AppearanceStreamContent | AppearanceStreamEntry; + +/** State stashed on `doc.internal` by the AcroForm plugin. */ +interface AcroFormPluginData { + fields: AcroFormField[]; + xForms: AcroFormXFormEntry[]; + /** + * acroFormDictionaryRoot contains information about the AcroForm + * Dictionary 0: The Event-Token, the AcroFormDictionaryCallback has + * 1: The Object ID of the Root + */ + acroFormDictionaryRoot: AcroFormDictionary | null; + /** + * After the PDF gets evaluated, the reference to the root has to be + * reset, this indicates, whether the root has already been printed + * out + */ + printedOut: boolean; + internal: unknown; + isInitialized: boolean; +} + +/** Bit-manipulation helpers exposed as `jsPDF.API.__acroform__`. */ +interface AcroFormUtilities { + setBit(number?: number, bitPosition?: number): number; + clearBit(number?: number, bitPosition?: number): number; + getBit(number: number, bitPosition: number): number; + getBitForPdf(number: number, bitPosition: number): number; + setBitForPdf(number: number, bitPosition: number): number; + clearBitForPdf(number: number, bitPosition: number): number; + calculateCoordinates(args: number[], scope: jsPDFDocument): number[]; + arrayToPdfArray( + array: unknown[], + objId?: number, + scope?: jsPDFDocument + ): string; +} + +interface AppearancePoint { + x: number; + y: number; +} + +interface AppearanceCross { + x1: AppearancePoint; + x2: AppearancePoint; + x3: AppearancePoint; + x4: AppearancePoint; +} + +/** Standard appearance builders for CheckBoxes. */ +interface AcroFormCheckBoxAppearanceProvider { + createAppearanceStream(): AppearanceDict; + YesPushDown(formObject: AcroFormField): AcroFormXObject; + YesNormal(formObject: AcroFormField): AcroFormXObject; + OffPushDown(formObject: AcroFormField): AcroFormXObject; +} + +/** Standard appearance builders for RadioButtons (Circle/Cross). */ +interface AcroFormRadioButtonAppearanceProvider { + createAppearanceStream(name: string): AppearanceDict; + getCA(): string; + YesNormal(formObject: AcroFormField): AcroFormXObject; + YesPushDown(formObject: AcroFormField): AcroFormXObject; + OffPushDown(formObject: AcroFormField): AcroFormXObject; +} + +interface AcroFormAppearanceInternal { + Bezier_C: number; + calculateCross(formObject: AcroFormField): AppearanceCross; + getWidth(formObject: AcroFormField): number; + getHeight(formObject: AcroFormField): number; +} + +interface AcroFormAppearanceType { + CheckBox: AcroFormCheckBoxAppearanceProvider; + RadioButton: { + Circle: AcroFormRadioButtonAppearanceProvider; + Cross: AcroFormRadioButtonAppearanceProvider; + }; + createDefaultAppearanceStream(formObject: AcroFormField): string; + internal: AcroFormAppearanceInternal; +} + +/** The static class map exposed as `jsPDF.AcroForm` / `jsPDF.API.AcroForm`. */ +interface AcroFormStatic { + ChoiceField: typeof AcroFormChoiceField; + ListBox: typeof AcroFormListBox; + ComboBox: typeof AcroFormComboBox; + EditBox: typeof AcroFormEditBox; + Button: typeof AcroFormButton; + PushButton: typeof AcroFormPushButton; + RadioButton: typeof AcroFormRadioButton; + CheckBox: typeof AcroFormCheckBox; + TextField: typeof AcroFormTextField; + PasswordField: typeof AcroFormPasswordField; + Appearance: AcroFormAppearanceType; +} + +/** Annotation reference entry pushed into the page context by this plugin. */ +interface AcroFormAnnotationEntry { + type: string; + object: AcroFormField; +} + +interface PageContextWithAnnotations extends PageContext { + annotations: AcroFormAnnotationEntry[]; +} + +declare module "../types.js" { + interface jsPDFInternal { + /** State stashed by the AcroForm plugin (see initializeAcroForm). */ + acroformPlugin: AcroFormPluginData; + } + interface jsPDFAPI { + __acroform__: AcroFormUtilities; + addField(this: jsPDFDocument, fieldObject: AcroFormField): jsPDFDocument; + AcroFormChoiceField: typeof AcroFormChoiceField; + AcroFormListBox: typeof AcroFormListBox; + AcroFormComboBox: typeof AcroFormComboBox; + AcroFormEditBox: typeof AcroFormEditBox; + AcroFormButton: typeof AcroFormButton; + AcroFormPushButton: typeof AcroFormPushButton; + AcroFormRadioButton: typeof AcroFormRadioButton; + AcroFormCheckBox: typeof AcroFormCheckBox; + AcroFormTextField: typeof AcroFormTextField; + AcroFormPasswordField: typeof AcroFormPasswordField; + AcroFormAppearance: AcroFormAppearanceType; + AcroForm: AcroFormStatic; + } +} + +var jsPDFAPI: JsPDFAPI = jsPDF.API; var scaleFactor = 1; -var pdfEscape = function(value) { +var pdfEscape = function (value: string): string { return value .replace(/\\/g, "\\\\") .replace(/\(/g, "\\(") .replace(/\)/g, "\\)"); }; -var pdfUnescape = function(value) { +var pdfUnescape = function (value: string): string { return value .replace(/\\\\/g, "\\") .replace(/\\\(/g, "(") @@ -34,38 +195,29 @@ var pdfUnescape = function(value) { * Escapes a PDF Name Object. * Replaces special characters (delimiter, whitespace, #) with their hex representation. */ -var pdfEscapeName = function(value) { +var pdfEscapeName = function (value: string): string { return value .toString() .replace(/#/g, "#23") .replace(/[\s\n\r()<>[\]{}\/%]/g, c => { - const hex = c - .charCodeAt(0) - .toString(16) - .toUpperCase(); + const hex = c.charCodeAt(0).toString(16).toUpperCase(); return "#" + (hex.length === 1 ? "0" + hex : hex); }); }; -var f2 = function(number) { +var f2 = function (number: number): string { return number.toFixed(2); // Ie, %.2f }; -var f5 = function(number) { +var f5 = function (number: number): string { return number.toFixed(5); // Ie, %.2f }; -jsPDFAPI.__acroform__ = {}; -var inherit = function(child, parent) { - child.prototype = Object.create(parent.prototype); - child.prototype.constructor = child; -}; - -var scale = function(x) { +var scale = function (x: number): number { return x * scaleFactor; }; -var createFormXObject = function(formObject) { +var createFormXObject = function (formObject: AcroFormField): AcroFormXObject { var xobj = new AcroFormXObject(); var height = AcroFormAppearance.internal.getHeight(formObject) || 0; var width = AcroFormAppearance.internal.getWidth(formObject) || 0; @@ -76,7 +228,7 @@ var createFormXObject = function(formObject) { /** * Bit-Operations */ -var setBit = (jsPDFAPI.__acroform__.setBit = function(number, bitPosition) { +var setBit = function (number?: number, bitPosition?: number): number { number = number || 0; bitPosition = bitPosition || 0; @@ -90,9 +242,9 @@ var setBit = (jsPDFAPI.__acroform__.setBit = function(number, bitPosition) { number |= bitMask; return number; -}); +}; -var clearBit = (jsPDFAPI.__acroform__.clearBit = function(number, bitPosition) { +var clearBit = function (number?: number, bitPosition?: number): number { number = number || 0; bitPosition = bitPosition || 0; @@ -106,60 +258,51 @@ var clearBit = (jsPDFAPI.__acroform__.clearBit = function(number, bitPosition) { number &= ~bitMask; return number; -}); +}; -var getBit = (jsPDFAPI.__acroform__.getBit = function(number, bitPosition) { +var getBit = function (number: number, bitPosition: number): number { if (isNaN(number) || isNaN(bitPosition)) { throw new Error( "Invalid arguments passed to jsPDF.API.__acroform__.getBit" ); } return (number & (1 << bitPosition)) === 0 ? 0 : 1; -}); +}; /* * Ff starts counting the bit position at 1 and not like javascript at 0 */ -var getBitForPdf = (jsPDFAPI.__acroform__.getBitForPdf = function( - number, - bitPosition -) { +var getBitForPdf = function (number: number, bitPosition: number): number { if (isNaN(number) || isNaN(bitPosition)) { throw new Error( "Invalid arguments passed to jsPDF.API.__acroform__.getBitForPdf" ); } return getBit(number, bitPosition - 1); -}); +}; -var setBitForPdf = (jsPDFAPI.__acroform__.setBitForPdf = function( - number, - bitPosition -) { +var setBitForPdf = function (number: number, bitPosition: number): number { if (isNaN(number) || isNaN(bitPosition)) { throw new Error( "Invalid arguments passed to jsPDF.API.__acroform__.setBitForPdf" ); } return setBit(number, bitPosition - 1); -}); +}; -var clearBitForPdf = (jsPDFAPI.__acroform__.clearBitForPdf = function( - number, - bitPosition -) { +var clearBitForPdf = function (number: number, bitPosition: number): number { if (isNaN(number) || isNaN(bitPosition)) { throw new Error( "Invalid arguments passed to jsPDF.API.__acroform__.clearBitForPdf" ); } return clearBit(number, bitPosition - 1); -}); +}; -var calculateCoordinates = (jsPDFAPI.__acroform__.calculateCoordinates = function( - args, - scope -) { +var calculateCoordinates = function ( + args: number[], + scope: jsPDFDocument +): number[] { var getHorizontalCoordinate = scope.internal.getHorizontalCoordinate; var getVerticalCoordinate = scope.internal.getVerticalCoordinate; var x = args[0]; @@ -167,22 +310,22 @@ var calculateCoordinates = (jsPDFAPI.__acroform__.calculateCoordinates = functio var w = args[2]; var h = args[3]; - var coordinates: any = {}; - - coordinates.lowerLeft_X = getHorizontalCoordinate(x) || 0; - coordinates.lowerLeft_Y = getVerticalCoordinate(y + h) || 0; - coordinates.upperRight_X = getHorizontalCoordinate(x + w) || 0; - coordinates.upperRight_Y = getVerticalCoordinate(y) || 0; + var lowerLeft_X = getHorizontalCoordinate(x) || 0; + var lowerLeft_Y = getVerticalCoordinate(y + h) || 0; + var upperRight_X = getHorizontalCoordinate(x + w) || 0; + var upperRight_Y = getVerticalCoordinate(y) || 0; return [ - Number(f2(coordinates.lowerLeft_X)), - Number(f2(coordinates.lowerLeft_Y)), - Number(f2(coordinates.upperRight_X)), - Number(f2(coordinates.upperRight_Y)) + Number(f2(lowerLeft_X)), + Number(f2(lowerLeft_Y)), + Number(f2(upperRight_X)), + Number(f2(upperRight_Y)) ]; -}); +}; -var calculateAppearanceStream = function(formObject) { +var calculateAppearanceStream = function ( + formObject: AcroFormField +): AppearanceStreamContent { if (formObject.appearanceStreamContent) { return formObject.appearanceStreamContent; } @@ -219,12 +362,17 @@ var calculateAppearanceStream = function(formObject) { return appearanceStreamContent; }; -var calculateX = function(formObject, text) { +var calculateX = function ( + // TextField-specific fields (multiline) are optional here because the + // appearance calculation is shared across field types. + formObject: AcroFormField & { multiline?: boolean }, + text: string +): { text: string; fontSize: number } { var maxFontSize = formObject.fontSize === 0 ? formObject.maxFontSize : formObject.fontSize; var returnValue = { text: "", - fontSize: "" + fontSize: 0 }; // Remove Brackets text = text.substr(0, 1) == "(" ? text.substr(1) : text; @@ -233,11 +381,12 @@ var calculateX = function(formObject, text) { ? text.substr(0, text.length - 1) : text; // split into array of words - var textSplit = text.split(" "); + var words = text.split(" "); + var textSplit: string[][]; if (formObject.multiline) { - textSplit = textSplit.map(word => word.split("\n")); + textSplit = words.map(word => word.split("\n")); } else { - textSplit = textSplit.map(word => [word]); + textSplit = words.map(word => [word]); } var fontSize = maxFontSize; // The Starting fontSize (The Maximum) @@ -249,7 +398,11 @@ var calculateX = function(formObject, text) { var width = AcroFormAppearance.internal.getWidth(formObject) || 0; width = width < 0 ? -width : width; - var isSmallerThanWidth = function(i, lastLine, fontSize) { + var isSmallerThanWidth = function ( + i: number, + lastLine: string, + fontSize: number + ): boolean { if (i + 1 < textSplit.length) { var tmp = lastLine + " " + textSplit[i + 1][0]; var TextWidth = calculateFontSpace(tmp, formObject, fontSize).width; @@ -269,12 +422,12 @@ var calculateX = function(formObject, text) { ? height - fontSize : (height - textHeight) / 2; startY += lineSpacing; - var startX; + var startX: number; var lastY = startY; var firstWordInLine = 0, lastWordInLine = 0; - var lastLength; + var lastLength: number; var currWord = 0; if (fontSize <= 0) { @@ -313,7 +466,7 @@ var calculateX = function(formObject, text) { lastLine.substr(lastLine.length - 1) == " " ? lastLine.substr(0, lastLine.length - 1) : lastLine; - var key = parseInt(i as any); + var key = i; var nextLineIsSmaller = isSmallerThanWidth(key, lastLine, fontSize); var isLastWord = i >= textSplit.length - 1; @@ -393,7 +546,7 @@ var calculateX = function(formObject, text) { text += f2(startX) + " " + f2(lastY) + " Td\n"; text += "(" + pdfEscape(line) + ") Tj\n"; // reset X in PDF - text += -f2(startX) + " 0 Td\n"; + text += -Number(f2(startX)) + " 0 Td\n"; // After a Line, adjust y position lastY = -(fontSize + lineSpacing); @@ -423,7 +576,11 @@ var calculateX = function(formObject, text) { * @param fontsize * @returns {TextMetrics} (Has Height and Width) */ -var calculateFontSpace = function(text, formObject, fontSize) { +var calculateFontSpace = function ( + text: string, + formObject: AcroFormField, + fontSize: number +): { height: number; width: number } { var font = formObject.scope.internal.getFont( formObject.fontName, formObject.fontStyle @@ -431,21 +588,21 @@ var calculateFontSpace = function(text, formObject, fontSize) { var width = formObject.scope.getStringUnitWidth(text, { font: font, - fontSize: parseFloat(fontSize), + fontSize: parseFloat(String(fontSize)), charSpace: 0 - }) * parseFloat(fontSize); + }) * parseFloat(String(fontSize)); var height = formObject.scope.getStringUnitWidth("3", { font: font, - fontSize: parseFloat(fontSize), + fontSize: parseFloat(String(fontSize)), charSpace: 0 }) * - parseFloat(fontSize) * + parseFloat(String(fontSize)) * 1.5; return { height: height, width: width }; }; -var acroformPluginTemplate = { +var acroformPluginTemplate: AcroFormPluginData = { fields: [], xForms: [], /** @@ -464,13 +621,13 @@ var acroformPluginTemplate = { isInitialized: false }; -var annotReferenceCallback = function(scope) { +var annotReferenceCallback = function (scope: jsPDFDocument): void { //set objId to undefined and force it to get a new objId on buildDocument scope.internal.acroformPlugin.acroFormDictionaryRoot.objId = undefined; var fields = scope.internal.acroformPlugin.acroFormDictionaryRoot.Fields; for (var i in fields) { if (fields.hasOwnProperty(i)) { - var formObject = fields[i]; + var formObject = fields[Number(i)]; //set objId to undefined and force it to get a new objId on buildDocument formObject.objId = undefined; // add Annot Reference! @@ -483,7 +640,7 @@ var annotReferenceCallback = function(scope) { } }; -var putForm = function(formObject) { +var putForm = function (formObject: AcroFormField): void { if (formObject.scope.internal.acroformPlugin.printedOut) { formObject.scope.internal.acroformPlugin.printedOut = false; formObject.scope.internal.acroformPlugin.acroFormDictionaryRoot = null; @@ -496,28 +653,33 @@ var putForm = function(formObject) { * Create the Reference to the widgetAnnotation, so that it gets referenced * in the Annot[] int the+ (Requires the Annotation Plugin) */ -var createAnnotationReference = function(object, scope) { +var createAnnotationReference = function ( + object: AcroFormField, + scope: jsPDFDocument +): void { var options = { type: "reference", object: object }; - var findEntry = function(entry) { + var findEntry = function (entry: AcroFormAnnotationEntry): boolean { return entry.type === options.type && entry.object === options.object; }; if ( - scope.internal - .getPageInfo(object.page) - .pageContext.annotations.find(findEntry) === undefined + ( + scope.internal.getPageInfo(object.page) + .pageContext as PageContextWithAnnotations + ).annotations.find(findEntry) === undefined ) { - scope.internal - .getPageInfo(object.page) - .pageContext.annotations.push(options); + ( + scope.internal.getPageInfo(object.page) + .pageContext as PageContextWithAnnotations + ).annotations.push(options); } }; // Callbacks -var putCatalogCallback = function(scope) { +var putCatalogCallback = function (scope: jsPDFDocument): void { // Put reference to AcroForm to DocumentCatalog if ( typeof scope.internal.acroformPlugin.acroFormDictionaryRoot !== "undefined" @@ -539,7 +701,7 @@ var putCatalogCallback = function(scope) { * Adds /Acroform X 0 R to Document Catalog, and creates the AcroForm * Dictionary */ -var AcroFormDictionaryCallback = function(scope) { +var AcroFormDictionaryCallback = function (scope: jsPDFDocument): void { // Remove event scope.internal.events.unsubscribe( scope.internal.acroformPlugin.acroFormDictionaryRoot._eventID @@ -554,7 +716,10 @@ var AcroFormDictionaryCallback = function(scope) { * If fieldArray is set, use the fields that are inside it instead of the * fields from the AcroRoot (for the FormXObjects...) */ -var createFieldCallback = function(fieldArray, scope) { +var createFieldCallback = function ( + fieldArray: AcroFormField[] | undefined, + scope: jsPDFDocument +): void { var standardFields = !fieldArray; if (!fieldArray) { @@ -573,8 +738,8 @@ var createFieldCallback = function(fieldArray, scope) { for (var i in fieldArray) { if (fieldArray.hasOwnProperty(i)) { - var fieldObject = fieldArray[i]; - var keyValueList = []; + var fieldObject = fieldArray[Number(i)]; + var keyValueList: Array<{ key: string; value: string | number }> = []; var oldRect = fieldObject.Rect; if (fieldObject.Rect) { @@ -584,9 +749,8 @@ var createFieldCallback = function(fieldArray, scope) { // Start Writing the Object scope.internal.newObjectDeferredBegin(fieldObject.objId, true); - fieldObject.DA = AcroFormAppearance.createDefaultAppearanceStream( - fieldObject - ); + fieldObject.DA = + AcroFormAppearance.createDefaultAppearanceStream(fieldObject); if ( typeof fieldObject === "object" && @@ -611,18 +775,27 @@ var createFieldCallback = function(fieldArray, scope) { // Assume AppearanceStreamContent is a Array with N,R,D (at least // one of them!) if (fieldObject.appearanceStreamContent) { + // The appearance stream is a (sub-)dictionary at this point; + // string/XObject variants take the else branch below. + var appearanceStreamContent = + fieldObject.appearanceStreamContent as Record< + string, + Record | AppearanceStreamEntry + >; var appearanceStreamString = ""; // Iterate over N,R and D - for (var k in fieldObject.appearanceStreamContent) { - if (fieldObject.appearanceStreamContent.hasOwnProperty(k)) { - var value = fieldObject.appearanceStreamContent[k]; + for (var k in appearanceStreamContent) { + if (appearanceStreamContent.hasOwnProperty(k)) { + var value = appearanceStreamContent[k]; + var obj: typeof value; appearanceStreamString += "/" + k + " "; appearanceStreamString += "<<"; if (Object.keys(value).length >= 1 || Array.isArray(value)) { // appearanceStream is an Array or Object! - for (var i in value) { - if (value.hasOwnProperty(i)) { - var obj = value[i]; + var valueRecord = value as Record; + for (var i in valueRecord) { + if (valueRecord.hasOwnProperty(i)) { + obj = valueRecord[i]; if (typeof obj === "function") { // if Function is referenced, call it in order // to get the FormXObject @@ -671,11 +844,15 @@ var createFieldCallback = function(fieldArray, scope) { } }; -var createXFormObjectCallback = function(fieldArray, scope) { +var createXFormObjectCallback = function ( + fieldArray: AcroFormXFormEntry[], + scope: jsPDFDocument +): void { for (var i in fieldArray) { if (fieldArray.hasOwnProperty(i)) { var key = i; - var fieldObject = fieldArray[i]; + // Only FormXObjects are stored in the xForms list. + var fieldObject = fieldArray[Number(i)] as AcroFormXObject; // Start Writing the Object scope.internal.newObjectDeferredBegin(fieldObject.objId, true); @@ -685,12 +862,15 @@ var createXFormObjectCallback = function(fieldArray, scope) { ) { fieldObject.putStream(); } - delete fieldArray[key]; + delete fieldArray[Number(key)]; } } }; -var initializeAcroForm = function(scope, formObject) { +var initializeAcroForm = function ( + scope: jsPDFDocument, + formObject: AcroFormField +): void { formObject.scope = scope; if ( scope.internal !== undefined && @@ -706,44 +886,46 @@ var initializeAcroForm = function(scope, formObject) { } scaleFactor = scope.internal.scaleFactor; // The Object Number of the AcroForm Dictionary - scope.internal.acroformPlugin.acroFormDictionaryRoot = new AcroFormDictionary(); + scope.internal.acroformPlugin.acroFormDictionaryRoot = + new AcroFormDictionary(); scope.internal.acroformPlugin.acroFormDictionaryRoot.scope = scope; // add Callback for creating the AcroForm Dictionary - scope.internal.acroformPlugin.acroFormDictionaryRoot._eventID = scope.internal.events.subscribe( - "postPutResources", - function() { + scope.internal.acroformPlugin.acroFormDictionaryRoot._eventID = + scope.internal.events.subscribe("postPutResources", function () { AcroFormDictionaryCallback(scope); - } - ); + }); - scope.internal.events.subscribe("buildDocument", function() { + scope.internal.events.subscribe("buildDocument", function () { annotReferenceCallback(scope); }); // buildDocument // Register event, that is triggered when the DocumentCatalog is // written, in order to add /AcroForm - scope.internal.events.subscribe("putCatalog", function() { + scope.internal.events.subscribe("putCatalog", function () { putCatalogCallback(scope); }); // Register event, that creates all Fields - scope.internal.events.subscribe("postPutPages", function(fieldArray) { - createFieldCallback(fieldArray, scope); - }); + scope.internal.events.subscribe( + "postPutPages", + function (fieldArray?: AcroFormField[]) { + createFieldCallback(fieldArray, scope); + } + ); scope.internal.acroformPlugin.isInitialized = true; } }; //PDF 32000-1:2008, page 26, 7.3.6 -var arrayToPdfArray = (jsPDFAPI.__acroform__.arrayToPdfArray = function( - array, - objId, - scope -) { - var encryptor = function(data) { +var arrayToPdfArray = function ( + array: unknown[], + objId?: number, + scope?: jsPDFDocument +): string { + var encryptor: Encryptor = function (data) { return data; }; if (Array.isArray(array)) { @@ -752,19 +934,20 @@ var arrayToPdfArray = (jsPDFAPI.__acroform__.arrayToPdfArray = function( if (i !== 0) { content += " "; } - switch (typeof array[i]) { + var element = array[i]; + switch (typeof element) { case "boolean": case "number": case "object": - content += array[i].toString(); + content += element.toString(); break; case "string": - if (array[i].substr(0, 1) === "/") { - content += "/" + pdfEscapeName(array[i].substr(1)); + if (element.substr(0, 1) === "/") { + content += "/" + pdfEscapeName(element.substr(1)); } else { if (typeof objId !== "undefined" && scope) encryptor = scope.internal.getEncryptor(objId); - content += "(" + pdfEscape(encryptor(array[i].toString())) + ")"; + content += "(" + pdfEscape(encryptor(element.toString())) + ")"; } break; } @@ -775,27 +958,31 @@ var arrayToPdfArray = (jsPDFAPI.__acroform__.arrayToPdfArray = function( throw new Error( "Invalid argument passed to jsPDF.__acroform__.arrayToPdfArray" ); -}); +}; -function getMatches(string, regex, index?) { +function getMatches(string: string, regex: RegExp, index?: number): string[] { index || (index = 1); // default to the first capturing group var matches = []; - var match; + var match: RegExpExecArray | null; while ((match = regex.exec(string))) { matches.push(match[index]); } return matches; } -var pdfArrayToStringArray = function(array) { - var result = []; +var pdfArrayToStringArray = function (array: string): string[] { + var result: string[] = []; if (typeof array === "string") { result = getMatches(array, /\((.*?)\)/g); } return result; }; -var toPdfString = function(string, objId, scope) { - var encryptor = function(data) { +var toPdfString = function ( + string: string, + objId: number | undefined, + scope: jsPDFDocument | undefined +): string { + var encryptor: Encryptor = function (data) { return data; }; if (typeof objId !== "undefined" && scope) @@ -814,197 +1001,220 @@ var toPdfString = function(string, objId, scope) { * @class AcroFormPDFObject * @classdesc A AcroFormPDFObject */ -var AcroFormPDFObject = function() { - this._objId = undefined; - this._scope = undefined; +class AcroFormPDFObject { + declare _objId: number | undefined; + declare _scope: jsPDFDocument | undefined; + declare objId: number; + declare scope: jsPDFDocument; + declare stream: string | null; - /** - * @name AcroFormPDFObject#objId - * @type {any} - */ - Object.defineProperty(this, "objId", { - get: function() { - if (typeof this._objId === "undefined") { - if (typeof this.scope === "undefined") { - return undefined; + constructor() { + this._objId = undefined; + this._scope = undefined; + + /** + * @name AcroFormPDFObject#objId + * @type {any} + */ + Object.defineProperty(this, "objId", { + get: function (this: AcroFormPDFObject) { + if (typeof this._objId === "undefined") { + if (typeof this.scope === "undefined") { + return undefined; + } + this._objId = this.scope.internal.newObjectDeferred(); } - this._objId = this.scope.internal.newObjectDeferred(); + return this._objId; + }, + set: function (this: AcroFormPDFObject, value: number) { + this._objId = value; } - return this._objId; - }, - set: function(value) { - this._objId = value; - } - }); - Object.defineProperty(this, "scope", { - value: this._scope, - writable: true - }); -}; + }); + Object.defineProperty(this, "scope", { + value: this._scope, + writable: true + }); + } -/** - * @function AcroFormPDFObject.toString - */ -AcroFormPDFObject.prototype.toString = function() { - return this.objId + " 0 R"; -}; + /** + * @function AcroFormPDFObject.toString + */ + toString(): string { + return this.objId + " 0 R"; + } -AcroFormPDFObject.prototype.putStream = function() { - var keyValueList = this.getKeyValueListForStream(); - this.scope.internal.putStream({ - data: this.stream, - additionalKeyValues: keyValueList, - objectId: this.objId - }); - this.scope.internal.out("endobj"); -}; + putStream(): void { + var keyValueList = this.getKeyValueListForStream(); + this.scope.internal.putStream({ + data: this.stream, + additionalKeyValues: keyValueList, + objectId: this.objId + }); + this.scope.internal.out("endobj"); + } -/** - * Returns an key-value-List of all non-configurable Variables from the Object - * - * @name getKeyValueListForStream - * @returns {string} - */ -AcroFormPDFObject.prototype.getKeyValueListForStream = function() { - var keyValueList = []; - var keys = Object.getOwnPropertyNames(this).filter(function(key) { - return ( - key != "content" && - key != "appearanceStreamContent" && - key != "scope" && - key != "objId" && - key.substring(0, 1) != "_" - ); - }); - - for (var i in keys) { - if (Object.getOwnPropertyDescriptor(this, keys[i]).configurable === false) { - var key = keys[i]; - var value = this[key]; - - if (value) { - if (Array.isArray(value)) { - keyValueList.push({ - key: key, - value: arrayToPdfArray(value, this.objId, this.scope) - }); - } else if (value instanceof AcroFormPDFObject) { - // In case it is a reference to another PDFObject, - // take the reference number - (value as any).scope = this.scope; - keyValueList.push({ key: key, value: (value as any).objId + " 0 R" }); - } else if (typeof value !== "function") { - keyValueList.push({ key: key, value: value }); + /** + * Returns an key-value-List of all non-configurable Variables from the Object + * + * @name getKeyValueListForStream + * @returns {string} + */ + getKeyValueListForStream(): Array<{ key: string; value: string | number }> { + var keyValueList: Array<{ key: string; value: string | number }> = []; + var keys = Object.getOwnPropertyNames(this).filter(function (key) { + return ( + key != "content" && + key != "appearanceStreamContent" && + key != "scope" && + key != "objId" && + key.substring(0, 1) != "_" + ); + }); + + for (var i in keys) { + if ( + Object.getOwnPropertyDescriptor(this, keys[Number(i)]).configurable === + false + ) { + var key = keys[Number(i)]; + var value = (this as AcroFormPDFObject & Record)[key]; + + if (value) { + if (Array.isArray(value)) { + keyValueList.push({ + key: key, + value: arrayToPdfArray(value, this.objId, this.scope) + }); + } else if (value instanceof AcroFormPDFObject) { + // In case it is a reference to another PDFObject, + // take the reference number + value.scope = this.scope; + keyValueList.push({ key: key, value: value.objId + " 0 R" }); + } else if (typeof value !== "function") { + keyValueList.push({ key: key, value: value as string | number }); + } } } } + return keyValueList; } - return keyValueList; -}; +} -var AcroFormXObject = function() { - AcroFormPDFObject.call(this); - - Object.defineProperty(this, "Type", { - value: "/XObject", - configurable: false, - writable: true - }); - - Object.defineProperty(this, "Subtype", { - value: "/Form", - configurable: false, - writable: true - }); - - Object.defineProperty(this, "FormType", { - value: 1, - configurable: false, - writable: true - }); - - var _BBox = []; - Object.defineProperty(this, "BBox", { - configurable: false, - get: function() { - return _BBox; - }, - set: function(value) { - _BBox = value; - } - }); - - Object.defineProperty(this, "Resources", { - value: "2 0 R", - configurable: false, - writable: true - }); - - var _stream; - Object.defineProperty(this, "stream", { - enumerable: false, - configurable: true, - set: function(value) { - _stream = value.trim(); - }, - get: function() { - if (_stream) { - return _stream; - } else { - return null; +class AcroFormXObject extends AcroFormPDFObject { + declare Type: string; + declare Subtype: string; + declare FormType: number; + declare BBox: number[]; + declare Resources: string; + + constructor() { + super(); + + Object.defineProperty(this, "Type", { + value: "/XObject", + configurable: false, + writable: true + }); + + Object.defineProperty(this, "Subtype", { + value: "/Form", + configurable: false, + writable: true + }); + + Object.defineProperty(this, "FormType", { + value: 1, + configurable: false, + writable: true + }); + + var _BBox: number[] = []; + Object.defineProperty(this, "BBox", { + configurable: false, + get: function () { + return _BBox; + }, + set: function (value: number[]) { + _BBox = value; } - } - }); -}; + }); + + Object.defineProperty(this, "Resources", { + value: "2 0 R", + configurable: false, + writable: true + }); + + var _stream: string; + Object.defineProperty(this, "stream", { + enumerable: false, + configurable: true, + set: function (value: string) { + _stream = value.trim(); + }, + get: function () { + if (_stream) { + return _stream; + } else { + return null; + } + } + }); + } +} -inherit(AcroFormXObject, AcroFormPDFObject); +class AcroFormDictionary extends AcroFormPDFObject { + declare Kids: AcroFormField[]; + declare Fields: AcroFormField[]; + declare DA: string; + declare _eventID: string; -var AcroFormDictionary = function() { - AcroFormPDFObject.call(this); + constructor() { + super(); - var _Kids = []; + var _Kids: AcroFormField[] = []; - Object.defineProperty(this, "Kids", { - enumerable: false, - configurable: true, - get: function() { - if (_Kids.length > 0) { - return _Kids; - } else { - return undefined; + Object.defineProperty(this, "Kids", { + enumerable: false, + configurable: true, + get: function () { + if (_Kids.length > 0) { + return _Kids; + } else { + return undefined; + } } - } - }); - Object.defineProperty(this, "Fields", { - enumerable: false, - configurable: false, - get: function() { - return _Kids; - } - }); - - // Default Appearance - var _DA; - Object.defineProperty(this, "DA", { - enumerable: false, - configurable: false, - get: function() { - if (!_DA) { - return undefined; + }); + Object.defineProperty(this, "Fields", { + enumerable: false, + configurable: false, + get: function () { + return _Kids; } - var encryptor = function(data) { - return data; - }; - if (this.scope) encryptor = this.scope.internal.getEncryptor(this.objId); - return "(" + pdfEscape(encryptor(_DA)) + ")"; - }, - set: function(value) { - _DA = value; - } - }); -}; + }); -inherit(AcroFormDictionary, AcroFormPDFObject); + // Default Appearance + var _DA: string; + Object.defineProperty(this, "DA", { + enumerable: false, + configurable: false, + get: function (this: AcroFormDictionary) { + if (!_DA) { + return undefined; + } + var encryptor: Encryptor = function (data) { + return data; + }; + if (this.scope) + encryptor = this.scope.internal.getEncryptor(this.objId); + return "(" + pdfEscape(encryptor(_DA)) + ")"; + }, + set: function (value: string) { + _DA = value; + } + }); + } +} /** * The Field Object contains the Variables, that every Field needs @@ -1012,959 +1222,1021 @@ inherit(AcroFormDictionary, AcroFormPDFObject); * @class AcroFormField * @classdesc An AcroForm FieldObject */ -var AcroFormField: any = function() { - AcroFormPDFObject.call(this); - - //Annotation-Flag See Table 165 - var _F = 4; - Object.defineProperty(this, "F", { - enumerable: false, - configurable: false, - get: function() { - return _F; - }, - set: function(value) { - if (!isNaN(value)) { - _F = value; - } else { - throw new Error( - 'Invalid value "' + value + '" for attribute F supplied.' - ); +class AcroFormField extends AcroFormPDFObject { + declare static FieldNum: number; + + declare F: number; + declare showWhenPrinted: boolean; + declare Ff: number; + declare Rect: number[]; + declare x: number; + declare y: number; + declare width: number; + declare height: number; + declare FT: string; + declare T: string; + declare fieldName: string; + declare fontName: string; + declare fontStyle: string; + declare fontSize: number; + declare maxFontSize: number; + declare color: string; + declare DA: string; + declare DV: string; + declare defaultValue: string; + declare _V: string; + declare V: string; + declare value: string; + declare hasAnnotation: boolean; + declare Type: string | null; + declare Subtype: string | null; + declare hasAppearanceStream: boolean; + declare page: number; + declare readOnly: boolean; + declare required: boolean; + declare noExport: boolean; + declare Q: number; + declare textAlign: string; + declare appearanceStreamContent?: AppearanceStreamContent; + + constructor() { + super(); + + //Annotation-Flag See Table 165 + var _F = 4; + Object.defineProperty(this, "F", { + enumerable: false, + configurable: false, + get: function () { + return _F; + }, + set: function (value: number) { + if (!isNaN(value)) { + _F = value; + } else { + throw new Error( + 'Invalid value "' + value + '" for attribute F supplied.' + ); + } } - } - }); + }); - /** - * (PDF 1.2) If set, print the annotation when the page is printed. If clear, never print the annotation, regardless of wether is is displayed on the screen. - * NOTE 2 This can be useful for annotations representing interactive pushbuttons, which would serve no meaningful purpose on the printed page. - * - * @name AcroFormField#showWhenPrinted - * @default true - * @type {boolean} - */ - Object.defineProperty(this, "showWhenPrinted", { - enumerable: true, - configurable: true, - get: function() { - return Boolean(getBitForPdf(_F, 3)); - }, - set: function(value) { - if (Boolean(value) === true) { - this.F = setBitForPdf(_F, 3); - } else { - this.F = clearBitForPdf(_F, 3); - } - } - }); - - var _Ff = 0; - Object.defineProperty(this, "Ff", { - enumerable: false, - configurable: false, - get: function() { - return _Ff; - }, - set: function(value) { - if (!isNaN(value)) { - _Ff = value; - } else { - throw new Error( - 'Invalid value "' + value + '" for attribute Ff supplied.' - ); - } - } - }); - - var _Rect = []; - Object.defineProperty(this, "Rect", { - enumerable: false, - configurable: false, - get: function() { - if (_Rect.length === 0) { - return undefined; - } - return _Rect; - }, - set: function(value) { - if (typeof value !== "undefined") { - _Rect = value; - } else { - _Rect = []; + /** + * (PDF 1.2) If set, print the annotation when the page is printed. If clear, never print the annotation, regardless of wether is is displayed on the screen. + * NOTE 2 This can be useful for annotations representing interactive pushbuttons, which would serve no meaningful purpose on the printed page. + * + * @name AcroFormField#showWhenPrinted + * @default true + * @type {boolean} + */ + Object.defineProperty(this, "showWhenPrinted", { + enumerable: true, + configurable: true, + get: function () { + return Boolean(getBitForPdf(_F, 3)); + }, + set: function (this: AcroFormField, value: boolean) { + if (Boolean(value) === true) { + this.F = setBitForPdf(_F, 3); + } else { + this.F = clearBitForPdf(_F, 3); + } } - } - }); - - /** - * The x-position of the field. - * - * @name AcroFormField#x - * @default null - * @type {number} - */ - Object.defineProperty(this, "x", { - enumerable: true, - configurable: true, - get: function() { - if (!_Rect || isNaN(_Rect[0])) { - return 0; - } - return _Rect[0]; - }, - set: function(value) { - _Rect[0] = value; - } - }); - - /** - * The y-position of the field. - * - * @name AcroFormField#y - * @default null - * @type {number} - */ - Object.defineProperty(this, "y", { - enumerable: true, - configurable: true, - get: function() { - if (!_Rect || isNaN(_Rect[1])) { - return 0; - } - return _Rect[1]; - }, - set: function(value) { - _Rect[1] = value; - } - }); - - /** - * The width of the field. - * - * @name AcroFormField#width - * @default null - * @type {number} - */ - Object.defineProperty(this, "width", { - enumerable: true, - configurable: true, - get: function() { - if (!_Rect || isNaN(_Rect[2])) { - return 0; - } - return _Rect[2]; - }, - set: function(value) { - _Rect[2] = value; - } - }); + }); - /** - * The height of the field. - * - * @name AcroFormField#height - * @default null - * @type {number} - */ - Object.defineProperty(this, "height", { - enumerable: true, - configurable: true, - get: function() { - if (!_Rect || isNaN(_Rect[3])) { - return 0; - } - return _Rect[3]; - }, - set: function(value) { - _Rect[3] = value; - } - }); - - var _FT = ""; - Object.defineProperty(this, "FT", { - enumerable: true, - configurable: false, - get: function() { - return _FT; - }, - set: function(value) { - switch (value) { - case "/Btn": - case "/Tx": - case "/Ch": - case "/Sig": - _FT = value; - break; - default: + var _Ff = 0; + Object.defineProperty(this, "Ff", { + enumerable: false, + configurable: false, + get: function () { + return _Ff; + }, + set: function (value: number) { + if (!isNaN(value)) { + _Ff = value; + } else { throw new Error( - 'Invalid value "' + value + '" for attribute FT supplied.' + 'Invalid value "' + value + '" for attribute Ff supplied.' ); + } } - } - }); - - var _T = null; + }); - Object.defineProperty(this, "T", { - enumerable: true, - configurable: false, - get: function() { - if (!_T || _T.length < 1) { - // In case of a Child from a Radio´Group, you don't need a FieldName - if (this instanceof AcroFormChildClass) { + var _Rect: number[] = []; + Object.defineProperty(this, "Rect", { + enumerable: false, + configurable: false, + get: function () { + if (_Rect.length === 0) { return undefined; } - _T = "FieldObject" + AcroFormField.FieldNum++; + return _Rect; + }, + set: function (value: number[]) { + if (typeof value !== "undefined") { + _Rect = value; + } else { + _Rect = []; + } } - var encryptor = function(data) { - return data; - }; - if (this.scope) encryptor = this.scope.internal.getEncryptor(this.objId); - return "(" + pdfEscape(encryptor(_T)) + ")"; - }, - set: function(value) { - _T = value.toString(); - } - }); + }); - /** - * (Optional) The partial field name (see 12.7.3.2, “Field Names”). - * - * @name AcroFormField#fieldName - * @default null - * @type {string} - */ - Object.defineProperty(this, "fieldName", { - configurable: true, - enumerable: true, - get: function() { - return _T; - }, - set: function(value) { - _T = value; - } - }); + /** + * The x-position of the field. + * + * @name AcroFormField#x + * @default null + * @type {number} + */ + Object.defineProperty(this, "x", { + enumerable: true, + configurable: true, + get: function () { + if (!_Rect || isNaN(_Rect[0])) { + return 0; + } + return _Rect[0]; + }, + set: function (value: number) { + _Rect[0] = value; + } + }); - var _fontName = "helvetica"; - /** - * The fontName of the font to be used. - * - * @name AcroFormField#fontName - * @default 'helvetica' - * @type {string} - */ - Object.defineProperty(this, "fontName", { - enumerable: true, - configurable: true, - get: function() { - return _fontName; - }, - set: function(value) { - _fontName = value; - } - }); + /** + * The y-position of the field. + * + * @name AcroFormField#y + * @default null + * @type {number} + */ + Object.defineProperty(this, "y", { + enumerable: true, + configurable: true, + get: function () { + if (!_Rect || isNaN(_Rect[1])) { + return 0; + } + return _Rect[1]; + }, + set: function (value: number) { + _Rect[1] = value; + } + }); - var _fontStyle = "normal"; - /** - * The fontStyle of the font to be used. - * - * @name AcroFormField#fontStyle - * @default 'normal' - * @type {string} - */ - Object.defineProperty(this, "fontStyle", { - enumerable: true, - configurable: true, - get: function() { - return _fontStyle; - }, - set: function(value) { - _fontStyle = value; - } - }); + /** + * The width of the field. + * + * @name AcroFormField#width + * @default null + * @type {number} + */ + Object.defineProperty(this, "width", { + enumerable: true, + configurable: true, + get: function () { + if (!_Rect || isNaN(_Rect[2])) { + return 0; + } + return _Rect[2]; + }, + set: function (value: number) { + _Rect[2] = value; + } + }); - var _fontSize = 0; - /** - * The fontSize of the font to be used. - * - * @name AcroFormField#fontSize - * @default 0 (for auto) - * @type {number} - */ - Object.defineProperty(this, "fontSize", { - enumerable: true, - configurable: true, - get: function() { - return _fontSize; - }, - set: function(value) { - _fontSize = value; - } - }); + /** + * The height of the field. + * + * @name AcroFormField#height + * @default null + * @type {number} + */ + Object.defineProperty(this, "height", { + enumerable: true, + configurable: true, + get: function () { + if (!_Rect || isNaN(_Rect[3])) { + return 0; + } + return _Rect[3]; + }, + set: function (value: number) { + _Rect[3] = value; + } + }); - var _maxFontSize = undefined; - /** - * The maximum fontSize of the font to be used. - * - * @name AcroFormField#maxFontSize - * @default 0 (for auto) - * @type {number} - */ - Object.defineProperty(this, "maxFontSize", { - enumerable: true, - configurable: true, - get: function() { - if (_maxFontSize === undefined) { - // use the old default value here - the value is some kind of random as it depends on the scaleFactor (user unit) - // ("50" is transformed to the "user space" but then used in "pdf space") - return 50 / scaleFactor; - } else { - return _maxFontSize; + var _FT = ""; + Object.defineProperty(this, "FT", { + enumerable: true, + configurable: false, + get: function () { + return _FT; + }, + set: function (value: string) { + switch (value) { + case "/Btn": + case "/Tx": + case "/Ch": + case "/Sig": + _FT = value; + break; + default: + throw new Error( + 'Invalid value "' + value + '" for attribute FT supplied.' + ); + } } - }, - set: function(value) { - _maxFontSize = value; - } - }); + }); - var _color = "black"; - /** - * The color of the text - * - * @name AcroFormField#color - * @default 'black' - * @type {string|rgba} - */ - Object.defineProperty(this, "color", { - enumerable: true, - configurable: true, - get: function() { - return _color; - }, - set: function(value) { - _color = value; - } - }); - - var _DA = "/F1 0 Tf 0 g"; - // Defines the default appearance (Needed for variable Text) - Object.defineProperty(this, "DA", { - enumerable: true, - configurable: false, - get: function() { - if ( - !_DA || - this instanceof AcroFormChildClass || - this instanceof AcroFormTextField - ) { - return undefined; + var _T: string = null; + + Object.defineProperty(this, "T", { + enumerable: true, + configurable: false, + get: function (this: AcroFormField) { + if (!_T || _T.length < 1) { + // In case of a Child from a Radio´Group, you don't need a FieldName + if (this instanceof AcroFormChildClass) { + return undefined; + } + _T = "FieldObject" + AcroFormField.FieldNum++; + } + var encryptor: Encryptor = function (data) { + return data; + }; + if (this.scope) + encryptor = this.scope.internal.getEncryptor(this.objId); + return "(" + pdfEscape(encryptor(_T)) + ")"; + }, + set: function (value: string) { + _T = value.toString(); } - return toPdfString(_DA, this.objId, this.scope); - }, - set: function(value) { - value = value.toString(); - _DA = value; - } - }); - - var _DV = null; - Object.defineProperty(this, "DV", { - enumerable: false, - configurable: false, - get: function() { - if (!_DV) { - return undefined; + }); + + /** + * (Optional) The partial field name (see 12.7.3.2, “Field Names”). + * + * @name AcroFormField#fieldName + * @default null + * @type {string} + */ + Object.defineProperty(this, "fieldName", { + configurable: true, + enumerable: true, + get: function () { + return _T; + }, + set: function (value: string) { + _T = value; } - if (this instanceof AcroFormButton === false) { - return toPdfString(_DV, this.objId, this.scope); + }); + + var _fontName = "helvetica"; + /** + * The fontName of the font to be used. + * + * @name AcroFormField#fontName + * @default 'helvetica' + * @type {string} + */ + Object.defineProperty(this, "fontName", { + enumerable: true, + configurable: true, + get: function () { + return _fontName; + }, + set: function (value: string) { + _fontName = value; } - return _DV; - }, - set: function(value) { - value = value.toString(); - if (this instanceof AcroFormButton === false) { - if (value.substr(0, 1) === "(") { - _DV = pdfUnescape(value.substr(1, value.length - 2)); - } else { - _DV = pdfUnescape(value); - } - } else { - _DV = value; + }); + + var _fontStyle = "normal"; + /** + * The fontStyle of the font to be used. + * + * @name AcroFormField#fontStyle + * @default 'normal' + * @type {string} + */ + Object.defineProperty(this, "fontStyle", { + enumerable: true, + configurable: true, + get: function () { + return _fontStyle; + }, + set: function (value: string) { + _fontStyle = value; } - } - }); + }); - /** - * (Optional; inheritable) The default value to which the field reverts when a reset-form action is executed (see 12.7.5.3, “Reset-Form Action”). The format of this value is the same as that of value. - * - * @name AcroFormField#defaultValue - * @default null - * @type {any} - */ - Object.defineProperty(this, "defaultValue", { - enumerable: true, - configurable: true, - get: function() { - if (this instanceof AcroFormButton === true) { - return pdfUnescape(_DV.substr(1, _DV.length - 1)); - } else { - return _DV; + var _fontSize = 0; + /** + * The fontSize of the font to be used. + * + * @name AcroFormField#fontSize + * @default 0 (for auto) + * @type {number} + */ + Object.defineProperty(this, "fontSize", { + enumerable: true, + configurable: true, + get: function () { + return _fontSize; + }, + set: function (value: number) { + _fontSize = value; } - }, - set: function(value) { - value = value.toString(); - if (this instanceof AcroFormButton === true) { - _DV = "/" + pdfEscapeName(value); - } else { - _DV = value; + }); + + var _maxFontSize: number = undefined; + /** + * The maximum fontSize of the font to be used. + * + * @name AcroFormField#maxFontSize + * @default 0 (for auto) + * @type {number} + */ + Object.defineProperty(this, "maxFontSize", { + enumerable: true, + configurable: true, + get: function () { + if (_maxFontSize === undefined) { + // use the old default value here - the value is some kind of random as it depends on the scaleFactor (user unit) + // ("50" is transformed to the "user space" but then used in "pdf space") + return 50 / scaleFactor; + } else { + return _maxFontSize; + } + }, + set: function (value: number) { + _maxFontSize = value; } - } - }); - - var _V = null; - Object.defineProperty(this, "_V", { - enumerable: false, - configurable: false, - get: function() { - if (!_V) { - return undefined; + }); + + var _color = "black"; + /** + * The color of the text + * + * @name AcroFormField#color + * @default 'black' + * @type {string|rgba} + */ + Object.defineProperty(this, "color", { + enumerable: true, + configurable: true, + get: function () { + return _color; + }, + set: function (value: string) { + _color = value; } - return _V; - }, - set: function(value) { - this.V = value; - } - }); - Object.defineProperty(this, "V", { - enumerable: false, - configurable: false, - get: function() { - if (!_V) { - return undefined; + }); + + var _DA = "/F1 0 Tf 0 g"; + // Defines the default appearance (Needed for variable Text) + Object.defineProperty(this, "DA", { + enumerable: true, + configurable: false, + get: function (this: AcroFormField) { + if ( + !_DA || + this instanceof AcroFormChildClass || + this instanceof AcroFormTextField + ) { + return undefined; + } + return toPdfString(_DA, this.objId, this.scope); + }, + set: function (value: string) { + value = value.toString(); + _DA = value; } - if (this instanceof AcroFormButton === false) { - return toPdfString(_V, this.objId, this.scope); + }); + + var _DV: string = null; + Object.defineProperty(this, "DV", { + enumerable: false, + configurable: false, + get: function (this: AcroFormField) { + if (!_DV) { + return undefined; + } + if (this instanceof AcroFormButton === false) { + return toPdfString(_DV, this.objId, this.scope); + } + return _DV; + }, + set: function (this: AcroFormField, value: string) { + value = value.toString(); + if (this instanceof AcroFormButton === false) { + if (value.substr(0, 1) === "(") { + _DV = pdfUnescape(value.substr(1, value.length - 2)); + } else { + _DV = pdfUnescape(value); + } + } else { + _DV = value; + } } - return _V; - }, - set: function(value) { - value = value.toString(); - if (this instanceof AcroFormButton === false) { - if (value.substr(0, 1) === "(") { - _V = pdfUnescape(value.substr(1, value.length - 2)); + }); + + /** + * (Optional; inheritable) The default value to which the field reverts when a reset-form action is executed (see 12.7.5.3, “Reset-Form Action”). The format of this value is the same as that of value. + * + * @name AcroFormField#defaultValue + * @default null + * @type {any} + */ + Object.defineProperty(this, "defaultValue", { + enumerable: true, + configurable: true, + get: function (this: AcroFormField) { + if (this instanceof AcroFormButton === true) { + return pdfUnescape(_DV.substr(1, _DV.length - 1)); } else { - _V = pdfUnescape(value); + return _DV; + } + }, + set: function (this: AcroFormField, value: string) { + value = value.toString(); + if (this instanceof AcroFormButton === true) { + _DV = "/" + pdfEscapeName(value); + } else { + _DV = value; } - } else { - _V = value; } - } - }); + }); - /** - * (Optional; inheritable) The field’s value, whose format varies depending on the field type. See the descriptions of individual field types for further information. - * - * @name AcroFormField#value - * @default null - * @type {any} - */ - Object.defineProperty(this, "value", { - enumerable: true, - configurable: true, - get: function() { - if (this instanceof AcroFormButton === true) { - return pdfUnescape(_V.substr(1, _V.length - 1)); - } else { + var _V: string = null; + Object.defineProperty(this, "_V", { + enumerable: false, + configurable: false, + get: function () { + if (!_V) { + return undefined; + } return _V; + }, + set: function (this: AcroFormField, value: string) { + this.V = value; } - }, - set: function(value) { - value = value.toString(); - if (this instanceof AcroFormButton === true) { - _V = "/" + pdfEscapeName(value); - } else { - _V = value; + }); + Object.defineProperty(this, "V", { + enumerable: false, + configurable: false, + get: function (this: AcroFormField) { + if (!_V) { + return undefined; + } + if (this instanceof AcroFormButton === false) { + return toPdfString(_V, this.objId, this.scope); + } + return _V; + }, + set: function (this: AcroFormField, value: string) { + value = value.toString(); + if (this instanceof AcroFormButton === false) { + if (value.substr(0, 1) === "(") { + _V = pdfUnescape(value.substr(1, value.length - 2)); + } else { + _V = pdfUnescape(value); + } + } else { + _V = value; + } } - } - }); - - /** - * Check if field has annotations - * - * @name AcroFormField#hasAnnotation - * @readonly - * @type {boolean} - */ - Object.defineProperty(this, "hasAnnotation", { - enumerable: true, - configurable: true, - get: function() { - return this.Rect; - } - }); + }); - Object.defineProperty(this, "Type", { - enumerable: true, - configurable: false, - get: function() { - return this.hasAnnotation ? "/Annot" : null; - } - }); + /** + * (Optional; inheritable) The field’s value, whose format varies depending on the field type. See the descriptions of individual field types for further information. + * + * @name AcroFormField#value + * @default null + * @type {any} + */ + Object.defineProperty(this, "value", { + enumerable: true, + configurable: true, + get: function (this: AcroFormField) { + if (this instanceof AcroFormButton === true) { + return pdfUnescape(_V.substr(1, _V.length - 1)); + } else { + return _V; + } + }, + set: function (this: AcroFormField, value: string) { + value = value.toString(); + if (this instanceof AcroFormButton === true) { + _V = "/" + pdfEscapeName(value); + } else { + _V = value; + } + } + }); - Object.defineProperty(this, "Subtype", { - enumerable: true, - configurable: false, - get: function() { - return this.hasAnnotation ? "/Widget" : null; - } - }); + /** + * Check if field has annotations + * + * @name AcroFormField#hasAnnotation + * @readonly + * @type {boolean} + */ + Object.defineProperty(this, "hasAnnotation", { + enumerable: true, + configurable: true, + get: function (this: AcroFormField) { + return this.Rect; + } + }); - var _hasAppearanceStream = false; - /** - * true if field has an appearanceStream - * - * @name AcroFormField#hasAppearanceStream - * @readonly - * @type {boolean} - */ - Object.defineProperty(this, "hasAppearanceStream", { - enumerable: true, - configurable: true, - get: function() { - return _hasAppearanceStream; - }, - set: function(value) { - value = Boolean(value); - _hasAppearanceStream = value; - } - }); + Object.defineProperty(this, "Type", { + enumerable: true, + configurable: false, + get: function (this: AcroFormField) { + return this.hasAnnotation ? "/Annot" : null; + } + }); - /** - * The page on which the AcroFormField is placed - * - * @name AcroFormField#page - * @type {number} - */ - var _page; - Object.defineProperty(this, "page", { - enumerable: true, - configurable: true, - get: function() { - if (!_page) { - return undefined; + Object.defineProperty(this, "Subtype", { + enumerable: true, + configurable: false, + get: function (this: AcroFormField) { + return this.hasAnnotation ? "/Widget" : null; } - return _page; - }, - set: function(value) { - _page = value; - } - }); + }); - /** - * If set, the user may not change the value of the field. Any associated widget annotations will not interact with the user; that is, they will not respond to mouse clicks or change their appearance in response to mouse motions. This flag is useful for fields whose values are computed or imported from a database. - * - * @name AcroFormField#readOnly - * @default false - * @type {boolean} - */ - Object.defineProperty(this, "readOnly", { - enumerable: true, - configurable: true, - get: function() { - return Boolean(getBitForPdf(this.Ff, 1)); - }, - set: function(value) { - if (Boolean(value) === true) { - this.Ff = setBitForPdf(this.Ff, 1); - } else { - this.Ff = clearBitForPdf(this.Ff, 1); + var _hasAppearanceStream = false; + /** + * true if field has an appearanceStream + * + * @name AcroFormField#hasAppearanceStream + * @readonly + * @type {boolean} + */ + Object.defineProperty(this, "hasAppearanceStream", { + enumerable: true, + configurable: true, + get: function () { + return _hasAppearanceStream; + }, + set: function (value: boolean) { + value = Boolean(value); + _hasAppearanceStream = value; } - } - }); + }); - /** - * If set, the field shall have a value at the time it is exported by a submitform action (see 12.7.5.2, “Submit-Form Action”). - * - * @name AcroFormField#required - * @default false - * @type {boolean} - */ - Object.defineProperty(this, "required", { - enumerable: true, - configurable: true, - get: function() { - return Boolean(getBitForPdf(this.Ff, 2)); - }, - set: function(value) { - if (Boolean(value) === true) { - this.Ff = setBitForPdf(this.Ff, 2); - } else { - this.Ff = clearBitForPdf(this.Ff, 2); + /** + * The page on which the AcroFormField is placed + * + * @name AcroFormField#page + * @type {number} + */ + var _page: number; + Object.defineProperty(this, "page", { + enumerable: true, + configurable: true, + get: function () { + if (!_page) { + return undefined; + } + return _page; + }, + set: function (value: number) { + _page = value; } - } - }); + }); - /** - * If set, the field shall not be exported by a submit-form action (see 12.7.5.2, “Submit-Form Action”) - * - * @name AcroFormField#noExport - * @default false - * @type {boolean} - */ - Object.defineProperty(this, "noExport", { - enumerable: true, - configurable: true, - get: function() { - return Boolean(getBitForPdf(this.Ff, 3)); - }, - set: function(value) { - if (Boolean(value) === true) { - this.Ff = setBitForPdf(this.Ff, 3); - } else { - this.Ff = clearBitForPdf(this.Ff, 3); + /** + * If set, the user may not change the value of the field. Any associated widget annotations will not interact with the user; that is, they will not respond to mouse clicks or change their appearance in response to mouse motions. This flag is useful for fields whose values are computed or imported from a database. + * + * @name AcroFormField#readOnly + * @default false + * @type {boolean} + */ + Object.defineProperty(this, "readOnly", { + enumerable: true, + configurable: true, + get: function (this: AcroFormField) { + return Boolean(getBitForPdf(this.Ff, 1)); + }, + set: function (this: AcroFormField, value: boolean) { + if (Boolean(value) === true) { + this.Ff = setBitForPdf(this.Ff, 1); + } else { + this.Ff = clearBitForPdf(this.Ff, 1); + } } - } - }); - - var _Q = null; - Object.defineProperty(this, "Q", { - enumerable: true, - configurable: false, - get: function() { - if (_Q === null) { - return undefined; + }); + + /** + * If set, the field shall have a value at the time it is exported by a submitform action (see 12.7.5.2, “Submit-Form Action”). + * + * @name AcroFormField#required + * @default false + * @type {boolean} + */ + Object.defineProperty(this, "required", { + enumerable: true, + configurable: true, + get: function (this: AcroFormField) { + return Boolean(getBitForPdf(this.Ff, 2)); + }, + set: function (this: AcroFormField, value: boolean) { + if (Boolean(value) === true) { + this.Ff = setBitForPdf(this.Ff, 2); + } else { + this.Ff = clearBitForPdf(this.Ff, 2); + } } - return _Q; - }, - set: function(value) { - if ([0, 1, 2].indexOf(value) !== -1) { - _Q = value; - } else { - throw new Error( - 'Invalid value "' + value + '" for attribute Q supplied.' - ); + }); + + /** + * If set, the field shall not be exported by a submit-form action (see 12.7.5.2, “Submit-Form Action”) + * + * @name AcroFormField#noExport + * @default false + * @type {boolean} + */ + Object.defineProperty(this, "noExport", { + enumerable: true, + configurable: true, + get: function (this: AcroFormField) { + return Boolean(getBitForPdf(this.Ff, 3)); + }, + set: function (this: AcroFormField, value: boolean) { + if (Boolean(value) === true) { + this.Ff = setBitForPdf(this.Ff, 3); + } else { + this.Ff = clearBitForPdf(this.Ff, 3); + } } - } - }); + }); - /** - * (Optional; inheritable) A code specifying the form of quadding (justification) that shall be used in displaying the text: - * 'left', 'center', 'right' - * - * @name AcroFormField#textAlign - * @default 'left' - * @type {string} - */ - Object.defineProperty(this, "textAlign", { - get: function() { - var result; - switch (_Q) { - case 0: - default: - result = "left"; - break; - case 1: - result = "center"; - break; - case 2: - result = "right"; - break; + var _Q: number = null; + Object.defineProperty(this, "Q", { + enumerable: true, + configurable: false, + get: function () { + if (_Q === null) { + return undefined; + } + return _Q; + }, + set: function (value: number) { + if ([0, 1, 2].indexOf(value) !== -1) { + _Q = value; + } else { + throw new Error( + 'Invalid value "' + value + '" for attribute Q supplied.' + ); + } } - return result; - }, - configurable: true, - enumerable: true, - set: function(value) { - switch (value) { - case "right": - case 2: - _Q = 2; - break; - case "center": - case 1: - _Q = 1; - break; - case "left": - case 0: - default: - _Q = 0; + }); + + /** + * (Optional; inheritable) A code specifying the form of quadding (justification) that shall be used in displaying the text: + * 'left', 'center', 'right' + * + * @name AcroFormField#textAlign + * @default 'left' + * @type {string} + */ + Object.defineProperty(this, "textAlign", { + get: function () { + var result; + switch (_Q) { + case 0: + default: + result = "left"; + break; + case 1: + result = "center"; + break; + case 2: + result = "right"; + break; + } + return result; + }, + configurable: true, + enumerable: true, + set: function (value: string | number) { + switch (value) { + case "right": + case 2: + _Q = 2; + break; + case "center": + case 1: + _Q = 1; + break; + case "left": + case 0: + default: + _Q = 0; + } } - } - }); -}; + }); + } +} -inherit(AcroFormField, AcroFormPDFObject); +// Static counter, assigned outside the class body (a bare `static x = 0` +// field would require babel's class-properties transform, which this build +// deliberately omits). +AcroFormField.FieldNum = 0; /** * @class AcroFormChoiceField * @extends AcroFormField */ -var AcroFormChoiceField = function() { - AcroFormField.call(this); - // Field Type = Choice Field - this.FT = "/Ch"; - // options - this.V = "()"; - - this.fontName = "zapfdingbats"; - // Top Index - var _TI = 0; - - Object.defineProperty(this, "TI", { - enumerable: true, - configurable: false, - get: function() { - return _TI; - }, - set: function(value) { - _TI = value; - } - }); - - /** - * (Optional) For scrollable list boxes, the top index (the index in the Opt array of the first option visible in the list). Default value: 0. - * - * @name AcroFormChoiceField#topIndex - * @default 0 - * @type {number} - */ - Object.defineProperty(this, "topIndex", { - enumerable: true, - configurable: true, - get: function() { - return _TI; - }, - set: function(value) { - _TI = value; - } - }); - - var _Opt = []; - Object.defineProperty(this, "Opt", { - enumerable: true, - configurable: false, - get: function() { - return arrayToPdfArray(_Opt, this.objId, this.scope); - }, - set: function(value) { - _Opt = pdfArrayToStringArray(value); - } - }); +class AcroFormChoiceField extends AcroFormField { + declare TI: number; + declare topIndex: number; + declare Opt: string; + declare getOptions: (this: AcroFormChoiceField) => string[]; + declare setOptions: (this: AcroFormChoiceField, value: string[]) => void; + declare addOption: (this: AcroFormChoiceField, value: string) => void; + declare removeOption: ( + this: AcroFormChoiceField, + value: string, + allEntries?: boolean + ) => void; + declare combo: boolean; + declare edit: boolean; + declare sort: boolean; + declare multiSelect: boolean; + declare doNotSpellCheck: boolean; + declare commitOnSelChange: boolean; + + constructor() { + super(); + // Field Type = Choice Field + this.FT = "/Ch"; + // options + this.V = "()"; + + this.fontName = "zapfdingbats"; + // Top Index + var _TI = 0; + + Object.defineProperty(this, "TI", { + enumerable: true, + configurable: false, + get: function () { + return _TI; + }, + set: function (value: number) { + _TI = value; + } + }); - /** - * @memberof AcroFormChoiceField - * @name getOptions - * @function - * @instance - * @returns {array} array of Options - */ - this.getOptions = function() { - return _Opt; - }; + /** + * (Optional) For scrollable list boxes, the top index (the index in the Opt array of the first option visible in the list). Default value: 0. + * + * @name AcroFormChoiceField#topIndex + * @default 0 + * @type {number} + */ + Object.defineProperty(this, "topIndex", { + enumerable: true, + configurable: true, + get: function () { + return _TI; + }, + set: function (value: number) { + _TI = value; + } + }); - /** - * @memberof AcroFormChoiceField - * @name setOptions - * @function - * @instance - * @param {array} value - */ - this.setOptions = function(value) { - _Opt = value; - if (this.sort) { - _Opt.sort(); - } - }; + var _Opt: string[] = []; + Object.defineProperty(this, "Opt", { + enumerable: true, + configurable: false, + get: function (this: AcroFormChoiceField) { + return arrayToPdfArray(_Opt, this.objId, this.scope); + }, + set: function (value: string) { + _Opt = pdfArrayToStringArray(value); + } + }); - /** - * @memberof AcroFormChoiceField - * @name addOption - * @function - * @instance - * @param {string} value - */ - this.addOption = function(value) { - value = value || ""; - value = value.toString(); - _Opt.push(value); - if (this.sort) { - _Opt.sort(); - } - }; + /** + * @memberof AcroFormChoiceField + * @name getOptions + * @function + * @instance + * @returns {array} array of Options + */ + this.getOptions = function () { + return _Opt; + }; - /** - * @memberof AcroFormChoiceField - * @name removeOption - * @function - * @instance - * @param {string} value - * @param {boolean} allEntries (default: false) - */ - this.removeOption = function(value, allEntries) { - allEntries = allEntries || false; - value = value || ""; - value = value.toString(); + /** + * @memberof AcroFormChoiceField + * @name setOptions + * @function + * @instance + * @param {array} value + */ + this.setOptions = function (this: AcroFormChoiceField, value: string[]) { + _Opt = value; + if (this.sort) { + _Opt.sort(); + } + }; - while (_Opt.indexOf(value) !== -1) { - _Opt.splice(_Opt.indexOf(value), 1); - if (allEntries === false) { - break; + /** + * @memberof AcroFormChoiceField + * @name addOption + * @function + * @instance + * @param {string} value + */ + this.addOption = function (this: AcroFormChoiceField, value: string) { + value = value || ""; + value = value.toString(); + _Opt.push(value); + if (this.sort) { + _Opt.sort(); } - } - }; + }; - /** - * If set, the field is a combo box; if clear, the field is a list box. - * - * @name AcroFormChoiceField#combo - * @default false - * @type {boolean} - */ - Object.defineProperty(this, "combo", { - enumerable: true, - configurable: true, - get: function() { - return Boolean(getBitForPdf(this.Ff, 18)); - }, - set: function(value) { - if (Boolean(value) === true) { - this.Ff = setBitForPdf(this.Ff, 18); - } else { - this.Ff = clearBitForPdf(this.Ff, 18); + /** + * @memberof AcroFormChoiceField + * @name removeOption + * @function + * @instance + * @param {string} value + * @param {boolean} allEntries (default: false) + */ + this.removeOption = function (value: string, allEntries?: boolean) { + allEntries = allEntries || false; + value = value || ""; + value = value.toString(); + + while (_Opt.indexOf(value) !== -1) { + _Opt.splice(_Opt.indexOf(value), 1); + if (allEntries === false) { + break; + } } - } - }); + }; - /** - * If set, the combo box shall include an editable text box as well as a drop-down list; if clear, it shall include only a drop-down list. This flag shall be used only if the Combo flag is set. - * - * @name AcroFormChoiceField#edit - * @default false - * @type {boolean} - */ - Object.defineProperty(this, "edit", { - enumerable: true, - configurable: true, - get: function() { - return Boolean(getBitForPdf(this.Ff, 19)); - }, - set: function(value) { - //PDF 32000-1:2008, page 444 - if (this.combo === true) { + /** + * If set, the field is a combo box; if clear, the field is a list box. + * + * @name AcroFormChoiceField#combo + * @default false + * @type {boolean} + */ + Object.defineProperty(this, "combo", { + enumerable: true, + configurable: true, + get: function (this: AcroFormChoiceField) { + return Boolean(getBitForPdf(this.Ff, 18)); + }, + set: function (this: AcroFormChoiceField, value: boolean) { if (Boolean(value) === true) { - this.Ff = setBitForPdf(this.Ff, 19); + this.Ff = setBitForPdf(this.Ff, 18); } else { - this.Ff = clearBitForPdf(this.Ff, 19); + this.Ff = clearBitForPdf(this.Ff, 18); } } - } - }); + }); - /** - * If set, the field’s option items shall be sorted alphabetically. This flag is intended for use by writers, not by readers. Conforming readers shall display the options in the order in which they occur in the Opt array (see Table 231). - * - * @name AcroFormChoiceField#sort - * @default false - * @type {boolean} - */ - Object.defineProperty(this, "sort", { - enumerable: true, - configurable: true, - get: function() { - return Boolean(getBitForPdf(this.Ff, 20)); - }, - set: function(value) { - if (Boolean(value) === true) { - this.Ff = setBitForPdf(this.Ff, 20); - _Opt.sort(); - } else { - this.Ff = clearBitForPdf(this.Ff, 20); + /** + * If set, the combo box shall include an editable text box as well as a drop-down list; if clear, it shall include only a drop-down list. This flag shall be used only if the Combo flag is set. + * + * @name AcroFormChoiceField#edit + * @default false + * @type {boolean} + */ + Object.defineProperty(this, "edit", { + enumerable: true, + configurable: true, + get: function (this: AcroFormChoiceField) { + return Boolean(getBitForPdf(this.Ff, 19)); + }, + set: function (this: AcroFormChoiceField, value: boolean) { + //PDF 32000-1:2008, page 444 + if (this.combo === true) { + if (Boolean(value) === true) { + this.Ff = setBitForPdf(this.Ff, 19); + } else { + this.Ff = clearBitForPdf(this.Ff, 19); + } + } } - } - }); + }); - /** - * (PDF 1.4) If set, more than one of the field’s option items may be selected simultaneously; if clear, at most one item shall be selected - * - * @name AcroFormChoiceField#multiSelect - * @default false - * @type {boolean} - */ - Object.defineProperty(this, "multiSelect", { - enumerable: true, - configurable: true, - get: function() { - return Boolean(getBitForPdf(this.Ff, 22)); - }, - set: function(value) { - if (Boolean(value) === true) { - this.Ff = setBitForPdf(this.Ff, 22); - } else { - this.Ff = clearBitForPdf(this.Ff, 22); + /** + * If set, the field’s option items shall be sorted alphabetically. This flag is intended for use by writers, not by readers. Conforming readers shall display the options in the order in which they occur in the Opt array (see Table 231). + * + * @name AcroFormChoiceField#sort + * @default false + * @type {boolean} + */ + Object.defineProperty(this, "sort", { + enumerable: true, + configurable: true, + get: function (this: AcroFormChoiceField) { + return Boolean(getBitForPdf(this.Ff, 20)); + }, + set: function (this: AcroFormChoiceField, value: boolean) { + if (Boolean(value) === true) { + this.Ff = setBitForPdf(this.Ff, 20); + _Opt.sort(); + } else { + this.Ff = clearBitForPdf(this.Ff, 20); + } } - } - }); + }); - /** - * (PDF 1.4) If set, text entered in the field shall not be spellchecked. This flag shall not be used unless the Combo and Edit flags are both set. - * - * @name AcroFormChoiceField#doNotSpellCheck - * @default false - * @type {boolean} - */ - Object.defineProperty(this, "doNotSpellCheck", { - enumerable: true, - configurable: true, - get: function() { - return Boolean(getBitForPdf(this.Ff, 23)); - }, - set: function(value) { - if (Boolean(value) === true) { - this.Ff = setBitForPdf(this.Ff, 23); - } else { - this.Ff = clearBitForPdf(this.Ff, 23); + /** + * (PDF 1.4) If set, more than one of the field’s option items may be selected simultaneously; if clear, at most one item shall be selected + * + * @name AcroFormChoiceField#multiSelect + * @default false + * @type {boolean} + */ + Object.defineProperty(this, "multiSelect", { + enumerable: true, + configurable: true, + get: function (this: AcroFormChoiceField) { + return Boolean(getBitForPdf(this.Ff, 22)); + }, + set: function (this: AcroFormChoiceField, value: boolean) { + if (Boolean(value) === true) { + this.Ff = setBitForPdf(this.Ff, 22); + } else { + this.Ff = clearBitForPdf(this.Ff, 22); + } } - } - }); + }); - /** - * (PDF 1.5) If set, the new value shall be committed as soon as a selection is made (commonly with the pointing device). In this case, supplying a value for a field involves three actions: selecting the field for fill-in, selecting a choice for the fill-in value, and leaving that field, which finalizes or “commits” the data choice and triggers any actions associated with the entry or changing of this data. If this flag is on, then processing does not wait for leaving the field action to occur, but immediately proceeds to the third step. - * This option enables applications to perform an action once a selection is made, without requiring the user to exit the field. If clear, the new value is not committed until the user exits the field. - * - * @name AcroFormChoiceField#commitOnSelChange - * @default false - * @type {boolean} - */ - Object.defineProperty(this, "commitOnSelChange", { - enumerable: true, - configurable: true, - get: function() { - return Boolean(getBitForPdf(this.Ff, 27)); - }, - set: function(value) { - if (Boolean(value) === true) { - this.Ff = setBitForPdf(this.Ff, 27); - } else { - this.Ff = clearBitForPdf(this.Ff, 27); + /** + * (PDF 1.4) If set, text entered in the field shall not be spellchecked. This flag shall not be used unless the Combo and Edit flags are both set. + * + * @name AcroFormChoiceField#doNotSpellCheck + * @default false + * @type {boolean} + */ + Object.defineProperty(this, "doNotSpellCheck", { + enumerable: true, + configurable: true, + get: function (this: AcroFormChoiceField) { + return Boolean(getBitForPdf(this.Ff, 23)); + }, + set: function (this: AcroFormChoiceField, value: boolean) { + if (Boolean(value) === true) { + this.Ff = setBitForPdf(this.Ff, 23); + } else { + this.Ff = clearBitForPdf(this.Ff, 23); + } } - } - }); + }); - this.hasAppearanceStream = false; -}; -inherit(AcroFormChoiceField, AcroFormField); + /** + * (PDF 1.5) If set, the new value shall be committed as soon as a selection is made (commonly with the pointing device). In this case, supplying a value for a field involves three actions: selecting the field for fill-in, selecting a choice for the fill-in value, and leaving that field, which finalizes or “commits” the data choice and triggers any actions associated with the entry or changing of this data. If this flag is on, then processing does not wait for leaving the field action to occur, but immediately proceeds to the third step. + * This option enables applications to perform an action once a selection is made, without requiring the user to exit the field. If clear, the new value is not committed until the user exits the field. + * + * @name AcroFormChoiceField#commitOnSelChange + * @default false + * @type {boolean} + */ + Object.defineProperty(this, "commitOnSelChange", { + enumerable: true, + configurable: true, + get: function (this: AcroFormChoiceField) { + return Boolean(getBitForPdf(this.Ff, 27)); + }, + set: function (this: AcroFormChoiceField, value: boolean) { + if (Boolean(value) === true) { + this.Ff = setBitForPdf(this.Ff, 27); + } else { + this.Ff = clearBitForPdf(this.Ff, 27); + } + } + }); + + this.hasAppearanceStream = false; + } +} /** * @class AcroFormListBox * @extends AcroFormChoiceField * @extends AcroFormField */ -var AcroFormListBox = function() { - AcroFormChoiceField.call(this); - this.fontName = "helvetica"; +class AcroFormListBox extends AcroFormChoiceField { + constructor() { + super(); + this.fontName = "helvetica"; - //PDF 32000-1:2008, page 444 - this.combo = false; -}; -inherit(AcroFormListBox, AcroFormChoiceField); + //PDF 32000-1:2008, page 444 + this.combo = false; + } +} /** * @class AcroFormComboBox @@ -1972,11 +2244,12 @@ inherit(AcroFormListBox, AcroFormChoiceField); * @extends AcroFormChoiceField * @extends AcroFormField */ -var AcroFormComboBox = function() { - AcroFormListBox.call(this); - this.combo = true; -}; -inherit(AcroFormComboBox, AcroFormListBox); +class AcroFormComboBox extends AcroFormListBox { + constructor() { + super(); + this.combo = true; + } +} /** * @class AcroFormEditBox @@ -1985,229 +2258,278 @@ inherit(AcroFormComboBox, AcroFormListBox); * @extends AcroFormChoiceField * @extends AcroFormField */ -var AcroFormEditBox = function() { - AcroFormComboBox.call(this); - this.edit = true; -}; -inherit(AcroFormEditBox, AcroFormComboBox); +class AcroFormEditBox extends AcroFormComboBox { + constructor() { + super(); + this.edit = true; + } +} /** * @class AcroFormButton * @extends AcroFormField */ -var AcroFormButton = function() { - AcroFormField.call(this); - this.FT = "/Btn"; +class AcroFormButton extends AcroFormField { + declare noToggleToOff: boolean; + declare radio: boolean; + declare pushButton: boolean; + declare radioIsUnison: boolean; + declare MK: Record | string; + declare caption: string; + declare AS: string; + declare appearanceState: string; + + constructor() { + super(); + this.FT = "/Btn"; - /** - * (Radio buttons only) If set, exactly one radio button shall be selected at all times; selecting the currently selected button has no effect. If clear, clicking the selected button deselects it, leaving no button selected. - * - * @name AcroFormButton#noToggleToOff - * @type {boolean} - */ - Object.defineProperty(this, "noToggleToOff", { - enumerable: true, - configurable: true, - get: function() { - return Boolean(getBitForPdf(this.Ff, 15)); - }, - set: function(value) { - if (Boolean(value) === true) { - this.Ff = setBitForPdf(this.Ff, 15); - } else { - this.Ff = clearBitForPdf(this.Ff, 15); + /** + * (Radio buttons only) If set, exactly one radio button shall be selected at all times; selecting the currently selected button has no effect. If clear, clicking the selected button deselects it, leaving no button selected. + * + * @name AcroFormButton#noToggleToOff + * @type {boolean} + */ + Object.defineProperty(this, "noToggleToOff", { + enumerable: true, + configurable: true, + get: function (this: AcroFormButton) { + return Boolean(getBitForPdf(this.Ff, 15)); + }, + set: function (this: AcroFormButton, value: boolean) { + if (Boolean(value) === true) { + this.Ff = setBitForPdf(this.Ff, 15); + } else { + this.Ff = clearBitForPdf(this.Ff, 15); + } } - } - }); + }); - /** - * If set, the field is a set of radio buttons; if clear, the field is a checkbox. This flag may be set only if the Pushbutton flag is clear. - * - * @name AcroFormButton#radio - * @type {boolean} - */ - Object.defineProperty(this, "radio", { - enumerable: true, - configurable: true, - get: function() { - return Boolean(getBitForPdf(this.Ff, 16)); - }, - set: function(value) { - if (Boolean(value) === true) { - this.Ff = setBitForPdf(this.Ff, 16); - } else { - this.Ff = clearBitForPdf(this.Ff, 16); + /** + * If set, the field is a set of radio buttons; if clear, the field is a checkbox. This flag may be set only if the Pushbutton flag is clear. + * + * @name AcroFormButton#radio + * @type {boolean} + */ + Object.defineProperty(this, "radio", { + enumerable: true, + configurable: true, + get: function (this: AcroFormButton) { + return Boolean(getBitForPdf(this.Ff, 16)); + }, + set: function (this: AcroFormButton, value: boolean) { + if (Boolean(value) === true) { + this.Ff = setBitForPdf(this.Ff, 16); + } else { + this.Ff = clearBitForPdf(this.Ff, 16); + } } - } - }); + }); - /** - * If set, the field is a pushbutton that does not retain a permanent value. - * - * @name AcroFormButton#pushButton - * @type {boolean} - */ - Object.defineProperty(this, "pushButton", { - enumerable: true, - configurable: true, - get: function() { - return Boolean(getBitForPdf(this.Ff, 17)); - }, - set: function(value) { - if (Boolean(value) === true) { - this.Ff = setBitForPdf(this.Ff, 17); - } else { - this.Ff = clearBitForPdf(this.Ff, 17); + /** + * If set, the field is a pushbutton that does not retain a permanent value. + * + * @name AcroFormButton#pushButton + * @type {boolean} + */ + Object.defineProperty(this, "pushButton", { + enumerable: true, + configurable: true, + get: function (this: AcroFormButton) { + return Boolean(getBitForPdf(this.Ff, 17)); + }, + set: function (this: AcroFormButton, value: boolean) { + if (Boolean(value) === true) { + this.Ff = setBitForPdf(this.Ff, 17); + } else { + this.Ff = clearBitForPdf(this.Ff, 17); + } } - } - }); + }); - /** - * (PDF 1.5) If set, a group of radio buttons within a radio button field that use the same value for the on state will turn on and off in unison; that is if one is checked, they are all checked. If clear, the buttons are mutually exclusive (the same behavior as HTML radio buttons). - * - * @name AcroFormButton#radioIsUnison - * @type {boolean} - */ - Object.defineProperty(this, "radioIsUnison", { - enumerable: true, - configurable: true, - get: function() { - return Boolean(getBitForPdf(this.Ff, 26)); - }, - set: function(value) { - if (Boolean(value) === true) { - this.Ff = setBitForPdf(this.Ff, 26); - } else { - this.Ff = clearBitForPdf(this.Ff, 26); - } - } - }); - - var _MK: any = {}; - Object.defineProperty(this, "MK", { - enumerable: false, - configurable: false, - get: function() { - var encryptor = function(data) { - return data; - }; - if (this.scope) encryptor = this.scope.internal.getEncryptor(this.objId); - if (Object.keys(_MK).length !== 0) { - var result = []; - result.push("<<"); - var key; - for (key in _MK) { - result.push("/" + key + " (" + pdfEscape(encryptor(_MK[key])) + ")"); + /** + * (PDF 1.5) If set, a group of radio buttons within a radio button field that use the same value for the on state will turn on and off in unison; that is if one is checked, they are all checked. If clear, the buttons are mutually exclusive (the same behavior as HTML radio buttons). + * + * @name AcroFormButton#radioIsUnison + * @type {boolean} + */ + Object.defineProperty(this, "radioIsUnison", { + enumerable: true, + configurable: true, + get: function (this: AcroFormButton) { + return Boolean(getBitForPdf(this.Ff, 26)); + }, + set: function (this: AcroFormButton, value: boolean) { + if (Boolean(value) === true) { + this.Ff = setBitForPdf(this.Ff, 26); + } else { + this.Ff = clearBitForPdf(this.Ff, 26); } - result.push(">>"); - return result.join("\n"); } - return undefined; - }, - set: function(value) { - if (typeof value === "object") { - _MK = value; + }); + + var _MK: Record = {}; + Object.defineProperty(this, "MK", { + enumerable: false, + configurable: false, + get: function (this: AcroFormButton) { + var encryptor: Encryptor = function (data) { + return data; + }; + if (this.scope) + encryptor = this.scope.internal.getEncryptor(this.objId); + if (Object.keys(_MK).length !== 0) { + var result = []; + result.push("<<"); + var key; + for (key in _MK) { + result.push( + "/" + key + " (" + pdfEscape(encryptor(_MK[key])) + ")" + ); + } + result.push(">>"); + return result.join("\n"); + } + return undefined; + }, + set: function (value: Record) { + if (typeof value === "object") { + _MK = value; + } } - } - }); + }); - /** - * From the PDF reference: - * (Optional, button fields only) The widget annotation's normal caption which shall be displayed when it is not interacting with the user. - * Unlike the remaining entries listed in this Table which apply only to widget annotations associated with pushbutton fields (see Pushbuttons in 12.7.4.2, "Button Fields"), the CA entry may be used with any type of button field, including check boxes (see Check Boxes in 12.7.4.2, "Button Fields") and radio buttons (Radio Buttons in 12.7.4.2, "Button Fields"). - * - * - '8' = Cross, - * - 'l' = Circle, - * - '' = nothing - * @name AcroFormButton#caption - * @type {string} - */ - Object.defineProperty(this, "caption", { - enumerable: true, - configurable: true, - get: function() { - return _MK.CA || ""; - }, - set: function(value) { - if (typeof value === "string") { - _MK.CA = value; + /** + * From the PDF reference: + * (Optional, button fields only) The widget annotation's normal caption which shall be displayed when it is not interacting with the user. + * Unlike the remaining entries listed in this Table which apply only to widget annotations associated with pushbutton fields (see Pushbuttons in 12.7.4.2, "Button Fields"), the CA entry may be used with any type of button field, including check boxes (see Check Boxes in 12.7.4.2, "Button Fields") and radio buttons (Radio Buttons in 12.7.4.2, "Button Fields"). + * + * - '8' = Cross, + * - 'l' = Circle, + * - '' = nothing + * @name AcroFormButton#caption + * @type {string} + */ + Object.defineProperty(this, "caption", { + enumerable: true, + configurable: true, + get: function () { + return _MK.CA || ""; + }, + set: function (value: string) { + if (typeof value === "string") { + _MK.CA = value; + } } - } - }); - - var _AS; - Object.defineProperty(this, "AS", { - enumerable: false, - configurable: false, - get: function() { - return _AS; - }, - set: function(value) { - var name = value === undefined || value === null ? "" : value.toString(); - if (name.substr(0, 1) === "/") { - name = name.substr(1); + }); + + var _AS: string; + Object.defineProperty(this, "AS", { + enumerable: false, + configurable: false, + get: function () { + return _AS; + }, + set: function (value: string) { + var name = + value === undefined || value === null ? "" : value.toString(); + if (name.substr(0, 1) === "/") { + name = name.substr(1); + } + _AS = "/" + pdfEscapeName(name); } - _AS = "/" + pdfEscapeName(name); - } - }); + }); - /** - * (Required if the appearance dictionary AP contains one or more subdictionaries; PDF 1.2) The annotation's appearance state, which selects the applicable appearance stream from an appearance subdictionary (see Section 12.5.5, "Appearance Streams") - * - * @name AcroFormButton#appearanceState - * @type {any} - */ - Object.defineProperty(this, "appearanceState", { - enumerable: true, - configurable: true, - get: function() { - return _AS.substr(1, _AS.length - 1); - }, - set: function(value) { - _AS = "/" + pdfEscapeName(value); - } - }); -}; -inherit(AcroFormButton, AcroFormField); + /** + * (Required if the appearance dictionary AP contains one or more subdictionaries; PDF 1.2) The annotation's appearance state, which selects the applicable appearance stream from an appearance subdictionary (see Section 12.5.5, "Appearance Streams") + * + * @name AcroFormButton#appearanceState + * @type {any} + */ + Object.defineProperty(this, "appearanceState", { + enumerable: true, + configurable: true, + get: function () { + return _AS.substr(1, _AS.length - 1); + }, + set: function (value: string) { + _AS = "/" + pdfEscapeName(value); + } + }); + } +} /** * @class AcroFormPushButton * @extends AcroFormButton * @extends AcroFormField */ -var AcroFormPushButton = function() { - AcroFormButton.call(this); - this.pushButton = true; -}; -inherit(AcroFormPushButton, AcroFormButton); +class AcroFormPushButton extends AcroFormButton { + constructor() { + super(); + this.pushButton = true; + } +} /** * @class AcroFormRadioButton * @extends AcroFormButton * @extends AcroFormField */ -var AcroFormRadioButton = function() { - AcroFormButton.call(this); - this.radio = true; - this.pushButton = false; - - var _Kids = []; - Object.defineProperty(this, "Kids", { - enumerable: true, - configurable: false, - get: function() { - return _Kids; - }, - set: function(value) { - if (typeof value !== "undefined") { - _Kids = value; - } else { - _Kids = []; +class AcroFormRadioButton extends AcroFormButton { + declare Kids: AcroFormChildClass[]; + + constructor() { + super(); + this.radio = true; + this.pushButton = false; + + var _Kids: AcroFormChildClass[] = []; + Object.defineProperty(this, "Kids", { + enumerable: true, + configurable: false, + get: function () { + return _Kids; + }, + set: function (value: AcroFormChildClass[]) { + if (typeof value !== "undefined") { + _Kids = value; + } else { + _Kids = []; + } + } + }); + } + + setAppearance(appearance: AcroFormRadioButtonAppearanceProvider): void { + if (!("createAppearanceStream" in appearance && "getCA" in appearance)) { + throw new Error( + "Couldn't assign Appearance to RadioButton. Appearance was Invalid!" + ); + } + for (var objId in this.Kids) { + if (this.Kids.hasOwnProperty(objId)) { + var child = this.Kids[Number(objId)]; + child.appearanceStreamContent = appearance.createAppearanceStream( + child.optionName + ); + child.caption = appearance.getCA(); } } - }); -}; -inherit(AcroFormRadioButton, AcroFormButton); + } + + createOption(name: string): AcroFormChildClass { + // Create new Child for RadioGroup + var child = new AcroFormChildClass(); + child.Parent = this; + child.optionName = name; + // Add to Parent + this.Kids.push(child); + + addField.call(this.scope, child); + + return child; + } +} /** * The Child class of a RadioButton (the radioGroup) -> The single Buttons @@ -2216,389 +2538,386 @@ inherit(AcroFormRadioButton, AcroFormButton); * @extends AcroFormField * @ignore */ -var AcroFormChildClass = function() { - AcroFormField.call(this); - - var _parent; - Object.defineProperty(this, "Parent", { - enumerable: false, - configurable: false, - get: function() { - return _parent; - }, - set: function(value) { - _parent = value; - } - }); - - var _optionName; - Object.defineProperty(this, "optionName", { - enumerable: false, - configurable: true, - get: function() { - return _optionName; - }, - set: function(value) { - _optionName = value; - } - }); - - var _MK: any = {}; - Object.defineProperty(this, "MK", { - enumerable: false, - configurable: false, - get: function() { - var encryptor = function(data) { - return data; - }; - if (this.scope) encryptor = this.scope.internal.getEncryptor(this.objId); - var result = []; - result.push("<<"); - var key; - for (key in _MK) { - result.push("/" + key + " (" + pdfEscape(encryptor(_MK[key])) + ")"); - } - result.push(">>"); - return result.join("\n"); - }, - set: function(value) { - if (typeof value === "object") { - _MK = value; +class AcroFormChildClass extends AcroFormField { + declare Parent: AcroFormRadioButton; + declare optionName: string; + declare MK: Record | string; + declare caption: string; + declare AS: string; + declare appearanceState: string; + declare _AppearanceType: AcroFormRadioButtonAppearanceProvider; + + constructor() { + super(); + + var _parent: AcroFormRadioButton; + Object.defineProperty(this, "Parent", { + enumerable: false, + configurable: false, + get: function () { + return _parent; + }, + set: function (value: AcroFormRadioButton) { + _parent = value; } - } - }); + }); - /** - * From the PDF reference: - * (Optional, button fields only) The widget annotation's normal caption which shall be displayed when it is not interacting with the user. - * Unlike the remaining entries listed in this Table which apply only to widget annotations associated with pushbutton fields (see Pushbuttons in 12.7.4.2, "Button Fields"), the CA entry may be used with any type of button field, including check boxes (see Check Boxes in 12.7.4.2, "Button Fields") and radio buttons (Radio Buttons in 12.7.4.2, "Button Fields"). - * - * - '8' = Cross, - * - 'l' = Circle, - * - '' = nothing - * @name AcroFormButton#caption - * @type {string} - */ - Object.defineProperty(this, "caption", { - enumerable: true, - configurable: true, - get: function() { - return _MK.CA || ""; - }, - set: function(value) { - if (typeof value === "string") { - _MK.CA = value; + var _optionName: string; + Object.defineProperty(this, "optionName", { + enumerable: false, + configurable: true, + get: function () { + return _optionName; + }, + set: function (value: string) { + _optionName = value; } - } - }); - - var _AS; - Object.defineProperty(this, "AS", { - enumerable: false, - configurable: false, - get: function() { - return _AS; - }, - set: function(value) { - var name = value === undefined || value === null ? "" : value.toString(); - if (name.substr(0, 1) === "/") { - name = name.substr(1); + }); + + var _MK: Record = {}; + Object.defineProperty(this, "MK", { + enumerable: false, + configurable: false, + get: function (this: AcroFormChildClass) { + var encryptor: Encryptor = function (data) { + return data; + }; + if (this.scope) + encryptor = this.scope.internal.getEncryptor(this.objId); + var result = []; + result.push("<<"); + var key; + for (key in _MK) { + result.push("/" + key + " (" + pdfEscape(encryptor(_MK[key])) + ")"); + } + result.push(">>"); + return result.join("\n"); + }, + set: function (value: Record) { + if (typeof value === "object") { + _MK = value; + } } - _AS = "/" + pdfEscapeName(name); - } - }); + }); - /** - * (Required if the appearance dictionary AP contains one or more subdictionaries; PDF 1.2) The annotation's appearance state, which selects the applicable appearance stream from an appearance subdictionary (see Section 12.5.5, "Appearance Streams") - * - * @name AcroFormButton#appearanceState - * @type {any} - */ - Object.defineProperty(this, "appearanceState", { - enumerable: true, - configurable: true, - get: function() { - return _AS.substr(1, _AS.length - 1); - }, - set: function(value) { - var name = value === undefined || value === null ? "" : value.toString(); - if (name.substr(0, 1) === "/") { - name = name.substr(1); + /** + * From the PDF reference: + * (Optional, button fields only) The widget annotation's normal caption which shall be displayed when it is not interacting with the user. + * Unlike the remaining entries listed in this Table which apply only to widget annotations associated with pushbutton fields (see Pushbuttons in 12.7.4.2, "Button Fields"), the CA entry may be used with any type of button field, including check boxes (see Check Boxes in 12.7.4.2, "Button Fields") and radio buttons (Radio Buttons in 12.7.4.2, "Button Fields"). + * + * - '8' = Cross, + * - 'l' = Circle, + * - '' = nothing + * @name AcroFormButton#caption + * @type {string} + */ + Object.defineProperty(this, "caption", { + enumerable: true, + configurable: true, + get: function () { + return _MK.CA || ""; + }, + set: function (value: string) { + if (typeof value === "string") { + _MK.CA = value; + } } - _AS = "/" + pdfEscapeName(name); - } - }); - this.caption = "l"; - this.appearanceState = "Off"; - // todo: set AppearanceType as variable that can be set from the - // outside... - this._AppearanceType = AcroFormAppearance.RadioButton.Circle; - // The Default appearanceType is the Circle - this.appearanceStreamContent = this._AppearanceType.createAppearanceStream( - this.optionName - ); -}; -inherit(AcroFormChildClass, AcroFormField); + }); -AcroFormRadioButton.prototype.setAppearance = function(appearance) { - if (!("createAppearanceStream" in appearance && "getCA" in appearance)) { - throw new Error( - "Couldn't assign Appearance to RadioButton. Appearance was Invalid!" + var _AS: string; + Object.defineProperty(this, "AS", { + enumerable: false, + configurable: false, + get: function () { + return _AS; + }, + set: function (value: string) { + var name = + value === undefined || value === null ? "" : value.toString(); + if (name.substr(0, 1) === "/") { + name = name.substr(1); + } + _AS = "/" + pdfEscapeName(name); + } + }); + + /** + * (Required if the appearance dictionary AP contains one or more subdictionaries; PDF 1.2) The annotation's appearance state, which selects the applicable appearance stream from an appearance subdictionary (see Section 12.5.5, "Appearance Streams") + * + * @name AcroFormButton#appearanceState + * @type {any} + */ + Object.defineProperty(this, "appearanceState", { + enumerable: true, + configurable: true, + get: function () { + return _AS.substr(1, _AS.length - 1); + }, + set: function (value: string) { + var name = + value === undefined || value === null ? "" : value.toString(); + if (name.substr(0, 1) === "/") { + name = name.substr(1); + } + _AS = "/" + pdfEscapeName(name); + } + }); + this.caption = "l"; + this.appearanceState = "Off"; + // todo: set AppearanceType as variable that can be set from the + // outside... + this._AppearanceType = AcroFormAppearance.RadioButton.Circle; + // The Default appearanceType is the Circle + this.appearanceStreamContent = this._AppearanceType.createAppearanceStream( + this.optionName ); } - for (var objId in this.Kids) { - if (this.Kids.hasOwnProperty(objId)) { - var child = this.Kids[objId]; - child.appearanceStreamContent = appearance.createAppearanceStream( - child.optionName - ); - child.caption = appearance.getCA(); - } - } -}; - -AcroFormRadioButton.prototype.createOption = function(name) { - // Create new Child for RadioGroup - var child = new AcroFormChildClass(); - child.Parent = this; - child.optionName = name; - // Add to Parent - this.Kids.push(child); - - addField.call(this.scope, child); - - return child; -}; +} /** * @class AcroFormCheckBox * @extends AcroFormButton * @extends AcroFormField */ -var AcroFormCheckBox = function() { - AcroFormButton.call(this); - - this.fontName = "zapfdingbats"; - this.caption = "3"; - this.appearanceState = "On"; - this.value = "On"; - this.textAlign = "center"; - this.appearanceStreamContent = AcroFormAppearance.CheckBox.createAppearanceStream(); -}; -inherit(AcroFormCheckBox, AcroFormButton); +class AcroFormCheckBox extends AcroFormButton { + constructor() { + super(); + + this.fontName = "zapfdingbats"; + this.caption = "3"; + this.appearanceState = "On"; + this.value = "On"; + this.textAlign = "center"; + this.appearanceStreamContent = + AcroFormAppearance.CheckBox.createAppearanceStream(); + } +} /** * @class AcroFormTextField * @extends AcroFormField */ -var AcroFormTextField = function() { - AcroFormField.call(this); - this.FT = "/Tx"; +class AcroFormTextField extends AcroFormField { + declare multiline: boolean; + declare fileSelect: boolean; + declare doNotSpellCheck: boolean; + declare doNotScroll: boolean; + declare comb: boolean; + declare richText: boolean; + declare MaxLen: number; + declare maxLength: number; + + constructor() { + super(); + this.FT = "/Tx"; - /** - * If set, the field may contain multiple lines of text; if clear, the field’s text shall be restricted to a single line. - * - * @name AcroFormTextField#multiline - * @type {boolean} - */ - Object.defineProperty(this, "multiline", { - enumerable: true, - configurable: true, - get: function() { - return Boolean(getBitForPdf(this.Ff, 13)); - }, - set: function(value) { - if (Boolean(value) === true) { - this.Ff = setBitForPdf(this.Ff, 13); - } else { - this.Ff = clearBitForPdf(this.Ff, 13); + /** + * If set, the field may contain multiple lines of text; if clear, the field’s text shall be restricted to a single line. + * + * @name AcroFormTextField#multiline + * @type {boolean} + */ + Object.defineProperty(this, "multiline", { + enumerable: true, + configurable: true, + get: function (this: AcroFormTextField) { + return Boolean(getBitForPdf(this.Ff, 13)); + }, + set: function (this: AcroFormTextField, value: boolean) { + if (Boolean(value) === true) { + this.Ff = setBitForPdf(this.Ff, 13); + } else { + this.Ff = clearBitForPdf(this.Ff, 13); + } } - } - }); + }); - /** - * (PDF 1.4) If set, the text entered in the field represents the pathname of a file whose contents shall be submitted as the value of the field. - * - * @name AcroFormTextField#fileSelect - * @type {boolean} - */ - Object.defineProperty(this, "fileSelect", { - enumerable: true, - configurable: true, - get: function() { - return Boolean(getBitForPdf(this.Ff, 21)); - }, - set: function(value) { - if (Boolean(value) === true) { - this.Ff = setBitForPdf(this.Ff, 21); - } else { - this.Ff = clearBitForPdf(this.Ff, 21); + /** + * (PDF 1.4) If set, the text entered in the field represents the pathname of a file whose contents shall be submitted as the value of the field. + * + * @name AcroFormTextField#fileSelect + * @type {boolean} + */ + Object.defineProperty(this, "fileSelect", { + enumerable: true, + configurable: true, + get: function (this: AcroFormTextField) { + return Boolean(getBitForPdf(this.Ff, 21)); + }, + set: function (this: AcroFormTextField, value: boolean) { + if (Boolean(value) === true) { + this.Ff = setBitForPdf(this.Ff, 21); + } else { + this.Ff = clearBitForPdf(this.Ff, 21); + } } - } - }); + }); - /** - * (PDF 1.4) If set, text entered in the field shall not be spell-checked. - * - * @name AcroFormTextField#doNotSpellCheck - * @type {boolean} - */ - Object.defineProperty(this, "doNotSpellCheck", { - enumerable: true, - configurable: true, - get: function() { - return Boolean(getBitForPdf(this.Ff, 23)); - }, - set: function(value) { - if (Boolean(value) === true) { - this.Ff = setBitForPdf(this.Ff, 23); - } else { - this.Ff = clearBitForPdf(this.Ff, 23); + /** + * (PDF 1.4) If set, text entered in the field shall not be spell-checked. + * + * @name AcroFormTextField#doNotSpellCheck + * @type {boolean} + */ + Object.defineProperty(this, "doNotSpellCheck", { + enumerable: true, + configurable: true, + get: function (this: AcroFormTextField) { + return Boolean(getBitForPdf(this.Ff, 23)); + }, + set: function (this: AcroFormTextField, value: boolean) { + if (Boolean(value) === true) { + this.Ff = setBitForPdf(this.Ff, 23); + } else { + this.Ff = clearBitForPdf(this.Ff, 23); + } } - } - }); + }); - /** - * (PDF 1.4) If set, the field shall not scroll (horizontally for single-line fields, vertically for multiple-line fields) to accommodate more text than fits within its annotation rectangle. Once the field is full, no further text shall be accepted for interactive form filling; for noninteractive form filling, the filler should take care not to add more character than will visibly fit in the defined area. - * - * @name AcroFormTextField#doNotScroll - * @type {boolean} - */ - Object.defineProperty(this, "doNotScroll", { - enumerable: true, - configurable: true, - get: function() { - return Boolean(getBitForPdf(this.Ff, 24)); - }, - set: function(value) { - if (Boolean(value) === true) { - this.Ff = setBitForPdf(this.Ff, 24); - } else { - this.Ff = clearBitForPdf(this.Ff, 24); + /** + * (PDF 1.4) If set, the field shall not scroll (horizontally for single-line fields, vertically for multiple-line fields) to accommodate more text than fits within its annotation rectangle. Once the field is full, no further text shall be accepted for interactive form filling; for noninteractive form filling, the filler should take care not to add more character than will visibly fit in the defined area. + * + * @name AcroFormTextField#doNotScroll + * @type {boolean} + */ + Object.defineProperty(this, "doNotScroll", { + enumerable: true, + configurable: true, + get: function (this: AcroFormTextField) { + return Boolean(getBitForPdf(this.Ff, 24)); + }, + set: function (this: AcroFormTextField, value: boolean) { + if (Boolean(value) === true) { + this.Ff = setBitForPdf(this.Ff, 24); + } else { + this.Ff = clearBitForPdf(this.Ff, 24); + } } - } - }); + }); - /** - * (PDF 1.5) May be set only if the MaxLen entry is present in the text field dictionary (see Table 229) and if the Multiline, Password, and FileSelect flags are clear. If set, the field shall be automatically divided into as many equally spaced positions, or combs, as the value of MaxLen, and the text is laid out into those combs. - * - * @name AcroFormTextField#comb - * @type {boolean} - */ - Object.defineProperty(this, "comb", { - enumerable: true, - configurable: true, - get: function() { - return Boolean(getBitForPdf(this.Ff, 25)); - }, - set: function(value) { - if (Boolean(value) === true) { - this.Ff = setBitForPdf(this.Ff, 25); - } else { - this.Ff = clearBitForPdf(this.Ff, 25); + /** + * (PDF 1.5) May be set only if the MaxLen entry is present in the text field dictionary (see Table 229) and if the Multiline, Password, and FileSelect flags are clear. If set, the field shall be automatically divided into as many equally spaced positions, or combs, as the value of MaxLen, and the text is laid out into those combs. + * + * @name AcroFormTextField#comb + * @type {boolean} + */ + Object.defineProperty(this, "comb", { + enumerable: true, + configurable: true, + get: function (this: AcroFormTextField) { + return Boolean(getBitForPdf(this.Ff, 25)); + }, + set: function (this: AcroFormTextField, value: boolean) { + if (Boolean(value) === true) { + this.Ff = setBitForPdf(this.Ff, 25); + } else { + this.Ff = clearBitForPdf(this.Ff, 25); + } } - } - }); + }); - /** - * (PDF 1.5) If set, the value of this field shall be a rich text string (see 12.7.3.4, “Rich Text Strings”). If the field has a value, the RV entry of the field dictionary (Table 222) shall specify the rich text string. - * - * @name AcroFormTextField#richText - * @type {boolean} - */ - Object.defineProperty(this, "richText", { - enumerable: true, - configurable: true, - get: function() { - return Boolean(getBitForPdf(this.Ff, 26)); - }, - set: function(value) { - if (Boolean(value) === true) { - this.Ff = setBitForPdf(this.Ff, 26); - } else { - this.Ff = clearBitForPdf(this.Ff, 26); + /** + * (PDF 1.5) If set, the value of this field shall be a rich text string (see 12.7.3.4, “Rich Text Strings”). If the field has a value, the RV entry of the field dictionary (Table 222) shall specify the rich text string. + * + * @name AcroFormTextField#richText + * @type {boolean} + */ + Object.defineProperty(this, "richText", { + enumerable: true, + configurable: true, + get: function (this: AcroFormTextField) { + return Boolean(getBitForPdf(this.Ff, 26)); + }, + set: function (this: AcroFormTextField, value: boolean) { + if (Boolean(value) === true) { + this.Ff = setBitForPdf(this.Ff, 26); + } else { + this.Ff = clearBitForPdf(this.Ff, 26); + } } - } - }); - - var _MaxLen = null; - Object.defineProperty(this, "MaxLen", { - enumerable: true, - configurable: false, - get: function() { - return _MaxLen; - }, - set: function(value) { - _MaxLen = value; - } - }); + }); - /** - * (Optional; inheritable) The maximum length of the field’s text, in characters. - * - * @name AcroFormTextField#maxLength - * @type {number} - */ - Object.defineProperty(this, "maxLength", { - enumerable: true, - configurable: true, - get: function() { - return _MaxLen; - }, - set: function(value) { - if (Number.isInteger(value)) { + var _MaxLen: number = null; + Object.defineProperty(this, "MaxLen", { + enumerable: true, + configurable: false, + get: function () { + return _MaxLen; + }, + set: function (value: number) { _MaxLen = value; } - } - }); + }); - Object.defineProperty(this, "hasAppearanceStream", { - enumerable: true, - configurable: true, - get: function() { - return this.V || this.DV; - } - }); -}; -inherit(AcroFormTextField, AcroFormField); + /** + * (Optional; inheritable) The maximum length of the field’s text, in characters. + * + * @name AcroFormTextField#maxLength + * @type {number} + */ + Object.defineProperty(this, "maxLength", { + enumerable: true, + configurable: true, + get: function () { + return _MaxLen; + }, + set: function (value: number) { + if (Number.isInteger(value)) { + _MaxLen = value; + } + } + }); + + Object.defineProperty(this, "hasAppearanceStream", { + enumerable: true, + configurable: true, + get: function (this: AcroFormTextField) { + return this.V || this.DV; + } + }); + } +} /** * @class AcroFormPasswordField * @extends AcroFormTextField * @extends AcroFormField */ -var AcroFormPasswordField = function() { - AcroFormTextField.call(this); +class AcroFormPasswordField extends AcroFormTextField { + declare password: boolean; - /** - * If set, the field is intended for entering a secure password that should not be echoed visibly to the screen. Characters typed from the keyboard shall instead be echoed in some unreadable form, such as asterisks or bullet characters. - * NOTE To protect password confidentiality, readers should never store the value of the text field in the PDF file if this flag is set. - * - * @name AcroFormTextField#password - * @type {boolean} - */ - Object.defineProperty(this, "password", { - enumerable: true, - configurable: true, - get: function() { - return Boolean(getBitForPdf(this.Ff, 14)); - }, - set: function(value) { - if (Boolean(value) === true) { - this.Ff = setBitForPdf(this.Ff, 14); - } else { - this.Ff = clearBitForPdf(this.Ff, 14); + constructor() { + super(); + + /** + * If set, the field is intended for entering a secure password that should not be echoed visibly to the screen. Characters typed from the keyboard shall instead be echoed in some unreadable form, such as asterisks or bullet characters. + * NOTE To protect password confidentiality, readers should never store the value of the text field in the PDF file if this flag is set. + * + * @name AcroFormTextField#password + * @type {boolean} + */ + Object.defineProperty(this, "password", { + enumerable: true, + configurable: true, + get: function (this: AcroFormPasswordField) { + return Boolean(getBitForPdf(this.Ff, 14)); + }, + set: function (this: AcroFormPasswordField, value: boolean) { + if (Boolean(value) === true) { + this.Ff = setBitForPdf(this.Ff, 14); + } else { + this.Ff = clearBitForPdf(this.Ff, 14); + } } - } - }); - this.password = true; -}; -inherit(AcroFormPasswordField, AcroFormTextField); + }); + this.password = true; + } +} // Contains Methods for creating standard appearances -var AcroFormAppearance: any = { +var AcroFormAppearance: AcroFormAppearanceType = { CheckBox: { - createAppearanceStream: function() { + createAppearanceStream: function (): AppearanceDict { var appearance = { N: { On: AcroFormAppearance.CheckBox.YesNormal @@ -2616,7 +2935,7 @@ var AcroFormAppearance: any = { * * @returns {AcroFormXObject} */ - YesPushDown: function(formObject) { + YesPushDown: function (formObject: AcroFormField): AcroFormXObject { var xobj = createFormXObject(formObject); xobj.scope = formObject.scope; var stream = []; @@ -2627,7 +2946,10 @@ var AcroFormAppearance: any = { var encodedColor = formObject.scope.__private__.encodeColorString( formObject.color ); - var calcRes = calculateX(formObject, formObject.caption); + var calcRes = calculateX( + formObject, + (formObject as AcroFormButton).caption + ); stream.push("0.749023 g"); stream.push( "0 0 " + @@ -2652,7 +2974,7 @@ var AcroFormAppearance: any = { return xobj; }, - YesNormal: function(formObject) { + YesNormal: function (formObject: AcroFormField): AcroFormXObject { var xobj = createFormXObject(formObject); xobj.scope = formObject.scope; var fontKey = formObject.scope.internal.getFont( @@ -2665,7 +2987,10 @@ var AcroFormAppearance: any = { var stream = []; var height = AcroFormAppearance.internal.getHeight(formObject); var width = AcroFormAppearance.internal.getWidth(formObject); - var calcRes = calculateX(formObject, formObject.caption); + var calcRes = calculateX( + formObject, + (formObject as AcroFormButton).caption + ); stream.push("1 g"); stream.push("0 0 " + f2(width) + " " + f2(height) + " re"); stream.push("f"); @@ -2691,7 +3016,7 @@ var AcroFormAppearance: any = { * * @returns {AcroFormXObject} */ - OffPushDown: function(formObject) { + OffPushDown: function (formObject: AcroFormField): AcroFormXObject { var xobj = createFormXObject(formObject); xobj.scope = formObject.scope; var stream = []; @@ -2711,8 +3036,11 @@ var AcroFormAppearance: any = { RadioButton: { Circle: { - createAppearanceStream: function(name) { - var appearanceStreamContent = { + createAppearanceStream: function (name: string): AppearanceDict { + var appearanceStreamContent: Record< + string, + Record + > = { D: { Off: AcroFormAppearance.RadioButton.Circle.OffPushDown }, @@ -2724,11 +3052,11 @@ var AcroFormAppearance: any = { AcroFormAppearance.RadioButton.Circle.YesPushDown; return appearanceStreamContent; }, - getCA: function() { + getCA: function (): string { return "l"; }, - YesNormal: function(formObject) { + YesNormal: function (formObject: AcroFormField): AcroFormXObject { var xobj = createFormXObject(formObject); xobj.scope = formObject.scope; var stream = []; @@ -2809,7 +3137,7 @@ var AcroFormAppearance: any = { xobj.stream = stream.join("\n"); return xobj; }, - YesPushDown: function(formObject) { + YesPushDown: function (formObject: AcroFormField): AcroFormXObject { var xobj = createFormXObject(formObject); xobj.scope = formObject.scope; var stream = []; @@ -2914,7 +3242,7 @@ var AcroFormAppearance: any = { xobj.stream = stream.join("\n"); return xobj; }, - OffPushDown: function(formObject) { + OffPushDown: function (formObject: AcroFormField): AcroFormXObject { var xobj = createFormXObject(formObject); xobj.scope = formObject.scope; var stream = []; @@ -2963,8 +3291,11 @@ var AcroFormAppearance: any = { * @returns {Object} * @ignore */ - createAppearanceStream: function(name) { - var appearanceStreamContent = { + createAppearanceStream: function (name: string): AppearanceDict { + var appearanceStreamContent: Record< + string, + Record + > = { D: { Off: AcroFormAppearance.RadioButton.Cross.OffPushDown }, @@ -2976,11 +3307,11 @@ var AcroFormAppearance: any = { AcroFormAppearance.RadioButton.Cross.YesPushDown; return appearanceStreamContent; }, - getCA: function() { + getCA: function (): string { return "8"; }, - YesNormal: function(formObject) { + YesNormal: function (formObject: AcroFormField): AcroFormXObject { var xobj = createFormXObject(formObject); xobj.scope = formObject.scope; var stream = []; @@ -3004,7 +3335,7 @@ var AcroFormAppearance: any = { xobj.stream = stream.join("\n"); return xobj; }, - YesPushDown: function(formObject) { + YesPushDown: function (formObject: AcroFormField): AcroFormXObject { var xobj = createFormXObject(formObject); xobj.scope = formObject.scope; var cross = AcroFormAppearance.internal.calculateCross(formObject); @@ -3037,7 +3368,7 @@ var AcroFormAppearance: any = { xobj.stream = stream.join("\n"); return xobj; }, - OffPushDown: function(formObject) { + OffPushDown: function (formObject: AcroFormField): AcroFormXObject { var xobj = createFormXObject(formObject); xobj.scope = formObject.scope; var stream = []; @@ -3061,7 +3392,7 @@ var AcroFormAppearance: any = { * * @returns {AcroFormXObject} */ - createDefaultAppearanceStream: function(formObject) { + createDefaultAppearanceStream: function (formObject: AcroFormField): string { // Set Helvetica to Standard Font (size: auto) // Color: Black var fontKey = formObject.scope.internal.getFont( @@ -3074,60 +3405,73 @@ var AcroFormAppearance: any = { var fontSize = formObject.fontSize; var result = "/" + fontKey + " " + fontSize + " Tf " + encodedColor; return result; - } -}; + }, -AcroFormAppearance.internal = { - Bezier_C: 0.551915024494, + internal: { + Bezier_C: 0.551915024494, - calculateCross: function(formObject) { - var width = AcroFormAppearance.internal.getWidth(formObject); - var height = AcroFormAppearance.internal.getHeight(formObject); - var a = Math.min(width, height); + calculateCross: function (formObject: AcroFormField): AppearanceCross { + var width = AcroFormAppearance.internal.getWidth(formObject); + var height = AcroFormAppearance.internal.getHeight(formObject); + var a = Math.min(width, height); - var cross = { - x1: { - // upperLeft - x: (width - a) / 2, - y: (height - a) / 2 + a // height - borderPadding - }, - x2: { - // lowerRight - x: (width - a) / 2 + a, - y: (height - a) / 2 // borderPadding - }, - x3: { - // lowerLeft - x: (width - a) / 2, - y: (height - a) / 2 // borderPadding - }, - x4: { - // upperRight - x: (width - a) / 2 + a, - y: (height - a) / 2 + a // height - borderPadding + var cross = { + x1: { + // upperLeft + x: (width - a) / 2, + y: (height - a) / 2 + a // height - borderPadding + }, + x2: { + // lowerRight + x: (width - a) / 2 + a, + y: (height - a) / 2 // borderPadding + }, + x3: { + // lowerLeft + x: (width - a) / 2, + y: (height - a) / 2 // borderPadding + }, + x4: { + // upperRight + x: (width - a) / 2 + a, + y: (height - a) / 2 + a // height - borderPadding + } + }; + + return cross; + }, + + getWidth: function (formObject: AcroFormField): number { + var result = 0; + if (typeof formObject === "object") { + result = scale(formObject.Rect[2]); } - }; + return result; + }, - return cross; - } -}; -AcroFormAppearance.internal.getWidth = function(formObject) { - var result = 0; - if (typeof formObject === "object") { - result = scale(formObject.Rect[2]); - } - return result; -}; -AcroFormAppearance.internal.getHeight = function(formObject) { - var result = 0; - if (typeof formObject === "object") { - result = scale(formObject.Rect[3]); + getHeight: function (formObject: AcroFormField): number { + var result = 0; + if (typeof formObject === "object") { + result = scale(formObject.Rect[3]); + } + return result; + } } - return result; }; // Public: +jsPDFAPI.__acroform__ = { + setBit: setBit, + clearBit: clearBit, + getBit: getBit, + getBitForPdf: getBitForPdf, + setBitForPdf: setBitForPdf, + clearBitForPdf: clearBitForPdf, + calculateCoordinates: calculateCoordinates, + arrayToPdfArray: arrayToPdfArray +}; + /** * Add an AcroForm-Field to the jsPDF-instance * @@ -3137,7 +3481,10 @@ AcroFormAppearance.internal.getHeight = function(formObject) { * @param {Object} fieldObject * @returns {jsPDF} */ -var addField = (jsPDFAPI.addField = function(fieldObject) { +var addField = (jsPDFAPI.addField = function ( + this: jsPDFDocument, + fieldObject: AcroFormField +) { initializeAcroForm(this, fieldObject); if (fieldObject instanceof AcroFormField) { @@ -3145,7 +3492,7 @@ var addField = (jsPDFAPI.addField = function(fieldObject) { } else { throw new Error("Invalid argument passed to jsPDF.addField."); } - (fieldObject as any).page = (fieldObject as any).scope.internal.getCurrentPageInfo().pageNumber; + fieldObject.page = fieldObject.scope.internal.getCurrentPageInfo().pageNumber; return this; }); @@ -3175,7 +3522,9 @@ jsPDFAPI.AcroForm = { Appearance: AcroFormAppearance }; -(jsPDF as any).AcroForm = { +// jsPDF is a plain constructor function whose declared type has no static +// plugin surface; the intersection cast adds the AcroForm static. +(jsPDF as typeof jsPDF & { AcroForm: AcroFormStatic }).AcroForm = { ChoiceField: AcroFormChoiceField, ListBox: AcroFormListBox, ComboBox: AcroFormComboBox, @@ -3189,7 +3538,7 @@ jsPDFAPI.AcroForm = { Appearance: AcroFormAppearance }; -var AcroForm = (jsPDF as any).AcroForm; +var AcroForm = (jsPDF as typeof jsPDF & { AcroForm: AcroFormStatic }).AcroForm; export { AcroForm, diff --git a/src/modules/addimage.ts b/src/modules/addimage.ts index beb7dfb73..806891372 100644 --- a/src/modules/addimage.ts +++ b/src/modules/addimage.ts @@ -34,12 +34,153 @@ import { jsPDF } from "../jspdf.js"; import { atob } from "../libs/AtobBtoa.js"; +import type { jsPDFAPI as jsPDFAPIType, jsPDFDocument } from "../types.js"; + +/** The typed-array flavours accepted as raw image data. */ +export type ImageTypedArray = + | Int8Array + | Uint8Array + | Uint8ClampedArray + | Int16Array + | Uint16Array + | Int32Array + | Uint32Array + | Float32Array + | Float64Array; + +/** Single dimensional array of RGBA values with size. For example from canvas getImageData. */ +export interface RGBAData { + data: Uint8ClampedArray; + width: number; + height: number; +} + +export type ImageCompression = "NONE" | "FAST" | "MEDIUM" | "SLOW"; + +/** Everything `addImage` accepts as its imageData argument. */ +export type ImageInput = + string | HTMLImageElement | HTMLCanvasElement | Uint8Array | RGBAData; + +/** Options-object form of `addImage` (adapted from types/index.d.ts). */ +export interface ImageOptions { + imageData: ImageInput; + x?: number; + y?: number; + w?: number; + h?: number; + width?: number; + height?: number; + alias?: string; + compression?: ImageCompression; + rotation?: number; + /** Alias of `rotation`. */ + angle?: number; + format?: string; +} -(function(jsPDFAPI) { +/** + * The decoded image object produced by the format plugins + * (`processPNG`/`processJPEG`/...) and consumed by `putImage`. Adapted from + * `ImageProperties` in types/index.d.ts, extended with the internal members + * this plugin reads and writes (`objectId`, `sMaskBitsPerComponent`, ...). + */ +export interface ImageProperties { + alias?: number | string; + width: number; + height: number; + colorSpace: string; + bitsPerComponent: number; + filter?: string; + decodeParameters?: string; + transparency?: number[]; + palette?: number[] | Uint8Array; + sMask?: string; + sMaskBitsPerComponent?: number; + predictor?: number; + index?: number; + data: string; + fileType?: string; + /** Assigned by putImage() while the image XObject is written. */ + objectId?: number; +} + +/** + * Signature of the dynamically dispatched format processors + * (`processPNG` etc.) contributed by the image-format plugins. + */ +export type ImageFormatProcessor = ( + imageData?: unknown, + index?: number, + alias?: number | string, + compression?: ImageCompression, + dataAsBinaryString?: string +) => ImageProperties; + +/** The helper namespace this plugin exposes as `jsPDF.API.__addimage__`. */ +export interface AddImageNamespace { + getImageFileTypeByImageData( + imageData: ImageInput | ImageTypedArray | ArrayBuffer, + fallbackFormat?: string + ): string; + /** `data` is optional at runtime: absent/unrecognized input hashes to 0. */ + sHashCode(data?: string | ImageTypedArray): number; + /** Called without an argument, validates the empty string (returns false). */ + validateStringAsBase64(possibleBase64String?: string): boolean; + /** Returns null for absent or non-data-URL input. */ + extractImageFromDataUrl(dataUrl?: string | null): string | null; + isArrayBuffer(object: unknown): object is ArrayBuffer; + isArrayBufferView(object: unknown): object is ImageTypedArray; + binaryStringToUint8Array(binary_string: string): Uint8Array; + arrayBufferToBinaryString(buffer: ArrayBuffer | ImageTypedArray): string; + convertBase64ToBinaryString(stringData: string, throwError?: boolean): string; +} + +declare module "../types.js" { + interface jsPDFAPI { + __addimage__: AddImageNamespace; + color_spaces: Record; + decode: Record; + image_compression: Record; + addImage( + imageData: ImageInput, + format: string, + x: number, + y: number, + w?: number, + h?: number, + alias?: string, + compression?: ImageCompression, + rotation?: number + ): jsPDFDocument; + addImage( + imageData: ImageInput, + x: number, + y: number, + w?: number, + h?: number, + alias?: string, + compression?: ImageCompression, + rotation?: number + ): jsPDFDocument; + addImage(options: ImageOptions): jsPDFDocument; + getImageProperties(imageData: ImageInput): ImageProperties; + + // Provided by src/modules/fileloading.ts; declared here so this module + // typechecks independently (merged declarations become overloads). + loadFile( + url: string, + sync?: boolean, + callback?: (data: string) => string + ): string; + } +} + +(function (jsPDFAPI: jsPDFAPIType) { "use strict"; var namespace = "addImage_"; - jsPDFAPI.__addimage__ = {}; + // Filled member by member directly below. + jsPDFAPI.__addimage__ = {} as AddImageNamespace; var UNKNOWN = "UNKNOWN"; @@ -48,7 +189,7 @@ import { atob } from "../libs/AtobBtoa.js"; // higher values cause larger and slower garbage collection. var ARRAY_APPLY_BATCH = 8192; - var imageFileTypeHeaders = { + var imageFileTypeHeaders: Record>> = { PNG: [[0x89, 0x50, 0x4e, 0x47]], TIFF: [ [0x4d, 0x4d, 0x00, 0x2a], //Motorola @@ -127,78 +268,84 @@ import { atob } from "../libs/AtobBtoa.js"; * * @returns {string} filetype of Image */ - var getImageFileTypeByImageData = (jsPDFAPI.__addimage__.getImageFileTypeByImageData = function( - imageData, - fallbackFormat? - ) { - fallbackFormat = fallbackFormat || UNKNOWN; - var i; - var j; - var result = UNKNOWN; - var headerSchemata; - var compareResult; - var fileType; - - if ( - fallbackFormat === "RGBA" || - (imageData.data !== undefined && - imageData.data instanceof Uint8ClampedArray && - "height" in imageData && - "width" in imageData) + var getImageFileTypeByImageData = + (jsPDFAPI.__addimage__.getImageFileTypeByImageData = function ( + imageData: ImageInput | ImageTypedArray | ArrayBuffer, + fallbackFormat?: string ) { - return "RGBA"; - } + fallbackFormat = fallbackFormat || UNKNOWN; + var i; + var j; + var result = UNKNOWN; + var headerSchemata; + var compareResult; + var fileType; + + // Duck-typed RGBA check, mirroring the legacy untyped behavior (a string + // or typed array simply has no `data` member). + var imageDataAsRGBA = imageData as RGBAData; + if ( + fallbackFormat === "RGBA" || + (imageDataAsRGBA.data !== undefined && + imageDataAsRGBA.data instanceof Uint8ClampedArray && + "height" in imageDataAsRGBA && + "width" in imageDataAsRGBA) + ) { + return "RGBA"; + } - if (isArrayBufferView(imageData)) { - for (fileType in imageFileTypeHeaders) { - headerSchemata = imageFileTypeHeaders[fileType]; - for (i = 0; i < headerSchemata.length; i += 1) { - compareResult = true; - for (j = 0; j < headerSchemata[i].length; j += 1) { - if (headerSchemata[i][j] === undefined) { - continue; + if (isArrayBufferView(imageData)) { + for (fileType in imageFileTypeHeaders) { + headerSchemata = imageFileTypeHeaders[fileType]; + for (i = 0; i < headerSchemata.length; i += 1) { + compareResult = true; + for (j = 0; j < headerSchemata[i].length; j += 1) { + if (headerSchemata[i][j] === undefined) { + continue; + } + if (headerSchemata[i][j] !== imageData[j]) { + compareResult = false; + break; + } } - if (headerSchemata[i][j] !== imageData[j]) { - compareResult = false; + if (compareResult === true) { + result = fileType; break; } } - if (compareResult === true) { - result = fileType; - break; - } } - } - } else { - for (fileType in imageFileTypeHeaders) { - headerSchemata = imageFileTypeHeaders[fileType]; - for (i = 0; i < headerSchemata.length; i += 1) { - compareResult = true; - for (j = 0; j < headerSchemata[i].length; j += 1) { - if (headerSchemata[i][j] === undefined) { - continue; + } else { + for (fileType in imageFileTypeHeaders) { + headerSchemata = imageFileTypeHeaders[fileType]; + for (i = 0; i < headerSchemata.length; i += 1) { + compareResult = true; + for (j = 0; j < headerSchemata[i].length; j += 1) { + if (headerSchemata[i][j] === undefined) { + continue; + } + if ( + headerSchemata[i][j] !== (imageData as string).charCodeAt(j) + ) { + compareResult = false; + break; + } } - if (headerSchemata[i][j] !== imageData.charCodeAt(j)) { - compareResult = false; + if (compareResult === true) { + result = fileType; break; } } - if (compareResult === true) { - result = fileType; - break; - } } } - } - if (result === UNKNOWN && fallbackFormat !== UNKNOWN) { - result = fallbackFormat; - } - return result; - }); + if (result === UNKNOWN && fallbackFormat !== UNKNOWN) { + result = fallbackFormat; + } + return result; + }); // Image functionality ported from pdf.js - var putImage = function(image) { + var putImage = function (this: jsPDFDocument, image: ImageProperties) { var out = this.internal.write; var putStream = this.internal.putStream; var getFilters = this.internal.getFilters; @@ -210,7 +357,8 @@ import { atob } from "../libs/AtobBtoa.js"; image.objectId = this.internal.newObject(); - var additionalKeyValues = []; + var additionalKeyValues: Array<{ key: string; value: string | number }> = + []; additionalKeyValues.push({ key: "Type", value: "/XObject" }); additionalKeyValues.push({ key: "Subtype", value: "/Image" }); additionalKeyValues.push({ key: "Width", value: image.width }); @@ -291,7 +439,7 @@ import { atob } from "../libs/AtobBtoa.js"; if ("sMask" in image && typeof image.sMask !== "undefined") { const sMaskBitsPerComponent = image.sMaskBitsPerComponent ?? image.bitsPerComponent; - const sMask: any = { + const sMask: ImageProperties = { width: image.width, height: image.height, colorSpace: "DeviceGray", @@ -317,14 +465,20 @@ import { atob } from "../libs/AtobBtoa.js"; out("endobj"); } }; - var putResourcesCallback = function() { - var images = this.internal.collections[namespace + "images"]; + var putResourcesCallback = function (this: jsPDFDocument) { + var images = this.internal.collections[namespace + "images"] as Record< + string, + ImageProperties + >; for (var i in images) { putImage.call(this, images[i]); } }; - var putXObjectsDictCallback = function() { - var images = this.internal.collections[namespace + "images"], + var putXObjectsDictCallback = function (this: jsPDFDocument) { + var images = this.internal.collections[namespace + "images"] as Record< + string, + ImageProperties + >, out = this.internal.write, image; for (var i in images) { @@ -333,12 +487,14 @@ import { atob } from "../libs/AtobBtoa.js"; } }; - var checkCompressValue = function(value) { + var checkCompressValue = function (value?: string): ImageCompression { if (value && typeof value === "string") value = value.toUpperCase(); - return value in jsPDFAPI.image_compression ? value : image_compression.NONE; + return typeof value === "string" && value in jsPDFAPI.image_compression + ? (value as ImageCompression) + : image_compression.NONE; }; - var initialize = function() { + var initialize = function (this: jsPDFDocument) { if (!this.internal.collections[namespace + "images"]) { this.internal.collections[namespace + "images"] = {}; this.internal.events.subscribe("putResources", putResourcesCallback); @@ -346,47 +502,61 @@ import { atob } from "../libs/AtobBtoa.js"; } }; - var getImages = function() { - var images = this.internal.collections[namespace + "images"]; + var getImages = function (this: jsPDFDocument) { + var images = this.internal.collections[namespace + "images"] as Record< + string, + ImageProperties + >; initialize.call(this); return images; }; - var getImageIndex = function() { + var getImageIndex = function (this: jsPDFDocument) { return Object.keys(this.internal.collections[namespace + "images"]).length; }; - var notDefined = function(value) { - return typeof value === "undefined" || value === null || value.length === 0; + var notDefined = function (value?: string | number | null) { + return ( + typeof value === "undefined" || + value === null || + (value as string).length === 0 + ); }; - var generateAliasFromImageData = function(imageData) { + var generateAliasFromImageData = function ( + imageData: ImageInput | ImageTypedArray + ) { if (typeof imageData === "string" || isArrayBufferView(imageData)) { return sHashCode(imageData); - } else if (isArrayBufferView(imageData.data)) { - return sHashCode(imageData.data); + } else if (isArrayBufferView((imageData as RGBAData).data)) { + return sHashCode((imageData as RGBAData).data); } return null; }; - var isImageTypeSupported = function(type) { - return typeof jsPDFAPI["process" + type.toUpperCase()] === "function"; + var isImageTypeSupported = function (type: string) { + return ( + // Dynamic plugin dispatch: the processXXX methods are contributed by + // the individual image-format plugins. + typeof (jsPDFAPI as unknown as Record)[ + "process" + type.toUpperCase() + ] === "function" + ); }; - var isDOMElement = function(object) { - return typeof object === "object" && object.nodeType === 1; + var isDOMElement = function (object: unknown): object is HTMLElement { + return typeof object === "object" && (object as HTMLElement).nodeType === 1; }; - var getImageDataFromElement = function(element, format?) { + var getImageDataFromElement = function ( + element: HTMLElement, + format?: string + ): string { //if element is an image which uses data url definition, just return the dataurl if (element.nodeName === "IMG" && element.hasAttribute("src")) { var src = "" + element.getAttribute("src"); //is base64 encoded dataUrl, directly process it if (src.indexOf("data:image/") === 0) { - return atob( - unescape(src) - .split("base64,") - .pop() - ); + return atob(unescape(src).split("base64,").pop()); } //it is probably an url, try to load it @@ -397,12 +567,13 @@ import { atob } from "../libs/AtobBtoa.js"; } if (element.nodeName === "CANVAS") { - if (element.width === 0 || element.height === 0) { + var canvas = element as HTMLCanvasElement; + if (canvas.width === 0 || canvas.height === 0) { throw new Error( "Given canvas must have data. Canvas width: " + - element.width + + canvas.width + ", height: " + - element.height + canvas.height ); } var mimeType; @@ -419,17 +590,18 @@ import { atob } from "../libs/AtobBtoa.js"; mimeType = "image/jpeg"; break; } - return atob( - element - .toDataURL(mimeType, 1.0) - .split("base64,") - .pop() - ); + return atob(canvas.toDataURL(mimeType, 1.0).split("base64,").pop()); } }; - var checkImagesForAlias = function(alias) { - var images = this.internal.collections[namespace + "images"]; + var checkImagesForAlias = function ( + this: jsPDFDocument, + alias: number | string + ): ImageProperties | undefined { + var images = this.internal.collections[namespace + "images"] as Record< + string, + ImageProperties + >; if (images) { for (var e in images) { if (alias === images[e].alias) { @@ -439,7 +611,12 @@ import { atob } from "../libs/AtobBtoa.js"; } }; - var determineWidthAndHeight = function(width, height, image) { + var determineWidthAndHeight = function ( + this: jsPDFDocument, + width: number, + height: number, + image: ImageProperties + ) { if (!width && !height) { width = -96; height = -96; @@ -460,7 +637,15 @@ import { atob } from "../libs/AtobBtoa.js"; return [width, height]; }; - var writeImageToPDF = function(x, y, width, height, image, rotation) { + var writeImageToPDF = function ( + this: jsPDFDocument, + x: number, + y: number, + width: number, + height: number, + image: ImageProperties, + rotation?: number + ) { var dims = determineWidthAndHeight.call(this, width, height, image), coord = this.internal.getCoordinateString, vcoord = this.internal.getVerticalCoordinateString; @@ -476,10 +661,10 @@ import { atob } from "../libs/AtobBtoa.js"; var c = Math.cos(rotation); var s = Math.sin(rotation); //like in pdf Reference do it 4 digits instead of 2 - var f4 = function(number) { + var f4 = function (number: number) { return number.toFixed(4); }; - var rotationTransformationMatrix = [ + var rotationTransformationMatrix: Array = [ f4(c), f4(s), f4(s * -1), @@ -569,7 +754,9 @@ import { atob } from "../libs/AtobBtoa.js"; * @param {string} data * @returns {string} */ - var sHashCode = (jsPDFAPI.__addimage__.sHashCode = function(data) { + var sHashCode = (jsPDFAPI.__addimage__.sHashCode = function ( + data?: string | ImageTypedArray + ) { var hash = 0, i, len; @@ -600,39 +787,38 @@ import { atob } from "../libs/AtobBtoa.js"; * * @returns {boolean} */ - var validateStringAsBase64 = (jsPDFAPI.__addimage__.validateStringAsBase64 = function( - possibleBase64String - ) { - possibleBase64String = possibleBase64String || ""; - possibleBase64String.toString().trim(); + var validateStringAsBase64 = (jsPDFAPI.__addimage__.validateStringAsBase64 = + function (possibleBase64String?: string) { + possibleBase64String = possibleBase64String || ""; + possibleBase64String.toString().trim(); - var result = true; + var result = true; - if (possibleBase64String.length === 0) { - result = false; - } + if (possibleBase64String.length === 0) { + result = false; + } - if (possibleBase64String.length % 4 !== 0) { - result = false; - } + if (possibleBase64String.length % 4 !== 0) { + result = false; + } - if ( - /^[A-Za-z0-9+/]+$/.test( - possibleBase64String.substr(0, possibleBase64String.length - 2) - ) === false - ) { - result = false; - } + if ( + /^[A-Za-z0-9+/]+$/.test( + possibleBase64String.substr(0, possibleBase64String.length - 2) + ) === false + ) { + result = false; + } - if ( - /^[A-Za-z0-9/][A-Za-z0-9+/]|[A-Za-z0-9+/]=|==$/.test( - possibleBase64String.substr(-2) - ) === false - ) { - result = false; - } - return result; - }); + if ( + /^[A-Za-z0-9/][A-Za-z0-9+/]|[A-Za-z0-9+/]=|==$/.test( + possibleBase64String.substr(-2) + ) === false + ) { + result = false; + } + return result; + }); /** * Strips out and returns info from a valid base64 data URI @@ -642,33 +828,32 @@ import { atob } from "../libs/AtobBtoa.js"; * @param {string} dataUrl a valid data URI of format 'data:[][;base64],' * @returns {string} The raw Base64-encoded data. */ - var extractImageFromDataUrl = (jsPDFAPI.__addimage__.extractImageFromDataUrl = function( - dataUrl - ) { - if (dataUrl == null) { - return null; - } + var extractImageFromDataUrl = (jsPDFAPI.__addimage__.extractImageFromDataUrl = + function (dataUrl?: string | null) { + if (dataUrl == null) { + return null; + } - // avoid using a regexp for parsing because it might be vulnerable against ReDoS attacks + // avoid using a regexp for parsing because it might be vulnerable against ReDoS attacks - dataUrl = dataUrl.trim(); + dataUrl = dataUrl.trim(); - if (!dataUrl.startsWith("data:")) { - return null; - } + if (!dataUrl.startsWith("data:")) { + return null; + } - const commaIndex = dataUrl.indexOf(","); - if (commaIndex < 0) { - return null; - } + const commaIndex = dataUrl.indexOf(","); + if (commaIndex < 0) { + return null; + } - const dataScheme = dataUrl.substring(0, commaIndex).trim(); - if (!dataScheme.endsWith("base64")) { - return null; - } + const dataScheme = dataUrl.substring(0, commaIndex).trim(); + if (!dataScheme.endsWith("base64")) { + return null; + } - return dataUrl.substring(commaIndex + 1); - }); + return dataUrl.substring(commaIndex + 1); + }); /** * Tests supplied object to determine if ArrayBuffer @@ -679,7 +864,9 @@ import { atob } from "../libs/AtobBtoa.js"; * * @returns {boolean} */ - jsPDFAPI.__addimage__.isArrayBuffer = function(object) { + jsPDFAPI.__addimage__.isArrayBuffer = function ( + object: unknown + ): object is ArrayBuffer { return object instanceof ArrayBuffer; }; @@ -691,9 +878,9 @@ import { atob } from "../libs/AtobBtoa.js"; * @param {Object} object an Object * @returns {boolean} */ - var isArrayBufferView = (jsPDFAPI.__addimage__.isArrayBufferView = function( - object - ) { + var isArrayBufferView = (jsPDFAPI.__addimage__.isArrayBufferView = function ( + object: unknown + ): object is ImageTypedArray { return ( object instanceof Int8Array || object instanceof Uint8Array || @@ -716,16 +903,17 @@ import { atob } from "../libs/AtobBtoa.js"; * @param {string} BinaryString with ImageData * @returns {Uint8Array} */ - var binaryStringToUint8Array = (jsPDFAPI.__addimage__.binaryStringToUint8Array = function( - binary_string - ) { - var len = binary_string.length; - var bytes = new Uint8Array(len); - for (var i = 0; i < len; i++) { - bytes[i] = binary_string.charCodeAt(i); - } - return bytes; - }); + var binaryStringToUint8Array = + (jsPDFAPI.__addimage__.binaryStringToUint8Array = function ( + binary_string: string + ) { + var len = binary_string.length; + var bytes = new Uint8Array(len); + for (var i = 0; i < len; i++) { + bytes[i] = binary_string.charCodeAt(i); + } + return bytes; + }); /** * Convert the Buffer to a Binary String @@ -737,24 +925,27 @@ import { atob } from "../libs/AtobBtoa.js"; * * @returns {String} */ - var arrayBufferToBinaryString = (jsPDFAPI.__addimage__.arrayBufferToBinaryString = function( - buffer - ) { - var out = ""; - // There are calls with both ArrayBuffer and already converted Uint8Array or other BufferView. - // Do not copy the array if input is already an array. - var buf = isArrayBufferView(buffer) ? buffer : new Uint8Array(buffer); - for (var i = 0; i < buf.length; i += ARRAY_APPLY_BATCH) { - // Limit the amount of characters being parsed to prevent overflow. - // Note that while TextDecoder would be faster, it does not have the same - // functionality as fromCharCode with any provided encodings as of 3/2021. - out += String.fromCharCode.apply( - null, - buf.subarray(i, i + ARRAY_APPLY_BATCH) as any - ); - } - return out; - }); + var arrayBufferToBinaryString = + (jsPDFAPI.__addimage__.arrayBufferToBinaryString = function ( + buffer: ArrayBuffer | ImageTypedArray + ) { + var out = ""; + // There are calls with both ArrayBuffer and already converted Uint8Array or other BufferView. + // Do not copy the array if input is already an array. + var buf = isArrayBufferView(buffer) ? buffer : new Uint8Array(buffer); + for (var i = 0; i < buf.length; i += ARRAY_APPLY_BATCH) { + // Limit the amount of characters being parsed to prevent overflow. + // Note that while TextDecoder would be faster, it does not have the same + // functionality as fromCharCode with any provided encodings as of 3/2021. + out += String.fromCharCode.apply( + null, + // fromCharCode is declared to take number[], but accepts any + // array-like of char codes at runtime. + buf.subarray(i, i + ARRAY_APPLY_BATCH) as unknown as number[] + ); + } + return out; + }); /** * Possible parameter for addImage, an RGBA buffer with size. @@ -785,28 +976,39 @@ import { atob } from "../libs/AtobBtoa.js"; * * @returns jsPDF */ - jsPDFAPI.addImage = function() { + jsPDFAPI.addImage = function ( + this: jsPDFDocument, + arg0: ImageInput | ImageOptions, + arg1?: string | number, + arg2?: number, + arg3?: number, + arg4?: number, + arg5?: number | string, + arg6?: string, + arg7?: string | number, + arg8?: number + ) { var imageData, format, x, y, w, h, alias, compression, rotation; - imageData = arguments[0]; - if (typeof arguments[1] === "number") { + imageData = arg0; + if (typeof arg1 === "number") { format = UNKNOWN; - x = arguments[1]; - y = arguments[2]; - w = arguments[3]; - h = arguments[4]; - alias = arguments[5]; - compression = arguments[6]; - rotation = arguments[7]; + x = arg1; + y = arg2; + w = arg3; + h = arg4; + alias = arg5 as string; + compression = arg6; + rotation = arg7 as number; } else { - format = arguments[1]; - x = arguments[2]; - y = arguments[3]; - w = arguments[4]; - h = arguments[5]; - alias = arguments[6]; - compression = arguments[7]; - rotation = arguments[8]; + format = arg1; + x = arg2; + y = arg3; + w = arg4; + h = arg5 as number; + alias = arg6; + compression = arg7 as string; + rotation = arg8; } if ( @@ -841,7 +1043,7 @@ import { atob } from "../libs/AtobBtoa.js"; var image = processImageData.call( this, - imageData, + imageData as ImageInput, format, alias, compression @@ -852,7 +1054,13 @@ import { atob } from "../libs/AtobBtoa.js"; return this; }; - var processImageData = function(imageData, format, alias, compression) { + var processImageData = function ( + this: jsPDFDocument, + imageData: ImageInput, + format: string, + alias?: number | string, + compression?: string + ) { var result, dataAsBinaryString; if ( @@ -897,11 +1105,15 @@ import { atob } from "../libs/AtobBtoa.js"; if (!result) { // no need to convert if imageData is already uint8array if (!(imageData instanceof Uint8Array) && format !== "RGBA") { - dataAsBinaryString = imageData; - imageData = binaryStringToUint8Array(imageData); + dataAsBinaryString = imageData as string; + imageData = binaryStringToUint8Array(imageData as string); } - result = this["process" + format.toUpperCase()]( + // Dynamic plugin dispatch: the processXXX methods are contributed by + // the individual image-format plugins. + result = (this as unknown as Record)[ + "process" + format.toUpperCase() + ]( imageData, getImageIndex.call(this), alias, @@ -922,36 +1134,37 @@ import { atob } from "../libs/AtobBtoa.js"; * @param {string} stringData * @returns {string} binary string */ - var convertBase64ToBinaryString = (jsPDFAPI.__addimage__.convertBase64ToBinaryString = function( - stringData, - throwError? - ) { - throwError = typeof throwError === "boolean" ? throwError : true; - var imageData = ""; - var rawData; - - if (typeof stringData === "string") { - rawData = extractImageFromDataUrl(stringData) ?? stringData; - - try { - imageData = atob(rawData); - } catch (e) { - if (throwError) { - if (!validateStringAsBase64(rawData)) { - throw new Error( - "Supplied Data is not a valid base64-String jsPDF.convertBase64ToBinaryString " - ); - } else { - throw new Error( - "atob-Error in jsPDF.convertBase64ToBinaryString " + - (e as any).message - ); + var convertBase64ToBinaryString = + (jsPDFAPI.__addimage__.convertBase64ToBinaryString = function ( + stringData: string, + throwError?: boolean + ) { + throwError = typeof throwError === "boolean" ? throwError : true; + var imageData = ""; + var rawData; + + if (typeof stringData === "string") { + rawData = extractImageFromDataUrl(stringData) ?? stringData; + + try { + imageData = atob(rawData); + } catch (e) { + if (throwError) { + if (!validateStringAsBase64(rawData)) { + throw new Error( + "Supplied Data is not a valid base64-String jsPDF.convertBase64ToBinaryString " + ); + } else { + throw new Error( + "atob-Error in jsPDF.convertBase64ToBinaryString " + + (e as Error).message + ); + } } } } - } - return imageData; - }); + return imageData; + }); /** * @name getImageProperties @@ -959,7 +1172,10 @@ import { atob } from "../libs/AtobBtoa.js"; * @param {Object} imageData * @returns {Object} */ - jsPDFAPI.getImageProperties = function(imageData) { + jsPDFAPI.getImageProperties = function ( + this: jsPDFDocument, + imageData: ImageInput + ) { var image; var tmpImageData = ""; var format; @@ -992,10 +1208,14 @@ import { atob } from "../libs/AtobBtoa.js"; } if (!(imageData instanceof Uint8Array)) { - imageData = binaryStringToUint8Array(imageData); + imageData = binaryStringToUint8Array(imageData as string); } - image = this["process" + format.toUpperCase()](imageData); + // Dynamic plugin dispatch: the processXXX methods are contributed by + // the individual image-format plugins. + image = (this as unknown as Record)[ + "process" + format.toUpperCase() + ](imageData); if (!image) { throw new Error("An unknown error occurred whilst processing the image"); diff --git a/src/modules/annotations.ts b/src/modules/annotations.ts index 62c9dd0d8..095d3db59 100644 --- a/src/modules/annotations.ts +++ b/src/modules/annotations.ts @@ -54,11 +54,111 @@ */ import { jsPDF } from "../jspdf.js"; +import type { + AddPagePayload, + jsPDFAPI as JsPDFAPI, + jsPDFDocument, + PageContext, + PutPagePayload, + TextOptionsLight +} from "../types.js"; -(function(jsPDFAPI) { +export interface AnnotationBounds { + x: number; + y: number; + w: number; + h: number; +} + +/** Link-specific options (also accepted by createAnnotation/textWithLink). */ +export interface LinkAnnotationOptions { + name?: string; + url?: string; + pageNumber?: number; + top?: number; + left?: number; + zoom?: number; + magFactor?: "Fit" | "FitH" | "FitV" | "XYZ"; +} + +interface ReferenceAnnotation { + type: "reference"; + object: { objId: number }; +} + +interface TextAnnotation { + type: "text"; + bounds: AnnotationBounds; + contents: string; + title?: string; + open?: boolean; +} + +interface FreeTextAnnotation { + type: "freetext"; + bounds: AnnotationBounds; + contents: string; + color?: string; +} + +interface LinkAnnotation { + type: "link"; + /** Already formatted PDF coordinate strings (see link() below). */ + finalBounds: { x: string; y: string; w: string; h: string }; + options: LinkAnnotationOptions; +} + +/** An entry of `pageContext.annotations`. */ +export type PageAnnotation = + ReferenceAnnotation | TextAnnotation | FreeTextAnnotation | LinkAnnotation; + +/** Options accepted by createAnnotation(). */ +export interface CreateAnnotationOptions extends LinkAnnotationOptions { + type: "link" | "text" | "freetext"; + bounds: AnnotationBounds; + contents?: string; + title?: string; + open?: boolean; + color?: string; +} + +interface PageContextWithAnnotations extends PageContext { + annotations: PageAnnotation[]; +} + +declare module "../types.js" { + interface jsPDFAPI { + createAnnotation(options: CreateAnnotationOptions): void; + link( + x: number, + y: number, + w: number, + h: number, + options: LinkAnnotationOptions + ): void; + textWithLink( + text: string, + x: number, + y: number, + options: TextOptionsLight & LinkAnnotationOptions + ): number; + getTextWidth(text: string): number; + } + interface jsPDFDocument { + /** + * Optional named-destination map consulted for `options.name` links; + * nothing in the core populates it. + */ + annotations?: { + _nameMap: Record; + }; + } +} + +(function (this: void, jsPDFAPI: JsPDFAPI) { "use strict"; - var notEmpty = function(obj) { + var notEmpty = function (obj: unknown): boolean | undefined { if (typeof obj != "undefined") { if (obj != "") { return true; @@ -68,22 +168,23 @@ import { jsPDF } from "../jspdf.js"; jsPDF.API.events.push([ "addPage", - function(addPageData) { + function (this: jsPDFDocument, addPageData: AddPagePayload) { var pageInfo = this.internal.getPageInfo(addPageData.pageNumber); - pageInfo.pageContext.annotations = []; + (pageInfo.pageContext as PageContextWithAnnotations).annotations = []; } ]); jsPDFAPI.events.push([ "putPage", - function(putPageData) { + function (this: jsPDFDocument, putPageData: PutPagePayload) { var getHorizontalCoordinateString = this.internal.getCoordinateString; - var getVerticalCoordinateString = this.internal - .getVerticalCoordinateString; + var getVerticalCoordinateString = + this.internal.getVerticalCoordinateString; var pageInfo = this.internal.getPageInfoByObjId(putPageData.objId); - var pageAnnos = putPageData.pageContext.annotations; + var pageAnnos = (putPageData.pageContext as PageContextWithAnnotations) + .annotations; - var anno, rect, line; + var anno: PageAnnotation, rect: string, line: string; var found = false; for (var a = 0; a < pageAnnos.length && !found; a++) { anno = pageAnnos[a]; @@ -294,7 +395,10 @@ import { jsPDF } from "../jspdf.js"; * @function * @param {Object} options */ - jsPDFAPI.createAnnotation = function(options) { + jsPDFAPI.createAnnotation = function ( + this: jsPDFDocument, + options: CreateAnnotationOptions + ) { var pageInfo = this.internal.getCurrentPageInfo(); switch (options.type) { case "link": @@ -308,7 +412,11 @@ import { jsPDF } from "../jspdf.js"; break; case "text": case "freetext": - pageInfo.pageContext.annotations.push(options); + // The options object doubles as the stored text/freetext annotation + // entry (its `type` was checked above); the assertion names that. + (pageInfo.pageContext as PageContextWithAnnotations).annotations.push( + options as unknown as PageAnnotation + ); break; } }; @@ -327,12 +435,19 @@ import { jsPDF } from "../jspdf.js"; * @param {number} h * @param {Object} options */ - jsPDFAPI.link = function(x, y, w, h, options) { + jsPDFAPI.link = function ( + this: jsPDFDocument, + x: number, + y: number, + w: number, + h: number, + options: LinkAnnotationOptions + ) { var pageInfo = this.internal.getCurrentPageInfo(); var getHorizontalCoordinateString = this.internal.getCoordinateString; var getVerticalCoordinateString = this.internal.getVerticalCoordinateString; - pageInfo.pageContext.annotations.push({ + (pageInfo.pageContext as PageContextWithAnnotations).annotations.push({ finalBounds: { x: getHorizontalCoordinateString(x), y: getVerticalCoordinateString(y), @@ -356,10 +471,16 @@ import { jsPDF } from "../jspdf.js"; * @param {Object} options * @returns {number} width the width of the text/link */ - jsPDFAPI.textWithLink = function(text, x, y, options) { + jsPDFAPI.textWithLink = function ( + this: jsPDFDocument, + text: string, + x: number, + y: number, + options: TextOptionsLight & LinkAnnotationOptions + ) { var totalLineWidth = this.getTextWidth(text); var lineHeight = this.internal.getLineHeight() / this.internal.scaleFactor; - var linkHeight, linkWidth; + var linkHeight: number, linkWidth: number; // Checking if maxWidth option is passed to determine lineWidth and number of lines for each line if (options.maxWidth !== undefined) { @@ -395,7 +516,7 @@ import { jsPDF } from "../jspdf.js"; * @param {string} text * @returns {number} txtWidth */ - jsPDFAPI.getTextWidth = function(text) { + jsPDFAPI.getTextWidth = function (this: jsPDFDocument, text: string) { var fontSize = this.internal.getFontSize(); var txtWidth = (this.getStringUnitWidth(text) * fontSize) / this.internal.scaleFactor; diff --git a/src/modules/arabic.ts b/src/modules/arabic.ts index 3374cd8f7..e5fadf70b 100644 --- a/src/modules/arabic.ts +++ b/src/modules/arabic.ts @@ -7,6 +7,41 @@ */ import { jsPDF } from "../jspdf.js"; +import type { jsPDFAPI as JsPDFAPI, TextProcessingPayload } from "../types.js"; + +/** Nested ligature lookup: char code -> replacement or deeper table. */ +interface LigatureTree { + [code: number]: number | LigatureTree; +} + +/** The helper namespace this plugin exposes as `jsPDF.API.__arabicParser__`. */ +export interface ArabicParserNamespace { + isInArabicSubstitutionA(letter: string): boolean; + isArabicLetter(letter: string): boolean; + isArabicEndLetter(letter: string): boolean; + isArabicAlfLetter(letter: string): boolean; + arabicLetterHasIsolatedForm(letter: string): boolean; + arabicLetterHasFinalForm(letter: string): boolean; + arabicLetterHasInitialForm(letter: string): boolean; + arabicLetterHasMedialForm(letter: string): boolean; + resolveLigatures(letters: string): string; + isArabicDiacritic(letter?: string): boolean; + getCorrectForm( + currentChar: string, + beforeChar: string, + nextChar: string + ): number; + processArabic(text: string): string; + processArabic(payload: TextProcessingPayload): TextProcessingPayload; +} + +declare module "../types.js" { + interface jsPDFAPI { + __arabicParser__: ArabicParserNamespace; + processArabic(text: string): string; + processArabic(payload: TextProcessingPayload): TextProcessingPayload; + } +} /** * jsPDF arabic parser PlugIn @@ -14,14 +49,14 @@ import { jsPDF } from "../jspdf.js"; * @name arabic * @module */ -(function(jsPDFAPI) { +(function (jsPDFAPI: JsPDFAPI) { "use strict"; /** * Arabic shape substitutions: char code => (isolated, final, initial, medial). * Arabic Substition A */ - var arabicSubstitionA = { + var arabicSubstitionA: Record = { 0x0621: [0xfe80], // ARABIC LETTER HAMZA 0x0622: [0xfe81, 0xfe82], // ARABIC LETTER ALEF WITH MADDA ABOVE 0x0623: [0xfe83, 0xfe84], // ARABIC LETTER ALEF WITH HAMZA ABOVE @@ -106,7 +141,7 @@ import { jsPDF } from "../jspdf.js"; }; */ - var ligatures = { + var ligatures: LigatureTree = { 0xfedf: { 0xfe82: 0xfef5, // ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE ISOLATED FORM 0xfe84: 0xfef7, // ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE ISOLATED FORM @@ -129,7 +164,7 @@ import { jsPDF } from "../jspdf.js"; } }; - var arabic_diacritics = { + var arabic_diacritics: Record = { 1612: 64606, // Shadda + Dammatan 1613: 64607, // Shadda + Kasratan 1614: 64608, // Shadda + Fatha @@ -145,17 +180,19 @@ import { jsPDF } from "../jspdf.js"; var initialForm = 2; var medialForm = 3; - jsPDFAPI.__arabicParser__ = {}; + // Created empty here and filled member by member directly below. + jsPDFAPI.__arabicParser__ = {} as ArabicParserNamespace; //private - var isInArabicSubstitutionA = (jsPDFAPI.__arabicParser__.isInArabicSubstitutionA = function( - letter - ) { - return typeof arabicSubstitionA[letter.charCodeAt(0)] !== "undefined"; - }); + var isInArabicSubstitutionA = + (jsPDFAPI.__arabicParser__.isInArabicSubstitutionA = function ( + letter: string + ) { + return typeof arabicSubstitionA[letter.charCodeAt(0)] !== "undefined"; + }); - var isArabicLetter = (jsPDFAPI.__arabicParser__.isArabicLetter = function( - letter + var isArabicLetter = (jsPDFAPI.__arabicParser__.isArabicLetter = function ( + letter: string ) { return ( typeof letter === "string" && @@ -165,25 +202,25 @@ import { jsPDF } from "../jspdf.js"; ); }); - var isArabicEndLetter = (jsPDFAPI.__arabicParser__.isArabicEndLetter = function( - letter - ) { - return ( - isArabicLetter(letter) && - isInArabicSubstitutionA(letter) && - arabicSubstitionA[letter.charCodeAt(0)].length <= 2 - ); - }); - - var isArabicAlfLetter = (jsPDFAPI.__arabicParser__.isArabicAlfLetter = function( - letter + var isArabicEndLetter = (jsPDFAPI.__arabicParser__.isArabicEndLetter = + function (letter: string) { + return ( + isArabicLetter(letter) && + isInArabicSubstitutionA(letter) && + arabicSubstitionA[letter.charCodeAt(0)].length <= 2 + ); + }); + + var isArabicAlfLetter = (jsPDFAPI.__arabicParser__.isArabicAlfLetter = + function (letter: string) { + return ( + isArabicLetter(letter) && alfletter.indexOf(letter.charCodeAt(0)) >= 0 + ); + }); + + jsPDFAPI.__arabicParser__.arabicLetterHasIsolatedForm = function ( + letter: string ) { - return ( - isArabicLetter(letter) && alfletter.indexOf(letter.charCodeAt(0)) >= 0 - ); - }); - - jsPDFAPI.__arabicParser__.arabicLetterHasIsolatedForm = function(letter) { return ( isArabicLetter(letter) && isInArabicSubstitutionA(letter) && @@ -191,17 +228,20 @@ import { jsPDF } from "../jspdf.js"; ); }; - var arabicLetterHasFinalForm = (jsPDFAPI.__arabicParser__.arabicLetterHasFinalForm = function( - letter + var arabicLetterHasFinalForm = + (jsPDFAPI.__arabicParser__.arabicLetterHasFinalForm = function ( + letter: string + ) { + return ( + isArabicLetter(letter) && + isInArabicSubstitutionA(letter) && + arabicSubstitionA[letter.charCodeAt(0)].length >= 2 + ); + }); + + jsPDFAPI.__arabicParser__.arabicLetterHasInitialForm = function ( + letter: string ) { - return ( - isArabicLetter(letter) && - isInArabicSubstitutionA(letter) && - arabicSubstitionA[letter.charCodeAt(0)].length >= 2 - ); - }); - - jsPDFAPI.__arabicParser__.arabicLetterHasInitialForm = function(letter) { return ( isArabicLetter(letter) && isInArabicSubstitutionA(letter) && @@ -209,62 +249,68 @@ import { jsPDF } from "../jspdf.js"; ); }; - var arabicLetterHasMedialForm = (jsPDFAPI.__arabicParser__.arabicLetterHasMedialForm = function( - letter - ) { - return ( - isArabicLetter(letter) && - isInArabicSubstitutionA(letter) && - arabicSubstitionA[letter.charCodeAt(0)].length == 4 - ); - }); - - var resolveLigatures = (jsPDFAPI.__arabicParser__.resolveLigatures = function( - letters - ) { - var i = 0; - var tmpLigatures = ligatures; - var result = ""; - var effectedLetters = 0; - - for (i = 0; i < letters.length; i += 1) { - if (typeof tmpLigatures[letters.charCodeAt(i)] !== "undefined") { - effectedLetters++; - tmpLigatures = tmpLigatures[letters.charCodeAt(i)]; - - if (typeof tmpLigatures === "number") { - result += String.fromCharCode(tmpLigatures); - tmpLigatures = ligatures; - effectedLetters = 0; - } - if (i === letters.length - 1) { + var arabicLetterHasMedialForm = + (jsPDFAPI.__arabicParser__.arabicLetterHasMedialForm = function ( + letter: string + ) { + return ( + isArabicLetter(letter) && + isInArabicSubstitutionA(letter) && + arabicSubstitionA[letter.charCodeAt(0)].length == 4 + ); + }); + + var resolveLigatures = (jsPDFAPI.__arabicParser__.resolveLigatures = + function (letters: string) { + var i = 0; + var tmpLigatures: number | LigatureTree = ligatures; + var result = ""; + var effectedLetters = 0; + + for (i = 0; i < letters.length; i += 1) { + // At the top of each iteration tmpLigatures is always a tree (every + // branch that leaves it as a number resets it to `ligatures` below); + // the assertions record that invariant for the indexed accesses. + if ( + typeof (tmpLigatures as LigatureTree)[letters.charCodeAt(i)] !== + "undefined" + ) { + effectedLetters++; + tmpLigatures = (tmpLigatures as LigatureTree)[letters.charCodeAt(i)]; + + if (typeof tmpLigatures === "number") { + result += String.fromCharCode(tmpLigatures); + tmpLigatures = ligatures; + effectedLetters = 0; + } + if (i === letters.length - 1) { + tmpLigatures = ligatures; + result += letters.charAt(i - (effectedLetters - 1)); + i = i - (effectedLetters - 1); + effectedLetters = 0; + } + } else { tmpLigatures = ligatures; - result += letters.charAt(i - (effectedLetters - 1)); - i = i - (effectedLetters - 1); + result += letters.charAt(i - effectedLetters); + i = i - effectedLetters; effectedLetters = 0; } - } else { - tmpLigatures = ligatures; - result += letters.charAt(i - effectedLetters); - i = i - effectedLetters; - effectedLetters = 0; } - } - return result; - }); + return result; + }); - jsPDFAPI.__arabicParser__.isArabicDiacritic = function(letter) { + jsPDFAPI.__arabicParser__.isArabicDiacritic = function (letter?: string) { return ( letter !== undefined && arabic_diacritics[letter.charCodeAt(0)] !== undefined ); }; - var getCorrectForm = (jsPDFAPI.__arabicParser__.getCorrectForm = function( - currentChar, - beforeChar, - nextChar + var getCorrectForm = (jsPDFAPI.__arabicParser__.getCorrectForm = function ( + currentChar: string, + beforeChar: string, + nextChar: string ) { if (!isArabicLetter(currentChar)) { return -1; @@ -306,7 +352,7 @@ import { jsPDF } from "../jspdf.js"; * @param {string} text * @returns {string} */ - var parseArabic = function(text) { + var parseArabic = function (text: string): string { text = text || ""; var result = ""; @@ -346,33 +392,36 @@ import { jsPDF } from "../jspdf.js"; return result; }; - var processArabic = (jsPDFAPI.__arabicParser__.processArabic = jsPDFAPI.processArabic = function() { - var text = - typeof arguments[0] === "string" ? arguments[0] : arguments[0].text; - var tmpText = []; - var result; - - if (Array.isArray(text)) { - var i = 0; - tmpText = []; - for (i = 0; i < text.length; i += 1) { - if (Array.isArray(text[i])) { - tmpText.push([parseArabic(text[i][0]), text[i][1], text[i][2]]); + var processArabic = + (jsPDFAPI.__arabicParser__.processArabic = + jsPDFAPI.processArabic = + function () { + var text = + typeof arguments[0] === "string" ? arguments[0] : arguments[0].text; + var tmpText = []; + var result; + + if (Array.isArray(text)) { + var i = 0; + tmpText = []; + for (i = 0; i < text.length; i += 1) { + if (Array.isArray(text[i])) { + tmpText.push([parseArabic(text[i][0]), text[i][1], text[i][2]]); + } else { + tmpText.push([parseArabic(text[i])]); + } + } + result = tmpText; } else { - tmpText.push([parseArabic(text[i])]); + result = parseArabic(text); } - } - result = tmpText; - } else { - result = parseArabic(text); - } - if (typeof arguments[0] === "string") { - return result; - } else { - arguments[0].text = result; - return arguments[0]; - } - }); + if (typeof arguments[0] === "string") { + return result; + } else { + arguments[0].text = result; + return arguments[0]; + } + }); jsPDFAPI.events.push(["preProcessText", processArabic]); })(jsPDF.API); diff --git a/src/modules/autoprint.ts b/src/modules/autoprint.ts index 04e15775c..4da4dfd93 100644 --- a/src/modules/autoprint.ts +++ b/src/modules/autoprint.ts @@ -6,12 +6,23 @@ */ import { jsPDF } from "../jspdf.js"; +import type { jsPDFAPI as JsPDFAPI, jsPDFDocument } from "../types.js"; + +export interface AutoPrintOptions { + variant?: "non-conform" | "javascript"; +} + +declare module "../types.js" { + interface jsPDFAPI { + autoPrint(options?: AutoPrintOptions): jsPDFDocument; + } +} /** * @name autoprint * @module */ -(function(jsPDFAPI) { +(function (jsPDFAPI: JsPDFAPI) { "use strict"; /** @@ -27,9 +38,12 @@ import { jsPDF } from "../jspdf.js"; * doc.autoPrint({variant: 'non-conform'}); * doc.save('autoprint.pdf'); */ - jsPDFAPI.autoPrint = function(options) { + jsPDFAPI.autoPrint = function ( + this: jsPDFDocument, + options?: AutoPrintOptions + ) { "use strict"; - var refAutoPrintTag; + var refAutoPrintTag: number | undefined; options = options || {}; options.variant = options.variant || "non-conform"; @@ -40,19 +54,25 @@ import { jsPDF } from "../jspdf.js"; break; case "non-conform": default: - this.internal.events.subscribe("postPutResources", function() { - refAutoPrintTag = this.internal.newObject(); - this.internal.out("<<"); - this.internal.out("/S /Named"); - this.internal.out("/Type /Action"); - this.internal.out("/N /Print"); - this.internal.out(">>"); - this.internal.out("endobj"); - }); + this.internal.events.subscribe( + "postPutResources", + function (this: jsPDFDocument) { + refAutoPrintTag = this.internal.newObject(); + this.internal.out("<<"); + this.internal.out("/S /Named"); + this.internal.out("/Type /Action"); + this.internal.out("/N /Print"); + this.internal.out(">>"); + this.internal.out("endobj"); + } + ); - this.internal.events.subscribe("putCatalog", function() { - this.internal.out("/OpenAction " + refAutoPrintTag + " 0 R"); - }); + this.internal.events.subscribe( + "putCatalog", + function (this: jsPDFDocument) { + this.internal.out("/OpenAction " + refAutoPrintTag + " 0 R"); + } + ); break; } return this; diff --git a/src/modules/bmp_support.ts b/src/modules/bmp_support.ts index bdd41ded3..1c5235cd3 100644 --- a/src/modules/bmp_support.ts +++ b/src/modules/bmp_support.ts @@ -1,6 +1,19 @@ import { JPEGEncoder } from "../libs/JPEGEncoder.js"; import { BmpDecoder } from "../libs/BMPDecoder.js"; import { jsPDF } from "../jspdf.js"; +import type { jsPDFAPI as JsPDFAPI, jsPDFDocument } from "../types.js"; +import type { ImageCompression, ImageProperties } from "./addimage.js"; + +declare module "../types.js" { + interface jsPDFAPI { + processBMP( + imageData?: unknown, + index?: number, + alias?: number | string, + compression?: ImageCompression + ): ImageProperties; + } +} /** * @license @@ -15,10 +28,16 @@ import { jsPDF } from "../jspdf.js"; * @name bmp_support * @module */ -(function(jsPDFAPI) { +(function (jsPDFAPI: JsPDFAPI) { "use strict"; - jsPDFAPI.processBMP = function(imageData, index, alias, compression) { + jsPDFAPI.processBMP = function ( + this: jsPDFDocument, + imageData: Uint8Array, + index?: number, + alias?: number | string, + compression?: ImageCompression + ) { var reader = new BmpDecoder(imageData, false); var width = reader.width, height = reader.height; diff --git a/src/modules/canvas.ts b/src/modules/canvas.ts index ba008578d..6fdd1733b 100644 --- a/src/modules/canvas.ts +++ b/src/modules/canvas.ts @@ -7,6 +7,35 @@ */ import { jsPDF } from "../jspdf.js"; +import type { jsPDFAPI as JsPDFAPI, jsPDFDocument } from "../types.js"; + +/** The canvas-like wrapper installed on every document as `doc.canvas`. */ +export interface CanvasShim { + pdf: jsPDFDocument; + width: number; + height: number; + childNodes: unknown[]; + style: Record; + parentNode: undefined; + getContext( + contextType?: string, + contextAttributes?: Record + ): jsPDFDocument["context2d"] | null; + toDataURL(): string; +} + +/** Static side of the classic constructor function below. */ +interface CanvasShimConstructor { + new (): CanvasShim; + prototype: CanvasShim; +} + +declare module "../types.js" { + interface jsPDFDocument { + /** The Canvas wrapper for this document, assigned on "initialized". */ + canvas: CanvasShim; + } +} /** * jsPDF Canvas PlugIn @@ -16,20 +45,22 @@ import { jsPDF } from "../jspdf.js"; * @name canvas * @module */ -(function(jsPDFAPI) { +(function (this: void, jsPDFAPI: JsPDFAPI) { "use strict"; /** * @class Canvas * @classdesc A Canvas Wrapper for jsPDF */ - var Canvas = function() { - var jsPdfInstance = undefined; + // A classic constructor function carries no construct signature in its + // inferred type; the assertion reinstates the `new`-able shape. + var Canvas = function (this: CanvasShim) { + var jsPdfInstance: jsPDFDocument | undefined = undefined; Object.defineProperty(this, "pdf", { - get: function() { + get: function () { return jsPdfInstance; }, - set: function(value) { + set: function (value: jsPDFDocument) { jsPdfInstance = value; } }); @@ -42,10 +73,10 @@ import { jsPDF } from "../jspdf.js"; * @name width */ Object.defineProperty(this, "width", { - get: function() { + get: function () { return _width; }, - set: function(value) { + set: function (this: CanvasShim, value: number) { if (isNaN(value) || Number.isInteger(value) === false || value < 0) { _width = 150; } else { @@ -65,10 +96,10 @@ import { jsPDF } from "../jspdf.js"; * @name height */ Object.defineProperty(this, "height", { - get: function() { + get: function () { return _height; }, - set: function(value) { + set: function (this: CanvasShim, value: number) { if (isNaN(value) || Number.isInteger(value) === false || value < 0) { _height = 300; } else { @@ -80,28 +111,28 @@ import { jsPDF } from "../jspdf.js"; } }); - var _childNodes = []; + var _childNodes: unknown[] = []; Object.defineProperty(this, "childNodes", { - get: function() { + get: function () { return _childNodes; }, - set: function(value) { + set: function (value: unknown[]) { _childNodes = value; } }); - var _style = {}; + var _style: Record = {}; Object.defineProperty(this, "style", { - get: function() { + get: function () { return _style; }, - set: function(value) { + set: function (value: Record) { _style = value; } }); Object.defineProperty(this, "parentNode", {}); - }; + } as unknown as CanvasShimConstructor; /** * The getContext() method returns a drawing context on the canvas, or null if the context identifier is not supported. @@ -111,19 +142,28 @@ import { jsPDF } from "../jspdf.js"; * @param {string} contextType Is a String containing the context identifier defining the drawing context associated to the canvas. Possible value is "2d", leading to the creation of a Context2D object representing a two-dimensional rendering context. * @param {object} contextAttributes */ - Canvas.prototype.getContext = function(contextType, contextAttributes) { + Canvas.prototype.getContext = function ( + this: CanvasShim, + contextType?: string, + contextAttributes?: Record + ) { contextType = contextType || "2d"; - var key; + var key: string; if (contextType !== "2d") { return null; } for (key in contextAttributes) { if (this.pdf.context2d.hasOwnProperty(key)) { - this.pdf.context2d[key] = contextAttributes[key]; + // Copies arbitrary, caller-provided attributes onto the context; + // dynamic by design, hence the indexable view of the instance. + (this.pdf.context2d as unknown as Record)[key] = + contextAttributes[key]; } } - this.pdf.context2d._canvas = this; + // `_canvas` is an expando the canvas plugin stashes on the context; it is + // not part of the Context2D class surface. + (this.pdf.context2d as unknown as { _canvas: CanvasShim })._canvas = this; return this.pdf.context2d; }; @@ -133,13 +173,13 @@ import { jsPDF } from "../jspdf.js"; * @name toDataURL * @function */ - Canvas.prototype.toDataURL = function() { + Canvas.prototype.toDataURL = function () { throw new Error("toDataURL is not implemented."); }; jsPDFAPI.events.push([ "initialized", - function() { + function (this: jsPDFDocument) { this.canvas = new Canvas(); this.canvas.pdf = this; } diff --git a/src/modules/canvg.d.ts b/src/modules/canvg.d.ts new file mode 100644 index 000000000..8ba37812b --- /dev/null +++ b/src/modules/canvg.d.ts @@ -0,0 +1,32 @@ +/** + * Minimal ambient typing for the optional "canvg" dependency used by + * src/modules/svg.ts. + * + * The installed canvg package declares `"types": "lib/index.d.ts"`, but its + * package.json "exports" map lacks a "types" condition, so under this + * repository's `moduleResolution: "bundler"` the module resolves to the + * untyped `lib/index.es.js` (TS7016). This shim declares only the surface + * that src/modules/svg.ts actually consumes. + */ +declare module "canvg" { + export interface CanvgRenderOptions { + ignoreMouse?: boolean; + ignoreAnimation?: boolean; + ignoreDimensions?: boolean; + } + + export interface CanvgInstance { + render(options?: CanvgRenderOptions): Promise; + } + + export interface CanvgStatic { + fromString( + ctx: CanvasRenderingContext2D, + svg: string, + options?: CanvgRenderOptions + ): CanvgInstance; + } + + const Canvg: CanvgStatic; + export default Canvg; +} diff --git a/src/modules/cell.ts b/src/modules/cell.ts index ffecaf99b..1bdc89488 100644 --- a/src/modules/cell.ts +++ b/src/modules/cell.ts @@ -30,111 +30,108 @@ */ import { jsPDF } from "../jspdf.js"; +import type { + Font, + jsPDFAPI as jsPDFAPIType, + jsPDFDocument +} from "../types.js"; /** - * @name cell - * @module + * The margin box used by the cell plugin. `width` is the usable page width + * and is filled in lazily by the plugin itself. */ -(function(jsPDFAPI) { - "use strict"; - - var NO_MARGINS = { left: 0, top: 0, bottom: 0, right: 0 }; - - var px2pt = (0.264583 * 72) / 25.4; - var printingHeaderRow = false; - - var _initialize = function() { - if (typeof this.internal.__cell__ === "undefined") { - this.internal.__cell__ = {}; - this.internal.__cell__.padding = 3; - this.internal.__cell__.headerFunction = undefined; - this.internal.__cell__.margins = Object.assign({}, NO_MARGINS); - this.internal.__cell__.margins.width = this.getPageWidth(); - _reset.call(this); - } +export interface CellMargins { + left?: number; + top?: number; + bottom?: number; + right?: number; + width?: number; +} + +/** Column definition accepted by `table()` (adapted from types/index.d.ts). */ +export interface CellConfig { + name: string; + prompt?: string; + align?: string; + padding?: number; + width?: number; +} + +export interface TableRowData { + row: number; + data: Record; +} + +export interface TableCellData { + row: number; + col: number; + data: string; +} + +/** Options accepted by `table()` (adapted from types/index.d.ts). */ +export interface TableConfig { + printHeaders?: boolean; + autoSize?: boolean; + margins?: CellMargins; + fontSize?: number; + padding?: number; + headerBackgroundColor?: string; + headerTextColor?: string; + rowStart?: (e: TableRowData, doc: jsPDFDocument) => void; + cellStart?: (e: TableCellData, doc: jsPDFDocument) => void; + css?: { + "font-size": number; }; +} - var _reset = function() { - this.internal.__cell__.lastCell = new Cell(); - this.internal.__cell__.pages = 1; - }; +/** Returns `[x, y, width, height]` for the header row's last-cell position. */ +export type CellHeaderFunction = ( + doc: jsPDFDocument, + pages: number +) => number[]; - var Cell: any = function() { - var _x = arguments[0]; - Object.defineProperty(this, "x", { - enumerable: true, - get: function() { - return _x; - }, - set: function(value) { - _x = value; - } - }); - var _y = arguments[1]; - Object.defineProperty(this, "y", { - enumerable: true, - get: function() { - return _y; - }, - set: function(value) { - _y = value; - } - }); - var _width = arguments[2]; - Object.defineProperty(this, "width", { - enumerable: true, - get: function() { - return _width; - }, - set: function(value) { - _width = value; - } - }); - var _height = arguments[3]; - Object.defineProperty(this, "height", { - enumerable: true, - get: function() { - return _height; - }, - set: function(value) { - _height = value; - } - }); - var _text = arguments[4]; - Object.defineProperty(this, "text", { - enumerable: true, - get: function() { - return _text; - }, - set: function(value) { - _text = value; - } - }); - var _lineNumber = arguments[5]; - Object.defineProperty(this, "lineNumber", { - enumerable: true, - get: function() { - return _lineNumber; - }, - set: function(value) { - _lineNumber = value; - } - }); - var _align = arguments[6]; - Object.defineProperty(this, "align", { - enumerable: true, - get: function() { - return _align; - }, - set: function(value) { - _align = value; - } - }); +export interface GetTextDimensionsOptions { + font?: Font; + fontSize?: number; + maxWidth?: number; + scaleFactor?: number; +} - return this; - }; - - Cell.prototype.clone = function() { +/** + * A single cell of the cell/table plugin. + * + * Historically this was an `arguments`-based constructor function defining + * accessor properties; it is now a plain class with the same observable + * shape (enumerable own `x`/`y`/`width`/`height`/`text`/`lineNumber`/`align`). + */ +export class Cell { + declare x?: number; + declare y?: number; + declare width?: number; + declare height?: number; + declare text?: string | string[]; + declare lineNumber?: number; + declare align?: string; + + constructor( + x?: number, + y?: number, + width?: number, + height?: number, + text?: string | string[], + lineNumber?: number, + align?: string + ) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + this.text = text; + this.lineNumber = lineNumber; + this.align = align; + } + + clone(): Cell { return new Cell( this.x, this.y, @@ -144,9 +141,9 @@ import { jsPDF } from "../jspdf.js"; this.lineNumber, this.align ); - }; + } - Cell.prototype.toArray = function() { + toArray(): Array { return [ this.x, this.y, @@ -156,6 +153,101 @@ import { jsPDF } from "../jspdf.js"; this.lineNumber, this.align ]; + } +} + +/** Internal state stashed on `doc.internal.__cell__` by this plugin. */ +export interface CellState { + padding?: number; + headerFunction?: CellHeaderFunction; + margins?: CellMargins; + lastCell?: Cell; + pages?: number; + tableHeaderRow?: Cell[]; + printHeaders?: boolean; + table_font_size?: number; + headerBackgroundColor?: string; + headerTextColor?: string; + table_x?: number; + table_y?: number; +} + +declare module "../types.js" { + interface jsPDFInternal { + __cell__?: CellState; + } + + interface jsPDFAPI { + setHeaderFunction(func: CellHeaderFunction): jsPDFDocument; + getTextDimensions( + text: string | string[] | number, + options?: GetTextDimensionsOptions + ): { w: number; h: number }; + cellAddPage(): jsPDFDocument; + cell( + x: number, + y: number, + width: number, + height: number, + text: string, + lineNumber: number, + align: string + ): jsPDFDocument; + table( + x: number, + y: number, + data: Array>, + headers: string[] | CellConfig[], + config?: TableConfig + ): jsPDFDocument; + setTableHeaderRow(config: Cell[]): void; + printHeaderRow(lineNumber: number, new_page?: boolean): void; + + // Provided by src/modules/split_text_to_size.ts; declared here so this + // module typechecks independently (merged declarations become overloads). + splitTextToSize( + text: string | string[], + maxlen: number, + options?: Record + ): string[]; + getStringUnitWidth( + text: string, + options?: { + font?: Font; + fontSize?: number; + charSpace?: number; + doKerning?: boolean; + } + ): number; + } +} + +/** + * @name cell + * @module + */ +(function (jsPDFAPI: jsPDFAPIType) { + "use strict"; + + var NO_MARGINS: CellMargins = { left: 0, top: 0, bottom: 0, right: 0 }; + + var px2pt = (0.264583 * 72) / 25.4; + var printingHeaderRow = false; + + var _initialize = function (this: jsPDFDocument) { + if (typeof this.internal.__cell__ === "undefined") { + this.internal.__cell__ = {}; + this.internal.__cell__.padding = 3; + this.internal.__cell__.headerFunction = undefined; + this.internal.__cell__.margins = Object.assign({}, NO_MARGINS); + this.internal.__cell__.margins.width = this.getPageWidth(); + _reset.call(this); + } + }; + + var _reset = function (this: jsPDFDocument) { + this.internal.__cell__.lastCell = new Cell(); + this.internal.__cell__.pages = 1; }; /** @@ -163,7 +255,10 @@ import { jsPDF } from "../jspdf.js"; * @function * @param {function} func */ - jsPDFAPI.setHeaderFunction = function(func) { + jsPDFAPI.setHeaderFunction = function ( + this: jsPDFDocument, + func: CellHeaderFunction + ) { _initialize.call(this); this.internal.__cell__.headerFunction = typeof func === "function" ? func : undefined; @@ -176,7 +271,11 @@ import { jsPDF } from "../jspdf.js"; * @param {string} txt * @returns {Object} dimensions */ - jsPDFAPI.getTextDimensions = function(text, options) { + jsPDFAPI.getTextDimensions = function ( + this: jsPDFDocument, + text: string | string[] | number, + options?: GetTextDimensionsOptions + ) { _initialize.call(this); options = options || {}; var fontSize = options.fontSize || this.getFontSize(); @@ -203,7 +302,10 @@ import { jsPDF } from "../jspdf.js"; if (typeof text === "string") { text = this.splitTextToSize(text, maxWidth); } else if (Object.prototype.toString.call(text) === "[object Array]") { - text = text.reduce(function(acc, textLine) { + text = (text as string[]).reduce(function ( + acc: string[], + textLine: string + ) { return acc.concat(scope.splitTextToSize(textLine, maxWidth)); }, []); } @@ -237,7 +339,7 @@ import { jsPDF } from "../jspdf.js"; * @name cellAddPage * @function */ - jsPDFAPI.cellAddPage = function() { + jsPDFAPI.cellAddPage = function (this: jsPDFDocument) { _initialize.call(this); this.addPage(); @@ -266,21 +368,22 @@ import { jsPDF } from "../jspdf.js"; * @param {string} align * @return {jsPDF} jsPDF-instance */ - var cell: any = (jsPDFAPI.cell = function() { + var cell = function ( + this: jsPDFDocument, + x?: number | Cell, + y?: number, + width?: number, + height?: number, + text?: string | string[], + lineNumber?: number, + align?: string + ) { var currentCell; - if (arguments[0] instanceof Cell) { - currentCell = arguments[0]; + if (x instanceof Cell) { + currentCell = x; } else { - currentCell = new Cell( - arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6] - ); + currentCell = new Cell(x, y, width, height, text, lineNumber, align); } _initialize.call(this); var lastCell = this.internal.__cell__.lastCell; @@ -353,7 +456,8 @@ import { jsPDF } from "../jspdf.js"; } this.internal.__cell__.lastCell = currentCell; return this; - }); + }; + jsPDFAPI.cell = cell; /** * Create a table from a set of data. @@ -376,7 +480,14 @@ import { jsPDF } from "../jspdf.js"; * @returns {jsPDF} jsPDF-instance */ - jsPDFAPI.table = function(x, y, data, headers, config) { + jsPDFAPI.table = function ( + this: jsPDFDocument, + x: number, + y: number, + data: Array>, + headers: string[] | CellConfig[], + config?: TableConfig + ) { _initialize.call(this); if (!data) { throw new Error("No data for PDF table."); @@ -384,16 +495,16 @@ import { jsPDF } from "../jspdf.js"; config = config || {}; - var headerNames = [], - headerLabels = [], - headerAligns = [], + var headerNames: string[] = [], + headerLabels: string[] = [], + headerAligns: string[] = [], i, - columnMatrix = {}, - columnWidths = {}, + columnMatrix: Record = {}, + columnWidths: Record = {}, column, - columnMinWidths = [], + columnMinWidths: number[] = [], j, - tableHeaderConfigs = [], + tableHeaderConfigs: Cell[] = [], //set up defaults. If a value is provided in config, defaults will be overwritten: autoSize = config.autoSize || false, printHeaders = config.printHeaders === false ? false : true, @@ -423,27 +534,28 @@ import { jsPDF } from "../jspdf.js"; // No headers defined so we derive from data headerNames = Object.keys(data[0]); headerLabels = headerNames; - headerAligns = headerNames.map(function() { + headerAligns = headerNames.map(function () { return "left"; }); } else if (Array.isArray(headers) && typeof headers[0] === "object") { - headerNames = headers.map(function(header) { + var headerConfigs = headers as CellConfig[]; + headerNames = headerConfigs.map(function (header) { return header.name; }); - headerLabels = headers.map(function(header) { + headerLabels = headerConfigs.map(function (header) { return header.prompt || header.name || ""; }); - headerAligns = headers.map(function(header) { + headerAligns = headerConfigs.map(function (header) { return header.align || "left"; }); // Split header configs into names and prompts - for (i = 0; i < headers.length; i += 1) { - columnWidths[headers[i].name] = headers[i].width * px2pt; + for (i = 0; i < headerConfigs.length; i += 1) { + columnWidths[headerConfigs[i].name] = headerConfigs[i].width * px2pt; } } else if (Array.isArray(headers) && typeof headers[0] === "string") { - headerNames = headers; + headerNames = headers as string[]; headerLabels = headerNames; - headerAligns = headerNames.map(function() { + headerAligns = headerNames.map(function () { return "left"; }); } @@ -452,13 +564,13 @@ import { jsPDF } from "../jspdf.js"; autoSize || (Array.isArray(headers) && typeof headers[0] === "string") ) { - var headerName; + var headerName: string; for (i = 0; i < headerNames.length; i += 1) { headerName = headerNames[i]; // Create a matrix of columns e.g., {column_title: [row1_Record, row2_Record]} - columnMatrix[headerName] = data.map(function(rec) { + columnMatrix[headerName] = data.map(function (rec) { return rec[headerName]; }); @@ -495,7 +607,7 @@ import { jsPDF } from "../jspdf.js"; // -- Construct the table if (printHeaders) { - var row = {}; + var row: Record = {}; for (i = 0; i < headerNames.length; i += 1) { row[headerNames[i]] = {}; row[headerNames[i]].text = headerLabels[i]; @@ -505,7 +617,7 @@ import { jsPDF } from "../jspdf.js"; var rowHeight = calculateLineHeight.call(this, row, columnWidths); // Construct the header row - tableHeaderConfigs = headerNames.map(function(value) { + tableHeaderConfigs = headerNames.map(function (value) { return new Cell( x, y, @@ -526,7 +638,12 @@ import { jsPDF } from "../jspdf.js"; // Construct the data rows - var align = headers.reduce(function(pv, cv) { + // Note: with string[] headers `cv.name` is undefined at runtime, so the + // lookup below yields undefined aligns — preserved legacy behavior. + var align = (headers as CellConfig[]).reduce(function ( + pv: Record, + cv + ) { pv[cv.name] = cv.align; return pv; }, {}); @@ -583,27 +700,33 @@ import { jsPDF } from "../jspdf.js"; * @returns {number} lineHeight * @private */ - var calculateLineHeight = function calculateLineHeight(model, columnWidths) { + var calculateLineHeight = function calculateLineHeight( + this: jsPDFDocument, + model: Record, + columnWidths: Record + ): number { var padding = this.internal.__cell__.padding; var fontSize = this.internal.__cell__.table_font_size; var scaleFactor = this.internal.scaleFactor; return Object.keys(model) - .map(function(key) { + .map(function (this: jsPDFDocument, key) { var value = model[key]; return this.splitTextToSize( - value.hasOwnProperty("text") ? value.text : value, + value.hasOwnProperty("text") + ? (value as { text: string | string[] }).text + : (value as string), columnWidths[key] - padding - padding ); }, this) - .map(function(value) { + .map(function (this: jsPDFDocument, value) { return ( (this.getLineHeightFactor() * value.length * fontSize) / scaleFactor + padding + padding ); }, this) - .reduce(function(pv, cv) { + .reduce(function (pv, cv) { return Math.max(pv, cv); }, 0); }; @@ -617,7 +740,7 @@ import { jsPDF } from "../jspdf.js"; * An array of cell configs that would define a header row: Each config matches the config used by jsPDFAPI.cell * except the lineNumber parameter is excluded */ - jsPDFAPI.setTableHeaderRow = function(config) { + jsPDFAPI.setTableHeaderRow = function (this: jsPDFDocument, config: Cell[]) { _initialize.call(this); this.internal.__cell__.tableHeaderRow = config; }; @@ -630,7 +753,11 @@ import { jsPDF } from "../jspdf.js"; * @param {number} lineNumber The line number to output the header at * @param {boolean} new_page */ - jsPDFAPI.printHeaderRow = function(lineNumber, new_page) { + jsPDFAPI.printHeaderRow = function ( + this: jsPDFDocument, + lineNumber: number, + new_page?: boolean + ) { _initialize.call(this); if (!this.internal.__cell__.tableHeaderRow) { throw new Error("Property tableHeaderRow does not exist."); @@ -655,7 +782,7 @@ import { jsPDF } from "../jspdf.js"; } this.setFont(undefined, "bold"); - var tempHeaderConf = []; + var tempHeaderConf: Cell[] = []; for (var i = 0; i < this.internal.__cell__.tableHeaderRow.length; i += 1) { tableHeaderCell = this.internal.__cell__.tableHeaderRow[i].clone(); if (new_page) { diff --git a/src/modules/context2d.ts b/src/modules/context2d.ts index 3a1310138..e1f3a8023 100644 --- a/src/modules/context2d.ts +++ b/src/modules/context2d.ts @@ -15,18 +15,186 @@ import { parseFontFamily, resolveFontFace } from "../libs/fontFace.js"; +import type { FontFaceInput, FontFaceMap } from "../libs/fontFace.js"; +import type { ImageProperties } from "./addimage.js"; +import type { + jsPDFAPI as JsPDFAPI, + jsPDFDocument, + Font, + Matrix as MatrixType, + MatrixConstructor, + PointType, + PointConstructor, + RectangleType, + RectangleConstructor +} from "../types.js"; + +declare module "../types.js" { + interface jsPDFAPI { + // Provided by the addimage plugin (src/modules/addimage.ts). Declared + // with the full return shape so this (earlier-merged) overload does not + // shadow the richer one addimage.ts declares. + getImageProperties(imageData: unknown): ImageProperties; + addImage( + imageData: unknown, + format: string, + x: number, + y: number, + w: number, + h: number, + alias?: string | null, + compression?: string | null, + rotation?: number + ): jsPDFDocument; + // Provided by the cell plugin (src/modules/cell.ts). + getTextDimensions(text: string): { w: number; h: number }; + // Provided by the split_text_to_size plugin. + getStringUnitWidth(text: string): number; + splitTextToSize(text: string, maxlen: number): string[]; + } + interface jsPDFDocument { + /** The Context2D instance for this document, assigned on "initialized". */ + context2d: Context2D; + /** Core alias of setLineDashPattern (see src/jspdf.ts). */ + setLineDash(dashArray?: number[], dashPhase?: number): jsPDFDocument; + /** Core alias of setLineMiterLimit (see src/jspdf.ts). */ + setMiterLimit(length: number): jsPDFDocument; + // encodeColorString in src/jspdf.ts accepts an alpha descriptor object as + // the fourth channel argument; context2d relies on that. + setFillColor( + ch1: number, + ch2: number, + ch3: number, + options: { a: number } + ): jsPDFDocument; + setTextColor( + ch1: number, + ch2: number, + ch3: number, + options: { a: number } + ): jsPDFDocument; + } + interface jsPDFInternal { + // The core getFont supports a noFallback option and then may return + // undefined (see getFont in src/jspdf.ts). + getFont( + fontName: string, + fontStyle: string, + options: { noFallback?: boolean; disableWarning?: boolean } + ): Font | undefined; + } +} /** - * This plugin mimics the HTML5 CanvasRenderingContext2D. - * - * The goal is to provide a way for current canvas implementations to print directly to a PDF. - * - * @name context2d - * @module + * An entry of the internal path array. Depending on `type`, only a subset of + * the coordinate members is present (see the push sites in Context2D). */ -(function(jsPDFAPI) { - "use strict"; - var ContextLayer: any = function(ctx?) { +interface PathEntry { + type?: string; + x?: number; + y?: number; + w?: number; + h?: number; + x1?: number; + y1?: number; + x2?: number; + y2?: number; + radius?: number; + startAngle?: number; + endAngle?: number; + counterclockwise?: boolean; +} + +/** Aggregated drawing move built by drawPaths from the path entries. */ +interface PathMove { + begin?: boolean; + close?: boolean; + arc?: boolean; + start?: PathEntry; + deltas?: number[][]; + abs?: PathEntry[]; +} + +/** Minimal canvas gradient stand-in returned by createLinearGradient & co. */ +interface CanvasGradientStub { + colorStops: Array<[number, string]>; + addColorStop(offset: number, color: string): void; + getColor(): string; + isCanvasGradient: true; +} + +/** Cubic bezier segment approximating part of an arc (see createSmallArc). */ +interface ArcCurve { + x1: number; + y1: number; + x2: number; + y2: number; + x3: number; + y3: number; + x4: number; + y4: number; +} + +interface RGBAResult { + r: number; + g: number; + b: number; + a: number; + style: string; +} + +interface PutTextOptions { + text: string; + x: number; + y: number; + scale: number; + angle: number; + align: string; + maxWidth?: number; + renderingMode?: "stroke"; +} + +//stubs, wired to the document internals on the "initialized" event +var f2: (value: number) => string, + getHorizontalCoordinateString: (value: number) => string, + getVerticalCoordinateString: (value: number) => string, + getHorizontalCoordinate: (value: number) => number, + getVerticalCoordinate: (value: number) => number, + Point: PointConstructor, + Rectangle: RectangleConstructor, + Matrix: MatrixConstructor, + _ctx: ContextLayer; + +class ContextLayer { + declare isStrokeTransparent: boolean; + declare strokeOpacity: number; + declare strokeStyle: string; + declare fillStyle: string; + declare isFillTransparent: boolean; + declare fillOpacity: number; + declare font: string; + declare textBaseline: string; + declare textAlign: string; + declare lineWidth: number; + declare lineJoin: string; + declare lineCap: string; + declare path: PathEntry[]; + declare transform: MatrixType; + declare globalCompositeOperation: string; + declare globalAlpha: number; + declare clip_path: PathEntry[]; + declare currentPoint: PointType; + declare miterLimit: number; + declare lastPoint: PointType; + declare lineDashOffset: number; + declare lineDash: number[]; + declare margin: number[]; + declare prevPageLastElemOffset: number; + declare ignoreClearRect: boolean; + /** Stashed by Context2D#save(). */ + declare fontSize?: number; + + constructor(ctx?: Partial) { ctx = ctx || {}; this.isStrokeTransparent = ctx.isStrokeTransparent || false; this.strokeOpacity = ctx.strokeOpacity || 1; @@ -58,46 +226,82 @@ import { this.ignoreClearRect = typeof ctx.ignoreClearRect === "boolean" ? ctx.ignoreClearRect : true; - return this; - }; - - //stub - var f2, - getHorizontalCoordinateString, - getVerticalCoordinateString, - getHorizontalCoordinate, - getVerticalCoordinate, - Point, - Rectangle, - Matrix, - _ctx; - jsPDFAPI.events.push([ - "initialized", - function() { - this.context2d = new Context2D(this); - - f2 = this.internal.f2; - getHorizontalCoordinateString = this.internal.getCoordinateString; - getVerticalCoordinateString = this.internal.getVerticalCoordinateString; - getHorizontalCoordinate = this.internal.getHorizontalCoordinate; - getVerticalCoordinate = this.internal.getVerticalCoordinate; - Point = this.internal.Point; - Rectangle = this.internal.Rectangle; - Matrix = this.internal.Matrix; - _ctx = new ContextLayer(); - } - ]); + } +} + +/** Return value of Context2D#measureText(). */ +class TextMetrics { + declare readonly width: number; + + constructor(options?: { width?: number }) { + options = options || {}; + var _width = options.width || 0; + Object.defineProperty(this, "width", { + get: function (): number { + return _width; + } + }); + } +} - var Context2D = function(pdf) { +/** + * This plugin mimics the HTML5 CanvasRenderingContext2D. + * + * The goal is to provide a way for current canvas implementations to print directly to a PDF. + * + * @name context2d + * @module + */ +class Context2D { + // The members below are backed by Object.defineProperty accessors created + // in the constructor (several of them proxy the shared module-level `_ctx` + // layer, faithful to the original implementation); `declare` only provides + // their types and emits no runtime code. + declare readonly canvas: { parentNode: boolean; style: boolean }; + declare readonly pdf: jsPDFDocument; + declare pageWrapXEnabled: boolean; + declare pageWrapYEnabled: boolean; + declare posX: number; + declare posY: number; + declare margin: number[]; + declare autoPaging: boolean | "slice" | "text"; + declare lastBreak: number; + declare pageBreaks: number[]; + declare ctx: ContextLayer; + declare path: PathEntry[]; + declare ctxStack: ContextLayer[]; + declare fillStyle: string | CanvasGradientStub; + declare strokeStyle: string | CanvasGradientStub; + declare lineCap: string; + declare lineWidth: number; + declare lineJoin: string; + declare miterLimit: number; + declare textBaseline: string; + declare textAlign: string; + declare fontFaces: FontFaceInput[] | null; + declare font: string; + declare globalCompositeOperation: string; + declare globalAlpha: number; + declare lineDashOffset: number; + declare lineDash: number[]; + declare ignoreClearRect: boolean; + /** Last line dash state written to the PDF (see setLineDash below). */ + declare prevLineDash?: string; + /** Assigned by the canvas plugin (src/modules/canvas.ts). */ + declare pageWrapX: number; + /** Assigned by the canvas plugin (src/modules/canvas.ts). */ + declare pageWrapY: number; + + constructor(pdf: jsPDFDocument) { Object.defineProperty(this, "canvas", { - get: function() { + get: function () { return { parentNode: false, style: false }; } }); var _pdf = pdf; Object.defineProperty(this, "pdf", { - get: function() { + get: function () { return _pdf; } }); @@ -109,10 +313,10 @@ import { * @default false */ Object.defineProperty(this, "pageWrapXEnabled", { - get: function() { + get: function () { return _pageWrapXEnabled; }, - set: function(value) { + set: function (value: boolean) { _pageWrapXEnabled = Boolean(value); } }); @@ -124,10 +328,10 @@ import { * @default true */ Object.defineProperty(this, "pageWrapYEnabled", { - get: function() { + get: function () { return _pageWrapYEnabled; }, - set: function(value) { + set: function (value: boolean) { _pageWrapYEnabled = Boolean(value); } }); @@ -139,10 +343,10 @@ import { * @default 0 */ Object.defineProperty(this, "posX", { - get: function() { + get: function () { return _posX; }, - set: function(value) { + set: function (value: number) { if (!isNaN(value)) { _posX = value; } @@ -156,10 +360,10 @@ import { * @default 0 */ Object.defineProperty(this, "posY", { - get: function() { + get: function () { return _posY; }, - set: function(value) { + set: function (value: number) { if (!isNaN(value)) { _posY = value; } @@ -173,11 +377,11 @@ import { * @default [0, 0, 0, 0] */ Object.defineProperty(this, "margin", { - get: function() { + get: function () { return _ctx.margin; }, - set: function(value) { - var margin; + set: function (value: number | number[]) { + var margin: number[]; if (typeof value === "number") { margin = [value, value, value, value]; } else { @@ -191,7 +395,7 @@ import { } }); - var _autoPaging = false; + var _autoPaging: boolean | "slice" | "text" = false; /** * Gets or sets the auto paging mode. When auto paging is enabled, the context2d will automatically draw on the * next page if a shape or text chunk doesn't fit entirely on the current page. The context2d will create new @@ -216,10 +420,10 @@ import { * @default false */ Object.defineProperty(this, "autoPaging", { - get: function() { + get: function () { return _autoPaging; }, - set: function(value) { + set: function (value: boolean | "slice" | "text") { _autoPaging = value; } }); @@ -231,15 +435,15 @@ import { * @default 0 */ Object.defineProperty(this, "lastBreak", { - get: function() { + get: function () { return lastBreak; }, - set: function(value) { + set: function (value: number) { lastBreak = value; } }); - var pageBreaks = []; + var pageBreaks: number[] = []; /** * Y Position of page breaks. * @name pageBreaks @@ -247,10 +451,10 @@ import { * @default 0 */ Object.defineProperty(this, "pageBreaks", { - get: function() { + get: function () { return pageBreaks; }, - set: function(value) { + set: function (value: number[]) { pageBreaks = value; } }); @@ -261,10 +465,10 @@ import { * @default {} */ Object.defineProperty(this, "ctx", { - get: function() { + get: function () { return _ctx; }, - set: function(value) { + set: function (value: ContextLayer) { if (value instanceof ContextLayer) { _ctx = value; } @@ -277,10 +481,10 @@ import { * @default [] */ Object.defineProperty(this, "path", { - get: function() { + get: function () { return _ctx.path; }, - set: function(value) { + set: function (value: PathEntry[]) { _ctx.path = value; } }); @@ -290,12 +494,12 @@ import { * @type {array} * @default [] */ - var _ctxStack = []; + var _ctxStack: ContextLayer[] = []; Object.defineProperty(this, "ctxStack", { - get: function() { + get: function () { return _ctxStack; }, - set: function(value) { + set: function (value: ContextLayer[]) { _ctxStack = value; } }); @@ -310,10 +514,10 @@ import { * A pattern object to use to fill the drawing (not supported by context2d) */ Object.defineProperty(this, "fillStyle", { - get: function() { + get: function (this: Context2D) { return this.ctx.fillStyle; }, - set: function(value) { + set: function (this: Context2D, value: string | CanvasGradientStub) { var rgba; rgba = getRGBA(value); @@ -336,10 +540,10 @@ import { * @property {pattern} pattern A pattern object used to create a pattern stroke (not supported by context2d) */ Object.defineProperty(this, "strokeStyle", { - get: function() { + get: function (this: Context2D) { return this.ctx.strokeStyle; }, - set: function(value) { + set: function (this: Context2D, value: string | CanvasGradientStub) { var rgba = getRGBA(value); this.ctx.strokeStyle = rgba.style; @@ -366,10 +570,10 @@ import { * square A square end cap is added to each end of the line
    */ Object.defineProperty(this, "lineCap", { - get: function() { + get: function (this: Context2D) { return this.ctx.lineCap; }, - set: function(value) { + set: function (this: Context2D, value: string) { if (["butt", "round", "square"].indexOf(value) !== -1) { this.ctx.lineCap = value; this.pdf.setLineCap(value); @@ -385,10 +589,10 @@ import { * @property {number} lineWidth The current line width, in pixels */ Object.defineProperty(this, "lineWidth", { - get: function() { + get: function (this: Context2D) { return this.ctx.lineWidth; }, - set: function(value) { + set: function (this: Context2D, value: number) { if (!isNaN(value)) { this.ctx.lineWidth = value; this.pdf.setLineWidth(value); @@ -400,10 +604,10 @@ import { * Sets or returns the type of corner created, when two lines meet */ Object.defineProperty(this, "lineJoin", { - get: function() { + get: function (this: Context2D) { return this.ctx.lineJoin; }, - set: function(value) { + set: function (this: Context2D, value: string) { if (["bevel", "round", "miter"].indexOf(value) !== -1) { this.ctx.lineJoin = value; this.pdf.setLineJoin(value); @@ -418,10 +622,10 @@ import { * @default 10 */ Object.defineProperty(this, "miterLimit", { - get: function() { + get: function (this: Context2D) { return this.ctx.miterLimit; }, - set: function(value) { + set: function (this: Context2D, value: number) { if (!isNaN(value)) { this.ctx.miterLimit = value; this.pdf.setMiterLimit(value); @@ -430,29 +634,32 @@ import { }); Object.defineProperty(this, "textBaseline", { - get: function() { + get: function (this: Context2D) { return this.ctx.textBaseline; }, - set: function(value) { + set: function (this: Context2D, value: string) { this.ctx.textBaseline = value; } }); Object.defineProperty(this, "textAlign", { - get: function() { + get: function (this: Context2D) { return this.ctx.textAlign; }, - set: function(value) { + set: function (this: Context2D, value: string) { if (["right", "end", "center", "left", "start"].indexOf(value) !== -1) { this.ctx.textAlign = value; } } }); - var _fontFaceMap = null; - var _cachedFontList = null; + var _fontFaceMap: FontFaceMap | null = null; + var _cachedFontList: string | null = null; - function getFontFaceMap(pdf, fontFaces) { + function getFontFaceMap( + pdf: jsPDFDocument, + fontFaces: FontFaceInput[] + ): FontFaceMap { var currentFontMap = pdf.getFontList(); // Check if the font list has changed by comparing the JSON representation @@ -468,14 +675,16 @@ import { return _fontFaceMap; } - function convertToFontFaces(fontMap) { - var fontFaces = []; + function convertToFontFaces( + fontMap: Record + ): FontFaceInput[] { + var fontFaces: FontFaceInput[] = []; - Object.keys(fontMap).forEach(function(family) { + Object.keys(fontMap).forEach(function (family) { var styles = fontMap[family]; - styles.forEach(function(style) { - var fontFace = null; + styles.forEach(function (style) { + var fontFace: FontFaceInput | null = null; switch (style) { case "bold": @@ -524,7 +733,7 @@ import { return fontFaces; } - var _fontFaces = null; + var _fontFaces: FontFaceInput[] | null = null; /** * A map of available font-faces, as passed in the options of * .html(). If set a limited implementation of the font style matching @@ -533,10 +742,10 @@ import { */ Object.defineProperty(this, "fontFaces", { - get: function() { + get: function () { return _fontFaces; }, - set: function(value) { + set: function (value: FontFaceInput[] | null) { _fontFaceMap = null; _cachedFontList = null; _fontFaces = value; @@ -544,49 +753,54 @@ import { }); Object.defineProperty(this, "font", { - get: function() { + get: function (this: Context2D) { return this.ctx.font; }, - set: function(value) { + set: function (this: Context2D, value: string) { this.ctx.font = value; - var rx, matches; //source: https://stackoverflow.com/a/10136041 // eslint-disable-next-line no-useless-escape - rx = /^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-_,\"\'\sa-z0-9]+?)\s*$/i; - matches = rx.exec(value); - if (matches !== null) { - var fontStyle = matches[1]; - var fontVariant = matches[2]; - var fontWeight = matches[3]; - var fontSize = matches[4]; - var lineHeight = matches[5]; - var fontFamily = matches[6]; - } else { + var rx = + /^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-_,\"\'\sa-z0-9]+?)\s*$/i; + var matches = rx.exec(value); + if (matches === null) { return; } + var fontStyle = matches[1]; + // eslint-disable-next-line no-unused-vars + var fontVariant = matches[2]; + var fontWeight = matches[3]; + var fontSize = matches[4]; + // eslint-disable-next-line no-unused-vars + var lineHeight = matches[5]; + var fontFamily = matches[6]; + var rxFontSize = /^([.\d]+)((?:%|in|[cem]m|ex|p[ctx]))$/i; var fontSizeUnit = rxFontSize.exec(fontSize)[2]; + var fontSizeNumber: number; if ("px" === fontSizeUnit) { - fontSize = Math.floor( + fontSizeNumber = Math.floor( parseFloat(fontSize) * this.pdf.internal.scaleFactor ); } else if ("em" === fontSizeUnit) { - fontSize = Math.floor(parseFloat(fontSize) * this.pdf.getFontSize()); + fontSizeNumber = Math.floor( + parseFloat(fontSize) * this.pdf.getFontSize() + ); } else { - fontSize = Math.floor( + fontSizeNumber = Math.floor( parseFloat(fontSize) * this.pdf.internal.scaleFactor ); } - this.pdf.setFontSize(fontSize); + this.pdf.setFontSize(fontSizeNumber); var parts = parseFontFamily(fontFamily); if (this.fontFaces) { var fontFaceMap = getFontFaceMap(this.pdf, this.fontFaces); - var rules = parts.map(function(ff) { + var rules = parts.map(function (ff) { return { family: ff, stretch: "normal", // TODO: Extract font-stretch from font rule (perhaps write proper parser for it?) @@ -618,7 +832,7 @@ import { } var jsPdfFontName = ""; - var fallbackFonts = { + var fallbackFonts: Record = { arial: "Helvetica", Arial: "Helvetica", verdana: "Helvetica", @@ -677,19 +891,19 @@ import { }); Object.defineProperty(this, "globalCompositeOperation", { - get: function() { + get: function (this: Context2D) { return this.ctx.globalCompositeOperation; }, - set: function(value) { + set: function (this: Context2D, value: string) { this.ctx.globalCompositeOperation = value; } }); Object.defineProperty(this, "globalAlpha", { - get: function() { + get: function (this: Context2D) { return this.ctx.globalAlpha; }, - set: function(value) { + set: function (this: Context2D, value: number) { this.ctx.globalAlpha = value; } }); @@ -701,10 +915,10 @@ import { * @default 0.0 */ Object.defineProperty(this, "lineDashOffset", { - get: function() { + get: function (this: Context2D) { return this.ctx.lineDashOffset; }, - set: function(value) { + set: function (this: Context2D, value: number) { this.ctx.lineDashOffset = value; setLineDash.call(this); } @@ -712,10 +926,10 @@ import { // Not HTML API Object.defineProperty(this, "lineDash", { - get: function() { + get: function (this: Context2D) { return this.ctx.lineDash; }, - set: function(value) { + set: function (this: Context2D, value: number[]) { this.ctx.lineDash = value; setLineDash.call(this); } @@ -723,14 +937,14 @@ import { // Not HTML API Object.defineProperty(this, "ignoreClearRect", { - get: function() { + get: function (this: Context2D) { return this.ctx.ignoreClearRect; }, - set: function(value) { + set: function (this: Context2D, value: boolean) { this.ctx.ignoreClearRect = Boolean(value); } }); - }; + } /** * Sets the line dash pattern used when stroking lines. @@ -738,9 +952,9 @@ import { * @function * @description It uses an array of values that specify alternating lengths of lines and gaps which describe the pattern. */ - Context2D.prototype.setLineDash = function(dashArray) { + setLineDash(dashArray: number[]): void { this.lineDash = dashArray; - }; + } /** * gets the current line dash pattern. @@ -748,7 +962,7 @@ import { * @function * @returns {Array} An Array of numbers that specify distances to alternately draw a line and a gap (in coordinate space units). If the number, when setting the elements, is odd, the elements of the array get copied and concatenated. For example, setting the line dash to [5, 15, 25] will result in getting back [5, 15, 25, 5, 15, 25]. */ - Context2D.prototype.getLineDash = function() { + getLineDash(): number[] { if (this.lineDash.length % 2) { // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/getLineDash#return_value return this.lineDash.concat(this.lineDash); @@ -756,11 +970,11 @@ import { // The copied value is returned to prevent contamination from outside. return this.lineDash.slice(); } - }; + } - Context2D.prototype.fill = function() { + fill(): void { pathPreProcess.call(this, "fill", false); - }; + } /** * Actually draws the path you have defined @@ -769,9 +983,9 @@ import { * @function * @description The stroke() method actually draws the path you have defined with all those moveTo() and lineTo() methods. The default color is black. */ - Context2D.prototype.stroke = function() { + stroke(): void { pathPreProcess.call(this, "stroke", false); - }; + } /** * Begins a path, or resets the current @@ -780,13 +994,13 @@ import { * @function * @description The beginPath() method begins a path, or resets the current path. */ - Context2D.prototype.beginPath = function() { + beginPath(): void { this.path = [ { type: "begin" } ]; - }; + } /** * Moves the path to the specified point in the canvas, without creating a line @@ -796,7 +1010,7 @@ import { * @param x {Number} The x-coordinate of where to move the path to * @param y {Number} The y-coordinate of where to move the path to */ - Context2D.prototype.moveTo = function(x, y) { + moveTo(x: number, y: number): void { if (isNaN(x) || isNaN(y)) { console.error("jsPDF.context2d.moveTo: Invalid arguments", arguments); throw new Error("Invalid arguments passed to jsPDF.context2d.moveTo"); @@ -810,7 +1024,7 @@ import { y: pt.y }); this.ctx.lastPoint = new Point(x, y); - }; + } /** * Creates a path from the current point back to the starting point @@ -819,7 +1033,7 @@ import { * @function * @description The closePath() method creates a path from the current point back to the starting point. */ - Context2D.prototype.closePath = function() { + closePath(): void { var pathBegin = new Point(0, 0); var i = 0; for (i = this.path.length - 1; i !== -1; i--) { @@ -837,7 +1051,7 @@ import { type: "close" }); this.ctx.lastPoint = new Point(pathBegin.x, pathBegin.y); - }; + } /** * Adds a new point and creates a line to that point from the last specified point in the canvas @@ -848,7 +1062,7 @@ import { * @param y The y-coordinate of where to create the line to * @description The lineTo() method adds a new point and creates a line TO that point FROM the last specified point in the canvas (this method does not draw the line). */ - Context2D.prototype.lineTo = function(x, y) { + lineTo(x: number, y: number): void { if (isNaN(x) || isNaN(y)) { console.error("jsPDF.context2d.lineTo: Invalid arguments", arguments); throw new Error("Invalid arguments passed to jsPDF.context2d.lineTo"); @@ -862,7 +1076,7 @@ import { y: pt.y }); this.ctx.lastPoint = new Point(pt.x, pt.y); - }; + } /** * Clips a region of any shape and size from the original canvas @@ -871,10 +1085,10 @@ import { * @function * @description The clip() method clips a region of any shape and size from the original canvas. */ - Context2D.prototype.clip = function() { + clip(): void { this.ctx.clip_path = JSON.parse(JSON.stringify(this.path)); pathPreProcess.call(this, null, true); - }; + } /** * Creates a cubic Bézier curve @@ -887,7 +1101,7 @@ import { * @param y {Number} The y-coordinate of the ending point * @description The quadraticCurveTo() method adds a point to the current path by using the specified control points that represent a quadratic Bézier curve.

    A quadratic Bézier curve requires two points. The first point is a control point that is used in the quadratic Bézier calculation and the second point is the ending point for the curve. The starting point for the curve is the last point in the current path. If a path does not exist, use the beginPath() and moveTo() methods to define a starting point. */ - Context2D.prototype.quadraticCurveTo = function(cpx, cpy, x, y) { + quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void { if (isNaN(x) || isNaN(y) || isNaN(cpx) || isNaN(cpy)) { console.error( "jsPDF.context2d.quadraticCurveTo: Invalid arguments", @@ -909,7 +1123,7 @@ import { y: pt0.y }); this.ctx.lastPoint = new Point(pt0.x, pt0.y); - }; + } /** * Creates a cubic Bézier curve @@ -924,7 +1138,14 @@ import { * @param y {Number} The y-coordinate of the ending point * @description The bezierCurveTo() method adds a point to the current path by using the specified control points that represent a cubic Bézier curve.

    A cubic bezier curve requires three points. The first two points are control points that are used in the cubic Bézier calculation and the last point is the ending point for the curve. The starting point for the curve is the last point in the current path. If a path does not exist, use the beginPath() and moveTo() methods to define a starting point. */ - Context2D.prototype.bezierCurveTo = function(cp1x, cp1y, cp2x, cp2y, x, y) { + bezierCurveTo( + cp1x: number, + cp1y: number, + cp2x: number, + cp2y: number, + x: number, + y: number + ): void { if ( isNaN(x) || isNaN(y) || @@ -955,7 +1176,7 @@ import { y: pt0.y }); this.ctx.lastPoint = new Point(pt0.x, pt0.y); - }; + } /** * Creates an arc/curve (used to create circles, or parts of circles) @@ -970,14 +1191,14 @@ import { * @param counterclockwise {Boolean} Optional. Specifies whether the drawing should be counterclockwise or clockwise. False is default, and indicates clockwise, while true indicates counter-clockwise. * @description The arc() method creates an arc/curve (used to create circles, or parts of circles). */ - Context2D.prototype.arc = function( - x, - y, - radius, - startAngle, - endAngle, - counterclockwise - ) { + arc( + x: number, + y: number, + radius: number, + startAngle: number, + endAngle: number, + counterclockwise?: boolean + ): void { if ( isNaN(x) || isNaN(y) || @@ -1017,7 +1238,7 @@ import { counterclockwise: counterclockwise }); // this.ctx.lastPoint(new Point(pt.x,pt.y)); - }; + } /** * Creates an arc/curve between two tangents @@ -1032,9 +1253,9 @@ import { * @description The arcTo() method creates an arc/curve between two tangents on the canvas. */ // eslint-disable-next-line no-unused-vars - Context2D.prototype.arcTo = function(x1, y1, x2, y2, radius) { + arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void { throw new Error("arcTo not implemented."); - }; + } /** * Creates a rectangle @@ -1047,7 +1268,7 @@ import { * @param h {Number} The height of the rectangle, in pixels * @description The rect() method creates a rectangle. */ - Context2D.prototype.rect = function(x, y, w, h) { + rect(x: number, y: number, w: number, h: number): void { if (isNaN(x) || isNaN(y) || isNaN(w) || isNaN(h)) { console.error("jsPDF.context2d.rect: Invalid arguments", arguments); throw new Error("Invalid arguments passed to jsPDF.context2d.rect"); @@ -1059,7 +1280,7 @@ import { this.lineTo(x, y); this.lineTo(x + w, y); this.lineTo(x, y); - }; + } /** * Draws a "filled" rectangle @@ -1072,7 +1293,7 @@ import { * @param h {Number} The height of the rectangle, in pixels * @description The fillRect() method draws a "filled" rectangle. The default color of the fill is black. */ - Context2D.prototype.fillRect = function(x, y, w, h) { + fillRect(x: number, y: number, w: number, h: number): void { if (isNaN(x) || isNaN(y) || isNaN(w) || isNaN(h)) { console.error("jsPDF.context2d.fillRect: Invalid arguments", arguments); throw new Error("Invalid arguments passed to jsPDF.context2d.fillRect"); @@ -1080,7 +1301,7 @@ import { if (isFillTransparent.call(this)) { return; } - var tmp: any = {}; + var tmp: { lineCap?: string; lineJoin?: string } = {}; if (this.lineCap !== "butt") { tmp.lineCap = this.lineCap; this.lineCap = "butt"; @@ -1100,7 +1321,7 @@ import { if (tmp.hasOwnProperty("lineJoin")) { this.lineJoin = tmp.lineJoin; } - }; + } /** * Draws a rectangle (no fill) @@ -1113,7 +1334,7 @@ import { * @param h {Number} The height of the rectangle, in pixels * @description The strokeRect() method draws a rectangle (no fill). The default color of the stroke is black. */ - Context2D.prototype.strokeRect = function strokeRect(x, y, w, h) { + strokeRect(x: number, y: number, w: number, h: number): void { if (isNaN(x) || isNaN(y) || isNaN(w) || isNaN(h)) { console.error("jsPDF.context2d.strokeRect: Invalid arguments", arguments); throw new Error("Invalid arguments passed to jsPDF.context2d.strokeRect"); @@ -1124,7 +1345,7 @@ import { this.beginPath(); this.rect(x, y, w, h); this.stroke(); - }; + } /** * Clears the specified pixels within a given rectangle @@ -1141,7 +1362,7 @@ import { * This flag is stored in the save/restore context and is managed the same way as other drawing states. * */ - Context2D.prototype.clearRect = function(x, y, w, h) { + clearRect(x: number, y: number, w: number, h: number): void { if (isNaN(x) || isNaN(y) || isNaN(w) || isNaN(h)) { console.error("jsPDF.context2d.clearRect: Invalid arguments", arguments); throw new Error("Invalid arguments passed to jsPDF.context2d.clearRect"); @@ -1152,7 +1373,7 @@ import { this.fillStyle = "#ffffff"; this.fillRect(x, y, w, h); - }; + } /** * Saves the state of the current context @@ -1160,7 +1381,7 @@ import { * @name save * @function */ - Context2D.prototype.save = function(doStackPush) { + save(doStackPush?: boolean): void { doStackPush = typeof doStackPush === "boolean" ? doStackPush : true; var tmpPageNumber = this.pdf.internal.getCurrentPageInfo().pageNumber; for (var i = 0; i < this.pdf.internal.getNumberOfPages(); i++) { @@ -1175,7 +1396,7 @@ import { this.ctxStack.push(this.ctx); this.ctx = ctx; } - }; + } /** * Returns previously saved path state and attributes @@ -1183,7 +1404,7 @@ import { * @name restore * @function */ - Context2D.prototype.restore = function(doStackPop) { + restore(doStackPop?: boolean): void { doStackPop = typeof doStackPop === "boolean" ? doStackPop : true; var tmpPageNumber = this.pdf.internal.getCurrentPageInfo().pageNumber; for (var i = 0; i < this.pdf.internal.getNumberOfPages(); i++) { @@ -1203,114 +1424,15 @@ import { this.lineDash = this.ctx.lineDash; this.lineDashOffset = this.ctx.lineDashOffset; } - }; + } /** * @name toDataURL * @function */ - Context2D.prototype.toDataURL = function() { + toDataURL(): never { throw new Error("toDataUrl not implemented."); - }; - - //helper functions - - /** - * Get the decimal values of r, g, b and a - * - * @name getRGBA - * @function - * @private - * @ignore - */ - var getRGBA = function(style) { - var rxRgb = /rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/; - var rxRgba = /rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)/; - var rxTransparent = /transparent|rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*0+\s*\)/; - - var r, g, b, a; - - if (style.isCanvasGradient === true) { - style = style.getColor(); - } - - if (!style) { - return { r: 0, g: 0, b: 0, a: 0, style: style }; - } - - if (rxTransparent.test(style)) { - r = 0; - g = 0; - b = 0; - a = 0; - } else { - var matches = rxRgb.exec(style); - if (matches !== null) { - r = parseInt(matches[1]); - g = parseInt(matches[2]); - b = parseInt(matches[3]); - a = 1; - } else { - matches = rxRgba.exec(style); - if (matches !== null) { - r = parseInt(matches[1]); - g = parseInt(matches[2]); - b = parseInt(matches[3]); - a = parseFloat(matches[4]); - } else { - a = 1; - - if (typeof style === "string" && style.charAt(0) !== "#") { - var rgbColor = new RGBColor(style); - if (rgbColor.ok) { - style = rgbColor.toHex(); - } else { - style = "#000000"; - } - } - - if (style.length === 4) { - r = style.substring(1, 2); - r += r; - g = style.substring(2, 3); - g += g; - b = style.substring(3, 4); - b += b; - } else { - r = style.substring(1, 3); - g = style.substring(3, 5); - b = style.substring(5, 7); - } - r = parseInt(r, 16); - g = parseInt(g, 16); - b = parseInt(b, 16); - } - } - } - return { r: r, g: g, b: b, a: a, style: style }; - }; - - /** - * @name isFillTransparent - * @function - * @private - * @ignore - * @returns {Boolean} - */ - var isFillTransparent = function() { - return this.ctx.isFillTransparent || this.globalAlpha == 0; - }; - - /** - * @name isStrokeTransparent - * @function - * @private - * @ignore - * @returns {Boolean} - */ - var isStrokeTransparent = function() { - return Boolean(this.ctx.isStrokeTransparent || this.globalAlpha == 0); - }; + } /** * Draws "filled" text on the canvas @@ -1323,7 +1445,7 @@ import { * @param maxWidth {Number} Optional. The maximum allowed width of the text, in pixels * @description The fillText() method draws filled text on the canvas. The default color of the text is black. */ - Context2D.prototype.fillText = function(text, x, y, maxWidth) { + fillText(text: string, x: number, y: number, maxWidth?: number): void { if (isNaN(x) || isNaN(y) || typeof text !== "string") { console.error("jsPDF.context2d.fillText: Invalid arguments", arguments); throw new Error("Invalid arguments passed to jsPDF.context2d.fillText"); @@ -1347,7 +1469,7 @@ import { align: this.textAlign, maxWidth: maxWidth }); - }; + } /** * Draws text on the canvas (no fill) @@ -1360,7 +1482,7 @@ import { * @param maxWidth {Number} Optional. The maximum allowed width of the text, in pixels * @description The strokeText() method draws text (with no fill) on the canvas. The default color of the text is black. */ - Context2D.prototype.strokeText = function(text, x, y, maxWidth) { + strokeText(text: string, x: number, y: number, maxWidth?: number): void { if (isNaN(x) || isNaN(y) || typeof text !== "string") { console.error("jsPDF.context2d.strokeText: Invalid arguments", arguments); throw new Error("Invalid arguments passed to jsPDF.context2d.strokeText"); @@ -1384,7 +1506,7 @@ import { align: this.textAlign, maxWidth: maxWidth }); - }; + } /** * Returns an object that contains the width of the specified text @@ -1395,7 +1517,7 @@ import { * @description The measureText() method returns an object that contains the width of the specified text, in pixels. * @returns {Number} */ - Context2D.prototype.measureText = function(text) { + measureText(text: string): TextMetrics { if (typeof text !== "string") { console.error( "jsPDF.context2d.measureText: Invalid arguments", @@ -1413,18 +1535,8 @@ import { (pdf.getStringUnitWidth(text) * fontSize) / pdf.internal.scaleFactor; txtWidth *= Math.round(((k * 96) / 72) * 10000) / 10000; - var TextMetrics: any = function(options) { - options = options || {}; - var _width = options.width || 0; - Object.defineProperty(this, "width", { - get: function() { - return _width; - } - }); - return this; - }; return new TextMetrics({ width: txtWidth }); - }; + } //Transformations @@ -1437,14 +1549,14 @@ import { * @param scaleheight {Number} Scales the height of the current drawing (1=100%, 0.5=50%, 2=200%, etc.) * @description The scale() method scales the current drawing, bigger or smaller. */ - Context2D.prototype.scale = function(scalewidth, scaleheight) { + scale(scalewidth: number, scaleheight: number): void { if (isNaN(scalewidth) || isNaN(scaleheight)) { console.error("jsPDF.context2d.scale: Invalid arguments", arguments); throw new Error("Invalid arguments passed to jsPDF.context2d.scale"); } var matrix = new Matrix(scalewidth, 0.0, 0.0, scaleheight, 0.0, 0.0); this.ctx.transform = this.ctx.transform.multiply(matrix); - }; + } /** * Rotates the current drawing @@ -1455,7 +1567,7 @@ import { * @description To calculate from degrees to radians: degrees*Math.PI/180.
    * Example: to rotate 5 degrees, specify the following: 5*Math.PI/180 */ - Context2D.prototype.rotate = function(angle) { + rotate(angle: number): void { if (isNaN(angle)) { console.error("jsPDF.context2d.rotate: Invalid arguments", arguments); throw new Error("Invalid arguments passed to jsPDF.context2d.rotate"); @@ -1469,7 +1581,7 @@ import { 0.0 ); this.ctx.transform = this.ctx.transform.multiply(matrix); - }; + } /** * Remaps the (0,0) position on the canvas @@ -1480,14 +1592,14 @@ import { * @param y {Number} The value to add to vertical (y) coordinates * @description The translate() method remaps the (0,0) position on the canvas. */ - Context2D.prototype.translate = function(x, y) { + translate(x: number, y: number): void { if (isNaN(x) || isNaN(y)) { console.error("jsPDF.context2d.translate: Invalid arguments", arguments); throw new Error("Invalid arguments passed to jsPDF.context2d.translate"); } var matrix = new Matrix(1.0, 0.0, 0.0, 1.0, x, y); this.ctx.transform = this.ctx.transform.multiply(matrix); - }; + } /** * Replaces the current transformation matrix for the drawing @@ -1502,14 +1614,21 @@ import { * @param f {Number} Vertical moving * @description Each object on the canvas has a current transformation matrix.

    The transform() method replaces the current transformation matrix. It multiplies the current transformation matrix with the matrix described by:



    a c e

    b d f

    0 0 1

    In other words, the transform() method lets you scale, rotate, move, and skew the current context. */ - Context2D.prototype.transform = function(a, b, c, d, e, f) { + transform( + a: number, + b: number, + c: number, + d: number, + e: number, + f: number + ): void { if (isNaN(a) || isNaN(b) || isNaN(c) || isNaN(d) || isNaN(e) || isNaN(f)) { console.error("jsPDF.context2d.transform: Invalid arguments", arguments); throw new Error("Invalid arguments passed to jsPDF.context2d.transform"); } var matrix = new Matrix(a, b, c, d, e, f); this.ctx.transform = this.ctx.transform.multiply(matrix); - }; + } /** * Resets the current transform to the identity matrix. Then runs transform() @@ -1524,7 +1643,14 @@ import { * @param f {Number} Vertical moving * @description Each object on the canvas has a current transformation matrix.

    The setTransform() method resets the current transform to the identity matrix, and then runs transform() with the same arguments.

    In other words, the setTransform() method lets you scale, rotate, move, and skew the current context. */ - Context2D.prototype.setTransform = function(a, b, c, d, e, f) { + setTransform( + a?: number, + b?: number, + c?: number, + d?: number, + e?: number, + f?: number + ): void { a = isNaN(a) ? 1 : a; b = isNaN(b) ? 0 : b; c = isNaN(c) ? 0 : c; @@ -1532,54 +1658,7 @@ import { e = isNaN(e) ? 0 : e; f = isNaN(f) ? 0 : f; this.ctx.transform = new Matrix(a, b, c, d, e, f); - }; - - /** - * Should only be used if pageWrapYEnabled is true - * - * @name setPageByYPosition - * @function - * @private - * @ignore - * @returns One-based Page Number - */ - var setPageByYPosition = function(y) { - if (this.pageWrapYEnabled) { - this.lastBreak = 0; - var manualBreaks = 0; - var autoBreaks = 0; - for (var i = 0; i < this.pageBreaks.length; i++) { - if (y >= this.pageBreaks[i]) { - manualBreaks++; - if (this.lastBreak === 0) { - autoBreaks++; - } - var spaceBetweenLastBreak = this.pageBreaks[i] - this.lastBreak; - this.lastBreak = this.pageBreaks[i]; - var pagesSinceLastBreak = Math.floor( - spaceBetweenLastBreak / this.pageWrapY - ); - autoBreaks += pagesSinceLastBreak; - } - } - if (this.lastBreak === 0) { - var pagesSinceLastBreak = Math.floor(y / this.pageWrapY) + 1; - autoBreaks += pagesSinceLastBreak; - } - return autoBreaks + manualBreaks; - } else { - return this.pdf.internal.getCurrentPageInfo().pageNumber; - } - }; - - var hasMargins = function() { - return ( - this.margin[0] > 0 || - this.margin[1] > 0 || - this.margin[2] > 0 || - this.margin[3] > 0 - ); - }; + } /** * Draws an image, canvas, or video onto the canvas @@ -1595,17 +1674,17 @@ import { * @param width {Number} Optional. The width of the image to use (stretch or reduce the image) * @param height {Number} Optional. The height of the image to use (stretch or reduce the image) */ - Context2D.prototype.drawImage = function( - img, - sx, - sy, - swidth, - sheight, - x, - y, - width, - height - ) { + drawImage( + img: CanvasImageSource | string, + sx: number, + sy: number, + swidth?: number, + sheight?: number, + x?: number, + y?: number, + width?: number, + height?: number + ): void { var imageProperties = this.pdf.getImageProperties(img); var factorX = 1; var factorY = 1; @@ -1656,7 +1735,7 @@ import { if (this.autoPaging) { var pageArray = getPagesByPath.call(this, xRect); - var pages = []; + var pages: number[] = []; for (var ii = 0; ii < pageArray.length; ii += 1) { if (pages.indexOf(pageArray[ii]) === -1) { pages.push(pageArray[ii]); @@ -1665,7 +1744,7 @@ import { sortPages(pages); - var clipPath; + var clipPath: PathEntry[]; var min = pages[0]; var max = pages[pages.length - 1]; for (var i = min; i < max + 1; i++) { @@ -1695,7 +1774,7 @@ import { drawPaths.call(this, "fill", true); this.path = tmpPaths; } - var tmpRect = JSON.parse(JSON.stringify(xRect)); + var tmpRect: PathEntry = JSON.parse(JSON.stringify(xRect)); tmpRect = pathPositionRedo( [tmpRect], this.posX + this.margin[3], @@ -1745,947 +1824,1190 @@ import { angle ); } - }; + } + + // The coordinate parameters of the real canvas API are accepted (specs and + // ported canvas code pass them) but ignored: the stub only records color + // stops. + createLinearGradient( + _x0?: number, + _y0?: number, + _x1?: number, + _y1?: number + ): CanvasGradientStub { + var canvasGradient = Object.assign(function canvasGradient() {}, { + colorStops: [] as Array<[number, string]>, + addColorStop: function ( + this: CanvasGradientStub, + offset: number, + color: string + ): void { + this.colorStops.push([offset, color]); + }, + getColor: function (this: CanvasGradientStub): string { + if (this.colorStops.length === 0) { + return "#000000"; + } - var getPagesByPath = function(path, pageWrapX?, pageWrapY?) { - var result = []; - pageWrapX = pageWrapX || this.pdf.internal.pageSize.width; - pageWrapY = - pageWrapY || - this.pdf.internal.pageSize.height - this.margin[0] - this.margin[2]; - var yOffset = this.posY + this.ctx.prevPageLastElemOffset; + return this.colorStops[0][1]; + }, + isCanvasGradient: true as const + }); - switch (path.type) { - default: - case "mt": - case "lt": - result.push(Math.floor((path.y + yOffset) / pageWrapY) + 1); - break; - case "arc": - result.push( - Math.floor((path.y + yOffset - path.radius) / pageWrapY) + 1 - ); - result.push( - Math.floor((path.y + yOffset + path.radius) / pageWrapY) + 1 - ); - break; - case "qct": - var rectOfQuadraticCurve = getQuadraticCurveBoundary( - this.ctx.lastPoint.x, - this.ctx.lastPoint.y, - path.x1, - path.y1, - path.x, - path.y - ); - result.push( - Math.floor((rectOfQuadraticCurve.y + yOffset) / pageWrapY) + 1 - ); - result.push( - Math.floor( - (rectOfQuadraticCurve.y + rectOfQuadraticCurve.h + yOffset) / - pageWrapY - ) + 1 - ); - break; - case "bct": - var rectOfBezierCurve = getBezierCurveBoundary( - this.ctx.lastPoint.x, - this.ctx.lastPoint.y, - path.x1, - path.y1, - path.x2, - path.y2, - path.x, - path.y - ); - result.push( - Math.floor((rectOfBezierCurve.y + yOffset) / pageWrapY) + 1 - ); - result.push( - Math.floor( - (rectOfBezierCurve.y + rectOfBezierCurve.h + yOffset) / pageWrapY - ) + 1 - ); - break; - case "rect": - result.push(Math.floor((path.y + yOffset) / pageWrapY) + 1); - result.push(Math.floor((path.y + path.h + yOffset) / pageWrapY) + 1); - } + return canvasGradient; + } - for (var i = 0; i < result.length; i += 1) { - while (this.pdf.internal.getNumberOfPages() < result[i]) { - addPage.call(this); - } - } - return result; - }; + createPattern(): CanvasGradientStub { + return this.createLinearGradient(); + } - var addPage = function() { - var fillStyle = this.fillStyle; - var strokeStyle = this.strokeStyle; - var font = this.font; - var lineCap = this.lineCap; - var lineWidth = this.lineWidth; - var lineJoin = this.lineJoin; - this.pdf.addPage(); - this.fillStyle = fillStyle; - this.strokeStyle = strokeStyle; - this.font = font; - this.lineCap = lineCap; - this.lineWidth = lineWidth; - this.lineJoin = lineJoin; - }; + createRadialGradient(): CanvasGradientStub { + return this.createLinearGradient(); + } +} + +//helper functions - var pathPositionRedo = function(paths, x, y) { - for (var i = 0; i < paths.length; i++) { - switch (paths[i].type) { - case "bct": - paths[i].x2 += x; - paths[i].y2 += y; - case "qct": - paths[i].x1 += x; - paths[i].y1 += y; - case "mt": - case "lt": - case "arc": - default: - paths[i].x += x; - paths[i].y += y; +/** + * Get the decimal values of r, g, b and a + * + * @name getRGBA + * @function + * @private + * @ignore + */ +var getRGBA = function (style: string | CanvasGradientStub): RGBAResult { + var rxRgb = /rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/; + var rxRgba = /rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)/; + var rxTransparent = + /transparent|rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*0+\s*\)/; + + var r: number, g: number, b: number, a: number; + + // The gradient stubs produced by createLinearGradient are function + // objects, so no typeof narrowing here — property probing matches the + // original implementation exactly. + if ((style as CanvasGradientStub).isCanvasGradient === true) { + style = (style as CanvasGradientStub).getColor(); + } + // Non-string, non-gradient inputs keep flowing through the string code + // paths untouched, faithful to the original JavaScript implementation. + var styleString = style as string; + + if (!styleString) { + return { r: 0, g: 0, b: 0, a: 0, style: styleString }; + } + + if (rxTransparent.test(styleString)) { + r = 0; + g = 0; + b = 0; + a = 0; + } else { + var matches = rxRgb.exec(styleString); + if (matches !== null) { + r = parseInt(matches[1]); + g = parseInt(matches[2]); + b = parseInt(matches[3]); + a = 1; + } else { + matches = rxRgba.exec(styleString); + if (matches !== null) { + r = parseInt(matches[1]); + g = parseInt(matches[2]); + b = parseInt(matches[3]); + a = parseFloat(matches[4]); + } else { + a = 1; + + if (typeof styleString === "string" && styleString.charAt(0) !== "#") { + var rgbColor = new RGBColor(styleString); + if (rgbColor.ok) { + styleString = rgbColor.toHex(); + } else { + styleString = "#000000"; + } + } + + var rs: string, gs: string, bs: string; + if (styleString.length === 4) { + rs = styleString.substring(1, 2); + rs += rs; + gs = styleString.substring(2, 3); + gs += gs; + bs = styleString.substring(3, 4); + bs += bs; + } else { + rs = styleString.substring(1, 3); + gs = styleString.substring(3, 5); + bs = styleString.substring(5, 7); + } + r = parseInt(rs, 16); + g = parseInt(gs, 16); + b = parseInt(bs, 16); } } - return paths; - }; + } + return { r: r, g: g, b: b, a: a, style: styleString }; +}; - var sortPages = function(pages) { - return pages.sort(function(a, b) { - return a - b; - }); - }; +/** + * @name isFillTransparent + * @function + * @private + * @ignore + * @returns {Boolean} + */ +var isFillTransparent = function (this: Context2D): boolean { + return this.ctx.isFillTransparent || this.globalAlpha == 0; +}; - var pathPreProcess = function(rule, isClip) { - var fillStyle = this.fillStyle; - var strokeStyle = this.strokeStyle; - var lineCap = this.lineCap; - var oldLineWidth = this.lineWidth; - var lineWidth = Math.abs(oldLineWidth * this.ctx.transform.scaleX); - var lineJoin = this.lineJoin; +/** + * @name isStrokeTransparent + * @function + * @private + * @ignore + * @returns {Boolean} + */ +var isStrokeTransparent = function (this: Context2D): boolean { + return Boolean(this.ctx.isStrokeTransparent || this.globalAlpha == 0); +}; - if (this.autoPaging) { - var origPath = JSON.parse(JSON.stringify(this.path)); - var xPath = JSON.parse(JSON.stringify(this.path)); - var clipPath; - var tmpPath; - var pages = []; - - for (var i = 0; i < xPath.length; i++) { - if (typeof xPath[i].x !== "undefined") { - var page = getPagesByPath.call(this, xPath[i]); - - for (var ii = 0; ii < page.length; ii += 1) { - if (pages.indexOf(page[ii]) === -1) { - pages.push(page[ii]); - } - } +/** + * Should only be used if pageWrapYEnabled is true + * + * @name setPageByYPosition + * @function + * @private + * @ignore + * @returns One-based Page Number + */ +// eslint-disable-next-line no-unused-vars +var setPageByYPosition = function (this: Context2D, y: number): number { + if (this.pageWrapYEnabled) { + this.lastBreak = 0; + var manualBreaks = 0; + var autoBreaks = 0; + for (var i = 0; i < this.pageBreaks.length; i++) { + if (y >= this.pageBreaks[i]) { + manualBreaks++; + if (this.lastBreak === 0) { + autoBreaks++; } + var spaceBetweenLastBreak = this.pageBreaks[i] - this.lastBreak; + this.lastBreak = this.pageBreaks[i]; + var pagesSinceLastBreak = Math.floor( + spaceBetweenLastBreak / this.pageWrapY + ); + autoBreaks += pagesSinceLastBreak; } + } + if (this.lastBreak === 0) { + var pagesSinceLastBreak = Math.floor(y / this.pageWrapY) + 1; + autoBreaks += pagesSinceLastBreak; + } + return autoBreaks + manualBreaks; + } else { + return this.pdf.internal.getCurrentPageInfo().pageNumber; + } +}; + +var hasMargins = function (this: Context2D): boolean { + return ( + this.margin[0] > 0 || + this.margin[1] > 0 || + this.margin[2] > 0 || + this.margin[3] > 0 + ); +}; + +var getPagesByPath = function ( + this: Context2D, + path: PathEntry, + pageWrapX?: number, + pageWrapY?: number +): number[] { + var result: number[] = []; + pageWrapX = pageWrapX || this.pdf.internal.pageSize.width; + pageWrapY = + pageWrapY || + this.pdf.internal.pageSize.height - this.margin[0] - this.margin[2]; + var yOffset = this.posY + this.ctx.prevPageLastElemOffset; + + switch (path.type) { + default: + case "mt": + case "lt": + result.push(Math.floor((path.y + yOffset) / pageWrapY) + 1); + break; + case "arc": + result.push(Math.floor((path.y + yOffset - path.radius) / pageWrapY) + 1); + result.push(Math.floor((path.y + yOffset + path.radius) / pageWrapY) + 1); + break; + case "qct": + var rectOfQuadraticCurve = getQuadraticCurveBoundary( + this.ctx.lastPoint.x, + this.ctx.lastPoint.y, + path.x1, + path.y1, + path.x, + path.y + ); + result.push( + Math.floor((rectOfQuadraticCurve.y + yOffset) / pageWrapY) + 1 + ); + result.push( + Math.floor( + (rectOfQuadraticCurve.y + rectOfQuadraticCurve.h + yOffset) / + pageWrapY + ) + 1 + ); + break; + case "bct": + var rectOfBezierCurve = getBezierCurveBoundary( + this.ctx.lastPoint.x, + this.ctx.lastPoint.y, + path.x1, + path.y1, + path.x2, + path.y2, + path.x, + path.y + ); + result.push(Math.floor((rectOfBezierCurve.y + yOffset) / pageWrapY) + 1); + result.push( + Math.floor( + (rectOfBezierCurve.y + rectOfBezierCurve.h + yOffset) / pageWrapY + ) + 1 + ); + break; + case "rect": + result.push(Math.floor((path.y + yOffset) / pageWrapY) + 1); + result.push(Math.floor((path.y + path.h + yOffset) / pageWrapY) + 1); + } + + for (var i = 0; i < result.length; i += 1) { + while (this.pdf.internal.getNumberOfPages() < result[i]) { + addPage.call(this); + } + } + return result; +}; + +var addPage = function (this: Context2D): void { + var fillStyle = this.fillStyle; + var strokeStyle = this.strokeStyle; + var font = this.font; + var lineCap = this.lineCap; + var lineWidth = this.lineWidth; + var lineJoin = this.lineJoin; + this.pdf.addPage(); + this.fillStyle = fillStyle; + this.strokeStyle = strokeStyle; + this.font = font; + this.lineCap = lineCap; + this.lineWidth = lineWidth; + this.lineJoin = lineJoin; +}; + +var pathPositionRedo = function ( + paths: PathEntry[], + x: number, + y: number +): PathEntry[] { + for (var i = 0; i < paths.length; i++) { + switch (paths[i].type) { + case "bct": + paths[i].x2 += x; + paths[i].y2 += y; + case "qct": + paths[i].x1 += x; + paths[i].y1 += y; + case "mt": + case "lt": + case "arc": + default: + paths[i].x += x; + paths[i].y += y; + } + } + return paths; +}; + +var sortPages = function (pages: number[]): number[] { + return pages.sort(function (a, b) { + return a - b; + }); +}; + +var pathPreProcess = function ( + this: Context2D, + rule: string | null, + isClip: boolean +): void { + var fillStyle = this.fillStyle; + var strokeStyle = this.strokeStyle; + var lineCap = this.lineCap; + var oldLineWidth = this.lineWidth; + var lineWidth = Math.abs(oldLineWidth * this.ctx.transform.scaleX); + var lineJoin = this.lineJoin; + + if (this.autoPaging) { + var origPath: PathEntry[] = JSON.parse(JSON.stringify(this.path)); + var xPath: PathEntry[] = JSON.parse(JSON.stringify(this.path)); + var clipPath: PathEntry[]; + var tmpPath: PathEntry[]; + var pages: number[] = []; - for (var j = 0; j < pages.length; j++) { - while (this.pdf.internal.getNumberOfPages() < pages[j]) { - addPage.call(this); + for (var i = 0; i < xPath.length; i++) { + if (typeof xPath[i].x !== "undefined") { + var page = getPagesByPath.call(this, xPath[i]); + + for (var ii = 0; ii < page.length; ii += 1) { + if (pages.indexOf(page[ii]) === -1) { + pages.push(page[ii]); + } } } - sortPages(pages); - - var min = pages[0]; - var max = pages[pages.length - 1]; - for (var k = min; k < max + 1; k++) { - this.pdf.setPage(k); + } - this.fillStyle = fillStyle; - this.strokeStyle = strokeStyle; - this.lineCap = lineCap; - this.lineWidth = lineWidth; - this.lineJoin = lineJoin; + for (var j = 0; j < pages.length; j++) { + while (this.pdf.internal.getNumberOfPages() < pages[j]) { + addPage.call(this); + } + } + sortPages(pages); - var pageWidthMinusMargins = - this.pdf.internal.pageSize.width - this.margin[3] - this.margin[1]; - var topMargin = k === 1 ? this.posY + this.margin[0] : this.margin[0]; - var firstPageHeight = - this.pdf.internal.pageSize.height - - this.posY - - this.margin[0] - - this.margin[2]; - var pageHeightMinusMargins = - this.pdf.internal.pageSize.height - this.margin[0] - this.margin[2]; - var previousPageHeightSum = - k === 1 ? 0 : firstPageHeight + (k - 2) * pageHeightMinusMargins; + var min = pages[0]; + var max = pages[pages.length - 1]; + for (var k = min; k < max + 1; k++) { + this.pdf.setPage(k); - if (this.ctx.clip_path.length !== 0) { - var tmpPaths = this.path; - clipPath = JSON.parse(JSON.stringify(this.ctx.clip_path)); - this.path = pathPositionRedo( - clipPath, - this.posX + this.margin[3], - -previousPageHeightSum + topMargin + this.ctx.prevPageLastElemOffset - ); - drawPaths.call(this, rule, true); - this.path = tmpPaths; - } - tmpPath = JSON.parse(JSON.stringify(origPath)); + this.fillStyle = fillStyle; + this.strokeStyle = strokeStyle; + this.lineCap = lineCap; + this.lineWidth = lineWidth; + this.lineJoin = lineJoin; + + var pageWidthMinusMargins = + this.pdf.internal.pageSize.width - this.margin[3] - this.margin[1]; + var topMargin = k === 1 ? this.posY + this.margin[0] : this.margin[0]; + var firstPageHeight = + this.pdf.internal.pageSize.height - + this.posY - + this.margin[0] - + this.margin[2]; + var pageHeightMinusMargins = + this.pdf.internal.pageSize.height - this.margin[0] - this.margin[2]; + var previousPageHeightSum = + k === 1 ? 0 : firstPageHeight + (k - 2) * pageHeightMinusMargins; + + if (this.ctx.clip_path.length !== 0) { + var tmpPaths = this.path; + clipPath = JSON.parse(JSON.stringify(this.ctx.clip_path)); this.path = pathPositionRedo( - tmpPath, + clipPath, this.posX + this.margin[3], -previousPageHeightSum + topMargin + this.ctx.prevPageLastElemOffset ); - if (isClip === false || k === 0) { - const needsClipping = (k > min || k < max) && hasMargins.call(this); - if (needsClipping) { - this.pdf.saveGraphicsState(); - this.pdf - .rect( - this.margin[3], - this.margin[0], - pageWidthMinusMargins, - pageHeightMinusMargins, - null - ) - .clip() - .discardPath(); - } - drawPaths.call(this, rule, isClip); - if (needsClipping) { - this.pdf.restoreGraphicsState(); - } - } - this.lineWidth = oldLineWidth; + drawPaths.call(this, rule, true); + this.path = tmpPaths; + } + tmpPath = JSON.parse(JSON.stringify(origPath)); + this.path = pathPositionRedo( + tmpPath, + this.posX + this.margin[3], + -previousPageHeightSum + topMargin + this.ctx.prevPageLastElemOffset + ); + if (isClip === false || k === 0) { + const needsClipping = (k > min || k < max) && hasMargins.call(this); + if (needsClipping) { + this.pdf.saveGraphicsState(); + this.pdf + .rect( + this.margin[3], + this.margin[0], + pageWidthMinusMargins, + pageHeightMinusMargins, + null + ) + .clip() + .discardPath(); + } + drawPaths.call(this, rule, isClip); + if (needsClipping) { + this.pdf.restoreGraphicsState(); + } } - this.path = origPath; - } else { - this.lineWidth = lineWidth; - drawPaths.call(this, rule, isClip); this.lineWidth = oldLineWidth; } - }; - - /** - * Processes the paths - * - * @function - * @param rule {String} - * @param isClip {Boolean} - * @private - * @ignore - */ - var drawPaths = function(rule, isClip) { - if (rule === "stroke" && !isClip && isStrokeTransparent.call(this)) { - return; - } - - if (rule !== "stroke" && !isClip && isFillTransparent.call(this)) { - return; - } - - var moves = []; - - //var alpha = (this.ctx.fillOpacity < 1) ? this.ctx.fillOpacity : this.ctx.globalAlpha; - var delta; - var xPath = this.path; - for (var i = 0; i < xPath.length; i++) { - var pt = xPath[i]; + this.path = origPath; + } else { + this.lineWidth = lineWidth; + drawPaths.call(this, rule, isClip); + this.lineWidth = oldLineWidth; + } +}; - switch (pt.type) { - case "begin": - moves.push({ - begin: true - }); - break; +/** + * Processes the paths + * + * @function + * @param rule {String} + * @param isClip {Boolean} + * @private + * @ignore + */ +var drawPaths = function ( + this: Context2D, + rule: string | null, + isClip: boolean +): void { + if (rule === "stroke" && !isClip && isStrokeTransparent.call(this)) { + return; + } + + if (rule !== "stroke" && !isClip && isFillTransparent.call(this)) { + return; + } + + var moves: PathMove[] = []; + + //var alpha = (this.ctx.fillOpacity < 1) ? this.ctx.fillOpacity : this.ctx.globalAlpha; + var delta; + var xPath = this.path; + for (var i = 0; i < xPath.length; i++) { + var pt = xPath[i]; + + switch (pt.type) { + case "begin": + moves.push({ + begin: true + }); + break; - case "close": - moves.push({ - close: true - }); - break; + case "close": + moves.push({ + close: true + }); + break; - case "mt": - moves.push({ - start: pt, - deltas: [], - abs: [] - }); - break; + case "mt": + moves.push({ + start: pt, + deltas: [], + abs: [] + }); + break; - case "lt": - var iii = moves.length; - if (xPath[i - 1] && !isNaN(xPath[i - 1].x)) { - delta = [pt.x - xPath[i - 1].x, pt.y - xPath[i - 1].y]; - if (iii > 0) { - for (iii; iii >= 0; iii--) { - if ( - moves[iii - 1].close !== true && - moves[iii - 1].begin !== true - ) { - moves[iii - 1].deltas.push(delta); - moves[iii - 1].abs.push(pt); - break; - } + case "lt": + var iii = moves.length; + if (xPath[i - 1] && !isNaN(xPath[i - 1].x)) { + delta = [pt.x - xPath[i - 1].x, pt.y - xPath[i - 1].y]; + if (iii > 0) { + for (iii; iii >= 0; iii--) { + if ( + moves[iii - 1].close !== true && + moves[iii - 1].begin !== true + ) { + moves[iii - 1].deltas.push(delta); + moves[iii - 1].abs.push(pt); + break; } } } - break; + } + break; - case "bct": - delta = [ - pt.x1 - xPath[i - 1].x, - pt.y1 - xPath[i - 1].y, - pt.x2 - xPath[i - 1].x, - pt.y2 - xPath[i - 1].y, - pt.x - xPath[i - 1].x, - pt.y - xPath[i - 1].y - ]; - moves[moves.length - 1].deltas.push(delta); - break; + case "bct": + delta = [ + pt.x1 - xPath[i - 1].x, + pt.y1 - xPath[i - 1].y, + pt.x2 - xPath[i - 1].x, + pt.y2 - xPath[i - 1].y, + pt.x - xPath[i - 1].x, + pt.y - xPath[i - 1].y + ]; + moves[moves.length - 1].deltas.push(delta); + break; - case "qct": - var x1 = xPath[i - 1].x + (2.0 / 3.0) * (pt.x1 - xPath[i - 1].x); - var y1 = xPath[i - 1].y + (2.0 / 3.0) * (pt.y1 - xPath[i - 1].y); - var x2 = pt.x + (2.0 / 3.0) * (pt.x1 - pt.x); - var y2 = pt.y + (2.0 / 3.0) * (pt.y1 - pt.y); - var x3 = pt.x; - var y3 = pt.y; - delta = [ - x1 - xPath[i - 1].x, - y1 - xPath[i - 1].y, - x2 - xPath[i - 1].x, - y2 - xPath[i - 1].y, - x3 - xPath[i - 1].x, - y3 - xPath[i - 1].y - ]; - moves[moves.length - 1].deltas.push(delta); - break; + case "qct": + var x1 = xPath[i - 1].x + (2.0 / 3.0) * (pt.x1 - xPath[i - 1].x); + var y1 = xPath[i - 1].y + (2.0 / 3.0) * (pt.y1 - xPath[i - 1].y); + var x2 = pt.x + (2.0 / 3.0) * (pt.x1 - pt.x); + var y2 = pt.y + (2.0 / 3.0) * (pt.y1 - pt.y); + var x3 = pt.x; + var y3 = pt.y; + delta = [ + x1 - xPath[i - 1].x, + y1 - xPath[i - 1].y, + x2 - xPath[i - 1].x, + y2 - xPath[i - 1].y, + x3 - xPath[i - 1].x, + y3 - xPath[i - 1].y + ]; + moves[moves.length - 1].deltas.push(delta); + break; - case "arc": - moves.push({ - deltas: [], - abs: [], - arc: true - }); + case "arc": + moves.push({ + deltas: [], + abs: [], + arc: true + }); - if (Array.isArray(moves[moves.length - 1].abs)) { - moves[moves.length - 1].abs.push(pt); - } - break; - } + if (Array.isArray(moves[moves.length - 1].abs)) { + moves[moves.length - 1].abs.push(pt); + } + break; } - var style; - if (!isClip) { - if (rule === "stroke") { - style = "stroke"; - } else { - style = "fill"; - } + } + var style: string | null; + if (!isClip) { + if (rule === "stroke") { + style = "stroke"; } else { - style = null; - } - - var began = false; - for (var k = 0; k < moves.length; k++) { - if (moves[k].arc) { - var arcs = moves[k].abs; - - for (var ii = 0; ii < arcs.length; ii++) { - var arc = arcs[ii]; - - if (arc.type === "arc") { - drawArc.call( - this, - arc.x, - arc.y, - arc.radius, - arc.startAngle, - arc.endAngle, - arc.counterclockwise, - undefined, - isClip, - !began - ); - } else { - drawLine.call(this, arc.x, arc.y); - } - began = true; + style = "fill"; + } + } else { + style = null; + } + + var began = false; + for (var k = 0; k < moves.length; k++) { + if (moves[k].arc) { + var arcs = moves[k].abs; + + for (var ii = 0; ii < arcs.length; ii++) { + var arc = arcs[ii]; + + if (arc.type === "arc") { + drawArc.call( + this, + arc.x, + arc.y, + arc.radius, + arc.startAngle, + arc.endAngle, + arc.counterclockwise, + undefined, + isClip, + !began + ); + } else { + drawLine.call(this, arc.x, arc.y); } - } else if (moves[k].close === true) { - this.pdf.internal.out("h"); - began = false; - } else if (moves[k].begin !== true) { - var x = moves[k].start.x; - var y = moves[k].start.y; - drawLines.call(this, moves[k].deltas, x, y); began = true; } - } - - if (style) { - putStyle.call(this, style); - } - if (isClip) { - doClip.call(this); - } - }; - - var getBaseline = function(y) { - var height = - this.pdf.internal.getFontSize() / this.pdf.internal.scaleFactor; - var descent = height * (this.pdf.internal.getLineHeightFactor() - 1); - switch (this.ctx.textBaseline) { - case "bottom": - return y - descent; - case "top": - return y + height - descent; - case "hanging": - return y + height - 2 * descent; - case "middle": - return y + height / 2 - descent; - case "ideographic": - // TODO not implemented - return y; - case "alphabetic": - default: - return y; - } - }; + } else if (moves[k].close === true) { + this.pdf.internal.out("h"); + began = false; + } else if (moves[k].begin !== true) { + var x = moves[k].start.x; + var y = moves[k].start.y; + drawLines.call(this, moves[k].deltas, x, y); + began = true; + } + } + + if (style) { + putStyle.call(this, style); + } + if (isClip) { + doClip.call(this); + } +}; + +var getBaseline = function (this: Context2D, y: number): number { + var height = this.pdf.internal.getFontSize() / this.pdf.internal.scaleFactor; + var descent = height * (this.pdf.internal.getLineHeightFactor() - 1); + switch (this.ctx.textBaseline) { + case "bottom": + return y - descent; + case "top": + return y + height - descent; + case "hanging": + return y + height - 2 * descent; + case "middle": + return y + height / 2 - descent; + case "ideographic": + // TODO not implemented + return y; + case "alphabetic": + default: + return y; + } +}; + +var getTextBottom = function (this: Context2D, yBaseLine: number): number { + var height = this.pdf.internal.getFontSize() / this.pdf.internal.scaleFactor; + var descent = height * (this.pdf.internal.getLineHeightFactor() - 1); + return yBaseLine + descent; +}; - var getTextBottom = function(yBaseLine) { - var height = - this.pdf.internal.getFontSize() / this.pdf.internal.scaleFactor; - var descent = height * (this.pdf.internal.getLineHeightFactor() - 1); - return yBaseLine + descent; - }; - - Context2D.prototype.createLinearGradient = function createLinearGradient() { - var canvasGradient: any = function canvasGradient() {}; - - canvasGradient.colorStops = []; - canvasGradient.addColorStop = function(offset, color) { - this.colorStops.push([offset, color]); - }; - - canvasGradient.getColor = function() { - if (this.colorStops.length === 0) { - return "#000000"; - } - - return this.colorStops[0][1]; - }; - - canvasGradient.isCanvasGradient = true; - return canvasGradient; - }; - Context2D.prototype.createPattern = function createPattern() { - return this.createLinearGradient(); - }; - Context2D.prototype.createRadialGradient = function createRadialGradient() { - return this.createLinearGradient(); - }; - - /** - * - * @param x Edge point X - * @param y Edge point Y - * @param r Radius - * @param a1 start angle - * @param a2 end angle - * @param counterclockwise - * @param style - * @param isClip - */ - var drawArc = function( - x, - y, - r, - a1, - a2, - counterclockwise?, - style?, - isClip?, - includeMove? - ) { - // http://hansmuller-flex.blogspot.com/2011/10/more-about-approximating-circular-arcs.html - var curves = createArc.call(this, r, a1, a2, counterclockwise); - - for (var i = 0; i < curves.length; i++) { - var curve = curves[i]; - if (i === 0) { - if (includeMove) { - doMove.call(this, curve.x1 + x, curve.y1 + y); - } else { - drawLine.call(this, curve.x1 + x, curve.y1 + y); - } +/** + * + * @param x Edge point X + * @param y Edge point Y + * @param r Radius + * @param a1 start angle + * @param a2 end angle + * @param counterclockwise + * @param style + * @param isClip + */ +var drawArc = function ( + this: Context2D, + x: number, + y: number, + r: number, + a1: number, + a2: number, + counterclockwise?: boolean, + style?: string, + isClip?: boolean, + includeMove?: boolean +): void { + // http://hansmuller-flex.blogspot.com/2011/10/more-about-approximating-circular-arcs.html + var curves = createArc.call(this, r, a1, a2, counterclockwise); + + for (var i = 0; i < curves.length; i++) { + var curve = curves[i]; + if (i === 0) { + if (includeMove) { + doMove.call(this, curve.x1 + x, curve.y1 + y); + } else { + drawLine.call(this, curve.x1 + x, curve.y1 + y); } - drawCurve.call( - this, - x, - y, - curve.x2, - curve.y2, - curve.x3, - curve.y3, - curve.x4, - curve.y4 - ); } - - if (!isClip) { - putStyle.call(this, style); - } else { - doClip.call(this); - } - }; - - var putStyle = function(style) { - switch (style) { - case "stroke": - this.pdf.internal.out("S"); - break; - case "fill": - this.pdf.internal.out("f"); - break; - } - }; - - var doClip = function() { - this.pdf.clip(); - this.pdf.discardPath(); - }; - - var doMove = function(x, y) { - this.pdf.internal.out( - getHorizontalCoordinateString(x) + - " " + - getVerticalCoordinateString(y) + - " m" + drawCurve.call( + this, + x, + y, + curve.x2, + curve.y2, + curve.x3, + curve.y3, + curve.x4, + curve.y4 ); - }; - - var putText = function(options) { - var textAlign; - switch (options.align) { - case "right": - case "end": - textAlign = "right"; - break; - case "center": - textAlign = "center"; - break; - case "left": - case "start": - default: - textAlign = "left"; - break; - } - - var textDimensions = this.pdf.getTextDimensions(options.text); - var yBaseLine = getBaseline.call(this, options.y); - var yBottom = getTextBottom.call(this, yBaseLine); - var yTop = yBottom - textDimensions.h; - - var pt = this.ctx.transform.applyToPoint(new Point(options.x, yBaseLine)); - - var clipPath, oldSize, oldLineWidth; + } + + if (!isClip) { + putStyle.call(this, style); + } else { + doClip.call(this); + } +}; + +var putStyle = function (this: Context2D, style?: string | null): void { + switch (style) { + case "stroke": + this.pdf.internal.out("S"); + break; + case "fill": + this.pdf.internal.out("f"); + break; + } +}; + +var doClip = function (this: Context2D): void { + this.pdf.clip(); + this.pdf.discardPath(); +}; + +var doMove = function (this: Context2D, x: number, y: number): void { + this.pdf.internal.out( + getHorizontalCoordinateString(x) + + " " + + getVerticalCoordinateString(y) + + " m" + ); +}; + +var putText = function (this: Context2D, options: PutTextOptions): void { + var textAlign: "left" | "center" | "right"; + switch (options.align) { + case "right": + case "end": + textAlign = "right"; + break; + case "center": + textAlign = "center"; + break; + case "left": + case "start": + default: + textAlign = "left"; + break; + } + + var textDimensions = this.pdf.getTextDimensions(options.text); + var yBaseLine = getBaseline.call(this, options.y); + var yBottom = getTextBottom.call(this, yBaseLine); + var yTop = yBottom - textDimensions.h; + + var pt = this.ctx.transform.applyToPoint(new Point(options.x, yBaseLine)); + + var clipPath: PathEntry[]; + var oldSize: number; + var oldLineWidth: number; + + if (this.autoPaging) { + var decomposedTransformationMatrix = this.ctx.transform.decompose(); + var matrix = new Matrix(); + matrix = matrix.multiply(decomposedTransformationMatrix.translate); + matrix = matrix.multiply(decomposedTransformationMatrix.skew); + matrix = matrix.multiply(decomposedTransformationMatrix.scale); - if (this.autoPaging) { - var decomposedTransformationMatrix = this.ctx.transform.decompose(); - var matrix = new Matrix(); - matrix = matrix.multiply(decomposedTransformationMatrix.translate); - matrix = matrix.multiply(decomposedTransformationMatrix.skew); - matrix = matrix.multiply(decomposedTransformationMatrix.scale); - - var baselineRect = this.ctx.transform.applyToRectangle( - new Rectangle(options.x, yBaseLine, textDimensions.w, textDimensions.h) - ); - var textBounds = matrix.applyToRectangle( - new Rectangle(options.x, yTop, textDimensions.w, textDimensions.h) - ); - var pageArray = getPagesByPath.call(this, textBounds); - var pages = []; - for (var ii = 0; ii < pageArray.length; ii += 1) { - if (pages.indexOf(pageArray[ii]) === -1) { - pages.push(pageArray[ii]); - } + var baselineRect = this.ctx.transform.applyToRectangle( + new Rectangle(options.x, yBaseLine, textDimensions.w, textDimensions.h) + ); + var textBounds = matrix.applyToRectangle( + new Rectangle(options.x, yTop, textDimensions.w, textDimensions.h) + ); + var pageArray = getPagesByPath.call(this, textBounds); + var pages: number[] = []; + for (var ii = 0; ii < pageArray.length; ii += 1) { + if (pages.indexOf(pageArray[ii]) === -1) { + pages.push(pageArray[ii]); } + } - sortPages(pages); - - var min = pages[0]; - var max = pages[pages.length - 1]; - for (var i = min; i < max + 1; i++) { - this.pdf.setPage(i); - - var topMargin = i === 1 ? this.posY + this.margin[0] : this.margin[0]; - var firstPageHeight = - this.pdf.internal.pageSize.height - - this.posY - - this.margin[0] - - this.margin[2]; - var pageHeightMinusBottomMargin = - this.pdf.internal.pageSize.height - this.margin[2]; - var pageHeightMinusMargins = - pageHeightMinusBottomMargin - this.margin[0]; - var pageWidthMinusRightMargin = - this.pdf.internal.pageSize.width - this.margin[1]; - var pageWidthMinusMargins = pageWidthMinusRightMargin - this.margin[3]; - var previousPageHeightSum = - i === 1 ? 0 : firstPageHeight + (i - 2) * pageHeightMinusMargins; - - if (this.ctx.clip_path.length !== 0) { - var tmpPaths = this.path; - clipPath = JSON.parse(JSON.stringify(this.ctx.clip_path)); - this.path = pathPositionRedo( - clipPath, - this.posX + this.margin[3], - -1 * previousPageHeightSum + topMargin - ); - drawPaths.call(this, "fill", true); - this.path = tmpPaths; - } - var textBoundsOnPage = pathPositionRedo( - [JSON.parse(JSON.stringify(textBounds))], + sortPages(pages); + + var min = pages[0]; + var max = pages[pages.length - 1]; + for (var i = min; i < max + 1; i++) { + this.pdf.setPage(i); + + var topMargin = i === 1 ? this.posY + this.margin[0] : this.margin[0]; + var firstPageHeight = + this.pdf.internal.pageSize.height - + this.posY - + this.margin[0] - + this.margin[2]; + var pageHeightMinusBottomMargin = + this.pdf.internal.pageSize.height - this.margin[2]; + var pageHeightMinusMargins = pageHeightMinusBottomMargin - this.margin[0]; + var pageWidthMinusRightMargin = + this.pdf.internal.pageSize.width - this.margin[1]; + var pageWidthMinusMargins = pageWidthMinusRightMargin - this.margin[3]; + var previousPageHeightSum = + i === 1 ? 0 : firstPageHeight + (i - 2) * pageHeightMinusMargins; + + if (this.ctx.clip_path.length !== 0) { + var tmpPaths = this.path; + clipPath = JSON.parse(JSON.stringify(this.ctx.clip_path)); + this.path = pathPositionRedo( + clipPath, this.posX + this.margin[3], - -previousPageHeightSum + topMargin + this.ctx.prevPageLastElemOffset - )[0]; + -1 * previousPageHeightSum + topMargin + ); + drawPaths.call(this, "fill", true); + this.path = tmpPaths; + } + var textBoundsOnPage = pathPositionRedo( + [JSON.parse(JSON.stringify(textBounds))], + this.posX + this.margin[3], + -previousPageHeightSum + topMargin + this.ctx.prevPageLastElemOffset + )[0]; - if (options.scale >= 0.01) { - oldSize = this.pdf.internal.getFontSize(); - this.pdf.setFontSize(oldSize * options.scale); - oldLineWidth = this.lineWidth; - this.lineWidth = oldLineWidth * options.scale; - } + if (options.scale >= 0.01) { + oldSize = this.pdf.internal.getFontSize(); + this.pdf.setFontSize(oldSize * options.scale); + oldLineWidth = this.lineWidth; + this.lineWidth = oldLineWidth * options.scale; + } - var doSlice = this.autoPaging !== "text"; + var doSlice = this.autoPaging !== "text"; + if ( + doSlice || + textBoundsOnPage.y + textBoundsOnPage.h <= pageHeightMinusBottomMargin + ) { if ( doSlice || - textBoundsOnPage.y + textBoundsOnPage.h <= pageHeightMinusBottomMargin + (textBoundsOnPage.y >= topMargin && + textBoundsOnPage.x <= pageWidthMinusRightMargin) ) { - if ( - doSlice || - (textBoundsOnPage.y >= topMargin && - textBoundsOnPage.x <= pageWidthMinusRightMargin) - ) { - var croppedText = doSlice - ? options.text - : this.pdf.splitTextToSize( - options.text, - options.maxWidth || - pageWidthMinusRightMargin - textBoundsOnPage.x - )[0]; - var baseLineRectOnPage = pathPositionRedo( - [JSON.parse(JSON.stringify(baselineRect))], - this.posX + this.margin[3], - -previousPageHeightSum + - topMargin + - this.ctx.prevPageLastElemOffset - )[0]; - - const needsClipping = - doSlice && (i > min || i < max) && hasMargins.call(this); - - if (needsClipping) { - this.pdf.saveGraphicsState(); - this.pdf - .rect( - this.margin[3], - this.margin[0], - pageWidthMinusMargins, - pageHeightMinusMargins, - null - ) - .clip() - .discardPath(); - } + var croppedText = doSlice + ? options.text + : this.pdf.splitTextToSize( + options.text, + options.maxWidth || + pageWidthMinusRightMargin - textBoundsOnPage.x + )[0]; + var baseLineRectOnPage = pathPositionRedo( + [JSON.parse(JSON.stringify(baselineRect))], + this.posX + this.margin[3], + -previousPageHeightSum + topMargin + this.ctx.prevPageLastElemOffset + )[0]; - this.pdf.text( - croppedText, - baseLineRectOnPage.x, - baseLineRectOnPage.y, - { - angle: options.angle, - align: textAlign, - renderingMode: options.renderingMode - } - ); + const needsClipping = + doSlice && (i > min || i < max) && hasMargins.call(this); - if (needsClipping) { - this.pdf.restoreGraphicsState(); - } + if (needsClipping) { + this.pdf.saveGraphicsState(); + this.pdf + .rect( + this.margin[3], + this.margin[0], + pageWidthMinusMargins, + pageHeightMinusMargins, + null + ) + .clip() + .discardPath(); } - } else { - // This text is the last element of the page, but it got cut off due to the margin - // so we render it in the next page - if (textBoundsOnPage.y < pageHeightMinusBottomMargin) { - // As a result, all other elements have their y offset increased - this.ctx.prevPageLastElemOffset += - pageHeightMinusBottomMargin - textBoundsOnPage.y; + this.pdf.text( + croppedText, + baseLineRectOnPage.x, + baseLineRectOnPage.y, + { + angle: options.angle, + align: textAlign, + renderingMode: options.renderingMode + } + ); + + if (needsClipping) { + this.pdf.restoreGraphicsState(); } } + } else { + // This text is the last element of the page, but it got cut off due to the margin + // so we render it in the next page - if (options.scale >= 0.01) { - this.pdf.setFontSize(oldSize); - this.lineWidth = oldLineWidth; + if (textBoundsOnPage.y < pageHeightMinusBottomMargin) { + // As a result, all other elements have their y offset increased + this.ctx.prevPageLastElemOffset += + pageHeightMinusBottomMargin - textBoundsOnPage.y; } } - } else { - if (options.scale >= 0.01) { - oldSize = this.pdf.internal.getFontSize(); - this.pdf.setFontSize(oldSize * options.scale); - oldLineWidth = this.lineWidth; - this.lineWidth = oldLineWidth * options.scale; - } - this.pdf.text(options.text, pt.x + this.posX, pt.y + this.posY, { - angle: options.angle, - align: textAlign, - renderingMode: options.renderingMode, - maxWidth: options.maxWidth - }); if (options.scale >= 0.01) { this.pdf.setFontSize(oldSize); this.lineWidth = oldLineWidth; } } - }; - - var drawLine = function(x, y, prevX?, prevY?) { - prevX = prevX || 0; - prevY = prevY || 0; - - this.pdf.internal.out( - getHorizontalCoordinateString(x + prevX) + - " " + - getVerticalCoordinateString(y + prevY) + - " l" - ); - }; - - var drawLines = function(lines, x, y) { - return this.pdf.lines(lines, x, y, null, null); - }; - - var drawCurve = function(x, y, x1, y1, x2, y2, x3, y3) { - this.pdf.internal.out( - [ - f2(getHorizontalCoordinate(x1 + x)), - f2(getVerticalCoordinate(y1 + y)), - f2(getHorizontalCoordinate(x2 + x)), - f2(getVerticalCoordinate(y2 + y)), - f2(getHorizontalCoordinate(x3 + x)), - f2(getVerticalCoordinate(y3 + y)), - "c" - ].join(" ") - ); - }; - - /** - * Return a array of objects that represent bezier curves which approximate the circular arc centered at the origin, from startAngle to endAngle (radians) with the specified radius. - * - * Each bezier curve is an object with four points, where x1,y1 and x4,y4 are the arc's end points and x2,y2 and x3,y3 are the cubic bezier's control points. - * @function createArc - */ - var createArc = function(radius, startAngle, endAngle, anticlockwise) { - var EPSILON = 0.00001; // Roughly 1/1000th of a degree, see below - var twoPi = Math.PI * 2; - var halfPi = Math.PI / 2.0; - - while (startAngle > endAngle) { - startAngle = startAngle - twoPi; - } - var totalAngle = Math.abs(endAngle - startAngle); - if (totalAngle < twoPi) { - if (anticlockwise) { - totalAngle = twoPi - totalAngle; - } - } - - // Compute the sequence of arc curves, up to PI/2 at a time. - var curves = []; - - // clockwise or counterclockwise - var sgn = anticlockwise ? -1 : +1; + } else { + if (options.scale >= 0.01) { + oldSize = this.pdf.internal.getFontSize(); + this.pdf.setFontSize(oldSize * options.scale); + oldLineWidth = this.lineWidth; + this.lineWidth = oldLineWidth * options.scale; + } + this.pdf.text(options.text, pt.x + this.posX, pt.y + this.posY, { + angle: options.angle, + align: textAlign, + renderingMode: options.renderingMode, + maxWidth: options.maxWidth + }); - var a1 = startAngle; - for (; totalAngle > EPSILON; ) { - var remain = sgn * Math.min(totalAngle, halfPi); - var a2 = a1 + remain; - curves.push(createSmallArc.call(this, radius, a1, a2)); - totalAngle -= Math.abs(a2 - a1); - a1 = a2; + if (options.scale >= 0.01) { + this.pdf.setFontSize(oldSize); + this.lineWidth = oldLineWidth; } + } +}; + +var drawLine = function ( + this: Context2D, + x: number, + y: number, + prevX?: number, + prevY?: number +): void { + prevX = prevX || 0; + prevY = prevY || 0; + + this.pdf.internal.out( + getHorizontalCoordinateString(x + prevX) + + " " + + getVerticalCoordinateString(y + prevY) + + " l" + ); +}; + +var drawLines = function ( + this: Context2D, + lines: number[][], + x: number, + y: number +): jsPDFDocument { + return this.pdf.lines(lines, x, y, null, null); +}; + +var drawCurve = function ( + this: Context2D, + x: number, + y: number, + x1: number, + y1: number, + x2: number, + y2: number, + x3: number, + y3: number +): void { + this.pdf.internal.out( + [ + f2(getHorizontalCoordinate(x1 + x)), + f2(getVerticalCoordinate(y1 + y)), + f2(getHorizontalCoordinate(x2 + x)), + f2(getVerticalCoordinate(y2 + y)), + f2(getHorizontalCoordinate(x3 + x)), + f2(getVerticalCoordinate(y3 + y)), + "c" + ].join(" ") + ); +}; - return curves; - }; - - /** - * Cubic bezier approximation of a circular arc centered at the origin, from (radians) a1 to a2, where a2-a1 < pi/2. The arc's radius is r. - * - * Returns an object with four points, where x1,y1 and x4,y4 are the arc's end points and x2,y2 and x3,y3 are the cubic bezier's control points. - * - * This algorithm is based on the approach described in: A. Riškus, "Approximation of a Cubic Bezier Curve by Circular Arcs and Vice Versa," Information Technology and Control, 35(4), 2006 pp. 371-378. - */ - var createSmallArc = function(r, a1, a2) { - var a = (a2 - a1) / 2.0; - - var x4 = r * Math.cos(a); - var y4 = r * Math.sin(a); - var x1 = x4; - var y1 = -y4; - - var q1 = x1 * x1 + y1 * y1; - var q2 = q1 + x1 * x4 + y1 * y4; - var k2 = ((4 / 3) * (Math.sqrt(2 * q1 * q2) - q2)) / (x1 * y4 - y1 * x4); - - var x2 = x1 - k2 * y1; - var y2 = y1 + k2 * x1; - var x3 = x2; - var y3 = -y2; - - var ar = a + a1; - var cos_ar = Math.cos(ar); - var sin_ar = Math.sin(ar); - - return { - x1: r * Math.cos(a1), - y1: r * Math.sin(a1), - x2: x2 * cos_ar - y2 * sin_ar, - y2: x2 * sin_ar + y2 * cos_ar, - x3: x3 * cos_ar - y3 * sin_ar, - y3: x3 * sin_ar + y3 * cos_ar, - x4: r * Math.cos(a2), - y4: r * Math.sin(a2) - }; - }; - - var rad2deg = function(value) { - return (value * 180) / Math.PI; - }; - - var getQuadraticCurveBoundary = function(sx, sy, cpx, cpy, ex, ey) { - var midX1 = sx + (cpx - sx) * 0.5; - var midY1 = sy + (cpy - sy) * 0.5; - var midX2 = ex + (cpx - ex) * 0.5; - var midY2 = ey + (cpy - ey) * 0.5; - var resultX1 = Math.min(sx, ex, midX1, midX2); - var resultX2 = Math.max(sx, ex, midX1, midX2); - var resultY1 = Math.min(sy, ey, midY1, midY2); - var resultY2 = Math.max(sy, ey, midY1, midY2); - return new Rectangle( - resultX1, - resultY1, - resultX2 - resultX1, - resultY2 - resultY1 - ); - }; - - //De Casteljau algorithm - var getBezierCurveBoundary = function(ax, ay, bx, by, cx, cy, dx, dy) { - var tobx = bx - ax; - var toby = by - ay; - var tocx = cx - bx; - var tocy = cy - by; - var todx = dx - cx; - var tody = dy - cy; - var precision = 40; - var d, - i, - px, - py, - qx, - qy, - rx, - ry, - tx, - ty, - sx, - sy, - x, - y, - minx, - miny, - maxx, - maxy, - toqx, - toqy, - torx, - tory, - totx, - toty; - for (i = 0; i < precision + 1; i++) { - d = i / precision; - px = ax + d * tobx; - py = ay + d * toby; - qx = bx + d * tocx; - qy = by + d * tocy; - rx = cx + d * todx; - ry = cy + d * tody; - toqx = qx - px; - toqy = qy - py; - torx = rx - qx; - tory = ry - qy; - - sx = px + d * toqx; - sy = py + d * toqy; - tx = qx + d * torx; - ty = qy + d * tory; - totx = tx - sx; - toty = ty - sy; - - x = sx + d * totx; - y = sy + d * toty; - if (i == 0) { - minx = x; - miny = y; - maxx = x; - maxy = y; - } else { - minx = Math.min(minx, x); - miny = Math.min(miny, y); - maxx = Math.max(maxx, x); - maxy = Math.max(maxy, y); - } - } - return new Rectangle( - Math.round(minx), - Math.round(miny), - Math.round(maxx - minx), - Math.round(maxy - miny) - ); - }; +/** + * Return a array of objects that represent bezier curves which approximate the circular arc centered at the origin, from startAngle to endAngle (radians) with the specified radius. + * + * Each bezier curve is an object with four points, where x1,y1 and x4,y4 are the arc's end points and x2,y2 and x3,y3 are the cubic bezier's control points. + * @function createArc + */ +var createArc = function ( + radius: number, + startAngle: number, + endAngle: number, + anticlockwise?: boolean +): ArcCurve[] { + var EPSILON = 0.00001; // Roughly 1/1000th of a degree, see below + var twoPi = Math.PI * 2; + var halfPi = Math.PI / 2.0; + + while (startAngle > endAngle) { + startAngle = startAngle - twoPi; + } + var totalAngle = Math.abs(endAngle - startAngle); + if (totalAngle < twoPi) { + if (anticlockwise) { + totalAngle = twoPi - totalAngle; + } + } + + // Compute the sequence of arc curves, up to PI/2 at a time. + var curves: ArcCurve[] = []; + + // clockwise or counterclockwise + var sgn = anticlockwise ? -1 : +1; + + var a1 = startAngle; + for (; totalAngle > EPSILON;) { + var remain = sgn * Math.min(totalAngle, halfPi); + var a2 = a1 + remain; + curves.push(createSmallArc(radius, a1, a2)); + totalAngle -= Math.abs(a2 - a1); + a1 = a2; + } + + return curves; +}; - var getPrevLineDashValue = function(lineDash, lineDashOffset) { - return JSON.stringify({ - lineDash: lineDash, - lineDashOffset: lineDashOffset - }); +/** + * Cubic bezier approximation of a circular arc centered at the origin, from (radians) a1 to a2, where a2-a1 < pi/2. The arc's radius is r. + * + * Returns an object with four points, where x1,y1 and x4,y4 are the arc's end points and x2,y2 and x3,y3 are the cubic bezier's control points. + * + * This algorithm is based on the approach described in: A. Riškus, "Approximation of a Cubic Bezier Curve by Circular Arcs and Vice Versa," Information Technology and Control, 35(4), 2006 pp. 371-378. + */ +var createSmallArc = function (r: number, a1: number, a2: number): ArcCurve { + var a = (a2 - a1) / 2.0; + + var x4 = r * Math.cos(a); + var y4 = r * Math.sin(a); + var x1 = x4; + var y1 = -y4; + + var q1 = x1 * x1 + y1 * y1; + var q2 = q1 + x1 * x4 + y1 * y4; + var k2 = ((4 / 3) * (Math.sqrt(2 * q1 * q2) - q2)) / (x1 * y4 - y1 * x4); + + var x2 = x1 - k2 * y1; + var y2 = y1 + k2 * x1; + var x3 = x2; + var y3 = -y2; + + var ar = a + a1; + var cos_ar = Math.cos(ar); + var sin_ar = Math.sin(ar); + + return { + x1: r * Math.cos(a1), + y1: r * Math.sin(a1), + x2: x2 * cos_ar - y2 * sin_ar, + y2: x2 * sin_ar + y2 * cos_ar, + x3: x3 * cos_ar - y3 * sin_ar, + y3: x3 * sin_ar + y3 * cos_ar, + x4: r * Math.cos(a2), + y4: r * Math.sin(a2) }; +}; + +var rad2deg = function (value: number): number { + return (value * 180) / Math.PI; +}; + +var getQuadraticCurveBoundary = function ( + sx: number, + sy: number, + cpx: number, + cpy: number, + ex: number, + ey: number +): RectangleType { + var midX1 = sx + (cpx - sx) * 0.5; + var midY1 = sy + (cpy - sy) * 0.5; + var midX2 = ex + (cpx - ex) * 0.5; + var midY2 = ey + (cpy - ey) * 0.5; + var resultX1 = Math.min(sx, ex, midX1, midX2); + var resultX2 = Math.max(sx, ex, midX1, midX2); + var resultY1 = Math.min(sy, ey, midY1, midY2); + var resultY2 = Math.max(sy, ey, midY1, midY2); + return new Rectangle( + resultX1, + resultY1, + resultX2 - resultX1, + resultY2 - resultY1 + ); +}; + +//De Casteljau algorithm +var getBezierCurveBoundary = function ( + ax: number, + ay: number, + bx: number, + by: number, + cx: number, + cy: number, + dx: number, + dy: number +): RectangleType { + var tobx = bx - ax; + var toby = by - ay; + var tocx = cx - bx; + var tocy = cy - by; + var todx = dx - cx; + var tody = dy - cy; + var precision = 40; + var d: number, + i: number, + px: number, + py: number, + qx: number, + qy: number, + rx: number, + ry: number, + tx: number, + ty: number, + sx: number, + sy: number, + x: number, + y: number, + minx: number, + miny: number, + maxx: number, + maxy: number, + toqx: number, + toqy: number, + torx: number, + tory: number, + totx: number, + toty: number; + for (i = 0; i < precision + 1; i++) { + d = i / precision; + px = ax + d * tobx; + py = ay + d * toby; + qx = bx + d * tocx; + qy = by + d * tocy; + rx = cx + d * todx; + ry = cy + d * tody; + toqx = qx - px; + toqy = qy - py; + torx = rx - qx; + tory = ry - qy; + + sx = px + d * toqx; + sy = py + d * toqy; + tx = qx + d * torx; + ty = qy + d * tory; + totx = tx - sx; + toty = ty - sy; + + x = sx + d * totx; + y = sy + d * toty; + if (i == 0) { + minx = x; + miny = y; + maxx = x; + maxy = y; + } else { + minx = Math.min(minx, x); + miny = Math.min(miny, y); + maxx = Math.max(maxx, x); + maxy = Math.max(maxy, y); + } + } + return new Rectangle( + Math.round(minx), + Math.round(miny), + Math.round(maxx - minx), + Math.round(maxy - miny) + ); +}; + +var getPrevLineDashValue = function ( + lineDash: number[], + lineDashOffset: number +): string { + return JSON.stringify({ + lineDash: lineDash, + lineDashOffset: lineDashOffset + }); +}; + +var setLineDash = function (this: Context2D): void { + // Avoid unnecessary line dash declarations. + if ( + !this.prevLineDash && + !this.ctx.lineDash.length && + !this.ctx.lineDashOffset + ) { + return; + } + + // Avoid unnecessary line dash declarations. + const nextLineDash = getPrevLineDashValue( + this.ctx.lineDash, + this.ctx.lineDashOffset + ); + if (this.prevLineDash !== nextLineDash) { + this.pdf.setLineDash(this.ctx.lineDash, this.ctx.lineDashOffset); + this.prevLineDash = nextLineDash; + } +}; + +(function (jsPDFAPI: JsPDFAPI) { + "use strict"; - var setLineDash = function() { - // Avoid unnecessary line dash declarations. - if ( - !this.prevLineDash && - !this.ctx.lineDash.length && - !this.ctx.lineDashOffset - ) { - return; - } + jsPDFAPI.events.push([ + "initialized", + function (this: jsPDFDocument) { + this.context2d = new Context2D(this); - // Avoid unnecessary line dash declarations. - const nextLineDash = getPrevLineDashValue( - this.ctx.lineDash, - this.ctx.lineDashOffset - ); - if (this.prevLineDash !== nextLineDash) { - this.pdf.setLineDash(this.ctx.lineDash, this.ctx.lineDashOffset); - this.prevLineDash = nextLineDash; + f2 = this.internal.f2; + getHorizontalCoordinateString = this.internal.getCoordinateString; + getVerticalCoordinateString = this.internal.getVerticalCoordinateString; + getHorizontalCoordinate = this.internal.getHorizontalCoordinate; + getVerticalCoordinate = this.internal.getVerticalCoordinate; + Point = this.internal.Point; + Rectangle = this.internal.Rectangle; + Matrix = this.internal.Matrix; + _ctx = new ContextLayer(); } - }; + ]); })(jsPDF.API); diff --git a/src/modules/fileloading.ts b/src/modules/fileloading.ts index de2facf1f..41d5ddebd 100644 --- a/src/modules/fileloading.ts +++ b/src/modules/fileloading.ts @@ -8,20 +8,58 @@ */ import { jsPDF } from "../jspdf.js"; +import type { jsPDFAPI as JsPDFAPI, jsPDFDocument } from "../types.js"; // Ambient declarations for the module-format-specific branches kept inside // "@if MODULE_FORMAT" preprocess directive blocks. -declare const require: any; -declare const module: any; -declare const exports: any; -declare const define: any; -declare const process: any; +declare const require: (id: string) => unknown; +declare const module: unknown; +declare const exports: unknown; +declare const define: unknown; +declare const process: { + permission?: { has(scope: string, reference?: string): boolean }; +}; + +/** Surface of Node's "fs" module consumed by nodeReadFile(). */ +interface NodeFSModule { + realpathSync(path: string): string; + readFileSync(path: string, options: { encoding: string }): string; + readFile( + path: string, + options: { encoding: string }, + callback: (err: unknown, data?: string) => void + ): void; +} + +/** Surface of Node's "path" module consumed by nodeReadFile(). */ +interface NodePathModule { + resolve(path: string): string; + sep: string; +} + +type LoadFileCallback = (data?: string) => unknown; + +declare module "../types.js" { + interface jsPDFAPI { + loadFile( + url: string, + sync?: boolean, + callback?: (data: string) => string + ): string; + loadImageFile( + url: string, + sync?: boolean, + callback?: (data: string) => string + ): string; + allowFsRead?: string[]; + } +} /** * @name fileloading * @module */ -(function(jsPDFAPI) { +(function (jsPDFAPI: JsPDFAPI) { /** * @name loadFile * @function @@ -30,7 +68,12 @@ declare const process: any; * @param {function} callback * @returns {string|undefined} result */ - jsPDFAPI.loadFile = function(url, sync, callback) { + jsPDFAPI.loadFile = function ( + this: jsPDFDocument, + url: string, + sync?: boolean, + callback?: LoadFileCallback + ) { // @if MODULE_FORMAT!='cjs' return browserRequest(url, sync, callback); // @endif @@ -83,16 +126,24 @@ declare const process: any; */ jsPDFAPI.loadImageFile = jsPDFAPI.loadFile; - function browserRequest(url, sync, callback) { + function browserRequest( + url: string, + sync?: boolean, + callback?: LoadFileCallback + ): string | undefined { sync = sync === false ? false : true; - callback = typeof callback === "function" ? callback : function() {}; - var result = undefined; + callback = typeof callback === "function" ? callback : function () {}; + var result: string | undefined = undefined; - var xhr = function(url, sync, callback) { + var xhr = function ( + url: string, + sync: boolean, + callback: LoadFileCallback + ): string | undefined { var request = new XMLHttpRequest(); var i = 0; - var sanitizeUnicode = function(data) { + var sanitizeUnicode = function (data: string): string { var dataLength = data.length; var charArray = []; var StringFromCharCode = String.fromCharCode; @@ -109,7 +160,7 @@ declare const process: any; request.overrideMimeType("text/plain; charset=x-user-defined"); if (sync === false) { - request.onload = function() { + request.onload = function () { if (request.status === 200) { callback(sanitizeUnicode(this.responseText)); } else { @@ -130,12 +181,19 @@ declare const process: any; return result; } - function nodeReadFile(url, sync, callback) { + function nodeReadFile( + this: jsPDFDocument, + url: string, + sync?: boolean, + callback?: LoadFileCallback + ): string | undefined { sync = sync === false ? false : true; - var result = undefined; + var result: string | undefined = undefined; - var fs = require("fs"); - var path = require("path"); + // require() is declared as returning `unknown`; these assertions name the + // Node built-in surfaces this function consumes (see the interfaces above). + var fs = require("fs") as NodeFSModule; + var path = require("path") as NodePathModule; if (!process.permission && !this.allowFsRead) { throw new Error( @@ -186,7 +244,7 @@ declare const process: any; return undefined; } } else { - fs.readFile(url, { encoding: "latin1" }, function(err, data) { + fs.readFile(url, { encoding: "latin1" }, function (err, data) { if (!callback) { return; } diff --git a/src/modules/filters.ts b/src/modules/filters.ts index 0990eaf69..9b8c2bccb 100644 --- a/src/modules/filters.ts +++ b/src/modules/filters.ts @@ -9,16 +9,27 @@ import { jsPDF } from "../jspdf.js"; import { zlibSync } from "../libs/fflate.js"; +import type { jsPDFAPI as JsPDFAPI } from "../types.js"; -(function(jsPDFAPI) { +(function (jsPDFAPI: JsPDFAPI) { "use strict"; - var ASCII85Encode = function(a) { - var b, c, d, e, f, g, h, i, j, k; + var ASCII85Encode = function (a: string): string { + var b: string, + c: number[], + d: number, + e: number, + f: number, + g: number, + h: number, + i: number, + j: number, + k: number; // eslint-disable-next-line no-control-regex for ( - // @ts-ignore -- comma-operator expression kept verbatim from the JS - !/[^\x00-\xFF]/.test(a), + // Result of this test was always discarded (originally written as + // `!test(a)` with the value unused); the bare call keeps the behavior. + /[^\x00-\xFF]/.test(a), b = "\x00\x00\x00\x00".slice(a.length % 4 || 4), a += b, c = [], @@ -27,7 +38,7 @@ import { zlibSync } from "../libs/fflate.js"; e > d; d += 4 ) - (f = + ((f = (a.charCodeAt(d) << 24) + (a.charCodeAt(d + 1) << 16) + (a.charCodeAt(d + 2) << 8) + @@ -43,22 +54,18 @@ import { zlibSync } from "../libs/fflate.js"; (f = (f - h) / 85), (g = f % 85), c.push(g + 33, h + 33, i + 33, j + 33, k + 33)) - : c.push(122); + : c.push(122)); return ( - (function(a, b) { + (function (a: number[], b: number) { for (var c = b; c > 0; c--) a.pop(); })(c, b.length), String.fromCharCode.apply(String, c) + "~>" ); }; - var ASCII85Decode = function(a) { - var c, - d, - e, - f, - g, - h = String, + var ASCII85Decode = function (a: string): string { + var c: string, d: number, e: number[], f: number, g: number; + const h = String, l = "length", w = 255, x = "charCodeAt", @@ -66,9 +73,7 @@ import { zlibSync } from "../libs/fflate.js"; z = "replace"; for ( "~>" === a[y](-2), - a = a[y](0, -2) - [z](/\s/g, "") - [z]("z", "!!!!!"), + a = a[y](0, -2)[z](/\s/g, "")[z]("z", "!!!!!"), c = "uuuuu"[y](a[l] % 5 || 5), a += c, e = [], @@ -77,33 +82,33 @@ import { zlibSync } from "../libs/fflate.js"; g > f; f += 5 ) - (d = + ((d = 52200625 * (a[x](f) - 33) + 614125 * (a[x](f + 1) - 33) + 7225 * (a[x](f + 2) - 33) + 85 * (a[x](f + 3) - 33) + (a[x](f + 4) - 33)), - e.push(w & (d >> 24), w & (d >> 16), w & (d >> 8), w & d); + e.push(w & (d >> 24), w & (d >> 16), w & (d >> 8), w & d)); return ( - (function(a, b) { + (function (a: number[], b: number) { for (var c = b; c > 0; c--) a.pop(); })(e, c[l]), h.fromCharCode.apply(h, e) ); }; - var ASCIIHexEncode = function(value) { + var ASCIIHexEncode = function (value: string): string { return ( value .split("") - .map(function(value) { - return ("0" + value.charCodeAt().toString(16)).slice(-2); + .map(function (value) { + return ("0" + value.charCodeAt(0).toString(16)).slice(-2); }) .join("") + ">" ); }; - var ASCIIHexDecode = function(value) { + var ASCIIHexDecode = function (value: string): string { var regexCheckIfHex = new RegExp(/^([0-9A-Fa-f]{2})+$/); value = value.replace(/\s/g, ""); if (value.indexOf(">") !== -1) { @@ -117,7 +122,11 @@ import { zlibSync } from "../libs/fflate.js"; } var result = ""; for (var i = 0; i < value.length; i += 2) { - result += String.fromCharCode(("0x" + (value[i] + value[i + 1])) as any); + result += String.fromCharCode( + // fromCharCode applies ToNumber to its argument at runtime, so the + // hex string is coerced; the assertion keeps that behavior verbatim. + ("0x" + (value[i] + value[i + 1])) as unknown as number + ); } return result; }; @@ -134,32 +143,36 @@ import { zlibSync } from "../libs/fflate.js"; }; */ - var FlateEncode = function(data) { - var arr = new Uint8Array(data.length); + var FlateEncode = function (data: string): string { + var arr: Uint8Array = new Uint8Array(data.length); var i = data.length; while (i--) { arr[i] = data.charCodeAt(i); } arr = zlibSync(arr); - data = arr.reduce(function(data, byte) { + data = arr.reduce(function (data, byte) { return data + String.fromCharCode(byte); }, ""); return data; }; - jsPDFAPI.processDataByFilters = function(origData, filterChain) { + jsPDFAPI.processDataByFilters = function (origData, filterChain) { "use strict"; var i = 0; var data = origData || ""; - var reverseChain = []; + var reverseChain: string[] = []; filterChain = filterChain || []; if (typeof filterChain === "string") { filterChain = [filterChain]; } - for (i = 0; i < filterChain.length; i += 1) { - switch (filterChain[i]) { + // `filterChain === true` has no `length`, so the loop is skipped at + // runtime exactly as in the original JS; the assertion preserves that. + var chain = filterChain as string[]; + + for (i = 0; i < chain.length; i += 1) { + switch (chain[i]) { case "ASCII85Decode": case "/ASCII85Decode": data = ASCII85Decode(data); @@ -186,9 +199,7 @@ import { zlibSync } from "../libs/fflate.js"; reverseChain.push("/FlateDecode"); break; default: - throw new Error( - 'The filter: "' + filterChain[i] + '" is not implemented' - ); + throw new Error('The filter: "' + chain[i] + '" is not implemented'); } } diff --git a/src/modules/gif_support.ts b/src/modules/gif_support.ts index 2a0edd77f..3f39182ca 100644 --- a/src/modules/gif_support.ts +++ b/src/modules/gif_support.ts @@ -9,6 +9,25 @@ import { jsPDF } from "../jspdf.js"; import { GifReader } from "../libs/omggif.js"; import { JPEGEncoder } from "../libs/JPEGEncoder.js"; +import type { jsPDFAPI as JsPDFAPI, jsPDFDocument } from "../types.js"; +import type { ImageCompression, ImageProperties } from "./addimage.js"; + +declare module "../types.js" { + interface jsPDFAPI { + processGIF89A( + imageData?: unknown, + index?: number, + alias?: number | string, + compression?: ImageCompression + ): ImageProperties; + processGIF87A( + imageData?: unknown, + index?: number, + alias?: number | string, + compression?: ImageCompression + ): ImageProperties; + } +} /** * jsPDF Gif Support PlugIn @@ -16,15 +35,21 @@ import { JPEGEncoder } from "../libs/JPEGEncoder.js"; * @name gif_support * @module */ -(function(jsPDFAPI) { +(function (jsPDFAPI: JsPDFAPI) { "use strict"; - jsPDFAPI.processGIF89A = function(imageData, index, alias, compression) { + jsPDFAPI.processGIF89A = function ( + this: jsPDFDocument, + imageData: Uint8Array, + index?: number, + alias?: number | string, + compression?: ImageCompression + ) { var reader = new GifReader(imageData); var width = reader.width, height = reader.height; var qu = 100; - var pixels = []; + var pixels: number[] = []; reader.decodeAndBlitFrameRGBA(0, pixels); var rawImageData = { diff --git a/src/modules/html.ts b/src/modules/html.ts index f2f3464f5..b770fa935 100644 --- a/src/modules/html.ts +++ b/src/modules/html.ts @@ -10,13 +10,283 @@ import { jsPDF } from "../jspdf.js"; import { normalizeFontFace } from "../libs/fontFace.js"; import { globalObject } from "../libs/globalObject.js"; +import type { FontFaceInput, NormalizedFontFace } from "../libs/fontFace.js"; +import type { + jsPDFAPI as JsPDFAPI, + jsPDFDocument, + OutputOptions, + PageFormats +} from "../types.js"; // Ambient declarations for the module-format-specific branches kept inside // "@if MODULE_FORMAT" preprocess directive blocks. -declare const require: any; -declare const module: any; -declare const exports: any; -declare const define: any; +declare const require: ((id: string) => unknown) & + ((deps: string[], callback: (mod: unknown) => unknown) => unknown); +declare const module: { exports: unknown } | undefined; +declare const exports: unknown; +declare const define: + (((...args: unknown[]) => unknown) & { amd?: unknown }) | undefined; + +/** Minimal call surface of the lazily loaded html2canvas library. */ +type Html2CanvasStatic = ( + element: HTMLElement, + options?: Html2CanvasOptions +) => Promise; + +/** Shape returned by the html2canvas loader before unwrapping `default`. */ +type Html2CanvasModule = Html2CanvasStatic & { default?: Html2CanvasStatic }; + +/** Minimal call surface of the lazily loaded dompurify library. */ +type DOMPurifyStatic = { + sanitize(source: string): string; +}; + +/** Shape returned by the dompurify loader before unwrapping `default`. */ +type DOMPurifyModule = DOMPurifyStatic & { default?: DOMPurifyStatic }; + +/** html2canvas options (adapted from types/index.d.ts `Html2CanvasOptions`). */ +type Html2CanvasOptions = { + async?: boolean; + allowTaint?: boolean; + backgroundColor?: string | null; + canvas?: unknown; + foreignObjectRendering?: boolean; + ignoreElements?: (element: HTMLElement) => boolean; + imageTimeout?: number; + letterRendering?: boolean; + logging?: boolean; + onclone?: (doc: Document) => void; + proxy?: string | null; + removeContainer?: boolean; + scale?: number; + svgRendering?: boolean; + taintTest?: boolean; + useCORS?: boolean; + width?: number; + height?: number; + x?: number; + y?: number; + scrollX?: number; + scrollY?: number; + windowWidth?: number; + windowHeight?: number; + /** Legacy html2canvas option handled explicitly by this plugin. */ + onrendered?: (canvas: HTMLCanvasElement) => void; + /** Consumed by `cloneNode` when duplicating the source element. */ + javascriptEnabled?: boolean; +}; + +/** Image settings used when converting HTML to an image (types/index.d.ts `HTMLOptionImage`). */ +type HTMLOptionImage = { + type: "jpeg" | "png" | "webp"; + quality: number; +}; + +/** Page-size descriptor produced by `jsPDF.getPageSize` (plus the derived `inner` field). */ +type HTMLWorkerPageSize = { + width: number; + height: number; + unit: string; + k: number; + orientation: string; + inner?: { + width: number; + height: number; + px?: { width: number; height: number }; + ratio?: number; + }; +}; + +/** Internal state stored on `worker.prop`. */ +type HTMLWorkerProp = { + src: HTMLElement | null; + container: HTMLElement | null; + overlay: HTMLElement | null; + canvas: HTMLCanvasElement | null; + img: HTMLImageElement | null; + pdf: jsPDFDocument | null; + pageSize: HTMLWorkerPageSize | null; + callback: (pdf: jsPDFDocument) => void; +}; + +/** Progress bookkeeping stored on `worker.progress`. */ +type HTMLWorkerProgress = { + val: number; + /** Holds the pending callback (or the Worker itself); only ever used for bookkeeping. */ + state: unknown; + n: number; + stack: unknown[]; + ratio?: number; +}; + +/** Normalized options stored on `worker.opt`. */ +type HTMLWorkerOptions = { + filename: string; + margin: number[]; + enableLinks: boolean; + x: number; + y: number; + html2canvas: Html2CanvasOptions; + jsPDF: jsPDFDocument; + backgroundColor: string; + width?: number; + windowWidth?: number; + scrollX?: number; + scrollY?: number; + autoPaging?: boolean | "slice" | "text"; + image?: HTMLOptionImage; + fontFaces?: NormalizedFontFace[] | null; + worker?: boolean; +}; + +/** + * User-facing options accepted by `doc.html()` (adapted from + * types/index.d.ts `HTMLOptions`). + */ +type HTMLOptions = { + callback?: (doc: jsPDFDocument) => void; + margin?: number | number[]; + autoPaging?: boolean | "slice" | "text"; + filename?: string; + enableLinks?: boolean; + image?: HTMLOptionImage; + html2canvas?: Html2CanvasOptions; + jsPDF?: jsPDFDocument; + x?: number; + y?: number; + width?: number; + windowWidth?: number; + scrollX?: number; + scrollY?: number; + backgroundColor?: string; + fontFaces?: FontFaceInput[] | null; + worker?: boolean; + pageSize?: HTMLWorkerPageSize | null; +}; + +/** Input accepted by `worker.set()`: predefined props and arbitrary options. */ +type HTMLWorkerSetInput = HTMLOptions & Partial; + +/** Snapshot template cloned into every new Worker. */ +type HTMLWorkerTemplate = { + prop: HTMLWorkerProp; + progress: HTMLWorkerProgress; + opt: HTMLWorkerOptions; +}; + +/** Promise-chain callback invoked with `this` bound to the Worker. */ +type HTMLWorkerCallback = (this: HTMLWorker, value?: unknown) => unknown; + +/** Base `then` implementation swapped in by `Worker.prototype.then`. */ +type HTMLWorkerThenBase = ( + this: Promise, + onFulfilled?: HTMLWorkerCallback, + onRejected?: HTMLWorkerCallback +) => Promise; + +/** + * The Worker returned by `doc.html()`: a Promise whose prototype chain has + * been hijacked to expose the chainable conversion methods below (adapted + * from types/index.d.ts `HTMLWorker`). + */ +interface HTMLWorker { + prop: HTMLWorkerProp; + progress: HTMLWorkerProgress; + opt: HTMLWorkerOptions; + from(src: string | HTMLElement, type?: string): HTMLWorker; + to(target: string): HTMLWorker; + toContainer(): HTMLWorker; + toCanvas(): HTMLWorker; + toContext2d(): HTMLWorker; + toImg(): HTMLWorker; + toPdf(): HTMLWorker; + output( + type?: string, + options?: OutputOptions | string, + src?: string + ): HTMLWorker; + outputPdf(type?: string, options?: OutputOptions | string): HTMLWorker; + outputImg(type?: string, options?: unknown): HTMLWorker; + save(filename?: string): HTMLWorker; + doCallback(): HTMLWorker; + set(opt?: HTMLWorkerSetInput | null): HTMLWorker; + get(key: string, cbk?: (value: unknown) => unknown): HTMLWorker; + setMargin(margin: number | number[]): HTMLWorker; + setPageSize(pageSize?: HTMLWorkerPageSize | null): HTMLWorker; + setProgress( + val?: number | null, + state?: unknown, + n?: number | null, + stack?: unknown[] | null + ): HTMLWorker; + updateProgress( + val?: number | null, + state?: unknown, + n?: number | null, + stack?: unknown[] | null + ): HTMLWorker; + then( + onFulfilled?: (this: HTMLWorker, value: T) => unknown, + onRejected?: HTMLWorkerCallback + ): HTMLWorker; + thenCore( + onFulfilled?: HTMLWorkerCallback, + onRejected?: HTMLWorkerCallback, + thenBase?: HTMLWorkerThenBase + ): HTMLWorker; + thenExternal( + onFulfilled?: (value: unknown) => unknown, + onRejected?: (reason: unknown) => unknown + ): Promise; + thenList(fns: Array<(this: HTMLWorker) => unknown>): HTMLWorker; + catch(onRejected?: HTMLWorkerCallback): HTMLWorker; + catchExternal(onRejected?: (reason: unknown) => unknown): Promise; + error(msg: string): HTMLWorker; + using: HTMLWorker["set"]; + saveAs: HTMLWorker["save"]; + export: HTMLWorker["output"]; + run: HTMLWorker["then"]; +} + +/** Static surface of the classic function-constructor `Worker` below. */ +interface HTMLWorkerConstructor { + (this: HTMLWorker, opt?: HTMLOptions | null): HTMLWorker; + new (opt?: HTMLOptions | null): HTMLWorker; + prototype: HTMLWorker; + convert( + promise: Promise | object, + inherit?: object | null + ): HTMLWorker; + template: HTMLWorkerTemplate; +} + +/** Options-object form of the first `jsPDF.getPageSize` parameter. */ +type GetPageSizeOptions = { + orientation?: string; + unit?: string; + format?: string | number[]; +}; + +/** `jsPDF.getPageSize` static installed by this plugin. */ +type GetPageSizeFn = ( + orientation?: string | GetPageSizeOptions | jsPDFDocument, + unit?: string, + format?: string | number[] +) => HTMLWorkerPageSize; + +declare module "../types.js" { + interface jsPDFAPI { + /** + * Generate a PDF from an HTML element or string (html plugin, + * src/modules/html.ts). See the JSDoc on the implementation for details. + */ + html( + this: jsPDFDocument, + src: string | HTMLElement, + options?: HTMLOptions + ): HTMLWorker; + } +} /** * jsPDF html PlugIn @@ -24,85 +294,89 @@ declare const define: any; * @name html * @module */ -(function(jsPDFAPI) { +(function (jsPDFAPI: JsPDFAPI) { "use strict"; - function loadHtml2Canvas() { - return (function() { - if (globalObject["html2canvas"]) { - return Promise.resolve(globalObject["html2canvas"]); - } + function loadHtml2Canvas(): Promise { + return ( + (function (): Promise { + if (globalObject["html2canvas"]) { + return Promise.resolve(globalObject["html2canvas"]); + } - // @if MODULE_FORMAT='es' - return import("html2canvas"); - // @endif - - // @if MODULE_FORMAT!='es' - if (typeof exports === "object" && typeof module !== "undefined") { - return new Promise(function(resolve, reject) { - try { - resolve(require("html2canvas")); - } catch (e) { - reject(e); - } - }); - } - if (typeof define === "function" && define.amd) { - return new Promise(function(resolve, reject) { - try { - require(["html2canvas"], resolve); - } catch (e) { - reject(e); - } - }); - } - return Promise.reject(new Error("Could not load html2canvas")); - // @endif - })() - .catch(function(e) { + // @if MODULE_FORMAT='es' + return import("html2canvas"); + // @endif + + // @if MODULE_FORMAT!='es' + if (typeof exports === "object" && typeof module !== "undefined") { + return new Promise(function (resolve, reject) { + try { + resolve(require("html2canvas")); + } catch (e) { + reject(e); + } + }); + } + if (typeof define === "function" && define.amd) { + return new Promise(function (resolve, reject) { + try { + require(["html2canvas"], resolve); + } catch (e) { + reject(e); + } + }); + } + return Promise.reject(new Error("Could not load html2canvas")); + // @endif + })() as Promise + ) + .catch(function (e) { return Promise.reject(new Error("Could not load html2canvas: " + e)); }) - .then(function(html2canvas) { + .then(function (html2canvas) { return html2canvas.default ? html2canvas.default : html2canvas; }); } - function loadDomPurify() { - return (function() { - if (globalObject["DOMPurify"]) { - return Promise.resolve(globalObject["DOMPurify"]); - } + function loadDomPurify(): Promise { + return ( + (function (): Promise { + if (globalObject["DOMPurify"]) { + return Promise.resolve(globalObject["DOMPurify"]); + } - // @if MODULE_FORMAT='es' - return import("dompurify"); - // @endif - - // @if MODULE_FORMAT!='es' - if (typeof exports === "object" && typeof module !== "undefined") { - return new Promise(function(resolve, reject) { - try { - resolve(require("dompurify")); - } catch (e) { - reject(e); - } - }); - } - if (typeof define === "function" && define.amd) { - return new Promise(function(resolve, reject) { - try { - require(["dompurify"], resolve); - } catch (e) { - reject(e); - } - }); - } - return Promise.reject(new Error("Could not load dompurify")); - // @endif - })() - .catch(function(e) { + // @if MODULE_FORMAT='es' + return import("dompurify"); + // @endif + + // @if MODULE_FORMAT!='es' + if (typeof exports === "object" && typeof module !== "undefined") { + return new Promise(function (resolve, reject) { + try { + resolve(require("dompurify")); + } catch (e) { + reject(e); + } + }); + } + if (typeof define === "function" && define.amd) { + return new Promise(function (resolve, reject) { + try { + require(["dompurify"], resolve); + } catch (e) { + reject(e); + } + }); + } + return Promise.reject(new Error("Could not load dompurify")); + // @endif + })() as Promise + ) + .catch(function (e) { return Promise.reject(new Error("Could not load dompurify: " + e)); }) - .then(function(dompurify) { + .then(function (dompurify) { return dompurify.default ? dompurify.default : dompurify; }); } @@ -113,14 +387,16 @@ declare const define: any; * @private * @ignore */ - var objType = function(obj) { + var objType = function (obj: unknown) { var type = typeof obj; if (type === "undefined") return "undefined"; else if (type === "string" || obj instanceof String) return "string"; else if (type === "number" || obj instanceof Number) return "number"; else if (type === "function" || obj instanceof Function) return "function"; - else if (!!obj && obj.constructor === Array) return "array"; - else if (obj && obj.nodeType === 1) return "element"; + else if (!!obj && (obj as { constructor: unknown }).constructor === Array) + return "array"; + else if (obj && (obj as { nodeType?: number }).nodeType === 1) + return "element"; else if (type === "object") return "object"; else return "unknown"; }; @@ -131,14 +407,26 @@ declare const define: any; * @private * @ignore */ - var createElement = function(tagName, opt) { + var createElement = function ( + tagName: string, + opt: { + className?: string; + innerHTML?: string; + dompurify?: DOMPurifyStatic; + style?: Record; + } + ): HTMLElement { var el = document.createElement(tagName); if (opt.className) el.className = opt.className; if (opt.innerHTML && opt.dompurify) { el.innerHTML = opt.dompurify.sanitize(opt.innerHTML); } for (var key in opt.style) { - el.style[key] = opt.style[key]; + // The style templates use raw numbers for some properties (historical + // behavior); CSSStyleDeclaration declares no string index signature, so + // widen at this boundary. + (el.style as unknown as Record)[key] = + opt.style[key]; } return el; }; @@ -149,7 +437,7 @@ declare const define: any; * @private * @ignore */ - var cloneNode = function(node, javascriptEnabled) { + var cloneNode = function (node: Node, javascriptEnabled?: boolean): Node { // Recursively clone the node. var clone = node.nodeType === 3 @@ -168,19 +456,25 @@ declare const define: any; if (node.nodeType === 1) { // Preserve contents/properties of special nodes. if (node.nodeName === "CANVAS") { - clone.width = node.width; - clone.height = node.height; - clone.getContext("2d").drawImage(node, 0, 0); + (clone as HTMLCanvasElement).width = (node as HTMLCanvasElement).width; + (clone as HTMLCanvasElement).height = ( + node as HTMLCanvasElement + ).height; + (clone as HTMLCanvasElement) + .getContext("2d") + .drawImage(node as HTMLCanvasElement, 0, 0); } else if (node.nodeName === "TEXTAREA" || node.nodeName === "SELECT") { - clone.value = node.value; + (clone as HTMLTextAreaElement).value = ( + node as HTMLTextAreaElement + ).value; } // Preserve the node's scroll position when it loads. clone.addEventListener( "load", - function() { - clone.scrollTop = node.scrollTop; - clone.scrollLeft = node.scrollLeft; + function () { + (clone as HTMLElement).scrollTop = (node as HTMLElement).scrollTop; + (clone as HTMLElement).scrollLeft = (node as HTMLElement).scrollLeft; }, true ); @@ -192,19 +486,29 @@ declare const define: any; /* ----- CONSTRUCTOR ----- */ - var Worker: any = function Worker(opt) { + var Worker = function Worker( + this: HTMLWorker, + opt?: HTMLOptions | null + ): HTMLWorker { // Create the root parent for the proto chain, and the starting Worker. - var root = Object.assign( - (Worker as any).convert(Promise.resolve()), - JSON.parse(JSON.stringify((Worker as any).template)) + var root: HTMLWorker = Object.assign( + (Worker as HTMLWorkerConstructor).convert(Promise.resolve()), + JSON.parse( + JSON.stringify((Worker as HTMLWorkerConstructor).template) + ) as HTMLWorkerTemplate + ); + var self = (Worker as HTMLWorkerConstructor).convert( + Promise.resolve(), + root ); - var self = (Worker as any).convert(Promise.resolve(), root); // Set progress, optional settings, and return. self = self.setProgress(1, Worker, 1, [Worker]); self = self.set(opt); return self; - }; + // The classic function-constructor pattern is invisible to the type + // system; assert the assembled constructor type at this single boundary. + } as HTMLWorkerConstructor; // Boilerplate for subclassing Promise. Worker.prototype = Object.create(Promise.prototype); @@ -213,8 +517,9 @@ declare const define: any; // Converts/casts promises into Workers. Worker.convert = function convert(promise, inherit) { // Uses prototypal inheritance to receive changes made to ancestors' properties. - promise.__proto__ = inherit || Worker.prototype; - return promise; + (promise as { __proto__: object | null }).__proto__ = + inherit || Worker.prototype; + return promise as HTMLWorker; }; Worker.template = { @@ -226,7 +531,7 @@ declare const define: any; img: null, pdf: null, pageSize: null, - callback: function() {} + callback: function () {} }, progress: { val: 0, @@ -241,50 +546,61 @@ declare const define: any; x: 0, y: 0, html2canvas: {}, - jsPDF: {}, + // Placeholder only; a real document instance is injected via + // `set({ jsPDF })` before any use. + jsPDF: {} as jsPDFDocument, backgroundColor: "transparent" } }; /* ----- FROM / TO ----- */ - Worker.prototype.from = function from(src, type) { - function getType(src) { + Worker.prototype.from = function from( + this: HTMLWorker, + src: string | HTMLElement, + type?: string + ) { + function getType(src: string | HTMLElement) { switch (objType(src)) { case "string": return "string"; case "element": - return src.nodeName.toLowerCase() === "canvas" ? "canvas" : "element"; + return (src as HTMLElement).nodeName.toLowerCase() === "canvas" + ? "canvas" + : "element"; default: return "unknown"; } } - return this.then(function from_main() { + return this.then(function from_main(this: HTMLWorker) { type = type || getType(src); switch (type) { case "string": - return this.then(loadDomPurify).then(function(dompurify) { + return this.then(loadDomPurify).then(function ( + this: HTMLWorker, + dompurify: DOMPurifyStatic + ) { return this.set({ src: createElement("div", { - innerHTML: src, + innerHTML: src as string, dompurify: dompurify }) }); }); case "element": - return this.set({ src: src }); + return this.set({ src: src as HTMLElement }); case "canvas": - return this.set({ canvas: src }); + return this.set({ canvas: src as HTMLCanvasElement }); case "img": - return this.set({ img: src }); + return this.set({ img: src as HTMLImageElement }); default: return this.error("Unknown source type."); } }); }; - Worker.prototype.to = function to(target) { + Worker.prototype.to = function to(this: HTMLWorker, target: string) { // Route the 'to' request to the appropriate method. switch (target) { case "container": @@ -300,19 +616,21 @@ declare const define: any; } }; - Worker.prototype.toContainer = function toContainer() { + Worker.prototype.toContainer = function toContainer(this: HTMLWorker) { // Set up function prerequisites. var prereqs = [ - function checkSrc() { + function checkSrc(this: HTMLWorker) { return ( this.prop.src || this.error("Cannot duplicate - no source HTML.") ); }, - function checkPageSize() { + function checkPageSize(this: HTMLWorker) { return this.prop.pageSize || this.setPageSize(); } ]; - return this.thenList(prereqs).then(function toContainer_main() { + return this.thenList(prereqs).then(function toContainer_main( + this: HTMLWorker + ) { // Define the CSS styles for the container and its overlay parent. var overlayCSS = { position: "fixed", @@ -323,7 +641,7 @@ declare const define: any; bottom: 0, top: 0 }; - var containerCSS: any = { + var containerCSS: Record = { position: "relative", display: "inline-block", width: @@ -349,7 +667,7 @@ declare const define: any; this.opt.html2canvas.javascriptEnabled ); - if (source.tagName === "BODY") { + if ((source as HTMLElement).tagName === "BODY") { containerCSS.height = Math.max( document.body.scrollHeight, @@ -383,20 +701,22 @@ declare const define: any; this.prop.container.style.float = "none"; this.prop.overlay.appendChild(this.prop.container); document.body.appendChild(this.prop.overlay); - this.prop.container.firstChild.style.position = "relative"; - this.prop.container.height = + (this.prop.container.firstChild as HTMLElement).style.position = + "relative"; + // Historical expando: `height` is not a real HTMLElement property. + (this.prop.container as HTMLElement & { height?: string }).height = Math.max( - this.prop.container.firstChild.clientHeight, - this.prop.container.firstChild.scrollHeight, - this.prop.container.firstChild.offsetHeight + (this.prop.container.firstChild as HTMLElement).clientHeight, + (this.prop.container.firstChild as HTMLElement).scrollHeight, + (this.prop.container.firstChild as HTMLElement).offsetHeight ) + "px"; }); }; - Worker.prototype.toCanvas = function toCanvas() { + Worker.prototype.toCanvas = function toCanvas(this: HTMLWorker) { // Set up function prerequisites. var prereqs = [ - function checkContainer() { + function checkContainer(this: HTMLWorker) { return ( document.body.contains(this.prop.container) || this.toContainer() ); @@ -406,16 +726,22 @@ declare const define: any; // Fulfill prereqs then create the canvas. return this.thenList(prereqs) .then(loadHtml2Canvas) - .then(function toCanvas_main(html2canvas) { + .then(function toCanvas_main( + this: HTMLWorker, + html2canvas: Html2CanvasStatic + ) { // Handle old-fashioned 'onrendered' argument. var options = Object.assign({}, this.opt.html2canvas); delete options.onrendered; return html2canvas(this.prop.container, options); }) - .then(function toCanvas_post(canvas) { + .then(function toCanvas_post( + this: HTMLWorker, + canvas: HTMLCanvasElement + ) { // Handle old-fashioned 'onrendered' argument. - var onRendered = this.opt.html2canvas.onrendered || function() {}; + var onRendered = this.opt.html2canvas.onrendered || function () {}; onRendered(canvas); this.prop.canvas = canvas; @@ -423,10 +749,10 @@ declare const define: any; }); }; - Worker.prototype.toContext2d = function toContext2d() { + Worker.prototype.toContext2d = function toContext2d(this: HTMLWorker) { // Set up function prerequisites. var prereqs = [ - function checkContainer() { + function checkContainer(this: HTMLWorker) { return ( document.body.contains(this.prop.container) || this.toContainer() ); @@ -436,7 +762,10 @@ declare const define: any; // Fulfill prereqs then create the canvas. return this.thenList(prereqs) .then(loadHtml2Canvas) - .then(function toContext2d_main(html2canvas) { + .then(function toContext2d_main( + this: HTMLWorker, + html2canvas: Html2CanvasStatic + ) { // Handle old-fashioned 'onrendered' argument. var pdf = this.opt.jsPDF; @@ -481,7 +810,7 @@ declare const define: any; if (fontFaces) { for (var i = 0; i < fontFaces.length; ++i) { var font = fontFaces[i]; - var src = font.src.find(function(src) { + var src = font.src.find(function (src) { return src.format === "truetype"; }); @@ -504,11 +833,14 @@ declare const define: any; pdf.context2d.save(true); return html2canvas(this.prop.container, options); }) - .then(function toContext2d_post(canvas) { + .then(function toContext2d_post( + this: HTMLWorker, + canvas: HTMLCanvasElement + ) { this.opt.jsPDF.context2d.restore(true); // Handle old-fashioned 'onrendered' argument. - var onRendered = this.opt.html2canvas.onrendered || function() {}; + var onRendered = this.opt.html2canvas.onrendered || function () {}; onRendered(canvas); this.prop.canvas = canvas; @@ -516,16 +848,16 @@ declare const define: any; }); }; - Worker.prototype.toImg = function toImg() { + Worker.prototype.toImg = function toImg(this: HTMLWorker) { // Set up function prerequisites. var prereqs = [ - function checkCanvas() { + function checkCanvas(this: HTMLWorker) { return this.prop.canvas || this.toCanvas(); } ]; // Fulfill prereqs then create the image. - return this.thenList(prereqs).then(function toImg_main() { + return this.thenList(prereqs).then(function toImg_main(this: HTMLWorker) { var imgData = this.prop.canvas.toDataURL( "image/" + this.opt.image.type, this.opt.image.quality @@ -535,17 +867,17 @@ declare const define: any; }); }; - Worker.prototype.toPdf = function toPdf() { + Worker.prototype.toPdf = function toPdf(this: HTMLWorker) { // Set up function prerequisites. var prereqs = [ - function checkContext2d() { + function checkContext2d(this: HTMLWorker) { return this.toContext2d(); } //function checkCanvas() { return this.prop.canvas || this.toCanvas(); } ]; // Fulfill prereqs then create the image. - return this.thenList(prereqs).then(function toPdf_main() { + return this.thenList(prereqs).then(function toPdf_main(this: HTMLWorker) { // Create local copies of frequently used properties. this.prop.pdf = this.prop.pdf || this.opt.jsPDF; }); @@ -553,7 +885,12 @@ declare const define: any; /* ----- OUTPUT / SAVE ----- */ - Worker.prototype.output = function output(type, options, src) { + Worker.prototype.output = function output( + this: HTMLWorker, + type?: string, + options?: OutputOptions | string, + src?: string + ) { // Redirect requests to the correct function (outputPdf / outputImg). src = src || "pdf"; if (src.toLowerCase() === "img" || src.toLowerCase() === "image") { @@ -563,35 +900,49 @@ declare const define: any; } }; - Worker.prototype.outputPdf = function outputPdf(type, options) { + Worker.prototype.outputPdf = function outputPdf( + this: HTMLWorker, + type?: string, + options?: OutputOptions | string + ) { // Set up function prerequisites. var prereqs = [ - function checkPdf() { + function checkPdf(this: HTMLWorker) { return this.prop.pdf || this.toPdf(); } ]; // Fulfill prereqs then perform the appropriate output. - return this.thenList(prereqs).then(function outputPdf_main() { + return this.thenList(prereqs).then(function outputPdf_main( + this: HTMLWorker + ) { /* Currently implemented output types: * https://rawgit.com/MrRio/jsPDF/master/docs/jspdf.js.html#line992 * save(options), arraybuffer, blob, bloburi/bloburl, * datauristring/dataurlstring, dataurlnewwindow, datauri/dataurl */ - return this.prop.pdf.output(type, options); + // The core `output` is declared as per-literal-type overloads; the + // dynamic type string is forwarded verbatim at runtime, so pick a + // representative overload for the type check. + return this.prop.pdf.output(type as "datauristring", options); }); }; - Worker.prototype.outputImg = function outputImg(type) { + Worker.prototype.outputImg = function outputImg( + this: HTMLWorker, + type?: string + ) { // Set up function prerequisites. var prereqs = [ - function checkImg() { + function checkImg(this: HTMLWorker) { return this.prop.img || this.toImg(); } ]; // Fulfill prereqs then perform the appropriate output. - return this.thenList(prereqs).then(function outputImg_main() { + return this.thenList(prereqs).then(function outputImg_main( + this: HTMLWorker + ) { switch (type) { case undefined: case "img": @@ -608,10 +959,10 @@ declare const define: any; }); }; - Worker.prototype.save = function save(filename) { + Worker.prototype.save = function save(this: HTMLWorker, filename?: string) { // Set up function prerequisites. var prereqs = [ - function checkPdf() { + function checkPdf(this: HTMLWorker) { return this.prop.pdf || this.toPdf(); } ]; @@ -619,28 +970,33 @@ declare const define: any; // Fulfill prereqs, update the filename (if provided), and save the PDF. return this.thenList(prereqs) .set(filename ? { filename: filename } : null) - .then(function save_main() { + .then(function save_main(this: HTMLWorker) { this.prop.pdf.save(this.opt.filename); }); }; - Worker.prototype.doCallback = function doCallback() { + Worker.prototype.doCallback = function doCallback(this: HTMLWorker) { // Set up function prerequisites. var prereqs = [ - function checkPdf() { + function checkPdf(this: HTMLWorker) { return this.prop.pdf || this.toPdf(); } ]; // Fulfill prereqs, update the filename (if provided), and save the PDF. - return this.thenList(prereqs).then(function doCallback_main() { + return this.thenList(prereqs).then(function doCallback_main( + this: HTMLWorker + ) { this.prop.callback(this.prop.pdf); }); }; /* ----- SET / GET ----- */ - Worker.prototype.set = function set(opt) { + Worker.prototype.set = function set( + this: HTMLWorker, + opt?: HTMLWorkerSetInput | null + ) { // TODO: Implement ordered pairs? // Silently ignore invalid or empty input. @@ -649,18 +1005,20 @@ declare const define: any; } // Build an array of setter functions to queue. - var fns = Object.keys(opt || {}).map(function(key) { + var fns = Object.keys(opt || {}).map(function (this: HTMLWorker, key) { if (key in Worker.template.prop) { // Set pre-defined properties. - return function set_prop() { - this.prop[key] = opt[key]; + return function set_prop(this: HTMLWorker) { + (this.prop as Record)[key] = ( + opt as Record + )[key]; }; } else { switch (key) { case "margin": return this.setMargin.bind(this, opt.margin); case "jsPDF": - return function set_jsPDF() { + return function set_jsPDF(this: HTMLWorker) { this.opt.jsPDF = opt.jsPDF; return this.setPageSize(); }; @@ -668,39 +1026,61 @@ declare const define: any; return this.setPageSize.bind(this, opt.pageSize); default: // Set any other properties in opt. - return function set_opt() { - this.opt[key] = opt[key]; + return function set_opt(this: HTMLWorker) { + (this.opt as Record)[key] = ( + opt as Record + )[key]; }; } } }, this); // Set properties within the promise chain. - return this.then(function set_main() { + return this.then(function set_main(this: HTMLWorker) { return this.thenList(fns); }); }; - Worker.prototype.get = function get(key, cbk) { - return this.then(function get_main() { + Worker.prototype.get = function get( + this: HTMLWorker, + key: string, + cbk?: (value: unknown) => unknown + ) { + return this.then(function get_main(this: HTMLWorker) { // Fetch the requested property, either as a predefined prop or in opt. - var val = key in Worker.template.prop ? this.prop[key] : this.opt[key]; + var val = + key in Worker.template.prop + ? (this.prop as Record)[key] + : (this.opt as Record)[key]; return cbk ? cbk(val) : val; }); }; - Worker.prototype.setMargin = function setMargin(margin) { - return this.then(function setMargin_main() { + Worker.prototype.setMargin = function setMargin( + this: HTMLWorker, + margin: number | number[] + ) { + return this.then(function setMargin_main(this: HTMLWorker) { // Parse the margin property. switch (objType(margin)) { case "number": - margin = [margin, margin, margin, margin]; + margin = [ + margin as number, + margin as number, + margin as number, + margin as number + ]; // eslint-disable-next-line no-fallthrough case "array": - if (margin.length === 2) { - margin = [margin[0], margin[1], margin[0], margin[1]]; + if ((margin as number[]).length === 2) { + margin = [ + (margin as number[])[0], + (margin as number[])[1], + (margin as number[])[0], + (margin as number[])[1] + ]; } - if (margin.length === 4) { + if ((margin as number[]).length === 4) { break; } // eslint-disable-next-line no-fallthrough @@ -709,18 +1089,27 @@ declare const define: any; } // Set the margin property, then update pageSize. - this.opt.margin = margin; + this.opt.margin = margin as number[]; }).then(this.setPageSize); }; - Worker.prototype.setPageSize = function setPageSize(pageSize) { - function toPx(val, k) { + Worker.prototype.setPageSize = function setPageSize( + this: HTMLWorker, + pageSize?: HTMLWorkerPageSize | null + ) { + function toPx(val: number, k: number) { return Math.floor(((val * k) / 72) * 96); } - return this.then(function setPageSize_main() { + return this.then(function setPageSize_main(this: HTMLWorker) { // Retrieve page-size based on jsPDF settings, if not explicitly provided. - pageSize = pageSize || (jsPDF as any).getPageSize(this.opt.jsPDF); + pageSize = + pageSize || + // `getPageSize` is an expando static installed on the imported + // constructor function below; it is invisible to jsPDF's own type. + (jsPDF as unknown as { getPageSize: GetPageSizeFn }).getPageSize( + this.opt.jsPDF + ); // Add 'inner' field if not present. if (!pageSize.hasOwnProperty("inner")) { @@ -740,23 +1129,32 @@ declare const define: any; }); }; - Worker.prototype.setProgress = function setProgress(val, state, n, stack) { + Worker.prototype.setProgress = function setProgress( + this: HTMLWorker, + val?: number | null, + state?: unknown, + n?: number | null, + stack?: unknown[] | null + ) { // Immediately update all progress values. if (val != null) this.progress.val = val; if (state != null) this.progress.state = state; if (n != null) this.progress.n = n; if (stack != null) this.progress.stack = stack; - this.progress.ratio = this.progress.val / this.progress.state; + // `state` holds callbacks/the Worker at runtime; the division has always + // yielded NaN and is preserved as-is. + this.progress.ratio = this.progress.val / (this.progress.state as number); // Return this for command chaining. return this; }; Worker.prototype.updateProgress = function updateProgress( - val, - state, - n, - stack + this: HTMLWorker, + val?: number | null, + state?: unknown, + n?: number | null, + stack?: unknown[] | null ) { // Immediately update all progress values, using setProgress. return this.setProgress( @@ -769,33 +1167,39 @@ declare const define: any; /* ----- PROMISE MAPPING ----- */ - Worker.prototype.then = function then(onFulfilled, onRejected) { + Worker.prototype.then = function then( + this: HTMLWorker, + onFulfilled?: (this: HTMLWorker, value: T) => unknown, + onRejected?: HTMLWorkerCallback + ) { // Wrap `this` for encapsulation. var self = this; - return this.thenCore(onFulfilled, onRejected, function then_main( - onFulfilled, - onRejected - ) { - // Update progress while queuing, calling, and resolving `then`. - self.updateProgress(null, null, 1, [onFulfilled]); - return Promise.prototype.then - .call(this, function then_pre(val) { - self.updateProgress(null, onFulfilled); - return val; - }) - .then(onFulfilled, onRejected) - .then(function then_post(val) { - self.updateProgress(1); - return val; - }); - }); + return this.thenCore( + onFulfilled as HTMLWorkerCallback, + onRejected, + function then_main(onFulfilled, onRejected) { + // Update progress while queuing, calling, and resolving `then`. + self.updateProgress(null, null, 1, [onFulfilled]); + return Promise.prototype.then + .call(this, function then_pre(val) { + self.updateProgress(null, onFulfilled); + return val; + }) + .then(onFulfilled, onRejected) + .then(function then_post(val) { + self.updateProgress(1); + return val; + }); + } + ); }; Worker.prototype.thenCore = function thenCore( - onFulfilled, - onRejected, - thenBase + this: HTMLWorker, + onFulfilled?: HTMLWorkerCallback, + onRejected?: HTMLWorkerCallback, + thenBase?: HTMLWorkerThenBase ) { // Handle optional thenBase parameter. thenBase = thenBase || Promise.prototype.then; @@ -818,19 +1222,37 @@ declare const define: any; : Worker.convert(Object.assign({}, self), Promise.prototype); // Return the promise, after casting it into a Worker and preserving props. - var returnVal = thenBase.call(selfPromise, onFulfilled, onRejected); - return Worker.convert(returnVal, self.__proto__); + // The Worker hijacks the Promise prototype chain, so the nominal types + // diverge at this boundary. + var returnVal = thenBase.call( + selfPromise as unknown as Promise, + onFulfilled, + onRejected + ); + return Worker.convert( + returnVal, + (self as unknown as { __proto__: object }).__proto__ + ); }; Worker.prototype.thenExternal = function thenExternal( - onFulfilled, - onRejected + this: HTMLWorker, + onFulfilled?: (value: unknown) => unknown, + onRejected?: (reason: unknown) => unknown ) { // Call `then` and return a standard promise (exits the Worker chain). - return Promise.prototype.then.call(this, onFulfilled, onRejected); + // The Worker is a Promise at runtime despite its hijacked prototype. + return Promise.prototype.then.call( + this as unknown as Promise, + onFulfilled, + onRejected + ); }; - Worker.prototype.thenList = function thenList(fns) { + Worker.prototype.thenList = function thenList( + this: HTMLWorker, + fns: Array<(this: HTMLWorker) => unknown> + ) { // Queue a series of promise 'factories' into the promise chain. var self = this; fns.forEach(function thenList_forEach(fn) { @@ -839,21 +1261,35 @@ declare const define: any; return self; }; - Worker.prototype["catch"] = function(onRejected) { + Worker.prototype["catch"] = function ( + this: HTMLWorker, + onRejected?: HTMLWorkerCallback + ) { // Bind `this` to the promise handler, call `catch`, and return a Worker. if (onRejected) { onRejected = onRejected.bind(this); } - var returnVal = Promise.prototype["catch"].call(this, onRejected); + // The Worker is a Promise at runtime despite its hijacked prototype. + var returnVal = Promise.prototype["catch"].call( + this as unknown as Promise, + onRejected + ); return Worker.convert(returnVal, this); }; - Worker.prototype.catchExternal = function catchExternal(onRejected) { + Worker.prototype.catchExternal = function catchExternal( + this: HTMLWorker, + onRejected?: (reason: unknown) => unknown + ) { // Call `catch` and return a standard promise (exits the Worker chain). - return Promise.prototype["catch"].call(this, onRejected); + // The Worker is a Promise at runtime despite its hijacked prototype. + return Promise.prototype["catch"].call( + this as unknown as Promise, + onRejected + ); }; - Worker.prototype.error = function error(msg) { + Worker.prototype.error = function error(this: HTMLWorker, msg: string) { // Throw the error in the Promise chain. return this.then(function error_main() { throw new Error(msg); @@ -868,13 +1304,19 @@ declare const define: any; Worker.prototype.run = Worker.prototype.then; // Get dimensions of a PDF page, as determined by jsPDF. - (jsPDF as any).getPageSize = function(orientation, unit, format) { + // `getPageSize` is an expando static assigned onto the imported constructor + // function, which is invisible to jsPDF's own type. + (jsPDF as unknown as { getPageSize: GetPageSizeFn }).getPageSize = function ( + orientation, + unit, + format + ) { // Decode options object if (typeof orientation === "object") { var options = orientation; - orientation = options.orientation; - unit = options.unit || unit; - format = options.format || format; + orientation = (options as GetPageSizeOptions).orientation; + unit = (options as GetPageSizeOptions).unit || unit; + format = (options as GetPageSizeOptions).format || format; } // Default options @@ -884,7 +1326,7 @@ declare const define: any; var format_as_string = ("" + format).toLowerCase(); // Size in pt of various paper formats - var pageFormats = { + var pageFormats: PageFormats = { a0: [2383.94, 3370.39], a1: [1683.78, 2383.94], a2: [1190.55, 1683.78], @@ -967,8 +1409,8 @@ declare const define: any; pageWidth = pageFormats[format_as_string][0] / k; } else { try { - pageHeight = format[1]; - pageWidth = format[0]; + pageHeight = (format as number[])[1]; + pageWidth = (format as number[])[0]; } catch (err) { throw new Error("Invalid format: " + format); } @@ -1074,13 +1516,22 @@ declare const define: any; * y: 10 * }); */ - jsPDFAPI.html = function(src, options) { + jsPDFAPI.html = function ( + this: jsPDFDocument, + src: string | HTMLElement, + options?: HTMLOptions + ) { "use strict"; options = options || {}; - options.callback = options.callback || function() {}; + options.callback = options.callback || function () {}; options.html2canvas = options.html2canvas || {}; - options.html2canvas.canvas = options.html2canvas.canvas || this.canvas; + options.html2canvas.canvas = + options.html2canvas.canvas || + // The canvas plugin (src/modules/canvas.ts) installs `canvas` as an + // expando on the document instance; it is not part of the typed core + // surface yet. + (this as unknown as { canvas?: unknown }).canvas; options.jsPDF = options.jsPDF || this; options.fontFaces = options.fontFaces ? options.fontFaces.map(normalizeFontFace) diff --git a/src/modules/javascript.ts b/src/modules/javascript.ts index 723583b61..15e146855 100644 --- a/src/modules/javascript.ts +++ b/src/modules/javascript.ts @@ -25,6 +25,13 @@ */ import { jsPDF } from "../jspdf.js"; +import type { jsPDFAPI as JsPDFAPI, jsPDFDocument } from "../types.js"; + +declare module "../types.js" { + interface jsPDFAPI { + addJS(javascript: string): jsPDFDocument; + } +} /** * jsPDF JavaScript plugin @@ -32,7 +39,7 @@ import { jsPDF } from "../jspdf.js"; * @name javascript * @module */ -(function(jsPDFAPI) { +(function (jsPDFAPI: JsPDFAPI) { "use strict"; /** * @name addJS @@ -40,11 +47,11 @@ import { jsPDF } from "../jspdf.js"; * @param {string} javascript The javascript to be embedded into the PDF-file. * @returns {jsPDF} */ - jsPDFAPI.addJS = function(javascript) { - var jsNamesObj; - var jsJsObj; + jsPDFAPI.addJS = function (this: jsPDFDocument, javascript: string) { + var jsNamesObj: number | undefined; + var jsJsObj: number | undefined; // Escape only unescaped parentheses, without double-escaping already escaped ones - function escapeParens(str) { + function escapeParens(str: string): string { let out = ""; for (let i = 0; i < str.length; i++) { const ch = str[i]; @@ -67,27 +74,33 @@ import { jsPDF } from "../jspdf.js"; } const text = escapeParens(javascript); - this.internal.events.subscribe("postPutResources", function() { - jsNamesObj = this.internal.newObject(); - this.internal.out("<<"); - this.internal.out("/Names [(EmbeddedJS) " + (jsNamesObj + 1) + " 0 R]"); - this.internal.out(">>"); - this.internal.out("endobj"); + this.internal.events.subscribe( + "postPutResources", + function (this: jsPDFDocument) { + jsNamesObj = this.internal.newObject(); + this.internal.out("<<"); + this.internal.out("/Names [(EmbeddedJS) " + (jsNamesObj + 1) + " 0 R]"); + this.internal.out(">>"); + this.internal.out("endobj"); - jsJsObj = this.internal.newObject(); - this.internal.out("<<"); - this.internal.out("/S /JavaScript"); - // The sanitized 'text' is now safe to be enclosed in parentheses - this.internal.out("/JS (" + text + ")"); - this.internal.out(">>"); - this.internal.out("endobj"); - }); + jsJsObj = this.internal.newObject(); + this.internal.out("<<"); + this.internal.out("/S /JavaScript"); + // The sanitized 'text' is now safe to be enclosed in parentheses + this.internal.out("/JS (" + text + ")"); + this.internal.out(">>"); + this.internal.out("endobj"); + } + ); - this.internal.events.subscribe("putCatalog", function() { - if (jsNamesObj !== undefined && jsJsObj !== undefined) { - this.internal.out("/Names <>"); + this.internal.events.subscribe( + "putCatalog", + function (this: jsPDFDocument) { + if (jsNamesObj !== undefined && jsJsObj !== undefined) { + this.internal.out("/Names <>"); + } } - }); + ); return this; }; })(jsPDF.API); diff --git a/src/modules/jpeg_support.ts b/src/modules/jpeg_support.ts index 6eb194ceb..b0a822996 100644 --- a/src/modules/jpeg_support.ts +++ b/src/modules/jpeg_support.ts @@ -6,6 +6,25 @@ */ import { jsPDF } from "../jspdf.js"; +import type { jsPDFAPI as JsPDFAPI, jsPDFDocument } from "../types.js"; +import type { + ImageCompression, + ImageProperties, + ImageTypedArray +} from "./addimage.js"; + +declare module "../types.js" { + interface jsPDFAPI { + processJPEG( + data?: unknown, + index?: number, + alias?: number | string, + compression?: ImageCompression, + dataAsBinaryString?: string, + colorSpace?: string + ): ImageProperties; + } +} /** * jsPDF jpeg Support PlugIn @@ -13,7 +32,7 @@ import { jsPDF } from "../jspdf.js"; * @name jpeg_support * @module */ -(function(jsPDFAPI) { +(function (jsPDFAPI: JsPDFAPI) { "use strict"; /** @@ -31,7 +50,7 @@ import { jsPDF } from "../jspdf.js"; //takes a string imgData containing the raw bytes of //a jpeg image and returns [width, height] //Algorithm from: http://www.64lines.com/jpeg-width-height - var getJpegInfo = function(imgData) { + var getJpegInfo = function (imgData: string) { var width, height, numcomponents; var blockLength = imgData.charCodeAt(4) * 256 + imgData.charCodeAt(5); var len = imgData.length; @@ -55,13 +74,14 @@ import { jsPDF } from "../jspdf.js"; /** * @ignore */ - jsPDFAPI.processJPEG = function( - data, - index, - alias, - compression, - dataAsBinaryString, - colorSpace + jsPDFAPI.processJPEG = function ( + this: jsPDFDocument, + data: string | ArrayBuffer | ImageTypedArray, + index?: number, + alias?: number | string, + compression?: ImageCompression, + dataAsBinaryString?: string, + colorSpace?: string ) { var filter = this.decode.DCT_DECODE, bpc = 8, diff --git a/src/modules/outline.ts b/src/modules/outline.ts index 52fd8740d..7406ae195 100644 --- a/src/modules/outline.ts +++ b/src/modules/outline.ts @@ -7,6 +7,57 @@ */ import { jsPDF } from "../jspdf.js"; +import type { jsPDFAPI as JsPDFAPI, jsPDFDocument } from "../types.js"; + +export interface OutlineItemOptions { + pageNumber?: number; +} + +/** A node of the outline tree; the root carries no title/options. */ +export interface OutlineNode { + title?: string; + options?: OutlineItemOptions; + children: OutlineNode[]; + /** Deferred object id assigned by genIds_r() while rendering. */ + id?: number; +} + +interface OutlineRenderContext { + val: string; + pdf: jsPDFDocument; +} + +/** The outline builder installed on every document as `doc.outline`. */ +export interface Outline { + createNamedDestinations: boolean; + root: OutlineNode; + add( + parent: OutlineNode | null, + title: string, + options?: OutlineItemOptions + ): OutlineNode; + render(): string; + genIds_r(node: OutlineNode): void; + renderRoot(node: OutlineNode): void; + renderItems(node: OutlineNode): void; + line(text: string): void; + makeRef(node: OutlineNode): string; + makeString(val: string): string; + objStart(node: OutlineNode): void; + objEnd(): void; + count_r(ctx: { count: number }, node: OutlineNode): number; + /** Scratch state used while render() walks the tree. */ + ctx: OutlineRenderContext; + /** Last per-item descendant count computed by renderItems(). */ + count?: number; +} + +declare module "../types.js" { + interface jsPDFDocument { + /** The outline builder for this document, assigned on "initialized". */ + outline: Outline; + } +} /** * jsPDF Outline PlugIn @@ -15,15 +66,15 @@ import { jsPDF } from "../jspdf.js"; * @name outline * @module */ -(function(jsPDFAPI) { +(function (this: void, jsPDFAPI: JsPDFAPI) { "use strict"; - var namesOid; + var namesOid: number; //var destsGoto = []; jsPDFAPI.events.push([ "postPutResources", - function() { + function (this: jsPDFDocument) { var pdf = this; var rx = /^(\d+) 0 obj$/; @@ -48,7 +99,13 @@ import { jsPDF } from "../jspdf.js"; var m = rx.exec(line); if (m != null) { var oid = m[1]; - pdf.internal.newObjectDeferredBegin(oid, false); + // Preserved verbatim: the object id captured from the rendered + // line is a string; newObjectDeferredBegin coerces it when used + // as an offset table key. + pdf.internal.newObjectDeferredBegin( + oid as unknown as number, + false + ); } pdf.internal.write(line); } @@ -61,7 +118,7 @@ import { jsPDF } from "../jspdf.js"; // WARNING: this assumes jsPDF starts on page 3 and pageIDs // follow 5, 7, 9, etc // Write destination objects for each page - var dests = []; + var dests: number[] = []; for (var i = 0; i < totalPages; i++) { var id = pdf.internal.newObject(); dests.push(id); @@ -92,7 +149,7 @@ import { jsPDF } from "../jspdf.js"; jsPDFAPI.events.push([ "putCatalog", - function() { + function (this: jsPDFDocument) { var pdf = this; if (pdf.outline.root.children.length > 0) { pdf.internal.write( @@ -110,21 +167,23 @@ import { jsPDF } from "../jspdf.js"; jsPDFAPI.events.push([ "initialized", - function() { + function (this: jsPDFDocument) { var pdf = this; + // Created with its data members only and filled method by method + // directly below. pdf.outline = { createNamedDestinations: false, root: { children: [] } - }; + } as Outline; /** * Options: pageNumber */ - pdf.outline.add = function(parent, title, options) { - var item = { + pdf.outline.add = function (parent, title, options) { + var item: OutlineNode = { title: title, options: options, children: [] @@ -136,8 +195,9 @@ import { jsPDF } from "../jspdf.js"; return item; }; - pdf.outline.render = function() { - this.ctx = {}; + pdf.outline.render = function () { + // Created empty and filled property by property on the next lines. + this.ctx = {} as OutlineRenderContext; this.ctx.val = ""; this.ctx.pdf = pdf; @@ -148,14 +208,14 @@ import { jsPDF } from "../jspdf.js"; return this.ctx.val; }; - pdf.outline.genIds_r = function(node) { + pdf.outline.genIds_r = function (node) { node.id = pdf.internal.newObjectDeferred(); for (var i = 0; i < node.children.length; i++) { this.genIds_r(node.children[i]); } }; - pdf.outline.renderRoot = function(node) { + pdf.outline.renderRoot = function (node) { this.objStart(node); this.line("/Type /Outlines"); if (node.children.length > 0) { @@ -176,9 +236,9 @@ import { jsPDF } from "../jspdf.js"; this.objEnd(); }; - pdf.outline.renderItems = function(node) { - var getVerticalCoordinateString = this.ctx.pdf.internal - .getVerticalCoordinateString; + pdf.outline.renderItems = function (node) { + var getVerticalCoordinateString = + this.ctx.pdf.internal.getVerticalCoordinateString; for (var i = 0; i < node.children.length; i++) { var item = node.children[i]; this.objStart(item); @@ -241,27 +301,27 @@ import { jsPDF } from "../jspdf.js"; } }; - pdf.outline.line = function(text) { + pdf.outline.line = function (text) { this.ctx.val += text + "\r\n"; }; - pdf.outline.makeRef = function(node) { + pdf.outline.makeRef = function (node) { return node.id + " 0 R"; }; - pdf.outline.makeString = function(val) { + pdf.outline.makeString = function (val) { return "(" + pdf.internal.pdfEscape(val) + ")"; }; - pdf.outline.objStart = function(node) { + pdf.outline.objStart = function (node) { this.ctx.val += "\r\n" + node.id + " 0 obj" + "\r\n<<\r\n"; }; - pdf.outline.objEnd = function() { + pdf.outline.objEnd = function () { this.ctx.val += ">> \r\n" + "endobj" + "\r\n"; }; - pdf.outline.count_r = function(ctx, node) { + pdf.outline.count_r = function (ctx, node) { for (var i = 0; i < node.children.length; i++) { ctx.count++; this.count_r(ctx, node.children[i]); diff --git a/src/modules/png_support.ts b/src/modules/png_support.ts index 478241595..d7471abf8 100644 --- a/src/modules/png_support.ts +++ b/src/modules/png_support.ts @@ -27,6 +27,43 @@ import { jsPDF } from "../jspdf.js"; import { zlibSync } from "../libs/fflate.js"; import { decode as decodePng } from "../libs/fast-png.js"; +import type { jsPDFDocument } from "../types.js"; +import type { ImageCompression, ImageProperties } from "./addimage.js"; + +/** The decoded PNG object produced by fast-png's decode(). */ +type DecodedPng = ReturnType; + +/** A pixel-data array as produced by fast-png / consumed by the filters. */ +type PngLine = Uint8Array | Uint8ClampedArray | Uint16Array; + +type PngFilterMethod = ( + line: PngLine, + colorsPerPixel: number, + prevLine?: PngLine +) => number[]; + +/** Intermediate result of the three process*PNG() helpers below. */ +interface ProcessedPNGResult { + colorSpace: string; + colorsPerPixel: number; + sMaskBitsPerComponent?: number; + colorBytes: PngLine; + alphaBytes?: Uint8Array; + needSMask: boolean; + palette?: number[]; + mask?: number[]; +} + +declare module "../types.js" { + interface jsPDFAPI { + processPNG( + imageData?: unknown, + index?: number, + alias?: number | string, + compression?: ImageCompression + ): ImageProperties | undefined; + } +} /* * @see http://www.w3.org/TR/PNG-Chunks.html @@ -52,7 +89,13 @@ import { decode as decodePng } from "../libs/fast-png.js"; * @name processPNG * Entry point: process a PNG and return image dict and metadata for jsPDF */ -jsPDF.API.processPNG = function(imageData, index, alias, compression) { +jsPDF.API.processPNG = function ( + this: jsPDFDocument, + imageData?: unknown, + index?: number, + alias?: number | string, + compression?: ImageCompression +) { if (this.__addimage__.isArrayBuffer(imageData)) { imageData = new Uint8Array(imageData); } @@ -69,7 +112,7 @@ jsPDF.API.processPNG = function(imageData, index, alias, compression) { depth: bitsPerComponent } = decodedPng; - let result; + let result: ProcessedPNGResult; if (decodedPalette && channels === 1) { result = processIndexedPNG(decodedPng); } else if (channels === 2 || channels === 4) { @@ -89,9 +132,11 @@ jsPDF.API.processPNG = function(imageData, index, alias, compression) { mask } = result; - let predictor = null; + let predictor: number | null = null; - let filter, decodeParameters, sMask; + let filter: string | undefined, + decodeParameters: string | undefined, + sMask: string | Uint8Array | undefined; if (canCompress(compression)) { predictor = getPredictorFromCompression(compression); filter = this.decode.FLATE_DECODE; @@ -141,7 +186,8 @@ jsPDF.API.processPNG = function(imageData, index, alias, compression) { return { alias, - data: imageData, + // The conversion block above guarantees a binary string at this point. + data: imageData as string, index, filter, decodeParameters, @@ -175,7 +221,7 @@ jsPDF.API.processPNG = function(imageData, index, alias, compression) { 4 Paeth */ -function canCompress(value) { +function canCompress(value?: ImageCompression): boolean { return value !== jsPDF.API.image_compression.NONE && hasCompressionJS(); } @@ -183,14 +229,14 @@ function hasCompressionJS() { return typeof zlibSync === "function"; } function compressBytes( - bytes, - lineByteLength, - channels, - bitsPerComponent, - compression -) { - let level = 4; - let filter_method = filterUp; + bytes: PngLine, + lineByteLength: number, + channels: number, + bitsPerComponent: number, + compression?: ImageCompression +): string { + let level: 1 | 4 | 6 | 9 = 4; + let filter_method: PngFilterMethod = filterUp; switch (compression) { case jsPDF.API.image_compression.FAST: @@ -216,20 +262,20 @@ function compressBytes( bytesPerPixel, filter_method ); - const dat = zlibSync(bytes, { level: level as any }); + const dat = zlibSync(bytes, { level: level }); return jsPDF.API.__addimage__.arrayBufferToBinaryString(dat); } function applyPngFilterMethod( - bytes, - lineByteLength, - bytesPerPixel, - filter_method -) { + bytes: PngLine, + lineByteLength: number, + bytesPerPixel: number, + filter_method?: PngFilterMethod +): Uint8Array { const lines = bytes.length / lineByteLength; const result = new Uint8Array(bytes.length + lines); const filter_methods = getFilterMethods(); - let prevLine; + let prevLine: PngLine | undefined; for (let i = 0; i < lines; i += 1) { const offset = i * lineByteLength; @@ -239,7 +285,7 @@ function applyPngFilterMethod( result.set(filter_method(line, bytesPerPixel, prevLine), offset + i); } else { const len = filter_methods.length; - const results = []; + const results: number[][] = []; for (let j = 0; j < len; j += 1) { results[j] = filter_methods[j](line, bytesPerPixel, prevLine); @@ -256,20 +302,22 @@ function applyPngFilterMethod( return result; } -function filterNone(line) { +function filterNone(line: PngLine): number[] { /*const result = new Uint8Array(line.length + 1); result[0] = 0; result.set(line, 1);*/ - const result = Array.apply([], line); + // Array.apply spreads the (array-like) line into a plain array of samples; + // its loose lib typing loses the element type, hence the assertion. + const result = Array.apply([], line as unknown as number[]) as number[]; result.unshift(0); return result; } -function filterSub(line, colorsPerPixel) { +function filterSub(line: PngLine, colorsPerPixel: number): number[] { const len = line.length; - const result = []; + const result: number[] = []; result[0] = 1; @@ -281,9 +329,13 @@ function filterSub(line, colorsPerPixel) { return result; } -function filterUp(line, colorsPerPixel, prevLine) { +function filterUp( + line: PngLine, + colorsPerPixel: number, + prevLine?: PngLine +): number[] { const len = line.length; - const result = []; + const result: number[] = []; result[0] = 2; @@ -295,9 +347,13 @@ function filterUp(line, colorsPerPixel, prevLine) { return result; } -function filterAverage(line, colorsPerPixel, prevLine) { +function filterAverage( + line: PngLine, + colorsPerPixel: number, + prevLine?: PngLine +): number[] { const len = line.length; - const result = []; + const result: number[] = []; result[0] = 3; @@ -310,9 +366,13 @@ function filterAverage(line, colorsPerPixel, prevLine) { return result; } -function filterPaeth(line, colorsPerPixel, prevLine) { +function filterPaeth( + line: PngLine, + colorsPerPixel: number, + prevLine?: PngLine +): number[] { const len = line.length; - const result = []; + const result: number[] = []; result[0] = 4; @@ -327,7 +387,7 @@ function filterPaeth(line, colorsPerPixel, prevLine) { return result; } -function paethPredictor(left, up, upLeft) { +function paethPredictor(left: number, up: number, upLeft: number): number { if (left === up && up === upLeft) { return left; } @@ -341,17 +401,17 @@ function getFilterMethods() { return [filterNone, filterSub, filterUp, filterAverage, filterPaeth]; } -function getIndexOfSmallestSum(arrays) { - const sum = arrays.map(function(value) { - return value.reduce(function(pv, cv) { +function getIndexOfSmallestSum(arrays: number[][]): number { + const sum = arrays.map(function (value) { + return value.reduce(function (pv, cv) { return pv + Math.abs(cv); }, 0); }); return sum.indexOf(Math.min.apply(null, sum)); } -function getPredictorFromCompression(compression) { - let predictor; +function getPredictorFromCompression(compression?: ImageCompression): number { + let predictor: number; switch (compression) { case jsPDF.API.image_compression.FAST: predictor = 11; @@ -373,12 +433,12 @@ function getPredictorFromCompression(compression) { } // Extracted helper for Indexed PNGs (palette-based) -function processIndexedPNG(decodedPng) { +function processIndexedPNG(decodedPng: DecodedPng): ProcessedPNGResult { const { width, height, data, palette: decodedPalette, depth } = decodedPng; let needSMask = false; - let palette = []; - let mask = []; - let alphaBytes = undefined; + let palette: number[] = []; + let mask: number[] | undefined = []; + let alphaBytes: Uint8Array | undefined = undefined; let hasSemiTransparency = false; const maxMaskLength = 1; @@ -431,7 +491,7 @@ function processIndexedPNG(decodedPng) { /* * Splits color and alpha values into separate buffers */ -function processAlphaPNG(decodedPng) { +function processAlphaPNG(decodedPng: DecodedPng): ProcessedPNGResult { const { data, width, height, channels, depth } = decodedPng; const colorSpace = channels === 2 ? "DeviceGray" : "DeviceRGB"; @@ -478,12 +538,12 @@ function processAlphaPNG(decodedPng) { }; } -function processOpaquePNG(decodedPng) { +function processOpaquePNG(decodedPng: DecodedPng): ProcessedPNGResult { const { data, channels } = decodedPng; const colorSpace = channels === 1 ? "DeviceGray" : "DeviceRGB"; const colorsPerPixel = colorSpace === "DeviceGray" ? 1 : 3; - let colorBytes; + let colorBytes: PngLine; if (data instanceof Uint16Array) { colorBytes = convertUint16ArrayToUint8Array(data); } else { @@ -493,7 +553,7 @@ function processOpaquePNG(decodedPng) { return { colorSpace, colorsPerPixel, colorBytes, needSMask: false }; } -function convertUint16ArrayToUint8Array(data) { +function convertUint16ArrayToUint8Array(data: Uint16Array): Uint8Array { // PNG/PDF expect MSB-first byte order. Since EcmaScript does not specify // the byte order of Uint16Array, we need to use a DataView to ensure the // correct byte order. @@ -507,7 +567,11 @@ function convertUint16ArrayToUint8Array(data) { return out; } -function readSample(view, sampleIndex, depth) { +function readSample( + view: DataView, + sampleIndex: number, + depth: number +): number { const bitIndex = sampleIndex * depth; const byteIndex = Math.floor(bitIndex / 8); const bitOffset = 16 - (bitIndex - byteIndex * 8 + depth); @@ -516,7 +580,12 @@ function readSample(view, sampleIndex, depth) { return (word >> bitOffset) & bitMask; } -function writeSample(view, value, sampleIndex, depth) { +function writeSample( + view: DataView, + value: number, + sampleIndex: number, + depth: number +): void { const bitIndex = sampleIndex * depth; const byteIndex = Math.floor(bitIndex / 8); const bitOffset = 16 - (bitIndex - byteIndex * 8 + depth); @@ -527,7 +596,7 @@ function writeSample(view, value, sampleIndex, depth) { safeSetUint16(view, byteIndex, word | writeValue); } -function safeGetUint16(view, byteIndex) { +function safeGetUint16(view: DataView, byteIndex: number): number { if (byteIndex + 1 < view.byteLength) { return view.getUint16(byteIndex, false); } @@ -535,7 +604,7 @@ function safeGetUint16(view, byteIndex) { return b0 << 8; } -function safeSetUint16(view, byteIndex, value) { +function safeSetUint16(view: DataView, byteIndex: number, value: number): void { if (byteIndex + 1 < view.byteLength) { view.setUint16(byteIndex, value, false); return; diff --git a/src/modules/rgba_support.ts b/src/modules/rgba_support.ts index 551382dae..48089d256 100644 --- a/src/modules/rgba_support.ts +++ b/src/modules/rgba_support.ts @@ -25,13 +25,25 @@ */ import { jsPDF } from "../jspdf.js"; +import type { jsPDFAPI as JsPDFAPI, jsPDFDocument } from "../types.js"; +import type { ImageProperties, RGBAData } from "./addimage.js"; + +declare module "../types.js" { + interface jsPDFAPI { + processRGBA( + imageData?: unknown, + index?: number, + alias?: number | string + ): ImageProperties & { alpha: string }; + } +} /** * jsPDF RGBA array PlugIn * @name rgba_support * @module */ -(function(jsPDFAPI) { +(function (jsPDFAPI: JsPDFAPI) { "use strict"; /** @@ -42,7 +54,12 @@ import { jsPDF } from "../jspdf.js"; * RGBA array data can be obtained from DOM canvas getImageData. * @ignore */ - jsPDFAPI.processRGBA = function(imageData, index, alias) { + jsPDFAPI.processRGBA = function ( + this: jsPDFDocument, + imageData: RGBAData, + index?: number, + alias?: number | string + ) { "use strict"; var imagePixels = imageData.data; diff --git a/src/modules/setlanguage.ts b/src/modules/setlanguage.ts index 434165fc5..4502c13d1 100644 --- a/src/modules/setlanguage.ts +++ b/src/modules/setlanguage.ts @@ -5,6 +5,19 @@ */ import { jsPDF } from "../jspdf.js"; +import type { jsPDFAPI as JsPDFAPI, jsPDFDocument } from "../types.js"; + +declare module "../types.js" { + interface jsPDFAPI { + setLanguage(langCode: string): jsPDFDocument; + } + interface jsPDFInternal { + languageSettings?: { + isSubscribed?: boolean; + languageCode?: string; + }; + } +} /** * jsPDF setLanguage Plugin @@ -12,7 +25,7 @@ import { jsPDF } from "../jspdf.js"; * @name setLanguage * @module */ -(function(jsPDFAPI) { +(function (jsPDFAPI: JsPDFAPI) { "use strict"; /** @@ -28,10 +41,10 @@ import { jsPDF } from "../jspdf.js"; * doc.setLanguage("en-US") * doc.save('english.pdf') */ - jsPDFAPI.setLanguage = function(langCode) { + jsPDFAPI.setLanguage = function (this: jsPDFDocument, langCode: string) { "use strict"; - var langCodes = { + var langCodes: Record = { af: "Afrikaans", sq: "Albanian", ar: "Arabic (Standard)", @@ -238,11 +251,14 @@ import { jsPDF } from "../jspdf.js"; if (langCodes[langCode] !== undefined) { this.internal.languageSettings.languageCode = langCode; if (this.internal.languageSettings.isSubscribed === false) { - this.internal.events.subscribe("putCatalog", function() { - this.internal.write( - "/Lang (" + this.internal.languageSettings.languageCode + ")" - ); - }); + this.internal.events.subscribe( + "putCatalog", + function (this: jsPDFDocument) { + this.internal.write( + "/Lang (" + this.internal.languageSettings.languageCode + ")" + ); + } + ); this.internal.languageSettings.isSubscribed = true; } } diff --git a/src/modules/split_text_to_size.ts b/src/modules/split_text_to_size.ts index df0c8b7e8..0c1d3b9cd 100755 --- a/src/modules/split_text_to_size.ts +++ b/src/modules/split_text_to_size.ts @@ -25,6 +25,61 @@ */ import { jsPDF } from "../jspdf.js"; +import type { Font, jsPDFAPI as JsPDFAPI, jsPDFDocument } from "../types.js"; + +/** Character widths table: char code -> width, plus the `fof` fraction. */ +export interface FontWidthsTable { + [charCode: number]: number; + fof?: number; +} + +/** Kerning table: char code -> prior char code -> kerning value. */ +export interface FontKerningTable { + [charCode: number]: { [priorCharCode: number]: number }; + fof?: number; +} + +/** Options consumed by getCharWidthsArray()/getStringUnitWidth(). */ +export interface CharWidthsOptions { + font?: Font; + fontSize?: number; + charSpace?: number; + widths?: FontWidthsTable; + kerning?: FontKerningTable; + doKerning?: boolean; +} + +/** Options accepted by splitTextToSize(). */ +export interface SplitTextOptions extends CharWidthsOptions { + textIndent?: number; + lineIndent?: number; + fontName?: string; + fontStyle?: string; +} + +/** + * View of the font-metadata members this plugin consults: the metric tables + * written by standard_fonts_metrics, or the TTF font object (which carries + * widthOfString & co) written by ttfsupport. + */ +interface SplitFontMetadataView { + Unicode?: { widths?: FontWidthsTable; kerning?: FontKerningTable }; + widthOfString?: (text: string, fontSize: number, charSpace: number) => number; + widthOfGlyph?: (glyph: number | string) => number; + characterToGlyph?: (code: number) => number | string; +} + +declare module "../types.js" { + interface jsPDFAPI { + getCharWidthsArray(text: string, options?: CharWidthsOptions): number[]; + getStringUnitWidth(text: string, options?: CharWidthsOptions): number; + splitTextToSize( + text: string | string[], + maxlen: number, + options?: SplitTextOptions + ): string[]; + } +} /** * jsPDF split_text_to_size plugin @@ -32,7 +87,7 @@ import { jsPDF } from "../jspdf.js"; * @name split_text_to_size * @module */ -(function(API) { +(function (API: JsPDFAPI) { "use strict"; /** * Returns an array of length matching length of the 'word' string, with each @@ -44,46 +99,55 @@ import { jsPDF } from "../jspdf.js"; * @param {Object} options * @returns {Array} */ - var getCharWidthsArray = (API.getCharWidthsArray = function(text, options) { + var getCharWidthsArray = (API.getCharWidthsArray = function ( + this: jsPDFDocument, + text: string, + options?: CharWidthsOptions + ) { options = options || {}; var activeFont = options.font || this.internal.getFont(); var fontSize = options.fontSize || this.internal.getFontSize(); var charSpace = options.charSpace || this.internal.getCharSpace(); - var widths = options.widths - ? options.widths - : activeFont.metadata.Unicode.widths; + // font.metadata values are opaque to the core; the assertion names the + // members this plugin consults (see SplitFontMetadataView above). + var metadata = activeFont.metadata as SplitFontMetadataView; + + var widths = options.widths ? options.widths : metadata.Unicode.widths; var widthsFractionOf = widths.fof ? widths.fof : 1; - var kerning = options.kerning - ? options.kerning - : activeFont.metadata.Unicode.kerning; + var kerning = options.kerning ? options.kerning : metadata.Unicode.kerning; var kerningFractionOf = kerning.fof ? kerning.fof : 1; var doKerning = options.doKerning === false ? false : true; var kerningValue = 0; - var i; + var i: number; var length = text.length; - var char_code; + var char_code: number; var prior_char_code = 0; //for kerning var default_char_width = widths[0] || widthsFractionOf; - var output = []; + var output: number[] = []; for (i = 0; i < length; i++) { char_code = text.charCodeAt(i); - if (typeof activeFont.metadata.widthOfString === "function") { + if (typeof metadata.widthOfString === "function") { output.push( - (activeFont.metadata.widthOfGlyph( - activeFont.metadata.characterToGlyph(char_code) - ) + + (metadata.widthOfGlyph(metadata.characterToGlyph(char_code)) + charSpace * (1000 / fontSize) || 0) / 1000 ); } else { if ( doKerning && typeof kerning[char_code] === "object" && - !isNaN(parseInt(kerning[char_code][prior_char_code], 10)) + // parseInt applies ToString to its argument at runtime, so the + // numeric kerning value is accepted; the assertion keeps that. + !isNaN( + parseInt( + kerning[char_code][prior_char_code] as unknown as string, + 10 + ) + ) ) { kerningValue = kerning[char_code][prior_char_code] / kerningFractionOf; @@ -117,7 +181,11 @@ import { jsPDF } from "../jspdf.js"; * @param {string} options * @returns {number} result */ - var getStringUnitWidth = (API.getStringUnitWidth = function(text, options) { + var getStringUnitWidth = (API.getStringUnitWidth = function ( + this: jsPDFDocument, + text: string, + options?: CharWidthsOptions + ) { options = options || {}; var fontSize = options.fontSize || this.internal.getFontSize(); @@ -129,13 +197,17 @@ import { jsPDF } from "../jspdf.js"; text = API.processArabic(text); } - if (typeof font.metadata.widthOfString === "function") { - result = - font.metadata.widthOfString(text, fontSize, charSpace) / fontSize; + // See SplitFontMetadataView above. + var metadata = font.metadata as SplitFontMetadataView; + + if (typeof metadata.widthOfString === "function") { + result = metadata.widthOfString(text, fontSize, charSpace) / fontSize; } else { result = getCharWidthsArray - .apply(this, arguments as any) - .reduce(function(pv, cv) { + // The raw arguments object is forwarded verbatim; it always holds + // (text, options), which is exactly what getCharWidthsArray takes. + .apply(this, arguments as unknown as [string, CharWidthsOptions]) + .reduce(function (pv, cv) { return pv + cv; }, 0); } @@ -145,8 +217,13 @@ import { jsPDF } from "../jspdf.js"; /** returns array of lines */ - var splitLongWord = function(word, widths_array, firstLineMaxLen, maxLen) { - var answer = []; + var splitLongWord = function ( + word: string, + widths_array: number[], + firstLineMaxLen: number, + maxLen: number + ): string[] { + var answer: string[] = []; // 1st, chop off the piece that can fit on the hanging line. var i = 0, @@ -180,7 +257,12 @@ import { jsPDF } from "../jspdf.js"; // Note, all sizing inputs for this function must be in "font measurement units" // By default, for PDF, it's "point". - var splitParagraphIntoLines = function(text, maxlen, options) { + var splitParagraphIntoLines = function ( + this: jsPDFDocument, + text: string, + maxlen: number, + options?: SplitTextOptions + ): string[] { // at this time works only on Western scripts, ones with space char // separating the words. Feel free to expand. @@ -188,19 +270,19 @@ import { jsPDF } from "../jspdf.js"; options = {}; } - var line = [], + var line: string[] = [], lines = [line], line_length = options.textIndent || 0, separator_length = 0, current_word_length = 0, - word, - widths_array, + word: string, + widths_array: number[], words = text.split(" "), spaceCharWidth = getCharWidthsArray.apply(this, [" ", options])[0], - i, - l, - tmp, - lineIndent; + i: number, + l: number, + tmp: string[], + lineIndent: number; if (options.lineIndent === -1) { lineIndent = words[0].length + 2; @@ -209,12 +291,14 @@ import { jsPDF } from "../jspdf.js"; } if (lineIndent) { var pad = Array(lineIndent).join(" "), - wrds = []; - words.map(function(wrd) { - wrd = wrd.split(/\s*\n/); + wrds: string[] = []; + words.map(function (wrd: string | string[]) { + // The parameter is reused to hold its own split; the assertion names + // the string it necessarily is on entry. + wrd = (wrd as string).split(/\s*\n/); if (wrd.length > 1) { wrds = wrds.concat( - wrd.map(function(wrd, idx) { + wrd.map(function (wrd, idx) { return (idx && wrd.length ? "\n" : "") + wrd; }) ); @@ -235,7 +319,7 @@ import { jsPDF } from "../jspdf.js"; force = 1; } widths_array = getCharWidthsArray.apply(this, [word, options]); - current_word_length = widths_array.reduce(function(pv, cv) { + current_word_length = widths_array.reduce(function (pv, cv) { return pv + cv; }, 0); @@ -262,7 +346,7 @@ import { jsPDF } from "../jspdf.js"; } current_word_length = widths_array .slice(word.length - (line[0] ? line[0].length : 0)) - .reduce(function(pv, cv) { + .reduce(function (pv, cv) { return pv + cv; }, 0); } else { @@ -282,13 +366,13 @@ import { jsPDF } from "../jspdf.js"; } } - var postProcess; + var postProcess: (ln: string[], idx?: number) => string; if (lineIndent) { - postProcess = function(ln, idx) { + postProcess = function (ln: string[], idx?: number) { return (idx ? pad : "") + ln.join(" "); }; } else { - postProcess = function(ln) { + postProcess = function (ln: string[]) { return ln.join(" "); }; } @@ -313,17 +397,25 @@ import { jsPDF } from "../jspdf.js"; * @param {Object} options Optional flags needed for chopper to do the right thing. * @returns {Array} array Array with strings chopped to size. */ - API.splitTextToSize = function(text, maxlen, options) { + API.splitTextToSize = function ( + this: jsPDFDocument, + text: string | string[], + maxlen: number, + options?: SplitTextOptions + ) { "use strict"; options = options || {}; var fsize = options.fontSize || this.internal.getFontSize(), - newOptions: any = function(options) { - var widths = { + newOptions = function ( + this: jsPDFDocument, + options: SplitTextOptions + ): SplitTextOptions { + var widths: FontWidthsTable = { 0: 1 }, - kerning = {}; + kerning: FontKerningTable = {}; if (!options.widths || !options.kerning) { var f = this.internal.getFont(options.fontName, options.fontStyle), @@ -334,12 +426,21 @@ import { jsPDF } from "../jspdf.js"; if (f.metadata[encoding]) { return { - widths: f.metadata[encoding].widths || widths, - kerning: f.metadata[encoding].kerning || kerning + // font.metadata values are opaque to the core; the assertions + // name the metric-table entry consulted here. + widths: + (f.metadata[encoding] as SplitFontMetadataView["Unicode"]) + .widths || widths, + kerning: + (f.metadata[encoding] as SplitFontMetadataView["Unicode"]) + .kerning || kerning }; } else { return { - font: f.metadata, + // Latent quirk preserved for parity: the TTF metadata object is + // passed through the `font` option slot (getCharWidthsArray and + // getStringUnitWidth then look up `.metadata` on it). + font: f.metadata as unknown as Font, fontSize: this.internal.getFontSize(), charSpace: this.internal.getCharSpace() }; @@ -353,7 +454,7 @@ import { jsPDF } from "../jspdf.js"; }.call(this, options); // first we split on end-of-line chars - var paragraphs; + var paragraphs: string[]; if (Array.isArray(text)) { paragraphs = text; } else { @@ -377,9 +478,9 @@ import { jsPDF } from "../jspdf.js"; : 0; newOptions.lineIndent = options.lineIndent; - var i, - l, - output = []; + var i: number, + l: number, + output: string[] = []; for (i = 0, l = paragraphs.length; i < l; i++) { output = output.concat( splitParagraphIntoLines.apply(this, [ diff --git a/src/modules/standard_fonts_metrics.ts b/src/modules/standard_fonts_metrics.ts index dceb782d5..5c43f17d0 100644 --- a/src/modules/standard_fonts_metrics.ts +++ b/src/modules/standard_fonts_metrics.ts @@ -24,6 +24,40 @@ */ import { jsPDF } from "../jspdf.js"; +import type { AddFontPayload, jsPDFAPI as JsPDFAPI } from "../types.js"; + +/** + * The nested structure produced by uncompress()/consumed by compress(): + * leaves are numbers, every other value is a nested table. + */ +export interface FontMetricsTree { + [key: string]: number | FontMetricsTree; +} + +/** Helper namespace exposed as `jsPDF.API.__fontmetrics__`. */ +export interface FontMetricsNamespace { + compress(data: FontMetricsTree): string; + uncompress(data: string): FontMetricsTree; +} + +/** Per-font encoding entry (codepage list plus unicode -> codepage map). */ +interface EncodingBlock { + codePages: string[]; + WinAnsiEncoding: FontMetricsTree; +} + +/** The `Unicode` entry this plugin writes into `font.metadata`. */ +interface UnicodeFontMetadata { + widths?: number | FontMetricsTree; + kerning?: number | FontMetricsTree; + encoding?: EncodingBlock; +} + +declare module "../types.js" { + interface jsPDFAPI { + __fontmetrics__: FontMetricsNamespace; + } +} /** * This file adds the standard font metrics to jsPDF. @@ -45,33 +79,43 @@ import { jsPDF } from "../jspdf.js"; * @module */ -(function(API) { +(function (API: JsPDFAPI) { "use strict"; - API.__fontmetrics__ = API.__fontmetrics__ || {}; + // Created empty here and filled member by member directly below. + API.__fontmetrics__ = API.__fontmetrics__ || ({} as FontMetricsNamespace); var decoded = "0123456789abcdef", encoded = "klmnopqrstuvwxyz", - mappingUncompress = {}, - mappingCompress = {}; + mappingUncompress: Record = {}, + mappingCompress: Record = {}; for (var i = 0; i < encoded.length; i++) { mappingUncompress[encoded[i]] = decoded[i]; mappingCompress[decoded[i]] = encoded[i]; } - var hex = function(value) { - return "0x" + parseInt(value, 10).toString(16); + var hex = function (value: string | number): string { + // parseInt applies ToString to its argument at runtime, so numbers are + // accepted too; the assertion keeps that coercion verbatim. + return "0x" + parseInt(value as string, 10).toString(16); }; - var compress = (API.__fontmetrics__.compress = function(data) { + var compress = (API.__fontmetrics__.compress = function ( + data: FontMetricsTree + ): string { var vals = ["{"]; - var value, keystring, valuestring, numberprefix; + var value: number | FontMetricsTree, + keystring: string, + valuestring: string, + numberprefix: string; for (var key in data) { value = data[key]; if (!isNaN(parseInt(key, 10))) { - key = parseInt(key, 10) as any; + // Preserved verbatim: the loop variable is reused to hold the numeric + // key; hex() coerces it back through parseInt. + key = parseInt(key, 10) as unknown as string; keystring = hex(key).slice(2); keystring = keystring.slice(0, -1) + mappingCompress[keystring.slice(-1)]; @@ -114,22 +158,24 @@ import { jsPDF } from "../jspdf.js"; * @param * @returns {Type} */ - var uncompress = (API.__fontmetrics__.uncompress = function(data) { + var uncompress = (API.__fontmetrics__.uncompress = function ( + data: string + ): FontMetricsTree { if (typeof data !== "string") { throw new Error("Invalid argument passed to uncompress."); } - var output = {}, + var output: FontMetricsTree = {}, sign = 1, - stringparts, // undef. will be [] in string mode + stringparts: string[] | undefined, // undef. will be [] in string mode activeobject = output, - parentchain = [], - parent_key_pair, + parentchain: Array<[FontMetricsTree, string | number]> = [], + parent_key_pair: [FontMetricsTree, string | number], keyparts = "", valueparts = "", - key, // undef. will be Truthy when Key is resolved. + key: string | number | undefined, // undef. will be Truthy when Key is resolved. datalen = data.length - 1, // stripping ending } - ch; + ch: string; for (var i = 1; i < datalen; i += 1) { // - { } ' are special. @@ -200,13 +246,13 @@ import { jsPDF } from "../jspdf.js"; // these will be mapped to win cp1252 // for example, you can send char code (cp1252) 0x80 or (unicode) 0x20AC, getting "Euro" glyph displayed in both cases. - var encodingBlock = { + var encodingBlock: EncodingBlock = { codePages: ["WinAnsiEncoding"], WinAnsiEncoding: uncompress( "{19m8n201n9q201o9r201s9l201t9m201u8m201w9n201x9o201y8o202k8q202l8r202m9p202q8p20aw8k203k8t203t8v203u9v2cq8s212m9t15m8w15n9w2dw9s16k8u16l9u17s9z17x8y17y9y}" ) }; - var encodings = { + var encodings: { Unicode: Record } = { Unicode: { Courier: encodingBlock, "Courier-Bold": encodingBlock, @@ -225,7 +271,7 @@ import { jsPDF } from "../jspdf.js"; } }; - var fontMetrics = { + var fontMetrics: { Unicode: Record } = { Unicode: { // all sizing numbers are n/fontMetricsFractionOf = one font size unit // this means that if fontMetricsFractionOf = 1000, and letter A's width is 476, it's @@ -287,19 +333,24 @@ import { jsPDF } from "../jspdf.js"; */ API.events.push([ "addFont", - function(data) { + function (data: AddFontPayload) { var font = data.font; var metrics = fontMetrics["Unicode"][font.postScriptName]; if (metrics) { - font.metadata["Unicode"] = {}; - font.metadata["Unicode"].widths = metrics.widths; - font.metadata["Unicode"].kerning = metrics.kerning; + // font.metadata values are opaque to the core (Record); the assertions name the entry this plugin owns. + font.metadata["Unicode"] = {} as UnicodeFontMetadata; + (font.metadata["Unicode"] as UnicodeFontMetadata).widths = + metrics.widths; + (font.metadata["Unicode"] as UnicodeFontMetadata).kerning = + metrics.kerning; } var encodingBlock = encodings["Unicode"][font.postScriptName]; if (encodingBlock) { - font.metadata["Unicode"].encoding = encodingBlock; + (font.metadata["Unicode"] as UnicodeFontMetadata).encoding = + encodingBlock; font.encoding = encodingBlock.codePages[0]; } } diff --git a/src/modules/svg.ts b/src/modules/svg.ts index b02571566..038d7c25e 100644 --- a/src/modules/svg.ts +++ b/src/modules/svg.ts @@ -25,13 +25,34 @@ import { jsPDF } from "../jspdf.js"; import { console } from "../libs/console.js"; import { globalObject } from "../libs/globalObject.js"; +import type { CanvgStatic } from "canvg"; +import type { jsPDFAPI as JsPDFAPI, jsPDFDocument } from "../types.js"; +import type { ImageCompression } from "./addimage.js"; // Ambient declarations for the module-format-specific branches kept inside // "@if MODULE_FORMAT" preprocess directive blocks. -declare const require: any; -declare const module: any; -declare const exports: any; -declare const define: any; +declare const require: { + (id: string): unknown; + (ids: string[], onLoad: (mod: unknown) => void): unknown; +}; +declare const module: unknown; +declare const exports: unknown; +declare const define: { amd?: unknown }; + +declare module "../types.js" { + interface jsPDFAPI { + addSvgAsImage( + svg: string, + x: number, + y: number, + w: number, + h: number, + alias?: string, + compression?: ImageCompression, + rotation?: number + ): Promise; + } +} /** * jsPDF SVG plugin @@ -39,11 +60,11 @@ declare const define: any; * @name svg * @module */ -(function(jsPDFAPI) { +(function (jsPDFAPI: JsPDFAPI) { "use strict"; - function loadCanvg() { - return (function() { + function loadCanvg(): Promise { + return (function (): Promise { if (globalObject["canvg"]) { return Promise.resolve(globalObject["canvg"]); } @@ -54,7 +75,7 @@ declare const define: any; // @if MODULE_FORMAT!='es' if (typeof exports === "object" && typeof module !== "undefined") { - return new Promise(function(resolve, reject) { + return new Promise(function (resolve, reject) { try { resolve(require("canvg")); } catch (e) { @@ -63,7 +84,7 @@ declare const define: any; }); } if (typeof define === "function" && define.amd) { - return new Promise(function(resolve, reject) { + return new Promise(function (resolve, reject) { try { require(["canvg"], resolve); } catch (e) { @@ -74,11 +95,15 @@ declare const define: any; return Promise.reject(new Error("Could not load canvg")); // @endif })() - .catch(function(e) { + .catch(function (e) { return Promise.reject(new Error("Could not load canvg: " + e)); }) - .then(function(canvg) { - return canvg.default ? canvg.default : canvg; + .then(function (canvg) { + // The loaded value is either a module namespace carrying the library + // on `default` or the library itself; the runtime check is preserved + // and the assertion only names what the branches produce. + var loaded = canvg as { default?: CanvgStatic }; + return (loaded.default ? loaded.default : loaded) as CanvgStatic; }); } @@ -101,15 +126,16 @@ declare const define: any; * * @returns jsPDF jsPDF-instance */ - jsPDFAPI.addSvgAsImage = function( - svg, - x, - y, - w, - h, - alias, - compression, - rotation + jsPDFAPI.addSvgAsImage = function ( + this: jsPDFDocument, + svg: string, + x: number, + y: number, + w: number, + h: number, + alias?: string, + compression?: ImageCompression, + rotation?: number ) { if (isNaN(x) || isNaN(y)) { console.error("jsPDF.addSvgAsImage: Invalid coordinates", arguments); @@ -138,25 +164,29 @@ declare const define: any; var doc = this; return loadCanvg() .then( - function(canvg) { + function (canvg) { return canvg.fromString(ctx, svg, options); }, - function() { + function () { return Promise.reject(new Error("Could not load canvg.")); } ) - .then(function(instance) { + .then(function (instance) { return instance.render(options); }) - .then(function() { + .then(function () { doc.addImage( canvas.toDataURL("image/jpeg", 1.0), x, y, w, h, + // Latent bug preserved for parity: compression and rotation are + // passed one parameter slot early (into addImage's alias and + // compression parameters); `alias` itself is never forwarded. The + // assertion keeps the historical call shape verbatim. compression, - rotation + rotation as unknown as ImageCompression ); }); }; diff --git a/src/modules/total_pages.ts b/src/modules/total_pages.ts index bef62e7ca..74a31b47f 100644 --- a/src/modules/total_pages.ts +++ b/src/modules/total_pages.ts @@ -25,13 +25,20 @@ */ import { jsPDF } from "../jspdf.js"; +import type { jsPDFAPI as JsPDFAPI, jsPDFDocument } from "../types.js"; + +declare module "../types.js" { + interface jsPDFAPI { + putTotalPages(pageExpression: string): jsPDFDocument; + } +} /** * jsPDF total_pages plugin * @name total_pages * @module */ -(function(jsPDFAPI) { +(function (jsPDFAPI: JsPDFAPI) { "use strict"; /** * @name putTotalPages @@ -40,11 +47,14 @@ import { jsPDF } from "../jspdf.js"; * @returns {jsPDF} jsPDF-instance */ - jsPDFAPI.putTotalPages = function(pageExpression) { + jsPDFAPI.putTotalPages = function ( + this: jsPDFDocument, + pageExpression: string + ) { "use strict"; var replaceExpression; - var totalNumberOfPages = 0; + var totalNumberOfPages: number | string = 0; if (parseInt(this.internal.getFont().id.substr(1), 10) < 15) { replaceExpression = new RegExp(pageExpression, "g"); totalNumberOfPages = this.internal.getNumberOfPages(); @@ -63,7 +73,9 @@ import { jsPDF } from "../jspdf.js"; for (var i = 0; i < this.internal.pages[n].length; i++) { this.internal.pages[n][i] = this.internal.pages[n][i].replace( replaceExpression, - totalNumberOfPages + // String.prototype.replace coerces a non-string replacement at + // runtime; the assertion keeps that behavior without a conversion. + totalNumberOfPages as string ); } } diff --git a/src/modules/ttfsupport.ts b/src/modules/ttfsupport.ts index 06d139ff6..a26a10181 100644 --- a/src/modules/ttfsupport.ts +++ b/src/modules/ttfsupport.ts @@ -6,15 +6,30 @@ import { jsPDF } from "../jspdf.js"; import { atob } from "../libs/AtobBtoa.js"; +import type { + AddFontPayload, + Font, + TTFFontConstructor, + jsPDFConstructor +} from "../types.js"; + +declare module "../types.js" { + interface jsPDFAPI { + /** Installed by the vendored TTF library (src/libs/ttffont.ts). */ + TTFFont: TTFFontConstructor; + /** Installed by the vendored TTF library (src/libs/ttffont.ts). */ + PDFObject: { convert(value: unknown): string }; + } +} /** * @name ttfsupport * @module */ -(function(jsPDF) { +(function (jsPDF: jsPDFConstructor) { "use strict"; - var binaryStringToUint8Array = function(binary_string) { + var binaryStringToUint8Array = function (binary_string: string) { var len = binary_string.length; var bytes = new Uint8Array(len); for (var i = 0; i < len; i++) { @@ -23,12 +38,12 @@ import { atob } from "../libs/AtobBtoa.js"; return bytes; }; - var addFont = function(font, file) { + var addFont = function (font: Font, file: string | Uint8Array) { // eslint-disable-next-line no-control-regex - if (/^\x00\x01\x00\x00/.test(file)) { - file = binaryStringToUint8Array(file); + if (/^\x00\x01\x00\x00/.test(file as string)) { + file = binaryStringToUint8Array(file as string); } else { - file = binaryStringToUint8Array(atob(file)); + file = binaryStringToUint8Array(atob(file as string)); } font.metadata = jsPDF.API.TTFFont.open(file); font.metadata.Unicode = font.metadata.Unicode || { @@ -41,7 +56,7 @@ import { atob } from "../libs/AtobBtoa.js"; jsPDF.API.events.push([ "addFont", - function(data) { + function (data: AddFontPayload) { var file = undefined; var font = data.font; var instance = data.instance; diff --git a/src/modules/utf8.ts b/src/modules/utf8.ts index ba56b7e10..98fbcf9ae 100644 --- a/src/modules/utf8.ts +++ b/src/modules/utf8.ts @@ -1,11 +1,33 @@ import { jsPDF } from "../jspdf.js"; import { toPDFName } from "../libs/pdfname.js"; +import type { + Font, + PutFontPayload, + TTFFontInstance, + TextEntry, + TextProcessingMutex, + TextProcessingPayload, + jsPDFConstructor +} from "../types.js"; + +declare module "../types.js" { + interface jsPDFAPI { + pdfEscape16(text: string, font: Font): string; + } + interface Font { + /** Set by the utf8 plugin's putFont handlers once the font dictionary has been written. */ + isAlreadyPutted?: boolean; + } +} + +/** A font whose metadata has been populated by the TTF plugin. */ +type TTFFontEntry = Font & { metadata: TTFFontInstance }; /** * @name utf8 * @module */ -(function(jsPDF) { +(function (jsPDF: jsPDFConstructor) { "use strict"; var jsPDFAPI = jsPDF.API; @@ -14,7 +36,10 @@ import { toPDFName } from "../libs/pdfname.js"; /* comment : The character id of a 2-byte string is converted to a hexadecimal number by obtaining */ /* the corresponding glyph id and width, and then adding padding to the string. */ /***************************************************************************************************/ - var pdfEscape16 = (jsPDFAPI.pdfEscape16 = function(text, font) { + var pdfEscape16 = (jsPDFAPI.pdfEscape16 = function ( + text: string, + font: TTFFontEntry + ) { var widths = font.metadata.Unicode.widths; var padz = ["", "0", "00", "000", "0000"]; var ar = [""]; @@ -37,12 +62,13 @@ import { toPDFName } from "../libs/pdfname.js"; return ar.join(""); }); - var toUnicodeCmap = function(map) { + var toUnicodeCmap = function (map: Record) { var code, codes, range, unicode, unicodeMap, _i, _len; unicodeMap = "/CIDInit /ProcSet findresource begin\n12 dict begin\nbegincmap\n/CIDSystemInfo <<\n /Registry (Adobe)\n /Ordering (UCS)\n /Supplement 0\n>> def\n/CMapName /Adobe-Identity-UCS def\n/CMapType 2 def\n1 begincodespacerange\n<0000>\nendcodespacerange"; - codes = Object.keys(map).sort(function(a, b) { - return (a as any) - (b as any); + codes = Object.keys(map).sort(function (a, b) { + // Numeric sort of numeric string keys; subtraction coerces at runtime. + return (a as unknown as number) - (b as unknown as number); }); range = []; @@ -82,7 +108,7 @@ import { toPDFName } from "../libs/pdfname.js"; return unicodeMap; }; - var identityHFunction = function(options) { + var identityHFunction = function (options: PutFontPayload) { var font = options.font; var out = options.out; var newObject = options.newObject; @@ -159,12 +185,12 @@ import { toPDFName } from "../libs/pdfname.js"; jsPDFAPI.events.push([ "putFont", - function(args) { + function (args: PutFontPayload) { identityHFunction(args); } ]); - var winAnsiEncodingFunction = function(options) { + var winAnsiEncodingFunction = function (options: PutFontPayload) { var font = options.font; var out = options.out; var newObject = options.newObject; @@ -207,8 +233,10 @@ import { toPDFName } from "../libs/pdfname.js"; font.objectNumber = newObject(); for (var j = 0; j < font.metadata.hmtx.widths.length; j++) { font.metadata.hmtx.widths[j] = parseInt( + // parseInt coerces its argument to a string at runtime; kept as-is + // (truncation via parseInt) to avoid a behavior change. (font.metadata.hmtx.widths[j] * - (1000 / font.metadata.head.unitsPerEm)) as any + (1000 / font.metadata.head.unitsPerEm)) as unknown as string ); //Change the width of Em units to Point units. } out( @@ -232,17 +260,17 @@ import { toPDFName } from "../libs/pdfname.js"; jsPDFAPI.events.push([ "putFont", - function(args) { + function (args: PutFontPayload) { winAnsiEncodingFunction(args); } ]); - var utf8TextFunction = function(args) { + var utf8TextFunction = function (args: TextProcessingPayload) { var text = args.text || ""; var x = args.x; var y = args.y; var options = args.options || {}; - var mutex = args.mutex || {}; + var mutex = args.mutex || ({} as TextProcessingMutex); var pdfEscape = mutex.pdfEscape; var activeFontKey = mutex.activeFontKey; @@ -264,16 +292,16 @@ import { toPDFName } from "../libs/pdfname.js"; mutex: mutex }; } - strText = text; + strText = text as string; key = activeFontKey; if (Array.isArray(text)) { - strText = text[0]; + strText = text[0] as string; } for (s = 0; s < strText.length; s += 1) { if (fonts[key].metadata.hasOwnProperty("cmap")) { - cmapConfirm = - fonts[key].metadata.cmap.unicode.codeMap[strText[s].charCodeAt(0)]; + cmapConfirm = (fonts[key] as TTFFontEntry).metadata.cmap.unicode + .codeMap[strText[s].charCodeAt(0)]; /* if (Object.prototype.toString.call(text) === '[object Array]') { var i = 0; @@ -307,12 +335,12 @@ import { toPDFName } from "../libs/pdfname.js"; //For the default 13 font result = pdfEscape(str, key) .split("") - .map(function(cv) { + .map(function (cv) { return cv.charCodeAt(0).toString(16); }) .join(""); } else if (encoding === "Identity-H") { - result = pdfEscape16(str, fonts[key]); + result = pdfEscape16(str, fonts[key] as TTFFontEntry); } mutex.isHex = true; @@ -325,13 +353,13 @@ import { toPDFName } from "../libs/pdfname.js"; }; }; - var utf8EscapeFunction = function(parms) { + var utf8EscapeFunction = function (parms: TextProcessingPayload) { var text = parms.text || "", x = parms.x, y = parms.y, options = parms.options, mutex = parms.mutex; - var tmpText = []; + var tmpText: TextEntry[] = []; var args = { text: text, x: x, @@ -344,21 +372,25 @@ import { toPDFName } from "../libs/pdfname.js"; var i = 0; for (i = 0; i < text.length; i += 1) { if (Array.isArray(text[i])) { - if (text[i].length === 3) { + // CFA cannot narrow text[i] (variable index), hence the assertions. + var entryArray = text[i] as Array; + if (entryArray.length === 3) { tmpText.push([ - utf8TextFunction(Object.assign({}, args, { text: text[i][0] })) - .text, - text[i][1], - text[i][2] + utf8TextFunction(Object.assign({}, args, { text: entryArray[0] })) + .text as string, + entryArray[1], + entryArray[2] ]); } else { tmpText.push( - utf8TextFunction(Object.assign({}, args, { text: text[i] })).text + utf8TextFunction(Object.assign({}, args, { text: text[i] })) + .text as string ); } } else { tmpText.push( - utf8TextFunction(Object.assign({}, args, { text: text[i] })).text + utf8TextFunction(Object.assign({}, args, { text: text[i] })) + .text as string ); } } diff --git a/src/modules/vfs.ts b/src/modules/vfs.ts index f31c55695..21efbdd8f 100644 --- a/src/modules/vfs.ts +++ b/src/modules/vfs.ts @@ -7,6 +7,18 @@ */ import { jsPDF } from "../jspdf.js"; +import type { jsPDFAPI as JsPDFAPI, jsPDFDocument } from "../types.js"; + +declare module "../types.js" { + interface jsPDFAPI { + existsFileInVFS(filename: string): boolean; + addFileToVFS(filename: string, filecontent: string): jsPDFDocument; + getFileFromVFS(filename: string): string | null; + } + interface jsPDFInternal { + vFS?: Record; + } +} /** * Use the vFS to handle files @@ -14,10 +26,10 @@ import { jsPDF } from "../jspdf.js"; * @name vFS * @module */ -(function(jsPDFAPI) { +(function (jsPDFAPI: JsPDFAPI) { "use strict"; - var _initializeVFS = function() { + var _initializeVFS = function (this: jsPDFDocument) { if (typeof this.internal.vFS === "undefined") { this.internal.vFS = {}; } @@ -34,7 +46,7 @@ import { jsPDF } from "../jspdf.js"; * @example * doc.existsFileInVFS("someFile.txt"); */ - jsPDFAPI.existsFileInVFS = function(filename) { + jsPDFAPI.existsFileInVFS = function (this: jsPDFDocument, filename: string) { _initializeVFS.call(this); return typeof this.internal.vFS[filename] !== "undefined"; }; @@ -50,7 +62,11 @@ import { jsPDF } from "../jspdf.js"; * @example * doc.addFileToVFS("someFile.txt", "BADFACE1"); */ - jsPDFAPI.addFileToVFS = function(filename, filecontent) { + jsPDFAPI.addFileToVFS = function ( + this: jsPDFDocument, + filename: string, + filecontent: string + ) { _initializeVFS.call(this); this.internal.vFS[filename] = filecontent; return this; @@ -66,7 +82,7 @@ import { jsPDF } from "../jspdf.js"; * @example * doc.getFileFromVFS("someFile.txt"); */ - jsPDFAPI.getFileFromVFS = function(filename) { + jsPDFAPI.getFileFromVFS = function (this: jsPDFDocument, filename: string) { _initializeVFS.call(this); if (typeof this.internal.vFS[filename] !== "undefined") { diff --git a/src/modules/viewerpreferences.ts b/src/modules/viewerpreferences.ts index f030b3068..d5f690008 100644 --- a/src/modules/viewerpreferences.ts +++ b/src/modules/viewerpreferences.ts @@ -7,6 +7,44 @@ */ import { jsPDF } from "../jspdf.js"; +import type { jsPDFAPI as JsPDFAPI, jsPDFDocument } from "../types.js"; + +/** Value a viewer preference can hold once normalized into the configuration. */ +type ViewerPreferenceValue = boolean | string | number; + +interface ViewerPreferenceEntry { + defaultValue: ViewerPreferenceValue; + value: ViewerPreferenceValue; + type: "boolean" | "name" | "array" | "integer"; + explicitSet: boolean; + valueSet: Array | null; + pdfVersion: number; +} + +type ViewerPreferencesConfiguration = Record; + +interface ViewerPreferencesState { + configuration?: ViewerPreferencesConfiguration; + isSubscribed?: boolean; +} + +/** Options accepted by viewerPreferences(); see the JSDoc below for the keys. */ +export type ViewerPreferencesInput = Record< + string, + boolean | string | number | number[][] | undefined +>; + +declare module "../types.js" { + interface jsPDFAPI { + viewerPreferences( + options?: ViewerPreferencesInput | "reset", + doReset?: boolean + ): jsPDFDocument; + } + interface jsPDFInternal { + viewerpreferences?: ViewerPreferencesState; + } +} /** * Adds the ability to set ViewerPreferences and by thus @@ -15,7 +53,7 @@ import { jsPDF } from "../jspdf.js"; * @name viewerpreferences * @module */ -(function(jsPDFAPI) { +(function (jsPDFAPI: JsPDFAPI) { "use strict"; /** * Set the ViewerPreferences of the generated PDF @@ -106,12 +144,16 @@ import { jsPDF } from "../jspdf.js"; * 'NumCopies': 10 * }) */ - jsPDFAPI.viewerPreferences = function(options, doReset) { + jsPDFAPI.viewerPreferences = function ( + this: jsPDFDocument, + options?: ViewerPreferencesInput | "reset", + doReset?: boolean + ) { options = options || {}; doReset = doReset || false; - var configuration; - var configurationTemplate = { + var configuration: ViewerPreferencesConfiguration; + var configurationTemplate: ViewerPreferencesConfiguration = { HideToolbar: { defaultValue: false, value: false, @@ -257,17 +299,20 @@ import { jsPDF } from "../jspdf.js"; var configurationKeys = Object.keys(configurationTemplate); - var rangeArray = []; + var rangeArray: string[] = []; var i = 0; var j = 0; var k = 0; - var isValid; + var isValid: boolean; - var method; - var value; + var method: string; + var value: boolean | string | number | number[][] | undefined; - function arrayContainsElement(array, element) { - var iterator; + function arrayContainsElement( + array: ArrayLike | null, + element: unknown + ): boolean { + var iterator: number; var result = false; for (iterator = 0; iterator < array.length; iterator += 1) { @@ -313,25 +358,32 @@ import { jsPDF } from "../jspdf.js"; configuration[method].type === "name" && arrayContainsElement(configuration[method].valueSet, value) ) { - configuration[method].value = value; + // Membership in valueSet (checked above) guarantees a name string. + configuration[method].value = value as string; } else if ( configuration[method].type === "integer" && Number.isInteger(value) ) { - configuration[method].value = value; + // Number.isInteger() does not narrow; it guarantees a number here. + configuration[method].value = value as number; } else if (configuration[method].type === "array") { - for (i = 0; i < value.length; i += 1) { + // A PrintPageRange option is documented as an array of ranges, + // e.g. [[1, 5], [7, 9]]; the assertion names that shape. + var range = value as number[][]; + for (i = 0; i < range.length; i += 1) { isValid = true; - if (value[i].length === 1 && typeof value[i][0] === "number") { - rangeArray.push(String(value[i] - 1)); - } else if (value[i].length > 1) { - for (j = 0; j < value[i].length; j += 1) { - if (typeof value[i][j] !== "number") { + if (range[i].length === 1 && typeof range[i][0] === "number") { + // Preserved verbatim: subtracting from the one-element array + // relies on JS coercion ([n] - 1 === n - 1). + rangeArray.push(String((range[i] as unknown as number) - 1)); + } else if (range[i].length > 1) { + for (j = 0; j < range[i].length; j += 1) { + if (typeof range[i][j] !== "number") { isValid = false; } } if (isValid === true) { - rangeArray.push([value[i][0] - 1, value[i][1] - 1].join(" ")); + rangeArray.push([range[i][0] - 1, range[i][1] - 1].join(" ")); } } } @@ -346,24 +398,27 @@ import { jsPDF } from "../jspdf.js"; } if (this.internal.viewerpreferences.isSubscribed === false) { - this.internal.events.subscribe("putCatalog", function() { - var pdfDict = []; - var vPref; - for (vPref in configuration) { - if (configuration[vPref].explicitSet === true) { - if (configuration[vPref].type === "name") { - pdfDict.push("/" + vPref + " /" + configuration[vPref].value); - } else { - pdfDict.push("/" + vPref + " " + configuration[vPref].value); + this.internal.events.subscribe( + "putCatalog", + function (this: jsPDFDocument) { + var pdfDict: string[] = []; + var vPref: string; + for (vPref in configuration) { + if (configuration[vPref].explicitSet === true) { + if (configuration[vPref].type === "name") { + pdfDict.push("/" + vPref + " /" + configuration[vPref].value); + } else { + pdfDict.push("/" + vPref + " " + configuration[vPref].value); + } } } + if (pdfDict.length !== 0) { + this.internal.write( + "/ViewerPreferences\n<<\n" + pdfDict.join("\n") + "\n>>" + ); + } } - if (pdfDict.length !== 0) { - this.internal.write( - "/ViewerPreferences\n<<\n" + pdfDict.join("\n") + "\n>>" - ); - } - }); + ); this.internal.viewerpreferences.isSubscribed = true; } diff --git a/src/modules/webp_support.ts b/src/modules/webp_support.ts index 492f0e281..4bd8fb17a 100644 --- a/src/modules/webp_support.ts +++ b/src/modules/webp_support.ts @@ -9,6 +9,34 @@ import { jsPDF } from "../jspdf.js"; import { JPEGEncoder } from "../libs/JPEGEncoder.js"; import { WebPDecoder } from "../libs/WebPDecoder.js"; +import type { jsPDFAPI as JsPDFAPI, jsPDFDocument } from "../types.js"; +import type { ImageCompression, ImageProperties } from "./addimage.js"; + +declare module "../types.js" { + interface jsPDFAPI { + processWEBP( + imageData?: unknown, + index?: number, + alias?: number | string, + compression?: ImageCompression + ): ImageProperties; + } +} + +/** + * Boundary interface for the vendored WebP decoder + * (src/libs/WebPDecoder.ts, checked with @ts-nocheck); declares only the + * members this plugin consumes. + */ +interface WebPDecoderInstance { + width: number; + height: number; + getData(): ArrayLike; +} + +interface WebPDecoderConstructor { + new (imageData: Uint8Array, hasAlpha: boolean): WebPDecoderInstance; +} /** * jsPDF webp Support PlugIn @@ -16,11 +44,22 @@ import { WebPDecoder } from "../libs/WebPDecoder.js"; * @name webp_support * @module */ -(function(jsPDFAPI) { +(function (jsPDFAPI: JsPDFAPI) { "use strict"; - jsPDFAPI.processWEBP = function(imageData, index, alias, compression) { - var reader = new (WebPDecoder as any)(imageData, false); + jsPDFAPI.processWEBP = function ( + this: jsPDFDocument, + imageData: Uint8Array, + index?: number, + alias?: number | string, + compression?: ImageCompression + ) { + // The vendored decoder is an untyped constructor function; go through + // the local boundary interface instead of `any`. + var reader = new (WebPDecoder as unknown as WebPDecoderConstructor)( + imageData, + false + ); var width = reader.width, height = reader.height; var qu = 100; diff --git a/src/modules/xmp_metadata.ts b/src/modules/xmp_metadata.ts index 3870c9613..e43002f82 100644 --- a/src/modules/xmp_metadata.ts +++ b/src/modules/xmp_metadata.ts @@ -25,13 +25,34 @@ */ import { jsPDF } from "../jspdf.js"; +import type { jsPDFDocument } from "../types.js"; -function postPutResources() { +interface XMPMetadataState { + metadata: string; + namespaceUri: string | boolean; + rawXml: boolean; + /** Assigned while the metadata stream object is written. */ + metadataObjectNumber?: number; +} + +declare module "../types.js" { + interface jsPDFAPI { + addMetadata( + metadata: string, + rawXmlOrNamespaceUri?: string | boolean + ): jsPDFDocument; + } + interface jsPDFInternal { + __metadata__?: XMPMetadataState; + } +} + +function postPutResources(this: jsPDFDocument) { const metadata = this.internal.__metadata__.metadata; const utf8Metadata = unescape(encodeURIComponent(metadata)); const rawXml = this.internal.__metadata__.rawXml; - let content; + let content: string; if (rawXml) { content = utf8Metadata; } else { @@ -61,7 +82,7 @@ function postPutResources() { this.internal.write("endobj"); } -function putCatalog() { +function putCatalog(this: jsPDFDocument) { if (this.internal.__metadata__.metadataObjectNumber) { this.internal.write( "/Metadata " + this.internal.__metadata__.metadataObjectNumber + " 0 R" @@ -69,7 +90,7 @@ function putCatalog() { } } -function escapeXml(str) { +function escapeXml(str: string): string { return str .replace(/&/g, "&") .replace(/; + * } + * } + * ``` + * + * This mechanism was verified to compile under the repository tsconfig + * (moduleResolution "bundler", verbatimModuleSyntax, erasableSyntaxOnly). + * Because `jsPDFDocument` extends `jsPDFAPI`, methods merged into + * `jsPDFAPI` automatically show up on typed document instances. + */ + +// --------------------------------------------------------------------------- +// Constructor options +// --------------------------------------------------------------------------- + +export type Orientation = "p" | "portrait" | "l" | "landscape"; + +/** Measurement unit accepted by the constructor. A bare number is used as a custom scale factor. */ +export type Unit = "pt" | "px" | "in" | "mm" | "cm" | "ex" | "em" | "pc"; + +/** A named page format (e.g. "a4") or explicit `[width, height]` in unit-space. */ +export type PageFormat = string | number[]; + +/** Map of named page formats to `[width, height]` in points (see `pageFormats` in src/jspdf.ts). */ +export type PageFormats = Record; + +export type UserPermission = "print" | "modify" | "copy" | "annot-forms"; + +export interface EncryptionOptions { + userPassword?: string; + ownerPassword?: string; + userPermissions?: UserPermission[]; +} + +export interface jsPDFOptions { + orientation?: Orientation; + unit?: Unit | number; + format?: PageFormat; + compress?: boolean; + /** Alias of `compress` kept for backwards compatibility (see the constructor in src/jspdf.ts). */ + compressPdf?: boolean; + precision?: number; + filters?: string[]; + userUnit?: number; + encryption?: EncryptionOptions; + putOnlyUsedFonts?: boolean; + hotfixes?: string[]; + floatPrecision?: number | "smart"; + /** Default path painting operator, e.g. "S" (stroke). */ + defaultPathOperation?: string; + + // Undocumented options honored by the constructor in src/jspdf.ts. + /** Initial font size in points (default 16). */ + fontSize?: number; + /** Initial right-to-left mode (default false). */ + R2L?: boolean; + /** Initial line width in unit-space (default 0.200025). */ + lineWidth?: number; + /** Initial stroke color as an encoded PDF color string (default "0 G"). */ + strokeColor?: string; + /** Initial fill color as an encoded PDF color string (default "0 g"). */ + fillColor?: string; + /** Initial text color as an encoded PDF color string (default "0 g"). */ + textColor?: string; + /** Initial character spacing. */ + charSpace?: number; + /** Initial line height factor (default 1.15). */ + lineHeight?: number; +} + +export interface DocumentProperties { + title?: string; + subject?: string; + author?: string; + keywords?: string; + creator?: string; +} + +// --------------------------------------------------------------------------- +// PubSub +// --------------------------------------------------------------------------- + +/** + * Callback stored in the event system. Parameters are declared as `never[]` + * so that every concrete handler signature is assignable to this type + * (function parameters are contravariant); the payload of each topic is + * dynamic and owned by the publisher. + */ +export type PubSubCallback = (...args: never[]) => unknown; + +/** + * Topics published by the jsPDF core (plugins may publish additional ones). + * Kept as documentation and for autocomplete; the PubSub methods accept + * arbitrary strings since plugins define their own topics. + */ +export type KnownPubSubTopic = + | "addFont" + | "addFonts" + | "addFormObject" + | "addGState" + | "addPage" + | "addPattern" + | "buildDocument" + | "deletePage" + | "endTilingPattern" + | "initialized" + | "postProcessText" + | "postPutAdditionalObjects" + | "postPutPages" + | "postPutResources" + | "preProcessText" + | "putAdditionalObjects" + | "putCatalog" + | "putFont" + | "putGStateDict" + | "putPage" + | "putResources" + | "putShadingPatternDict" + | "putTilingPatternDict" + | "putXobjectDict"; + +/** topic -> token -> [callback, runOnce] */ +export type PubSubTopics = Record< + string, + Record +>; + +export interface PubSubInterface { + subscribe(topic: string, callback: PubSubCallback, once?: boolean): string; + unsubscribe(token: string): boolean; + publish(topic: string, ...args: unknown[]): void; + getTopics(): PubSubTopics; +} + +// --------------------------------------------------------------------------- +// Geometry: Point, Rectangle, Matrix +// --------------------------------------------------------------------------- + +export interface PointType { + x: number; + y: number; + /** "pt" for points, "rect" for rectangles (see `Point`/`Rectangle` in src/jspdf.ts). */ + type?: string; +} + +export interface RectangleType extends PointType { + w: number; + h: number; +} + +/** Constructor exposed as `internal.Point` (an ES class; requires `new`). */ +export interface PointConstructor { + new (x?: number, y?: number): PointType; +} + +/** Constructor exposed as `internal.Rectangle` (an ES class; requires `new`). */ +export interface RectangleConstructor { + new (x?: number, y?: number, w?: number, h?: number): RectangleType; +} + +/** The plain numeric fields of a matrix, without its methods. */ +export interface MatrixLike { + sx: number; + shy: number; + shx: number; + sy: number; + tx: number; + ty: number; +} + +/** + * A matrix for 2D homogeneous transformations, as produced by + * `doc.Matrix(...)` / `internal.Matrix`. `a`-`f` alias `sx`-`ty`. + */ +export interface Matrix extends MatrixLike { + a: number; + b: number; + c: number; + d: number; + e: number; + f: number; + + readonly rotation: number; + readonly scaleX: number; + readonly scaleY: number; + readonly isIdentity: boolean; + + join(separator?: string): string; + multiply(matrix: Matrix): Matrix; + decompose(): { + scale: Matrix; + translate: Matrix; + rotate: Matrix; + skew: Matrix; + }; + toString(precision?: number): string; + inversed(): Matrix; + applyToPoint(pt: PointType): PointType; + applyToRectangle(rect: RectangleType): RectangleType; + clone(): Matrix; +} + +/** Constructor exposed as `doc.Matrix` / `internal.Matrix` (an ES class; requires `new`). */ +export interface MatrixConstructor { + new ( + sx?: number, + shy?: number, + shx?: number, + sy?: number, + tx?: number, + ty?: number + ): Matrix; +} + +// --------------------------------------------------------------------------- +// Graphics state and patterns +// --------------------------------------------------------------------------- + +export interface GStateOptions { + opacity?: number; + "stroke-opacity"?: number; +} + +export interface GState extends GStateOptions { + /** Set by addGState(). */ + id: string; + /** Set by putGState(); -1 until then. */ + objectNumber: number; + equals(other: GState): boolean; +} + +/** Constructor exposed as `doc.GState` (an ES class; requires `new`). */ +export interface GStateConstructor { + new (parameters?: GStateOptions): GState; +} + +export interface Pattern { + gState?: GState; + matrix?: Matrix; + /** Set by addPattern(). */ + id: string; + /** Set by putPattern(); -1 until then. */ + objectNumber: number; +} + +export type ShadingPatternType = "axial" | "radial"; + +export interface ShadingPatternStop { + offset: number; + color: number[]; +} + +export interface ShadingPatternObject extends Pattern { + /** 2 for axial, 3 for radial (numeric PDF shading type, set from the "axial"/"radial" constructor argument). */ + type: 2 | 3; + coords: number[]; + colors: ShadingPatternStop[]; +} + +export interface TilingPatternObject extends Pattern { + boundingBox: number[]; + xStep: number; + yStep: number; + /** Set by endTilingPattern(). */ + stream: string; + cloneIndex: number; +} + +/** Constructor exposed as `doc.ShadingPattern` (an ES class; requires `new`). */ +export interface ShadingPatternConstructor { + new ( + type: ShadingPatternType, + coords: number[], + colors: ShadingPatternStop[], + gState?: GState, + matrix?: Matrix + ): ShadingPatternObject; +} + +/** Constructor exposed as `doc.TilingPattern` (an ES class; requires `new`). */ +export interface TilingPatternConstructor { + new ( + boundingBox: number[], + xStep: number, + yStep: number, + gState?: GState, + matrix?: Matrix + ): TilingPatternObject; +} + +// --------------------------------------------------------------------------- +// Fonts +// --------------------------------------------------------------------------- + +/** + * Populated dynamically by font plugins (standard_fonts_metrics, ttfsupport, + * utf8): metric tables, glyph data, unicode maps etc. The concrete shape + * depends on which plugin owns the font, hence the `unknown` values. + */ +export type FontMetadata = Record; + +export interface Font { + /** Font key, e.g. "F1" (note: a string, unlike the numeric `id` in types/index.d.ts). */ + id: string; + postScriptName: string; + fontName: string; + fontStyle: string; + encoding: string; + isStandardFont: boolean; + metadata: FontMetadata; + /** Assigned while the font dictionary is written (putFont); absent before. */ + objectNumber?: number; +} + +/** Collection of font objects keyed by font key ("F1", "F2", ...). */ +export type FontMap = Record; + +/** fontName -> fontStyle -> font key. */ +export type FontDictionary = Record>; + +// --------------------------------------------------------------------------- +// Static side of the jsPDF constructor +// --------------------------------------------------------------------------- + +/** + * The static surface of the `jsPDF` function/class as modules see it + * (src/jspdf.ts assigns `jsPDF.API` and `jsPDF.version` as expando statics). + * Useful for typing plugin IIFE parameters that receive the class itself. + */ +export interface jsPDFConstructor { + /** + * src/jspdf.ts declares jsPDF as a classic constructor *function*, so its + * inferred type carries a call signature rather than a construct signature; + * a `new` signature here would make the real value unassignable. + */ + (options?: jsPDFOptions): jsPDFDocument; + API: jsPDFAPI; + version: string; +} + +// --------------------------------------------------------------------------- +// TTF font boundary (vendored src/libs/ttffont.ts, which is @ts-nocheck) +// --------------------------------------------------------------------------- + +/** + * Boundary interface for the vendored TTF font library + * (`src/libs/ttffont.ts`, compiled CoffeeScript, checked with @ts-nocheck). + * Only the members actually consumed by the plugin modules are declared; + * everything else is reachable through the index signature as `unknown`. + */ +export interface TTFFontUnicodeTable { + encoding: Record; + kerning: Record; + /** Interleaved glyph-id / width-array entries as written by pdfEscape16. */ + widths: Array; +} + +export interface TTFFontInstance { + rawData: Uint8Array; + Unicode: TTFFontUnicodeTable; + glyIdsUsed: Array; + toUnicode: Record; + /** Returns the glyph id for a character code (0 when unmapped). */ + characterToGlyph(code: number): number | string; + /** + * Glyph advance width. Declared as string because every consumer feeds the + * result straight into parseInt(), which coerces; the vendored library is + * unchecked so the runtime value may be a number. + */ + widthOfGlyph(glyph: number | string): string; + subset: { + encode(glyphIds: Array, one?: number): ArrayLike; + }; + bbox: unknown; + flags: number; + stemV: number; + italicAngle: number; + ascender: number; + decender: number; + capHeight: number; + hmtx: { widths: number[] }; + head: { unitsPerEm: number }; + cmap?: { unicode: { codeMap: Record } }; + [member: string]: unknown; +} + +/** Static surface of `jsPDF.API.TTFFont` (installed by src/libs/ttffont.ts). */ +export interface TTFFontConstructor { + new (rawData: Uint8Array): TTFFontInstance; + open(file: Uint8Array): TTFFontInstance; +} + +// --------------------------------------------------------------------------- +// Core event payloads consumed by plugins +// --------------------------------------------------------------------------- + +/** + * One entry of a text argument once the core/plugins are done reshaping it: + * a string, a character code, or an array mixing text with per-line + * coordinates (e.g. `[text, x, y]`). + */ +export type TextEntry = string | number | Array; + +/** `mutex` member of the pre/postProcessText payloads (see src/jspdf.ts). */ +export interface TextProcessingMutex { + /** The core's internal pdfEscape; some plugins pass a font key as second argument. */ + pdfEscape(text: string, flags?: unknown): string; + activeFontKey: string; + fonts: FontMap; + activeFontSize: number; + /** Set by encoding plugins when `text` has been converted to hex. */ + isHex?: boolean; +} + +/** Payload published with the "preProcessText"/"postProcessText" topics. */ +export interface TextProcessingPayload { + text: TextEntry | TextEntry[]; + x: number; + y: number; + options: TextOptionsLight; + mutex: TextProcessingMutex; +} + +/** Payload published with the "putFont" topic (see putFont in src/jspdf.ts). */ +export interface PutFontPayload { + font: Font; + out: (...data: Array) => string[]; + newObject: () => number; + putStream: (options?: PutStreamOptions) => void; +} + +/** Payload published with the "addFont" topic (see addFont in src/jspdf.ts). */ +export interface AddFontPayload { + font: Font; + instance?: jsPDFDocument; +} + +/** Payload published with the "putPage" topic (see putPage in src/jspdf.ts). */ +export interface PutPagePayload { + objId: number; + pageContext: PageContext; + pageNumber: number; + /** The page's content stream lines. */ + page: string[]; +} + +/** Payload published with the "addPage" topic (see _addPage in src/jspdf.ts). */ +export interface AddPagePayload { + pageNumber: number; +} + +// --------------------------------------------------------------------------- +// Pages +// --------------------------------------------------------------------------- + +export interface PageBox { + bottomLeftX: number; + bottomLeftY: number; + topRightX: number; + topRightY: number; +} + +/** + * Per-page context created by beginPage() in src/jspdf.ts. Plugins may + * attach additional state (e.g. the annotations plugin adds `annotations`); + * such members should be merged in via module augmentation. + */ +export interface PageContext { + objId: number; + contentsObjId: number; + userUnit: number; + mediaBox: PageBox; + artBox: PageBox | null; + bleedBox: PageBox | null; + cropBox: PageBox | null; + trimBox: PageBox | null; + /** Last text rendering mode written for this page (see `text()` in src/jspdf.ts). */ + usedRenderingMode?: number; +} + +export interface PageInfo { + objId: number; + pageNumber: number; + pageContext: PageContext; +} + +/** Deferred object handle returned by `internal.newAdditionalObject()`. */ +export interface AdditionalObject { + objId: number; + content: string; +} + +export interface PageSize { + width: number; + height: number; + getWidth(): number; + setWidth(value: number): void; + getHeight(): number; + setHeight(value: number): void; +} + +// --------------------------------------------------------------------------- +// Output +// --------------------------------------------------------------------------- + +export type OutputType = + | "save" + | "arraybuffer" + | "blob" + | "bloburi" + | "bloburl" + | "datauristring" + | "dataurlstring" + | "pdfobjectnewwindow" + | "pdfjsnewwindow" + | "dataurlnewwindow" + | "datauri" + | "dataurl"; + +export interface OutputOptions { + filename?: string; + /** Only used by "pdfobjectnewwindow". */ + pdfObjectUrl?: string; + /** Only used by "pdfjsnewwindow". */ + pdfJsUrl?: string; + /** + * "pdfobjectnewwindow" forwards the whole options object to PDFObject.embed, + * so arbitrary additional options are allowed and passed through. + */ + [option: string]: unknown; +} + +// --------------------------------------------------------------------------- +// Streams and encryption +// --------------------------------------------------------------------------- + +export interface PutStreamOptions { + data?: string; + filters?: string[] | true; + alreadyAppliedFilters?: string[] | string; + addLength1?: boolean; + /** Required when the document is encrypted. */ + objectId?: number; + additionalKeyValues?: Array<{ key: string; value: string | number }>; +} + +/** A function encrypting stream data for a specific object id. */ +export type Encryptor = (data: string) => string; + +/** Result shape of `jsPDF.API.processDataByFilters` (filters plugin). */ +export interface ProcessedData { + data: string; + /** Space-joined chain of decode filter names, e.g. "/FlateDecode". */ + reverseChain: string; +} + +/** + * Surface of the PDFSecurity helper (`src/libs/pdfsecurity.ts`) that the + * core relies on, matching the class members declared there. + */ +export interface PDFSecurityInterface { + encryptor(objectId: number, generation: number): Encryptor; + /** Encryption algorithm version. */ + v: number; + /** Encryption revision. */ + r: number; + padding: string; + O: string; + U: string; + P: number; + encryptionKey: string; + /** Object id of the encryption dictionary; attached by putEncryptionDict in src/jspdf.ts. */ + oid?: number; + toHexString(byteString: string): string; +} + +// --------------------------------------------------------------------------- +// internal API (doc.internal) — the surface plugins consume +// --------------------------------------------------------------------------- + +/** + * The `internal` object assigned in src/jspdf.ts (`API.internal = { ... }`). + * Every member below was verified against that assignment. Plugins that + * stash their own state on `internal` (e.g. `__cell__`, `acroformPlugin`, + * `vFS`, `viewerpreferences`, `__metadata__`, `languageSettings`) must add + * those members via module augmentation of this interface (see the header + * comment). + */ +export interface jsPDFInternal { + pdfEscape( + text: string, + flags?: { autoencode?: boolean; noBOM?: boolean } + ): string; + getStyle(style: string): string; + /** Resolves a font entry; without arguments returns the active font. */ + getFont( + fontName?: string, + fontStyle?: string, + options?: { disableWarning?: boolean } + ): Font; + getFontSize(): number; + getCharSpace(): number; + getTextColor(): string; + getLineHeight(): number; + getLineHeightFactor(): number; + getLineWidth(): number; + /** Appends one or more strings (joined by spaces) to the current page stream. */ + write(value: string | number, ...rest: Array): string[]; + getHorizontalCoordinate(value: number): number; + getVerticalCoordinate(value: number): number; + /** Returns the scaled horizontal coordinate formatted as a PDF number string. */ + getCoordinateString(value: number): string; + /** Returns the scaled, flipped vertical coordinate formatted as a PDF number string. */ + getVerticalCoordinateString(value: number): string; + /** + * Scratch space shared between plugins; each plugin owns the entries it + * creates (e.g. the addimage plugin stores its image dictionary here), + * so values are opaque to the core. + */ + collections: Record; + newObject(): number; + newAdditionalObject(): AdditionalObject; + newObjectDeferred(): number; + newObjectDeferredBegin(oid: number, doOutput?: boolean): number; + getFilters(): string[]; + putStream(options?: PutStreamOptions): void; + events: PubSubInterface; + scaleFactor: number; + pageSize: PageSize; + encryptionOptions: EncryptionOptions | null; + encryption: PDFSecurityInterface | null; + getEncryptor(objectId: number): Encryptor; + output( + type?: OutputType, + options?: OutputOptions | string + ): string | ArrayBuffer | Blob | Window | null | undefined; + getNumberOfPages(): number; + /** Page content streams; index 0 is unused, page n lives at index n. */ + readonly pages: string[][]; + /** Appends a single line to the current output destination and returns it. */ + out(data: string | number): string[]; + /** Formats a number with two decimals. */ + f2(value: number): string; + /** Formats a number with three decimals. */ + f3(value: number): string; + getPageInfo(pageNumberOneBased: number): PageInfo; + getPageInfoByObjId(objId: number): PageInfo; + getCurrentPageInfo(): PageInfo; + getPDFVersion(): string; + Point: PointConstructor; + Rectangle: RectangleConstructor; + Matrix: MatrixConstructor; + hasHotfix(hotfixName: string): boolean; +} + +/** + * The `__private__` helper surface (`jsPDF.API.__private__`, copied onto every + * document instance). It exists for tests and internal plugin use; only the + * members consumed by typed plugin modules are declared, everything else is + * reachable through the index signature. + */ +export interface jsPDFPrivate { + encodeColorString( + options: + | string + | number[] + | { + ch1: string | number; + ch2?: string | number; + ch3?: string | number; + /** An `{ a: alpha }` descriptor is accepted as the fourth channel (RGBA). */ + ch4?: string | number | { a: number }; + pdfColorType?: "draw" | "fill" | "text"; + precision?: number; + } + ): string; + /** Redirects PDF stream writes into `destination` (used by specs to capture output). */ + setCustomOutputDestination(destination: string[]): void; + /** Restores the default output destination after setCustomOutputDestination. */ + resetCustomOutputDestination(): void; + /** Sets the /ID of the document; used by specs for deterministic output. */ + setFileId(value?: string): string; + /** Sets the creation date; used by specs for deterministic output. */ + setCreationDate(date?: Date | string): string; + /** Resolves a CSS-style fontStyle/fontWeight pair to a jsPDF style name. */ + combineFontStyleAndFontWeight( + fontStyle?: string, + fontWeight?: string | number + ): string; + [member: string]: unknown; +} + +// --------------------------------------------------------------------------- +// Plugin surface (jsPDF.API) +// --------------------------------------------------------------------------- + +/** + * An entry of `jsPDF.API.events`: `[topic, handler]` or + * `[topic, [handler, runOnce]]` (see the plugin wiring loop in src/jspdf.ts). + */ +export type jsPDFAPIEvent = [ + string, + PubSubCallback | [PubSubCallback, boolean] +]; + +/** + * The static plugin surface (`jsPDF.API`). Its members are copied onto every + * new document instance, so `jsPDFDocument` extends this interface. + * + * Deliberately has NO index signature: plugin modules declare the methods + * they add through module augmentation (see the header comment), keeping the + * whole surface strictly typed. Only the members the core itself relies on + * are declared here. + */ +export interface jsPDFAPI { + /** Event subscriptions registered by plugins; wired into every new instance's PubSub. */ + events: jsPDFAPIEvent[]; + /** + * Installed by the filters plugin (src/modules/filters.ts) and consumed by + * the core's putStream. Optional because the core guards for its presence. + */ + processDataByFilters?( + origData?: string, + filterChain?: string | string[] | true + ): ProcessedData; + /** + * Core alias pair installed directly on `jsPDF.API` by src/jspdf.ts + * (setLineDash is the legacy name of setLineDashPattern). Optional because + * they are attached during core initialization. + */ + setLineDash?(dashArray?: number[], dashPhase?: number): jsPDFDocument; + setLineDashPattern?(dashArray?: number[], dashPhase?: number): jsPDFDocument; +} + +// --------------------------------------------------------------------------- +// Document instance +// --------------------------------------------------------------------------- + +/** + * The public surface of a jsPDF document instance as constructed in + * src/jspdf.ts (core only; plugin methods arrive through `jsPDFAPI` + * augmentation). Adapted from types/index.d.ts and corrected against the + * implementation where the two disagreed. + */ +export interface jsPDFDocument extends jsPDFAPI { + version: string; + CapJoinStyles: Record; + internal: jsPDFInternal; + /** Test/plugin backdoor surface (see src/jspdf.ts `API.__private__`). */ + __private__: jsPDFPrivate; + /** Computes the width of a string in font units (see `getStringUnitWidth` in src/jspdf.ts). */ + getStringUnitWidth( + text: string, + options?: { + font?: Font; + fontSize?: number; + charSpace?: number; + doKerning?: boolean; + } + ): number; + /** Rounds a number to the given (or configured) precision (see src/jspdf.ts). */ + roundToPrecision(number: number, parmPrecision?: number): string; + /** Sets the global coordinate precision. */ + setPrecision(value: string): void; + /** Sets the default path painting operator (see `getStyle`). */ + setDefaultPathOperation(operator: string): jsPDFDocument; + /** Inserts a debug comment into the generated pdf. */ + comment(text: string): jsPDFDocument; + /** Alias of `unitMatrix`. */ + identityMatrix: Matrix; + + compatAPI(body?: (pdf: jsPDFDocument) => void): jsPDFDocument; + advancedAPI(body?: (pdf: jsPDFDocument) => void): jsPDFDocument; + isAdvancedAPI(): boolean; + + addFont( + postScriptName: string, + id: string, + fontStyle: string, + fontWeight?: string | number, + encoding?: + | "StandardEncoding" + | "MacRomanEncoding" + | "Identity-H" + | "WinAnsiEncoding", + isStandardFont?: boolean + ): string; + addFont( + url: URL, + id: string, + fontStyle: string, + fontWeight?: string | number, + encoding?: + "StandardEncoding" | "MacRomanEncoding" | "Identity-H" | "WinAnsiEncoding" + ): string; + addGState(key: string, gState: GState): jsPDFDocument; + addPage(format?: PageFormat, orientation?: Orientation): jsPDFDocument; + beginFormObject( + x: number, + y: number, + width: number, + height: number, + matrix: Matrix + ): jsPDFDocument; + circle(x: number, y: number, r: number, style?: string | null): jsPDFDocument; + clip(rule?: "evenodd"): jsPDFDocument; + clipEvenOdd(): jsPDFDocument; + close(): jsPDFDocument; + curveTo( + x1: number, + y1: number, + x2: number, + y2: number, + x3: number, + y3: number + ): jsPDFDocument; + deletePage(targetPage: number): jsPDFDocument; + discardPath(): jsPDFDocument; + doFormObject(key: string, matrix: Matrix): jsPDFDocument; + ellipse( + x: number, + y: number, + rx: number, + ry: number, + style?: string | null + ): jsPDFDocument; + endFormObject(key: string): jsPDFDocument; + f2(value: number): string; + fill(pattern?: PatternData): jsPDFDocument; + fillEvenOdd(pattern?: PatternData): jsPDFDocument; + fillStroke(pattern?: PatternData): jsPDFDocument; + fillStrokeEvenOdd(pattern?: PatternData): jsPDFDocument; + getCharSpace(): number; + getCreationDate(type: "jsDate"): Date; + getCreationDate(type?: string): Date | string; + getCurrentPageInfo(): PageInfo; + getDrawColor(): string; + getFileId(): string; + getFillColor(): string; + getFont(fontName?: string, fontStyle?: string): Font; + getFontList(): Record; + getFontSize(): number; + getFormObject(key: string): unknown; + getHorizontalCoordinateString(value: number): string; + getLineHeight(): number; + getLineHeightFactor(): number; + getLineWidth(): number; + getNumberOfPages(): number; + getPageInfo(pageNumberOneBased: number): PageInfo; + getPageWidth(pageNumber?: number): number; + getPageHeight(pageNumber?: number): number; + getR2L(): boolean; + getStyle(style: string): string; + getTextColor(): string; + getVerticalCoordinateString(value: number): string; + hpf(value: number): string; + insertPage(beforePage: number): jsPDFDocument; + line( + x1: number, + y1: number, + x2: number, + y2: number, + style?: string | null + ): jsPDFDocument; + lines( + lines: Array, + x: number, + y: number, + scale?: [number, number] | number[], + style?: string | null, + closed?: boolean + ): jsPDFDocument; + lineTo(x: number, y: number): jsPDFDocument; + movePage(targetPage: number, beforePage: number): jsPDFDocument; + moveTo(x: number, y: number): jsPDFDocument; + output(): string; + output(type: "arraybuffer"): ArrayBuffer; + output(type: "blob"): Blob; + output(type: "bloburi" | "bloburl"): string | undefined; + output( + type: "datauristring" | "dataurlstring", + options?: OutputOptions | string + ): string; + output( + type: "pdfobjectnewwindow" | "pdfjsnewwindow" | "dataurlnewwindow", + options?: OutputOptions | string + ): Window | null; + output(type: "dataurl" | "datauri", options?: OutputOptions | string): string; + output(type: "save", options?: OutputOptions | string): void; + path( + lines?: Array<{ op: string; c: number[] }>, + style?: string + ): jsPDFDocument; + pdfEscape( + text: string, + flags?: { autoencode?: boolean; noBOM?: boolean } + ): string; + rect( + x: number, + y: number, + w: number, + h: number, + style?: string | null + ): jsPDFDocument; + restoreGraphicsState(): jsPDFDocument; + roundedRect( + x: number, + y: number, + w: number, + h: number, + rx: number, + ry: number, + style?: string | null + ): jsPDFDocument; + save(filename: string, options: { returnPromise: true }): Promise; + save(filename?: string): jsPDFDocument; + saveGraphicsState(): jsPDFDocument; + scale(value: number): number; + setCharSpace(charSpace: number): jsPDFDocument; + setCreationDate(date?: Date | string): jsPDFDocument; + setCurrentTransformationMatrix(matrix: Matrix): jsPDFDocument; + setDisplayMode( + zoom?: + | number + | "fullheight" + | "fullwidth" + | "fullpage" + | "original" + | string + | null, + layout?: "continuous" | "single" | "twoleft" | "tworight" | "two" | null, + pmode?: "UseOutlines" | "UseThumbs" | "FullScreen" | null + ): jsPDFDocument; + setDocumentProperties(properties: DocumentProperties): jsPDFDocument; + setProperties(properties: DocumentProperties): jsPDFDocument; + setDrawColor( + ch1: string | number, + ch2?: number, + ch3?: number, + ch4?: number + ): jsPDFDocument; + setFileId(value: string): jsPDFDocument; + setFillColor( + ch1: string | number, + ch2?: number, + ch3?: number, + ch4?: number + ): jsPDFDocument; + setFont( + fontName: string, + fontStyle?: string, + fontWeight?: string | number + ): jsPDFDocument; + setFontSize(size: number): jsPDFDocument; + /** + * Accepts a GState object or the key of a previously added one. Note: the + * implementation returns undefined (not `this`), so the declared return + * type is void. + */ + setGState(gState: string | GState): void; + setLineCap(style: string | number): jsPDFDocument; + setLineDashPattern(dashArray?: number[], dashPhase?: number): jsPDFDocument; + setLineHeightFactor(value: number): jsPDFDocument; + setLineJoin(style: string | number): jsPDFDocument; + setLineMiterLimit(length: number): jsPDFDocument; + setLineWidth(width: number): jsPDFDocument; + setPage(pageNumber: number): jsPDFDocument; + setPageWidth(pageNumber: number, value: number): void; + setPageHeight(pageNumber: number, value: number): void; + setR2L(value: boolean): jsPDFDocument; + setTextColor( + ch1: string | number, + ch2?: number, + ch3?: number, + ch4?: number + ): jsPDFDocument; + stroke(): jsPDFDocument; + text( + text: string | string[], + x: number, + y: number, + options?: TextOptionsLight, + transform?: number | Matrix + ): jsPDFDocument; + /** + * @deprecated Legacy pre-August-2012 argument order + * `text(x, y, text, flags, angle, align)`; still supported by the + * implementation in src/jspdf.ts (see the argument-swapping shim there). + */ + text( + x: number, + y: number, + text: string | string[], + flags?: TextOptionsLight["flags"] | null, + angle?: number | null, + align?: string + ): jsPDFDocument; + triangle( + x1: number, + y1: number, + x2: number, + y2: number, + x3: number, + y3: number, + style?: string | null + ): jsPDFDocument; + + Matrix: MatrixConstructor; + matrixMult(m1: Matrix, m2: Matrix): Matrix; + unitMatrix: Matrix; + + GState: GStateConstructor; + ShadingPattern: ShadingPatternConstructor; + TilingPattern: TilingPatternConstructor; + + addShadingPattern(key: string, pattern: ShadingPatternObject): jsPDFDocument; + beginTilingPattern(pattern: TilingPatternObject): void; + endTilingPattern(key: string, pattern: TilingPatternObject): void; +} + +// --------------------------------------------------------------------------- +// Shared option shapes used by core drawing methods +// --------------------------------------------------------------------------- + +/** Reference to a previously registered pattern, used by fill()/fillEvenOdd()/... */ +export interface PatternData { + key: string; + matrix?: Matrix; + boundingBox?: number[]; + xStep?: number; + yStep?: number; +} + +export interface TextOptionsLight { + align?: "left" | "center" | "right" | "justify"; + angle?: number | Matrix; + baseline?: + "alphabetic" | "ideographic" | "bottom" | "top" | "middle" | "hanging"; + flags?: { + noBOM?: boolean; + autoencode?: boolean; + }; + rotationDirection?: 0 | 1; + /** @deprecated Legacy alias for `renderingMode` (see text() in src/jspdf.ts). */ + stroke?: boolean | number | string; + charSpace?: number; + horizontalScale?: number; + lineHeightFactor?: number; + maxWidth?: number; + renderingMode?: + | "fill" + | "stroke" + | "fillThenStroke" + | "invisible" + | "fillAndAddForClipping" + | "strokeAndAddPathForClipping" + | "fillThenStrokeAndAddToPathForClipping" + | "addToPathForClipping"; + isInputVisual?: boolean; + isOutputVisual?: boolean; + isInputRtl?: boolean; + isOutputRtl?: boolean; + isSymmetricSwapping?: boolean; +} + +export interface TextOptions extends TextOptionsLight { + text: string | string[]; + x: number; + y: number; +} diff --git a/test/deployment/amd/karma.conf.js b/test/deployment/amd/karma.conf.js index 887bea3c9..e872b8d14 100644 --- a/test/deployment/amd/karma.conf.js +++ b/test/deployment/amd/karma.conf.js @@ -29,13 +29,13 @@ module.exports = config => { included: false }, - "test/utils/compare.js", + "test/utils/compare.ts", "test/deployment/amd/loadGlobals.js", "test/deployment/amd/amd.spec.js", { - pattern: "test/specs/*.spec.js", + pattern: "test/specs/*.spec.ts", included: true, watched: true, served: true @@ -54,8 +54,9 @@ module.exports = config => { ], preprocessors: { - "test/**/!(acroform|unicode)*.spec.js": "babel", - "test/utils/compare.js": "babel" + "test/specs/*.spec.ts": ["babelTS"], + "test/deployment/**/*.spec.js": ["babel"], + "test/utils/compare.ts": ["babelTS"] } }); }; diff --git a/test/deployment/esm/karma.conf.js b/test/deployment/esm/karma.conf.js index d3e614113..d3d889bb1 100644 --- a/test/deployment/esm/karma.conf.js +++ b/test/deployment/esm/karma.conf.js @@ -16,7 +16,7 @@ module.exports = config => { "node_modules/html2canvas/dist/html2canvas.js", // load html2canvas globally - can't test dynamic import without symbolic name resolution "node_modules/dompurify/dist/purify.js", - "test/utils/compare.js", + "test/utils/compare.ts", "test/deployment/esm/loadGlobals.js", { @@ -29,7 +29,7 @@ module.exports = config => { "test/deployment/esm/esm.spec.js", { - pattern: "test/specs/*.spec.js", + pattern: "test/specs/*.spec.ts", included: true, watched: true, served: true @@ -48,7 +48,9 @@ module.exports = config => { ], preprocessors: { - "test/deployment/esm/asyncImportHelper.js": ["rollup"] + "test/deployment/esm/asyncImportHelper.js": ["rollup"], + "test/specs/*.spec.ts": ["babelTS"], + "test/utils/compare.ts": ["babelTS"] }, rollupPreprocessor: { diff --git a/test/deployment/globals/karma.conf.js b/test/deployment/globals/karma.conf.js index 3ead00751..bd9a7bb7d 100644 --- a/test/deployment/globals/karma.conf.js +++ b/test/deployment/globals/karma.conf.js @@ -18,12 +18,12 @@ module.exports = config => { "node_modules/dompurify/dist/purify.js", "test/deployment/globals/loadGlobals.js", - "test/utils/compare.js", + "test/utils/compare.ts", "test/deployment/globals/globals.spec.js", { - pattern: "test/specs/*.spec.js", + pattern: "test/specs/*.spec.ts", included: true, watched: true, served: true @@ -42,8 +42,9 @@ module.exports = config => { ], preprocessors: { - "test/**/!(acroform|unicode)*.spec.js": "babel", - "test/utils/compare.js": "babel" + "test/specs/*.spec.ts": ["babelTS"], + "test/deployment/**/*.spec.js": ["babel"], + "test/utils/compare.ts": ["babelTS"] } }); }; diff --git a/test/deployment/node/jasmine.json b/test/deployment/node/jasmine.json index a693e8f91..b296151e3 100644 --- a/test/deployment/node/jasmine.json +++ b/test/deployment/node/jasmine.json @@ -1,7 +1,16 @@ { "spec_dir": "test", - "spec_files": ["specs/**/*[sS]pec.js", "!**/*nospec.js"], - "helpers": ["deployment/node/loadGlobals.js", "utils/compare.js"], + "spec_files": [ + "specs/**/*[sS]pec.js", + "specs/**/*[sS]pec.ts", + "!specs/libs/**", + "!**/*nospec.js" + ], + "helpers": [ + "deployment/node/registerTypeScript.js", + "deployment/node/loadGlobals.js", + "utils/compare.ts" + ], "stop-on-failure": false, "stopSpecOnExpectationFailure": false, "random": false diff --git a/test/deployment/node/registerTypeScript.js b/test/deployment/node/registerTypeScript.js new file mode 100644 index 000000000..0be3a7a18 --- /dev/null +++ b/test/deployment/node/registerTypeScript.js @@ -0,0 +1,47 @@ +/** + * Jasmine helper (must be first in the helpers list): lets the Node test run + * load TypeScript spec files. + * + * - @babel/register strips types and rewrites ES modules to CommonJS for + * required ".ts" files (CI still runs Node 20, which has no native type + * stripping). + * - The Module._resolveFilename patch resolves the repo convention of ".js" + * import specifiers pointing at ".ts" files (see CONTRIBUTING.md). + */ +"use strict"; + +const Module = require("module"); + +require("@babel/register")({ + extensions: [".ts"], + babelrc: false, + configFile: false, + presets: [ + [ + "@babel/preset-typescript", + { allExtensions: true, allowDeclareFields: true } + ] + ], + plugins: ["@babel/plugin-transform-modules-commonjs"], + cache: true +}); + +const originalResolveFilename = Module._resolveFilename; +Module._resolveFilename = function(request, ...rest) { + try { + return originalResolveFilename.call(this, request, ...rest); + } catch (error) { + if (request.endsWith(".js")) { + try { + return originalResolveFilename.call( + this, + request.slice(0, -3) + ".ts", + ...rest + ); + } catch (ignored) { + throw error; + } + } + throw error; + } +}; diff --git a/test/deployment/typescript/karma.conf.js b/test/deployment/typescript/karma.conf.js index 6d33e3b0d..8b260bd06 100644 --- a/test/deployment/typescript/karma.conf.js +++ b/test/deployment/typescript/karma.conf.js @@ -13,7 +13,7 @@ module.exports = config => { // list of files / patterns to load in the browser files: [ - "test/utils/compare.js", + "test/utils/compare.ts", { pattern: "test/deployment/typescript/*.spec.ts", type: "module" @@ -35,7 +35,8 @@ module.exports = config => { browsers: ["Chrome", "Firefox"], preprocessors: { - "test/deployment/typescript/*.spec.ts": "rollup" + "test/deployment/typescript/*.spec.ts": "rollup", + "test/utils/compare.ts": ["babelTS"] }, rollupPreprocessor: { diff --git a/test/deployment/webworker/karma.conf.js b/test/deployment/webworker/karma.conf.js index f3e8a4c18..349e3aa21 100644 --- a/test/deployment/webworker/karma.conf.js +++ b/test/deployment/webworker/karma.conf.js @@ -20,7 +20,7 @@ module.exports = config => { included: false }, - "test/utils/compare.js", + "test/utils/compare.ts", { pattern: "test/deployment/webworker/*.spec.js", @@ -44,8 +44,9 @@ module.exports = config => { browsers: ["Chrome", "Firefox"], preprocessors: { - "test/**/!(acroform|unicode)*.spec.js": "babel", - "test/utils/compare.js": "babel" + "test/specs/*.spec.ts": ["babelTS"], + "test/deployment/**/*.spec.js": ["babel"], + "test/utils/compare.ts": ["babelTS"] } }); }; diff --git a/test/globals.d.ts b/test/globals.d.ts new file mode 100644 index 000000000..ec8b94454 --- /dev/null +++ b/test/globals.d.ts @@ -0,0 +1,69 @@ +/** + * Ambient declarations for the globals available inside spec files. + * + * Browser runs: `test/unit/loadGlobals.js` + `test/utils/compare.js` attach + * these to `window`. Node runs: `test/deployment/node/loadGlobals.js` + + * `test/utils/compare.js` attach them to `global`. + */ + +type jsPDFModule = typeof import("../src/index.js"); + +// jsPDF is a function-constructor supporting both `jsPDF(...)` and +// `new jsPDF(...)`; the intersection adds the construct signature the +// inferred function type lacks. +type jsPDFCtor = jsPDFModule["jsPDF"]; +// Legacy pre-August-2012 positional signature jsPDF(orientation, unit, +// format, compressPdf); still supported at runtime via the arguments-based +// shim at the top of the jsPDF constructor in src/jspdf.ts. +type jsPDFLegacyArgs = [ + orientation?: string, + unit?: import("../src/types.js").Unit | number, + format?: import("../src/types.js").PageFormat, + compressPdf?: boolean +]; +declare const jsPDF: jsPDFCtor & + ((...args: jsPDFLegacyArgs) => ReturnType) & + (new (...args: Parameters) => ReturnType) & + (new (...args: jsPDFLegacyArgs) => ReturnType); +declare const AcroForm: jsPDFModule["AcroForm"]; +declare const ChoiceField: jsPDFModule["AcroFormChoiceField"]; +declare const ListBox: jsPDFModule["AcroFormListBox"]; +declare const ComboBox: jsPDFModule["AcroFormComboBox"]; +declare const EditBox: jsPDFModule["AcroFormEditBox"]; +declare const Button: jsPDFModule["AcroFormButton"]; +declare const PushButton: jsPDFModule["AcroFormPushButton"]; +declare const RadioButton: jsPDFModule["AcroFormRadioButton"]; +declare const CheckBox: jsPDFModule["AcroFormCheckBox"]; +declare const TextField: jsPDFModule["AcroFormTextField"]; +declare const PasswordField: jsPDFModule["AcroFormPasswordField"]; +declare const Appearance: jsPDFModule["AcroFormAppearance"]; + +/** Compares a produced PDF against a reference file in test/reference/. */ +declare function comparePdf( + actual: string, + expectedFile: string, + suite?: string +): void; + +/** Loads a binary fixture served from test/reference/. */ +declare function loadBinaryResource(url: string, unicode?: boolean): string; + +declare function sendReference(filename: string, data: string): void; + +// Declared with `var` so it is visible both as a bare global and as a +// property of `globalThis`/`global` (specs probe `global.isNode`). +declare var isNode: boolean; + +declare function loadGlobals(): void; + +/** + * canvg's UMD global, loaded by the browser test runner. Minimal surface + * used by the context2d specs. + */ +declare const Canvg: { + fromString( + ctx: unknown, + svg: string, + options?: Record + ): { render(options?: Record): Promise }; +}; diff --git a/test/karma.common.conf.js b/test/karma.common.conf.js index eb0c8f22a..a7acd1bc0 100644 --- a/test/karma.common.conf.js +++ b/test/karma.common.conf.js @@ -17,7 +17,7 @@ var karmaConfig = { "src/libs/*.ts": ["babelTS"], "src/index.ts": ["babelTS"], "test/!(acroform|unicode)*.spec.js": ["babel"], - "test/utils/compare.js": ["babel"] + "test/utils/compare.ts": ["babelTS"] }, // web server port port: 9876, diff --git a/test/specs/Uint8Array.spec.js b/test/specs/Uint8Array.spec.ts similarity index 97% rename from test/specs/Uint8Array.spec.js rename to test/specs/Uint8Array.spec.ts index ca04fd007..09baf9f68 100644 --- a/test/specs/Uint8Array.spec.js +++ b/test/specs/Uint8Array.spec.ts @@ -5,7 +5,7 @@ describe("Module: addimage Uint8Array", () => { beforeAll(loadGlobals); - function convertDataURIToArrayBuffer(dataURI) { + function convertDataURIToArrayBuffer(dataURI: string) { var BASE64_MARKER = ";base64,"; var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length; var base64 = dataURI.substring(base64Index); diff --git a/test/specs/acroform.spec.js b/test/specs/acroform.spec.ts similarity index 81% rename from test/specs/acroform.spec.js rename to test/specs/acroform.spec.ts index 958fd4f5b..893994644 100644 --- a/test/specs/acroform.spec.js +++ b/test/specs/acroform.spec.ts @@ -4,16 +4,19 @@ /** * Acroform testing */ -describe("Module: Acroform Unit Test", function() { +describe("Module: Acroform Unit Test", function () { beforeAll(loadGlobals); - it("setBit", function() { - expect(function() { - jsPDF.API.__acroform__.setBit("invalid", 1); + // Note: the `("invalid" as unknown) as number`-style casts throughout this + // file feed deliberately invalid values to negative tests that expect a + // throw. + it("setBit", function () { + expect(function () { + jsPDF.API.__acroform__.setBit("invalid" as unknown as number, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.API.__acroform__.setBit") ); - expect(function() { - jsPDF.API.__acroform__.setBit(0, "invalid"); + expect(function () { + jsPDF.API.__acroform__.setBit(0, "invalid" as unknown as number); }).toThrow( new Error("Invalid arguments passed to jsPDF.API.__acroform__.setBit") ); @@ -22,14 +25,14 @@ describe("Module: Acroform Unit Test", function() { expect(jsPDF.API.__acroform__.setBit(0, 2)).toEqual(4); }); - it("getBit", function() { - expect(function() { - jsPDF.API.__acroform__.getBit("invalid", 1); + it("getBit", function () { + expect(function () { + jsPDF.API.__acroform__.getBit("invalid" as unknown as number, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.API.__acroform__.getBit") ); - expect(function() { - jsPDF.API.__acroform__.getBit(0, "invalid"); + expect(function () { + jsPDF.API.__acroform__.getBit(0, "invalid" as unknown as number); }).toThrow( new Error("Invalid arguments passed to jsPDF.API.__acroform__.getBit") ); @@ -39,14 +42,14 @@ describe("Module: Acroform Unit Test", function() { expect(jsPDF.API.__acroform__.getBit(4, 2)).toEqual(1); }); - it("clearBit", function() { - expect(function() { - jsPDF.API.__acroform__.clearBit("invalid", 1); + it("clearBit", function () { + expect(function () { + jsPDF.API.__acroform__.clearBit("invalid" as unknown as number, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.API.__acroform__.clearBit") ); - expect(function() { - jsPDF.API.__acroform__.clearBit(0, "invalid"); + expect(function () { + jsPDF.API.__acroform__.clearBit(0, "invalid" as unknown as number); }).toThrow( new Error("Invalid arguments passed to jsPDF.API.__acroform__.clearBit") ); @@ -58,16 +61,16 @@ describe("Module: Acroform Unit Test", function() { expect(jsPDF.API.__acroform__.clearBit(4, 2)).toEqual(0); }); - it("setBitForPdf", function() { - expect(function() { - jsPDF.API.__acroform__.setBitForPdf("invalid", 1); + it("setBitForPdf", function () { + expect(function () { + jsPDF.API.__acroform__.setBitForPdf("invalid" as unknown as number, 1); }).toThrow( new Error( "Invalid arguments passed to jsPDF.API.__acroform__.setBitForPdf" ) ); - expect(function() { - jsPDF.API.__acroform__.setBitForPdf(0, "invalid"); + expect(function () { + jsPDF.API.__acroform__.setBitForPdf(0, "invalid" as unknown as number); }).toThrow( new Error( "Invalid arguments passed to jsPDF.API.__acroform__.setBitForPdf" @@ -78,16 +81,16 @@ describe("Module: Acroform Unit Test", function() { expect(jsPDF.API.__acroform__.setBitForPdf(0, 3)).toEqual(4); }); - it("getBitForPdf", function() { - expect(function() { - jsPDF.API.__acroform__.getBitForPdf("invalid", 1); + it("getBitForPdf", function () { + expect(function () { + jsPDF.API.__acroform__.getBitForPdf("invalid" as unknown as number, 1); }).toThrow( new Error( "Invalid arguments passed to jsPDF.API.__acroform__.getBitForPdf" ) ); - expect(function() { - jsPDF.API.__acroform__.getBitForPdf(0, "invalid"); + expect(function () { + jsPDF.API.__acroform__.getBitForPdf(0, "invalid" as unknown as number); }).toThrow( new Error( "Invalid arguments passed to jsPDF.API.__acroform__.getBitForPdf" @@ -99,16 +102,16 @@ describe("Module: Acroform Unit Test", function() { expect(jsPDF.API.__acroform__.getBitForPdf(4, 3)).toEqual(1); }); - it("clearBitForPdf", function() { - expect(function() { - jsPDF.API.__acroform__.clearBitForPdf("invalid", 1); + it("clearBitForPdf", function () { + expect(function () { + jsPDF.API.__acroform__.clearBitForPdf("invalid" as unknown as number, 1); }).toThrow( new Error( "Invalid arguments passed to jsPDF.API.__acroform__.clearBitForPdf" ) ); - expect(function() { - jsPDF.API.__acroform__.clearBitForPdf(0, "invalid"); + expect(function () { + jsPDF.API.__acroform__.clearBitForPdf(0, "invalid" as unknown as number); }).toThrow( new Error( "Invalid arguments passed to jsPDF.API.__acroform__.clearBitForPdf" @@ -122,8 +125,16 @@ describe("Module: Acroform Unit Test", function() { expect(jsPDF.API.__acroform__.clearBitForPdf(4, 3)).toEqual(0); }); - it("AcroFormField Rect, x, y, width, height", function() { - var doc = new jsPDF("p", "pt", "a4"); + it("AcroFormField Rect, x, y, width, height", function () { + // Legacy positional constructor form jsPDF(orientation, unit, format); + // still supported at runtime by src/jspdf.ts. + var doc = new ( + jsPDF as unknown as new ( + orientation?: string, + unit?: string, + format?: string | number[] + ) => ReturnType + )("p", "pt", "a4"); var textFieldRect = new TextField(); textFieldRect.Rect = [50, 140, 30, 10]; // doc.addField(textFieldRect); @@ -150,7 +161,7 @@ describe("Module: Acroform Unit Test", function() { expect(textFieldRect.height).toEqual(0); }); - it("AcroFormField value", function() { + it("AcroFormField value", function () { var formObject = new TextField(); formObject.value = "test1"; @@ -197,7 +208,9 @@ describe("Module: Acroform Unit Test", function() { }); var radioGroup = new RadioButton(); radioGroup.V = "/Test5"; - radioGroup.Subtype = "Form"; + // Note: the historical `radioGroup.Subtype = "Form"` assignment was a + // silent no-op (Subtype is getter-only); as strict-mode module code it + // would throw, so it has been removed. doc.addField(radioGroup); var radioButton1 = radioGroup.createOption("Test"); @@ -212,7 +225,7 @@ describe("Module: Acroform Unit Test", function() { expect(radioGroup.value).toEqual("Test6"); }); - it("AcroFormField defaultValue", function() { + it("AcroFormField defaultValue", function () { var formObject = new TextField(); formObject.defaultValue = "test1"; @@ -252,7 +265,9 @@ describe("Module: Acroform Unit Test", function() { }); var radioGroup = new RadioButton(); radioGroup.DV = "/Test5"; - radioGroup.Subtype = "Form"; + // Note: the historical `radioGroup.Subtype = "Form"` assignment was a + // silent no-op (Subtype is getter-only); as strict-mode module code it + // would throw, so it has been removed. doc.addField(radioGroup); var radioButton1 = radioGroup.createOption("Test"); @@ -267,7 +282,7 @@ describe("Module: Acroform Unit Test", function() { expect(radioGroup.defaultValue).toEqual("Test6"); }); - it("AcroFormField AS", function() { + it("AcroFormField AS", function () { var doc = new jsPDF({ orientation: "p", unit: "mm", @@ -276,7 +291,9 @@ describe("Module: Acroform Unit Test", function() { }); var radioGroup = new RadioButton(); radioGroup.V = "/Test5"; - radioGroup.Subtype = "Form"; + // Note: the historical `radioGroup.Subtype = "Form"` assignment was a + // silent no-op (Subtype is getter-only); as strict-mode module code it + // would throw, so it has been removed. doc.addField(radioGroup); var radioButton1 = radioGroup.createOption("Test"); @@ -285,7 +302,7 @@ describe("Module: Acroform Unit Test", function() { expect(radioButton1.AS).toEqual("/Test"); }); - it("AcroFormField appearanceState", function() { + it("AcroFormField appearanceState", function () { var doc = new jsPDF({ orientation: "p", unit: "mm", @@ -294,7 +311,9 @@ describe("Module: Acroform Unit Test", function() { }); var radioGroup = new RadioButton(); radioGroup.V = "/Test5"; - radioGroup.Subtype = "Form"; + // Note: the historical `radioGroup.Subtype = "Form"` assignment was a + // silent no-op (Subtype is getter-only); as strict-mode module code it + // would throw, so it has been removed. doc.addField(radioGroup); var radioButton1 = radioGroup.createOption("Test"); @@ -309,7 +328,7 @@ describe("Module: Acroform Unit Test", function() { expect(radioButton1.appearanceState).toEqual("Test2b"); }); - it("AcroFormChoiceField getOptions, setOptions, addOption, removeOption", function() { + it("AcroFormChoiceField getOptions, setOptions, addOption, removeOption", function () { var listbox = new ListBox(); listbox.Opt = "[(c)(a)(d)(f)(b)(s)]"; // classic initialization @@ -320,10 +339,14 @@ describe("Module: Acroform Unit Test", function() { expect(listbox.getOptions()).toEqual(["c", "a", "d", "f", "b", "s", ""]); listbox.setOptions(["c", "a", "d", "f", "b", "s"]); - expect(listbox.getOptions("")).toEqual(["c", "a", "d", "f", "b", "s"]); + // getOptions() takes no arguments; the historical spurious "" argument is + // kept (and ignored at runtime) via a cast. + expect( + (listbox.getOptions as unknown as (x?: string) => string[])("") + ).toEqual(["c", "a", "d", "f", "b", "s"]); }); - it("AcroFormChoiceField sort", function() { + it("AcroFormChoiceField sort", function () { var listbox = new ListBox(); listbox.Opt = "[(c)(a)(d)(f)(b)(g)]"; // classic initialization @@ -366,9 +389,11 @@ describe("Module: Acroform Unit Test", function() { expect(listbox.Opt).toEqual("[(a) (b) (c) (d) (f) (g)]"); }); - it("arrayToPdfArray", function() { - expect(function() { - jsPDF.API.__acroform__.arrayToPdfArray("notAnArray"); + it("arrayToPdfArray", function () { + expect(function () { + jsPDF.API.__acroform__.arrayToPdfArray( + "notAnArray" as unknown as unknown[] + ); }).toThrow( new Error("Invalid argument passed to jsPDF.__acroform__.arrayToPdfArray") ); @@ -390,7 +415,7 @@ describe("Module: Acroform Unit Test", function() { ).toEqual("[549 3.14 false (Ralph) /SomeName]"); }); - it("AcroFormField T", function() { + it("AcroFormField T", function () { var field = new TextField(); expect(field.T.substr(1, 11)).toEqual("FieldObject"); field.T = "testname"; @@ -401,28 +426,28 @@ describe("Module: Acroform Unit Test", function() { expect(field.fieldName).toEqual("testname"); }); - it("AcroFormField FT", function() { + it("AcroFormField FT", function () { var field = new TextField(); - expect(function() { + expect(function () { field.FT = "Invalid"; }).toThrow(new Error('Invalid value "Invalid" for attribute FT supplied.')); - expect(function() { + expect(function () { field.FT = "/Btn"; }).not.toThrow( new Error('Invalid value "Invalid" for attribute FT supplied.') ); - expect(function() { + expect(function () { field.FT = "/Tx"; }).not.toThrow( new Error('Invalid value "Invalid" for attribute FT supplied.') ); - expect(function() { + expect(function () { field.FT = "/Ch"; }).not.toThrow( new Error('Invalid value "Invalid" for attribute FT supplied.') ); - expect(function() { + expect(function () { field.FT = "/Sig"; }).not.toThrow( new Error('Invalid value "Invalid" for attribute FT supplied.') @@ -432,14 +457,14 @@ describe("Module: Acroform Unit Test", function() { expect(field.FT).toEqual("/Tx"); }); - it("AcroFormTextField Ff", function() { + it("AcroFormTextField Ff", function () { var field = new TextField(); - expect(function() { - field.Ff = "Invalid"; + expect(function () { + field.Ff = "Invalid" as unknown as number; }).toThrow(new Error('Invalid value "Invalid" for attribute Ff supplied.')); - expect(function() { - field.FT = 0; + expect(function () { + field.FT = 0 as unknown as string; }).not.toThrow( new Error('Invalid value "Invalid" for attribute Ff supplied.') ); @@ -537,7 +562,7 @@ describe("Module: Acroform Unit Test", function() { expect(field.richText).toEqual(false); expect(field.Ff).toEqual(0); }); - it("AcroFormComboBox", function() { + it("AcroFormComboBox", function () { expect(new ComboBox().combo).toEqual(true); var field = new ComboBox(); expect(field.Ff).toEqual(Math.pow(2, 17)); @@ -580,7 +605,7 @@ describe("Module: Acroform Unit Test", function() { expect(field.commitOnSelChange).toEqual(false); }); - it("AcroFormEditBox", function() { + it("AcroFormEditBox", function () { expect(new EditBox().combo).toEqual(true); expect(new EditBox().edit).toEqual(true); @@ -595,7 +620,7 @@ describe("Module: Acroform Unit Test", function() { expect(field.combo).toEqual(true); expect(field.edit).toEqual(true); }); - it("AcroFormButton", function() { + it("AcroFormButton", function () { expect(new Button().FT).toEqual("/Btn"); var field = new Button(); @@ -626,13 +651,13 @@ describe("Module: Acroform Unit Test", function() { expect(field.radioIsUnison).toEqual(false); }); - it("AcroFormField F", function() { + it("AcroFormField F", function () { var field = new TextField(); - expect(function() { - field.F = "Invalid"; + expect(function () { + field.F = "Invalid" as unknown as number; }).toThrow(new Error('Invalid value "Invalid" for attribute F supplied.')); - expect(function() { + expect(function () { field.F = 0; }).not.toThrow( new Error('Invalid value "Invalid" for attribute F supplied.') @@ -647,7 +672,7 @@ describe("Module: Acroform Unit Test", function() { expect(field.F).toEqual(4); }); - it("AcroFormCheckBox", function() { + it("AcroFormCheckBox", function () { var field = new CheckBox(); expect(field.FT).toEqual("/Btn"); @@ -658,7 +683,7 @@ describe("Module: Acroform Unit Test", function() { expect(field.textAlign).toEqual("center"); }); - it("AcroFormField fontName, fontStyle", function() { + it("AcroFormField fontName, fontStyle", function () { var field = new TextField(); expect(field.fontName).toEqual("helvetica"); @@ -670,7 +695,7 @@ describe("Module: Acroform Unit Test", function() { expect(field.fontStyle).toEqual("bold"); }); - it("AcroFormField textAlign", function() { + it("AcroFormField textAlign", function () { var field = new TextField(); expect(field.Q).toEqual(undefined); @@ -678,36 +703,39 @@ describe("Module: Acroform Unit Test", function() { field.textAlign = "left"; expect(field.textAlign).toEqual("left"); expect(field.Q).toEqual(0); - field.textAlign = 0; + // The runtime setter also accepts numeric Q values (see src/modules/acroform.ts). + field.textAlign = 0 as unknown as string; expect(field.textAlign).toEqual("left"); expect(field.Q).toEqual(0); field.textAlign = "center"; expect(field.textAlign).toEqual("center"); expect(field.Q).toEqual(1); - field.textAlign = 1; + // The runtime setter also accepts numeric Q values (see src/modules/acroform.ts). + field.textAlign = 1 as unknown as string; expect(field.textAlign).toEqual("center"); expect(field.Q).toEqual(1); field.textAlign = "right"; expect(field.textAlign).toEqual("right"); expect(field.Q).toEqual(2); - field.textAlign = 2; + // The runtime setter also accepts numeric Q values (see src/modules/acroform.ts). + field.textAlign = 2 as unknown as string; expect(field.textAlign).toEqual("right"); expect(field.Q).toEqual(2); - expect(function() { - field.Q = "invalid"; + expect(function () { + field.Q = "invalid" as unknown as number; }).toThrow(new Error('Invalid value "invalid" for attribute Q supplied.')); - expect(function() { + expect(function () { field.Q = 3; }).toThrow(new Error('Invalid value "3" for attribute Q supplied.')); - expect(function() { + expect(function () { field.Q = 0; }).not.toThrow(new Error('Invalid value "0" for attribute Q supplied.')); }); - it("addField", function() { + it("addField", function () { var doc = new jsPDF({ orientation: "p", unit: "mm", @@ -715,30 +743,33 @@ describe("Module: Acroform Unit Test", function() { floatPrecision: 2 }); - expect(function() { + expect(function () { doc.addField(new TextField()); }).not.toThrow(new Error("Invalid argument passed to jsPDF.addField.")); - expect(function() { + expect(function () { doc.addField(new ChoiceField()); }).not.toThrow(new Error("Invalid argument passed to jsPDF.addField.")); - expect(function() { + expect(function () { doc.addField(new PasswordField()); }).not.toThrow(new Error("Invalid argument passed to jsPDF.addField.")); - expect(function() { + expect(function () { doc.addField(new Button()); }).not.toThrow(new Error("Invalid argument passed to jsPDF.addField.")); - expect(function() { + expect(function () { doc.addField(new PushButton()); }).not.toThrow(new Error("Invalid argument passed to jsPDF.addField.")); - expect(function() { + expect(function () { doc.addField(new ComboBox()); }).not.toThrow(new Error("Invalid argument passed to jsPDF.addField.")); - expect(function() { - doc.addField(new Object()); + expect(function () { + // Deliberately invalid field object (negative test). + doc.addField( + new Object() as unknown as Parameters[0] + ); }).toThrow(new Error("Invalid argument passed to jsPDF.addField.")); }); - it("addButton", function() { + it("addButton", function () { var doc = new jsPDF({ orientation: "p", unit: "mm", @@ -746,15 +777,18 @@ describe("Module: Acroform Unit Test", function() { floatPrecision: 2 }); - expect(function() { + expect(function () { doc.addField(new Button()); }).not.toThrow(new Error("Invalid argument passed to jsPDF.addField.")); - expect(function() { - doc.addField(new Object()); + expect(function () { + // Deliberately invalid field object (negative test). + doc.addField( + new Object() as unknown as Parameters[0] + ); }).toThrow(new Error("Invalid argument passed to jsPDF.addField.")); }); - it("AcroFormPasswordField", function() { + it("AcroFormPasswordField", function () { var field = new PasswordField(); expect(field.Ff).toEqual(Math.pow(2, 13)); @@ -766,11 +800,11 @@ describe("Module: Acroform Unit Test", function() { expect(field.password).toEqual(true); expect(field.Ff).toEqual(Math.pow(2, 13)); }); - it("AcroFormPushButton", function() { + it("AcroFormPushButton", function () { expect(new PushButton().pushButton).toEqual(true); expect(new PushButton() instanceof Button).toEqual(true); }); - it("ComboBox TopIndex", function() { + it("ComboBox TopIndex", function () { var comboBox = new ComboBox(); expect(comboBox.topIndex).toEqual(0); comboBox.topIndex = 1; @@ -778,9 +812,9 @@ describe("Module: Acroform Unit Test", function() { }); }); -describe("Module: Acroform Integration Test", function() { +describe("Module: Acroform Integration Test", function () { beforeAll(loadGlobals); - it("ComboBox - old", function() { + it("ComboBox - old", function () { var doc = new jsPDF({ orientation: "p", unit: "mm", @@ -802,7 +836,7 @@ describe("Module: Acroform Integration Test", function() { comparePdf(doc.output(), "combobox.pdf", "acroform"); }); - it("ComboBox - new", function() { + it("ComboBox - new", function () { var doc = jsPDF({ orientation: "p", unit: "mm", @@ -828,7 +862,7 @@ describe("Module: Acroform Integration Test", function() { comparePdf(doc.output(), "combobox.pdf", "acroform"); }); - it("CheckBox - old", function() { + it("CheckBox - old", function () { var doc = new jsPDF({ orientation: "p", unit: "mm", @@ -844,7 +878,7 @@ describe("Module: Acroform Integration Test", function() { comparePdf(doc.output(), "checkbox.pdf", "acroform"); }); - it("CheckBox - new", function() { + it("CheckBox - new", function () { var doc = new jsPDF({ orientation: "p", unit: "mm", @@ -860,7 +894,7 @@ describe("Module: Acroform Integration Test", function() { comparePdf(doc.output(), "checkbox.pdf", "acroform"); }); - it("ListBox - old", function() { + it("ListBox - old", function () { var doc = new jsPDF({ orientation: "p", unit: "mm", @@ -881,7 +915,7 @@ describe("Module: Acroform Integration Test", function() { comparePdf(doc.output(), "listbox.pdf", "acroform"); }); - it("ListBox - new", function() { + it("ListBox - new", function () { var doc = new jsPDF({ orientation: "p", unit: "mm", @@ -902,7 +936,7 @@ describe("Module: Acroform Integration Test", function() { comparePdf(doc.output(), "listbox.pdf", "acroform"); }); - it("should add a PushButton", function() { + it("should add a PushButton", function () { var doc = new jsPDF({ orientation: "p", unit: "mm", @@ -918,7 +952,7 @@ describe("Module: Acroform Integration Test", function() { comparePdf(doc.output(), "pushbutton.pdf", "acroform"); }); - it("should add a TextField", function() { + it("should add a TextField", function () { var doc = new jsPDF({ orientation: "p", unit: "mm", @@ -938,7 +972,7 @@ describe("Module: Acroform Integration Test", function() { comparePdf(doc.output(), "textfield.pdf", "acroform"); }); - it("should add a TextField: var. 2", function() { + it("should add a TextField: var. 2", function () { var doc = new jsPDF({ orientation: "p", unit: "mm", @@ -958,7 +992,7 @@ describe("Module: Acroform Integration Test", function() { comparePdf(doc.output(), "textfield.pdf", "acroform"); }); - it("should add a Password", function() { + it("should add a Password", function () { var doc = new jsPDF({ orientation: "p", unit: "mm", @@ -973,7 +1007,7 @@ describe("Module: Acroform Integration Test", function() { comparePdf(doc.output(), "password.pdf", "acroform"); }); - it("Check multiline text", function() { + it("Check multiline text", function () { var doc = new jsPDF({ orientation: "p", unit: "mm", @@ -991,7 +1025,7 @@ describe("Module: Acroform Integration Test", function() { comparePdf(doc.output(), "textfieldMultiline.pdf", "acroform"); }); - it("Check multiline text in small form", function() { + it("Check multiline text in small form", function () { var doc = new jsPDF({ orientation: "p", unit: "mm", @@ -1009,7 +1043,7 @@ describe("Module: Acroform Integration Test", function() { comparePdf(doc.output(), "textfieldMultilineSmallForm.pdf", "acroform"); }); - it("should add a RadioGroup Cross", function() { + it("should add a RadioGroup Cross", function () { var doc = new jsPDF({ orientation: "p", unit: "mm", @@ -1019,7 +1053,9 @@ describe("Module: Acroform Integration Test", function() { doc.text(50, 165, "RadioGroup:"); var radioGroup = new RadioButton(); radioGroup.V = "/Test"; - radioGroup.Subtype = "Form"; + // Note: the historical `radioGroup.Subtype = "Form"` assignment was a + // silent no-op (Subtype is getter-only); as strict-mode module code it + // would throw, so it has been removed. doc.addField(radioGroup); @@ -1038,7 +1074,7 @@ describe("Module: Acroform Integration Test", function() { comparePdf(doc.output(), "radiogroup.pdf", "acroform"); }); - it("should add a RadioGroup Circle", function() { + it("should add a RadioGroup Circle", function () { var doc = new jsPDF({ orientation: "p", unit: "mm", @@ -1048,7 +1084,9 @@ describe("Module: Acroform Integration Test", function() { doc.text(50, 165, "RadioGroup:"); var radioGroup = new RadioButton(); radioGroup.V = "/Test"; - radioGroup.Subtype = "Form"; + // Note: the historical `radioGroup.Subtype = "Form"` assignment was a + // silent no-op (Subtype is getter-only); as strict-mode module code it + // would throw, so it has been removed. doc.addField(radioGroup); @@ -1067,7 +1105,7 @@ describe("Module: Acroform Integration Test", function() { }); //fix for issue #1783 - it("acroform and annotations", function() { + it("acroform and annotations", function () { var doc = jsPDF({ floatPrecision: 2 }); //index items @@ -1092,7 +1130,7 @@ describe("Module: Acroform Integration Test", function() { comparePdf(doc.output(), "with_annotations.pdf", "acroform"); }); - it("should export all needed Classes", function() { + it("should export all needed Classes", function () { expect(jsPDF.API.AcroForm.Appearance); expect(jsPDF.API.AcroForm.CheckBox); expect(jsPDF.API.AcroForm.Button); @@ -1116,8 +1154,8 @@ describe("Module: Acroform Integration Test", function() { expect(jsPDF.API.AcroFormRadioButton); expect(jsPDF.API.AcroFormTextField); }); - describe("Security: PDF Injection Prevention", function() { - it("should escape malicious characters in ChoiceField options", function() { + describe("Security: PDF Injection Prevention", function () { + it("should escape malicious characters in ChoiceField options", function () { const doc = new jsPDF(); const field = new doc.AcroFormChoiceField(); const maliciousInput = "/dummy] /AA << /JS (app.alert(1)) >> ["; @@ -1131,7 +1169,7 @@ describe("Module: Acroform Integration Test", function() { expect(output).toContain("/dummy#5D"); }); - it("should escape appearanceState in CheckBox", function() { + it("should escape appearanceState in CheckBox", function () { const doc = new jsPDF(); const field = new doc.AcroFormCheckBox(); field.x = 0; @@ -1149,7 +1187,7 @@ describe("Module: Acroform Integration Test", function() { expect(output).toContain("#2FAA"); }); - it("should escape appearanceState in RadioButton", function() { + it("should escape appearanceState in RadioButton", function () { const doc = new jsPDF(); const field = new doc.AcroFormRadioButton(); const maliciousInput = "Off /AA << >>"; @@ -1162,10 +1200,13 @@ describe("Module: Acroform Integration Test", function() { expect(output).not.toContain("/AA <<"); expect(output).toContain("#2FAA"); }); - it("escapes malicious input in CheckBox AS", function() { + it("escapes malicious input in CheckBox AS", function () { var doc = new jsPDF(); var field = new doc.AcroFormCheckBox(); - field.x = 10; field.y = 10; field.width = 20; field.height = 10; + field.x = 10; + field.y = 10; + field.width = 20; + field.height = 10; doc.addField(field); field.AS = "/Off /AA << /E << /S /JavaScript /JS (app.alert(1)) >> >>"; @@ -1175,15 +1216,22 @@ describe("Module: Acroform Integration Test", function() { expect(field.AS).toContain("#2FAA"); }); - it("escapes malicious input in RadioButton child appearanceState", function() { + it("escapes malicious input in RadioButton child appearanceState", function () { var doc = new jsPDF(); var group = new doc.AcroFormRadioButton(); - group.x = 10; group.y = 10; group.width = 20; group.height = 10; + group.x = 10; + group.y = 10; + group.width = 20; + group.height = 10; doc.addField(group); var child = group.createOption("opt1"); - child.x = 10; child.y = 10; child.width = 20; child.height = 10; - child.appearanceState = "Off /AA << /E << /S /JavaScript /JS (app.alert(1)) >> >>"; + child.x = 10; + child.y = 10; + child.width = 20; + child.height = 10; + child.appearanceState = + "Off /AA << /E << /S /JavaScript /JS (app.alert(1)) >> >>"; var output = doc.output(); expect(output).not.toContain("/AA << /E << /S /JavaScript"); diff --git a/test/specs/addimage.spec.js b/test/specs/addimage.spec.ts similarity index 97% rename from test/specs/addimage.spec.js rename to test/specs/addimage.spec.ts index 94eac858c..673d487e3 100644 --- a/test/specs/addimage.spec.js +++ b/test/specs/addimage.spec.ts @@ -53,7 +53,7 @@ describe("Module: addimage", () => { } ctx.putImageData(image, 0, 0); - expect(function() { + expect(function () { doc.addImage(canvas, 10, 10); }).not.toThrow(); }); @@ -64,9 +64,11 @@ describe("Module: addimage", () => { canvas.width = 0; canvas.height = 100; - var expectedError = new Error("Given canvas must have data. Canvas width: 0, height: 100"); + var expectedError = new Error( + "Given canvas must have data. Canvas width: 0, height: 100" + ); - expect(function() { + expect(function () { doc.addImage(canvas, 10, 10); }).toThrow(expectedError); }); @@ -85,9 +87,17 @@ describe("Module: addimage", () => { ctx.putImageData(image, 0, 0); var imageElement = document.createElement("img"); - imageElement.setAttribute("src", canvas.toDataURL(), canvas.toDataURL()); + // The stray third argument is ignored by the DOM; kept verbatim, typed via + // a widened signature. + ( + imageElement.setAttribute as ( + name: string, + value: string, + extra?: string + ) => void + )("src", canvas.toDataURL(), canvas.toDataURL()); - expect(function() { + expect(function () { doc.addImage(imageElement, 10, 10); }).not.toThrow(); }); diff --git a/test/specs/annotations.spec.js b/test/specs/annotations.spec.ts similarity index 100% rename from test/specs/annotations.spec.js rename to test/specs/annotations.spec.ts diff --git a/test/specs/arabic.spec.js b/test/specs/arabic.spec.ts similarity index 100% rename from test/specs/arabic.spec.js rename to test/specs/arabic.spec.ts diff --git a/test/specs/autoprint.spec.js b/test/specs/autoprint.spec.ts similarity index 100% rename from test/specs/autoprint.spec.js rename to test/specs/autoprint.spec.ts diff --git a/test/specs/base64.spec.js b/test/specs/base64.spec.ts similarity index 95% rename from test/specs/base64.spec.js rename to test/specs/base64.spec.ts index dfb3178a6..5b39854b2 100644 --- a/test/specs/base64.spec.js +++ b/test/specs/base64.spec.ts @@ -5,7 +5,9 @@ describe("Module: addimage bas64Validation", () => { beforeAll(loadGlobals); - var global = + // Explicitly typed: the initializer references `global` itself, which + // TypeScript cannot infer (TS7022). Only `isNode` is accessed on it. + var global: { isNode?: boolean } = (typeof self !== "undefined" && self) || (typeof window !== "undefined" && window) || (typeof global !== "undefined" && global) || @@ -26,7 +28,7 @@ describe("Module: addimage bas64Validation", () => { } ctx.putImageData(image, 0, 0); - expect(function() { + expect(function () { doc.addImage(canvas.toDataURL(), 10, 10); }).not.toThrow(); }); diff --git a/test/specs/bidiEngine.spec.js b/test/specs/bidiEngine.spec.ts similarity index 70% rename from test/specs/bidiEngine.spec.js rename to test/specs/bidiEngine.spec.ts index cd7444ab9..47f35ac97 100644 --- a/test/specs/bidiEngine.spec.js +++ b/test/specs/bidiEngine.spec.ts @@ -1,27 +1,52 @@ /* global describe, beforeAll, it, expect, jsPDF */ -describe("Lib: Bidi Engine", function() { - var options = { +describe("Lib: Bidi Engine", function () { + /** Options accepted by the internal bidi engine (see src/libs/bidiEngine.ts). */ + interface BidiEngineOptions { + isInputVisual?: boolean; + isOutputVisual?: boolean; + isInputRtl?: boolean; + isOutputRtl?: boolean; + isSymmetricSwapping?: boolean; + } + + /** Instance surface of the internal bidi engine used by these specs. */ + interface BidiEngine { + doBidiReorder( + text: string, + sourceToTargetMap?: number[], + levels?: number[] + ): string; + setOptions(options?: BidiEngineOptions): void; + } + + var options: BidiEngineOptions = { isInputVisual: true, isSymmetricSwapping: true, isInputRtl: false, isOutputRtl: false }; var sourceString = "a(b)c\u05d0<\u05d5>\u05ea& 123"; - var bidiEngine; - beforeAll(async function() { + var bidiEngine: BidiEngine; + beforeAll(async function () { await loadGlobals(); - bidiEngine = new jsPDF.__bidiEngine__(options); + // jsPDF.__bidiEngine__ is an internal attachment that is deliberately + // not part of the public jsPDF typings, hence the one local cast here. + bidiEngine = new ( + jsPDF as unknown as { + __bidiEngine__: new (options?: BidiEngineOptions) => BidiEngine; + } + ).__bidiEngine__(options); }); - it("Visual left-to-right ->Logical left-to-right conversion", function() { + it("Visual left-to-right ->Logical left-to-right conversion", function () { var options = { isInputVisual: true, isSymmetricSwapping: true, isInputRtl: false, isOutputRtl: false }; - var levels = [], - sourceToTargetMap = []; + var levels: number[] = [], + sourceToTargetMap: number[] = []; bidiEngine.setOptions(options); var reorderedString = bidiEngine.doBidiReorder( @@ -31,28 +56,14 @@ describe("Lib: Bidi Engine", function() { ); expect(reorderedString).toEqual("a(b)c123 &\u05ea<\u05d5>\u05d0"); expect(sourceToTargetMap).toEqual([ - 0, - 1, - 2, - 3, - 4, - 12, - 13, - 14, - 11, - 10, - 9, - 8, - 7, - 6, - 5 + 0, 1, 2, 3, 4, 12, 13, 14, 11, 10, 9, 8, 7, 6, 5 ]); expect(levels).toEqual([0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2]); }); - it("Logical right-to-left -> Visual left-to-right conversion", function() { - var levels = [], - sourceToTargetMap = []; + it("Logical right-to-left -> Visual left-to-right conversion", function () { + var levels: number[] = [], + sourceToTargetMap: number[] = []; options = {}; options.isOutputVisual = true; options.isInputRtl = true; @@ -67,27 +78,13 @@ describe("Lib: Bidi Engine", function() { ); expect(reorderedString).toEqual("123 &\u05ea<\u05d5>\u05d0a(b)c"); expect(sourceToTargetMap).toEqual([ - 12, - 13, - 14, - 11, - 10, - 9, - 8, - 7, - 6, - 5, - 0, - 1, - 2, - 3, - 4 + 12, 13, 14, 11, 10, 9, 8, 7, 6, 5, 0, 1, 2, 3, 4 ]); expect(levels).toEqual([2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2]); }); - it("Logical left-to-right -> Logical right-to-left conversion", function() { - var levels = [], - sourceToTargetMap = []; + it("Logical left-to-right -> Logical right-to-left conversion", function () { + var levels: number[] = [], + sourceToTargetMap: number[] = []; options.isInputVisual = options.isOutputVisual = false; options.isInputRtl = false; @@ -102,28 +99,14 @@ describe("Lib: Bidi Engine", function() { ); expect(reorderedString).toEqual("\u05d0<\u05d5>\u05ea& a(b)c123"); expect(sourceToTargetMap).toEqual([ - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 0, - 1, - 2, - 3, - 4, - 12, - 13, - 14 + 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 12, 13, 14 ]); expect(levels).toEqual([1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2]); }); - it("Logical right-to-left -> Logical left-to-right conversion", function() { - var levels = [], - sourceToTargetMap = []; + it("Logical right-to-left -> Logical left-to-right conversion", function () { + var levels: number[] = [], + sourceToTargetMap: number[] = []; options.isInputVisual = options.isOutputVisual = false; options.isInputRtl = true; @@ -138,28 +121,14 @@ describe("Lib: Bidi Engine", function() { ); expect(reorderedString).toEqual("123 &\u05d0<\u05d5>\u05eaa(b)c"); expect(sourceToTargetMap).toEqual([ - 12, - 13, - 14, - 11, - 10, - 5, - 6, - 7, - 8, - 9, - 0, - 1, - 2, - 3, - 4 + 12, 13, 14, 11, 10, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4 ]); expect(levels).toEqual([0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]); }); - it("Visual right-to-left -> Visual left-to-right conversion", function() { - var levels = [], - sourceToTargetMap = []; + it("Visual right-to-left -> Visual left-to-right conversion", function () { + var levels: number[] = [], + sourceToTargetMap: number[] = []; options.isInputVisual = options.isOutputVisual = true; options.isInputRtl = true; @@ -174,28 +143,14 @@ describe("Lib: Bidi Engine", function() { ); expect(reorderedString).toEqual("321 &\u05ea>\u05d5<\u05d0c)b(a"); expect(sourceToTargetMap).toEqual([ - 14, - 13, - 12, - 11, - 10, - 9, - 8, - 7, - 6, - 5, - 4, - 3, - 2, - 1, - 0 + 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 ]); expect(levels).toEqual([2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2]); }); - it("Logical contextual -> Visual right-to-left conversion", function() { - var levels = [], - sourceToTargetMap = []; + it("Logical contextual -> Visual right-to-left conversion", function () { + var levels: number[] = [], + sourceToTargetMap: number[] = []; options = {}; options.isInputVisual = false; @@ -213,9 +168,9 @@ describe("Lib: Bidi Engine", function() { expect(sourceToTargetMap).toEqual([0, 1, 2, 3, 4, 9, 8, 7, 6, 5]); expect(levels).toEqual([1, 1, 1, 1, 1, 2, 2, 2, 2, 2]); }); - it("Logical left-to-right -> Visual right-to-left conversion", function() { - var levels = [], - sourceToTargetMap = []; + it("Logical left-to-right -> Visual right-to-left conversion", function () { + var levels: number[] = [], + sourceToTargetMap: number[] = []; options.isInputVisual = false; options.isOutputVisual = true; @@ -231,28 +186,14 @@ describe("Lib: Bidi Engine", function() { ); expect(reorderedString).toEqual("\u05d0>\u05d5<\u05ea& 321c)b(a"); expect(sourceToTargetMap).toEqual([ - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 14, - 13, - 12, - 4, - 3, - 2, - 1, - 0 + 5, 6, 7, 8, 9, 10, 11, 14, 13, 12, 4, 3, 2, 1, 0 ]); expect(levels).toEqual([0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2]); }); - it("Visual right-to-left -> Logical right-to-left conversion", function() { - var levels = [], - sourceToTargetMap = []; + it("Visual right-to-left -> Logical right-to-left conversion", function () { + var levels: number[] = [], + sourceToTargetMap: number[] = []; options.isInputVisual = true; options.isOutputVisual = false; @@ -267,21 +208,7 @@ describe("Lib: Bidi Engine", function() { ); expect(reorderedString).toEqual("c)b(a\u05d0>\u05d5<\u05ea& 321"); expect(sourceToTargetMap).toEqual([ - 4, - 3, - 2, - 1, - 0, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 14, - 13, - 12 + 4, 3, 2, 1, 0, 5, 6, 7, 8, 9, 10, 11, 14, 13, 12 ]); expect(levels).toEqual([2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2]); }); diff --git a/test/specs/bmp.spec.js b/test/specs/bmp.spec.ts similarity index 100% rename from test/specs/bmp.spec.js rename to test/specs/bmp.spec.ts diff --git a/test/specs/canvas.spec.js b/test/specs/canvas.spec.ts similarity index 100% rename from test/specs/canvas.spec.js rename to test/specs/canvas.spec.ts diff --git a/test/specs/cell.spec.js b/test/specs/cell.spec.ts similarity index 82% rename from test/specs/cell.spec.js rename to test/specs/cell.spec.ts index 19b1a85c1..b3574270c 100644 --- a/test/specs/cell.spec.js +++ b/test/specs/cell.spec.ts @@ -27,17 +27,23 @@ describe("Module: Cell", () => { doc.getTextDimensions("Octocat loves jsPDF", { maxWidth: 100 }).w ).toEqual(96.64000000000001); expect( - doc.getTextDimensions("Octocat loves jsPDF\njsPDF loves Octocat", { maxWidth: 100 }).h + doc.getTextDimensions("Octocat loves jsPDF\njsPDF loves Octocat", { + maxWidth: 100 + }).h ).toEqual(71.19999999999999); expect( - doc.getTextDimensions("Octocat loves jsPDF\njsPDF loves Octocat", { maxWidth: 100 }).w + doc.getTextDimensions("Octocat loves jsPDF\njsPDF loves Octocat", { + maxWidth: 100 + }).w ).toEqual(96.64000000000001); expect(doc.getTextDimensions("").w).toEqual(0); expect(doc.getTextDimensions("").h).toEqual(0); expect(doc.getTextDimensions([""]).w).toEqual(0); expect(doc.getTextDimensions([""]).h).toEqual(0); - expect(function() { - doc.getTextDimensions(); + expect(function () { + // Deliberately called without the required text argument to assert the + // runtime validation throws. + (doc.getTextDimensions as unknown as () => void)(); }).toThrow( new Error( "getTextDimensions expects text-parameter to be of type String or type Number or an Array of Strings." @@ -45,7 +51,7 @@ describe("Module: Cell", () => { ); }); - var generateData = function(amount) { + var generateData = function (amount: number) { var result = []; var data = { coin: "100", @@ -61,7 +67,7 @@ describe("Module: Cell", () => { return result; }; - function createHeaders(keys) { + function createHeaders(keys: string[]) { return keys.map(key => ({ name: key, prompt: key, @@ -129,19 +135,15 @@ describe("Module: Cell", () => { floatPrecision: 2 }); doc.table(1, 1, generateData(100), header, { - rowStart: function(e, docInstance) { - // docInstance equal to doc - if (17 < e.row && e.row < 36) - docInstance.setTextColor(255,0,0); - else - docInstance.setTextColor(0,0,0); + rowStart: function (e, docInstance) { + // docInstance equal to doc + if (17 < e.row && e.row < 36) docInstance.setTextColor(255, 0, 0); + else docInstance.setTextColor(0, 0, 0); }, - cellStart: function(e, docInstance) { - // docInstance equal to doc - if (e.row === 27 && e.col === 3) - docInstance.setFont(undefined, "bold"); - else - docInstance.setFont(undefined, "normal"); + cellStart: function (e, docInstance) { + // docInstance equal to doc + if (e.row === 27 && e.col === 3) docInstance.setFont(undefined, "bold"); + else docInstance.setFont(undefined, "normal"); } }); comparePdf(doc.output(), "table-formatted.pdf"); @@ -149,10 +151,10 @@ describe("Module: Cell", () => { it("table error handling", () => { var doc = new jsPDF({ putOnlyUsedFonts: true, orientation: "landscape" }); - expect(function() { + expect(function () { doc.table(1, 1, undefined, header, { autoSize: true }); }).toThrow(new Error("No data for PDF table.")); - expect(function() { + expect(function () { doc.printHeaderRow(1, false); }).toThrow(new Error("Property tableHeaderRow does not exist.")); }); diff --git a/test/specs/context2d.complex.spec.js b/test/specs/context2d.complex.spec.ts similarity index 87% rename from test/specs/context2d.complex.spec.js rename to test/specs/context2d.complex.spec.ts index 4e23917ee..e0562bb2d 100644 --- a/test/specs/context2d.complex.spec.js +++ b/test/specs/context2d.complex.spec.ts @@ -55,9 +55,11 @@ describe("Module: Context2D Complex Examples", () => { gradient.addColorStop(0, primaryColor); gradient.addColorStop(1, secondaryColor); - // Add a shadow around the object - context.shadowBlur = 10; - context.shadowColor = "black"; + // Add a shadow around the object. jsPDF's context2d does not implement + // canvas shadows; these writes are runtime no-ops kept verbatim from the + // upstream canvas sample, hence the casts. + (context as unknown as CanvasRenderingContext2D).shadowBlur = 10; + (context as unknown as CanvasRenderingContext2D).shadowColor = "black"; // Stroke the outer outline context.lineWidth = lineWidth * 2; @@ -66,7 +68,8 @@ describe("Module: Context2D Complex Examples", () => { context.stroke(); // Turn off the shadow, or all future fills will have shadows - context.shadowColor = "transparent"; + (context as unknown as CanvasRenderingContext2D).shadowColor = + "transparent"; // Fill the path context.fillStyle = gradient; @@ -125,7 +128,15 @@ describe("Module: Context2D Complex Examples", () => { var y3 = height; var depth = 6; - function sierpinski(x1, y1, x2, y2, x3, y3, depth) { + function sierpinski( + x1: number, + y1: number, + x2: number, + y2: number, + x3: number, + y3: number, + depth: number + ) { if (depth == 0) drawTriangle(x1, y1, x2, y2, x3, y3); else { var x12 = (x1 + x2) / 2; @@ -141,7 +152,14 @@ describe("Module: Context2D Complex Examples", () => { } } - function drawTriangle(x1, y1, x2, y2, x3, y3) { + function drawTriangle( + x1: number, + y1: number, + x2: number, + y2: number, + x3: number, + y3: number + ) { c.beginPath(); c.moveTo(x1, y1); c.lineTo(x2, y2); @@ -187,7 +205,7 @@ describe("Module: Context2D Complex Examples", () => { ctx.restore(); } - function drawStar(ctx, r) { + function drawStar(ctx: typeof doc.context2d, r: number) { ctx.save(); ctx.beginPath(); ctx.moveTo(r, 0); diff --git a/test/specs/context2d.input-validation.spec.js b/test/specs/context2d.input-validation.spec.ts similarity index 51% rename from test/specs/context2d.input-validation.spec.js rename to test/specs/context2d.input-validation.spec.ts index 99367a90e..bb47d35e1 100644 --- a/test/specs/context2d.input-validation.spec.js +++ b/test/specs/context2d.input-validation.spec.ts @@ -1,7 +1,9 @@ /* global describe, it, expect, jsPDF */ describe("Module: Context2D Input Validation", () => { beforeAll(loadGlobals); - var global = + // Explicitly typed: the initializer references `global` itself, which + // TypeScript cannot infer (TS7022). Only `console` is accessed on it. + var global: { console: Console } = (typeof self !== "undefined" && self) || (typeof window !== "undefined" && window) || (typeof global !== "undefined" && global) || @@ -10,66 +12,72 @@ describe("Module: Context2D Input Validation", () => { var tmpConsoleError = global.console.error; - beforeEach(function() { - global.console.error = function() {}; + beforeEach(function () { + global.console.error = function () {}; }); - afterEach(function() { + afterEach(function () { global.console.error = tmpConsoleError; }); it("context2d: moveTo", () => { var doc = new jsPDF(); - expect(function() { + // Deliberately mistyped arguments (cast through unknown) to assert the + // runtime input validation throws. + expect(function () { doc.context2d.moveTo(1, 1); }).not.toThrow( new Error("Invalid arguments passed to jsPDF.context2d.moveTo") ); - expect(function() { - doc.context2d.moveTo("invalid", 1); + expect(function () { + doc.context2d.moveTo("invalid" as unknown as number, 1); }).toThrow(new Error("Invalid arguments passed to jsPDF.context2d.moveTo")); - expect(function() { - doc.context2d.moveTo(1, "invalid"); + expect(function () { + doc.context2d.moveTo(1, "invalid" as unknown as number); }).toThrow(new Error("Invalid arguments passed to jsPDF.context2d.moveTo")); }); it("context2d: lineTo ", () => { var doc = new jsPDF(); - expect(function() { + // Deliberately mistyped arguments (cast through unknown) to assert the + // runtime input validation throws. + expect(function () { doc.context2d.lineTo(1, 1); }).not.toThrow( new Error("Invalid arguments passed to jsPDF.context2d.lineTo") ); - expect(function() { - doc.context2d.lineTo("invalid", 1); + expect(function () { + doc.context2d.lineTo("invalid" as unknown as number, 1); }).toThrow(new Error("Invalid arguments passed to jsPDF.context2d.lineTo")); - expect(function() { - doc.context2d.lineTo(1, "invalid"); + expect(function () { + doc.context2d.lineTo(1, "invalid" as unknown as number); }).toThrow(new Error("Invalid arguments passed to jsPDF.context2d.lineTo")); }); it("context2d: quadraticCurveTo", () => { var doc = new jsPDF(); - expect(function() { + // Deliberately mistyped arguments (cast through unknown) to assert the + // runtime input validation throws. + expect(function () { doc.context2d.quadraticCurveTo(1, 1, 1, 1); }).not.toThrow( new Error("Invalid arguments passed to jsPDF.context2d.quadraticCurveTo") ); - expect(function() { - doc.context2d.quadraticCurveTo("invalid", 1, 1, 1); + expect(function () { + doc.context2d.quadraticCurveTo("invalid" as unknown as number, 1, 1, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.quadraticCurveTo") ); - expect(function() { - doc.context2d.quadraticCurveTo(1, "invalid", 1, 1); + expect(function () { + doc.context2d.quadraticCurveTo(1, "invalid" as unknown as number, 1, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.quadraticCurveTo") ); - expect(function() { - doc.context2d.quadraticCurveTo(1, 1, "invalid", 1); + expect(function () { + doc.context2d.quadraticCurveTo(1, 1, "invalid" as unknown as number, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.quadraticCurveTo") ); - expect(function() { - doc.context2d.quadraticCurveTo(1, 1, 1, "invalid"); + expect(function () { + doc.context2d.quadraticCurveTo(1, 1, 1, "invalid" as unknown as number); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.quadraticCurveTo") ); @@ -77,38 +85,82 @@ describe("Module: Context2D Input Validation", () => { it("context2d: bezierCurveTo", () => { var doc = new jsPDF(); - expect(function() { + // Deliberately mistyped arguments (cast through unknown) to assert the + // runtime input validation throws. + expect(function () { doc.context2d.bezierCurveTo(1, 1, 1, 1, 1, 1); }).not.toThrow( new Error("Invalid arguments passed to jsPDF.context2d.bezierCurveTo") ); - expect(function() { - doc.context2d.bezierCurveTo("invalid", 1, 1, 1, 1, 1); + expect(function () { + doc.context2d.bezierCurveTo( + "invalid" as unknown as number, + 1, + 1, + 1, + 1, + 1 + ); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.bezierCurveTo") ); - expect(function() { - doc.context2d.bezierCurveTo(1, "invalid", 1, 1, 1, 1); + expect(function () { + doc.context2d.bezierCurveTo( + 1, + "invalid" as unknown as number, + 1, + 1, + 1, + 1 + ); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.bezierCurveTo") ); - expect(function() { - doc.context2d.bezierCurveTo(1, 1, "invalid", 1, 1, 1); + expect(function () { + doc.context2d.bezierCurveTo( + 1, + 1, + "invalid" as unknown as number, + 1, + 1, + 1 + ); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.bezierCurveTo") ); - expect(function() { - doc.context2d.bezierCurveTo(1, 1, 1, "invalid", 1, 1); + expect(function () { + doc.context2d.bezierCurveTo( + 1, + 1, + 1, + "invalid" as unknown as number, + 1, + 1 + ); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.bezierCurveTo") ); - expect(function() { - doc.context2d.bezierCurveTo(1, 1, 1, 1, "invalid", 1); + expect(function () { + doc.context2d.bezierCurveTo( + 1, + 1, + 1, + 1, + "invalid" as unknown as number, + 1 + ); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.bezierCurveTo") ); - expect(function() { - doc.context2d.bezierCurveTo(1, 1, 1, 1, 1, "invalid"); + expect(function () { + doc.context2d.bezierCurveTo( + 1, + 1, + 1, + 1, + 1, + "invalid" as unknown as number + ); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.bezierCurveTo") ); @@ -116,28 +168,65 @@ describe("Module: Context2D Input Validation", () => { it("context2d: arc", () => { var doc = new jsPDF(); - expect(function() { - doc.context2d.arc(1, 1, 1, 1, 1, 1); + // Deliberately mistyped arguments (cast through unknown) to assert the + // runtime input validation throws. + expect(function () { + doc.context2d.arc(1, 1, 1, 1, 1, 1 as unknown as boolean); }).not.toThrow( new Error("Invalid arguments passed to jsPDF.context2d.arc") ); - expect(function() { - doc.context2d.arc("invalid", 1, 1, 1, 1, 1); + expect(function () { + doc.context2d.arc( + "invalid" as unknown as number, + 1, + 1, + 1, + 1, + 1 as unknown as boolean + ); }).toThrow(new Error("Invalid arguments passed to jsPDF.context2d.arc")); - expect(function() { - doc.context2d.arc(1, "invalid", 1, 1, 1, 1); + expect(function () { + doc.context2d.arc( + 1, + "invalid" as unknown as number, + 1, + 1, + 1, + 1 as unknown as boolean + ); }).toThrow(new Error("Invalid arguments passed to jsPDF.context2d.arc")); - expect(function() { - doc.context2d.arc(1, 1, "invalid", 1, 1, 1); + expect(function () { + doc.context2d.arc( + 1, + 1, + "invalid" as unknown as number, + 1, + 1, + 1 as unknown as boolean + ); }).toThrow(new Error("Invalid arguments passed to jsPDF.context2d.arc")); - expect(function() { - doc.context2d.arc(1, 1, 1, "invalid", 1, 1); + expect(function () { + doc.context2d.arc( + 1, + 1, + 1, + "invalid" as unknown as number, + 1, + 1 as unknown as boolean + ); }).toThrow(new Error("Invalid arguments passed to jsPDF.context2d.arc")); - expect(function() { - doc.context2d.arc(1, 1, 1, 1, "invalid", 1); + expect(function () { + doc.context2d.arc( + 1, + 1, + 1, + 1, + "invalid" as unknown as number, + 1 as unknown as boolean + ); }).toThrow(new Error("Invalid arguments passed to jsPDF.context2d.arc")); - expect(function() { - doc.context2d.arc(1, 1, 1, 1, 1, "invalid"); + expect(function () { + doc.context2d.arc(1, 1, 1, 1, 1, "invalid" as unknown as boolean); }).not.toThrow( new Error("Invalid arguments passed to jsPDF.context2d.arc") ); @@ -145,49 +234,53 @@ describe("Module: Context2D Input Validation", () => { it("context2d: rect", () => { var doc = new jsPDF(); - expect(function() { + // Deliberately mistyped arguments (cast through unknown) to assert the + // runtime input validation throws. + expect(function () { doc.context2d.rect(1, 1, 1, 1); }).not.toThrow( new Error("Invalid arguments passed to jsPDF.context2d.rect") ); - expect(function() { - doc.context2d.rect("invalid", 1, 1, 1); + expect(function () { + doc.context2d.rect("invalid" as unknown as number, 1, 1, 1); }).toThrow(new Error("Invalid arguments passed to jsPDF.context2d.rect")); - expect(function() { - doc.context2d.rect(1, "invalid", 1, 1); + expect(function () { + doc.context2d.rect(1, "invalid" as unknown as number, 1, 1); }).toThrow(new Error("Invalid arguments passed to jsPDF.context2d.rect")); - expect(function() { - doc.context2d.rect(1, 1, "invalid", 1); + expect(function () { + doc.context2d.rect(1, 1, "invalid" as unknown as number, 1); }).toThrow(new Error("Invalid arguments passed to jsPDF.context2d.rect")); - expect(function() { - doc.context2d.rect(1, 1, 1, "invalid"); + expect(function () { + doc.context2d.rect(1, 1, 1, "invalid" as unknown as number); }).toThrow(new Error("Invalid arguments passed to jsPDF.context2d.rect")); }); it("context2d: fillRect", () => { var doc = new jsPDF(); - expect(function() { + // Deliberately mistyped arguments (cast through unknown) to assert the + // runtime input validation throws. + expect(function () { doc.context2d.fillRect(1, 1, 1, 1); }).not.toThrow( new Error("Invalid arguments passed to jsPDF.context2d.fillRect") ); - expect(function() { - doc.context2d.fillRect("invalid", 1, 1, 1); + expect(function () { + doc.context2d.fillRect("invalid" as unknown as number, 1, 1, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.fillRect") ); - expect(function() { - doc.context2d.fillRect(1, "invalid", 1, 1); + expect(function () { + doc.context2d.fillRect(1, "invalid" as unknown as number, 1, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.fillRect") ); - expect(function() { - doc.context2d.fillRect(1, 1, "invalid", 1); + expect(function () { + doc.context2d.fillRect(1, 1, "invalid" as unknown as number, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.fillRect") ); - expect(function() { - doc.context2d.fillRect(1, 1, 1, "invalid"); + expect(function () { + doc.context2d.fillRect(1, 1, 1, "invalid" as unknown as number); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.fillRect") ); @@ -195,28 +288,30 @@ describe("Module: Context2D Input Validation", () => { it("context2d: strokeRect", () => { var doc = new jsPDF(); - expect(function() { + // Deliberately mistyped arguments (cast through unknown) to assert the + // runtime input validation throws. + expect(function () { doc.context2d.strokeRect(1, 1, 1, 1); }).not.toThrow( new Error("Invalid arguments passed to jsPDF.context2d.strokeRect") ); - expect(function() { - doc.context2d.strokeRect("invalid", 1, 1, 1); + expect(function () { + doc.context2d.strokeRect("invalid" as unknown as number, 1, 1, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.strokeRect") ); - expect(function() { - doc.context2d.strokeRect(1, "invalid", 1, 1); + expect(function () { + doc.context2d.strokeRect(1, "invalid" as unknown as number, 1, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.strokeRect") ); - expect(function() { - doc.context2d.strokeRect(1, 1, "invalid", 1); + expect(function () { + doc.context2d.strokeRect(1, 1, "invalid" as unknown as number, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.strokeRect") ); - expect(function() { - doc.context2d.strokeRect(1, 1, 1, "invalid"); + expect(function () { + doc.context2d.strokeRect(1, 1, 1, "invalid" as unknown as number); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.strokeRect") ); @@ -224,28 +319,30 @@ describe("Module: Context2D Input Validation", () => { it("context2d: clearRect", () => { var doc = new jsPDF(); - expect(function() { + // Deliberately mistyped arguments (cast through unknown) to assert the + // runtime input validation throws. + expect(function () { doc.context2d.clearRect(1, 1, 1, 1); }).not.toThrow( new Error("Invalid arguments passed to jsPDF.context2d.clearRect") ); - expect(function() { - doc.context2d.clearRect("invalid", 1, 1, 1); + expect(function () { + doc.context2d.clearRect("invalid" as unknown as number, 1, 1, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.clearRect") ); - expect(function() { - doc.context2d.clearRect(1, "invalid", 1, 1); + expect(function () { + doc.context2d.clearRect(1, "invalid" as unknown as number, 1, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.clearRect") ); - expect(function() { - doc.context2d.clearRect(1, 1, "invalid", 1); + expect(function () { + doc.context2d.clearRect(1, 1, "invalid" as unknown as number, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.clearRect") ); - expect(function() { - doc.context2d.clearRect(1, 1, 1, "invalid"); + expect(function () { + doc.context2d.clearRect(1, 1, 1, "invalid" as unknown as number); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.clearRect") ); @@ -256,23 +353,25 @@ describe("Module: Context2D Input Validation", () => { it("context2d: fillText", () => { var doc = new jsPDF(); - expect(function() { + // Deliberately mistyped arguments (cast through unknown) to assert the + // runtime input validation throws. + expect(function () { doc.context2d.fillText("valid", 1, 1, 1); }).not.toThrow( new Error("Invalid arguments passed to jsPDF.context2d.fillText") ); - expect(function() { - doc.context2d.fillText(false, 1, 1, 1); + expect(function () { + doc.context2d.fillText(false as unknown as string, 1, 1, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.fillText") ); - expect(function() { - doc.context2d.fillText("valid", "invalid", 1, 1); + expect(function () { + doc.context2d.fillText("valid", "invalid" as unknown as number, 1, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.fillText") ); - expect(function() { - doc.context2d.fillText("valid", 1, "invalid", 1); + expect(function () { + doc.context2d.fillText("valid", 1, "invalid" as unknown as number, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.fillText") ); @@ -280,23 +379,25 @@ describe("Module: Context2D Input Validation", () => { it("context2d: strokeText", () => { var doc = new jsPDF(); - expect(function() { + // Deliberately mistyped arguments (cast through unknown) to assert the + // runtime input validation throws. + expect(function () { doc.context2d.strokeText("valid", 1, 1, 1); }).not.toThrow( new Error("Invalid arguments passed to jsPDF.context2d.strokeText") ); - expect(function() { - doc.context2d.strokeText(false, 1, 1, 1); + expect(function () { + doc.context2d.strokeText(false as unknown as string, 1, 1, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.strokeText") ); - expect(function() { - doc.context2d.strokeText("valid", "invalid", 1, 1); + expect(function () { + doc.context2d.strokeText("valid", "invalid" as unknown as number, 1, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.strokeText") ); - expect(function() { - doc.context2d.strokeText("valid", 1, "invalid", 1); + expect(function () { + doc.context2d.strokeText("valid", 1, "invalid" as unknown as number, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.strokeText") ); @@ -304,13 +405,15 @@ describe("Module: Context2D Input Validation", () => { it("context2d: measureText", () => { var doc = new jsPDF(); - expect(function() { + // Deliberately mistyped arguments (cast through unknown) to assert the + // runtime input validation throws. + expect(function () { doc.context2d.measureText("valid"); }).not.toThrow( new Error("Invalid arguments passed to jsPDF.context2d.measureText") ); - expect(function() { - doc.context2d.measureText(false); + expect(function () { + doc.context2d.measureText(false as unknown as string); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.measureText") ); @@ -318,45 +421,51 @@ describe("Module: Context2D Input Validation", () => { it("context2d: scale", () => { var doc = new jsPDF(); - expect(function() { + // Deliberately mistyped arguments (cast through unknown) to assert the + // runtime input validation throws. + expect(function () { doc.context2d.scale(1, 1); }).not.toThrow( new Error("Invalid arguments passed to jsPDF.context2d.scale") ); - expect(function() { - doc.context2d.scale("invalid", 1); + expect(function () { + doc.context2d.scale("invalid" as unknown as number, 1); }).toThrow(new Error("Invalid arguments passed to jsPDF.context2d.scale")); - expect(function() { - doc.context2d.scale(1, "invalid"); + expect(function () { + doc.context2d.scale(1, "invalid" as unknown as number); }).toThrow(new Error("Invalid arguments passed to jsPDF.context2d.scale")); }); it("context2d: rotate", () => { var doc = new jsPDF(); - expect(function() { + // Deliberately mistyped arguments (cast through unknown) to assert the + // runtime input validation throws. + expect(function () { doc.context2d.rotate(1); }).not.toThrow( new Error("Invalid arguments passed to jsPDF.context2d.rotate") ); - expect(function() { - doc.context2d.rotate("invalid"); + expect(function () { + doc.context2d.rotate("invalid" as unknown as number); }).toThrow(new Error("Invalid arguments passed to jsPDF.context2d.rotate")); }); it("context2d: translate", () => { var doc = new jsPDF(); - expect(function() { + // Deliberately mistyped arguments (cast through unknown) to assert the + // runtime input validation throws. + expect(function () { doc.context2d.translate(1, 1); }).not.toThrow( new Error("Invalid arguments passed to jsPDF.context2d.translate") ); - expect(function() { - doc.context2d.translate("invalid", 1); + expect(function () { + doc.context2d.translate("invalid" as unknown as number, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.translate") ); - expect(function() { - doc.context2d.translate(1, "invalid"); + expect(function () { + doc.context2d.translate(1, "invalid" as unknown as number); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.translate") ); @@ -364,38 +473,40 @@ describe("Module: Context2D Input Validation", () => { it("context2d: transform", () => { var doc = new jsPDF(); - expect(function() { + // Deliberately mistyped arguments (cast through unknown) to assert the + // runtime input validation throws. + expect(function () { doc.context2d.transform(1, 1, 1, 1, 1, 1); }).not.toThrow( new Error("Invalid arguments passed to jsPDF.context2d.transform") ); - expect(function() { - doc.context2d.transform("invalid", 1, 1, 1, 1, 1); + expect(function () { + doc.context2d.transform("invalid" as unknown as number, 1, 1, 1, 1, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.transform") ); - expect(function() { - doc.context2d.transform(1, "invalid", 1, 1, 1, 1); + expect(function () { + doc.context2d.transform(1, "invalid" as unknown as number, 1, 1, 1, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.transform") ); - expect(function() { - doc.context2d.transform(1, 1, "invalid", 1, 1, 1); + expect(function () { + doc.context2d.transform(1, 1, "invalid" as unknown as number, 1, 1, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.transform") ); - expect(function() { - doc.context2d.transform(1, 1, 1, "invalid", 1, 1); + expect(function () { + doc.context2d.transform(1, 1, 1, "invalid" as unknown as number, 1, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.transform") ); - expect(function() { - doc.context2d.transform(1, 1, 1, 1, "invalid", 1); + expect(function () { + doc.context2d.transform(1, 1, 1, 1, "invalid" as unknown as number, 1); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.transform") ); - expect(function() { - doc.context2d.transform(1, 1, 1, 1, 1, "invalid"); + expect(function () { + doc.context2d.transform(1, 1, 1, 1, 1, "invalid" as unknown as number); }).toThrow( new Error("Invalid arguments passed to jsPDF.context2d.transform") ); @@ -403,7 +514,7 @@ describe("Module: Context2D Input Validation", () => { it("context2d: toDataURL", () => { var doc = new jsPDF(); - expect(function() { + expect(function () { doc.context2d.toDataURL(); }).toThrow(new Error("toDataUrl not implemented.")); }); diff --git a/test/specs/context2d.likeARealOne.spec.js b/test/specs/context2d.likeARealOne.spec.ts similarity index 77% rename from test/specs/context2d.likeARealOne.spec.js rename to test/specs/context2d.likeARealOne.spec.ts index 01e19649a..4b5c65d5a 100644 --- a/test/specs/context2d.likeARealOne.spec.js +++ b/test/specs/context2d.likeARealOne.spec.ts @@ -8,7 +8,12 @@ describe("Module: Context2D: HTML comparison tests", () => { xit("default values like a real 2d-context", () => { var doc = new jsPDF(); - var ctx = doc.canvas.getContext("2d"); + // This skipped wishlist test asserts real-browser CanvasRenderingContext2D + // defaults that jsPDF's context2d does not implement (filter, shadows, + // image smoothing); type it as the real thing to keep the assertions. + var ctx = doc.canvas.getContext( + "2d" + ) as unknown as CanvasRenderingContext2D; expect(ctx.fillStyle).toEqual("#000000"); expect(ctx.filter).toEqual("none"); diff --git a/test/specs/context2d.pageoverlap.spec.js b/test/specs/context2d.pageoverlap.spec.ts similarity index 98% rename from test/specs/context2d.pageoverlap.spec.js rename to test/specs/context2d.pageoverlap.spec.ts index 3328d0351..f48ae8b41 100644 --- a/test/specs/context2d.pageoverlap.spec.js +++ b/test/specs/context2d.pageoverlap.spec.ts @@ -11,7 +11,7 @@ describe("Module: Context2D autoPaging", () => { var ctx = doc.context2d; doc.context2d.autoPaging = true; - var writeArray = []; + var writeArray: string[] = []; doc.__private__.setCustomOutputDestination(writeArray); ctx.strokeStyle = "#FF0000"; ctx.strokeRect(20, 20, 150, 3000); @@ -167,7 +167,7 @@ describe("Module: Context2D autoPaging", () => { var ctx = doc.context2d; doc.context2d.autoPaging = true; - var writeArray = []; + var writeArray: string[] = []; doc.__private__.setCustomOutputDestination(writeArray); ctx.fillText("test", 0, 1000); diff --git a/test/specs/context2d.spec.js b/test/specs/context2d.spec.ts similarity index 99% rename from test/specs/context2d.spec.js rename to test/specs/context2d.spec.ts index 8ed45ba38..ca07a5ae2 100644 --- a/test/specs/context2d.spec.js +++ b/test/specs/context2d.spec.ts @@ -338,10 +338,12 @@ describe("Context2D: standard tests", () => { }); it("context2d: arc", () => { + // The extra positional arguments are ignored at runtime when an options + // object is passed; kept verbatim and cast to the legacy signature. var doc = new jsPDF( { floatPrecision: 2 - }, + } as unknown as string, "pt", "a4" ); @@ -725,7 +727,7 @@ describe("Context2D: standard tests", () => { floatPrecision: 3 }); var ctx = doc.context2d; - var writeArray = []; + var writeArray: string[] = []; doc.__private__.setCustomOutputDestination(writeArray); ctx.beginPath(); @@ -749,7 +751,9 @@ describe("Context2D: standard tests", () => { const doc = new jsPDF(); const ctx = doc.context2d; expect(ctx.margin).toEqual([0, 0, 0, 0]); - ctx.margin = 1; + // The margin setter accepts a bare-number shorthand at runtime and + // normalizes it to [n, n, n, n]; the declared property type is number[]. + ctx.margin = 1 as unknown as number[]; expect(ctx.margin).toEqual([1, 1, 1, 1]); ctx.margin = [1]; expect(ctx.margin).toEqual([1, 1, 1, 1]); diff --git a/test/specs/context2d.w3school.spec.js b/test/specs/context2d.w3school.spec.ts similarity index 100% rename from test/specs/context2d.w3school.spec.js rename to test/specs/context2d.w3school.spec.ts diff --git a/test/specs/display-mode.spec.js b/test/specs/display-mode.spec.ts similarity index 96% rename from test/specs/display-mode.spec.js rename to test/specs/display-mode.spec.ts index adfa9f0e5..547c14595 100644 --- a/test/specs/display-mode.spec.js +++ b/test/specs/display-mode.spec.ts @@ -164,7 +164,9 @@ describe("Core: Display modes", () => { it("should throw an error for invalid page modes", () => { const doc = new jsPDF({ floatPrecision: 2 }); expect(() => { - doc.setDisplayMode(null, null, "MadeUp"); + // Deliberately invalid page mode (cast through unknown) to assert the + // runtime validation throws. + doc.setDisplayMode(null, null, "MadeUp" as unknown as "FullScreen"); }).toThrow( new Error( `Page mode must be one of UseNone, UseOutlines, UseThumbs, or FullScreen. "MadeUp" is not recognized.` diff --git a/test/specs/encryption.spec.js b/test/specs/encryption.spec.ts similarity index 96% rename from test/specs/encryption.spec.js rename to test/specs/encryption.spec.ts index 668503095..399a593e8 100644 --- a/test/specs/encryption.spec.js +++ b/test/specs/encryption.spec.ts @@ -52,7 +52,9 @@ describe("Core: Standard Encryption", () => { PasswordField, RadioButton, Appearance - } = jsPDF.AcroForm; + // jsPDF.AcroForm is attached at runtime by the acroform module but is + // not declared on the typed constructor. + } = (jsPDF as unknown as { AcroForm: typeof AcroForm }).AcroForm; doc.setFontSize(12); doc.text("ComboBox:", 10, 105); diff --git a/test/specs/fileloading.spec.js b/test/specs/fileloading.spec.ts similarity index 84% rename from test/specs/fileloading.spec.js rename to test/specs/fileloading.spec.ts index 7ef40fab7..ee1dc152f 100644 --- a/test/specs/fileloading.spec.js +++ b/test/specs/fileloading.spec.ts @@ -1,5 +1,13 @@ /* global describe, it, jsPDF, expect */ +/** + * Minimal view of Node's `process` used by the Node-only specs below + * (@types/node is not part of the test compilation). + */ +declare const process: { + permission?: { has(perm: string, url?: string): boolean }; +}; + describe("Module: FileLoad", () => { beforeAll(loadGlobals); var successURL = @@ -29,10 +37,13 @@ describe("Module: FileLoad", () => { if (typeof isNode !== "undefined" && isNode) { doc.allowFsRead = [successURL]; } - doc.loadFile(successURL, false, function(data) { + // The declared callback type requires a string return, but the runtime + // ignores the callback's return value (LoadFileCallback in + // src/modules/fileloading.ts), so the void callback is safe. + doc.loadFile(successURL, false, function (data?: string) { expect(data).toEqual("success"); done(); - }); + } as unknown as (data: string) => string); }); it("should fail to load a file (async)", done => { @@ -40,10 +51,11 @@ describe("Module: FileLoad", () => { if (typeof isNode !== "undefined" && isNode) { doc.allowFsRead = ["fail.txt"]; } - doc.loadFile("fail.txt", false, function(data) { + // See the cast note in the async success spec above. + doc.loadFile("fail.txt", false, function (data?: string) { expect(data).toEqual(undefined); done(); - }); + } as unknown as (data: string) => string); }); }); @@ -52,7 +64,7 @@ if (typeof isNode !== "undefined" && isNode) { describe("Module: FileLoad (Node permissions)", () => { const absSuccess = path.resolve("./test/reference/success.txt"); - let originalPermission; + let originalPermission: typeof process.permission; beforeEach(() => { originalPermission = process.permission; diff --git a/test/specs/filetypeRecognition.spec.js b/test/specs/filetypeRecognition.spec.ts similarity index 99% rename from test/specs/filetypeRecognition.spec.js rename to test/specs/filetypeRecognition.spec.ts index 11f4f03e8..9945c10e5 100644 --- a/test/specs/filetypeRecognition.spec.js +++ b/test/specs/filetypeRecognition.spec.ts @@ -122,7 +122,9 @@ describe("Module: addimage filetypeRecognition", () => { jsPDF.API.__addimage__.getImageFileTypeByImageData( jsPDF.API.__addimage__.convertBase64ToBinaryString( invalidImage, - "UNKNOWN" + // Deliberately mistyped second argument (throwError is a boolean at + // runtime); kept verbatim from the original spec. + "UNKNOWN" as unknown as boolean ) ) ).toEqual("UNKNOWN"); @@ -132,7 +134,7 @@ describe("Module: addimage filetypeRecognition", () => { ) ).toEqual("UNKNOWN"); var tmpConsoleWarn = console.warn; - console.warn = function() {}; + console.warn = function () {}; expect( jsPDF.API.__addimage__.getImageFileTypeByImageData( jsPDF.API.__addimage__.convertBase64ToBinaryString(invalidImage), diff --git a/test/specs/filters.spec.js b/test/specs/filters.spec.ts similarity index 100% rename from test/specs/filters.spec.js rename to test/specs/filters.spec.ts diff --git a/test/specs/fontmetrics.spec.js b/test/specs/fontmetrics.spec.ts similarity index 93% rename from test/specs/fontmetrics.spec.js rename to test/specs/fontmetrics.spec.ts index 1bfb253eb..b24f5c712 100644 --- a/test/specs/fontmetrics.spec.js +++ b/test/specs/fontmetrics.spec.ts @@ -10,15 +10,17 @@ describe("Module: Standard Font Metrics", () => { ).toEqual({ widths: { 0: 60, fof: 100 }, kerning: { fof: -100 } }); }); it("uncompress fail", () => { - expect(function() { + expect(function () { + // Deliberately invalid: uncompress expects a string (negative test). jsPDF.API.__fontmetrics__.uncompress({ widths: { 0: 60, fof: 100 }, kerning: { fof: -100 } - }); + } as unknown as string); }).toThrow(new Error("Invalid argument passed to uncompress.")); - expect(function() { + expect(function () { jsPDF.API.__fontmetrics__.compress({ - widths: "invalid", + // Deliberately invalid value type (negative test). + widths: "invalid" as unknown as number, kerning: { fof: -100 } }); }).toThrow(new Error("Don't know what to do with value type string.")); diff --git a/test/specs/fontstyle.spec.js b/test/specs/fontstyle.spec.ts similarity index 100% rename from test/specs/fontstyle.spec.js rename to test/specs/fontstyle.spec.ts diff --git a/test/specs/form-objects.spec.js b/test/specs/form-objects.spec.ts similarity index 100% rename from test/specs/form-objects.spec.js rename to test/specs/form-objects.spec.ts diff --git a/test/specs/getImageProperties.spec.js b/test/specs/getImageProperties.spec.ts similarity index 100% rename from test/specs/getImageProperties.spec.js rename to test/specs/getImageProperties.spec.ts diff --git a/test/specs/gif.spec.js b/test/specs/gif.spec.ts similarity index 100% rename from test/specs/gif.spec.js rename to test/specs/gif.spec.ts diff --git a/test/specs/html.spec.js b/test/specs/html.spec.ts similarity index 92% rename from test/specs/html.spec.js rename to test/specs/html.spec.ts index 6cb94df4d..65c2ad461 100644 --- a/test/specs/html.spec.js +++ b/test/specs/html.spec.ts @@ -1,13 +1,23 @@ /* global describe, it, jsPDF, comparePdf */ -const render = (markup, opts = {}) => - new Promise(resolve => { +/** Options forwarded to doc.html(); subset of the html plugin's options. */ +interface RenderOptions { + width?: number; + windowWidth?: number; + html2canvas?: { scale?: number }; + fontFaces?: import("../../src/libs/fontFace.js").FontFaceInput[]; +} + +const render = (markup: string, opts: RenderOptions = {}) => + new Promise>(resolve => { const doc = jsPDF({ floatPrecision: 2 }); doc.html(markup, { ...opts, callback: resolve }); }); -function toFontFaceRule(fontFace) { +function toFontFaceRule( + fontFace: import("../../src/libs/fontFace.js").FontFaceInput +) { const srcs = fontFace.src.map( src => `url('${src.url}') format('${src.format}')` ); @@ -277,7 +287,12 @@ describe("Module: html", () => { }); it("page break with image", async () => { - const doc = jsPDF({ floatPrecision: 2, unit: "pt", format: [100, 100], lineWidth: 1 }); + const doc = jsPDF({ + floatPrecision: 2, + unit: "pt", + format: [100, 100], + lineWidth: 1 + }); await new Promise(resolve => doc.html( '', @@ -317,9 +332,18 @@ describe("Module: html", () => { it("is able to render html multiple times", async () => { const doc = jsPDF({ floatPrecision: 2, unit: "pt" }); - await doc.html("
    ", { x: 30, y: 10 }); - await doc.html("
    ", { x: 50, y: 10 }); - await doc.html("
    ", { x: 10, y: 10 }); + await doc.html( + "
    ", + { x: 30, y: 10 } + ); + await doc.html( + "
    ", + { x: 50, y: 10 } + ); + await doc.html( + "
    ", + { x: 10, y: 10 } + ); comparePdf(doc.output(), "html-multiple.pdf", "html"); }); diff --git a/test/specs/init.spec.js b/test/specs/init.spec.ts similarity index 84% rename from test/specs/init.spec.js rename to test/specs/init.spec.ts index 70ba428a9..4be50d2a2 100644 --- a/test/specs/init.spec.js +++ b/test/specs/init.spec.ts @@ -8,7 +8,25 @@ describe("Core: Initialization Options", () => { beforeAll(loadGlobals); - var global = + + /** Minimal fake of the popup window handed back by the stubbed window.open. */ + interface FakePopupWindow { + document: Document; + PDFObject?: { embed: jasmine.Spy }; + } + + type JsPDFLegacyCtor = ( + orientation?: string, + unit?: string, + format?: string | number[], + compressPdf?: boolean + ) => ReturnType; + // Lazy: reads the jsPDF global at call time — in the Node run the global + // is only installed by loadGlobals() inside beforeAll, after module load. + const jsPDFLegacy: JsPDFLegacyCtor = (...args) => + (jsPDF as unknown as JsPDFLegacyCtor)(...args); + + var global: typeof globalThis & { isNode?: boolean } = (typeof self !== "undefined" && self) || (typeof window !== "undefined" && window) || (typeof global !== "undefined" && global) || @@ -88,7 +106,7 @@ describe("Core: Initialization Options", () => { }); if (global.isNode !== true) { - const createPopupWindow = () => { + const createPopupWindow = (): FakePopupWindow => { const popupDocument = document.implementation.createHTMLDocument(""); return { @@ -112,7 +130,7 @@ describe("Core: Initialization Options", () => { const popupWindow = createPopupWindow(); const payload = '">'; - spyOn(global, "open").and.returnValue(popupWindow); + spyOn(global, "open").and.returnValue(popupWindow as unknown as Window); doc.output("dataurlnewwindow", { filename: payload }); @@ -125,16 +143,17 @@ describe("Core: Initialization Options", () => { const doc = jsPDF(); const popupWindow = createPopupWindow(); const payload = '">'; - let viewerFrame; + let viewerFrame: HTMLIFrameElement; - spyOn(global, "open").and.returnValue(popupWindow); + spyOn(global, "open").and.returnValue(popupWindow as unknown as Window); doc.output("pdfjsnewwindow", { filename: payload, pdfJsUrl: "viewer.html" }); - viewerFrame = popupWindow.document.querySelector("#pdfViewer"); + viewerFrame = + popupWindow.document.querySelector("#pdfViewer"); Object.defineProperty(viewerFrame, "contentWindow", { value: { PDFViewerApplication: { @@ -143,13 +162,19 @@ describe("Core: Initialization Options", () => { } }); - viewerFrame.onload(); + // The onload handler assigned by jsPDF takes no arguments. + (viewerFrame.onload as unknown as () => void)(); expect(popupWindow.document.title).toEqual(payload); expect(popupWindow.document.querySelectorAll("script").length).toEqual(0); expect(viewerFrame.src).toContain(encodeURIComponent(payload)); expect( - viewerFrame.contentWindow.PDFViewerApplication.open + // contentWindow was stubbed above with a fake PDFViewerApplication. + ( + viewerFrame.contentWindow as unknown as { + PDFViewerApplication: { open: jasmine.Spy }; + } + ).PDFViewerApplication.open ).toHaveBeenCalled(); }); @@ -157,13 +182,13 @@ describe("Core: Initialization Options", () => { const doc = jsPDF(); const popupWindow = createPopupWindow(); const payload = ""; - let loaderScript; + let loaderScript: HTMLScriptElement; popupWindow.PDFObject = { embed: jasmine.createSpy("embed") }; - spyOn(global, "open").and.returnValue(popupWindow); + spyOn(global, "open").and.returnValue(popupWindow as unknown as Window); doc.output("pdfobjectnewwindow", { filename: payload, @@ -172,7 +197,8 @@ describe("Core: Initialization Options", () => { }); loaderScript = popupWindow.document.querySelector("script"); - loaderScript.onload(); + // The onload handler assigned by jsPDF takes no arguments. + (loaderScript.onload as unknown as () => void)(); expect(popupWindow.document.querySelectorAll("script").length).toEqual(1); expect(popupWindow.PDFObject.embed).toHaveBeenCalledWith( @@ -189,7 +215,7 @@ describe("Core: Initialization Options", () => { const popupWindow = createPopupWindow(); popupWindow.PDFObject = { embed: jasmine.createSpy("embed") }; - spyOn(global, "open").and.returnValue(popupWindow); + spyOn(global, "open").and.returnValue(popupWindow as unknown as Window); doc.output("pdfobjectnewwindow", { filename: "test.pdf" }); var loaderScript = popupWindow.document.querySelector("script"); @@ -202,7 +228,7 @@ describe("Core: Initialization Options", () => { const popupWindow = createPopupWindow(); popupWindow.PDFObject = { embed: jasmine.createSpy("embed") }; - spyOn(global, "open").and.returnValue(popupWindow); + spyOn(global, "open").and.returnValue(popupWindow as unknown as Window); doc.output("pdfobjectnewwindow", { filename: "test.pdf", @@ -227,7 +253,7 @@ describe("Core: Initialization Options", () => { const popupWindow = createPopupWindow(); const maliciousUrl = '" onload="alert(1)" data-x="'; - spyOn(global, "open").and.returnValue(popupWindow); + spyOn(global, "open").and.returnValue(popupWindow as unknown as Window); doc.output("pdfjsnewwindow", { filename: "test.pdf", @@ -243,7 +269,7 @@ describe("Core: Initialization Options", () => { }); } - const renderBoxes = doc => { + const renderBoxes = (doc: ReturnType) => { for (let i = 0; i < 100; i++) { doc.rect(0, 0, i, i); } @@ -329,18 +355,19 @@ describe("Core: Initialization Options", () => { it("should warn me about an invalid unit", () => { expect(() => { - jsPDF({ unit: "invalid" }); + // Deliberately invalid unit (negative test). + jsPDF({ unit: "invalid" as unknown as "mm" }); }).toThrow(new Error("Invalid unit: invalid")); }); it("should warn me about an invalid unit when passed as second argument", () => { expect(() => { - jsPDF("portrait", "invalid"); + jsPDFLegacy("portrait", "invalid"); }).toThrow(new Error("Invalid unit: invalid")); }); it("getCreationDate", () => { - const doc = jsPDF("portrait", "cm"); + const doc = jsPDFLegacy("portrait", "cm"); var creationDate = new Date(); doc.setCreationDate(creationDate); expect(doc.getCreationDate("jsDate").getFullYear()).toEqual( @@ -364,7 +391,7 @@ describe("Core: Initialization Options", () => { }); it("setCreationDate", () => { - const doc = jsPDF("portrait", "cm"); + const doc = jsPDFLegacy("portrait", "cm"); var creationDate = new Date(1987, 11, 10, 0, 0, 0); var pdfDateString = "D:19871210000000+00'00'"; doc.setCreationDate(pdfDateString); diff --git a/test/specs/japanese.spec.js b/test/specs/japanese.spec.ts similarity index 100% rename from test/specs/japanese.spec.js rename to test/specs/japanese.spec.ts diff --git a/test/specs/javascript.spec.js b/test/specs/javascript.spec.ts similarity index 100% rename from test/specs/javascript.spec.js rename to test/specs/javascript.spec.ts diff --git a/test/specs/jpeg.spec.js b/test/specs/jpeg.spec.ts similarity index 100% rename from test/specs/jpeg.spec.js rename to test/specs/jpeg.spec.ts diff --git a/test/specs/jspdf.unit.spec.js b/test/specs/jspdf.unit.spec.ts similarity index 64% rename from test/specs/jspdf.unit.spec.js rename to test/specs/jspdf.unit.spec.ts index 651cf8eff..b44cd8102 100644 --- a/test/specs/jspdf.unit.spec.js +++ b/test/specs/jspdf.unit.spec.ts @@ -8,78 +8,329 @@ describe("Core: Unit Tests", () => { beforeAll(loadGlobals); - var global = - (typeof self !== "undefined" && self) || + var global = ((typeof self !== "undefined" && self) || (typeof window !== "undefined" && window) || (typeof global !== "undefined" && global) || Function('return typeof this === "object" && this.content')() || - Function("return this")(); + Function("return this")()) as unknown as typeof globalThis & { + isNode?: boolean; + }; + + type TestDoc = ReturnType; + type PubSubInterface = import("../../src/types.js").PubSubInterface; + type PubSubCallback = import("../../src/types.js").PubSubCallback; + /** Deliberately invalid coordinate/dimension inputs are part of the spec. */ + type LooseNumber = number | string; + + /** Options bag accepted by the private `text` implementation. */ + interface TestTextOptions { + scope?: TestDoc; + angle?: number; + charSpace?: number; + R2L?: boolean; + renderingMode?: string | number | boolean; + align?: string; + maxWidth?: number; + } + + /** + * `getCurrentPageInfo` result; `pageContext` is left open because plugins + * (e.g. annotations) add members to it at runtime. + */ + interface TestPageInfo { + objId: number; + pageNumber: number; + pageContext: Record; + } + + /** + * Typed view of the internal `__private__` surface. + * + * src/types.ts declares jsPDFPrivate with an `[member: string]: unknown` + * index signature, so calling through `priv(doc)` directly is not + * type-safe. These specs exercise the concrete private helpers, so the + * members under test are re-declared here with their real signatures + * (mirroring the `API.__private__` assignments in src/jspdf.ts). Where the + * runtime is deliberately lenient (legacy argument orders, coercion, + * invalid-input guards under test), the parameter types reflect that + * leniency instead of the narrower source annotations. + */ + interface PrivateSurface { + PubSub: new (context: unknown) => PubSubInterface; + getPdfVersion(): string; + setPdfVersion(value: string): void; + getPageFormats(): Record; + getPageFormat(value: string): number[]; + f2(number: LooseNumber): string; + f3(number: LooseNumber): string; + roundToPrecision(number: LooseNumber, parmPrecision?: number): string; + scale(number: LooseNumber): number; + getFileId(): string; + setFileId(value?: string): string; + setCreationDate(date?: Date | string): string; + getCreationDate(type: "jsDate"): Date; + getCreationDate(type?: string): Date | string; + padd2(number: LooseNumber): string; + // Declared as string in src/jspdf.ts; the runtime coerces via toString + // and the spec exercises numeric input. + padd2Hex(hexString: LooseNumber): string; + setCustomOutputDestination(destination: string[]): void; + resetCustomOutputDestination(): void; + out(string: string | number): string[]; + write(value: string | number, ...rest: Array): string[]; + getArrayBuffer(data: string): ArrayBuffer; + getStandardFonts(): Array>; + getFontList(): Record; + getCharSpace(): number; + setCharSpace(charSpace: LooseNumber): unknown; + getLineWidth(): number; + setLineWidth(width: number): unknown; + setLineDash( + dashArray?: number[] | string, + dashPhase?: LooseNumber + ): unknown; + getLineHeight(): number; + setLineHeightFactor(value: number): unknown; + getHorizontalCoordinateString(value: number): string; + getVerticalCoordinateString(value: number): string; + getR2L(): boolean; + setZoomMode(zoom: string | number): void; + getZoomMode(): string | number; + setPageMode(pmode: string): void; + getPageMode(): string; + setLayoutMode(layout: string): void; + getLayoutMode(): string; + setDisplayMode( + zoom: string | number, + layout?: string, + pmode?: string + ): unknown; + getTextColor(): string; + setTextColor( + ch1: LooseNumber, + ch2?: LooseNumber, + ch3?: LooseNumber, + ch4?: LooseNumber + ): unknown; + getFillColor(): string; + setFillColor( + ch1: LooseNumber, + ch2?: LooseNumber, + ch3?: LooseNumber, + ch4?: LooseNumber + ): unknown; + getStrokeColor(): string; + setStrokeColor( + ch1: LooseNumber, + ch2?: LooseNumber, + ch3?: LooseNumber, + ch4?: LooseNumber + ): unknown; + encodeColorString: import("../../src/types.js").jsPDFPrivate["encodeColorString"]; + decodeColorString(color: string): string; + getDocumentProperty(key: string): string; + setDocumentProperty(key: string, value: string): string; + getDocumentProperties(): Record; + setDocumentProperties(properties: Record): unknown; + isValidStyle(style?: string | null): boolean; + getStyle(style: string): string; + newObject(): number; + newObjectDeferred(): number; + newAdditionalObject(): { objId: number; content: string }; + pdfEscape(text: string): string; + getNumberOfPages(): number; + getCurrentPageInfo(): TestPageInfo; + getFilters(): string | string[]; + putStream(options?: { + data?: string; + filters?: string[] | boolean; + alreadyAppliedFilters?: string[] | string; + addLength1?: boolean; + objectId?: number; + }): void; + putPage(page: { + number: number; + data: string[]; + mediaBox: { + bottomLeftX: number; + bottomLeftY: number; + topRightX: number; + topRightY: number; + }; + artBox: null; + bleedBox: null; + cropBox: null; + trimBox: null; + userUnit: number; + resourceDictionaryObjId: number; + rootDictionaryObjId: number; + objId: number; + contentsObjId: number; + }): number; + putCatalog(options?: { rootDictionaryObjId?: number }): void; + putInfo(): void; + putTrailer(): void; + putHeader(): void; + putXRef(): void; + buildDocument(): string; + getBlob(data: string): Blob; + output( + type?: string, + options?: string | Record + ): string | ArrayBuffer | Blob | null; + clip(rule?: string): unknown; + discardPath(): unknown; + // text/lines accept both the current and the legacy argument order. + text( + text?: string | string[] | number, + x?: LooseNumber, + y?: LooseNumber, + options?: TestTextOptions, + transform?: number + ): unknown; + line( + x1: LooseNumber, + y1: LooseNumber, + x2: LooseNumber, + y2: LooseNumber, + style?: string | null + ): unknown; + lines( + lines?: number[][] | number | string, + x?: LooseNumber, + y?: LooseNumber | number[][], + scale?: number[] | string, + style?: string | null, + closed?: boolean | string + ): unknown; + rect( + x: LooseNumber, + y: LooseNumber, + w: LooseNumber, + h: LooseNumber, + style?: string | null + ): unknown; + triangle( + x1: LooseNumber, + y1: LooseNumber, + x2: LooseNumber, + y2: LooseNumber, + x3: LooseNumber, + y3: LooseNumber, + style?: string | null + ): unknown; + roundedRect( + x: LooseNumber, + y: LooseNumber, + w: LooseNumber, + h: LooseNumber, + rx: LooseNumber, + ry: LooseNumber, + style?: string | null + ): unknown; + ellipse( + x: LooseNumber, + y: LooseNumber, + rx: LooseNumber, + ry: LooseNumber, + style?: string | null + ): unknown; + circle( + x: LooseNumber, + y: LooseNumber, + r: LooseNumber, + style?: string | null + ): unknown; + setLineCap(style: string | number): unknown; + setLineJoin(style: string | number): unknown; + setLineMiterLimit(length: LooseNumber): unknown; + } + + /** Single documented cast from the loose jsPDFPrivate index signature. */ + const priv = (doc: TestDoc): PrivateSurface => + (doc as unknown as { __private__: PrivateSurface }).__private__; + + // jsPDF also supports the legacy positional (orientation, unit, format) + // call form at runtime; the declared TS signature only takes options. + type JsPDFLegacyCtor = ( + orientation?: string, + unit?: string, + format?: string + ) => TestDoc; + // Lazy: reads the jsPDF global at call time — in the Node run the global + // is only installed by loadGlobals() inside beforeAll, after module load. + const jsPDFLegacy: JsPDFLegacyCtor = (...args) => + (jsPDF as unknown as JsPDFLegacyCtor)(...args); + //PubSub-Functionality it("jsPDF PubSub basic check", () => { - new new jsPDF({ floatPrecision: 2 }).__private__.PubSub({}); - expect(typeof new jsPDF({ floatPrecision: 2 }).__private__.PubSub).toEqual( + new (priv(new jsPDF({ floatPrecision: 2 })).PubSub)({}); + expect(typeof priv(new jsPDF({ floatPrecision: 2 })).PubSub).toEqual( "function" ); - expect(function() { - new new jsPDF({ floatPrecision: 2 }).__private__.PubSub("invalid"); + expect(function () { + new (priv(new jsPDF({ floatPrecision: 2 })).PubSub)("invalid"); }).toThrow( new Error("Invalid Context passed to initialize PubSub (jsPDF-module)") ); }); it("jsPDF PubSub subscribe/subscribe", () => { - expect(typeof new jsPDF({ floatPrecision: 2 }).__private__.PubSub).toEqual( + expect(typeof priv(new jsPDF({ floatPrecision: 2 })).PubSub).toEqual( "function" ); - var pubSub; + var pubSub: PubSubInterface; var testContext = {}; - var token; - pubSub = new new jsPDF({ floatPrecision: 2 }).__private__.PubSub( - testContext - ); + var token: string; + pubSub = new (priv(new jsPDF({ floatPrecision: 2 })).PubSub)(testContext); - expect(function() { - pubSub.subscribe("testEvent", function() {}, true); + expect(function () { + pubSub.subscribe("testEvent", function () {}, true); }).not.toThrow( new Error("Invalid arguments passed to PubSub.subscribe (jsPDF-module)") ); - expect(function() { - pubSub.subscribe("testEvent", "invalid"); + expect(function () { + // deliberately invalid callback to exercise the runtime guard + pubSub.subscribe("testEvent", "invalid" as unknown as PubSubCallback); }).toThrow( new Error("Invalid arguments passed to PubSub.subscribe (jsPDF-module)") ); - expect(function() { - pubSub.subscribe(1, function() {}); + expect(function () { + // deliberately invalid topic to exercise the runtime guard + pubSub.subscribe(1 as unknown as string, function () {}); }).toThrow( new Error("Invalid arguments passed to PubSub.subscribe (jsPDF-module)") ); - expect(function() { - pubSub.subscribe("testEvent", function() {}, "invalid"); + expect(function () { + // deliberately invalid `once` flag to exercise the runtime guard + pubSub.subscribe( + "testEvent", + function () {}, + "invalid" as unknown as boolean + ); }).toThrow( new Error("Invalid arguments passed to PubSub.subscribe (jsPDF-module)") ); expect( - typeof pubSub.subscribe("testEvent", function() {}) === "string" + typeof pubSub.subscribe("testEvent", function () {}) === "string" ).toEqual(true); expect(Object.keys(pubSub.getTopics()).length).toEqual(1); //check token - expect(pubSub.subscribe("testEvent", function() {}).length > 0).toEqual( + expect(pubSub.subscribe("testEvent", function () {}).length > 0).toEqual( true ); testContext = {}; - pubSub = new new jsPDF({ floatPrecision: 2 }).__private__.PubSub( - testContext - ); - pubSub.subscribe("testEvent", function() {}); + pubSub = new (priv(new jsPDF({ floatPrecision: 2 })).PubSub)(testContext); + pubSub.subscribe("testEvent", function () {}); expect(Object.keys(pubSub.getTopics()).length).toEqual(1); - pubSub.subscribe("testEvent", function() {}); + pubSub.subscribe("testEvent", function () {}); expect(Object.keys(pubSub.getTopics()).length).toEqual(1); - token = pubSub.subscribe("testEvent2", function() {}); + token = pubSub.subscribe("testEvent2", function () {}); expect(Object.keys(pubSub.getTopics()).length).toEqual(2); pubSub.unsubscribe("invalid"); @@ -88,10 +339,10 @@ describe("Core: Unit Tests", () => { pubSub.unsubscribe(token); expect(Object.keys(pubSub.getTopics()).length).toEqual(1); - token = pubSub.subscribe("testEvent2", function() {}); + token = pubSub.subscribe("testEvent2", function () {}); expect(Object.keys(pubSub.getTopics()).length).toEqual(2); - token = pubSub.subscribe("testEvent2", function() {}); + token = pubSub.subscribe("testEvent2", function () {}); expect(Object.keys(pubSub.getTopics()).length).toEqual(2); pubSub.unsubscribe(token); @@ -100,26 +351,24 @@ describe("Core: Unit Tests", () => { //PubSub-Functionality it("jsPDF PubSub publish", () => { - var pubSub; + var pubSub: PubSubInterface; var testContext = { success: false, - testFunction: function() { + testFunction: function () { this.success = true; }, - malFunction: null + malFunction: null as (() => void) | null }; - var token; + var token: string; var originalConsole = console.error; var tmpErrorMessage = ""; - console.error = function(value) { + console.error = function (value) { tmpErrorMessage = value; }; - pubSub = new new jsPDF({ floatPrecision: 2 }).__private__.PubSub( - testContext - ); + pubSub = new (priv(new jsPDF({ floatPrecision: 2 })).PubSub)(testContext); - token = pubSub.subscribe("testEvent", function() { + token = pubSub.subscribe("testEvent", function (this: typeof testContext) { this.testFunction(); }); pubSub.publish("testEvent"); @@ -127,8 +376,9 @@ describe("Core: Unit Tests", () => { pubSub.unsubscribe(token); testContext.success = false; - token = pubSub.subscribe("testEvent", function() { - this.malFunction(); + token = pubSub.subscribe("testEvent", function (this: typeof testContext) { + // deliberately calls the null member to trigger the PubSub error path + this.malFunction!(); }); pubSub.publish("testEvent"); expect(tmpErrorMessage).toEqual("jsPDF PubSub Error"); @@ -138,7 +388,7 @@ describe("Core: Unit Tests", () => { testContext = { success: false, - testFunction: function() { + testFunction: function () { this.success = true; }, malFunction: null @@ -146,7 +396,7 @@ describe("Core: Unit Tests", () => { token = pubSub.subscribe( "testEvent", - function() { + function (this: typeof testContext) { this.testFunction(); }, true @@ -160,69 +410,67 @@ describe("Core: Unit Tests", () => { it("jsPDF internal/private function getPDFVersion", () => { const doc = new jsPDF({ floatPrecision: 2 }); expect(doc.internal.getPDFVersion()).toEqual("1.3"); - expect(doc.__private__.getPdfVersion()).toEqual("1.3"); + expect(priv(doc).getPdfVersion()).toEqual("1.3"); }); it("jsPDF private function setPDFVersion", () => { const doc = new jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.getPdfVersion()).toEqual("1.3"); - doc.__private__.setPdfVersion("1.5"); - expect(doc.__private__.getPdfVersion()).toEqual("1.5"); + expect(priv(doc).getPdfVersion()).toEqual("1.3"); + priv(doc).setPdfVersion("1.5"); + expect(priv(doc).getPdfVersion()).toEqual("1.5"); }); it("jsPDF private function getPageFormats", () => { const doc = new jsPDF({ floatPrecision: 2 }); - expect(Object.keys(doc.__private__.getPageFormats()).length).toEqual(41); + expect(Object.keys(priv(doc).getPageFormats()).length).toEqual(41); }); it("jsPDF private function getPageFormat", () => { const doc = new jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.getPageFormat("a4")[0]).toEqual(595.28); - expect(doc.__private__.getPageFormat("a4")[1]).toEqual(841.89); + expect(priv(doc).getPageFormat("a4")[0]).toEqual(595.28); + expect(priv(doc).getPageFormat("a4")[1]).toEqual(841.89); }); it("jsPDF private function f2", () => { const doc = new jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.f2(2.22222)).toEqual("2.22"); + expect(priv(doc).f2(2.22222)).toEqual("2.22"); - expect(function() { - doc.__private__.f2("invalid"); + expect(function () { + priv(doc).f2("invalid"); }).toThrow(new Error("Invalid argument passed to jsPDF.f2")); }); it("jsPDF private function roundToPrecision", () => { const doc = new jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.roundToPrecision(2.22222, 2)).toEqual("2.22"); + expect(priv(doc).roundToPrecision(2.22222, 2)).toEqual("2.22"); - expect(function() { - doc.__private__.roundToPrecision("invalid"); + expect(function () { + priv(doc).roundToPrecision("invalid"); }).toThrow(new Error("Invalid argument passed to jsPDF.roundToPrecision")); }); it("jsPDF private function scale", () => { const doc = new jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.scale(1)).toEqual(2.834645669291339); + expect(priv(doc).scale(1)).toEqual(2.834645669291339); - expect(function() { - doc.__private__.scale("invalid"); + expect(function () { + priv(doc).scale("invalid"); }).toThrow(new Error("Invalid argument passed to jsPDF.scale")); }); it("jsPDF private function f3", () => { const doc = new jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.f3(2.22222)).toEqual("2.222"); + expect(priv(doc).f3(2.22222)).toEqual("2.222"); - expect(function() { - doc.__private__.f3("invalid"); + expect(function () { + priv(doc).f3("invalid"); }).toThrow(new Error("Invalid argument passed to jsPDF.f3")); }); it("jsPDF private function getFileId, setFileId", () => { const doc = new jsPDF({ floatPrecision: 2 }); - doc.__private__.setFileId("0000000000000000000000000BADFACE"); - expect(doc.__private__.getFileId()).toEqual( - "0000000000000000000000000BADFACE" - ); + priv(doc).setFileId("0000000000000000000000000BADFACE"); + expect(priv(doc).getFileId()).toEqual("0000000000000000000000000BADFACE"); }); it("jsPDF public function getFileId, setFileId", () => { @@ -233,30 +481,31 @@ describe("Core: Unit Tests", () => { it("jsPDF private function getCreationDate", () => { const doc = jsPDF({ floatPrecision: 2 }); - var regexPDFCreationDate = /^D:(20[0-2][0-9]|203[0-7]|19[7-9][0-9])(0[0-9]|1[0-2])([0-2][0-9]|3[0-1])(0[0-9]|1[0-9]|2[0-3])(0[0-9]|[1-5][0-9])(0[0-9]|[1-5][0-9])(\+0[0-9]|\+1[0-4]|\-0[0-9]|\-1[0-1])\'(0[0-9]|[1-5][0-9])\'?$/; + var regexPDFCreationDate = + /^D:(20[0-2][0-9]|203[0-7]|19[7-9][0-9])(0[0-9]|1[0-2])([0-2][0-9]|3[0-1])(0[0-9]|1[0-9]|2[0-3])(0[0-9]|[1-5][0-9])(0[0-9]|[1-5][0-9])(\+0[0-9]|\+1[0-4]|\-0[0-9]|\-1[0-1])\'(0[0-9]|[1-5][0-9])\'?$/; - expect( - regexPDFCreationDate.test(doc.__private__.setCreationDate()) - ).toEqual(true); + expect(regexPDFCreationDate.test(priv(doc).setCreationDate())).toEqual( + true + ); var creationDate = new Date(); - doc.__private__.setCreationDate(creationDate); - expect(doc.__private__.getCreationDate("jsDate").getFullYear()).toEqual( + priv(doc).setCreationDate(creationDate); + expect(priv(doc).getCreationDate("jsDate").getFullYear()).toEqual( creationDate.getFullYear() ); - expect(doc.__private__.getCreationDate("jsDate").getMonth()).toEqual( + expect(priv(doc).getCreationDate("jsDate").getMonth()).toEqual( creationDate.getMonth() ); - expect(doc.__private__.getCreationDate("jsDate").getDate()).toEqual( + expect(priv(doc).getCreationDate("jsDate").getDate()).toEqual( creationDate.getDate() ); - expect(doc.__private__.getCreationDate("jsDate").getHours()).toEqual( + expect(priv(doc).getCreationDate("jsDate").getHours()).toEqual( creationDate.getHours() ); - expect(doc.__private__.getCreationDate("jsDate").getMinutes()).toEqual( + expect(priv(doc).getCreationDate("jsDate").getMinutes()).toEqual( creationDate.getMinutes() ); - expect(doc.__private__.getCreationDate("jsDate").getSeconds()).toEqual( + expect(priv(doc).getCreationDate("jsDate").getSeconds()).toEqual( creationDate.getSeconds() ); }); @@ -265,28 +514,28 @@ describe("Core: Unit Tests", () => { const doc = jsPDF({ floatPrecision: 2 }); var creationDate = new Date(1987, 11, 10, 0, 0, 0); var pdfDateString = "D:19871210000000+00'00'"; - doc.__private__.setCreationDate(pdfDateString); - expect(doc.__private__.getCreationDate("jsDate").getFullYear()).toEqual( + priv(doc).setCreationDate(pdfDateString); + expect(priv(doc).getCreationDate("jsDate").getFullYear()).toEqual( creationDate.getFullYear() ); - expect(doc.__private__.getCreationDate("jsDate").getMonth()).toEqual( + expect(priv(doc).getCreationDate("jsDate").getMonth()).toEqual( creationDate.getMonth() ); - expect(doc.__private__.getCreationDate("jsDate").getDate()).toEqual( + expect(priv(doc).getCreationDate("jsDate").getDate()).toEqual( creationDate.getDate() ); - expect(doc.__private__.getCreationDate("jsDate").getHours()).toEqual( + expect(priv(doc).getCreationDate("jsDate").getHours()).toEqual( creationDate.getHours() ); - expect(doc.__private__.getCreationDate("jsDate").getMinutes()).toEqual( + expect(priv(doc).getCreationDate("jsDate").getMinutes()).toEqual( creationDate.getMinutes() ); - expect(doc.__private__.getCreationDate("jsDate").getSeconds()).toEqual( + expect(priv(doc).getCreationDate("jsDate").getSeconds()).toEqual( creationDate.getSeconds() ); - expect(function() { - doc.__private__.setCreationDate("invalid"); + expect(function () { + priv(doc).setCreationDate("invalid"); }).toThrow(new Error("Invalid argument passed to jsPDF.setCreationDate")); }); @@ -294,22 +543,22 @@ describe("Core: Unit Tests", () => { const doc = jsPDF({ floatPrecision: 2 }); var creationDate = new Date(); doc.setCreationDate(creationDate); - expect(doc.getCreationDate("jsDate").getFullYear()).toEqual( + expect((doc.getCreationDate("jsDate") as Date).getFullYear()).toEqual( creationDate.getFullYear() ); - expect(doc.getCreationDate("jsDate").getMonth()).toEqual( + expect((doc.getCreationDate("jsDate") as Date).getMonth()).toEqual( creationDate.getMonth() ); - expect(doc.getCreationDate("jsDate").getDate()).toEqual( + expect((doc.getCreationDate("jsDate") as Date).getDate()).toEqual( creationDate.getDate() ); - expect(doc.getCreationDate("jsDate").getHours()).toEqual( + expect((doc.getCreationDate("jsDate") as Date).getHours()).toEqual( creationDate.getHours() ); - expect(doc.getCreationDate("jsDate").getMinutes()).toEqual( + expect((doc.getCreationDate("jsDate") as Date).getMinutes()).toEqual( creationDate.getMinutes() ); - expect(doc.getCreationDate("jsDate").getSeconds()).toEqual( + expect((doc.getCreationDate("jsDate") as Date).getSeconds()).toEqual( creationDate.getSeconds() ); }); @@ -319,65 +568,66 @@ describe("Core: Unit Tests", () => { var creationDate = new Date(1987, 11, 10, 0, 0, 0); var pdfDateString = "D:19871210000000+00'00'"; doc.setCreationDate(pdfDateString); - expect(doc.getCreationDate("jsDate").getFullYear()).toEqual( + expect((doc.getCreationDate("jsDate") as Date).getFullYear()).toEqual( creationDate.getFullYear() ); - expect(doc.getCreationDate("jsDate").getMonth()).toEqual( + expect((doc.getCreationDate("jsDate") as Date).getMonth()).toEqual( creationDate.getMonth() ); - expect(doc.getCreationDate("jsDate").getDate()).toEqual( + expect((doc.getCreationDate("jsDate") as Date).getDate()).toEqual( creationDate.getDate() ); - expect(doc.getCreationDate("jsDate").getHours()).toEqual( + expect((doc.getCreationDate("jsDate") as Date).getHours()).toEqual( creationDate.getHours() ); - expect(doc.getCreationDate("jsDate").getMinutes()).toEqual( + expect((doc.getCreationDate("jsDate") as Date).getMinutes()).toEqual( creationDate.getMinutes() ); - expect(doc.getCreationDate("jsDate").getSeconds()).toEqual( + expect((doc.getCreationDate("jsDate") as Date).getSeconds()).toEqual( creationDate.getSeconds() ); }); it("jsPDF private function padd2", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.padd2(2)).toEqual("02"); - expect(doc.__private__.padd2(23)).toEqual("23"); - expect(doc.__private__.padd2(234)).toEqual("34"); + expect(priv(doc).padd2(2)).toEqual("02"); + expect(priv(doc).padd2(23)).toEqual("23"); + expect(priv(doc).padd2(234)).toEqual("34"); }); it("jsPDF private function padd2Hex", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.padd2Hex(2)).toEqual("02"); - expect(doc.__private__.padd2Hex(23)).toEqual("23"); - expect(doc.__private__.padd2Hex(234)).toEqual("34"); + expect(priv(doc).padd2Hex(2)).toEqual("02"); + expect(priv(doc).padd2Hex(23)).toEqual("23"); + expect(priv(doc).padd2Hex(234)).toEqual("34"); }); it("jsPDF private function getFilters", () => { var doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.getFilters()).toEqual([]); - doc = jsPDF({ filters: "FlateEncode" }); - expect(doc.__private__.getFilters()).toEqual("FlateEncode"); + expect(priv(doc).getFilters()).toEqual([]); + // deliberately-lenient input: the runtime accepts a bare filter string + doc = jsPDF({ filters: "FlateEncode" as unknown as string[] }); + expect(priv(doc).getFilters()).toEqual("FlateEncode"); doc = jsPDF({ filters: ["FlateEncode"] }); - expect(doc.__private__.getFilters()).toEqual(["FlateEncode"]); + expect(priv(doc).getFilters()).toEqual(["FlateEncode"]); doc = jsPDF({ compress: true }); - expect(doc.__private__.getFilters()).toEqual(["FlateEncode"]); + expect(priv(doc).getFilters()).toEqual(["FlateEncode"]); doc = jsPDF({ compress: false }); - expect(doc.__private__.getFilters()).toEqual([]); + expect(priv(doc).getFilters()).toEqual([]); }); it("jsPDF private function newObject", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.newObject()).toEqual(3); - expect(doc.__private__.newObject()).toEqual(4); - expect(doc.__private__.newObject()).toEqual(5); + expect(priv(doc).newObject()).toEqual(3); + expect(priv(doc).newObject()).toEqual(4); + expect(priv(doc).newObject()).toEqual(5); }); it("jsPDF private function newAdditionalObject", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.newAdditionalObject()).toEqual({ + expect(priv(doc).newAdditionalObject()).toEqual({ objId: 3, content: "" }); @@ -386,72 +636,74 @@ describe("Core: Unit Tests", () => { it("jsPDF private function newObjectDeferred", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.newObjectDeferred()).toEqual(3); - expect(doc.__private__.newObjectDeferred()).toEqual(4); - expect(doc.__private__.newObjectDeferred()).toEqual(5); + expect(priv(doc).newObjectDeferred()).toEqual(3); + expect(priv(doc).newObjectDeferred()).toEqual(4); + expect(priv(doc).newObjectDeferred()).toEqual(5); }); it("jsPDF private function out", () => { const doc = jsPDF({ floatPrecision: 2 }); - var writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - writeArray = doc.__private__.out(2); + var writeArray: string[] = []; + priv(doc).setCustomOutputDestination(writeArray); + writeArray = priv(doc).out(2); expect(writeArray[0]).toEqual("2"); - doc.__private__.resetCustomOutputDestination(); + priv(doc).resetCustomOutputDestination(); }); it("jsPDF private function out", () => { const doc = jsPDF({ floatPrecision: 2 }); - var writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - writeArray = doc.__private__.out(2); + var writeArray: string[] = []; + priv(doc).setCustomOutputDestination(writeArray); + writeArray = priv(doc).out(2); expect(writeArray[0]).toEqual("2"); - doc.__private__.resetCustomOutputDestination(); + priv(doc).resetCustomOutputDestination(); }); it("jsPDF private function write", () => { var doc = jsPDF({ floatPrecision: 2 }); - var writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - writeArray = doc.__private__.write("test"); + var writeArray: string[] = []; + priv(doc).setCustomOutputDestination(writeArray); + writeArray = priv(doc).write("test"); expect(writeArray[0]).toEqual("test"); doc = jsPDF({ floatPrecision: 2 }); - var writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - writeArray = doc.__private__.write("test", "test2"); + var writeArray: string[] = []; + priv(doc).setCustomOutputDestination(writeArray); + writeArray = priv(doc).write("test", "test2"); expect(writeArray[0]).toEqual("test test2"); }); it("jsPDF private function pdfEscape", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.pdfEscape("Test")).toEqual("Test"); - expect(doc.__private__.pdfEscape("(Test")).toEqual("\\(Test"); - expect(doc.__private__.pdfEscape("(Test)")).toEqual("\\(Test\\)"); - expect(doc.__private__.pdfEscape("\\Test")).toEqual("\\\\Test"); - expect(doc.__private__.pdfEscape("\\(Test")).toEqual("\\\\\\(Test"); + expect(priv(doc).pdfEscape("Test")).toEqual("Test"); + expect(priv(doc).pdfEscape("(Test")).toEqual("\\(Test"); + expect(priv(doc).pdfEscape("(Test)")).toEqual("\\(Test\\)"); + expect(priv(doc).pdfEscape("\\Test")).toEqual("\\\\Test"); + expect(priv(doc).pdfEscape("\\(Test")).toEqual("\\\\\\(Test"); - doc.__private__.resetCustomOutputDestination(); + priv(doc).resetCustomOutputDestination(); }); it("jsPDF private function getNumberOfPages", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.getNumberOfPages()).toEqual(1); + expect(priv(doc).getNumberOfPages()).toEqual(1); doc.addPage(); - expect(doc.__private__.getNumberOfPages()).toEqual(2); + expect(priv(doc).getNumberOfPages()).toEqual(2); doc.addPage(); - expect(doc.__private__.getNumberOfPages()).toEqual(3); + expect(priv(doc).getNumberOfPages()).toEqual(3); doc.addPage(); - expect(doc.__private__.getNumberOfPages()).toEqual(4); + expect(priv(doc).getNumberOfPages()).toEqual(4); }); it("jsPDF internal function getPageInfo", () => { const doc = jsPDF({ floatPrecision: 2 }); doc.addPage(); doc.addPage(); - expect(doc.internal.getPageInfo(1)).toEqual({ + // `as unknown`: the expected pageContext carries the runtime-added + // `annotations` member the PageContext type does not declare + expect(doc.internal.getPageInfo(1) as unknown).toEqual({ objId: 0, pageNumber: 1, pageContext: { @@ -471,7 +723,7 @@ describe("Core: Unit Tests", () => { annotations: [] } }); - expect(doc.internal.getPageInfo(2)).toEqual({ + expect(doc.internal.getPageInfo(2) as unknown).toEqual({ objId: 0, pageNumber: 2, pageContext: { @@ -491,7 +743,7 @@ describe("Core: Unit Tests", () => { annotations: [] } }); - expect(doc.internal.getPageInfo(3)).toEqual({ + expect(doc.internal.getPageInfo(3) as unknown).toEqual({ objId: 0, pageNumber: 3, pageContext: { @@ -512,10 +764,11 @@ describe("Core: Unit Tests", () => { } }); - expect(function() { - doc.internal.getPageInfo("invalid"); + expect(function () { + // deliberately invalid page number to exercise the runtime guard + doc.internal.getPageInfo("invalid" as unknown as number); }).toThrow(new Error("Invalid argument passed to jsPDF.getPageInfo")); - expect(function() { + expect(function () { doc.internal.getPageInfo(3.14); }).toThrow(new Error("Invalid argument passed to jsPDF.getPageInfo")); }); @@ -524,7 +777,7 @@ describe("Core: Unit Tests", () => { const doc = jsPDF({ floatPrecision: 2 }); doc.addPage(); doc.addPage(); - expect(doc.__private__.getCurrentPageInfo()).toEqual({ + expect(priv(doc).getCurrentPageInfo()).toEqual({ objId: 0, pageNumber: 3, pageContext: { @@ -548,26 +801,24 @@ describe("Core: Unit Tests", () => { it("jsPDF private function getArrayBuffer", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.getArrayBuffer("A").byteLength).toEqual(1); - expect(doc.__private__.getArrayBuffer("A") instanceof ArrayBuffer).toEqual( - true - ); + expect(priv(doc).getArrayBuffer("A").byteLength).toEqual(1); + expect(priv(doc).getArrayBuffer("A") instanceof ArrayBuffer).toEqual(true); }); if (global.isNode !== true) { it("jsPDF private function getBlob", () => { const doc = new jsPDF({ floatPrecision: 2 }); - expect(typeof doc.__private__.getBlob("A")).toEqual("object"); - expect(doc.__private__.getBlob("A") instanceof Blob).toEqual(true); - expect(doc.__private__.getBlob("A").type).toEqual("application/pdf"); + expect(typeof priv(doc).getBlob("A")).toEqual("object"); + expect(priv(doc).getBlob("A") instanceof Blob).toEqual(true); + expect(priv(doc).getBlob("A").type).toEqual("application/pdf"); }); } it("jsPDF private function output", () => { var doc = new jsPDF({ floatPrecision: 2 }); - doc.__private__.setFileId("0000000000000000000000000BADFACE"); - doc.__private__.setCreationDate("D:19871210000000+00'00'"); + priv(doc).setFileId("0000000000000000000000000BADFACE"); + priv(doc).setCreationDate("D:19871210000000+00'00'"); var data = [ "%PDF-1.3", @@ -803,32 +1054,32 @@ describe("Core: Unit Tests", () => { "2439", "%%EOF" ]; - expect(doc.__private__.output()).toEqual(data.join("\n")); + expect(priv(doc).output()).toEqual(data.join("\n")); - expect( - doc.__private__.output("arraybuffer") instanceof ArrayBuffer - ).toEqual(true); + expect(priv(doc).output("arraybuffer") instanceof ArrayBuffer).toEqual( + true + ); if (global.isNode !== true) { - expect(doc.__private__.output("blob") instanceof Blob).toEqual(true); + expect(priv(doc).output("blob") instanceof Blob).toEqual(true); } - expect(doc.__private__.output("datauristring")).toEqual( + expect(priv(doc).output("datauristring")).toEqual( "data:application/pdf;filename=generated.pdf;base64," + btoa(data.join("\n")) ); - expect(doc.__private__.output("dataurlstring")).toEqual( + expect(priv(doc).output("dataurlstring")).toEqual( "data:application/pdf;filename=generated.pdf;base64," + btoa(data.join("\n")) ); - expect(doc.__private__.output("invalid")).toEqual(null); + expect(priv(doc).output("invalid")).toEqual(null); }); //Font-Functionality it("jsPDF private function getStandardFonts", () => { const doc = jsPDF({ floatPrecision: 2 }); - const fontList = doc.__private__.getStandardFonts(); + const fontList = priv(doc).getStandardFonts(); expect(fontList).toEqual([ ["Helvetica", "helvetica", "normal", "WinAnsiEncoding"], ["Helvetica-Bold", "helvetica", "bold", "WinAnsiEncoding"], @@ -849,7 +1100,7 @@ describe("Core: Unit Tests", () => { it("jsPDF private function getFontList", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.getFontList()).toEqual({ + expect(priv(doc).getFontList()).toEqual({ helvetica: ["normal", "bold", "italic", "bolditalic"], Helvetica: ["", "Bold", "Oblique", "BoldOblique"], courier: ["normal", "bold", "italic", "bolditalic"], @@ -879,59 +1130,59 @@ describe("Core: Unit Tests", () => { it("jsPDF private function getCharSpace", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.getCharSpace()).toEqual(0); + expect(priv(doc).getCharSpace()).toEqual(0); }); it("jsPDF private function setCharSpace", () => { const doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setCharSpace(2); + priv(doc).setCharSpace(2); - expect(doc.__private__.getCharSpace()).toEqual(2); - expect(function() { - doc.__private__.setCharSpace("invalid"); + expect(priv(doc).getCharSpace()).toEqual(2); + expect(function () { + priv(doc).setCharSpace("invalid"); }).toThrow(new Error("Invalid argument passed to jsPDF.setCharSpace")); }); it("jsPDF private function getLineWidth", () => { const doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setLineWidth(595.28); + priv(doc).setLineWidth(595.28); - expect(doc.__private__.getLineWidth()).toEqual(595.28); + expect(priv(doc).getLineWidth()).toEqual(595.28); }); it("jsPDF private function setLineDash", () => { const doc = jsPDF({ floatPrecision: 3 }); - var writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); + var writeArray: string[] = []; + priv(doc).setCustomOutputDestination(writeArray); - expect(function() { - doc.__private__.setLineDash(""); + expect(function () { + priv(doc).setLineDash(""); }).not.toThrow(new Error("Invalid arguments passed to jsPDF.setLineDash")); - var writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - expect(function() { - doc.__private__.setLineDash(); + var writeArray: string[] = []; + priv(doc).setCustomOutputDestination(writeArray); + expect(function () { + priv(doc).setLineDash(); }).not.toThrow(new Error("Invalid arguments passed to jsPDF.setLineDash")); expect(writeArray).toEqual(["[] 0. d"]); - var writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - expect(function() { - doc.__private__.setLineDash("1 1", "1"); + var writeArray: string[] = []; + priv(doc).setCustomOutputDestination(writeArray); + expect(function () { + priv(doc).setLineDash("1 1", "1"); }).toThrow(new Error("Invalid arguments passed to jsPDF.setLineDash")); - var writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - expect(function() { - doc.__private__.setLineDash("1 1", 1); + var writeArray: string[] = []; + priv(doc).setCustomOutputDestination(writeArray); + expect(function () { + priv(doc).setLineDash("1 1", 1); }).toThrow(new Error("Invalid arguments passed to jsPDF.setLineDash")); - var writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - expect(function() { - doc.__private__.setLineDash([1, 1], 1); + var writeArray: string[] = []; + priv(doc).setCustomOutputDestination(writeArray); + expect(function () { + priv(doc).setLineDash([1, 1], 1); }).not.toThrow(new Error("Invalid arguments passed to jsPDF.setLineDash")); expect(writeArray).toEqual(["[2.835 2.835] 2.835 d"]); @@ -940,38 +1191,36 @@ describe("Core: Unit Tests", () => { it("jsPDF private function getLineHeight", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.getLineHeight()).toEqual(16 * 1.15); + expect(priv(doc).getLineHeight()).toEqual(16 * 1.15); }); it("jsPDF private function setLineHeightFactor", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.getLineHeight()).toEqual(16 * 1.15); - doc.__private__.setLineHeightFactor(1.0); - expect(doc.__private__.getLineHeight()).toEqual(16); + expect(priv(doc).getLineHeight()).toEqual(16 * 1.15); + priv(doc).setLineHeightFactor(1.0); + expect(priv(doc).getLineHeight()).toEqual(16); }); it("jsPDF public function setLineHeightFactor", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.getLineHeight()).toEqual(16 * 1.15); + expect(priv(doc).getLineHeight()).toEqual(16 * 1.15); doc.setLineHeightFactor(1.0); - expect(doc.__private__.getLineHeight()).toEqual(16); + expect(priv(doc).getLineHeight()).toEqual(16); }); it("jsPDF private function getHorizontalCoordinateString", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.getHorizontalCoordinateString(10)).toEqual("28.35"); - expect(doc.__private__.getHorizontalCoordinateString(100)).toEqual( - "283.46" - ); + expect(priv(doc).getHorizontalCoordinateString(10)).toEqual("28.35"); + expect(priv(doc).getHorizontalCoordinateString(100)).toEqual("283.46"); }); it("jsPDF private function getVerticalCoordinateString", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.getVerticalCoordinateString(10)).toEqual("813.54"); + expect(priv(doc).getVerticalCoordinateString(10)).toEqual("813.54"); }); it("jsPDF public function pageSize", () => { @@ -979,41 +1228,41 @@ describe("Core: Unit Tests", () => { expect(doc.internal.pageSize.getHeight()).toEqual(297.0000833333333); - doc = jsPDF("p", "pt", "a4"); + doc = jsPDFLegacy("p", "pt", "a4"); expect(doc.internal.pageSize.getHeight()).toEqual(841.89); expect(doc.internal.pageSize.height).toEqual(841.89); expect(doc.internal.pageSize.getWidth()).toEqual(595.28); expect(doc.internal.pageSize.width).toEqual(595.28); - doc = jsPDF("p", "pt", "a4"); + doc = jsPDFLegacy("p", "pt", "a4"); doc.internal.pageSize.setHeight(595.28); expect(doc.internal.pageSize.getHeight()).toEqual(595.28); expect(doc.internal.pageSize.height).toEqual(595.28); expect(doc.internal.pageSize.getWidth()).toEqual(595.28); expect(doc.internal.pageSize.width).toEqual(595.28); - doc = jsPDF("p", "pt", "a4"); + doc = jsPDFLegacy("p", "pt", "a4"); doc.internal.pageSize.height = 595.28; expect(doc.internal.pageSize.getHeight()).toEqual(595.28); expect(doc.internal.pageSize.height).toEqual(595.28); expect(doc.internal.pageSize.getWidth()).toEqual(595.28); expect(doc.internal.pageSize.width).toEqual(595.28); - doc = jsPDF("p", "pt", "a4"); + doc = jsPDFLegacy("p", "pt", "a4"); doc.internal.pageSize.setWidth(841.89); expect(doc.internal.pageSize.getHeight()).toEqual(841.89); expect(doc.internal.pageSize.height).toEqual(841.89); expect(doc.internal.pageSize.getWidth()).toEqual(841.89); expect(doc.internal.pageSize.width).toEqual(841.89); - doc = jsPDF("p", "pt", "a4"); + doc = jsPDFLegacy("p", "pt", "a4"); doc.internal.pageSize.width = 841.89; expect(doc.internal.pageSize.getHeight()).toEqual(841.89); expect(doc.internal.pageSize.height).toEqual(841.89); expect(doc.internal.pageSize.getWidth()).toEqual(841.89); expect(doc.internal.pageSize.width).toEqual(841.89); - doc = jsPDF("p", "pt", "a4"); + doc = jsPDFLegacy("p", "pt", "a4"); doc.internal.pageSize.height = 595.28; doc.internal.pageSize.width = 841.89; expect(doc.internal.pageSize.getHeight()).toEqual(595.28); @@ -1024,14 +1273,14 @@ describe("Core: Unit Tests", () => { it("jsPDF private function getR2L", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.getR2L()).toEqual(false); + expect(priv(doc).getR2L()).toEqual(false); }); it("jsPDF private function setR2L", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.getR2L()).toEqual(false); + expect(priv(doc).getR2L()).toEqual(false); doc.setR2L(true); - expect(doc.__private__.getR2L()).toEqual(true); + expect(priv(doc).getR2L()).toEqual(true); }); it("jsPDF public function setR2L", () => { @@ -1056,18 +1305,18 @@ describe("Core: Unit Tests", () => { it("jsPDF private function setZoomMode, getZoomMode", () => { const doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setZoomMode(2); - expect(doc.__private__.getZoomMode()).toEqual(2); - doc.__private__.setZoomMode("200%"); - expect(doc.__private__.getZoomMode()).toEqual("200%"); - doc.__private__.setZoomMode("fullwidth"); - expect(doc.__private__.getZoomMode()).toEqual("fullwidth"); - doc.__private__.setZoomMode("fullheight"); - expect(doc.__private__.getZoomMode()).toEqual("fullheight"); - doc.__private__.setZoomMode("original"); - expect(doc.__private__.getZoomMode()).toEqual("original"); - expect(function() { - doc.__private__.setZoomMode("invalid"); + priv(doc).setZoomMode(2); + expect(priv(doc).getZoomMode()).toEqual(2); + priv(doc).setZoomMode("200%"); + expect(priv(doc).getZoomMode()).toEqual("200%"); + priv(doc).setZoomMode("fullwidth"); + expect(priv(doc).getZoomMode()).toEqual("fullwidth"); + priv(doc).setZoomMode("fullheight"); + expect(priv(doc).getZoomMode()).toEqual("fullheight"); + priv(doc).setZoomMode("original"); + expect(priv(doc).getZoomMode()).toEqual("original"); + expect(function () { + priv(doc).setZoomMode("invalid"); }).toThrow( new Error( 'zoom must be Integer (e.g. 2), a percentage Value (e.g. 300%) or fullwidth, fullheight, fullpage, original. "invalid" is not recognized.' @@ -1077,10 +1326,10 @@ describe("Core: Unit Tests", () => { it("jsPDF private function setLayoutMode, getLayoutMode", () => { const doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setLayoutMode("continuous"); - expect(doc.__private__.getLayoutMode()).toEqual("continuous"); - expect(function() { - doc.__private__.setLayoutMode("invalid"); + priv(doc).setLayoutMode("continuous"); + expect(priv(doc).getLayoutMode()).toEqual("continuous"); + expect(function () { + priv(doc).setLayoutMode("invalid"); }).toThrow( new Error( 'Layout mode must be one of continuous, single, twoleft, tworight. "invalid" is not recognized.' @@ -1090,10 +1339,10 @@ describe("Core: Unit Tests", () => { it("jsPDF private function setPageMode, getPageMode", () => { const doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setPageMode("UseNone"); - expect(doc.__private__.getPageMode()).toEqual("UseNone"); - expect(function() { - doc.__private__.setPageMode("invalid"); + priv(doc).setPageMode("UseNone"); + expect(priv(doc).getPageMode()).toEqual("UseNone"); + expect(function () { + priv(doc).setPageMode("invalid"); }).toThrow( new Error( 'Page mode must be one of UseNone, UseOutlines, UseThumbs, or FullScreen. "invalid" is not recognized.' @@ -1103,52 +1352,52 @@ describe("Core: Unit Tests", () => { it("jsPDF private function setDisplayMode", () => { const doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setDisplayMode("200%", "continuous", "UseNone"); - expect(doc.__private__.getZoomMode()).toEqual("200%"); - expect(doc.__private__.getLayoutMode()).toEqual("continuous"); - expect(doc.__private__.getPageMode()).toEqual("UseNone"); + priv(doc).setDisplayMode("200%", "continuous", "UseNone"); + expect(priv(doc).getZoomMode()).toEqual("200%"); + expect(priv(doc).getLayoutMode()).toEqual("continuous"); + expect(priv(doc).getPageMode()).toEqual("UseNone"); }); it("jsPDF private function getTextColor", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.getTextColor()).toEqual("#000000"); + expect(priv(doc).getTextColor()).toEqual("#000000"); }); it("jsPDF private function setTextColor", () => { const doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setTextColor(255, 0, 0); - expect(doc.__private__.getTextColor()).toEqual("#ff0000"); + priv(doc).setTextColor(255, 0, 0); + expect(priv(doc).getTextColor()).toEqual("#ff0000"); }); it("jsPDF private function getFillColor", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.getFillColor()).toEqual("#000000"); + expect(priv(doc).getFillColor()).toEqual("#000000"); }); it("jsPDF private function getFillColor", () => { const doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setFillColor(255, 0, 0); - expect(doc.__private__.getFillColor()).toEqual("#ff0000"); + priv(doc).setFillColor(255, 0, 0); + expect(priv(doc).getFillColor()).toEqual("#ff0000"); }); it("jsPDF private function getStrokeColor", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.getStrokeColor()).toEqual("#000000"); + expect(priv(doc).getStrokeColor()).toEqual("#000000"); }); it("jsPDF private function setStrokeColor", () => { const doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setStrokeColor(255, 0, 0); - expect(doc.__private__.getStrokeColor()).toEqual("#ff0000"); + priv(doc).setStrokeColor(255, 0, 0); + expect(priv(doc).getStrokeColor()).toEqual("#ff0000"); }); it("jsPDF private function encodeColorString", () => { const doc = jsPDF({ floatPrecision: 2 }); + expect(priv(doc).encodeColorString({ ch1: 255, ch2: 0, ch3: 0 })).toEqual( + "1. 0. 0. rg" + ); expect( - doc.__private__.encodeColorString({ ch1: 255, ch2: 0, ch3: 0 }) - ).toEqual("1. 0. 0. rg"); - expect( - doc.__private__.encodeColorString({ + priv(doc).encodeColorString({ ch1: 255, ch2: 0, ch3: 0, @@ -1156,44 +1405,38 @@ describe("Core: Unit Tests", () => { }) ).toEqual("1. 0. 0. rg"); expect( - doc.__private__.encodeColorString({ + priv(doc).encodeColorString({ ch1: 255, ch2: 0, ch3: 0, precision: 3 }) ).toEqual("1. 0. 0. rg"); - expect(doc.__private__.encodeColorString({ ch1: "red" })).toEqual( + expect(priv(doc).encodeColorString({ ch1: "red" })).toEqual("1. 0. 0. rg"); + expect(priv(doc).encodeColorString({ ch1: "#f00" })).toEqual("1. 0. 0. rg"); + expect(priv(doc).encodeColorString({ ch1: "#ff0000" })).toEqual( "1. 0. 0. rg" ); - expect(doc.__private__.encodeColorString({ ch1: "#f00" })).toEqual( - "1. 0. 0. rg" - ); - expect(doc.__private__.encodeColorString({ ch1: "#ff0000" })).toEqual( - "1. 0. 0. rg" + expect(priv(doc).encodeColorString("red")).toEqual("1. 0. 0. rg"); + expect(priv(doc).encodeColorString("#f00")).toEqual("1. 0. 0. rg"); + expect(priv(doc).encodeColorString("#ff0000")).toEqual("1. 0. 0. rg"); + expect(priv(doc).encodeColorString("gray")).toEqual("0.502 g"); + expect(priv(doc).encodeColorString({ ch1: 128, precision: 2 })).toEqual( + "0.5 g" ); - expect(doc.__private__.encodeColorString("red")).toEqual("1. 0. 0. rg"); - expect(doc.__private__.encodeColorString("#f00")).toEqual("1. 0. 0. rg"); - expect(doc.__private__.encodeColorString("#ff0000")).toEqual("1. 0. 0. rg"); - expect(doc.__private__.encodeColorString("gray")).toEqual("0.502 g"); - expect( - doc.__private__.encodeColorString({ ch1: 128, precision: 2 }) - ).toEqual("0.5 g"); - expect( - doc.__private__.encodeColorString({ ch1: 128, precision: 3 }) - ).toEqual("0.502 g"); - expect(doc.__private__.encodeColorString({ ch1: "0.502" })).toEqual( + expect(priv(doc).encodeColorString({ ch1: 128, precision: 3 })).toEqual( "0.502 g" ); + expect(priv(doc).encodeColorString({ ch1: "0.502" })).toEqual("0.502 g"); expect( - doc.__private__.encodeColorString({ + priv(doc).encodeColorString({ ch1: "1.000", ch2: "0.000", ch3: "0.000" }) ).toEqual("1.000 0.000 0.000 rg"); expect( - doc.__private__.encodeColorString({ + priv(doc).encodeColorString({ ch1: 255, ch2: 0, ch3: 0, @@ -1201,7 +1444,7 @@ describe("Core: Unit Tests", () => { }) ).toEqual("1. 1. 1. rg"); expect( - doc.__private__.encodeColorString({ + priv(doc).encodeColorString({ ch1: 255, ch2: 0, ch3: 0, @@ -1209,7 +1452,7 @@ describe("Core: Unit Tests", () => { }) ).toEqual("1. 0. 0. rg"); expect( - doc.__private__.encodeColorString({ + priv(doc).encodeColorString({ ch1: "1.000", ch2: "0.000", ch3: "0.000", @@ -1217,7 +1460,7 @@ describe("Core: Unit Tests", () => { }) ).toEqual("1.000 0.000 0.000 1.000 k"); expect( - doc.__private__.encodeColorString({ + priv(doc).encodeColorString({ ch1: 1.0, ch2: 0.0, ch3: 0.0, @@ -1226,7 +1469,7 @@ describe("Core: Unit Tests", () => { }) ).toEqual("1. 0. 0. 1. k"); expect( - doc.__private__.encodeColorString({ + priv(doc).encodeColorString({ ch1: 1.0, ch2: 0.0, ch3: 0.0, @@ -1235,7 +1478,7 @@ describe("Core: Unit Tests", () => { }) ).toEqual("1. 0. 0. 1. k"); expect( - doc.__private__.encodeColorString({ + priv(doc).encodeColorString({ ch1: 0.4, ch2: 0.2, ch3: 0.4, @@ -1243,8 +1486,8 @@ describe("Core: Unit Tests", () => { precision: 2 }) ).toEqual("0.4 0.2 0.4 0.1 k"); - expect(function() { - doc.__private__.encodeColorString("invalid"); + expect(function () { + priv(doc).encodeColorString("invalid"); }).toThrow( new Error('Invalid color "invalid" passed to jsPDF.encodeColorString.') ); @@ -1252,41 +1495,35 @@ describe("Core: Unit Tests", () => { it("jsPDF private function decodeColorString", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.decodeColorString("1. 0. 0. rg")).toEqual("#ff0000"); - expect(doc.__private__.decodeColorString("1. 0. 0. rg")).toEqual("#ff0000"); - expect(doc.__private__.decodeColorString("1. 1. 0. RG")).toEqual("#ffff00"); - expect(doc.__private__.decodeColorString("1. 1. 1. RG")).toEqual("#ffffff"); - expect(doc.__private__.decodeColorString("0. 0. 1. rg")).toEqual("#0000ff"); - expect(doc.__private__.decodeColorString("0.33 0.1 1. rg")).toEqual( - "#5419ff" - ); - expect(doc.__private__.decodeColorString("0 g")).toEqual("#000000"); - expect(doc.__private__.decodeColorString("0 G")).toEqual("#000000"); - expect(doc.__private__.decodeColorString("0.39 G")).toEqual("#636363"); - expect(doc.__private__.decodeColorString("1. G")).toEqual("#ffffff"); - expect(doc.__private__.decodeColorString("0.32 0.67 0.1 0.32 k")).toEqual( + expect(priv(doc).decodeColorString("1. 0. 0. rg")).toEqual("#ff0000"); + expect(priv(doc).decodeColorString("1. 0. 0. rg")).toEqual("#ff0000"); + expect(priv(doc).decodeColorString("1. 1. 0. RG")).toEqual("#ffff00"); + expect(priv(doc).decodeColorString("1. 1. 1. RG")).toEqual("#ffffff"); + expect(priv(doc).decodeColorString("0. 0. 1. rg")).toEqual("#0000ff"); + expect(priv(doc).decodeColorString("0.33 0.1 1. rg")).toEqual("#5419ff"); + expect(priv(doc).decodeColorString("0 g")).toEqual("#000000"); + expect(priv(doc).decodeColorString("0 G")).toEqual("#000000"); + expect(priv(doc).decodeColorString("0.39 G")).toEqual("#636363"); + expect(priv(doc).decodeColorString("1. G")).toEqual("#ffffff"); + expect(priv(doc).decodeColorString("0.32 0.67 0.1 0.32 k")).toEqual( "#75399c" ); - expect(doc.__private__.decodeColorString("1. 0. 0. 0. K")).toEqual( - "#00ffff" - ); - expect(doc.__private__.decodeColorString("1. 0. 1. 0. K")).toEqual( - "#00ff00" - ); + expect(priv(doc).decodeColorString("1. 0. 0. 0. K")).toEqual("#00ffff"); + expect(priv(doc).decodeColorString("1. 0. 1. 0. K")).toEqual("#00ff00"); }); it("jsPDF private function getDocumentProperty, setDocumentProperty", () => { const doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setDocumentProperty("title", "Title"); - expect(doc.__private__.getDocumentProperty("title")).toEqual("Title"); + priv(doc).setDocumentProperty("title", "Title"); + expect(priv(doc).getDocumentProperty("title")).toEqual("Title"); - expect(function() { - doc.__private__.setDocumentProperty("invalid", "Title"); + expect(function () { + priv(doc).setDocumentProperty("invalid", "Title"); }).toThrow( new Error("Invalid arguments passed to jsPDF.setDocumentProperty") ); - expect(function() { - doc.__private__.getDocumentProperty("invalid"); + expect(function () { + priv(doc).getDocumentProperty("invalid"); }).toThrow( new Error("Invalid argument passed to jsPDF.getDocumentProperty") ); @@ -1294,10 +1531,10 @@ describe("Core: Unit Tests", () => { it("jsPDF private function getDocumentProperties, setDocumentProperties", () => { const doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setDocumentProperties({ title: "Title" }); - expect(doc.__private__.getDocumentProperty("title")).toEqual("Title"); + priv(doc).setDocumentProperties({ title: "Title" }); + expect(priv(doc).getDocumentProperty("title")).toEqual("Title"); - expect(doc.__private__.getDocumentProperties()).toEqual({ + expect(priv(doc).getDocumentProperties()).toEqual({ title: "Title", subject: "", author: "", @@ -1305,37 +1542,37 @@ describe("Core: Unit Tests", () => { creator: "" }); - // expect(function() {doc.__private__.setDocumentProperty('invalid', 'Title');}).toThrow(new Error('Invalid arguments passed to jsPDF.setDocumentProperty')); + // expect(function() {priv(doc).setDocumentProperty('invalid', 'Title');}).toThrow(new Error('Invalid arguments passed to jsPDF.setDocumentProperty')); }); it("jsPDF private function isValidStyle", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.isValidStyle("F")).toEqual(true); - expect(doc.__private__.isValidStyle("S")).toEqual(true); - expect(doc.__private__.isValidStyle("DF")).toEqual(true); - expect(doc.__private__.isValidStyle("X")).toEqual(false); + expect(priv(doc).isValidStyle("F")).toEqual(true); + expect(priv(doc).isValidStyle("S")).toEqual(true); + expect(priv(doc).isValidStyle("DF")).toEqual(true); + expect(priv(doc).isValidStyle("X")).toEqual(false); }); it("jsPDF private function getStyle", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(doc.__private__.getStyle("F")).toEqual("f"); - expect(doc.__private__.getStyle("X")).toEqual("S"); - expect(doc.__private__.getStyle("S")).toEqual("S"); - expect(doc.__private__.getStyle("FD")).toEqual("B"); - expect(doc.__private__.getStyle("DF")).toEqual("B"); - expect(doc.__private__.getStyle("f")).toEqual("f"); - expect(doc.__private__.getStyle("f*")).toEqual("f*"); - expect(doc.__private__.getStyle("B")).toEqual("B"); - expect(doc.__private__.getStyle("B*")).toEqual("B*"); + expect(priv(doc).getStyle("F")).toEqual("f"); + expect(priv(doc).getStyle("X")).toEqual("S"); + expect(priv(doc).getStyle("S")).toEqual("S"); + expect(priv(doc).getStyle("FD")).toEqual("B"); + expect(priv(doc).getStyle("DF")).toEqual("B"); + expect(priv(doc).getStyle("f")).toEqual("f"); + expect(priv(doc).getStyle("f*")).toEqual("f*"); + expect(priv(doc).getStyle("B")).toEqual("B"); + expect(priv(doc).getStyle("B*")).toEqual("B*"); }); it("jsPDF private function lines", () => { var doc = jsPDF({ floatPrecision: 3 }); - var writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.lines( + var writeArray: string[] = []; + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).lines( [ [2, 2], [-2, 2], @@ -1356,8 +1593,8 @@ describe("Core: Unit Tests", () => { //old method header writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.lines( + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).lines( 212, 110, [ @@ -1378,8 +1615,8 @@ describe("Core: Unit Tests", () => { ]); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.lines( + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).lines( [ [2, 2], [-2, 2], @@ -1400,8 +1637,8 @@ describe("Core: Unit Tests", () => { ]); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.lines( + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).lines( [ [2, 2], [-2, 2], @@ -1421,8 +1658,8 @@ describe("Core: Unit Tests", () => { "615.118 507.402 l", "f" ]); - expect(function() { - doc.__private__.lines( + expect(function () { + priv(doc).lines( [ [2, 2], [-2, 2], @@ -1435,8 +1672,8 @@ describe("Core: Unit Tests", () => { }).not.toThrow(new Error("Invalid arguments passed to jsPDF.lines")); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.lines( + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).lines( [ [2, 2], [-2, 2], @@ -1455,8 +1692,8 @@ describe("Core: Unit Tests", () => { "603.78 515.906 606.614 513.071 609.449 510.236 c", "615.118 507.402 l" ]); - expect(function() { - doc.__private__.lines( + expect(function () { + priv(doc).lines( [ [2, 2], [-2, 2], @@ -1468,8 +1705,8 @@ describe("Core: Unit Tests", () => { ); }).not.toThrow(new Error("Invalid arguments passed to jsPDF.lines")); - expect(function() { - doc.__private__.lines( + expect(function () { + priv(doc).lines( [ [2, 2], [-2, 2], @@ -1481,8 +1718,8 @@ describe("Core: Unit Tests", () => { [1, 1] ); }).not.toThrow(new Error("Invalid arguments passed to jsPDF.lines")); - expect(function() { - doc.__private__.lines( + expect(function () { + priv(doc).lines( [ [2, 2], [-2, 2], @@ -1495,8 +1732,8 @@ describe("Core: Unit Tests", () => { "F" ); }).not.toThrow(new Error("Invalid arguments passed to jsPDF.lines")); - expect(function() { - doc.__private__.lines( + expect(function () { + priv(doc).lines( [ [2, 2], [-2, 2], @@ -1511,11 +1748,11 @@ describe("Core: Unit Tests", () => { ); }).not.toThrow(new Error("Invalid arguments passed to jsPDF.lines")); - expect(function() { - doc.__private__.lines("invalid", 212, 110, [1, 1], "F", false); + expect(function () { + priv(doc).lines("invalid", 212, 110, [1, 1], "F", false); }).toThrow(new Error("Invalid arguments passed to jsPDF.lines")); - expect(function() { - doc.__private__.lines( + expect(function () { + priv(doc).lines( [ [2, 2], [-2, 2], @@ -1529,8 +1766,8 @@ describe("Core: Unit Tests", () => { false ); }).toThrow(new Error("Invalid arguments passed to jsPDF.lines")); - expect(function() { - doc.__private__.lines( + expect(function () { + priv(doc).lines( [ [2, 2], [-2, 2], @@ -1544,8 +1781,8 @@ describe("Core: Unit Tests", () => { false ); }).toThrow(new Error("Invalid arguments passed to jsPDF.lines")); - expect(function() { - doc.__private__.lines( + expect(function () { + priv(doc).lines( [ [2, 2], [-2, 2], @@ -1559,8 +1796,8 @@ describe("Core: Unit Tests", () => { false ); }).toThrow(new Error("Invalid arguments passed to jsPDF.lines")); - expect(function() { - doc.__private__.lines( + expect(function () { + priv(doc).lines( [ [2, 2], [-2, 2], @@ -1574,8 +1811,8 @@ describe("Core: Unit Tests", () => { false ); }).toThrow(new Error("Invalid arguments passed to jsPDF.lines")); - expect(function() { - doc.__private__.lines( + expect(function () { + priv(doc).lines( [ [2, 2], [-2, 2], @@ -1594,116 +1831,112 @@ describe("Core: Unit Tests", () => { it("jsPDF private function line", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(function() { - doc.__private__.line(1, 2, 3, 4); + expect(function () { + priv(doc).line(1, 2, 3, 4); }).not.toThrow(new Error("Invalid arguments passed to jsPDF.line")); - expect(function() { - doc.__private__.line("invalid", 2, 3, 4); + expect(function () { + priv(doc).line("invalid", 2, 3, 4); }).toThrow(new Error("Invalid arguments passed to jsPDF.line")); - expect(function() { - doc.__private__.line(1, "invalid", 3, 4); + expect(function () { + priv(doc).line(1, "invalid", 3, 4); }).toThrow(new Error("Invalid arguments passed to jsPDF.line")); - expect(function() { - doc.__private__.line(1, 2, "invalid", 4); + expect(function () { + priv(doc).line(1, 2, "invalid", 4); }).toThrow(new Error("Invalid arguments passed to jsPDF.line")); - expect(function() { - doc.__private__.line(1, 2, 3, "invalid"); + expect(function () { + priv(doc).line(1, 2, 3, "invalid"); }).toThrow(new Error("Invalid arguments passed to jsPDF.line")); }); it("jsPDF private function triangle", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(function() { - doc.__private__.triangle(1, 2, 3, 4, 5, 6, "F"); + expect(function () { + priv(doc).triangle(1, 2, 3, 4, 5, 6, "F"); }).not.toThrow(new Error("Invalid arguments passed to jsPDF.triangle")); - expect(function() { - doc.__private__.triangle("invalid", 2, 3, 4, 5, 6, "F"); + expect(function () { + priv(doc).triangle("invalid", 2, 3, 4, 5, 6, "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.triangle")); - expect(function() { - doc.__private__.triangle(1, "invalid", 3, 4, 5, 6, "F"); + expect(function () { + priv(doc).triangle(1, "invalid", 3, 4, 5, 6, "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.triangle")); - expect(function() { - doc.__private__.triangle(1, 2, "invalid", 4, 5, 6, "F"); + expect(function () { + priv(doc).triangle(1, 2, "invalid", 4, 5, 6, "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.triangle")); - expect(function() { - doc.__private__.triangle(1, 2, 3, "invalid", 5, 6, "F"); + expect(function () { + priv(doc).triangle(1, 2, 3, "invalid", 5, 6, "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.triangle")); - expect(function() { - doc.__private__.triangle(1, 2, 3, 4, "invalid", 6, "F"); + expect(function () { + priv(doc).triangle(1, 2, 3, 4, "invalid", 6, "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.triangle")); - expect(function() { - doc.__private__.triangle(1, 2, 3, 4, 5, "invalid", "F"); + expect(function () { + priv(doc).triangle(1, 2, 3, 4, 5, "invalid", "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.triangle")); - expect(function() { - doc.__private__.triangle(1, 2, 3, 4, 5, 6, "invalid"); + expect(function () { + priv(doc).triangle(1, 2, 3, 4, 5, 6, "invalid"); }).toThrow(new Error("Invalid arguments passed to jsPDF.triangle")); - expect(doc.__private__.triangle(1, 2, 3, 4, 5, 6, "F")).toBe( - doc.__private__ - ); + expect(priv(doc).triangle(1, 2, 3, 4, 5, 6, "F")).toBe(priv(doc)); }); it("jsPDF private function roundedRect", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(function() { - doc.__private__.roundedRect(1, 2, 3, 4, 5, 6, "F"); + expect(function () { + priv(doc).roundedRect(1, 2, 3, 4, 5, 6, "F"); }).not.toThrow(new Error("Invalid arguments passed to jsPDF.roundedRect")); - expect(function() { - doc.__private__.roundedRect("undefined", 2, 3, 4, 5, 6, "F"); + expect(function () { + priv(doc).roundedRect("undefined", 2, 3, 4, 5, 6, "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.roundedRect")); - expect(function() { - doc.__private__.roundedRect(1, "undefined", 3, 4, 5, 6, "F"); + expect(function () { + priv(doc).roundedRect(1, "undefined", 3, 4, 5, 6, "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.roundedRect")); - expect(function() { - doc.__private__.roundedRect(1, 2, "undefined", 4, 5, 6, "F"); + expect(function () { + priv(doc).roundedRect(1, 2, "undefined", 4, 5, 6, "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.roundedRect")); - expect(function() { - doc.__private__.roundedRect(1, 2, 3, "undefined", 5, 6, "F"); + expect(function () { + priv(doc).roundedRect(1, 2, 3, "undefined", 5, 6, "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.roundedRect")); - expect(function() { - doc.__private__.roundedRect(1, 2, 3, 4, "undefined", 6, "F"); + expect(function () { + priv(doc).roundedRect(1, 2, 3, 4, "undefined", 6, "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.roundedRect")); - expect(function() { - doc.__private__.roundedRect(1, 2, 3, 4, 5, "undefined", "F"); + expect(function () { + priv(doc).roundedRect(1, 2, 3, 4, 5, "undefined", "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.roundedRect")); - expect(function() { - doc.__private__.roundedRect(1, 2, 3, 4, 5, 6, "undefined"); + expect(function () { + priv(doc).roundedRect(1, 2, 3, 4, 5, 6, "undefined"); }).toThrow(new Error("Invalid arguments passed to jsPDF.roundedRect")); - expect(doc.__private__.roundedRect(1, 2, 3, 4, 5, 6, "F")).toBe( - doc.__private__ - ); + expect(priv(doc).roundedRect(1, 2, 3, 4, 5, 6, "F")).toBe(priv(doc)); }); it("jsPDF private function ellipse", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(function() { - doc.__private__.ellipse(1, 2, 3, 4, "F"); + expect(function () { + priv(doc).ellipse(1, 2, 3, 4, "F"); }).not.toThrow(new Error("Invalid arguments passed to jsPDF.ellipse")); - expect(function() { - doc.__private__.ellipse("undefined", 2, 3, 4, "F"); + expect(function () { + priv(doc).ellipse("undefined", 2, 3, 4, "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.ellipse")); - expect(function() { - doc.__private__.ellipse(1, "undefined", 3, 4, "F"); + expect(function () { + priv(doc).ellipse(1, "undefined", 3, 4, "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.ellipse")); - expect(function() { - doc.__private__.ellipse(1, 2, "undefined", 4, "F"); + expect(function () { + priv(doc).ellipse(1, 2, "undefined", 4, "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.ellipse")); - expect(function() { - doc.__private__.ellipse(1, 2, 3, "undefined", "F"); + expect(function () { + priv(doc).ellipse(1, 2, 3, "undefined", "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.ellipse")); - expect(function() { - doc.__private__.ellipse(1, 2, 3, 4, "undefined"); + expect(function () { + priv(doc).ellipse(1, 2, 3, 4, "undefined"); }).toThrow(new Error("Invalid arguments passed to jsPDF.ellipse")); - expect(doc.__private__.ellipse(1, 2, 3, 4, "F")).toBe(doc.__private__); + expect(priv(doc).ellipse(1, 2, 3, 4, "F")).toBe(priv(doc)); - var writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.ellipse(1, 2, 3, 4, null); + var writeArray: string[] = []; + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).ellipse(1, 2, 3, 4, null); expect(writeArray).toEqual([ "11.34 836.22 m", "11.34 842.48 7.53 847.56 2.83 847.56 c", @@ -1713,8 +1946,8 @@ describe("Core: Unit Tests", () => { ]); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.ellipse(1, 2, 3, 4, "F"); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).ellipse(1, 2, 3, 4, "F"); expect(writeArray).toEqual([ "11.34 836.22 m", "11.34 842.48 7.53 847.56 2.83 847.56 c", @@ -1728,122 +1961,122 @@ describe("Core: Unit Tests", () => { it("jsPDF private function rect", () => { const doc = jsPDF({ floatPrecision: 2 }); - var writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.rect(1, 2, 3, 4, "F"); + var writeArray: string[] = []; + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).rect(1, 2, 3, 4, "F"); expect(writeArray).toEqual(["2.83 836.22 8.5 -11.34 re", "f"]); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.rect(1, 2, 3, 4, null); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).rect(1, 2, 3, 4, null); expect(writeArray).toEqual(["2.83 836.22 8.5 -11.34 re"]); - expect(function() { - doc.__private__.rect(1, 2, 3, 4, "F"); + expect(function () { + priv(doc).rect(1, 2, 3, 4, "F"); }).not.toThrow(new Error("Invalid arguments passed to jsPDF.rect")); - expect(function() { - doc.__private__.rect("invalid", 2, 3, 4, "F"); + expect(function () { + priv(doc).rect("invalid", 2, 3, 4, "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.rect")); - expect(function() { - doc.__private__.rect(1, "invalid", 3, 4, "F"); + expect(function () { + priv(doc).rect(1, "invalid", 3, 4, "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.rect")); - expect(function() { - doc.__private__.rect(1, 2, "invalid", 4, "F"); + expect(function () { + priv(doc).rect(1, 2, "invalid", 4, "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.rect")); - expect(function() { - doc.__private__.rect(1, 2, 3, "invalid", "F"); + expect(function () { + priv(doc).rect(1, 2, 3, "invalid", "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.rect")); - expect(function() { - doc.__private__.rect(1, 2, 3, 4, "invalid"); + expect(function () { + priv(doc).rect(1, 2, 3, 4, "invalid"); }).toThrow(new Error("Invalid arguments passed to jsPDF.rect")); - var writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.rect(1, 2, 3, 4, "F"); + var writeArray: string[] = []; + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).rect(1, 2, 3, 4, "F"); expect(writeArray).toEqual(["2.83 836.22 8.5 -11.34 re", "f"]); - expect(doc.__private__.rect(1, 2, 3, 4, "F")).toBe(doc.__private__); + expect(priv(doc).rect(1, 2, 3, 4, "F")).toBe(priv(doc)); }); it("jsPDF private function circle", () => { const doc = jsPDF({ floatPrecision: 2 }); - expect(function() { - doc.__private__.circle(1, 2, 3, "F"); + expect(function () { + priv(doc).circle(1, 2, 3, "F"); }).not.toThrow(new Error("Invalid arguments passed to jsPDF.circle")); - expect(function() { - doc.__private__.circle("undefined", 2, 3, "F"); + expect(function () { + priv(doc).circle("undefined", 2, 3, "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.circle")); - expect(function() { - doc.__private__.circle(1, "undefined", 3, "F"); + expect(function () { + priv(doc).circle(1, "undefined", 3, "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.circle")); - expect(function() { - doc.__private__.circle(1, 2, "undefined", "F"); + expect(function () { + priv(doc).circle(1, 2, "undefined", "F"); }).toThrow(new Error("Invalid arguments passed to jsPDF.circle")); - expect(function() { - doc.__private__.circle(1, 2, 3, "undefined"); + expect(function () { + priv(doc).circle(1, 2, 3, "undefined"); }).toThrow(new Error("Invalid arguments passed to jsPDF.circle")); - expect(doc.__private__.circle(1, 2, 3, "F")).toBe(doc.__private__); + expect(priv(doc).circle(1, 2, 3, "F")).toBe(priv(doc)); }); it("jsPDF private function clip", () => { var doc = jsPDF({ floatPrecision: 2 }); - var writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.clip("evenodd"); + var writeArray: string[] = []; + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).clip("evenodd"); expect(writeArray).toEqual(["W*"]); var doc = jsPDF({ floatPrecision: 2 }); - var writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.clip(); + var writeArray: string[] = []; + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).clip(); expect(writeArray).toEqual(["W"]); }); it("jsPDF private function discardPath", () => { var doc = jsPDF({ floatPrecision: 2 }); - var writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.discardPath(); + var writeArray: string[] = []; + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).discardPath(); expect(writeArray).toEqual(["n"]); }); it("jsPDF private function text", () => { var doc = jsPDF({ floatPrecision: 2 }); - var writeArray; + var writeArray: string[]; - expect(function() { - doc.__private__.text("valid", 10, 10); + expect(function () { + priv(doc).text("valid", 10, 10); }).not.toThrow(new Error("Invalid arguments passed to jsPDF.text")); - expect(function() { - doc.__private__.text(undefined, 10, 10); + expect(function () { + priv(doc).text(undefined, 10, 10); }).toThrow(new Error("Invalid arguments passed to jsPDF.text")); - expect(function() { - doc.__private__.text("valid", undefined, 10); + expect(function () { + priv(doc).text("valid", undefined, 10); }).toThrow(new Error("Invalid arguments passed to jsPDF.text")); - expect(function() { - doc.__private__.text("valid", "invalid", 10); + expect(function () { + priv(doc).text("valid", "invalid", 10); }).toThrow(new Error("Invalid arguments passed to jsPDF.text")); - expect(function() { - doc.__private__.text("valid", 10, "invalid"); + expect(function () { + priv(doc).text("valid", 10, "invalid"); }).toThrow(new Error("Invalid arguments passed to jsPDF.text")); - expect(function() { - doc.__private__.text("valid", 10, undefined); + expect(function () { + priv(doc).text("valid", 10, undefined); }).toThrow(new Error("Invalid arguments passed to jsPDF.text")); - expect(function() { - doc.__private__.text("valid"); + expect(function () { + priv(doc).text("valid"); }).toThrow(new Error("Invalid arguments passed to jsPDF.text")); - expect(function() { - doc.__private__.text(); + expect(function () { + priv(doc).text(); }).toThrow(new Error("Invalid arguments passed to jsPDF.text")); //check for latest method header (text, x, y, options); doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text("This is a test.", 10, 10, { scope: doc }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text("This is a test.", 10, 10, { scope: doc }); expect(writeArray).toEqual([ [ "BT", @@ -1859,8 +2092,8 @@ describe("Core: Unit Tests", () => { //check for old method header (x, y, text); doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { scope: doc }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc }); expect(writeArray).toEqual([ [ "BT", @@ -1876,8 +2109,8 @@ describe("Core: Unit Tests", () => { //check for latest method header (text, x, y, options); text is Array doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(["This is a test."], 10, 10, { scope: doc }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(["This is a test."], 10, 10, { scope: doc }); expect(writeArray).toEqual([ [ "BT", @@ -1906,8 +2139,8 @@ describe("Core: Unit Tests", () => { //multiline doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text( + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text( `This is a line break`, 10, @@ -1930,8 +2163,8 @@ break`, //check for angle-functionality; doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { scope: doc, angle: 10 }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, angle: 10 }); expect(writeArray).toEqual([ [ "BT", @@ -1947,8 +2180,8 @@ break`, //check for charSpace-functionality; doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, charSpace: 10 }); @@ -1968,8 +2201,8 @@ break`, //check for R2L-functionality; doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { scope: doc, R2L: true }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, R2L: true }); expect(writeArray).toEqual([ [ "BT", @@ -1985,8 +2218,8 @@ break`, //check for renderingMode-functionality - fill; doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, renderingMode: "fill" }); @@ -2005,8 +2238,8 @@ break`, doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, renderingMode: 0 }); @@ -2025,8 +2258,8 @@ break`, doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, renderingMode: false }); @@ -2046,8 +2279,8 @@ break`, //check for renderingMode-functionality - stroke; doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, renderingMode: "stroke" }); @@ -2066,8 +2299,8 @@ break`, doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, renderingMode: 1 }); @@ -2086,8 +2319,8 @@ break`, doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, renderingMode: true }); @@ -2107,8 +2340,8 @@ break`, //check for renderingMode-functionality - fillThenStroke; doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, renderingMode: "fillThenStroke" }); @@ -2127,8 +2360,8 @@ break`, doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, renderingMode: 2 }); @@ -2148,8 +2381,8 @@ break`, //check for renderingMode-functionality - invisible; doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, renderingMode: "invisible" }); @@ -2168,8 +2401,8 @@ break`, doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, renderingMode: 3 }); @@ -2189,8 +2422,8 @@ break`, //check for renderingMode-functionality - fillAndAddForClipping; doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, renderingMode: "fillAndAddForClipping" }); @@ -2209,8 +2442,8 @@ break`, doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, renderingMode: 4 }); @@ -2230,8 +2463,8 @@ break`, //check for renderingMode-functionality - strokeAndAddPathForClipping; doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, renderingMode: "strokeAndAddPathForClipping" }); @@ -2250,8 +2483,8 @@ break`, doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, renderingMode: 5 }); @@ -2271,8 +2504,8 @@ break`, //check for renderingMode-functionality - fillThenStrokeAndAddToPathForClipping; doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, renderingMode: "fillThenStrokeAndAddToPathForClipping" }); @@ -2291,8 +2524,8 @@ break`, doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, renderingMode: 6 }); @@ -2312,8 +2545,8 @@ break`, //check for renderingMode-functionality - addToPathForClipping; doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, renderingMode: "addToPathForClipping" }); @@ -2332,8 +2565,8 @@ break`, doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, renderingMode: 7 }); @@ -2353,13 +2586,13 @@ break`, //check for renderingMode-functionality - reset on second call; doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).text(10, 10, "This is a test.", { scope: doc, renderingMode: "addToPathForClipping" }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { scope: doc }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc }); expect(writeArray).toEqual([ [ "BT", @@ -2376,8 +2609,8 @@ break`, //check for align-functionality - right; doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(200, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(200, 10, "This is a test.", { scope: doc, align: "right" }); @@ -2396,8 +2629,8 @@ break`, //check for align-functionality - center; doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(200, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(200, 10, "This is a test.", { scope: doc, align: "center" }); @@ -2416,8 +2649,8 @@ break`, //check for align-functionality - center; doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, align: "justify", maxWidth: 30 @@ -2439,8 +2672,8 @@ break`, ]); //check for align-functionality - throw Error; - expect(function() { - doc.__private__.text(200, 10, "This is a test.", { + expect(function () { + priv(doc).text(200, 10, "This is a test.", { scope: doc, align: "invalid" }); @@ -2453,8 +2686,8 @@ break`, //check for maxWidth-functionality - too wide; doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, maxWidth: 600 }); @@ -2473,8 +2706,8 @@ break`, //check for maxWidth-functionality - has to split; doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text(10, 10, "This is a test.", { + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text(10, 10, "This is a test.", { scope: doc, maxWidth: 30 }); @@ -2494,8 +2727,8 @@ break`, //check for maxWidth-functionality - has to split, preserving multiline; doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.text( + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).text( `This is a test. This is a test too.`, 10, @@ -2521,17 +2754,20 @@ This is a test too.`, ]); }); - it('jsPDF test text with line height', function() { + it("jsPDF test text with line height", function () { const doc1 = new jsPDF(); - let writeArray1 = []; - doc1.__private__.setCustomOutputDestination(writeArray1); + let writeArray1: string[] = []; + priv(doc1).setCustomOutputDestination(writeArray1); doc1.setLineHeightFactor(1.5); - doc1.text('Some text', 10, 10, { baseline: 'middle' }); + doc1.text("Some text", 10, 10, { baseline: "middle" }); - let writeArray2 = []; + let writeArray2: string[] = []; const doc2 = new jsPDF(); - doc2.__private__.setCustomOutputDestination(writeArray2); - doc2.text('Some text', 10, 10, { lineHeightFactor: 1.5, baseline: 'middle' }); + priv(doc2).setCustomOutputDestination(writeArray2); + doc2.text("Some text", 10, 10, { + lineHeightFactor: 1.5, + baseline: "middle" + }); expect(writeArray1).toEqual(writeArray2); }); @@ -2539,16 +2775,16 @@ This is a test too.`, it("jsPDF private function setLineCap", () => { var doc = jsPDF({ floatPrecision: 2 }); - var writeArray; + var writeArray: string[]; //miter/butt doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.setLineCap("miter"); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).setLineCap("miter"); expect(writeArray).toEqual(["0 J"]); - expect(function() { - doc.__private__.setLineCap("invalid"); + expect(function () { + priv(doc).setLineCap("invalid"); }).toThrow( new Error( "Line cap style of 'invalid' is not recognized. See or extend .CapJoinStyles property for valid styles" @@ -2559,16 +2795,16 @@ This is a test too.`, it("jsPDF private function setLineJoin", () => { var doc = jsPDF({ floatPrecision: 2 }); - var writeArray; + var writeArray: string[]; //butt doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.setLineJoin("butt"); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).setLineJoin("butt"); expect(writeArray).toEqual(["0 j"]); - expect(function() { - doc.__private__.setLineJoin("invalid"); + expect(function () { + priv(doc).setLineJoin("invalid"); }).toThrow( new Error( "Line join style of 'invalid' is not recognized. See or extend .CapJoinStyles property for valid styles" @@ -2577,40 +2813,40 @@ This is a test too.`, }); it("jsPDF private function setLineMiterLimit", () => { - var writeArray; + var writeArray: string[]; //miter/butt var doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.setLineMiterLimit(1); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).setLineMiterLimit(1); expect(writeArray).toEqual(["2.83 M"]); - expect(function() { - doc.__private__.setLineMiterLimit("invalid"); + expect(function () { + priv(doc).setLineMiterLimit("invalid"); }).toThrow(new Error("Invalid argument passed to jsPDF.setLineMiterLimit")); }); it("jsPDF private function putHeader", () => { var doc = jsPDF({ floatPrecision: 2 }); - var writeArray; + var writeArray: string[]; //without documentProperties doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putHeader(); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putHeader(); expect(writeArray).toEqual(["%PDF-1.3", "%ºß¬à"]); }); it("jsPDF private function putCatalog", () => { var doc = jsPDF({ floatPrecision: 2 }); - var writeArray; + var writeArray: string[]; //putCatalog, default Values doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putCatalog({ rootDictionaryObjId: 1 }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putCatalog({ rootDictionaryObjId: 1 }); expect(writeArray).toEqual([ "3 0 obj", "<<", @@ -2624,10 +2860,10 @@ This is a test too.`, //putCatalog zoomModes doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setZoomMode(2); + priv(doc).setZoomMode(2); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putCatalog({ rootDictionaryObjId: 1 }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putCatalog({ rootDictionaryObjId: 1 }); expect(writeArray).toEqual([ "3 0 obj", "<<", @@ -2640,10 +2876,10 @@ This is a test too.`, ]); doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setZoomMode("200%"); + priv(doc).setZoomMode("200%"); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putCatalog({ rootDictionaryObjId: 1 }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putCatalog({ rootDictionaryObjId: 1 }); expect(writeArray).toEqual([ "3 0 obj", "<<", @@ -2656,10 +2892,10 @@ This is a test too.`, ]); doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setZoomMode("fullwidth"); + priv(doc).setZoomMode("fullwidth"); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putCatalog({ rootDictionaryObjId: 1 }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putCatalog({ rootDictionaryObjId: 1 }); expect(writeArray).toEqual([ "3 0 obj", "<<", @@ -2672,10 +2908,10 @@ This is a test too.`, ]); doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setZoomMode("fullheight"); + priv(doc).setZoomMode("fullheight"); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putCatalog({ rootDictionaryObjId: 1 }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putCatalog({ rootDictionaryObjId: 1 }); expect(writeArray).toEqual([ "3 0 obj", "<<", @@ -2688,10 +2924,10 @@ This is a test too.`, ]); doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setZoomMode("fullpage"); + priv(doc).setZoomMode("fullpage"); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putCatalog({ rootDictionaryObjId: 1 }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putCatalog({ rootDictionaryObjId: 1 }); expect(writeArray).toEqual([ "3 0 obj", "<<", @@ -2704,10 +2940,10 @@ This is a test too.`, ]); doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setZoomMode("original"); + priv(doc).setZoomMode("original"); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putCatalog({ rootDictionaryObjId: 1 }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putCatalog({ rootDictionaryObjId: 1 }); expect(writeArray).toEqual([ "3 0 obj", "<<", @@ -2721,10 +2957,10 @@ This is a test too.`, //putCatalog layoutModes doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setLayoutMode("continuous"); + priv(doc).setLayoutMode("continuous"); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putCatalog({ rootDictionaryObjId: 1 }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putCatalog({ rootDictionaryObjId: 1 }); expect(writeArray).toEqual([ "3 0 obj", "<<", @@ -2737,10 +2973,10 @@ This is a test too.`, ]); doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setLayoutMode("single"); + priv(doc).setLayoutMode("single"); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putCatalog({ rootDictionaryObjId: 1 }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putCatalog({ rootDictionaryObjId: 1 }); expect(writeArray).toEqual([ "3 0 obj", "<<", @@ -2753,10 +2989,10 @@ This is a test too.`, ]); doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setLayoutMode("twoleft"); + priv(doc).setLayoutMode("twoleft"); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putCatalog({ rootDictionaryObjId: 1 }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putCatalog({ rootDictionaryObjId: 1 }); expect(writeArray).toEqual([ "3 0 obj", "<<", @@ -2769,10 +3005,10 @@ This is a test too.`, ]); doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setLayoutMode("two"); + priv(doc).setLayoutMode("two"); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putCatalog({ rootDictionaryObjId: 1 }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putCatalog({ rootDictionaryObjId: 1 }); expect(writeArray).toEqual([ "3 0 obj", "<<", @@ -2785,10 +3021,10 @@ This is a test too.`, ]); doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setLayoutMode("tworight"); + priv(doc).setLayoutMode("tworight"); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putCatalog({ rootDictionaryObjId: 1 }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putCatalog({ rootDictionaryObjId: 1 }); expect(writeArray).toEqual([ "3 0 obj", "<<", @@ -2802,10 +3038,10 @@ This is a test too.`, //putCatalog layoutModes doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setPageMode("UseNone"); + priv(doc).setPageMode("UseNone"); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putCatalog({ rootDictionaryObjId: 1 }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putCatalog({ rootDictionaryObjId: 1 }); expect(writeArray).toEqual([ "3 0 obj", "<<", @@ -2819,10 +3055,10 @@ This is a test too.`, ]); doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setPageMode("UseOutlines"); + priv(doc).setPageMode("UseOutlines"); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putCatalog({ rootDictionaryObjId: 1 }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putCatalog({ rootDictionaryObjId: 1 }); expect(writeArray).toEqual([ "3 0 obj", "<<", @@ -2836,10 +3072,10 @@ This is a test too.`, ]); doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setPageMode("UseThumbs"); + priv(doc).setPageMode("UseThumbs"); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putCatalog({ rootDictionaryObjId: 1 }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putCatalog({ rootDictionaryObjId: 1 }); expect(writeArray).toEqual([ "3 0 obj", "<<", @@ -2853,10 +3089,10 @@ This is a test too.`, ]); doc = jsPDF({ floatPrecision: 2 }); - doc.__private__.setPageMode("FullScreen"); + priv(doc).setPageMode("FullScreen"); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putCatalog({ rootDictionaryObjId: 1 }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putCatalog({ rootDictionaryObjId: 1 }); expect(writeArray).toEqual([ "3 0 obj", "<<", @@ -2873,15 +3109,15 @@ This is a test too.`, it("jsPDF private function putInfo", () => { var doc = jsPDF({ floatPrecision: 2 }); - var writeArray; + var writeArray: string[]; //without documentProperties doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); + priv(doc).setCustomOutputDestination(writeArray); var pdfDateString = "D:19871210000000+00'00'"; - doc.__private__.setCreationDate(pdfDateString); - doc.__private__.putInfo(); + priv(doc).setCreationDate(pdfDateString); + priv(doc).putInfo(); expect(writeArray).toEqual([ "3 0 obj", "<<", @@ -2893,18 +3129,18 @@ This is a test too.`, doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); + priv(doc).setCustomOutputDestination(writeArray); var pdfDateString = "D:19871210000000+00'00'"; - doc.__private__.setCreationDate(pdfDateString); + priv(doc).setCreationDate(pdfDateString); - doc.__private__.setDocumentProperties({ + priv(doc).setDocumentProperties({ title: "Title", subject: "Subject", author: "Author X", keywords: "Keyword1, Keyword2", creator: "Creator" }); - doc.__private__.putInfo(); + priv(doc).putInfo(); expect(writeArray).toEqual([ "3 0 obj", "<<", @@ -2923,15 +3159,15 @@ This is a test too.`, it("jsPDF private function putTrailer", () => { var doc = jsPDF({ floatPrecision: 2 }); - var writeArray; + var writeArray: string[]; //without documentProperties doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); + priv(doc).setCustomOutputDestination(writeArray); - doc.__private__.setFileId("0000000000000000000000000BADFACE"); - doc.__private__.putTrailer(); + priv(doc).setFileId("0000000000000000000000000BADFACE"); + priv(doc).putTrailer(); expect(writeArray).toEqual([ "trailer", "<<", @@ -2945,12 +3181,12 @@ This is a test too.`, it("jsPDF private function putXRef", () => { var doc = jsPDF({ floatPrecision: 2 }); - var writeArray; + var writeArray: string[]; doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putXRef(); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putXRef(); expect(writeArray).toEqual([ "xref", "0 3", @@ -2962,12 +3198,12 @@ This is a test too.`, it("jsPDF private function putStream", () => { var doc = jsPDF({ floatPrecision: 2 }); - var writeArray; + var writeArray: string[]; doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putStream({ + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putStream({ data: "someData", filters: [], alreadyAppliedFilters: [] @@ -2983,8 +3219,8 @@ This is a test too.`, doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putStream({ + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putStream({ data: "someData", filters: [], alreadyAppliedFilters: [], @@ -3002,8 +3238,8 @@ This is a test too.`, doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putStream({ + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putStream({ data: "someData", filters: [], alreadyAppliedFilters: ["/FlateDecode", "/SomeFilter"] @@ -3020,8 +3256,8 @@ This is a test too.`, doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putStream({ + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putStream({ data: "someData", filters: [], alreadyAppliedFilters: "/FlateDecode /SomeFilter" @@ -3038,8 +3274,8 @@ This is a test too.`, doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putStream(); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putStream(); expect(writeArray).toEqual(["<<", ">>"]); var expected = bufferFromString( @@ -3056,20 +3292,20 @@ This is a test too.`, doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putStream({ data: "streamData", filters: ["FlateEncode"] }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putStream({ data: "streamData", filters: ["FlateEncode"] }); expect(bufferFromString(writeArray.join("\n"))).toEqual(expected); doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putStream({ data: "streamData", filters: true }); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putStream({ data: "streamData", filters: true }); expect(bufferFromString(writeArray.join("\n"))).toEqual(expected); doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putStream({ + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putStream({ data: "x\u009C+.)JMÌuI,I\u0004\u0000\u0016Ò\u0004\u0007", alreadyAppliedFilters: ["/FlateDecode"] }); @@ -3078,23 +3314,23 @@ This is a test too.`, it("jsPDF public function comment", () => { var doc = jsPDF({ floatPrecision: 2 }); - var writeArray; + var writeArray: string[]; doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); + priv(doc).setCustomOutputDestination(writeArray); doc.comment("test"); expect(writeArray).toEqual(["#test"]); }); it("jsPDF private function putPage", () => { var doc = jsPDF({ floatPrecision: 2 }); - var writeArray; + var writeArray: string[]; doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.putPage({ + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).putPage({ number: 1, data: ["streamData"], mediaBox: { @@ -3137,14 +3373,14 @@ This is a test too.`, it("jsPDF private function buildDocument", () => { var doc = jsPDF(); - var writeArray; + var writeArray: string[]; doc = jsPDF({ floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.setFileId("0000000000000000000000000BADFACE"); - doc.__private__.setCreationDate("D:19871210000000+00'00'"); - doc.__private__.buildDocument(); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).setFileId("0000000000000000000000000BADFACE"); + priv(doc).setCreationDate("D:19871210000000+00'00'"); + priv(doc).buildDocument(); expect(writeArray).toEqual([ "%PDF-1.3", "%ºß¬à", @@ -3382,10 +3618,10 @@ This is a test too.`, doc = jsPDF({ orientation: "l", floatPrecision: 2 }); writeArray = []; - doc.__private__.setCustomOutputDestination(writeArray); - doc.__private__.setFileId("0000000000000000000000000BADFACE"); - doc.__private__.setCreationDate("D:19871210000000+00'00'"); - doc.__private__.buildDocument(); + priv(doc).setCustomOutputDestination(writeArray); + priv(doc).setFileId("0000000000000000000000000BADFACE"); + priv(doc).setCreationDate("D:19871210000000+00'00'"); + priv(doc).buildDocument(); expect(writeArray).toEqual([ "%PDF-1.3", "%ºß¬à", @@ -3625,7 +3861,13 @@ This is a test too.`, it("jsPdf public function beginFormObject, endFormObject", () => { var doc = jsPDF(); var startContext = doc.internal.getCurrentPageInfo().pageContext; - doc.beginFormObject(0, 0, 100, 100, new doc.internal.Matrix(1, 0, 0, 1, 0, 0)); + doc.beginFormObject( + 0, + 0, + 100, + 100, + new doc.internal.Matrix(1, 0, 0, 1, 0, 0) + ); expect(doc.internal.getCurrentPageInfo().pageContext).not.toEqual( startContext ); @@ -3633,7 +3875,13 @@ This is a test too.`, expect(doc.internal.getCurrentPageInfo().pageContext).toEqual(startContext); // Adding a form object with the same id twice should keep stack intact - doc.beginFormObject(0, 0, 100, 100, new doc.internal.Matrix(1, 0, 0, 1, 0, 0)); + doc.beginFormObject( + 0, + 0, + 100, + 100, + new doc.internal.Matrix(1, 0, 0, 1, 0, 0) + ); expect(doc.internal.getCurrentPageInfo().pageContext).not.toEqual( startContext ); @@ -3642,7 +3890,7 @@ This is a test too.`, }); }); -function bufferFromString(string) { +function bufferFromString(string: string) { // return Array.apply([], Buffer.from(string, "utf-8")); var buffer = new Uint8Array(string.length); diff --git a/test/specs/language.spec.js b/test/specs/language.spec.ts similarity index 100% rename from test/specs/language.spec.js rename to test/specs/language.spec.ts diff --git a/test/specs/atobbtoa.spec.mjs b/test/specs/libs/atobbtoa.spec.ts similarity index 97% rename from test/specs/atobbtoa.spec.mjs rename to test/specs/libs/atobbtoa.spec.ts index d128beda1..616270903 100644 --- a/test/specs/atobbtoa.spec.mjs +++ b/test/specs/libs/atobbtoa.spec.ts @@ -1,4 +1,4 @@ -import { atob, btoa } from "../../src/libs/AtobBtoa.js"; +import { atob, btoa } from "../../../src/libs/AtobBtoa.js"; describe("Lib: AtobBtoa", () => { it("exports functions", () => { diff --git a/test/specs/blob.spec.mjs b/test/specs/libs/blob.spec.ts similarity index 98% rename from test/specs/blob.spec.mjs rename to test/specs/libs/blob.spec.ts index 92ab44417..747dc70d7 100644 --- a/test/specs/blob.spec.mjs +++ b/test/specs/libs/blob.spec.ts @@ -2,7 +2,7 @@ // that a working Blob (and File/FileReader/URL) implementation is available // on the global object. Importing it must not break the environment, and the // resulting global Blob must behave according to the Blob spec. -import "../../src/libs/Blob.js"; +import "../../../src/libs/Blob.js"; describe("Lib: Blob", () => { it("provides a global Blob constructor", () => { diff --git a/test/specs/bmpdecoder.spec.mjs b/test/specs/libs/bmpdecoder.spec.ts similarity index 75% rename from test/specs/bmpdecoder.spec.mjs rename to test/specs/libs/bmpdecoder.spec.ts index 160298d7a..e42bd81f5 100644 --- a/test/specs/bmpdecoder.spec.mjs +++ b/test/specs/libs/bmpdecoder.spec.ts @@ -1,7 +1,24 @@ -import { BmpDecoder } from "../../src/libs/BMPDecoder.js"; +import { BmpDecoder } from "../../../src/libs/BMPDecoder.js"; + +interface BmpDecoderInstance { + flag: string; + width: number; + height: number; + bitPP: number; + bottom_up: boolean; + data: Uint8Array; + getData(): Uint8Array; +} + +// BmpDecoder is a legacy function-style constructor without a construct +// signature, so cast it to a typed constructor for the tests. +const BmpDecoderCtor = BmpDecoder as unknown as new ( + buffer: Uint8Array, + isWithAlpha: boolean +) => BmpDecoderInstance; describe("Lib: BMPDecoder", () => { - function u32(value) { + function u32(value: number): number[] { return [ value & 255, (value >> 8) & 255, @@ -10,16 +27,16 @@ describe("Lib: BMPDecoder", () => { ]; } - function u16(value) { + function u16(value: number): number[] { return [value & 255, (value >> 8) & 255]; } // Minimal 2x2 24-bit bottom-up BMP: // top row: red (255,0,0), green (0,255,0) // bottom row: blue (0,0,255), white (255,255,255) - function create2x2Bmp24() { + function create2x2Bmp24(): Uint8Array { return new Uint8Array( - [].concat( + ([] as number[]).concat( [0x42, 0x4d], // "BM" u32(70), // file size u32(0), // reserved @@ -45,12 +62,12 @@ describe("Lib: BMPDecoder", () => { it("throws 'Invalid BMP File' for wrong magic bytes", () => { expect(function() { - new BmpDecoder(new Uint8Array([0x00, 0x01, 0x02, 0x03]), false); + new BmpDecoderCtor(new Uint8Array([0x00, 0x01, 0x02, 0x03]), false); }).toThrowError("Invalid BMP File"); }); it("parses the header of a 2x2 24-bit BMP", () => { - var decoder = new BmpDecoder(create2x2Bmp24(), false); + var decoder = new BmpDecoderCtor(create2x2Bmp24(), false); expect(decoder.flag).toBe("BM"); expect(decoder.width).toBe(2); @@ -60,7 +77,7 @@ describe("Lib: BMPDecoder", () => { }); it("decodes a 2x2 24-bit BMP to top-down RGBA pixel data", () => { - var decoder = new BmpDecoder(create2x2Bmp24(), false); + var decoder = new BmpDecoderCtor(create2x2Bmp24(), false); var data = decoder.getData(); expect(data instanceof Uint8Array).toBe(true); @@ -113,7 +130,7 @@ describe("Lib: BMPDecoder", () => { ], 54 ); - var decoder = new BmpDecoder(bytes, false); + var decoder = new BmpDecoderCtor(bytes, false); expect(decoder.height).toBe(2); expect(decoder.bottom_up).toBe(false); @@ -138,7 +155,7 @@ describe("Lib: BMPDecoder", () => { }); it("getData returns the decoded data property", () => { - var decoder = new BmpDecoder(create2x2Bmp24(), false); + var decoder = new BmpDecoderCtor(create2x2Bmp24(), false); expect(decoder.getData()).toBe(decoder.data); }); diff --git a/test/specs/console.spec.mjs b/test/specs/libs/console.spec.ts similarity index 94% rename from test/specs/console.spec.mjs rename to test/specs/libs/console.spec.ts index b9a42763e..54c16cc6e 100644 --- a/test/specs/console.spec.mjs +++ b/test/specs/libs/console.spec.ts @@ -1,5 +1,5 @@ -import { console } from "../../src/libs/console.js"; -import { globalObject } from "../../src/libs/globalObject.js"; +import { console } from "../../../src/libs/console.js"; +import { globalObject } from "../../../src/libs/globalObject.js"; describe("Lib: console", () => { it("exports log, warn and error functions", () => { diff --git a/test/specs/filesaver.spec.mjs b/test/specs/libs/filesaver.spec.ts similarity index 85% rename from test/specs/filesaver.spec.mjs rename to test/specs/libs/filesaver.spec.ts index 43b4670ef..07a4946fb 100644 --- a/test/specs/filesaver.spec.mjs +++ b/test/specs/libs/filesaver.spec.ts @@ -6,7 +6,7 @@ // jasmine.clock() is installed so those timeouts only fire when we tick the // clock, and the anchor's dispatchEvent is stubbed before ticking so no real // download/navigation is ever triggered. -import { saveAs } from "../../src/libs/FileSaver.js"; +import { saveAs } from "../../../src/libs/FileSaver.js"; describe("Lib: FileSaver", () => { it("exports saveAs as a function", () => { @@ -14,19 +14,19 @@ describe("Lib: FileSaver", () => { }); describe("saving a Blob", () => { - let createdAnchors; - let createObjectURLSpy; - let revokeObjectURLSpy; + let createdAnchors: HTMLAnchorElement[]; + let createObjectURLSpy: jasmine.Spy; + let revokeObjectURLSpy: jasmine.Spy; beforeEach(() => { jasmine.clock().install(); createdAnchors = []; const originalCreateElement = document.createElement.bind(document); - spyOn(document, "createElement").and.callFake(tagName => { + spyOn(document, "createElement").and.callFake((tagName: string) => { const element = originalCreateElement(tagName); if (String(tagName).toLowerCase() === "a") { - createdAnchors.push(element); + createdAnchors.push(element as HTMLAnchorElement); } return element; }); @@ -92,7 +92,8 @@ describe("Lib: FileSaver", () => { it("uses the blob's own name property when no name is given", () => { const blob = new Blob(["data"], { type: "text/plain" }); - blob.name = "from-blob.txt"; + // FileSaver reads an optional non-standard `name` property off the blob. + (blob as Blob & { name?: string }).name = "from-blob.txt"; try { saveAs(blob); @@ -118,7 +119,10 @@ describe("Lib: FileSaver", () => { // the click is scheduled with setTimeout(..., 0) jasmine.clock().tick(1); expect(anchor.dispatchEvent).toHaveBeenCalledTimes(1); - const event = anchor.dispatchEvent.calls.mostRecent().args[0]; + // dispatchEvent was replaced with a spy in stubClicks(). + const event: Event = ( + anchor.dispatchEvent as unknown as jasmine.Spy + ).calls.mostRecent().args[0]; expect(event.type).toBe("click"); expect(revokeObjectURLSpy).not.toHaveBeenCalled(); diff --git a/test/specs/fontfaces.spec.mjs b/test/specs/libs/fontfaces.spec.ts similarity index 98% rename from test/specs/fontfaces.spec.mjs rename to test/specs/libs/fontfaces.spec.ts index 960b112ed..f899b3a77 100644 --- a/test/specs/fontfaces.spec.mjs +++ b/test/specs/libs/fontfaces.spec.ts @@ -3,13 +3,14 @@ import { buildFontFaceMap, normalizeFontFace, parseFontFamily -} from "../../src/libs/fontFace.js"; +} from "../../../src/libs/fontFace.js"; +import type { FontFaceInput } from "../../../src/libs/fontFace.js"; -function fontFace(opts) { +function fontFace(opts: Partial): FontFaceInput { return { family: "TestFont", src: undefined, ...opts }; } -function merge(...args) { +function merge(...args: object[]) { return Object.assign({}, ...args); } diff --git a/test/specs/globalobject.spec.mjs b/test/specs/libs/globalobject.spec.ts similarity index 92% rename from test/specs/globalobject.spec.mjs rename to test/specs/libs/globalobject.spec.ts index 4514a0594..b280becfa 100644 --- a/test/specs/globalobject.spec.mjs +++ b/test/specs/libs/globalobject.spec.ts @@ -1,4 +1,4 @@ -import { globalObject } from "../../src/libs/globalObject.js"; +import { globalObject } from "../../../src/libs/globalObject.js"; describe("Lib: globalObject", () => { it("is defined", () => { diff --git a/test/specs/jpegencoder.spec.mjs b/test/specs/libs/jpegencoder.spec.ts similarity index 70% rename from test/specs/jpegencoder.spec.mjs rename to test/specs/libs/jpegencoder.spec.ts index b17e63267..b4d68eb34 100644 --- a/test/specs/jpegencoder.spec.mjs +++ b/test/specs/libs/jpegencoder.spec.ts @@ -1,7 +1,27 @@ -import { JPEGEncoder } from "../../src/libs/JPEGEncoder.js"; +import { JPEGEncoder } from "../../../src/libs/JPEGEncoder.js"; + +interface RGBAImageData { + width: number; + height: number; + data: Uint8Array; +} + +interface JPEGEncoderInstance { + encode(imageData: RGBAImageData): Uint8Array; +} + +// JPEGEncoder is a legacy function-style constructor without a construct +// signature, so cast it to a typed constructor for the tests. +const JPEGEncoderCtor = JPEGEncoder as unknown as new ( + quality?: number +) => JPEGEncoderInstance; describe("Lib: JPEGEncoder", () => { - function createImageData(width, height, rgba) { + function createImageData( + width: number, + height: number, + rgba: number[] + ): RGBAImageData { var data = new Uint8Array(width * height * 4); for (var i = 0; i < width * height; i++) { data[i * 4] = rgba[0]; @@ -13,7 +33,7 @@ describe("Lib: JPEGEncoder", () => { } it("encodes an 8x8 red image to a Uint8Array", () => { - var encoder = new JPEGEncoder(80); + var encoder = new JPEGEncoderCtor(80); var result = encoder.encode(createImageData(8, 8, [255, 0, 0, 255])); expect(result instanceof Uint8Array).toBe(true); @@ -21,7 +41,7 @@ describe("Lib: JPEGEncoder", () => { }); it("output starts with the JPEG SOI marker (0xFFD8)", () => { - var encoder = new JPEGEncoder(80); + var encoder = new JPEGEncoderCtor(80); var result = encoder.encode(createImageData(8, 8, [255, 0, 0, 255])); expect(result[0]).toBe(0xff); @@ -29,7 +49,7 @@ describe("Lib: JPEGEncoder", () => { }); it("output ends with the JPEG EOI marker (0xFFD9)", () => { - var encoder = new JPEGEncoder(80); + var encoder = new JPEGEncoderCtor(80); var result = encoder.encode(createImageData(8, 8, [255, 0, 0, 255])); expect(result[result.length - 2]).toBe(0xff); @@ -38,8 +58,8 @@ describe("Lib: JPEGEncoder", () => { it("is deterministic for fixed input and quality", () => { var imageData = createImageData(8, 8, [12, 128, 240, 255]); - var first = new JPEGEncoder(80).encode(imageData); - var second = new JPEGEncoder(80).encode(imageData); + var first = new JPEGEncoderCtor(80).encode(imageData); + var second = new JPEGEncoderCtor(80).encode(imageData); expect(first.length).toBe(second.length); expect(Array.from(first)).toEqual(Array.from(second)); @@ -47,22 +67,22 @@ describe("Lib: JPEGEncoder", () => { it("produces different output for different qualities", () => { var imageData = createImageData(8, 8, [255, 0, 0, 255]); - var high = new JPEGEncoder(80).encode(imageData); - var low = new JPEGEncoder(10).encode(imageData); + var high = new JPEGEncoderCtor(80).encode(imageData); + var low = new JPEGEncoderCtor(10).encode(imageData); expect(Array.from(high)).not.toEqual(Array.from(low)); }); it("defaults to quality 50 when constructed without arguments", () => { var imageData = createImageData(8, 8, [255, 0, 0, 255]); - var implicit = new JPEGEncoder().encode(imageData); - var explicit = new JPEGEncoder(50).encode(imageData); + var implicit = new JPEGEncoderCtor().encode(imageData); + var explicit = new JPEGEncoderCtor(50).encode(imageData); expect(Array.from(implicit)).toEqual(Array.from(explicit)); }); it("encodes image dimensions that are not multiples of 8", () => { - var encoder = new JPEGEncoder(75); + var encoder = new JPEGEncoderCtor(75); var result = encoder.encode(createImageData(3, 5, [0, 255, 0, 255])); expect(result[0]).toBe(0xff); @@ -74,7 +94,7 @@ describe("Lib: JPEGEncoder", () => { it("writes the image dimensions into the SOF0 segment", () => { var width = 6; var height = 4; - var result = new JPEGEncoder(80).encode( + var result = new JPEGEncoderCtor(80).encode( createImageData(width, height, [10, 20, 30, 255]) ); diff --git a/test/specs/omggif.spec.mjs b/test/specs/libs/omggif.spec.ts similarity index 68% rename from test/specs/omggif.spec.mjs rename to test/specs/libs/omggif.spec.ts index 69074782e..0a81571e9 100644 --- a/test/specs/omggif.spec.mjs +++ b/test/specs/libs/omggif.spec.ts @@ -1,4 +1,51 @@ -import { GifReader, GifWriter } from "../../src/libs/omggif.js"; +import { GifReader, GifWriter } from "../../../src/libs/omggif.js"; + +interface GifFrameInfo { + x: number; + y: number; + width: number; + height: number; + has_local_palette: boolean; + interlaced: boolean; + transparent_index: number | null; +} + +interface GifReaderInstance { + width: number; + height: number; + numFrames(): number; + frameInfo(frameNum: number): GifFrameInfo; + decodeAndBlitFrameRGBA(frameNum: number, pixels: Uint8Array): void; + decodeAndBlitFrameBGRA(frameNum: number, pixels: Uint8Array): void; +} + +interface GifWriterOptions { + palette?: number[]; +} + +interface GifWriterInstance { + addFrame( + x: number, + y: number, + w: number, + h: number, + indexedPixels: number[], + opts: GifWriterOptions + ): number; + end(): number; +} + +// GifReader and GifWriter are legacy function-style constructors without +// construct signatures, so cast them to typed constructors for the tests. +const GifReaderCtor = GifReader as unknown as new ( + buf: Uint8Array +) => GifReaderInstance; +const GifWriterCtor = GifWriter as unknown as new ( + buf: Uint8Array, + width: number, + height: number, + gopts: GifWriterOptions +) => GifWriterInstance; describe("Lib: omggif", () => { // Minimal 2x2 GIF89a with a two-color global palette (red, green) and @@ -20,12 +67,12 @@ describe("Lib: omggif", () => { describe("GifReader", () => { it("throws for an invalid header", () => { expect(function() { - new GifReader(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8])); + new GifReaderCtor(new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8])); }).toThrowError("Invalid GIF 87a/89a header."); }); it("parses width, height and frame count of a 2x2 GIF", () => { - var reader = new GifReader(minimalGif); + var reader = new GifReaderCtor(minimalGif); expect(reader.width).toBe(2); expect(reader.height).toBe(2); @@ -33,7 +80,7 @@ describe("Lib: omggif", () => { }); it("reports frame info", () => { - var reader = new GifReader(minimalGif); + var reader = new GifReaderCtor(minimalGif); var info = reader.frameInfo(0); expect(info.x).toBe(0); @@ -46,7 +93,7 @@ describe("Lib: omggif", () => { }); it("throws for an out of range frame index", () => { - var reader = new GifReader(minimalGif); + var reader = new GifReaderCtor(minimalGif); expect(function() { reader.frameInfo(1); @@ -57,7 +104,7 @@ describe("Lib: omggif", () => { }); it("decodes RGBA pixel data", () => { - var reader = new GifReader(minimalGif); + var reader = new GifReaderCtor(minimalGif); var pixels = new Uint8Array(2 * 2 * 4); reader.decodeAndBlitFrameRGBA(0, pixels); @@ -84,7 +131,7 @@ describe("Lib: omggif", () => { }); it("decodes BGRA pixel data", () => { - var reader = new GifReader(minimalGif); + var reader = new GifReaderCtor(minimalGif); var pixels = new Uint8Array(2 * 2 * 4); reader.decodeAndBlitFrameBGRA(0, pixels); @@ -112,7 +159,7 @@ describe("Lib: omggif", () => { describe("GifWriter", () => { it("throws for a palette size that is not a power of two", () => { expect(function() { - new GifWriter(new Uint8Array(64), 2, 2, { + new GifWriterCtor(new Uint8Array(64), 2, 2, { palette: [0xff0000, 0x00ff00, 0x0000ff] }); }).toThrowError( @@ -122,15 +169,15 @@ describe("Lib: omggif", () => { it("throws for invalid dimensions", () => { expect(function() { - new GifWriter(new Uint8Array(64), 0, 2, {}); + new GifWriterCtor(new Uint8Array(64), 0, 2, {}); }).toThrowError("Width/Height invalid."); expect(function() { - new GifWriter(new Uint8Array(64), 2, 65536, {}); + new GifWriterCtor(new Uint8Array(64), 2, 65536, {}); }).toThrowError("Width/Height invalid."); }); it("throws when there are not enough pixels for the frame size", () => { - var writer = new GifWriter(new Uint8Array(128), 2, 2, {}); + var writer = new GifWriterCtor(new Uint8Array(128), 2, 2, {}); expect(function() { writer.addFrame(0, 0, 2, 2, [0, 1, 1], { @@ -141,7 +188,7 @@ describe("Lib: omggif", () => { it("round-trips a 2x2 image through GifWriter and GifReader", () => { var buf = new Uint8Array(1024); - var writer = new GifWriter(buf, 2, 2, { + var writer = new GifWriterCtor(buf, 2, 2, { palette: [0xff0000, 0x00ff00] }); writer.addFrame(0, 0, 2, 2, [0, 1, 1, 0], {}); @@ -149,7 +196,7 @@ describe("Lib: omggif", () => { expect(Array.from(gifBytes)).toEqual(Array.from(minimalGif)); - var reader = new GifReader(gifBytes); + var reader = new GifReaderCtor(gifBytes); var pixels = new Uint8Array(2 * 2 * 4); reader.decodeAndBlitFrameRGBA(0, pixels); diff --git a/test/specs/pdfname.spec.mjs b/test/specs/libs/pdfname.spec.ts similarity index 97% rename from test/specs/pdfname.spec.mjs rename to test/specs/libs/pdfname.spec.ts index 8af3485aa..f3453744d 100644 --- a/test/specs/pdfname.spec.mjs +++ b/test/specs/libs/pdfname.spec.ts @@ -1,4 +1,4 @@ -import { toPDFName } from "../../src/libs/pdfname.js"; +import { toPDFName } from "../../../src/libs/pdfname.js"; describe("Lib: pdfname", ()=>{ it("ASCII control characters to pdf name", ()=>{ diff --git a/test/specs/rgbcolor.spec.mjs b/test/specs/libs/rgbcolor.spec.ts similarity index 65% rename from test/specs/rgbcolor.spec.mjs rename to test/specs/libs/rgbcolor.spec.ts index 64d160039..91c2d220c 100644 --- a/test/specs/rgbcolor.spec.mjs +++ b/test/specs/libs/rgbcolor.spec.ts @@ -1,9 +1,24 @@ -import { RGBColor } from "../../src/libs/rgbcolor.js"; +import { RGBColor } from "../../../src/libs/rgbcolor.js"; + +interface RGBColorInstance { + ok: boolean; + r: number; + g: number; + b: number; + toHex(): string; + toRGB(): string; +} + +// RGBColor is a legacy function-style constructor without a construct +// signature, so cast it to a typed constructor for the tests. +const RGBColorCtor = RGBColor as unknown as new ( + colorString?: string +) => RGBColorInstance; describe("Lib: rgbcolor", () => { describe("named colors", () => { it("parses simple named colors", () => { - var color = new RGBColor("red"); + var color = new RGBColorCtor("red"); expect(color.ok).toBe(true); expect(color.r).toBe(255); expect(color.g).toBe(0); @@ -11,29 +26,29 @@ describe("Lib: rgbcolor", () => { }); it("is case-insensitive", () => { - var color = new RGBColor("RED"); + var color = new RGBColorCtor("RED"); expect(color.ok).toBe(true); expect(color.toHex()).toBe("#ff0000"); }); it("strips spaces from named colors", () => { - var color = new RGBColor(" Light Blue "); + var color = new RGBColorCtor(" Light Blue "); expect(color.ok).toBe(true); expect(color.toHex()).toBe("#add8e6"); }); it("parses a selection of named colors to their hex values", () => { - expect(new RGBColor("black").toHex()).toBe("#000000"); - expect(new RGBColor("white").toHex()).toBe("#ffffff"); - expect(new RGBColor("rebeccapurple").ok).toBe(false); - expect(new RGBColor("seashell").toHex()).toBe("#fff5ee"); - expect(new RGBColor("yellowgreen").toHex()).toBe("#9acd32"); + expect(new RGBColorCtor("black").toHex()).toBe("#000000"); + expect(new RGBColorCtor("white").toHex()).toBe("#ffffff"); + expect(new RGBColorCtor("rebeccapurple").ok).toBe(false); + expect(new RGBColorCtor("seashell").toHex()).toBe("#fff5ee"); + expect(new RGBColorCtor("yellowgreen").toHex()).toBe("#9acd32"); }); }); describe("hex colors", () => { it("parses 6-digit hex with leading #", () => { - var color = new RGBColor("#00ff00"); + var color = new RGBColorCtor("#00ff00"); expect(color.ok).toBe(true); expect(color.r).toBe(0); expect(color.g).toBe(255); @@ -41,7 +56,7 @@ describe("Lib: rgbcolor", () => { }); it("parses 6-digit hex without leading #", () => { - var color = new RGBColor("336699"); + var color = new RGBColorCtor("336699"); expect(color.ok).toBe(true); expect(color.r).toBe(51); expect(color.g).toBe(102); @@ -49,7 +64,7 @@ describe("Lib: rgbcolor", () => { }); it("parses 3-digit hex with leading #", () => { - var color = new RGBColor("#0f0"); + var color = new RGBColorCtor("#0f0"); expect(color.ok).toBe(true); expect(color.r).toBe(0); expect(color.g).toBe(255); @@ -57,7 +72,7 @@ describe("Lib: rgbcolor", () => { }); it("parses 3-digit hex without leading #", () => { - var color = new RGBColor("fb0"); + var color = new RGBColorCtor("fb0"); expect(color.ok).toBe(true); expect(color.r).toBe(255); expect(color.g).toBe(187); @@ -65,21 +80,21 @@ describe("Lib: rgbcolor", () => { }); it("is case-insensitive for hex digits", () => { - var color = new RGBColor("#00FF00"); + var color = new RGBColorCtor("#00FF00"); expect(color.ok).toBe(true); expect(color.toHex()).toBe("#00ff00"); }); it("only considers the first 6 characters after a leading #", () => { // 8-digit hex (with alpha) is truncated to the first 6 digits - var color = new RGBColor("#ff0000cc"); + var color = new RGBColorCtor("#ff0000cc"); expect(color.ok).toBe(true); expect(color.toHex()).toBe("#ff0000"); }); it("accepts non-hex word characters and treats them as 0", () => { // The hex regex matches \w, so "zzzzzz" parses "ok" but yields black - var color = new RGBColor("zzzzzz"); + var color = new RGBColorCtor("zzzzzz"); expect(color.ok).toBe(true); expect(color.toHex()).toBe("#000000"); }); @@ -87,7 +102,7 @@ describe("Lib: rgbcolor", () => { describe("rgb() colors", () => { it("parses rgb() with spaces", () => { - var color = new RGBColor("rgb(1, 2, 3)"); + var color = new RGBColorCtor("rgb(1, 2, 3)"); expect(color.ok).toBe(true); expect(color.r).toBe(1); expect(color.g).toBe(2); @@ -95,7 +110,7 @@ describe("Lib: rgbcolor", () => { }); it("parses rgb() without spaces", () => { - var color = new RGBColor("rgb(255,234,245)"); + var color = new RGBColorCtor("rgb(255,234,245)"); expect(color.ok).toBe(true); expect(color.r).toBe(255); expect(color.g).toBe(234); @@ -103,7 +118,7 @@ describe("Lib: rgbcolor", () => { }); it("clamps channel values greater than 255", () => { - var color = new RGBColor("rgb(300, 300, 300)"); + var color = new RGBColorCtor("rgb(300, 300, 300)"); expect(color.ok).toBe(true); expect(color.r).toBe(255); expect(color.g).toBe(255); @@ -111,19 +126,19 @@ describe("Lib: rgbcolor", () => { }); it("does not parse negative channel values", () => { - var color = new RGBColor("rgb(-1,0,0)"); + var color = new RGBColorCtor("rgb(-1,0,0)"); expect(color.ok).toBe(false); }); it("does not parse rgba()", () => { - var color = new RGBColor("rgba(1,2,3,1)"); + var color = new RGBColorCtor("rgba(1,2,3,1)"); expect(color.ok).toBe(false); }); }); describe("invalid input", () => { it("sets ok to false and defaults channels to 0", () => { - var color = new RGBColor("not a color"); + var color = new RGBColorCtor("not a color"); expect(color.ok).toBe(false); expect(color.r).toBe(0); expect(color.g).toBe(0); @@ -131,14 +146,14 @@ describe("Lib: rgbcolor", () => { }); it("handles an empty string", () => { - var color = new RGBColor(""); + var color = new RGBColorCtor(""); expect(color.ok).toBe(false); expect(color.toHex()).toBe("#000000"); expect(color.toRGB()).toBe("rgb(0, 0, 0)"); }); it("handles undefined input", () => { - var color = new RGBColor(undefined); + var color = new RGBColorCtor(undefined); expect(color.ok).toBe(false); expect(color.toHex()).toBe("#000000"); }); @@ -146,13 +161,13 @@ describe("Lib: rgbcolor", () => { describe("getters", () => { it("toRGB formats the parsed color", () => { - expect(new RGBColor("#010203").toRGB()).toBe("rgb(1, 2, 3)"); - expect(new RGBColor("red").toRGB()).toBe("rgb(255, 0, 0)"); + expect(new RGBColorCtor("#010203").toRGB()).toBe("rgb(1, 2, 3)"); + expect(new RGBColorCtor("red").toRGB()).toBe("rgb(255, 0, 0)"); }); it("toHex zero-pads single-digit channels", () => { - expect(new RGBColor("rgb(1, 2, 3)").toHex()).toBe("#010203"); - expect(new RGBColor("rgb(15, 16, 255)").toHex()).toBe("#0f10ff"); + expect(new RGBColorCtor("rgb(1, 2, 3)").toHex()).toBe("#010203"); + expect(new RGBColorCtor("rgb(15, 16, 255)").toHex()).toBe("#0f10ff"); }); }); }); diff --git a/test/specs/webpdecoder.spec.mjs b/test/specs/libs/webpdecoder.spec.ts similarity index 56% rename from test/specs/webpdecoder.spec.mjs rename to test/specs/libs/webpdecoder.spec.ts index 6bc2e865c..d5611d4da 100644 --- a/test/specs/webpdecoder.spec.mjs +++ b/test/specs/libs/webpdecoder.spec.ts @@ -1,11 +1,25 @@ -import { WebPDecoder } from "../../src/libs/WebPDecoder.js"; +import { WebPDecoder } from "../../../src/libs/WebPDecoder.js"; + +interface WebPDecoderInstance { + width: number[]; + height: number[]; + data: Uint8Array; + getData(): Uint8Array; +} + +// WebPDecoder is a legacy function-style constructor without a construct +// signature, so cast it to a typed constructor for the tests. +const WebPDecoderCtor = WebPDecoder as unknown as new ( + imageData: Uint8Array, + hasAlpha: boolean +) => WebPDecoderInstance; describe("Lib: WebPDecoder", () => { // 1x1 white lossy (VP8) WebP image. var oneByOneWhiteWebP = "UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoBAAEAAwA0JaQAA3AA/vuUAAA="; - function base64ToUint8Array(base64) { + function base64ToUint8Array(base64: string): Uint8Array { var binary = atob(base64); var bytes = new Uint8Array(binary.length); for (var i = 0; i < binary.length; i++) { @@ -16,12 +30,12 @@ describe("Lib: WebPDecoder", () => { it("throws for data that is not a RIFF/WebP container", () => { expect(function() { - new WebPDecoder(new Uint8Array([0x01, 0x02, 0x03, 0x04]), false); + new WebPDecoderCtor(new Uint8Array([0x01, 0x02, 0x03, 0x04]), false); }).toThrow(); }); it("decodes the dimensions of a 1x1 lossy WebP", () => { - var decoder = new WebPDecoder(base64ToUint8Array(oneByOneWhiteWebP), false); + var decoder = new WebPDecoderCtor(base64ToUint8Array(oneByOneWhiteWebP), false); // width and height are reported as single-element arrays expect(decoder.width[0]).toBe(1); @@ -29,7 +43,7 @@ describe("Lib: WebPDecoder", () => { }); it("decodes a 1x1 white WebP to opaque white RGBA pixel data", () => { - var decoder = new WebPDecoder(base64ToUint8Array(oneByOneWhiteWebP), false); + var decoder = new WebPDecoderCtor(base64ToUint8Array(oneByOneWhiteWebP), false); var pixels = decoder.getData(); expect(pixels.length).toBe(1 * 1 * 4); @@ -40,7 +54,7 @@ describe("Lib: WebPDecoder", () => { }); it("getData returns the decoded data property", () => { - var decoder = new WebPDecoder(base64ToUint8Array(oneByOneWhiteWebP), false); + var decoder = new WebPDecoderCtor(base64ToUint8Array(oneByOneWhiteWebP), false); expect(decoder.getData()).toBe(decoder.data); }); diff --git a/test/specs/outline.spec.js b/test/specs/outline.spec.ts similarity index 100% rename from test/specs/outline.spec.js rename to test/specs/outline.spec.ts diff --git a/test/specs/pages.spec.js b/test/specs/pages.spec.ts similarity index 100% rename from test/specs/pages.spec.js rename to test/specs/pages.spec.ts diff --git a/test/specs/png.spec.js b/test/specs/png.spec.ts similarity index 99% rename from test/specs/png.spec.js rename to test/specs/png.spec.ts index 4d0ac90ed..8a5c650ad 100644 --- a/test/specs/png.spec.js +++ b/test/specs/png.spec.ts @@ -401,7 +401,7 @@ describe("Module: PNGSupport", () => { describe("more PNGs", () => { beforeAll(loadGlobals); - function runTest(fileName, compression) { + function runTest(fileName: string, compression: "NONE" | "MEDIUM") { const testName = fileName.replace(/\.png$/i, ""); const pngData = loadBinaryResource("reference/images/" + fileName); const doc = new jsPDF({ diff --git a/test/specs/processArabic.spec.js b/test/specs/processArabic.spec.ts similarity index 86% rename from test/specs/processArabic.spec.js rename to test/specs/processArabic.spec.ts index 5b50f86a9..249ccbcf6 100644 --- a/test/specs/processArabic.spec.js +++ b/test/specs/processArabic.spec.ts @@ -1,25 +1,25 @@ /* global describe, it, expect, jsPDF */ -describe("Module: ArabicParser", function() { +describe("Module: ArabicParser", function () { beforeAll(loadGlobals); - it("isArabicLetter", function() { + it("isArabicLetter", function () { expect(jsPDF.API.__arabicParser__.isArabicLetter("ف")).toEqual(true); expect(jsPDF.API.__arabicParser__.isArabicLetter("a")).toEqual(false); }); - it("isArabicEndLetter", function() { + it("isArabicEndLetter", function () { expect(jsPDF.API.__arabicParser__.isArabicEndLetter("د")).toEqual(true); expect(jsPDF.API.__arabicParser__.isArabicEndLetter("ف")).toEqual(false); expect(jsPDF.API.__arabicParser__.isArabicEndLetter("a")).toEqual(false); }); - it("isArabicAlfLetter", function() { + it("isArabicAlfLetter", function () { expect(jsPDF.API.__arabicParser__.isArabicAlfLetter("ا")).toEqual(true); expect(jsPDF.API.__arabicParser__.isArabicAlfLetter("د")).toEqual(false); expect(jsPDF.API.__arabicParser__.isArabicAlfLetter("ف")).toEqual(false); expect(jsPDF.API.__arabicParser__.isArabicAlfLetter("a")).toEqual(false); }); - it("arabicLetterHasIsolatedForm", function() { + it("arabicLetterHasIsolatedForm", function () { expect(jsPDF.API.__arabicParser__.arabicLetterHasIsolatedForm("ا")).toEqual( true ); @@ -34,7 +34,7 @@ describe("Module: ArabicParser", function() { ); }); - it("arabicLetterHasFinalForm", function() { + it("arabicLetterHasFinalForm", function () { expect(jsPDF.API.__arabicParser__.arabicLetterHasFinalForm("ا")).toEqual( true ); @@ -49,7 +49,7 @@ describe("Module: ArabicParser", function() { ); }); - it("arabicLetterHasInitialForm", function() { + it("arabicLetterHasInitialForm", function () { expect(jsPDF.API.__arabicParser__.arabicLetterHasInitialForm("ا")).toEqual( false ); @@ -65,7 +65,7 @@ describe("Module: ArabicParser", function() { ); }); - it("arabicLetterHasMedialForm", function() { + it("arabicLetterHasMedialForm", function () { expect(jsPDF.API.__arabicParser__.arabicLetterHasMedialForm("ا")).toEqual( false ); @@ -81,7 +81,7 @@ describe("Module: ArabicParser", function() { ); }); - it("isArabicDiacritic", function() { + it("isArabicDiacritic", function () { expect(jsPDF.API.__arabicParser__.isArabicDiacritic("ا")).toEqual(false); expect(jsPDF.API.__arabicParser__.isArabicDiacritic("د")).toEqual(false); expect(jsPDF.API.__arabicParser__.isArabicDiacritic("ف")).toEqual(false); @@ -89,7 +89,7 @@ describe("Module: ArabicParser", function() { expect(jsPDF.API.__arabicParser__.isArabicDiacritic("a")).toEqual(false); }); - it("getCorrectForm", function() { + it("getCorrectForm", function () { expect(jsPDF.API.__arabicParser__.getCorrectForm("a", "", "")).toEqual(-1); expect(jsPDF.API.__arabicParser__.isArabicDiacritic("د")).toEqual(false); expect(jsPDF.API.__arabicParser__.isArabicDiacritic("ف")).toEqual(false); @@ -97,7 +97,7 @@ describe("Module: ArabicParser", function() { expect(jsPDF.API.__arabicParser__.isArabicDiacritic("a")).toEqual(false); }); - it("feh", function() { + it("feh", function () { expect(jsPDF.API.processArabic("ف").charCodeAt(0)).toEqual(65233); expect(jsPDF.API.processArabic("دف").charCodeAt(1)).toEqual(65233); @@ -120,7 +120,7 @@ describe("Module: ArabicParser", function() { expect(jsPDF.API.processArabic("فففف").charCodeAt(3)).toEqual(65234); }); - it("dal", function() { + it("dal", function () { expect(jsPDF.API.processArabic("د").charCodeAt(0)).toEqual(65193); expect(jsPDF.API.processArabic("دف").charCodeAt(0)).toEqual(65193); @@ -141,7 +141,7 @@ describe("Module: ArabicParser", function() { expect(jsPDF.API.processArabic("ددد").charCodeAt(2)).toEqual(65193); }); - it("resolveLigatures", function() { + it("resolveLigatures", function () { expect( jsPDF.API.__arabicParser__.resolveLigatures("ﻟﺎ").charCodeAt(0) ).toEqual(65275); @@ -150,7 +150,7 @@ describe("Module: ArabicParser", function() { ).toEqual(65275); }); - it("lam alif", function() { + it("lam alif", function () { expect(jsPDF.API.processArabic("لا").charCodeAt(0)).toEqual(65275); expect(jsPDF.API.processArabic("لاا").charCodeAt(0)).toEqual(65275); @@ -168,19 +168,24 @@ describe("Module: ArabicParser", function() { expect(jsPDF.API.processArabic("دلاا").charCodeAt(2)).toEqual(65165); }); - it("alif", function() { + it("alif", function () { expect(jsPDF.API.processArabic("اَ").charCodeAt(0)).toEqual(65165); }); - it("ligatures", function() { + it("ligatures", function () { expect(jsPDF.API.processArabic("الله").charCodeAt(0)).toEqual(65010); }); - it("position array passthrough", function() { + it("position array passthrough", function () { expect( - jsPDF.API.processArabic({ text: [["الله", 0, 0]] }).text[0][0].charCodeAt( - 0 - ) + // Minimal payload cast: at runtime processArabic only reads and + // rewrites `.text`, so the other payload members can be omitted. + ( + jsPDF.API.processArabic({ + text: [["الله", 0, 0]] + } as unknown as import("../../src/types.js").TextProcessingPayload) + .text as unknown as [string, number, number][] + )[0][0].charCodeAt(0) ).toEqual(65010); }); }); diff --git a/test/specs/putTotalPages.spec.js b/test/specs/putTotalPages.spec.ts similarity index 100% rename from test/specs/putTotalPages.spec.js rename to test/specs/putTotalPages.spec.ts diff --git a/test/specs/rgba.spec.js b/test/specs/rgba.spec.ts similarity index 100% rename from test/specs/rgba.spec.js rename to test/specs/rgba.spec.ts diff --git a/test/specs/shapes.spec.js b/test/specs/shapes.spec.ts similarity index 100% rename from test/specs/shapes.spec.js rename to test/specs/shapes.spec.ts diff --git a/test/specs/split_text_to_size.spec.js b/test/specs/split_text_to_size.spec.ts similarity index 100% rename from test/specs/split_text_to_size.spec.js rename to test/specs/split_text_to_size.spec.ts diff --git a/test/specs/svg.spec.js b/test/specs/svg.spec.ts similarity index 100% rename from test/specs/svg.spec.js rename to test/specs/svg.spec.ts diff --git a/test/specs/text.spec.js b/test/specs/text.spec.ts similarity index 97% rename from test/specs/text.spec.js rename to test/specs/text.spec.ts index a824a8cb7..345891a23 100644 --- a/test/specs/text.spec.js +++ b/test/specs/text.spec.ts @@ -178,7 +178,10 @@ break` it("should justify custom font", () => { const doc = jsPDF({ floatPrecision: 2 }); var PTSans; - if (typeof global === "object" && global.isNode === true) { + if ( + typeof global === "object" && + (global as { isNode?: boolean }).isNode === true + ) { doc.allowFsRead = ["./test/reference/PTSans.ttf"]; PTSans = doc.loadFile("./test/reference/PTSans.ttf"); } else { @@ -203,7 +206,8 @@ break` it("should throw an error if not a string", () => { expect(() => { const doc = jsPDF({ floatPrecision: 2 }); - doc.text(10, 10, 43290943); + // Deliberately invalid: text must be a string or array (negative test). + doc.text(10, 10, 43290943 as unknown as string); }).toThrow( new Error('Type of text must be string or Array. "10" is not recognized.') ); diff --git a/test/specs/ttfsupport.spec.js b/test/specs/ttfsupport.spec.ts similarity index 100% rename from test/specs/ttfsupport.spec.js rename to test/specs/ttfsupport.spec.ts diff --git a/test/specs/unicode.spec.js b/test/specs/unicode.spec.ts similarity index 100% rename from test/specs/unicode.spec.js rename to test/specs/unicode.spec.ts diff --git a/test/specs/vfs.spec.js b/test/specs/vfs.spec.ts similarity index 100% rename from test/specs/vfs.spec.js rename to test/specs/vfs.spec.ts diff --git a/test/specs/viewerpreferences.spec.js b/test/specs/viewerpreferences.spec.ts similarity index 100% rename from test/specs/viewerpreferences.spec.js rename to test/specs/viewerpreferences.spec.ts diff --git a/test/specs/webp.spec.js b/test/specs/webp.spec.ts similarity index 100% rename from test/specs/webp.spec.js rename to test/specs/webp.spec.ts diff --git a/test/specs/xmpmetadata.spec.js b/test/specs/xmpmetadata.spec.ts similarity index 100% rename from test/specs/xmpmetadata.spec.js rename to test/specs/xmpmetadata.spec.ts diff --git a/test/tsconfig.json b/test/tsconfig.json new file mode 100644 index 000000000..e0b3e6938 --- /dev/null +++ b/test/tsconfig.json @@ -0,0 +1,14 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "types": [ + "jasmine" + ] + }, + "include": [ + "globals.d.ts", + "specs/**/*.ts", + "utils/**/*.ts", + "../src/modules/canvg.d.ts" + ] +} diff --git a/test/unit/karma.conf.js b/test/unit/karma.conf.js index ab6143d5a..f5c71f20a 100644 --- a/test/unit/karma.conf.js +++ b/test/unit/karma.conf.js @@ -21,7 +21,7 @@ module.exports = config => { "node_modules/canvg/lib/umd.js", "node_modules/html2canvas/dist/html2canvas.js", "node_modules/dompurify/dist/purify.js", - "test/utils/compare.js", + "test/utils/compare.ts", { pattern: "test/specs/*.spec.js", included: true @@ -31,6 +31,11 @@ module.exports = config => { included: true, type: "module" }, + { + pattern: "test/specs/**/*.spec.ts", + included: true, + type: "module" + }, { pattern: "test/reference/**/*.*", included: false, @@ -43,7 +48,9 @@ module.exports = config => { "src/jspdf.ts": ["babelTS", "coverage"], "src/modules/*.ts": ["babelTS", "coverage"], "src/libs/*.ts": ["babelTS"], - "src/index.ts": ["babelTS"] + "src/index.ts": ["babelTS"], + "test/specs/**/*.spec.ts": ["babelTS"], + "test/utils/*.ts": ["babelTS"] }, rollupPreprocessor: { diff --git a/test/utils/compare.js b/test/utils/compare.ts similarity index 65% rename from test/utils/compare.js rename to test/utils/compare.ts index e68e17f0e..060079878 100644 --- a/test/utils/compare.js +++ b/test/utils/compare.ts @@ -1,21 +1,37 @@ /* eslint-disable no-console */ /* global XMLHttpRequest, expect, fail */ -var globalVar = +declare const global: typeof globalThis | undefined; +declare function require(id: string): { + readFileSync(path: string, options: { encoding: string }): string; + resolve(path: string): string; +}; +declare const __dirname: string; + +interface CompareGlobals { + isNode?: boolean; + sendReference(filename: string, data: string): void; + loadBinaryResource(url: string, unicodeCleanUp?: boolean): string; + comparePdf(actual: string, expectedFile: string, suite?: string): void; +} + +const globalVar: CompareGlobals & typeof globalThis = (typeof self !== "undefined" && self) || (typeof global !== "undefined" && global) || (typeof window !== "undefined" && window) || Function("return this")(); globalVar.sendReference = function() {}; -globalVar.loadBinaryResource = function() {}; +globalVar.loadBinaryResource = function() { + return ""; +}; -var prefix = globalVar.isNode ? "/../" : "/base/test/"; +const prefix = globalVar.isNode ? "/../" : "/base/test/"; if (globalVar.isNode === true) { - var fs = require("fs"); - var path = require("path"); - globalVar.loadBinaryResource = function(url) { - var result = ""; + const fs = require("fs"); + const path = require("path"); + globalVar.loadBinaryResource = function(url: string): string { + let result = ""; try { result = fs.readFileSync(path.resolve(__dirname + prefix + url), { encoding: "latin1" @@ -26,11 +42,11 @@ if (globalVar.isNode === true) { return result; }; } else { - globalVar.sendReference = function(filename, data) { + globalVar.sendReference = function(filename: string, data: string): void { const req = new XMLHttpRequest(); req.open("POST", `http://localhost:9090${filename}`, true); req.setRequestHeader("Content-Type", "text/plain; charset=x-user-defined"); - req.onload = e => { + req.onload = () => { //console.log(e) }; @@ -45,7 +61,10 @@ if (globalVar.isNode === true) { req.send(blob); }; - globalVar.loadBinaryResource = function(url, unicodeCleanUp) { + globalVar.loadBinaryResource = function( + url: string, + unicodeCleanUp?: boolean + ): string { const req = new XMLHttpRequest(); req.open("GET", prefix + url, false); // XHR binary charset opt by Marcus Granado 2006 [http://mgran.blogspot.com] @@ -58,7 +77,7 @@ if (globalVar.isNode === true) { const responseText = req.responseText; if (unicodeCleanUp) { const StringFromCharCode = String.fromCharCode; - const byteArray = new Array(req.responseText.length); + const byteArray = new Array(req.responseText.length); for (let i = 0; i < responseText.length; i += 1) { byteArray[i] = StringFromCharCode(responseText.charCodeAt(i) & 0xff); @@ -70,7 +89,7 @@ if (globalVar.isNode === true) { }; } -function resetFile(pdfFile) { +function resetFile(pdfFile: string): string { pdfFile = pdfFile.replace( /\/CreationDate \([^)]+\)/, "/CreationDate (D:19871210000000+00'00')" @@ -82,26 +101,27 @@ function resetFile(pdfFile) { pdfFile = pdfFile.replace(/\/Producer \([^)]+\)/, "/Producer (jsPDF 0.0.0)"); return pdfFile; } -/** - * Find a better way to set this - * @type {Boolean} - */ -globalVar.comparePdf = function(actual, expectedFile, suite) { - var pdf; + +globalVar.comparePdf = function( + actual: string, + expectedFile: string, + _suite?: string +): void { + let pdf: string; try { pdf = globalVar.loadBinaryResource("reference/" + expectedFile, true); if (typeof pdf !== "string") { throw Error("Error loading 'reference/" + expectedFile + "'"); } } catch (error) { - fail(error.message); + fail(error instanceof Error ? error.message : String(error)); globalVar.sendReference( "/test/reference/" + expectedFile, resetFile(actual.replace(/^\s+|\s+$/g, "")) ); return; } - var expected = resetFile(pdf.replace(/^\s+|\s+$/g, "")); + const expected = resetFile(pdf.replace(/^\s+|\s+$/g, "")); actual = resetFile(actual.replace(/^\s+|\s+$/g, "")); expect(actual.replace(/[\r]/g, "").split("\n")).toEqual( diff --git a/tsconfig.json b/tsconfig.json index 29f6438ed..e8ed5eb83 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,9 +6,9 @@ "moduleResolution": "bundler", "noEmit": true, "strict": true, - "noImplicitAny": false, + "noImplicitAny": true, "strictNullChecks": false, - "noImplicitThis": false, + "noImplicitThis": true, "isolatedModules": true, "verbatimModuleSyntax": true, "erasableSyntaxOnly": true, diff --git a/types/index.d.ts b/types/index.d.ts index fd21f959a..b0ca0e08b 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -405,12 +405,7 @@ declare module "jspdf" { strokeStyle: string | Gradient; textAlign: "right" | "end" | "center" | "left" | "start"; textBaseline: - | "alphabetic" - | "bottom" - | "top" - | "hanging" - | "middle" - | "ideographic"; + "alphabetic" | "bottom" | "top" | "hanging" | "middle" | "ideographic"; arc( x: number, y: number, @@ -522,11 +517,7 @@ declare module "jspdf" { export interface ImageOptions { imageData: - | string - | HTMLImageElement - | HTMLCanvasElement - | Uint8Array - | RGBAData; + string | HTMLImageElement | HTMLCanvasElement | Uint8Array | RGBAData; x: number; y: number; width: number; @@ -557,12 +548,7 @@ declare module "jspdf" { align?: "left" | "center" | "right" | "justify"; angle?: number | Matrix; baseline?: - | "alphabetic" - | "ideographic" - | "bottom" - | "top" - | "middle" - | "hanging"; + "alphabetic" | "ideographic" | "bottom" | "top" | "middle" | "hanging"; flags?: { noBOM: boolean; autoencode: boolean; @@ -977,11 +963,7 @@ declare module "jspdf" { // jsPDF plugin: addImage addImage( imageData: - | string - | HTMLImageElement - | HTMLCanvasElement - | Uint8Array - | RGBAData, + string | HTMLImageElement | HTMLCanvasElement | Uint8Array | RGBAData, format: string, x: number, y: number, @@ -993,11 +975,7 @@ declare module "jspdf" { ): jsPDF; addImage( imageData: - | string - | HTMLImageElement - | HTMLCanvasElement - | Uint8Array - | RGBAData, + string | HTMLImageElement | HTMLCanvasElement | Uint8Array | RGBAData, x: number, y: number, w: number, diff --git a/types/jspdf-tests-node.ts b/types/jspdf-tests-node.ts index 6fa251c11..bc57fd894 100644 --- a/types/jspdf-tests-node.ts +++ b/types/jspdf-tests-node.ts @@ -224,18 +224,18 @@ function test_triangles() { } function test_images() { - const getImageFromUrl = function(url: string, callback: Function) { + const getImageFromUrl = function (url: string, callback: Function) { const img = new Image(); - img.onerror = function() { + img.onerror = function () { alert('Cannot load image: "' + url + '"'); }; - img.onload = function() { + img.onload = function () { callback(img); }; img.src = url; }; - const createPDF = function(imgData: string) { + const createPDF = function (imgData: string) { const doc = new jsPDF(); doc.addImage(imgData, "JPEG", 10, 10, 50, 50, "monkey"); // Cache the image using the alias 'monkey' doc.addImage("monkey", 70, 10, 100, 120); // use the cached 'monkey' image, JPEG is optional regardless @@ -582,7 +582,7 @@ function test_html() { const doc = new jsPDF(); doc.html(document.body, { - callback: function(doc) {}, + callback: function (doc) {}, html2canvas: { allowTaint: false }, @@ -605,7 +605,7 @@ function test_addImage() { function test_loadFile() { const doc = new jsPDF(); doc.loadFile("../image.png"); - doc.loadFile("../image.png", false, function(data) { + doc.loadFile("../image.png", false, function (data) { return data; }); } diff --git a/types/jspdf-tests.ts b/types/jspdf-tests.ts index 7e5b34b28..418c09821 100644 --- a/types/jspdf-tests.ts +++ b/types/jspdf-tests.ts @@ -223,18 +223,18 @@ function test_triangles() { } function test_images() { - const getImageFromUrl = function(url: string, callback: Function) { + const getImageFromUrl = function (url: string, callback: Function) { const img = new Image(); - img.onerror = function() { + img.onerror = function () { alert('Cannot load image: "' + url + '"'); }; - img.onload = function() { + img.onload = function () { callback(img); }; img.src = url; }; - const createPDF = function(imgData: string) { + const createPDF = function (imgData: string) { const doc = new jsPDF(); doc.addImage(imgData, "JPEG", 10, 10, 50, 50, "monkey"); // Cache the image using the alias 'monkey' doc.addImage("monkey", 70, 10, 100, 120); // use the cached 'monkey' image, JPEG is optional regardless @@ -581,7 +581,7 @@ function test_html() { const doc = new jsPDF(); doc.html(document.body, { - callback: function(doc) {}, + callback: function (doc) {}, html2canvas: { allowTaint: false }, @@ -604,7 +604,7 @@ function test_addImage() { function test_loadFile() { const doc = new jsPDF(); doc.loadFile("../image.png"); - doc.loadFile("../image.png", false, function(data) { + doc.loadFile("../image.png", false, function (data) { return data; }); }