@e-llm-studio/instant-learning 0.0.50 → 0.0.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -298,7 +298,7 @@ const $8=B8("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7
298
298
  * This source code is licensed under the ISC license.
299
299
  * See the LICENSE file in the root directory of this source tree.
300
300
  */
301
- const q8=B8("volume-2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]),G8=B8("volume-off",[["path",{d:"M16 9a5 5 0 0 1 .95 2.293",key:"1fgyg8"}],["path",{d:"M19.364 5.636a9 9 0 0 1 1.889 9.96",key:"l3zxae"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"m7 7-.587.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298V11",key:"1gbwow"}],["path",{d:"M9.828 4.172A.686.686 0 0 1 11 4.657v.686",key:"s2je0y"}]]);B8("volume-x",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);B8("volume",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}]]);B8("vote",[["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}],["path",{d:"M5 7c0-1.1.9-2 2-2h10a2 2 0 0 1 2 2v12H5V7Z",key:"1ezoue"}],["path",{d:"M22 19H2",key:"nuriw5"}]]);B8("wallet-cards",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2",key:"4125el"}],["path",{d:"M3 11h3c.8 0 1.6.3 2.1.9l1.1.9c1.6 1.6 4.1 1.6 5.7 0l1.1-.9c.5-.5 1.3-.9 2.1-.9H21",key:"1dpki6"}]]);B8("wallet-minimal",[["path",{d:"M17 14h.01",key:"7oqj8z"}],["path",{d:"M7 7h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14",key:"u1rqew"}]]);B8("wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]);B8("wallpaper",[["circle",{cx:"8",cy:"9",r:"2",key:"gjzl9d"}],["path",{d:"m9 17 6.1-6.1a2 2 0 0 1 2.81.01L22 15V5a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2",key:"69xh40"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}]]);B8("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);B8("wand",[["path",{d:"M15 4V2",key:"z1p9b7"}],["path",{d:"M15 16v-2",key:"px0unx"}],["path",{d:"M8 9h2",key:"1g203m"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M17.8 11.8 19 13",key:"yihg8r"}],["path",{d:"M15 9h.01",key:"x1ddxp"}],["path",{d:"M17.8 6.2 19 5",key:"fd4us0"}],["path",{d:"m3 21 9-9",key:"1jfql5"}],["path",{d:"M12.2 6.2 11 5",key:"i3da3b"}]]);B8("warehouse",[["path",{d:"M18 21V10a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1v11",key:"pb2vm6"}],["path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 1.132-1.803l7.95-3.974a2 2 0 0 1 1.837 0l7.948 3.974A2 2 0 0 1 22 8z",key:"doq5xv"}],["path",{d:"M6 13h12",key:"yf64js"}],["path",{d:"M6 17h12",key:"1jwigz"}]]);B8("washing-machine",[["path",{d:"M3 6h3",key:"155dbl"}],["path",{d:"M17 6h.01",key:"e2y6kg"}],["rect",{width:"18",height:"20",x:"3",y:"2",rx:"2",key:"od3kk9"}],["circle",{cx:"12",cy:"13",r:"5",key:"nlbqau"}],["path",{d:"M12 18a2.5 2.5 0 0 0 0-5 2.5 2.5 0 0 1 0-5",key:"17lach"}]]);B8("watch",[["path",{d:"M12 10v2.2l1.6 1",key:"n3r21l"}],["path",{d:"m16.13 7.66-.81-4.05a2 2 0 0 0-2-1.61h-2.68a2 2 0 0 0-2 1.61l-.78 4.05",key:"18k57s"}],["path",{d:"m7.88 16.36.8 4a2 2 0 0 0 2 1.61h2.72a2 2 0 0 0 2-1.61l.81-4.05",key:"16ny36"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}]]);B8("waves-ladder",[["path",{d:"M19 5a2 2 0 0 0-2 2v11",key:"s41o68"}],["path",{d:"M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"rd2r6e"}],["path",{d:"M7 13h10",key:"1rwob1"}],["path",{d:"M7 9h10",key:"12czzb"}],["path",{d:"M9 5a2 2 0 0 0-2 2v11",key:"x0q4gh"}]]);B8("waves",[["path",{d:"M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"knzxuh"}],["path",{d:"M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"2jd2cc"}],["path",{d:"M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"rd2r6e"}]]);B8("waypoints",[["circle",{cx:"12",cy:"4.5",r:"2.5",key:"r5ysbb"}],["path",{d:"m10.2 6.3-3.9 3.9",key:"1nzqf6"}],["circle",{cx:"4.5",cy:"12",r:"2.5",key:"jydg6v"}],["path",{d:"M7 12h10",key:"b7w52i"}],["circle",{cx:"19.5",cy:"12",r:"2.5",key:"1piiel"}],["path",{d:"m13.8 17.7 3.9-3.9",key:"1wyg1y"}],["circle",{cx:"12",cy:"19.5",r:"2.5",key:"13o1pw"}]]);B8("webcam",[["circle",{cx:"12",cy:"10",r:"8",key:"1gshiw"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 22h10",key:"10w4w3"}],["path",{d:"M12 22v-4",key:"1utk9m"}]]);B8("webhook-off",[["path",{d:"M17 17h-5c-1.09-.02-1.94.92-2.5 1.9A3 3 0 1 1 2.57 15",key:"1tvl6x"}],["path",{d:"M9 3.4a4 4 0 0 1 6.52.66",key:"q04jfq"}],["path",{d:"m6 17 3.1-5.8a2.5 2.5 0 0 0 .057-2.05",key:"azowf0"}],["path",{d:"M20.3 20.3a4 4 0 0 1-2.3.7",key:"5joiws"}],["path",{d:"M18.6 13a4 4 0 0 1 3.357 3.414",key:"cangb8"}],["path",{d:"m12 6 .6 1",key:"tpjl1n"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);B8("webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]);B8("weight",[["circle",{cx:"12",cy:"5",r:"3",key:"rqqgnr"}],["path",{d:"M6.5 8a2 2 0 0 0-1.905 1.46L2.1 18.5A2 2 0 0 0 4 21h16a2 2 0 0 0 1.925-2.54L19.4 9.5A2 2 0 0 0 17.48 8Z",key:"56o5sh"}]]);B8("wheat-off",[["path",{d:"m2 22 10-10",key:"28ilpk"}],["path",{d:"m16 8-1.17 1.17",key:"1qqm82"}],["path",{d:"M3.47 12.53 5 11l1.53 1.53a3.5 3.5 0 0 1 0 4.94L5 19l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1rdhi6"}],["path",{d:"m8 8-.53.53a3.5 3.5 0 0 0 0 4.94L9 15l1.53-1.53c.55-.55.88-1.25.98-1.97",key:"4wz8re"}],["path",{d:"M10.91 5.26c.15-.26.34-.51.56-.73L13 3l1.53 1.53a3.5 3.5 0 0 1 .28 4.62",key:"rves66"}],["path",{d:"M20 2h2v2a4 4 0 0 1-4 4h-2V6a4 4 0 0 1 4-4Z",key:"19rau1"}],["path",{d:"M11.47 17.47 13 19l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L5 19l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"tc8ph9"}],["path",{d:"m16 16-.53.53a3.5 3.5 0 0 1-4.94 0L9 15l1.53-1.53a3.49 3.49 0 0 1 1.97-.98",key:"ak46r"}],["path",{d:"M18.74 13.09c.26-.15.51-.34.73-.56L21 11l-1.53-1.53a3.5 3.5 0 0 0-4.62-.28",key:"1tw520"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);B8("wheat",[["path",{d:"M2 22 16 8",key:"60hf96"}],["path",{d:"M3.47 12.53 5 11l1.53 1.53a3.5 3.5 0 0 1 0 4.94L5 19l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1rdhi6"}],["path",{d:"M7.47 8.53 9 7l1.53 1.53a3.5 3.5 0 0 1 0 4.94L9 15l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1sdzmb"}],["path",{d:"M11.47 4.53 13 3l1.53 1.53a3.5 3.5 0 0 1 0 4.94L13 11l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"eoatbi"}],["path",{d:"M20 2h2v2a4 4 0 0 1-4 4h-2V6a4 4 0 0 1 4-4Z",key:"19rau1"}],["path",{d:"M11.47 17.47 13 19l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L5 19l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"tc8ph9"}],["path",{d:"M15.47 13.47 17 15l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L9 15l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"2m8kc5"}],["path",{d:"M19.47 9.47 21 11l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L13 11l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"vex3ng"}]]);B8("whole-word",[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]]);B8("wifi-cog",[["path",{d:"m14.305 19.53.923-.382",key:"3m78fa"}],["path",{d:"m15.228 16.852-.923-.383",key:"npixar"}],["path",{d:"m16.852 15.228-.383-.923",key:"5xggr7"}],["path",{d:"m16.852 20.772-.383.924",key:"dpfhf9"}],["path",{d:"m19.148 15.228.383-.923",key:"1reyyz"}],["path",{d:"m19.53 21.696-.382-.924",key:"1goivc"}],["path",{d:"M2 7.82a15 15 0 0 1 20 0",key:"1ovjuk"}],["path",{d:"m20.772 16.852.924-.383",key:"htqkph"}],["path",{d:"m20.772 19.148.924.383",key:"9w9pjp"}],["path",{d:"M5 11.858a10 10 0 0 1 11.5-1.785",key:"3sn16i"}],["path",{d:"M8.5 15.429a5 5 0 0 1 2.413-1.31",key:"1pxovh"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]]);B8("wifi-high",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);B8("wifi-low",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);B8("wifi-off",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);B8("wifi-pen",[["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1817ys"}],["path",{d:"M5 12.859a10 10 0 0 1 10.5-2.222",key:"rpb7oy"}],["path",{d:"M8.5 16.429a5 5 0 0 1 3-1.406",key:"r8bmzl"}]]);B8("wifi-zero",[["path",{d:"M12 20h.01",key:"zekei9"}]]);B8("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);B8("wind-arrow-down",[["path",{d:"M10 2v8",key:"d4bbey"}],["path",{d:"M12.8 21.6A2 2 0 1 0 14 18H2",key:"19kp1d"}],["path",{d:"M17.5 10a2.5 2.5 0 1 1 2 4H2",key:"19kpjc"}],["path",{d:"m6 6 4 4 4-4",key:"k13n16"}]]);B8("wine-off",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M7 10h3m7 0h-1.343",key:"v48bem"}],["path",{d:"M12 15v7",key:"t2xh3l"}],["path",{d:"M7.307 7.307A12.33 12.33 0 0 0 7 10a5 5 0 0 0 7.391 4.391M8.638 2.981C8.75 2.668 8.872 2.34 9 2h6c1.5 4 2 6 2 8 0 .407-.05.809-.145 1.198",key:"1ymjlu"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);B8("wind",[["path",{d:"M12.8 19.6A2 2 0 1 0 14 16H2",key:"148xed"}],["path",{d:"M17.5 8a2.5 2.5 0 1 1 2 4H2",key:"1u4tom"}],["path",{d:"M9.8 4.4A2 2 0 1 1 11 8H2",key:"75valh"}]]);B8("wine",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M12 15v7",key:"t2xh3l"}],["path",{d:"M12 15a5 5 0 0 0 5-5c0-2-.5-4-2-8H9c-1.5 4-2 6-2 8a5 5 0 0 0 5 5Z",key:"10ffi3"}]]);B8("workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);B8("worm",[["path",{d:"m19 12-1.5 3",key:"9bcu4o"}],["path",{d:"M19.63 18.81 22 20",key:"121v98"}],["path",{d:"M6.47 8.23a1.68 1.68 0 0 1 2.44 1.93l-.64 2.08a6.76 6.76 0 0 0 10.16 7.67l.42-.27a1 1 0 1 0-2.73-4.21l-.42.27a1.76 1.76 0 0 1-2.63-1.99l.64-2.08A6.66 6.66 0 0 0 3.94 3.9l-.7.4a1 1 0 1 0 2.55 4.34z",key:"1tij6q"}]]);B8("wrap-text",[["path",{d:"m16 16-2 2 2 2",key:"kkc6pm"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["path",{d:"M3 18h7",key:"sq21v6"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]);B8("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);B8("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);B8("youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]);B8("zap-off",[["path",{d:"M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317",key:"193nxd"}],["path",{d:"M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773",key:"27a7lr"}],["path",{d:"M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643",key:"1e0qe9"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);B8("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);B8("zoom-in",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);B8("zoom-out",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);var Y8=function(e){var a=e.amplitude,r=e.variant,o=e.isActive,c=e.className,l=void 0===c?"":c,i=e.onClick,s=e.disabled,d=void 0!==s&&s,u=e.isConnecting,m=n.useState(Array(40).fill(4)),p=m[0],v=m[1],f=n.useRef(null),z=function(){var e=Math.min(Math.max(a,0),1),t=Math.max(e,.2),n=Array(40).fill(0).map((function(e,n){var a=Math.sin(n+Date.now()/100)+.5*Math.random();return 5+9*Math.abs(a)*t}));v(n),f.current=requestAnimationFrame(z)};n.useEffect((function(){return o?f.current=requestAnimationFrame(z):(v(Array(40).fill(4)),f.current&&cancelAnimationFrame(f.current)),function(){f.current&&cancelAnimationFrame(f.current)}}),[o,a]);var g=o?"#364152":"#D0D4DB",y="microphone"===r?o||u?$8:W8:o?q8:G8;return t.jsxs("div",h({className:l,style:{position:"relative",height:"3rem",zIndex:50,width:"100%",overflow:"hidden",display:"flex",alignItems:"center"}},{children:[t.jsx("div",h({style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",height:"2rem",gap:"0.25rem"}},{children:p.map((function(e,n){return t.jsx("div",{style:{flexShrink:0,width:"4px",borderRadius:"9999px",transition:"all 100ms",backgroundColor:g,height:"".concat(e,"px"),opacity:o?1:.4}},n)}))})),t.jsx("button",h({onClick:i,disabled:d,"aria-label":"".concat(r," button"),style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",width:"2rem",height:"2rem",borderRadius:"9999px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 200ms",backgroundColor:"white",border:"1px solid ".concat(g),cursor:d?"not-allowed":"pointer"}},{children:t.jsx(y,{color:g,className:u?"animate-spin":"",style:{width:"1.25rem",height:"1.25rem"}})}))]}))};v(".welcome-message{align-items:flex-start;animation:fadeSlideIn 1.2s ease-out forwards;border-radius:.5rem;color:#333;display:fixed;font-size:1rem;line-height:1.75rem;max-width:100%;opacity:0;overflow-wrap:break-word;padding:1rem;transform:translateY(10px);white-space:pre-wrap;word-break:break-word}@keyframes fadeSlideIn{to{opacity:1;transform:translateY(0)}}");var K8=function(e){var a=e.label,r=e.onToggle,o=n.useState(!1),c=o[0],l=o[1],i=n.useRef(null);return n.useEffect((function(){var e=i.current;e&&c&&(e.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.1)",e.style.transform="scale(1)",e.style.backgroundColor="#E8F5E9",e.style.color="#2E7D32")}),[c]),t.jsxs("span",h({ref:i,onClick:function(){var e=!c;console.log("newstate: ",e),l(e),r(a,e)},style:{cursor:"pointer",backgroundColor:c?"#E8F5E9":"#fff",color:c?"#2E7D32":"#000000de",transition:"all 0.2s ease-in-out",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.2)",transform:"scale(1)"},onMouseEnter:function(e){c||(e.currentTarget.style.boxShadow="0 4px 12px rgba(30, 136, 229, 0.3)",e.currentTarget.style.transform="scale(1.02)",e.currentTarget.style.backgroundColor="#f0f7ff",e.currentTarget.style.color="#1E88E5")},onMouseLeave:function(e){c||(e.currentTarget.style.boxShadow="0 2px 4px rgba(0, 0, 0, 0.2)",e.currentTarget.style.transform="scale(1)",e.currentTarget.style.backgroundColor="#fbfaff",e.currentTarget.style.color="#000000de")}},{children:[t.jsx("span",h({style:{fontWeight:"bold",fontSize:"16px",transition:"all 0.3s ease",transform:c?"scale(1.2)":"scale(1)",opacity:c?1:.9,paddingLeft:"0.25rem",paddingRight:"0.25rem"}},{children:c?"✓":"+"})),t.jsx("span",{children:a})]}))};function X8(e){return"string"==typeof e?e:Array.isArray(e)?e.map(X8).join(""):"object"==typeof e&&null!==e&&"props"in e?X8(e.props.children):""}var Q8=function(e){var a=e.label,r=e.onToggle,o=n.useState(!1),c=o[0],l=o[1],i=n.useRef(null);return n.useEffect((function(){var e=i.current;e&&c&&(e.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.1)",e.style.transform="scale(1)",e.style.backgroundColor="#E8F5E9",e.style.color="#2E7D32")}),[c]),t.jsxs("span",h({ref:i,onClick:function(){var e=!c;console.log("newstate: ",e),l(e),r(X8(a),e)},style:{cursor:"pointer",backgroundColor:c?"#E8F5E9":"#fff",color:c?"#2E7D32":"#000000de",transition:"all 0.2s ease-in-out",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.2)",transform:"scale(1)"},onMouseEnter:function(e){c||(e.currentTarget.style.boxShadow="0 4px 12px rgba(30, 136, 229, 0.3)",e.currentTarget.style.transform="scale(1.02)",e.currentTarget.style.backgroundColor="#f0f7ff",e.currentTarget.style.color="#1E88E5")},onMouseLeave:function(e){c||(e.currentTarget.style.boxShadow="0 2px 4px rgba(0, 0, 0, 0.2)",e.currentTarget.style.transform="scale(1)",e.currentTarget.style.backgroundColor="#fbfaff",e.currentTarget.style.color="#000000de")}},{children:[t.jsx("span",h({style:{fontWeight:"bold",fontSize:"16px",transition:"all 0.3s ease",transform:c?"scale(1.2)":"scale(1)",opacity:c?1:.9,paddingLeft:"0.25rem",paddingRight:"0.25rem"}},{children:c?"✓":"+"})),t.jsx("span",{children:a})]}))},J8=function(e){var a=e.index,r=e.content,o=e.messages,c=e.handleStream,l=e.scrollToBottom,i=n.useState([]),s=i[0],u=i[1],m=n.useState(!1),v=m[0],f=m[1],z=n.useState([]),g=z[0],y=z[1],M=n.useState(!1),E=M[0],b=M[1],H=n.useState([]),V=H[0],C=H[1],L=n.useState([]),x=L[0],S=L[1],k=n.useMemo((function(){return{img:function(e){e.node;var n=d(e,["node"]);return t.jsx("img",h({},n,{style:{height:"100%",width:"100%",objectFit:"contain"},alt:(null==n?void 0:n.alt)||"",className:"w-full sm:max-w-lg md:max-w-2xl lg:max-w-4xl mx-auto"}))},p:function(e){e.node;var n=d(e,["node"]);return t.jsx("p",h({},n,{style:{maxWidth:"100%",wordWrap:"break-word",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal",overflow:"hidden",display:"block",fontSize:"1rem",lineHeight:"1.625rem",marginBottom:"1rem",marginTop:"10px"}},{children:null==n?void 0:n.children}))},code:function(e){e.node;var n=d(e,["node"]);return t.jsx("span",h({},n,{style:{maxWidth:"100%",wordWrap:"break-word",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal",overflow:"hidden",display:"inline-flex",fontSize:"1rem",lineHeight:"1.625rem"}},{children:null==n?void 0:n.children}))},ol:function(e){e.node;var n=d(e,["node"]);return t.jsx("ol",h({},n,{style:{display:"flex",flexDirection:"column",gap:"1rem",listStyle:"decimal",paddingLeft:"2.5rem"}},{children:null==n?void 0:n.children}))},ul:function(e){e.node;var n=d(e,["node"]);return t.jsx("ul",h({},n,{style:{display:"flex",flexDirection:"column",gap:"1rem",listStyle:"decimal",paddingLeft:"2.5rem"}},{children:null==n?void 0:n.children}))},wta:function(e){e.node;var n=d(e,["node"]);n.key||n["data-key"];var a=n.label||n.children||"Unknown label";return t.jsx(K8,{label:a,onToggle:function(e,t){!function(e,t){console.log(e,t);var n=Array.isArray(e)?e[0]:e;f(!0),u((function(e){return t?e.includes(n)?e:p(p([],e,!0),[n],!1):e.filter((function(e){return e!==n}))}))}(e,t)}})},editwta:function(e){e.node;var n=d(e,["node"]);n.key||n["data-key"];var a=n.label||n.children||"Unknown label";return t.jsx(Q8,{label:a,onToggle:function(e,t){!function(e,t){var n=Array.isArray(e)?e[0]:e;b(!0),y((function(e){return t?e.includes(n)?e:p(p([],e,!0),[n],!1):e.filter((function(e){return e!==n}))})),null==l||l()}(e,t)}})}}}),[r,o,x]);!function(e,t){n.useEffect((function(){for(var n,a=0,r=(null===(n=e[e.length-1])||void 0===n?void 0:n.orchestratorAndAgentsMessages)||[];a<r.length;a++){for(var o=r[a],c=(null==o?void 0:o.responsedata)||"",l=/<wta>([\s\S]*?)<\/wta>/gi,i=[],s=void 0;null!==(s=l.exec(c));)console.log("match wta suggestion",s),i.push(s[1]);i.length&&t(i)}}),[e,t])}(o,C);!function(e){n.useEffect((function(){for(var t,n=0,a=(null===(t=e[e.length-1])||void 0===t?void 0:t.orchestratorAndAgentsMessages)||[];n<a.length;n++){for(var r=a[n],o=(null==r?void 0:r.responsedata)||"",c=/<editwta>([\s\S]*?)<\/editwta>/gi,l=[],i=void 0;null!==(i=c.exec(o));)console.log("match wta suggestion",i),l.push(i[1]);l.length&&S(l)}}),[e,S])}(o);var w=n.useMemo((function(){if(!Array.isArray(s)||!Array.isArray(V))return"";var e=s.map((function(e){return V.indexOf(e)})).filter((function(e){return-1!==e})).map((function(e){return e+1}));return e.join(" and ")}),[s,V]),T=n.useMemo((function(){if(!Array.isArray(g)||!Array.isArray(x))return"";var e=g.map((function(e){var t;return null===(t=x.map((function(e){return null==e?void 0:e.replaceAll("**","")})))||void 0===t?void 0:t.indexOf(e)})).filter((function(e){return-1!==e})).map((function(e){return e+1}));return e.join(" and ")}),[g,x]);return t.jsxs(t.Fragment,{children:[t.jsx(cM,h({components:k,rehypePlugins:[eC]},{children:r}),a),t.jsx("div",h({style:{display:"flex",maxWidth:"100%"}},{children:t.jsx("div",h({style:{width:"100%"}},{children:(null==s?void 0:s.length)>0&&v?t.jsxs("span",{children:["It looks like you’ve chosen ",s.length>1?"suggestions":"suggestion"," ",w,". Would you like me to proceed with them?",t.jsx("p",{children:t.jsx("button",h({style:{padding:"0.5rem 1rem",margin:"1rem 0rem",backgroundColor:"#4CAF50",color:"white",border:"none",borderRadius:"8px",cursor:"pointer",fontSize:"0.75rem",fontWeight:"500",boxShadow:"0 2px 5px rgba(0, 0, 0, 0.2)",transition:"background-color 0.3s",fontFamily:"Plus Jakarta Sans, sans-serif"},onClick:function(e){c(new KeyboardEvent("keydown",{key:"Enter"}),!1,"Add when to apply conditions ".concat(s.join(" or "))),f(!1)}},{children:"Yes"}))})]}):t.jsx("span",{})}))})),t.jsx("div",h({style:{display:"flex",maxWidth:"100%"}},{children:t.jsx("div",h({style:{width:"100%"}},{children:(null==g?void 0:g.length)>0&&E?t.jsxs("span",{children:["It looks like you’ve chosen ",g.length>1?"options":"option"," ",T,". Would you like me to proceed with them?",t.jsx("p",{children:t.jsx("button",h({style:{padding:"0.5rem 1rem",margin:"1rem 0rem",backgroundColor:"#4CAF50",color:"white",border:"none",borderRadius:"8px",cursor:"pointer",fontSize:"0.75rem",fontWeight:"500",boxShadow:"0 2px 5px rgba(0, 0, 0, 0.2)",transition:"background-color 0.3s",fontFamily:"Plus Jakarta Sans, sans-serif"},onClick:function(e){var t;c(new KeyboardEvent("keydown",{key:"Enter"}),!1,"".concat(null===(t=g.join(" or "))||void 0===t?void 0:t.replace(/\b\d+[A-Z]?\.\s*/g,""))),y([]),b(!1)}},{children:"Yes"}))})]}):t.jsx("span",{})}))}))]})};function Z8(e){return e.replace(/\bFalse\b/g,"false").replace(/\bTrue\b/g,"true").replace(/([{,]\s*)'([^']+?)'\s*:/g,'$1"$2":').replace(/:\s*'([^']*?)'/g,(function(e,t){var n=t.replace(/"/g,'\\"');return': "'.concat(n,'"')})).replace(/\bNone\b/g,"null")}var e7,t7,n7=function(){return t.jsx("svg",h({width:"20px",height:"20px",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:t.jsx("path",{d:"M9.91158 12H7.45579H4L2.02268 4.13539C2.0111 4.0893 2.00193 4.04246 2.00046 3.99497C1.97811 3.27397 2.77209 2.77366 3.46029 3.10388L22 12L3.46029 20.8961C2.77983 21.2226 1.99597 20.7372 2.00002 20.0293C2.00038 19.9658 2.01455 19.9032 2.03296 19.8425L3.5 15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}))},a7=function(e){var n=e.resetChatHistory,a=e.isStreamEnd;return t.jsxs("div",h({className:T8,style:{width:"100%",padding:"0.75rem 0rem",display:"flex",alignItems:"center",justifyContent:"space-between",backgroundColor:"#fff",borderBottom:"1px solid #e5e7eb",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.04)"}},{children:[t.jsxs("span",h({style:{fontSize:"1.25rem",fontWeight:700,color:"#1f2937",flex:1,marginLeft:"0.5rem",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:[t.jsx("span",h({style:{color:"#5928ED"}},{children:"InstantLearning.AI"}))," Chat"]})),t.jsx(vJ,h({title:"New chat",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx("div",h({onClick:function(){console.log(w8,"hello"),a&&n()},style:{height:"1.8rem",width:"1.8rem",marginLeft:"1rem",marginRight:"0.5rem",cursor:a?"pointer":"not-allowed",backgroundColor:"transparent",transition:"transform 0.2s ease-in-out, opacity 0.2s",opacity:a?.8:.4,pointerEvents:a?"auto":"none"},onMouseOver:function(e){a&&(e.currentTarget.style.opacity="1")},onMouseOut:function(e){a&&(e.currentTarget.style.opacity="0.8")}},{children:t.jsx(w8,{})}))}))]}))},r7=function(e){var a=e.label,r=e.onToggle,o=n.useState(!1),c=o[0],l=o[1],i=n.useRef(null);return n.useEffect((function(){var e=i.current;e&&c&&(e.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.1)",e.style.transform="scale(1)",e.style.backgroundColor="#E8F5E9",e.style.color="#2E7D32")}),[c]),t.jsxs("span",h({ref:i,onClick:function(){var e=!c;l(e),r(a,e)},style:{cursor:"pointer",backgroundColor:c?"#E8F5E9":"#fbfaff",color:c?"#2E7D32":"#000000de",transition:"all 0.2s ease-in-out",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.2)",transform:"scale(1)"},onMouseEnter:function(e){c||(e.currentTarget.style.boxShadow="0 4px 12px rgba(30, 136, 229, 0.3)",e.currentTarget.style.transform="scale(1.02)",e.currentTarget.style.backgroundColor="#f0f7ff",e.currentTarget.style.color="#1E88E5")},onMouseLeave:function(e){c||(e.currentTarget.style.boxShadow="0 2px 4px rgba(0, 0, 0, 0.2)",e.currentTarget.style.transform="scale(1)",e.currentTarget.style.backgroundColor="#fbfaff",e.currentTarget.style.color="#000000de")}},{children:[t.jsx("span",h({style:{fontWeight:"bold",fontSize:"16px",transition:"all 0.3s ease",transform:c?"scale(1.2)":"scale(1)",opacity:c?1:.9,paddingLeft:"0.25rem",paddingRight:"0.25rem"}},{children:c?"✓":"+"})),t.jsx("span",{children:a})]}))},o7=function(e){e.chatAssistantLogoUrl;var a=e.chatAssistantName,r=e.organizationName,o=e.baseUrl,c=e.setInstantLearningSuggestions,l=e.formDataState,i=e.setFormDataState;e.hasUserFilledForm;var s=e.setHasUserFilledForm,v=e.baseWebsocketUrl,f=e.setIsNewChatClicked;e.selectedText,e.ChatIconComponent,e.ggcAssistantName;var z=e.ThinkingBulbIconComponent;e.hasUserWrittenModification;var g=e.setExtractedModification,y=e.setSave,M=e.setExtractedTooltip,E=e.setIsSaveLoading;e.isSaveLoading,e.save,e.instantLearningSuggestions,e.template;var b=e.setShouldTriggerSave,H=e.validationWtaResponse,V=e.setValidationWtaResponse,C=e.learningWtaResponse,L=e.setLearningWtaResponse,x=e.isFormSaveClicked,S=e.setIsFormSavedClicked,k=a,w=n.useRef("".concat(k,"-").concat(r,"-").concat(V8())),T=n.useRef("".concat(V8())),O=o,A=n.useRef(null),R=n.useRef(null),N=n.useState([]),_=N[0],D=N[1],P=n.useState(!1);P[0];var F=P[1],I=n.useState(""),j=I[0],B=I[1],U=n.useState(""),W=U[0],$=U[1],q=n.useState([]),G=q[0],Y=q[1],K=n.useState(!1),X=K[0],Q=K[1],J=n.useState(!1);J[0];var Z=J[1],ee=n.useState(!0),te=ee[0],ne=ee[1],ae=n.useState(!0),re=ae[0],oe=ae[1],ce=n.useState("");ce[0];var le=ce[1],ie=n.useState(""),se=ie[0],he=ie[1],de=n.useState(!1),ue=de[0],me=de[1],pe=n.useState(!1),ve=pe[0],fe=pe[1],ze=n.useState(!1),ge=ze[0],ye=ze[1],Me=n.useState([]);Me[0];var Ee=Me[1],be=n.useMemo((function(){return""===(null==j?void 0:j.trim())||ue}),[j,ue]),He=n.useRef(null),Ve=n.useState("100%"),Ce=Ve[0],Le=Ve[1];n.useMemo((function(){var e,t,n;return!(""===(null===(e=null==l?void 0:l.original)||void 0===e?void 0:e.trim())||(null==l?void 0:l.isTooltipEnabled)&&""===(null===(t=null==l?void 0:l.tooltip)||void 0===t?void 0:t.trim())||(null==l?void 0:l.isModificationEnabled)&&""===(null===(n=null==l?void 0:l.modification)||void 0===n?void 0:n.trim()))}),[l]),n.useEffect((function(){var e="Please tell me how I should correct “".concat((null==l?void 0:l.original)||"","”? ");$(e)}),[l]),n.useEffect((function(){var e=A.current,t=function(){var e=A.current;if(e){var t=e.scrollTop,n=e.scrollHeight,a=e.clientHeight;ye(!(n-(t+a)<=35))}};return e&&(e.addEventListener("scroll",t),t()),function(){e&&e.removeEventListener("scroll",t)}}),[ge,te,G]);var xe=function(e){return n.useMemo((function(){for(var t,n=[],a=/['"]conditions_whentoapply['"]\s*:\s*(\[\s*\]|\[\s*\{\s*['"]when_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\2).)*\2\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\}(?:\s*,\s*\{\s*['"]when_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\3).)*\3\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\})*\s*\])\s*,\s*['"]conditions_whennottoapply['"]\s*:\s*(\[\s*\]|\[\s*\{\s*['"]when_not_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\5).)*\5\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\}(?:\s*,\s*\{\s*['"]when_not_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\6).)*\6\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\})*\s*\])/,r=/['"]is_valid['"]\s*:\s*(true|false|True|False)\s*,\s*['"]conflictingConditions['"]\s*:\s*\[\s*(\{[\s\S]*?['"]conflictType['"]\s*:\s*['"][^'"]+['"][\s\S]*?\}\s*,?\s*)*\]/,o=/['"]is_valid_db['"]\s*:\s*(true|false|True|False)\s*,\s*['"]conflicting_learnings['"]\s*:\s*\[[\s\S]*?\]\s*,\s*['"]similar_learnings['"]\s*:\s*\[[\s\S]*?\]/,c=0,l=(null===(t=e[e.length-1])||void 0===t?void 0:t.orchestratorAndAgentsMessages)||[];c<l.length;c++){var i=l[c],s=(null==i?void 0:i.responsedata)||"";console.log("Ressponse Data",String(s));var h=s.match(a);if(h)try{var d=N8.parse("{".concat(h[0],"}"));n.push(d)}catch(e){console.error("Failed to parse JSON:",e)}var u=s.match(r);if(console.log("validationObj before cond "),u)try{var m=Z8(u[0]||""),p=N8.parse("{".concat(m,"}"));console.log("validationObj before set ",p),V(p),console.log("validationObj after set in chat",H)}catch(e){console.error("Failed to parse validation JSON:",e)}var v=s.match(o);if(v)try{var f=Z8(v[0]||""),z=N8.parse("{".concat(f,"}"));L(z),console.log("dbVal after set in chat",C)}catch(e){console.error("Failed to parse validation JSON:",e)}}return n}),[e])}(G);n.useEffect((function(){var e=(null==xe?void 0:xe[(null==xe?void 0:xe.length)-1])||null;e&&(c(e),console.log("Parsed suggestions:",xe))}),[xe]);var Se=function(e){return n.useMemo((function(){for(var t,n=[],a=/['"](\w+)['"]\s*:\s*['"](.*?)['"]/g,r=0,o=(null===(t=e[e.length-1])||void 0===t?void 0:t.orchestratorAndAgentsMessages)||[];r<o.length;r++){var c=o[r],l=((null==c?void 0:c.responsedata)||"").match(a);if(l)try{var i=N8.parse("{".concat(l[0],"}"));n.push(i)}catch(e){console.error("Failed to parse JSON for header message:",e)}}return n}),[e])}(G);n.useEffect((function(){var e=(null==Se?void 0:Se[(null==Se?void 0:Se.length)-1])||null;e&&g(e.modification)}),[Se]);!function(e,t){n.useEffect((function(){for(var n,a=0,r=(null===(n=e[e.length-1])||void 0===n?void 0:n.orchestratorAndAgentsMessages)||[];a<r.length;a++){for(var o=r[a],c=(null==o?void 0:o.responsedata)||"",l=/<wta>([\s\S]*?)<\/wta>/gi,i=[],s=void 0;null!==(s=l.exec(c));)console.log("match wta suggestion",s),i.push(s[1]);i.length&&t(i)}}),[e,t])}(G,Ee);var ke=function(e){return n.useMemo((function(){for(var t,n=[],a=/^\{\s*(['"])(\w+)\1\s*:\s*(['"])(.*?)\3\s*\}$/,r=0,o=(null===(t=e[e.length-1])||void 0===t?void 0:t.orchestratorAndAgentsMessages)||[];r<o.length;r++){var c=o[r],l=((null==c?void 0:c.responsedata)||"").match(a);if(l){console.log("match: ",l[0]);try{var i=N8.parse(l[0]);n.push(i)}catch(e){console.error("Failed to parse JSON:",e)}}}return n}),[e])}(G);n.useEffect((function(){var e=(null==ke?void 0:ke[(null==ke?void 0:ke.length)-1])||null;e&&(console.log("latestParseTooltip: ",e),M(null==e?void 0:e.tooltip))}),[ke]);var we=function(e){var t=n.useState([]),a=t[0],r=t[1];return n.useEffect((function(){for(var t,n=[],a=/\{\s*['"]save['"]\s*:\s*(True|False|true|false)\s*\}/,o=0,c=(null===(t=e[e.length-1])||void 0===t?void 0:t.orchestratorAndAgentsMessages)||[];o<c.length;o++){var l=c[o],i=((null==l?void 0:l.responsedata)||"").match(a);if(i)try{var s=i[0].replace(/\bTrue\b/,"true").replace(/\bFalse\b/,"false").replace(/'/g,'"');console.log("corrected:",s);var h=N8.parse(s);!0===h.save&&b(!0),n.push(h)}catch(e){console.error("Failed to parse JSON:",e)}}r(n)}),[e]),a}(G);n.useEffect((function(){var e=(null==we?void 0:we[(null==we?void 0:we.length)-1])||null;if(e&&"boolean"==typeof e.save){E(!0);var t=setTimeout((function(){E(!1),y(e.save)}),200);return function(){clearTimeout(t)}}}),[we]),n.useEffect((function(){x&&(_e(new KeyboardEvent("keydown",{key:"Enter"}),!1,"Save it"),S(!1))}),[x]),n.useEffect((function(){Oe(),Ae();var e=function(){var e,t=(null===(e=null==He?void 0:He.current)||void 0===e?void 0:e.clientHeight)||0,n="calc(100% - ".concat(t,"px - 10px");Le(n)};return e(),window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[]);var Te=n.useCallback((function(){var e=A.current;e&&setTimeout((function(){e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),ye(!1)}),100)}),[]);n.useEffect((function(){(null==_?void 0:_.length)>0&&Te()}),[_]);var Oe=function(){var e={method:"get",maxBodyLength:1/0,url:"".concat(O,"/api/chatbot/getChatSettings?name=").concat(k,"&organizationName=").concat(r),headers:{}};ES.request(e).then((function(e){var t,n,a;(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.chatSettings)&&""!==(null===(a=null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.chatSettings)||void 0===a?void 0:a.chatInitialMessage)&&oe(!0)})).catch((function(e){console.error(e)}))},Ae=function(){return u(void 0,void 0,void 0,(function(){var e,t;return m(this,(function(n){e="".concat(O,"/api/chat/history?name=").concat(k,"&organizationName=").concat(r);try{t={method:"GET",params:{guestSessionId:w.current},withCredentials:!0},ES.get(e,t).then((function(e){var t=e.data;t.length>0?(Y(t),Te()):oe(!0)})).catch((function(e){console.error(e)}))}catch(e){Q(!1),console.error(e)}return[2]}))}))};function Re(e){var t=null==e?void 0:e.replace(/<a [^>]*>.*?<\/a>/g,(function(e){return null==e?void 0:e.replace(/\*/g,"&ast;")}));return t}var Ne=function(e,t,n,a,r,o){var c,l,i,s,d,u,m,v,f,z,g,y,M,E,b,H,V,C;console.log("userInput: ",r);var L={role:"assistant",content:"",id:V8()};if(null===(s=null===(i=null===(l=null===(c=null==e?void 0:e.chatStream)||void 0===c?void 0:c.continueChatResult)||void 0===l?void 0:l.message)||void 0===i?void 0:i.content)||void 0===s?void 0:s.includes("WaitMessage: "))Q(!1),Z(!0),L.content=function(e){var t="WaitMessage: ",n=e.indexOf(t);if(-1!==n){var a=e.substring(n+13);return null==a?void 0:a.replaceAll("WaitMessage: ","")}return""}((null===(m=null===(u=null===(d=null==e?void 0:e.chatStream)||void 0===d?void 0:d.continueChatResult)||void 0===u?void 0:u.message)||void 0===m?void 0:m.content)+"\n\n"),Y(p(p([],G,!0),[{role:"user",content:r,time:a,isFirstQuestionSent:o||!1,id:(null===(f=null===(v=null==e?void 0:e.chatStream)||void 0===v?void 0:v.continueChatResult)||void 0===f?void 0:f.requestId)||"",reply:""},L],!1));else{Q(!1),Z(!1),L.content=null===(M=Re(null===(y=null===(g=null===(z=null==e?void 0:e.chatStream)||void 0===z?void 0:z.continueChatResult)||void 0===g?void 0:g.message)||void 0===y?void 0:y.content))||void 0===M?void 0:M.replaceAll("WaitMessage: ","");var x=function(e,t,n){var a,r,o,c,l,i,s,d,u,m,v,f,z,g,y,M,E,b,H,V,C,L,x,S,k,w,T,O,A,R,N,_,D,P,F,I,j,B,U,W,$,q,G,Y,K,X,Q,J,Z,ee,te,ne,ae,re,oe,ce,le,ie,se,he,de,ue,me,pe,ve,fe,ze,ge,ye,Me,Ee,be,He,Ve,Ce,Le,xe,Se,ke,we,Te,Oe,Ae,Ne,_e,De,Pe,Fe,Ie,je,Be,Ue,We,$e,qe,Ge,Ye,Ke,Xe,Qe,Je,Ze,et,tt,nt,at,rt,ot,ct,lt,it,st,ht,dt,ut,mt,pt,vt,ft,zt,gt,yt,Mt,Et,bt,Ht,Vt,Ct,Lt,xt,St,kt,wt,Tt,Ot,At,Rt,Nt,_t,Dt,Pt,Ft,It,jt,Bt,Ut,Wt,$t,qt,Gt,Yt,Kt,Xt,Qt,Jt,Zt,en,tn,nn,an,rn,on,cn,ln,sn,hn,dn,un,mn,pn;console.log("event",e,Object.keys(e)),console.log("content: ",null==e?void 0:e.data);var vn={role:"assistant",content:"",id:V8()};if(!1===(null===(o=null===(r=null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.chatStream)||void 0===r?void 0:r.continueChatResult)||void 0===o?void 0:o.thinking_break)&&!0===(null===(i=null===(l=null===(c=null==e?void 0:e.data)||void 0===c?void 0:c.chatStream)||void 0===l?void 0:l.continueChatResult)||void 0===i?void 0:i.is_orchestrator)&&!1===(null===(u=null===(d=null===(s=null==e?void 0:e.data)||void 0===s?void 0:s.chatStream)||void 0===d?void 0:d.continueChatResult)||void 0===u?void 0:u.isEnd)&&(vn.content=null===(g=Re(null===(z=null===(f=null===(v=null===(m=null==e?void 0:e.data)||void 0===m?void 0:m.chatStream)||void 0===v?void 0:v.continueChatResult)||void 0===f?void 0:f.message)||void 0===z?void 0:z.content))||void 0===g?void 0:g.replaceAll("WaitMessage: ","")),!0===(null===(E=null===(M=null===(y=null==e?void 0:e.data)||void 0===y?void 0:y.chatStream)||void 0===M?void 0:M.continueChatResult)||void 0===E?void 0:E.thinking_break)&&!0===(null===(V=null===(H=null===(b=null==e?void 0:e.data)||void 0===b?void 0:b.chatStream)||void 0===H?void 0:H.continueChatResult)||void 0===V?void 0:V.is_orchestrator)&&!1===(null===(x=null===(L=null===(C=null==e?void 0:e.data)||void 0===C?void 0:C.chatStream)||void 0===L?void 0:L.continueChatResult)||void 0===x?void 0:x.isEnd)&&(vn.content="",t.push({responsedata:null===(T=null===(w=null===(k=null===(S=null==e?void 0:e.data)||void 0===S?void 0:S.chatStream)||void 0===k?void 0:k.continueChatResult)||void 0===w?void 0:w.message)||void 0===T?void 0:T.content,responseFrom:null===(R=null===(A=null===(O=null==e?void 0:e.data)||void 0===O?void 0:O.chatStream)||void 0===A?void 0:A.continueChatResult)||void 0===R?void 0:R.responded_by,header_message:null===(D=null===(_=null===(N=null==e?void 0:e.data)||void 0===N?void 0:N.chatStream)||void 0===_?void 0:_.continueChatResult)||void 0===D?void 0:D.header_message,finalResponseStatus:!1,explainability_id:null!==(j=null===(I=null===(F=null===(P=null==e?void 0:e.data)||void 0===P?void 0:P.chatStream)||void 0===F?void 0:F.continueChatResult)||void 0===I?void 0:I.explainability_id)&&void 0!==j?j:"",isParallelToolResponse:!1})),!1===(null===(W=null===(U=null===(B=null==e?void 0:e.data)||void 0===B?void 0:B.chatStream)||void 0===U?void 0:U.continueChatResult)||void 0===W?void 0:W.thinking_break)&&!0===(null===(G=null===(q=null===($=null==e?void 0:e.data)||void 0===$?void 0:$.chatStream)||void 0===q?void 0:q.continueChatResult)||void 0===G?void 0:G.is_orchestrator)&&!0===(null===(X=null===(K=null===(Y=null==e?void 0:e.data)||void 0===Y?void 0:Y.chatStream)||void 0===K?void 0:K.continueChatResult)||void 0===X?void 0:X.isEnd)&&(vn.content=null===(te=Re(null===(ee=null===(Z=null===(J=null===(Q=null==e?void 0:e.data)||void 0===Q?void 0:Q.chatStream)||void 0===J?void 0:J.continueChatResult)||void 0===Z?void 0:Z.message)||void 0===ee?void 0:ee.content))||void 0===te?void 0:te.replaceAll("WaitMessage: ","")),!1===(null===(re=null===(ae=null===(ne=null==e?void 0:e.data)||void 0===ne?void 0:ne.chatStream)||void 0===ae?void 0:ae.continueChatResult)||void 0===re?void 0:re.thinking_break)&&!1===(null===(le=null===(ce=null===(oe=null==e?void 0:e.data)||void 0===oe?void 0:oe.chatStream)||void 0===ce?void 0:ce.continueChatResult)||void 0===le?void 0:le.is_orchestrator)&&!1===(null===(he=null===(se=null===(ie=null==e?void 0:e.data)||void 0===ie?void 0:ie.chatStream)||void 0===se?void 0:se.continueChatResult)||void 0===he?void 0:he.isEnd)){if((gn=null===(ue=null===(de=null==e?void 0:e.data)||void 0===de?void 0:de.chatStream)||void 0===ue?void 0:ue.continueChatResult).explainability_id&&gn.responded_by){var fn=gn.explainability_id,zn=gn.responded_by;n.has(fn)||n.set(fn,{responded_by:zn,index:t.length})}n.has(null===(pe=null===(me=null==e?void 0:e.data)||void 0===me?void 0:me.chatStream)||void 0===pe?void 0:pe.continueChatResult.explainability_id)?t[Hn=null==(yn=n.get(null===(ze=null===(fe=null===(ve=null==e?void 0:e.data)||void 0===ve?void 0:ve.chatStream)||void 0===fe?void 0:fe.continueChatResult)||void 0===ze?void 0:ze.explainability_id))?void 0:yn.index]={responsedata:null===(Ee=null===(Me=null===(ye=null===(ge=null==e?void 0:e.data)||void 0===ge?void 0:ge.chatStream)||void 0===ye?void 0:ye.continueChatResult)||void 0===Me?void 0:Me.message)||void 0===Ee?void 0:Ee.content,responseFrom:null===(Ve=null===(He=null===(be=null==e?void 0:e.data)||void 0===be?void 0:be.chatStream)||void 0===He?void 0:He.continueChatResult)||void 0===Ve?void 0:Ve.responded_by,header_message:null===(xe=null===(Le=null===(Ce=null==e?void 0:e.data)||void 0===Ce?void 0:Ce.chatStream)||void 0===Le?void 0:Le.continueChatResult)||void 0===xe?void 0:xe.header_message,finalResponseStatus:!0,explainability_id:null!==(Te=null===(we=null===(ke=null===(Se=null==e?void 0:e.data)||void 0===Se?void 0:Se.chatStream)||void 0===ke?void 0:ke.continueChatResult)||void 0===we?void 0:we.explainability_id)&&void 0!==Te?Te:"",isParallelToolResponse:!0}:t=p(p([],t,!0),[{responsedata:null===(_e=null===(Ne=null===(Ae=null===(Oe=null==e?void 0:e.data)||void 0===Oe?void 0:Oe.chatStream)||void 0===Ae?void 0:Ae.continueChatResult)||void 0===Ne?void 0:Ne.message)||void 0===_e?void 0:_e.content,responseFrom:null===(Fe=null===(Pe=null===(De=null==e?void 0:e.data)||void 0===De?void 0:De.chatStream)||void 0===Pe?void 0:Pe.continueChatResult)||void 0===Fe?void 0:Fe.responded_by,header_message:null===(Be=null===(je=null===(Ie=null==e?void 0:e.data)||void 0===Ie?void 0:Ie.chatStream)||void 0===je?void 0:je.continueChatResult)||void 0===Be?void 0:Be.header_message,finalResponseStatus:!0,explainability_id:null!==(qe=null===($e=null===(We=null===(Ue=null==e?void 0:e.data)||void 0===Ue?void 0:Ue.chatStream)||void 0===We?void 0:We.continueChatResult)||void 0===$e?void 0:$e.explainability_id)&&void 0!==qe?qe:"",isParallelToolResponse:!1}],!1)}if(!0===(null===(Ke=null===(Ye=null===(Ge=null==e?void 0:e.data)||void 0===Ge?void 0:Ge.chatStream)||void 0===Ye?void 0:Ye.continueChatResult)||void 0===Ke?void 0:Ke.thinking_break)&&!1===(null===(Je=null===(Qe=null===(Xe=null==e?void 0:e.data)||void 0===Xe?void 0:Xe.chatStream)||void 0===Qe?void 0:Qe.continueChatResult)||void 0===Je?void 0:Je.is_orchestrator)&&!1===(null===(tt=null===(et=null===(Ze=null==e?void 0:e.data)||void 0===Ze?void 0:Ze.chatStream)||void 0===et?void 0:et.continueChatResult)||void 0===tt?void 0:tt.isEnd)){var gn,yn;(gn=null===(at=null===(nt=null==e?void 0:e.data)||void 0===nt?void 0:nt.chatStream)||void 0===at?void 0:at.continueChatResult).explainability_id&&gn.responded_by&&(fn=gn.explainability_id,zn=gn.responded_by,n.has(fn)||n.set(fn,{responded_by:zn,index:t.length})),n.has(null===(ct=null===(ot=null===(rt=null==e?void 0:e.data)||void 0===rt?void 0:rt.chatStream)||void 0===ot?void 0:ot.continueChatResult)||void 0===ct?void 0:ct.explainability_id)?t[Hn=null==(yn=n.get(null===(st=null===(it=null===(lt=null==e?void 0:e.data)||void 0===lt?void 0:lt.chatStream)||void 0===it?void 0:it.continueChatResult)||void 0===st?void 0:st.explainability_id))?void 0:yn.index]={responsedata:null===(mt=null===(ut=null===(dt=null===(ht=null==e?void 0:e.data)||void 0===ht?void 0:ht.chatStream)||void 0===dt?void 0:dt.continueChatResult)||void 0===ut?void 0:ut.message)||void 0===mt?void 0:mt.content,responseFrom:null===(ft=null===(vt=null===(pt=null==e?void 0:e.data)||void 0===pt?void 0:pt.chatStream)||void 0===vt?void 0:vt.continueChatResult)||void 0===ft?void 0:ft.responded_by,header_message:null===(yt=null===(gt=null===(zt=null==e?void 0:e.data)||void 0===zt?void 0:zt.chatStream)||void 0===gt?void 0:gt.continueChatResult)||void 0===yt?void 0:yt.header_message,finalResponseStatus:!1,explainability_id:null!==(Ht=null===(bt=null===(Et=null===(Mt=null==e?void 0:e.data)||void 0===Mt?void 0:Mt.chatStream)||void 0===Et?void 0:Et.continueChatResult)||void 0===bt?void 0:bt.explainability_id)&&void 0!==Ht?Ht:"",isParallelToolResponse:!0}:t.push({responsedata:null===(xt=null===(Lt=null===(Ct=null===(Vt=null==e?void 0:e.data)||void 0===Vt?void 0:Vt.chatStream)||void 0===Ct?void 0:Ct.continueChatResult)||void 0===Lt?void 0:Lt.message)||void 0===xt?void 0:xt.content,responseFrom:null===(wt=null===(kt=null===(St=null==e?void 0:e.data)||void 0===St?void 0:St.chatStream)||void 0===kt?void 0:kt.continueChatResult)||void 0===wt?void 0:wt.responded_by,header_message:null===(At=null===(Ot=null===(Tt=null==e?void 0:e.data)||void 0===Tt?void 0:Tt.chatStream)||void 0===Ot?void 0:Ot.continueChatResult)||void 0===At?void 0:At.header_message,finalResponseStatus:!1,explainability_id:null!==(Dt=null===(_t=null===(Nt=null===(Rt=null==e?void 0:e.data)||void 0===Rt?void 0:Rt.chatStream)||void 0===Nt?void 0:Nt.continueChatResult)||void 0===_t?void 0:_t.explainability_id)&&void 0!==Dt?Dt:"",isParallelToolResponse:!1})}var Mn=null===(jt=null===(It=null===(Ft=null===(Pt=null==e?void 0:e.data)||void 0===Pt?void 0:Pt.chatStream)||void 0===Ft?void 0:Ft.continueChatResult)||void 0===It?void 0:It.message)||void 0===jt?void 0:jt.annotations,En=(null===($t=null===(Wt=null===(Ut=null===(Bt=null==e?void 0:e.data)||void 0===Bt?void 0:Bt.chatStream)||void 0===Ut?void 0:Ut.continueChatResult)||void 0===Wt?void 0:Wt.message)||void 0===$t?void 0:$t.userFeedbackId)||"",bn={role:"assistant",content:vn.content,orchestratorAndAgentsMessages:t,time:new Date,requestId:null!==(Kt=null===(Yt=null===(Gt=null===(qt=null==e?void 0:e.data)||void 0===qt?void 0:qt.chatStream)||void 0===Gt?void 0:Gt.continueChatResult)||void 0===Yt?void 0:Yt.requestId)&&void 0!==Kt?Kt:"",citations:null===(Zt=null===(Jt=null===(Qt=null===(Xt=null==e?void 0:e.data)||void 0===Xt?void 0:Xt.chatStream)||void 0===Qt?void 0:Qt.continueChatResult)||void 0===Jt?void 0:Jt.message)||void 0===Zt?void 0:Zt.citations,guides_utilized:null!==(rn=null===(an=null===(nn=null===(tn=null===(en=null==e?void 0:e.data)||void 0===en?void 0:en.chatStream)||void 0===tn?void 0:tn.continueChatResult)||void 0===nn?void 0:nn.message)||void 0===an?void 0:an.guides_utilized)&&void 0!==rn?rn:[],annotations:Mn,resourceId:null===(ln=null===(cn=null===(on=null==e?void 0:e.data)||void 0===on?void 0:on.chatStream)||void 0===cn?void 0:cn.continueChatResult)||void 0===ln?void 0:ln.resourceId,userFeedbackId:En,citationDisplayType:null!==(mn=null===(un=null===(dn=null===(hn=null===(sn=null==e?void 0:e.data)||void 0===sn?void 0:sn.chatStream)||void 0===hn?void 0:hn.continueChatResult)||void 0===dn?void 0:dn.message)||void 0===un?void 0:un.citationDisplayType)&&void 0!==mn?mn:""};if(Mn)for(var Hn=0;Hn<(null==Mn?void 0:Mn.length);Hn++){var Vn=Mn[Hn];bn=h(h({},bn),{content:null===(pn=null==bn?void 0:bn.content)||void 0===pn?void 0:pn.replace(null==Vn?void 0:Vn.text,(null==Vn?void 0:Vn.text)+"<sup>".concat(Hn,"</sup>"))})}return bn}({data:e},n,t);console.log("assistantObject",x),Y(p(p([],G,!0),[{role:"user",content:r||"",time:a,isFirstQuestionSent:o||!1,requestId:null!==(H=null===(b=null===(E=null==e?void 0:e.chatStream)||void 0===E?void 0:E.continueChatResult)||void 0===b?void 0:b.requestId)&&void 0!==H?H:""},x],!1)),ne(null===(C=null===(V=null==e?void 0:e.chatStream)||void 0===V?void 0:V.continueChatResult)||void 0===C?void 0:C.isEnd)}},_e=function(e,t,n){var a,o,c,i,s,d,u,m=(null==n?void 0:n.trim())||(null==j?void 0:j.trim())||"";if(!("Enter"!==e.key||e.shiftKey||""===(null==n?void 0:n.trim())&&""===(null==j?void 0:j.trim())||ue)){me(!0);var f=new Date;Y(p(p([],G.map((function(e,t){var n;return h(h({},e),{content:null===(n=Re(e.content))||void 0===n?void 0:n.replace("WaitMessage: ","")})})),!0),[{role:"user",content:m,time:f,isFirstQuestionSent:!1}],!1));var z=new Map,g=[];F(!1);var y={WEBSOCKET_URL:v,organizationName:r,chatAssistantName:k,selectedAIModel:"gpt-4",replyMessage:"",userName:"Guest User",userEmailId:"guestUser@example.com",userId:"Guest User",query:(null==n?void 0:n.trim())||(null==j?void 0:j.trim())||"",requestId:"requestId-".concat(V8()),customPrompt:"",enableForBackend:!1,guestSessionId:w.current,chatPreviewId:T.current,customMetaData:h(h({},l),{whenToApply:null===(o=null===(a=null==l?void 0:l.whenToApply)||void 0===a?void 0:a.split("OR"))||void 0===o?void 0:o.filter((function(e){return""!==e})),whenNotToApply:null===(i=null===(c=null==l?void 0:l.whenNotToApply)||void 0===c?void 0:c.split("OR"))||void 0===i?void 0:i.filter((function(e){return""!==e})),isFirstQuestion:0===G.length,validation:null!=H?H:null,conflicting_learnings:null!==(s=null==C?void 0:C.conflicting_learnings)&&void 0!==s?s:"",similar_learnings:null!==(d=null==C?void 0:C.similar_learnings)&&void 0!==d?d:""}),aiModel:"",onStreamEvent:function(e){return Ne(e,z,g,f,m,t)},onStreamEnd:function(e){me(!1)},onError:function(e){return console.error("Stream error:",e)}};if(""!==(null==j?void 0:j.trim())||(null==n?void 0:n.trim())){Q(!0),null===(u=R.current)||void 0===u||u.blur(),B(""),Te();for(var M="Thanks for sharing your thoughts. I’m putting together the most helpful suggestions now, so we can make sure this really fits your needs.".split(" "),E="",b=function(e){setTimeout((function(){E+=M[e]+" ",he(E.trim())}),25*e)},V=0;V<M.length;V++)b(V);y8.startChatStream(y)}}};return n.useMemo((function(){return{img:function(e){e.node;var n=d(e,["node"]);return t.jsx("img",h({},n,{style:{height:"100%",width:"100%",objectFit:"contain"},alt:(null==n?void 0:n.alt)||"",className:"w-full sm:max-w-lg md:max-w-2xl lg:max-w-4xl mx-auto"}))},p:function(e){e.node;var n=d(e,["node"]);return t.jsx("p",h({},n,{style:{maxWidth:"100%",wordWrap:"break-word",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal",overflow:"hidden",display:"block",fontSize:"1rem",lineHeight:"1.625rem",marginBottom:"1rem",marginTop:"10px"}},{children:null==n?void 0:n.children}))},code:function(e){e.node;var n=d(e,["node"]);return t.jsx("span",h({},n,{style:{maxWidth:"100%",wordWrap:"break-word",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal",overflow:"hidden",display:"inline-flex",fontSize:"1rem",lineHeight:"1.625rem"}},{children:null==n?void 0:n.children}))},ol:function(e){e.node;var n=d(e,["node"]);return t.jsx("ol",h({},n,{style:{display:"flex",flexDirection:"column",gap:"1rem",listStyle:"decimal",paddingLeft:"2.5rem"}},{children:null==n?void 0:n.children}))},ul:function(e){e.node;var n=d(e,["node"]);return t.jsx("ul",h({},n,{style:{display:"flex",flexDirection:"column",gap:"1rem",listStyle:"decimal",paddingLeft:"2.5rem"}},{children:null==n?void 0:n.children}))},wta:function(e){e.node;var n=d(e,["node"]);n.key||n["data-key"];var a=n.label||n.children||"Unknown label";return t.jsx(r7,{label:a,onToggle:function(e,t){!function(e,t){var n=Array.isArray(e)?e[0]:e;null==_||_.length,F(!0),D((function(e){return t?e.includes(n)?e:p(p([],e,!0),[n],!1):e.filter((function(e){return e!==n}))}))}(e,t)}})}}}),[]),t.jsxs("div",h({className:T8,style:{height:"100%",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",fontFamily:"Plus Jakarta Sans, sans-serif",backgroundColor:"#fbfaff",border:"1px solid #d1d5db",overflow:"hidden"}},{children:[t.jsxs("div",h({style:{width:"100%",height:"100%",backgroundColor:"#fbfaff",maxWidth:"100%",overflow:"hidden"}},{children:[t.jsx("div",h({ref:He},{children:t.jsx(a7,{resetChatHistory:function(){var e="".concat(O,"/api/chat/resetHistory?name=").concat(k,"&organizationName=").concat(r);V(null),L(null);try{var t={method:"GET",params:{guestSessionId:w.current},withCredentials:!0};ES.get(e,t).then((function(){g(""),M(""),f(!0),F(!1),D([]),le(""),T.current="".concat(V8()),s(!1),Y([]),oe(!0),i((function(e){return h(h({},e),{modification:"",tooltip:"",whenToApply:"",whenNotToApply:"",isTooltipEnabled:!1,isModificationEnabled:!0})}))})).catch((function(e){console.error(e)}))}catch(e){Q(!1),console.error(e)}},isStreamEnd:te})})),t.jsxs("div",h({style:{width:"100%",height:Ce,maxHeight:Ce,overflowY:"auto",backgroundColor:"#fbfaff"},ref:A},{children:[t.jsx("div",h({className:"welcome-message",style:{alignItems:"flex-start",paddingLeft:"0.5rem",paddingTop:"1rem",maxWidth:"70%",fontSize:"1rem",lineHeight:"1.75rem",borderRadius:"0.5rem",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"pre-wrap",color:"#333",fontWeight:"700",textAlign:"left"}},{children:t.jsx("span",{children:"I’m here to help fine-tune your learning so it works as accurately as it should."})})),t.jsxs("div",h({style:{display:"flex",flexDirection:"row",fontFamily:"inherit",padding:"16px 10px 0px 16px",maxWidth:"80%"}},{children:[t.jsx("div",h({style:{maxHeight:"32px",maxWidth:"32px",marginTop:"0.3rem"}},{children:t.jsxs("svg",h({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[t.jsx("g",h({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:t.jsx("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),t.jsx("defs",{children:t.jsx("clipPath",h({id:"clip0_6004_60631"},{children:t.jsx("rect",{width:"24",height:"24",fill:"white"})}))})]}))})),t.jsx("div",h({style:{display:"flex",flexDirection:"column",fontWeight:400,color:"#000"}},{children:t.jsx("div",h({style:{display:"inline-flex",flexDirection:"column",alignItems:"flex-start",paddingLeft:"1rem",paddingRight:"1rem",width:"100%",maxWidth:"100%",fontSize:"1rem",lineHeight:"1.75rem",marginBottom:"1rem",borderRadius:"0.5rem",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"pre-wrap",color:"#333"}},{children:t.jsx("span",{children:t.jsx(cM,h({components:{p:function(e){e.node;var n=d(e,["node"]);return t.jsx("p",h({},n,{style:{margin:0}},{children:null==n?void 0:n.children}))}}},{children:W}))})}))}))]})),G.length?G.map((function(e,n){return t.jsxs("div",h({style:{display:"flex",padding:"0.5rem 1rem",maxWidth:"100%"}},{children:["assistant"==(null==e?void 0:e.role)&&t.jsx("div",h({style:{maxHeight:"32px",maxWidth:"32px",marginTop:"0.5rem",marginRight:"1rem"}},{children:t.jsxs("svg",h({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[t.jsx("g",h({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:t.jsx("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),t.jsx("defs",{children:t.jsx("clipPath",h({id:"clip0_6004_60631"},{children:t.jsx("rect",{width:"24",height:"24",fill:"white"})}))})]}))})),t.jsxs("div",h({style:{width:"100%"}},{children:["assistant"===e.role&&e.orchestratorAndAgentsMessages&&e.orchestratorAndAgentsMessages.length>0&&t.jsx(k8,{orchestratorAndAgentsMessages:null==e?void 0:e.orchestratorAndAgentsMessages,isStreamEnd:te,isCurrentMessage:n===G.length-1,ThinkingBulbIconComponent:z}),"assistant"===(null==e?void 0:e.role)?t.jsx(J8,{index:n,content:null==e?void 0:e.content,messages:G,handleStream:_e}):t.jsx("span",{}),t.jsx("div",h({style:{display:"flex",justifyContent:"flex-end"}},{children:"user"===e.role?t.jsx("div",h({style:{backgroundColor:"#8694A10D",padding:"0 1rem",borderRadius:"8px",maxWidth:"80%"}},{children:t.jsx(J8,{index:n,content:null==e?void 0:e.content,messages:G,handleStream:_e,scrollToBottom:Te})})):t.jsx("span",{})}))]}))]}))})):re&&t.jsx(t.Fragment,{}),X&&t.jsxs("div",h({style:{display:"flex",padding:"16px 16px 0px 16px"}},{children:[t.jsx("div",h({style:{maxHeight:"32px",maxWidth:"32px",marginTop:"0.2rem"}},{children:t.jsxs("svg",h({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[t.jsx("g",h({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:t.jsx("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),t.jsx("defs",{children:t.jsx("clipPath",h({id:"clip0_6004_60631"},{children:t.jsx("rect",{width:"24",height:"24",fill:"white"})}))})]}))})),t.jsx("div",h({style:{display:"inline-flex",alignItems:"flex-start",paddingLeft:"1rem",paddingRight:"1rem",paddingBottom:"1rem",width:"100%",maxWidth:"100%",fontSize:"1rem",lineHeight:"1.75rem",marginBottom:"1rem",borderRadius:"0.5rem",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"pre-wrap",color:"#333"}},{children:t.jsx("span",{children:se})}))]}))]}))]})),t.jsxs("div",h({style:{width:"95%",height:"content-fit",backgroundColor:"#fbfaff",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"end",position:"relative"}},{children:[t.jsx("div",h({style:{visibility:ge?"visible":"hidden",position:"absolute",top:"-3rem",zIndex:0,pointerEvents:"none"}},{children:t.jsx("button",h({onClick:Te,style:{borderRadius:"9999px",padding:0,backgroundColor:"#fff",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",border:"1px solid #d1d5db",pointerEvents:"auto",cursor:"pointer",display:"flex",justifyContent:"center",alignItems:"center",zIndex:1,height:"2.25rem",width:"2.25rem",margin:"0.3rem"}},{children:t.jsx("svg",h({fill:"#000000",width:"16px",height:"16px",viewBox:"0 0 24 24",id:"down","data-name":"Flat Color",xmlns:"http://www.w3.org/2000/svg"},{children:t.jsx("path",{id:"primary",d:"M19.71,13.29a1,1,0,0,0-1.42,0L13,18.59V3a1,1,0,0,0-2,0V18.59l-5.29-5.3a1,1,0,0,0-1.42,1.42l7,7a1,1,0,0,0,1.42,0l7-7A1,1,0,0,0,19.71,13.29Z"})}))}))})),t.jsx("div",h({style:{width:"100%",backgroundColor:"#fff",display:"flex",alignItems:"end",gap:"0.5rem",border:"1px solid #E5E7EB",borderRadius:"8px"}},{children:t.jsxs("div",h({style:{width:"100%",display:"flex"}},{children:[t.jsx("textarea",{ref:R,placeholder:"Tell me more about this learning...",value:j||"",onChange:function(e){return B(e.target.value)},onFocus:function(){return fe(!0)},onBlur:function(){return fe(!1)},onKeyDown:function(e){return _e(e)},style:{flexGrow:1,padding:"0.5rem",borderRadius:"0.5rem",border:"none",fontSize:"1rem",lineHeight:"1.5rem",resize:"none",backgroundColor:"#fff",color:"inherit",minHeight:ve?"120px":"50px",height:ve?"120px":"50px",maxHeight:"120px",overflowY:"auto",fontFamily:"inherit",outline:"none",transition:"min-height 0.3s ease, background-color 0.3s ease",boxSizing:"border-box"}}),t.jsxs("span",h({style:{display:"flex",flexDirection:"column",justifyContent:"end",alignItems:"end"}},{children:[" ",t.jsx("button",h({onClick:function(e){_e(new KeyboardEvent("keydown",{key:"Enter"}))},disabled:be,style:{padding:"0.5rem 0.75rem",borderRadius:"0.375rem",border:"none",backgroundColor:"white",color:be?"#d1d5db":"#5928ed",fontWeight:"bold",fontSize:"1rem",cursor:be?"not-allowed":"pointer",transition:"background-color 0.3s, color 0.3s",height:"50px"}},{children:t.jsx(n7,{})}))]}))]}))}))]})),t.jsxs("div",h({style:{width:"95%",display:"flex",gap:"0.25rem",flexDirection:"row"}},{children:[t.jsx(vJ,h({title:"Coming soon",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx("span",h({style:{width:"50%"}},{children:t.jsx(Y8,{amplitude:1,variant:"speaker",isActive:!1,onClick:function(){return null},disabled:!1})}))})),t.jsx(vJ,h({title:"Coming soon",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx("span",h({style:{width:"50%"}},{children:t.jsx(Y8,{amplitude:1,variant:"microphone",isActive:!1,onClick:function(){return null},disabled:!1})}))}))]}))]}))},c7={},l7={exports:{}},i7={exports:{}};function s7(){return e7||(e7=1,function(e){function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(i7)),i7.exports}function h7(){return t7||(t7=1,function(e){var t=s7().default;function n(a,r){if("function"==typeof WeakMap)var o=new WeakMap,c=new WeakMap;return(e.exports=n=function(e,n){if(!n&&e&&e.__esModule)return e;var a,r,l={__proto__:null,default:e};if(null===e||"object"!=t(e)&&"function"!=typeof e)return l;if(a=n?c:o){if(a.has(e))return a.get(e);a.set(e,l)}for(var i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((r=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,i))&&(r.get||r.set)?a(l,i,r):l[i]=e[i]);return l},e.exports.__esModule=!0,e.exports.default=e.exports)(a,r)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}(l7)),l7.exports}var d7,u7,m7={},p7=Ee(Gl);function v7(){return d7||(d7=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t.createSvgIcon}});var t=p7}(m7)),m7}var f7,z7=function(){if(u7)return c7;u7=1;var e=a_(),t=h7();Object.defineProperty(c7,"__esModule",{value:!0}),c7.default=void 0;var n=t(c.default),a=(0,e(v7()).default)(n.createElement("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"}),"Delete");return c7.default=a,c7}(),g7=Me(z7),y7={};var M7,E7=function(){if(f7)return y7;f7=1;var e=a_(),t=h7();Object.defineProperty(y7,"__esModule",{value:!0}),y7.default=void 0;var n=t(c.default),a=(0,e(v7()).default)(n.createElement("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z"}),"Lock");return y7.default=a,y7}(),b7=Me(E7),H7={};var V7,C7=function(){if(M7)return H7;M7=1;var e=a_(),t=h7();Object.defineProperty(H7,"__esModule",{value:!0}),H7.default=void 0;var n=t(c.default),a=(0,e(v7()).default)(n.createElement("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"}),"Edit");return H7.default=a,H7}(),L7=Me(C7),x7={};var S7,k7=function(){if(V7)return x7;V7=1;var e=a_(),t=h7();Object.defineProperty(x7,"__esModule",{value:!0}),x7.default=void 0;var n=t(c.default),a=(0,e(v7()).default)(n.createElement("path",{d:"M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z"}),"KeyboardArrowUp");return x7.default=a,x7}(),w7=Me(k7),T7=function(e){var n=e.similarLearnings,a=void 0===n?[]:n,r=e.formData,o=c.default.useState((function(){return(a||[]).reduce((function(e,t){return e[t.id]=!0,e}),{})})),l=o[0],i=o[1];return a.length?t.jsx(DB,h({sx:{marginTop:3}},{children:t.jsxs(DB,h({sx:{borderRadius:"8px",padding:"16px",border:"1px solid #3b82f6",backgroundColor:"#dbeafe"}},{children:[t.jsx(DB,h({sx:{display:"flex",alignItems:"center",marginBottom:1}},{children:t.jsxs(XP,h({sx:{fontSize:"1rem",fontWeight:600,fontFamily:"Plus Jakarta Sans",color:"#111827"}},{children:["Found ",a.length," similar Instant ",a.length>1?"Learnings":"Learning"]}))})),t.jsx(DB,h({sx:{display:"flex",flexDirection:"column",gap:2,maxHeight:"300px",overflowY:"auto",pr:1,mt:2}},{children:a.map((function(e,n){var a,o,c,s=e.id,d=e.feedback,u=null===(a=d.when_to_apply)||void 0===a?void 0:a.trim(),m=null===(o=d.when_not_to_apply)||void 0===o?void 0:o.trim(),p=l[s];return t.jsxs(DB,h({sx:{border:"1px solid #D1D5DB",borderRadius:"8px",padding:"16px",backgroundColor:"#fff",flexShrink:0}},{children:[t.jsxs(DB,h({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:2,gap:1}},{children:[t.jsx(XP,h({sx:{fontSize:"1rem",fontFamily:"Plus Jakarta Sans",minWidth:"130px",flexShrink:0,fontWeight:700}},{children:"Instant Learning:"})),t.jsx(DB,h({sx:{flex:1,overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal"}},{children:t.jsx(XP,h({sx:{fontSize:"0.95rem",fontFamily:"Plus Jakarta Sans",color:"#111827"}},{children:d.variant}))})),t.jsx(vJ,h({title:null===(c=r.scope)||void 0===c?void 0:c.split(" ").map((function(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()})).join(" "),placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsxs(XP,h({sx:{fontSize:"0.875rem",fontFamily:"Plus Jakarta Sans",flexShrink:0,border:"1px solid #D1D5DB",borderRadius:"25px",padding:"10px",display:"flex",alignItems:"center",cursor:"pointer"}},{children:["Section: ","Custom",t.jsx(U8,{size:16,style:{paddingLeft:"0.25rem"}})]}))})),t.jsx(w7,{onClick:function(){return function(e){i((function(t){var n;return h(h({},t),((n={})[e]=!t[e],n))}))}(s)},style:{fontSize:30,transform:p?"rotate(0deg)":"rotate(180deg)",transition:"transform 0.3s ease-in-out",cursor:"pointer"}})]})),t.jsx(TD,h({in:p,timeout:"auto",unmountOnExit:!0},{children:t.jsxs(DB,h({sx:{display:"flex",gap:2,mb:3}},{children:[t.jsx(DB,h({sx:{flex:1,display:"flex",flexDirection:"column"}},{children:u&&t.jsxs(t.Fragment,{children:[t.jsx(XP,h({sx:{fontFamily:"Plus Jakarta Sans",fontSize:"1rem",marginBottom:1,fontWeight:700}},{children:"When to apply"})),t.jsx(T2,{fullWidth:!0,multiline:!0,value:d.when_to_apply,placeholder:"When to apply",sx:{pointerEvents:"none",fontFamily:"Plus Jakarta Sans","& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"}}})]})})),t.jsx(DB,h({sx:{flex:1,display:"flex",flexDirection:"column",fontFamily:"Plus Jakarta Sans"}},{children:m&&t.jsxs(t.Fragment,{children:[t.jsx(XP,h({sx:{fontFamily:"Plus Jakarta Sans",fontSize:"1rem",marginBottom:1,fontWeight:700}},{children:"When not to apply"})),t.jsx(T2,{fullWidth:!0,multiline:!0,value:d.when_not_to_apply,placeholder:"When not to apply",sx:{pointerEvents:"none",fontFamily:"Plus Jakarta Sans","& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"}}})]})}))]}))}))]}),s)}))}))]}))})):null},O7={};var A7=function(){if(S7)return O7;S7=1;var e=a_(),t=h7();Object.defineProperty(O7,"__esModule",{value:!0}),O7.default=void 0;var n=t(c.default),a=(0,e(v7()).default)(n.createElement("path",{d:"M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z"}),"KeyboardArrowDown");return O7.default=a,O7}(),R7=Me(A7),N7=function(e){var a=e.conflictingConditions,r=n.useState((function(){return a.map((function(e,t){return t}))})),o=r[0],c=r[1],l=function(e){switch(e){case"whenToApply_vs_whenNotToApply":return"When to apply & When not to apply";case"whenToApply_internal":return"When to apply";case"whenNotToApply_internal":return"When not to apply";default:return e.replace(/_/g," ")}};return a&&0!==a.length?t.jsxs(DB,h({sx:{backgroundColor:"#FEF2F2",border:"1px solid #FCA5A5",boxShadow:"0 1px 4px rgba(0, 0, 0, 0.04)",padding:3,borderRadius:2,mt:3,mb:3,fontFamily:"Plus Jakarta Sans"}},{children:[t.jsx(XP,h({sx:{fontSize:"1.15rem",fontWeight:700,color:"#B91C1C",mb:2,fontFamily:"Plus Jakarta Sans"}},{children:"Conflicting Conditions Found"})),t.jsx(DB,h({sx:{maxHeight:360,overflowY:"auto",pr:1.5}},{children:a.map((function(e,n){var a=[];e.condition_wta&&a.push({label:"When To Apply",value:e.condition_wta}),e.condition_wnta&&a.push({label:"When Not To Apply",value:e.condition_wnta}),1===a.length&&a.push(h({},a[0]));var r=o.includes(n);return t.jsxs($D,h({expanded:r,onChange:function(){return function(e){c((function(t){return t.includes(e)?t.filter((function(t){return t!==e})):p(p([],t,!0),[e],!1)}))}(n)},disableGutters:!0,sx:{mb:2,border:"1px solid #FCA5A5",fontFamily:"Plus Jakarta Sans",borderRadius:2,"&::before":{display:"none"}}},{children:[t.jsxs(CP,h({expandIcon:t.jsx(R7,{style:{color:"#991B1B",transition:"transform 0.3s ease-in-out"}}),"aria-controls":"panel-".concat(n,"-content"),id:"panel-".concat(n,"-header"),sx:{fontFamily:"Plus Jakarta Sans",color:"#991B1B",fontWeight:600,px:2,py:1.5}},{children:["Conflict in: ",l(e.conflictType)]})),t.jsxs(ZD,h({sx:{px:2,pb:2}},{children:[t.jsx(DB,h({sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},gap:2,mb:2}},{children:a.map((function(e,n){return t.jsxs(DB,h({sx:{flex:1,border:"1px solid #FCA5A5",borderRadius:2,padding:2,backgroundColor:"#FFFFFF"}},{children:[t.jsx(XP,h({variant:"caption",sx:{fontSize:"0.9rem",color:"#6B7280",fontWeight:600,mb:.5,display:"block",fontFamily:"Plus Jakarta Sans"}},{children:e.label})),t.jsx(XP,h({variant:"body2",sx:{fontSize:"1rem",color:"#374151",whiteSpace:"pre-line",fontFamily:"Plus Jakarta Sans"}},{children:e.value}))]}),n)}))})),t.jsxs(XP,h({variant:"body2",sx:{fontSize:"1rem",color:"#1F2937",lineHeight:1.6,fontFamily:"Plus Jakarta Sans"}},{children:[t.jsx("strong",{children:"Reason:"})," ",e.reason]}))]}))]}),n)}))}))]})):null},_7=function(e){var a=e.conflictingConditions||[],r=a[0],o=a[1],c=r||[],l=o||[],i=n.useState((function(){return c.map((function(e,t){return t}))})),s=i[0],d=i[1],u=n.useState((function(){return l.map((function(e,t){return t}))})),m=u[0],v=u[1],f=function(e,n,a){var r="conflict"===a?s.includes(n):m.includes(n),o="conflict"===a?"#991B1B":"#F87171",c="conflict"===a?"Conflicting with: ".concat(e.feedback.variant):"Similar to: ".concat(e.feedback.variant),l=[];return e.feedback.when_to_apply&&l.push({label:"When To Apply",value:e.feedback.when_to_apply}),e.feedback.when_not_to_apply&&l.push({label:"When Not To Apply",value:e.feedback.when_not_to_apply}),1===l.length&&l.push(h({},l[0])),t.jsxs($D,h({expanded:r,onChange:function(){return function(e,t){"conflict"===t?d((function(t){return t.includes(e)?t.filter((function(t){return t!==e})):p(p([],t,!0),[e],!1)})):v((function(t){return t.includes(e)?t.filter((function(t){return t!==e})):p(p([],t,!0),[e],!1)}))}(n,a)},disableGutters:!0,sx:{mb:2,border:"1px solid #FCA5A5",borderRadius:2,fontFamily:"Plus Jakarta Sans","&::before":{display:"none"}}},{children:[t.jsx(CP,h({expandIcon:t.jsx(R7,{style:{color:o}}),"aria-controls":"panel-".concat(a,"-").concat(n,"-content"),id:"panel-".concat(a,"-").concat(n,"-header"),sx:{fontFamily:"Plus Jakarta Sans",color:o,fontWeight:600,px:2,py:1.5}},{children:c})),t.jsx(ZD,h({sx:{px:2,pb:2}},{children:t.jsx(DB,h({sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},gap:2,mb:2}},{children:l.map((function(e,n){return t.jsxs(DB,h({sx:{flex:1,border:"1px solid #FCA5A5",borderRadius:2,padding:2,backgroundColor:"#FFFFFF"}},{children:[t.jsx(XP,h({variant:"caption",sx:{fontSize:"0.9rem",color:"#6B7280",fontWeight:600,mb:.5,display:"block",fontFamily:"Plus Jakarta Sans"}},{children:e.label})),t.jsx(XP,h({variant:"body2",sx:{fontSize:"1rem",color:"#374151",whiteSpace:"pre-line",fontFamily:"Plus Jakarta Sans"}},{children:Array.isArray(e.value)?e.value.join("\n"):e.value}))]}),n)}))}))}))]}),"".concat(a,"-").concat(n))};return c&&0!==c.length||l&&0!==l.length?t.jsxs(DB,h({sx:{backgroundColor:"#FEF2F2",border:"1px solid #FCA5A5",boxShadow:"0 1px 4px rgba(0, 0, 0, 0.04)",padding:3,borderRadius:2,mt:3,mb:3,fontFamily:"Plus Jakarta Sans"}},{children:[t.jsx(XP,h({sx:{fontSize:"1.15rem",fontWeight:700,color:"#B91C1C",mb:2,fontFamily:"Plus Jakarta Sans"}},{children:"Conflciting/Similar Learning Found"})),t.jsxs(DB,h({sx:{maxHeight:360,overflowY:"auto",pr:1.5}},{children:[c.map((function(e,t){return f(e,t,"conflict")})),l.map((function(e,t){return f(e,t,"similar")}))]}))]})):null},D7=function(e){var a;e.organizationName;var r=e.selectedText,o=e.scopeOptions,c=e.devModeTag,l=e.chatLogo,i=void 0===l?null:l,s=e.submitFunction;e.setShowChat,e.showChat;var d=e.setFormDataState,v=e.instantLearningSuggestions;e.setHasUserFilledForm,e.hasUserFilledForm;var f=e.isNewChatClicked,z=e.setIsNewChatClicked,g=e.setHasUserWrittenModification,y=e.extractedModification,M=e.save,E=e.extractedTooltip;e.isSaveLoading,e.shouldTriggerSave;var b=e.baseUrl,H=e.topic_table,V=e.variant_table,C=e.scope_table,L=e.embedding_column_name,x=e.embedding_model,S=e.validationWtaResponse,k=e.setValidationWtaResponse,w=e.learningWtaResponse;e.setLearningWtaResponse;var T=e.setIsFormSavedClicked,O=n.useState({context:"",issue_with_response:"",original:null!=r?r:"",modification:"",whenToApply:"",whenNotToApply:"",tooltip:"",scope:o[0].value,isTooltipEnabled:!1,isModificationEnabled:!0,isDevMode:!1}),A=O[0],R=O[1],N=n.useState(!1),_=N[0],D=N[1],P=n.useState(!1),F=P[0],I=P[1],j=n.useState(!1),B=j[0],U=j[1],W=n.useState(!1),$=W[0],q=W[1],G=n.useState([]),Y=G[0],K=G[1],X=n.useState([]),Q=X[0],J=X[1],Z=n.useState(!1),ee=Z[0],te=Z[1],ne=n.useState(!1),ae=ne[0],re=ne[1],oe=n.useState(!1),ce=oe[0],le=oe[1],ie=n.useState(!1),se=ie[0],he=ie[1],de=n.useState(null),ue=de[0],me=de[1],pe=n.useState(!1);pe[0],pe[1];var ve=n.useState(null);ve[0];var fe=ve[1],ze=n.useState(null),ge=ze[0],ye=ze[1],Me=n.useState(!1),Ee=Me[0],be=Me[1],He=n.useState(!1),Ve=He[0],Ce=He[1],Le=n.useState(null),xe=Le[0],Se=Le[1],ke=n.useState(null),we=ke[0],Te=ke[1],Oe=n.useMemo((function(){var e,t,n,a,r=""!==(null===(e=null==A?void 0:A.original)||void 0===e?void 0:e.trim()),o=""!==(null===(t=null==A?void 0:A.whenToApply)||void 0===t?void 0:t.trim()),c=(null==Y?void 0:Y.length)>0,l=!(null==A?void 0:A.isTooltipEnabled)||""!==(null===(n=null==A?void 0:A.tooltip)||void 0===n?void 0:n.trim()),i=!0;return(null==A?void 0:A.isModificationEnabled)&&(i=""!==(null===(a=null==A?void 0:A.modification)||void 0===a?void 0:a.trim())),r&&o&&c&&(l||i)}),[A,Y,v]),Ae=n.useRef(null);n.useEffect((function(){A.isModificationEnabled||R((function(e){return h(h({},e),{modification:""})})),A.isTooltipEnabled||R((function(e){return h(h({},e),{tooltip:""})}))}),[A.isModificationEnabled,A.isTooltipEnabled]),n.useEffect((function(){if(""===y&&(null==A?void 0:A.isTooltipEnabled)&&R((function(e){return h(h({},e),{isModificationEnabled:!1})})),""!==y||(null==A?void 0:A.isTooltipEnabled)||R((function(e){return h(h({},e),{modification:""})})),y&&""!==y){R((function(e){return h(h({},e),{modification:y,isModificationEnabled:!0})})),q(!0);var e=setTimeout((function(){q(!1)}),400);return function(){return clearTimeout(e)}}}),[y]),n.useEffect((function(){""===E&&R((function(e){return h(h({},e),{isTooltipEnabled:!1})})),E&&""!==E&&R((function(e){return h(h({},e),{tooltip:E,isTooltipEnabled:!0})}))}),[E]),n.useEffect((function(){f&&(R((function(e){return h(h({},e),{modification:"",tooltip:"",isTooltipEnabled:!1,isModificationEnabled:!0,whenToApply:"",whenNotToApply:""})})),K([]),J([]),z(!1),he(!1),be(!1),Ce(!1))}),[f]),n.useEffect((function(){d(A)}),[A]),n.useEffect((function(){""===A.original.trim()||""===A.modification.trim()&&""===A.tooltip.trim()||_||D(!0)}),[A]),n.useEffect((function(){if((null==Y?void 0:Y.length)>0&&!ee){I(!0);var e=setTimeout((function(){I(!1)}),400);return function(){return clearTimeout(e)}}}),[JSON.stringify(Y)]),n.useEffect((function(){if((null==Q?void 0:Q.length)>0&&!ae){U(!0);var e=setTimeout((function(){U(!1)}),400);return function(){return clearTimeout(e)}}}),[JSON.stringify(Q)]),n.useEffect((function(){var e,t,n,a;if(v){te(!1),re(!1);var r=null===(e=null==v?void 0:v.conditions_whentoapply)||void 0===e?void 0:e.map((function(e){return e.when_to_apply})),o=null===(t=null==v?void 0:v.conditions_whennottoapply)||void 0===t?void 0:t.map((function(e){return e.when_not_to_apply}));(null===(n=null==v?void 0:v.conditions_whentoapply)||void 0===n?void 0:n.length)&&(K(r.filter((function(e){return""!==e}))),R((function(e){return h(h({},e),{whenToApply:null==r?void 0:r.join(" OR ")})}))),(null===(a=null==v?void 0:v.conditions_whennottoapply)||void 0===a?void 0:a.length)&&(J(o.filter((function(e){return""!==e}))),R((function(e){return h(h({},e),{whenNotToApply:null==o?void 0:o.join(" OR ")})})))}}),[v]);var Re=n.useRef(null),Ne=n.useCallback((function(){Re.current&&clearTimeout(Re.current),Re.current=setTimeout((function(){g(!0)}),1e3)}),[]),_e=n.useCallback((function(e){return function(t){R((function(n){var a;return h(h({},n),((a={})[e]=t.target.value,a))})),Ne()}}),[Ne]),De=function(e){return e.replace(new RegExp("<".concat(c,">"),"gi"),"").replace(new RegExp("</".concat(c,">"),"gi"),"").replace(/<\/?[^>]+(>|$)/g,"")},Pe=n.useCallback((function(e){var t=De(e);R((function(e){return h(h({},e),{tooltip:t})})),Ne()}),[Ne]),Fe=function(e){return function(t){var n=t.target.checked,a={};"isTooltipEnabled"===e?a={tooltip:n?A.tooltip:"",isModificationEnabled:!n||A.isModificationEnabled}:"isModificationEnabled"===e&&(a={modification:n?A.modification:""}),R((function(t){var r;return h(h(h({},t),a),((r={})[e]=n,r))}))}};n.useEffect((function(){if(M){T(!0);u(void 0,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,Be()];case 1:return e.sent()?[4,je()]:[3,3];case 2:e.sent(),e.label=3;case 3:return[2]}}))}))}}),[M]);n.useEffect((function(){S&&!1===S.is_valid?(be(!0),ye(S.conflictingConditions),Ge()):S&&S.is_valid&&(be(!1),ye(null))}),[S]),n.useEffect((function(){w&&!1===w.is_valid_db?(Ce(!0),Se(w.conflicting_learnings),Te(w.similar_learnings),Ge()):w&&w.is_valid_db&&(Ce(!1),Se(null),Te(null))}),[w]);var Ie,je=function(){return u(void 0,void 0,void 0,(function(){var e,t,n,a,r;return m(this,(function(o){switch(o.label){case 0:le(!0),o.label=1;case 1:return o.trys.push([1,4,,5]),[4,fetch("".concat(b,"/instant_learning/similar-variants"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topic_table:null!=H?H:"techolution-instantLearning-topics",variant_table:null!=V?V:"techolution-instantLearning-variants",scope_table:null!=C?C:"techolution-instantLearning-scopes",embedding_column_name:null!=L?L:"variant_embedding",embedding_model:null!=x?x:"mxbai-embed-large-v1",scope_id:[A.scope],topic:A.original,variants:{variant:"Replace ".concat(A.original," with ").concat(A.modification),conditions_whentoapply:A.whenToApply,conditions_whennottoapply:A.whenNotToApply},similarity_threshold:.4})})];case 2:return[4,o.sent().json()];case 3:return e=o.sent(),le(!1),e.response&&e.response.similar_learnings&&e.response.similar_learnings.length>0?(console.log("API response:",e),t=(null===(r=null==e?void 0:e.response)||void 0===r?void 0:r.similar_learnings)||{},n=Object.keys(t).length>0,he(n),me(e)):he(!1),[3,5];case 4:return a=o.sent(),le(!1),console.error("API error:",a),he(!1),[3,5];case 5:return[2]}}))}))},Be=function(){return u(void 0,void 0,void 0,(function(){var e,t,n,a,r,o,c,l;return m(this,(function(i){switch(i.label){case 0:le(!0),i.label=1;case 1:return i.trys.push([1,4,,5]),[4,fetch("".concat(b,"/instant_learning/validate-wta"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({whenToApply:null===(a=null===(n=null==A?void 0:A.whenToApply)||void 0===n?void 0:n.split("OR"))||void 0===a?void 0:a.filter((function(e){return""!==e})),whenNotToApply:null===(o=null===(r=null==A?void 0:A.whenNotToApply)||void 0===r?void 0:r.split("OR"))||void 0===o?void 0:o.filter((function(e){return""!==e}))})})];case 2:return[4,i.sent().json()];case 3:return e=i.sent(),le(!1),e.response&&k(e.response),e&&e.response&&e.response.is_valid?(fe(null),be(!1),ye(null),console.log("Form submitted:",A),le(!0),""===(null==A?void 0:A.modification)&&R((function(e){return h(h({},e),{isModificationEnabled:!1})})),""===(null==A?void 0:A.tooltip)&&R((function(e){return h(h({},e),{isTooltipEnabled:!1})})),s(A,le)):e&&e.response&&!e.response.is_valid&&(fe(null===(c=e.response)||void 0===c?void 0:c.reason),be(!0),ye(e.response.conflictingConditions),Ge()),[2,null===(l=null==e?void 0:e.response)||void 0===l?void 0:l.is_valid];case 4:return t=i.sent(),le(!1),console.error("API error:",t),[3,5];case 5:return[2]}}))}))},Ue=n.useRef(null),We=n.useState(!1),$e=We[0],qe=We[1],Ge=function(){var e=Ue.current;e&&setTimeout((function(){e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),qe(!1)}),200)};return n.useEffect((function(){var e=Ue.current,t=function(){var e=Ue.current;if(e){var t=e.scrollTop,n=e.scrollHeight,a=e.clientHeight;qe(!(n-(t+a)<=35))}};return e&&(e.addEventListener("scroll",t),t()),function(){e&&e.removeEventListener("scroll",t)}}),[$e]),t.jsxs(DB,h({p:0,className:T8,sx:{display:"flex",flexDirection:"column",height:"100%",width:"100%"}},{children:[t.jsx(DB,{children:t.jsx(XP,h({sx:{fontSize:20,fontWeight:600,fontFamily:"Plus Jakarta Sans"}},{children:"Instant Learning"}))}),t.jsxs(DB,h({sx:{fontFamily:"Plus Jakarta Sans",display:"flex",flexDirection:"column",gap:2,justifyContent:"space-between",flexGrow:1,paddingTop:"20px",height:"calc(100% - 30px)",overflow:"auto"}},{children:[t.jsxs(DB,h({sx:{display:"flex",flexDirection:"column",gap:"20px",height:"calc(100% - 90px)",overflow:"auto",position:"relative"},ref:Ue},{children:[t.jsxs(DB,h({sx:{display:"flex",gap:2}},{children:[t.jsxs(DB,h({sx:{flex:1}},{children:[t.jsxs(DB,h({sx:{display:"flex",alignItems:"center"}},{children:[t.jsxs(XP,h({sx:{fontFamily:"Plus Jakarta Sans",fontSize:"1rem",fontWeight:600,display:"flex",alignItems:"center"}},{children:["Original"," ",t.jsx(DB,h({component:"span",sx:{color:"red"}},{children:"*"})),t.jsx(vJ,h({title:"Original word/phrase which needs to be replaced",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx(U8,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),t.jsx(DZ,{sx:{visibility:"hidden"},disabled:!0})]})),t.jsx(T2,{sx:{"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"}},id:"original",value:A.original,onChange:_e("original"),fullWidth:!0,placeholder:"Enter original"})]})),t.jsxs(DB,h({sx:{flex:1}},{children:[t.jsxs(DB,h({sx:{display:"flex",alignItems:"center"}},{children:[t.jsxs(XP,h({sx:{fontFamily:"Plus Jakarta Sans",fontWeight:600,fontSize:"1rem",display:"flex",alignItems:"center"}},{children:["Modification",A.isModificationEnabled&&!A.isTooltipEnabled&&t.jsx(DB,h({component:"span",sx:{color:"red"}},{children:"*"})),t.jsx(vJ,h({title:"Modified word/phrase which Original needs to be replaced with",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx(U8,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),t.jsx(DZ,{checked:A.isModificationEnabled,disabled:!A.isTooltipEnabled,onChange:Fe("isModificationEnabled"),sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"#5928ed"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{backgroundColor:"#5928ed"}}})]})),A.isModificationEnabled&&t.jsx(T2,{sx:{"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},boxShadow:$?"0 0 12px 3px rgba(34, 197, 94, 0.6)":"none",transition:"box-shadow 0.3s ease-in-out"},id:"modification",value:A.modification,onChange:_e("modification"),fullWidth:!0,placeholder:"Change ".concat(r," to...")})]}))]})),t.jsxs(DB,h({sx:{display:"flex",gap:2}},{children:[t.jsx(DB,{sx:{flex:1}}),t.jsxs(DB,h({sx:{flex:1}},{children:[t.jsxs(DB,h({sx:{display:"flex",justifyContent:"space-between"}},{children:[t.jsxs(DB,h({sx:{display:"flex",alignItems:"center"}},{children:[t.jsxs(XP,h({sx:{fontSize:"1rem",fontWeight:600,fontFamily:"Plus Jakarta Sans",display:"flex",alignItems:"center"}},{children:["Tooltip",A.isTooltipEnabled&&t.jsx(DB,h({component:"span",sx:{color:"red"}},{children:"*"})),t.jsx(vJ,h({title:"Adds a tooltip to the modification or the original word",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx(U8,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),t.jsx(DZ,{checked:A.isTooltipEnabled,onChange:Fe("isTooltipEnabled"),sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"#5928ed"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{backgroundColor:"#5928ed"}}})]})),A.isTooltipEnabled&&t.jsxs(DB,h({sx:{display:"flex",alignItems:"center"}},{children:[t.jsx(XP,h({sx:{fontSize:14,fontWeight:600,fontFamily:"Plus Jakarta Sans"}},{children:"Dev Mode"})),t.jsx(DZ,{checked:A.isDevMode,onChange:Fe("isDevMode"),sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"#4b5563"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{backgroundColor:"#4b5563"}}})]}))]})),A.isTooltipEnabled&&t.jsx(T2,{id:"tooltip",inputRef:Ae,value:function(){var e=De(A.tooltip);return A.isDevMode?"<".concat(c,">").concat(e,"</").concat(c,">"):e}(),onChange:function(e){return Pe(e.target.value)},onFocus:function(){setTimeout((function(){if(A.isDevMode){var e=De(A.tooltip),t="<".concat(c,">").length+e.length,n=Ae.current;n&&n.setSelectionRange(t,t)}}),0)},fullWidth:!0,placeholder:A.isDevMode?"<".concat(c,">Enter tooltip content</").concat(c,">"):"Enter tooltip content",sx:{"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"}}})]}))]})),t.jsxs(DB,h({sx:{display:"flex",gap:2,height:"".concat(A.isTooltipEnabled?"calc(100% - 248px)":"calc(100% - 200px)")}},{children:[!(null==Y?void 0:Y.length)&&t.jsxs(DB,h({sx:{flex:1}},{children:[t.jsxs(XP,h({sx:{fontSize:"1rem",fontWeight:600,marginBottom:"8px",fontFamily:"Plus Jakarta Sans",display:"flex",alignItems:"center"},gutterBottom:!0},{children:["When To Apply",t.jsx(DB,h({component:"span",sx:{color:"red"}},{children:"*"})),t.jsx(vJ,h({title:"Specific situations or conditions where this learning should be applied.",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx(U8,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),t.jsxs(DB,h({sx:{border:"1px solid #ccc",borderRadius:"8px",padding:2,height:"calc(100% - 64px)",display:"flex",flexDirection:"column"}},{children:[t.jsxs("div",h({style:{width:"100%",display:"flex",gap:"0.25rem"}},{children:[t.jsxs("svg",h({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[t.jsx("g",h({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:t.jsx("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),t.jsx("defs",{children:t.jsx("clipPath",h({id:"clip0_6004_60631"},{children:t.jsx("rect",{width:"24",height:"24",fill:"white"})}))})]})),t.jsx(XP,h({variant:"body1",sx:{ml:i?1:0,fontWeight:"600",fontFamily:"Plus Jakarta Sans",color:"#5928ed"}},{children:"AI Suggestions"}))]})),t.jsx("div",h({style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"}},{children:t.jsxs("div",h({style:{width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:"0.5rem",paddingTop:"1rem",paddingBottom:"1rem"}},{children:[t.jsx("div",h({style:{fontWeight:"700",color:"#6b7280"}},{children:"No suggestions found"})),t.jsxs("div",h({style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",gap:"0.25rem",fontSize:"1rem",flexFlow:"wrap"}},{children:[t.jsx("div",h({style:{}},{children:"Tell us about your learning in "})),t.jsx("span",h({style:{color:"#5928ED",fontWeight:"700"}},{children:"InstantLearning.AI"}))," ",t.jsx("span",{children:"Chat"})]}))]}))}))]}))]})),(null==Y?void 0:Y.length)>0&&t.jsxs(DB,h({sx:{flex:1,height:"100%"}},{children:[t.jsxs(XP,h({sx:{fontSize:"1rem",fontWeight:600,marginBottom:"8px",fontFamily:"Plus Jakarta Sans, sans-serif",display:"flex",alignItems:"center"},gutterBottom:!0},{children:["When To Apply",t.jsx(DB,h({component:"span",sx:{color:"red"}},{children:"*"})),t.jsx(vJ,h({title:"Specific situations or conditions where this learning should be applied.",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx(U8,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),t.jsxs(DB,h({sx:{border:"1px solid #ccc",borderRadius:"8px",padding:2,height:"calc(100% - 64px)",boxShadow:F?"0 0 12px 3px rgba(34, 197, 94, 0.6)":"none",transition:"box-shadow 0.3s ease-in-out"}},{children:[t.jsxs(DB,h({display:"flex",alignItems:"center",justifyContent:"space-between",sx:{mb:"8px"}},{children:[t.jsxs(DB,h({display:"flex",gap:"0.25rem",alignItems:"center"},{children:[i&&t.jsx(DB,{component:"img",src:i,alt:"Chat",sx:{width:14,height:14}}),t.jsxs("svg",h({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[t.jsx("g",h({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:t.jsx("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),t.jsx("defs",{children:t.jsx("clipPath",h({id:"clip0_6004_60631"},{children:t.jsx("rect",{width:"24",height:"24",fill:"white"})}))})]})),t.jsx(XP,h({variant:"body1",sx:{ml:i?1:0,fontWeight:"600",fontFamily:"Plus Jakarta Sans",color:"#5928ed"}},{children:"AI Suggestions"}))]})),(null==Y?void 0:Y.length)>0&&t.jsx(vJ,h({title:ee?"Save & Lock":"Edit",componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx(OP,h({disabled:Y.some((function(e){return""===(null==e?void 0:e.trim())})),onClick:function(){return te((function(e){return!e}))},size:"small",sx:{color:"gray","&:hover":{color:"black"}}},{children:ee?t.jsx(b7,{fontSize:"small"}):t.jsx(L7,{fontSize:"small"})}))}))]})),t.jsx(DB,h({sx:{height:"calc(100% - 38px)",overflow:"auto"}},{children:t.jsx("ol",h({style:{paddingLeft:"0rem",fontFamily:"Plus Jakarta Sans",margin:0}},{children:F?t.jsxs(DB,h({sx:{display:"flex",justifyContent:"center",py:2,gap:2}},{children:[t.jsx(yW,{size:24}),t.jsx("span",{children:"Generating When to apply..."})]})):t.jsx(DB,h({sx:{pt:"16px"}},{children:Y.map((function(e,t){return{value:e,index:t}})).map((function(e,n){var a=e.value,r=e.index;return t.jsxs(DB,h({sx:{display:"flex",alignItems:"flex-start",gap:1,mb:r<Y.length-1?2:0,fontFamily:"Plus Jakarta Sans"},component:"li"},{children:[t.jsx(T2,{variant:"outlined",disabled:!ee,fullWidth:!0,multiline:!0,value:"".concat(a),onChange:function(e){var t=p([],Y,!0);t[r]=e.target.value,K(t),R((function(e){return h(h({},e),{whenToApply:t.join(" OR ")})}))},sx:{backgroundColor:"#f9fafb",borderRadius:1,"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputBase-input.Mui-disabled":{color:"#000",WebkitTextFillColor:"#000"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root.Mui-disabled":{color:"rgba(0, 0, 0, 0.6)"}},InputProps:{startAdornment:t.jsxs(mG,h({position:"start",sx:{color:"#000",alignSelf:"flex-start",paddingTop:"12px"}},{children:[r+1,"."]}))}}),ee&&t.jsx(OP,h({onClick:function(){if(Y.length>1){var e=Y.filter((function(e,t){return t!==r}));K(e),R((function(t){return h(h({},t),{whenToApply:e.join(" OR ")})}))}},sx:{mt:1}},{children:t.jsx(g7,{})}))]}),r)}))}))}))}))]}))]})),!(null==Q?void 0:Q.length)&&t.jsxs(DB,h({sx:{flex:1}},{children:[t.jsxs(XP,h({sx:{fontSize:"1rem",fontWeight:600,marginBottom:"8px",fontFamily:"Plus Jakarta Sans",display:"flex",alignItems:"center"},gutterBottom:!0},{children:["When Not To Apply",t.jsx(vJ,h({title:"Cases where this learning should not be applied to avoid incorrect responses.",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx(U8,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),t.jsxs(DB,h({sx:{border:"1px solid #ccc",borderRadius:"8px",padding:2,flex:1,display:"flex",flexDirection:"column",height:"calc(100% - 64px)"}},{children:[t.jsxs("div",h({style:{width:"100%",display:"flex",gap:"0.25rem"}},{children:[t.jsxs("svg",h({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[t.jsx("g",h({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:t.jsx("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),t.jsx("defs",{children:t.jsx("clipPath",h({id:"clip0_6004_60631"},{children:t.jsx("rect",{width:"24",height:"24",fill:"white"})}))})]})),t.jsx(XP,h({variant:"body1",sx:{ml:i?1:0,fontWeight:"600",fontFamily:"Plus Jakarta Sans",color:"#5928ed"}},{children:"AI Suggestions"}))]})),t.jsx("div",h({style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"}},{children:t.jsxs("div",h({style:{width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:"0.5rem",paddingTop:"1rem",paddingBottom:"1rem"}},{children:[t.jsx("div",h({style:{fontWeight:"700",color:"#6b7280"}},{children:"No suggestions found"})),t.jsxs("div",h({style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",gap:"0.25rem",fontSize:"1rem",flexFlow:"wrap"}},{children:[t.jsx("div",h({style:{}},{children:"Tell us about your learning in "})),t.jsx("span",h({style:{color:"#5928ED",fontWeight:"700"}},{children:"InstantLearning.AI"}))," ",t.jsx("span",{children:"Chat"})]}))]}))}))]}))]})),(null==Q?void 0:Q.length)>0&&t.jsxs(DB,h({sx:{flex:1,height:"100%"}},{children:[t.jsxs(XP,h({sx:{fontSize:"1rem",fontWeight:600,marginBottom:"8px",fontFamily:"Plus Jakarta Sans",display:"flex",alignItems:"center"},gutterBottom:!0},{children:["When Not To Apply",t.jsx(vJ,h({title:"Cases where this learning should not be applied to avoid incorrect responses.",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx(U8,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),t.jsxs(DB,h({sx:{border:"1px solid #ccc",borderRadius:"8px",padding:2,height:"calc(100% - 64px)",boxShadow:B?"0 0 12px 3px rgba(34, 197, 94, 0.6)":"none",transition:"box-shadow 0.3s ease-in-out"}},{children:[t.jsxs(DB,h({display:"flex",alignItems:"center",justifyContent:"space-between",sx:{mb:"8px"}},{children:[t.jsxs(DB,h({display:"flex",gap:"0.25rem",alignItems:"center"},{children:[i&&t.jsx(DB,{component:"img",src:i,alt:"Chat",sx:{width:14,height:14}}),t.jsxs("svg",h({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[t.jsx("g",h({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:t.jsx("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),t.jsx("defs",{children:t.jsx("clipPath",h({id:"clip0_6004_60631"},{children:t.jsx("rect",{width:"24",height:"24",fill:"white"})}))})]})),t.jsx(XP,h({variant:"body1",sx:{ml:i?1:0,fontWeight:"600",fontFamily:"Plus Jakarta Sans",color:"#5928ed"}},{children:"AI Suggestions"}))]})),(null==Q?void 0:Q.length)>0&&t.jsx(vJ,h({placement:"top",arrow:!0,title:ae?"Save & Lock":"Edit",componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx(OP,h({disabled:Q.some((function(e){return""===(null==e?void 0:e.trim())})),onClick:function(){return re((function(e){return!e}))},size:"small",sx:{color:"gray","&:hover":{color:"black"}}},{children:ae?t.jsx(b7,{fontSize:"small"}):t.jsx(L7,{fontSize:"small"})}))}))]})),t.jsx(DB,h({sx:{height:"calc(100% - 38px)",overflow:"auto"}},{children:t.jsx("ol",h({style:{paddingLeft:"0rem",margin:0}},{children:B?t.jsxs(DB,h({sx:{display:"flex",justifyContent:"center",py:2,gap:2}},{children:[t.jsx(yW,{size:24}),t.jsx("span",{children:"Generating When not to apply..."})]})):t.jsx(DB,h({sx:{pt:"16px"}},{children:Q.map((function(e,t){return{value:e,index:t}})).map((function(e,n){var a=e.value,r=e.index;return t.jsxs(DB,h({sx:{display:"flex",alignItems:"flex-start",gap:1,mb:r<Q.length-1?2:0},component:"li"},{children:[t.jsx(T2,{variant:"outlined",disabled:!ae,fullWidth:!0,multiline:!0,value:"".concat(a),error:!a.trim(),onChange:function(e){var t=p([],Q,!0);t[r]=e.target.value,J(t)},sx:{backgroundColor:"#f9fafb",borderRadius:1,"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputBase-input.Mui-disabled":{color:"#000",WebkitTextFillColor:"#000"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root.Mui-disabled":{color:"rgba(0, 0, 0, 0.6)"}},InputProps:{startAdornment:t.jsxs(mG,h({position:"start",sx:{color:"#000",alignSelf:"flex-start",paddingTop:"12px"}},{children:[r+1,"."]}))}}),ae&&t.jsx(OP,h({onClick:function(){if(Q.length>1){var e=Q.filter((function(e,t){return t!==r}));J(e),R((function(t){return h(h({},t),{whenNotToApply:e.join(" OR ")})}))}},disabled:1===Q.length,sx:{mt:1}},{children:t.jsx(g7,{})}))]}),r)}))}))}))}))]}))]}))]})),se&&t.jsx(T7,{similarLearnings:null===(a=null==ue?void 0:ue.response)||void 0===a?void 0:a.similar_learnings,formData:A}),Ee&&ge&&t.jsx(N7,{conflictingConditions:ge}),!Ee&&Ve&&t.jsx(_7,{conflictingConditions:[xe,we]})]})),t.jsxs(DB,h({sx:{display:"flex",gap:2}},{children:[t.jsxs(DB,h({sx:{flex:1}},{children:[t.jsx(XP,h({sx:{fontSize:"1rem",fontWeight:600,fontFamily:"Plus Jakarta Sans"},gutterBottom:!0},{children:"Scope"})),t.jsx(W$,h({sx:{width:"50%",fontFamily:"Plus Jakarta Sans"},variant:"outlined"},{children:t.jsxs(XX,h({id:"scope",value:A.scope,onChange:(Ie="scope",function(e){R((function(t){var n;return h(h({},t),((n={})[Ie]=e.target.value,n))}))}),displayEmpty:!0,sx:{fontFamily:"Plus Jakarta Sans"},fullWidth:!0},{children:[t.jsx(eK,h({value:"",disabled:!0},{children:"Select scope"})),o.map((function(e,n){return t.jsx(eK,h({value:e.value,sx:{fontFamily:"Plus Jakarta Sans"}},{children:e.labelText}),n)}))]}))}))]})),t.jsx(DB,h({sx:{flex:1,display:"flex",alignItems:"flex-end",justifyContent:"flex-end"}},{children:t.jsxs(cU,h({variant:"contained",onClick:function(){return u(void 0,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return T(!0),[4,Be()];case 1:return e.sent()?[4,je()]:[3,3];case 2:e.sent(),e.label=3;case 3:return[2]}}))}))},sx:{width:"30%",height:"56px",fontFamily:"Plus Jakarta Sans",backgroundColor:"green",textTransform:"capitalize","&:hover":{backgroundColor:"#006400"},pointerEvents:ce?"none":"auto"},disabled:!Oe},{children:[ce&&t.jsx(yW,{sx:{marginRight:"8px",color:"#fff"},size:16}),ce?"Saving":"Save"]}))}))]}))]}))]}))},P7="PdfEditorCitation-module_citationRoot__5OtUI",F7="PdfEditorCitation-module_citationTitle__X9kQm",I7="PdfEditorCitation-module_citationBody__C99jX",j7="PdfEditorCitation-module_citationBodyWhenCollapsed__8vG0V";v(".PdfEditorCitation-module_citationRoot__5OtUI{display:flex;flex-direction:column}.PdfEditorCitation-module_citationTitle__X9kQm{align-items:center;background-color:#eff6ff;border:1px solid #000;border-radius:10px;cursor:pointer;display:inline-flex;gap:10px;padding:5px 8px;width:fit-content}.PdfEditorCitation-module_citationBody__C99jX{background-color:#fff;flex-grow:1}.PdfEditorCitation-module_citationBodyWhenCollapsed__8vG0V{display:none}.PdfEditorCitation-module_citationBodyWhenFullScreen__VKtop{bottom:0;height:100%!important;left:0;max-height:100%;position:absolute;right:0;top:0;width:100%!important}");var B7,U7={};var W7,$7=function(){if(B7)return U7;B7=1;var e=a_(),t=h7();Object.defineProperty(U7,"__esModule",{value:!0}),U7.default=void 0;var n=t(c.default),a=(0,e(v7()).default)(n.createElement("path",{d:"M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"}),"ExpandLess");return U7.default=a,U7}(),q7=Me($7),G7={};var Y7=function(){if(W7)return G7;W7=1;var e=a_(),t=h7();Object.defineProperty(G7,"__esModule",{value:!0}),G7.default=void 0;var n=t(c.default),a=(0,e(v7()).default)(n.createElement("path",{d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"}),"ExpandMore");return G7.default=a,G7}(),K7=Me(Y7),X7=function(){return X7=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},X7.apply(this,arguments)};function Q7(e,t,n,a){return new(n||(n=Promise))((function(r,o){function c(e){try{i(a.next(e))}catch(e){o(e)}}function l(e){try{i(a.throw(e))}catch(e){o(e)}}function i(e){e.done?r(e.value):function(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(c,l)}i((a=a.apply(e,t||[])).next())}))}function J7(e,t){var n,a,r,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return c.next=l(0),c.throw=l(1),c.return=l(2),"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function l(l){return function(i){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;c&&(c=0,l[0]&&(o=0)),o;)try{if(n=1,a&&(r=2&l[0]?a.return:l[0]?a.throw||((r=a.return)&&r.call(a),0):a.next)&&!(r=r.call(a,l[1])).done)return r;switch(a=0,r&&(l=[2&l[0],r.value]),l[0]){case 0:case 1:r=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,a=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]<r[3])){o.label=l[1];break}if(6===l[0]&&o.label<r[1]){o.label=r[1],r=l;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(l);break}r[2]&&o.ops.pop(),o.trys.pop();continue}l=t.call(e,o)}catch(e){l=[6,e],a=0}finally{n=r=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,i])}}}function Z7(e,t,n){if(n||2===arguments.length)for(var a,r=0,o=t.length;r<o;r++)!a&&r in t||(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var eee=void 0!==Ke?Ke:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function tee(){throw new Error("setTimeout has not been defined")}function nee(){throw new Error("clearTimeout has not been defined")}var aee=tee,ree=nee;function oee(e){if(aee===setTimeout)return setTimeout(e,0);if((aee===tee||!aee)&&setTimeout)return aee=setTimeout,setTimeout(e,0);try{return aee(e,0)}catch(t){try{return aee.call(null,e,0)}catch(t){return aee.call(this,e,0)}}}"function"==typeof eee.setTimeout&&(aee=setTimeout),"function"==typeof eee.clearTimeout&&(ree=clearTimeout);var cee,lee=[],iee=!1,see=-1;function hee(){iee&&cee&&(iee=!1,cee.length?lee=cee.concat(lee):see=-1,lee.length&&dee())}function dee(){if(!iee){var e=oee(hee);iee=!0;for(var t=lee.length;t;){for(cee=lee,lee=[];++see<t;)cee&&cee[see].run();see=-1,t=lee.length}cee=null,iee=!1,function(e){if(ree===clearTimeout)return clearTimeout(e);if((ree===nee||!ree)&&clearTimeout)return ree=clearTimeout,clearTimeout(e);try{return ree(e)}catch(t){try{return ree.call(null,e)}catch(t){return ree.call(this,e)}}}(e)}}function uee(e,t){this.fun=e,this.array=t}function mee(){}uee.prototype.run=function(){this.fun.apply(null,this.array)};var pee=mee,vee=mee,fee=mee,zee=mee,gee=mee,yee=mee,Mee=mee,Eee=eee.performance||{},bee=Eee.now||Eee.mozNow||Eee.msNow||Eee.oNow||Eee.webkitNow||function(){return(new Date).getTime()},Hee=new Date,Vee={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];lee.push(new uee(e,t)),1!==lee.length||iee||oee(dee)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:pee,addListener:vee,once:fee,off:zee,removeListener:gee,removeAllListeners:yee,emit:Mee,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*bee.call(Eee),n=Math.floor(t),a=Math.floor(t%1*1e9);return e&&(n-=e[0],(a-=e[1])<0&&(n--,a+=1e9)),[n,a]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-Hee)/1e3}};function Cee(e,t){return function(){return e.apply(t,arguments)}}const{toString:Lee}=Object.prototype,{getPrototypeOf:xee}=Object,See=(Aee=Object.create(null),e=>{const t=Lee.call(e);return Aee[t]||(Aee[t]=t.slice(8,-1).toLowerCase())}),kee=e=>(e=e.toLowerCase(),t=>See(t)===e),wee=e=>t=>typeof t===e,{isArray:Tee}=Array,Oee=wee("undefined");var Aee;const Ree=kee("ArrayBuffer"),Nee=wee("string"),_ee=wee("function"),Dee=wee("number"),Pee=e=>null!==e&&"object"==typeof e,Fee=e=>{if("object"!==See(e))return!1;const t=xee(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},Iee=kee("Date"),jee=kee("File"),Bee=kee("Blob"),Uee=kee("FileList"),Wee=kee("URLSearchParams"),[$ee,qee,Gee,Yee]=["ReadableStream","Request","Response","Headers"].map(kee);function Kee(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let a,r;if("object"!=typeof e&&(e=[e]),Tee(e))for(a=0,r=e.length;a<r;a++)t.call(null,e[a],a,e);else{const r=n?Object.getOwnPropertyNames(e):Object.keys(e),o=r.length;let c;for(a=0;a<o;a++)c=r[a],t.call(null,e[c],c,e)}}function Xee(e,t){t=t.toLowerCase();const n=Object.keys(e);let a,r=n.length;for(;r-- >0;)if(a=n[r],t===a.toLowerCase())return a;return null}const Qee="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:eee,Jee=e=>!Oee(e)&&e!==Qee,Zee=(ete="undefined"!=typeof Uint8Array&&xee(Uint8Array),e=>ete&&e instanceof ete);var ete;const tte=kee("HTMLFormElement"),nte=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),ate=kee("RegExp"),rte=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),a={};Kee(n,((n,r)=>{let o;!1!==(o=t(n,r,e))&&(a[r]=o||n)})),Object.defineProperties(e,a)},ote="abcdefghijklmnopqrstuvwxyz",cte="0123456789",lte={DIGIT:cte,ALPHA:ote,ALPHA_DIGIT:ote+ote.toUpperCase()+cte},ite=kee("AsyncFunction"),ste=(hte="function"==typeof setImmediate,dte=_ee(Qee.postMessage),hte?setImmediate:dte?(ute=`axios@${Math.random()}`,mte=[],Qee.addEventListener("message",(({source:e,data:t})=>{e===Qee&&t===ute&&mte.length&&mte.shift()()}),!1),e=>{mte.push(e),Qee.postMessage(ute,"*")}):e=>setTimeout(e));var hte,dte,ute,mte;const pte="undefined"!=typeof queueMicrotask?queueMicrotask.bind(Qee):Vee.nextTick||ste;var vte={isArray:Tee,isArrayBuffer:Ree,isBuffer:function(e){return null!==e&&!Oee(e)&&null!==e.constructor&&!Oee(e.constructor)&&_ee(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||_ee(e.append)&&("formdata"===(t=See(e))||"object"===t&&_ee(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Ree(e.buffer),t},isString:Nee,isNumber:Dee,isBoolean:e=>!0===e||!1===e,isObject:Pee,isPlainObject:Fee,isReadableStream:$ee,isRequest:qee,isResponse:Gee,isHeaders:Yee,isUndefined:Oee,isDate:Iee,isFile:jee,isBlob:Bee,isRegExp:ate,isFunction:_ee,isStream:e=>Pee(e)&&_ee(e.pipe),isURLSearchParams:Wee,isTypedArray:Zee,isFileList:Uee,forEach:Kee,merge:function e(){const{caseless:t}=Jee(this)&&this||{},n={},a=(a,r)=>{const o=t&&Xee(n,r)||r;Fee(n[o])&&Fee(a)?n[o]=e(n[o],a):Fee(a)?n[o]=e({},a):Tee(a)?n[o]=a.slice():n[o]=a};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&Kee(arguments[e],a);return n},extend:(e,t,n,{allOwnKeys:a}={})=>(Kee(t,((t,a)=>{n&&_ee(t)?e[a]=Cee(t,n):e[a]=t}),{allOwnKeys:a}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,a)=>{e.prototype=Object.create(t.prototype,a),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,a)=>{let r,o,c;const l={};if(t=t||{},null==e)return t;do{for(r=Object.getOwnPropertyNames(e),o=r.length;o-- >0;)c=r[o],a&&!a(c,e,t)||l[c]||(t[c]=e[c],l[c]=!0);e=!1!==n&&xee(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:See,kindOfTest:kee,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const a=e.indexOf(t,n);return-1!==a&&a===n},toArray:e=>{if(!e)return null;if(Tee(e))return e;let t=e.length;if(!Dee(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let a;for(;(a=n.next())&&!a.done;){const n=a.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const a=[];for(;null!==(n=e.exec(t));)a.push(n);return a},isHTMLForm:tte,hasOwnProperty:nte,hasOwnProp:nte,reduceDescriptors:rte,freezeMethods:e=>{rte(e,((t,n)=>{if(_ee(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const a=e[n];_ee(a)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))}))},toObjectSet:(e,t)=>{const n={},a=e=>{e.forEach((e=>{n[e]=!0}))};return Tee(e)?a(e):a(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n})),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:Xee,global:Qee,isContextDefined:Jee,ALPHABET:lte,generateString:(e=16,t=lte.ALPHA_DIGIT)=>{let n="";const{length:a}=t;for(;e--;)n+=t[Math.random()*a|0];return n},isSpecCompliantForm:function(e){return!!(e&&_ee(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),n=(e,a)=>{if(Pee(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[a]=e;const r=Tee(e)?[]:{};return Kee(e,((e,t)=>{const o=n(e,a+1);!Oee(o)&&(r[t]=o)})),t[a]=void 0,r}}return e};return n(e,0)},isAsyncFn:ite,isThenable:e=>e&&(Pee(e)||_ee(e))&&_ee(e.then)&&_ee(e.catch),setImmediate:ste,asap:pte},fte=[],zte=[],gte="undefined"!=typeof Uint8Array?Uint8Array:Array,yte=!1;function Mte(){yte=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)fte[t]=e[t],zte[e.charCodeAt(t)]=t;zte["-".charCodeAt(0)]=62,zte["_".charCodeAt(0)]=63}function Ete(e,t,n){for(var a,r,o=[],c=t;c<n;c+=3)a=(e[c]<<16)+(e[c+1]<<8)+e[c+2],o.push(fte[(r=a)>>18&63]+fte[r>>12&63]+fte[r>>6&63]+fte[63&r]);return o.join("")}function bte(e){var t;yte||Mte();for(var n=e.length,a=n%3,r="",o=[],c=16383,l=0,i=n-a;l<i;l+=c)o.push(Ete(e,l,l+c>i?i:l+c));return 1===a?(t=e[n-1],r+=fte[t>>2],r+=fte[t<<4&63],r+="=="):2===a&&(t=(e[n-2]<<8)+e[n-1],r+=fte[t>>10],r+=fte[t>>4&63],r+=fte[t<<2&63],r+="="),o.push(r),o.join("")}function Hte(e,t,n,a,r){var o,c,l=8*r-a-1,i=(1<<l)-1,s=i>>1,h=-7,d=n?r-1:0,u=n?-1:1,m=e[t+d];for(d+=u,o=m&(1<<-h)-1,m>>=-h,h+=l;h>0;o=256*o+e[t+d],d+=u,h-=8);for(c=o&(1<<-h)-1,o>>=-h,h+=a;h>0;c=256*c+e[t+d],d+=u,h-=8);if(0===o)o=1-s;else{if(o===i)return c?NaN:1/0*(m?-1:1);c+=Math.pow(2,a),o-=s}return(m?-1:1)*c*Math.pow(2,o-a)}function Vte(e,t,n,a,r,o){var c,l,i,s=8*o-r-1,h=(1<<s)-1,d=h>>1,u=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,m=a?0:o-1,p=a?1:-1,v=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(l=isNaN(t)?1:0,c=h):(c=Math.floor(Math.log(t)/Math.LN2),t*(i=Math.pow(2,-c))<1&&(c--,i*=2),(t+=c+d>=1?u/i:u*Math.pow(2,1-d))*i>=2&&(c++,i/=2),c+d>=h?(l=0,c=h):c+d>=1?(l=(t*i-1)*Math.pow(2,r),c+=d):(l=t*Math.pow(2,d-1)*Math.pow(2,r),c=0));r>=8;e[n+m]=255&l,m+=p,l/=256,r-=8);for(c=c<<r|l,s+=r;s>0;e[n+m]=255&c,m+=p,c/=256,s-=8);e[n+m-p]|=128*v}var Cte={}.toString,Lte=Array.isArray||function(e){return"[object Array]"==Cte.call(e)};function xte(){return kte.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Ste(e,t){if(xte()<t)throw new RangeError("Invalid typed array length");return kte.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=kte.prototype:(null===e&&(e=new kte(t)),e.length=t),e}function kte(e,t,n){if(!(kte.TYPED_ARRAY_SUPPORT||this instanceof kte))return new kte(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return Ote(this,e)}return wte(this,e,t,n)}function wte(e,t,n,a){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,a){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(a||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===a?new Uint8Array(t):void 0===a?new Uint8Array(t,n):new Uint8Array(t,n,a),kte.TYPED_ARRAY_SUPPORT?(e=t).__proto__=kte.prototype:e=Ate(e,t),e}(e,t,n,a):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!kte.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var a=0|_te(t,n),r=(e=Ste(e,a)).write(t,n);return r!==a&&(e=e.slice(0,r)),e}(e,t,n):function(e,t){if(Nte(t)){var n=0|Rte(t.length);return 0===(e=Ste(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(a=t.length)!=a?Ste(e,0):Ate(e,t);if("Buffer"===t.type&&Lte(t.data))return Ate(e,t.data)}var a;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function Tte(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function Ote(e,t){if(Tte(t),e=Ste(e,t<0?0:0|Rte(t)),!kte.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function Ate(e,t){var n=t.length<0?0:0|Rte(t.length);e=Ste(e,n);for(var a=0;a<n;a+=1)e[a]=255&t[a];return e}function Rte(e){if(e>=xte())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+xte().toString(16)+" bytes");return 0|e}function Nte(e){return!(null==e||!e._isBuffer)}function _te(e,t){if(Nte(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var a=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return sne(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return hne(e).length;default:if(a)return sne(e).length;t=(""+t).toLowerCase(),a=!0}}function Dte(e,t,n){var a=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Jte(this,t,n);case"utf8":case"utf-8":return Yte(this,t,n);case"ascii":return Xte(this,t,n);case"latin1":case"binary":return Qte(this,t,n);case"base64":return Gte(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Zte(this,t,n);default:if(a)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),a=!0}}function Pte(e,t,n){var a=e[t];e[t]=e[n],e[n]=a}function Fte(e,t,n,a,r){if(0===e.length)return-1;if("string"==typeof n?(a=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=r?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(r)return-1;n=e.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof t&&(t=kte.from(t,a)),Nte(t))return 0===t.length?-1:Ite(e,t,n,a,r);if("number"==typeof t)return t&=255,kte.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):Ite(e,[t],n,a,r);throw new TypeError("val must be string, number or Buffer")}function Ite(e,t,n,a,r){var o,c=1,l=e.length,i=t.length;if(void 0!==a&&("ucs2"===(a=String(a).toLowerCase())||"ucs-2"===a||"utf16le"===a||"utf-16le"===a)){if(e.length<2||t.length<2)return-1;c=2,l/=2,i/=2,n/=2}function s(e,t){return 1===c?e[t]:e.readUInt16BE(t*c)}if(r){var h=-1;for(o=n;o<l;o++)if(s(e,o)===s(t,-1===h?0:o-h)){if(-1===h&&(h=o),o-h+1===i)return h*c}else-1!==h&&(o-=o-h),h=-1}else for(n+i>l&&(n=l-i),o=n;o>=0;o--){for(var d=!0,u=0;u<i;u++)if(s(e,o+u)!==s(t,u)){d=!1;break}if(d)return o}return-1}function jte(e,t,n,a){n=Number(n)||0;var r=e.length-n;a?(a=Number(a))>r&&(a=r):a=r;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");a>o/2&&(a=o/2);for(var c=0;c<a;++c){var l=parseInt(t.substr(2*c,2),16);if(isNaN(l))return c;e[n+c]=l}return c}function Bte(e,t,n,a){return dne(sne(t,e.length-n),e,n,a)}function Ute(e,t,n,a){return dne(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,a)}function Wte(e,t,n,a){return Ute(e,t,n,a)}function $te(e,t,n,a){return dne(hne(t),e,n,a)}function qte(e,t,n,a){return dne(function(e,t){for(var n,a,r,o=[],c=0;c<e.length&&!((t-=2)<0);++c)a=(n=e.charCodeAt(c))>>8,r=n%256,o.push(r),o.push(a);return o}(t,e.length-n),e,n,a)}function Gte(e,t,n){return 0===t&&n===e.length?bte(e):bte(e.slice(t,n))}function Yte(e,t,n){n=Math.min(e.length,n);for(var a=[],r=t;r<n;){var o,c,l,i,s=e[r],h=null,d=s>239?4:s>223?3:s>191?2:1;if(r+d<=n)switch(d){case 1:s<128&&(h=s);break;case 2:128==(192&(o=e[r+1]))&&(i=(31&s)<<6|63&o)>127&&(h=i);break;case 3:o=e[r+1],c=e[r+2],128==(192&o)&&128==(192&c)&&(i=(15&s)<<12|(63&o)<<6|63&c)>2047&&(i<55296||i>57343)&&(h=i);break;case 4:o=e[r+1],c=e[r+2],l=e[r+3],128==(192&o)&&128==(192&c)&&128==(192&l)&&(i=(15&s)<<18|(63&o)<<12|(63&c)<<6|63&l)>65535&&i<1114112&&(h=i)}null===h?(h=65533,d=1):h>65535&&(h-=65536,a.push(h>>>10&1023|55296),h=56320|1023&h),a.push(h),r+=d}return function(e){var t=e.length;if(t<=Kte)return String.fromCharCode.apply(String,e);for(var n="",a=0;a<t;)n+=String.fromCharCode.apply(String,e.slice(a,a+=Kte));return n}(a)}kte.TYPED_ARRAY_SUPPORT=void 0===eee.TYPED_ARRAY_SUPPORT||eee.TYPED_ARRAY_SUPPORT,xte(),kte.poolSize=8192,kte._augment=function(e){return e.__proto__=kte.prototype,e},kte.from=function(e,t,n){return wte(null,e,t,n)},kte.TYPED_ARRAY_SUPPORT&&(kte.prototype.__proto__=Uint8Array.prototype,kte.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&kte[Symbol.species]),kte.alloc=function(e,t,n){return function(e,t,n,a){return Tte(t),t<=0?Ste(e,t):void 0!==n?"string"==typeof a?Ste(e,t).fill(n,a):Ste(e,t).fill(n):Ste(e,t)}(null,e,t,n)},kte.allocUnsafe=function(e){return Ote(null,e)},kte.allocUnsafeSlow=function(e){return Ote(null,e)},kte.isBuffer=function(e){return null!=e&&(!!e._isBuffer||une(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&une(e.slice(0,0))}(e))},kte.compare=function(e,t){if(!Nte(e)||!Nte(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,a=t.length,r=0,o=Math.min(n,a);r<o;++r)if(e[r]!==t[r]){n=e[r],a=t[r];break}return n<a?-1:a<n?1:0},kte.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},kte.concat=function(e,t){if(!Lte(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return kte.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var a=kte.allocUnsafe(t),r=0;for(n=0;n<e.length;++n){var o=e[n];if(!Nte(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(a,r),r+=o.length}return a},kte.byteLength=_te,kte.prototype._isBuffer=!0,kte.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)Pte(this,t,t+1);return this},kte.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)Pte(this,t,t+3),Pte(this,t+1,t+2);return this},kte.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)Pte(this,t,t+7),Pte(this,t+1,t+6),Pte(this,t+2,t+5),Pte(this,t+3,t+4);return this},kte.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?Yte(this,0,e):Dte.apply(this,arguments)},kte.prototype.equals=function(e){if(!Nte(e))throw new TypeError("Argument must be a Buffer");return this===e||0===kte.compare(this,e)},kte.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},kte.prototype.compare=function(e,t,n,a,r){if(!Nte(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===a&&(a=0),void 0===r&&(r=this.length),t<0||n>e.length||a<0||r>this.length)throw new RangeError("out of range index");if(a>=r&&t>=n)return 0;if(a>=r)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(r>>>=0)-(a>>>=0),c=(n>>>=0)-(t>>>=0),l=Math.min(o,c),i=this.slice(a,r),s=e.slice(t,n),h=0;h<l;++h)if(i[h]!==s[h]){o=i[h],c=s[h];break}return o<c?-1:c<o?1:0},kte.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},kte.prototype.indexOf=function(e,t,n){return Fte(this,e,t,n,!0)},kte.prototype.lastIndexOf=function(e,t,n){return Fte(this,e,t,n,!1)},kte.prototype.write=function(e,t,n,a){if(void 0===t)a="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)a=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===a&&(a="utf8")):(a=n,n=void 0)}var r=this.length-t;if((void 0===n||n>r)&&(n=r),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");a||(a="utf8");for(var o=!1;;)switch(a){case"hex":return jte(this,e,t,n);case"utf8":case"utf-8":return Bte(this,e,t,n);case"ascii":return Ute(this,e,t,n);case"latin1":case"binary":return Wte(this,e,t,n);case"base64":return $te(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return qte(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+a);a=(""+a).toLowerCase(),o=!0}},kte.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Kte=4096;function Xte(e,t,n){var a="";n=Math.min(e.length,n);for(var r=t;r<n;++r)a+=String.fromCharCode(127&e[r]);return a}function Qte(e,t,n){var a="";n=Math.min(e.length,n);for(var r=t;r<n;++r)a+=String.fromCharCode(e[r]);return a}function Jte(e,t,n){var a=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>a)&&(n=a);for(var r="",o=t;o<n;++o)r+=ine(e[o]);return r}function Zte(e,t,n){for(var a=e.slice(t,n),r="",o=0;o<a.length;o+=2)r+=String.fromCharCode(a[o]+256*a[o+1]);return r}function ene(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function tne(e,t,n,a,r,o){if(!Nte(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>r||t<o)throw new RangeError('"value" argument is out of bounds');if(n+a>e.length)throw new RangeError("Index out of range")}function nne(e,t,n,a){t<0&&(t=65535+t+1);for(var r=0,o=Math.min(e.length-n,2);r<o;++r)e[n+r]=(t&255<<8*(a?r:1-r))>>>8*(a?r:1-r)}function ane(e,t,n,a){t<0&&(t=4294967295+t+1);for(var r=0,o=Math.min(e.length-n,4);r<o;++r)e[n+r]=t>>>8*(a?r:3-r)&255}function rne(e,t,n,a,r,o){if(n+a>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function one(e,t,n,a,r){return r||rne(e,0,n,4),Vte(e,t,n,a,23,4),n+4}function cne(e,t,n,a,r){return r||rne(e,0,n,8),Vte(e,t,n,a,52,8),n+8}kte.prototype.slice=function(e,t){var n,a=this.length;if((e=~~e)<0?(e+=a)<0&&(e=0):e>a&&(e=a),(t=void 0===t?a:~~t)<0?(t+=a)<0&&(t=0):t>a&&(t=a),t<e&&(t=e),kte.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=kte.prototype;else{var r=t-e;n=new kte(r,void 0);for(var o=0;o<r;++o)n[o]=this[o+e]}return n},kte.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||ene(e,t,this.length);for(var a=this[e],r=1,o=0;++o<t&&(r*=256);)a+=this[e+o]*r;return a},kte.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||ene(e,t,this.length);for(var a=this[e+--t],r=1;t>0&&(r*=256);)a+=this[e+--t]*r;return a},kte.prototype.readUInt8=function(e,t){return t||ene(e,1,this.length),this[e]},kte.prototype.readUInt16LE=function(e,t){return t||ene(e,2,this.length),this[e]|this[e+1]<<8},kte.prototype.readUInt16BE=function(e,t){return t||ene(e,2,this.length),this[e]<<8|this[e+1]},kte.prototype.readUInt32LE=function(e,t){return t||ene(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},kte.prototype.readUInt32BE=function(e,t){return t||ene(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},kte.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||ene(e,t,this.length);for(var a=this[e],r=1,o=0;++o<t&&(r*=256);)a+=this[e+o]*r;return a>=(r*=128)&&(a-=Math.pow(2,8*t)),a},kte.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||ene(e,t,this.length);for(var a=t,r=1,o=this[e+--a];a>0&&(r*=256);)o+=this[e+--a]*r;return o>=(r*=128)&&(o-=Math.pow(2,8*t)),o},kte.prototype.readInt8=function(e,t){return t||ene(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},kte.prototype.readInt16LE=function(e,t){t||ene(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},kte.prototype.readInt16BE=function(e,t){t||ene(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},kte.prototype.readInt32LE=function(e,t){return t||ene(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},kte.prototype.readInt32BE=function(e,t){return t||ene(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},kte.prototype.readFloatLE=function(e,t){return t||ene(e,4,this.length),Hte(this,e,!0,23,4)},kte.prototype.readFloatBE=function(e,t){return t||ene(e,4,this.length),Hte(this,e,!1,23,4)},kte.prototype.readDoubleLE=function(e,t){return t||ene(e,8,this.length),Hte(this,e,!0,52,8)},kte.prototype.readDoubleBE=function(e,t){return t||ene(e,8,this.length),Hte(this,e,!1,52,8)},kte.prototype.writeUIntLE=function(e,t,n,a){e=+e,t|=0,n|=0,a||tne(this,e,t,n,Math.pow(2,8*n)-1,0);var r=1,o=0;for(this[t]=255&e;++o<n&&(r*=256);)this[t+o]=e/r&255;return t+n},kte.prototype.writeUIntBE=function(e,t,n,a){e=+e,t|=0,n|=0,a||tne(this,e,t,n,Math.pow(2,8*n)-1,0);var r=n-1,o=1;for(this[t+r]=255&e;--r>=0&&(o*=256);)this[t+r]=e/o&255;return t+n},kte.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||tne(this,e,t,1,255,0),kte.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},kte.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||tne(this,e,t,2,65535,0),kte.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):nne(this,e,t,!0),t+2},kte.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||tne(this,e,t,2,65535,0),kte.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):nne(this,e,t,!1),t+2},kte.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||tne(this,e,t,4,4294967295,0),kte.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ane(this,e,t,!0),t+4},kte.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||tne(this,e,t,4,4294967295,0),kte.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ane(this,e,t,!1),t+4},kte.prototype.writeIntLE=function(e,t,n,a){if(e=+e,t|=0,!a){var r=Math.pow(2,8*n-1);tne(this,e,t,n,r-1,-r)}var o=0,c=1,l=0;for(this[t]=255&e;++o<n&&(c*=256);)e<0&&0===l&&0!==this[t+o-1]&&(l=1),this[t+o]=(e/c|0)-l&255;return t+n},kte.prototype.writeIntBE=function(e,t,n,a){if(e=+e,t|=0,!a){var r=Math.pow(2,8*n-1);tne(this,e,t,n,r-1,-r)}var o=n-1,c=1,l=0;for(this[t+o]=255&e;--o>=0&&(c*=256);)e<0&&0===l&&0!==this[t+o+1]&&(l=1),this[t+o]=(e/c|0)-l&255;return t+n},kte.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||tne(this,e,t,1,127,-128),kte.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},kte.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||tne(this,e,t,2,32767,-32768),kte.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):nne(this,e,t,!0),t+2},kte.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||tne(this,e,t,2,32767,-32768),kte.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):nne(this,e,t,!1),t+2},kte.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||tne(this,e,t,4,2147483647,-2147483648),kte.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ane(this,e,t,!0),t+4},kte.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||tne(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),kte.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ane(this,e,t,!1),t+4},kte.prototype.writeFloatLE=function(e,t,n){return one(this,e,t,!0,n)},kte.prototype.writeFloatBE=function(e,t,n){return one(this,e,t,!1,n)},kte.prototype.writeDoubleLE=function(e,t,n){return cne(this,e,t,!0,n)},kte.prototype.writeDoubleBE=function(e,t,n){return cne(this,e,t,!1,n)},kte.prototype.copy=function(e,t,n,a){if(n||(n=0),a||0===a||(a=this.length),t>=e.length&&(t=e.length),t||(t=0),a>0&&a<n&&(a=n),a===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(a<0)throw new RangeError("sourceEnd out of bounds");a>this.length&&(a=this.length),e.length-t<a-n&&(a=e.length-t+n);var r,o=a-n;if(this===e&&n<t&&t<a)for(r=o-1;r>=0;--r)e[r+t]=this[r+n];else if(o<1e3||!kte.TYPED_ARRAY_SUPPORT)for(r=0;r<o;++r)e[r+t]=this[r+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},kte.prototype.fill=function(e,t,n,a){if("string"==typeof e){if("string"==typeof t?(a=t,t=0,n=this.length):"string"==typeof n&&(a=n,n=this.length),1===e.length){var r=e.charCodeAt(0);r<256&&(e=r)}if(void 0!==a&&"string"!=typeof a)throw new TypeError("encoding must be a string");if("string"==typeof a&&!kte.isEncoding(a))throw new TypeError("Unknown encoding: "+a)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var c=Nte(e)?e:sne(new kte(e,a).toString()),l=c.length;for(o=0;o<n-t;++o)this[o+t]=c[o%l]}return this};var lne=/[^+\/0-9A-Za-z-_]/g;function ine(e){return e<16?"0"+e.toString(16):e.toString(16)}function sne(e,t){var n;t=t||1/0;for(var a=e.length,r=null,o=[],c=0;c<a;++c){if((n=e.charCodeAt(c))>55295&&n<57344){if(!r){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(c+1===a){(t-=3)>-1&&o.push(239,191,189);continue}r=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),r=n;continue}n=65536+(r-55296<<10|n-56320)}else r&&(t-=3)>-1&&o.push(239,191,189);if(r=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function hne(e){return function(e){var t,n,a,r,o,c;yte||Mte();var l=e.length;if(l%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[l-2]?2:"="===e[l-1]?1:0,c=new gte(3*l/4-o),a=o>0?l-4:l;var i=0;for(t=0,n=0;t<a;t+=4,n+=3)r=zte[e.charCodeAt(t)]<<18|zte[e.charCodeAt(t+1)]<<12|zte[e.charCodeAt(t+2)]<<6|zte[e.charCodeAt(t+3)],c[i++]=r>>16&255,c[i++]=r>>8&255,c[i++]=255&r;return 2===o?(r=zte[e.charCodeAt(t)]<<2|zte[e.charCodeAt(t+1)]>>4,c[i++]=255&r):1===o&&(r=zte[e.charCodeAt(t)]<<10|zte[e.charCodeAt(t+1)]<<4|zte[e.charCodeAt(t+2)]>>2,c[i++]=r>>8&255,c[i++]=255&r),c}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(lne,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function dne(e,t,n,a){for(var r=0;r<a&&!(r+n>=t.length||r>=e.length);++r)t[r+n]=e[r];return r}function une(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function mne(e,t,n,a,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),a&&(this.request=a),r&&(this.response=r,this.status=r.status?r.status:null)}vte.inherits(mne,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:vte.toJSONObject(this.config),code:this.code,status:this.status}}});const pne=mne.prototype,vne={};function fne(e){return vte.isPlainObject(e)||vte.isArray(e)}function zne(e){return vte.endsWith(e,"[]")?e.slice(0,-2):e}function gne(e,t,n){return e?e.concat(t).map((function(e,t){return e=zne(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{vne[e]={value:e}})),Object.defineProperties(mne,vne),Object.defineProperty(pne,"isAxiosError",{value:!0}),mne.from=(e,t,n,a,r,o)=>{const c=Object.create(pne);return vte.toFlatObject(e,c,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),mne.call(c,e.message,t,n,a,r),c.cause=e,c.name=e.name,o&&Object.assign(c,o),c};const yne=vte.toFlatObject(vte,{},null,(function(e){return/^is[A-Z]/.test(e)}));function Mne(e,t,n){if(!vte.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const a=(n=vte.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!vte.isUndefined(t[e])}))).metaTokens,r=n.visitor||s,o=n.dots,c=n.indexes,l=(n.Blob||"undefined"!=typeof Blob&&Blob)&&vte.isSpecCompliantForm(t);if(!vte.isFunction(r))throw new TypeError("visitor must be a function");function i(e){if(null===e)return"";if(vte.isDate(e))return e.toISOString();if(!l&&vte.isBlob(e))throw new mne("Blob is not supported. Use a Buffer instead.");return vte.isArrayBuffer(e)||vte.isTypedArray(e)?l&&"function"==typeof Blob?new Blob([e]):kte.from(e):e}function s(e,n,r){let l=e;if(e&&!r&&"object"==typeof e)if(vte.endsWith(n,"{}"))n=a?n:n.slice(0,-2),e=JSON.stringify(e);else if(vte.isArray(e)&&function(e){return vte.isArray(e)&&!e.some(fne)}(e)||(vte.isFileList(e)||vte.endsWith(n,"[]"))&&(l=vte.toArray(e)))return n=zne(n),l.forEach((function(e,a){!vte.isUndefined(e)&&null!==e&&t.append(!0===c?gne([n],a,o):null===c?n:n+"[]",i(e))})),!1;return!!fne(e)||(t.append(gne(r,n,o),i(e)),!1)}const h=[],d=Object.assign(yne,{defaultVisitor:s,convertValue:i,isVisitable:fne});if(!vte.isObject(e))throw new TypeError("data must be an object");return function e(n,a){if(!vte.isUndefined(n)){if(-1!==h.indexOf(n))throw Error("Circular reference detected in "+a.join("."));h.push(n),vte.forEach(n,(function(n,o){!0===(!(vte.isUndefined(n)||null===n)&&r.call(t,n,vte.isString(o)?o.trim():o,a,d))&&e(n,a?a.concat(o):[o])})),h.pop()}}(e),t}function Ene(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function bne(e,t){this._pairs=[],e&&Mne(e,this,t)}const Hne=bne.prototype;function Vne(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Cne(e,t,n){if(!t)return e;const a=n&&n.encode||Vne;vte.isFunction(n)&&(n={serialize:n});const r=n&&n.serialize;let o;if(o=r?r(t,n):vte.isURLSearchParams(t)?t.toString():new bne(t,n).toString(a),o){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}Hne.append=function(e,t){this._pairs.push([e,t])},Hne.toString=function(e){const t=e?function(t){return e.call(this,t,Ene)}:Ene;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};class Lne{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){vte.forEach(this.handlers,(function(t){null!==t&&e(t)}))}}var xne={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Sne={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:bne,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const kne="undefined"!=typeof window&&"undefined"!=typeof document,wne="object"==typeof navigator&&navigator||void 0,Tne=kne&&(!wne||["ReactNative","NativeScript","NS"].indexOf(wne.product)<0),One="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Ane=kne&&window.location.href||"http://localhost";var Rne={...Object.freeze({__proto__:null,hasBrowserEnv:kne,hasStandardBrowserWebWorkerEnv:One,hasStandardBrowserEnv:Tne,navigator:wne,origin:Ane}),...Sne};function Nne(e){function t(e,n,a,r){let o=e[r++];if("__proto__"===o)return!0;const c=Number.isFinite(+o),l=r>=e.length;return o=!o&&vte.isArray(a)?a.length:o,l?(vte.hasOwnProp(a,o)?a[o]=[a[o],n]:a[o]=n,!c):(a[o]&&vte.isObject(a[o])||(a[o]=[]),t(e,n,a[o],r)&&vte.isArray(a[o])&&(a[o]=function(e){const t={},n=Object.keys(e);let a;const r=n.length;let o;for(a=0;a<r;a++)o=n[a],t[o]=e[o];return t}(a[o])),!c)}if(vte.isFormData(e)&&vte.isFunction(e.entries)){const n={};return vte.forEachEntry(e,((e,a)=>{t(function(e){return vte.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),a,n,0)})),n}return null}const _ne={transitional:xne,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",a=n.indexOf("application/json")>-1,r=vte.isObject(e);if(r&&vte.isHTMLForm(e)&&(e=new FormData(e)),vte.isFormData(e))return a?JSON.stringify(Nne(e)):e;if(vte.isArrayBuffer(e)||vte.isBuffer(e)||vte.isStream(e)||vte.isFile(e)||vte.isBlob(e)||vte.isReadableStream(e))return e;if(vte.isArrayBufferView(e))return e.buffer;if(vte.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(r){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Mne(e,new Rne.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,a){return Rne.isNode&&vte.isBuffer(e)?(this.append(t,e.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((o=vte.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return Mne(o?{"files[]":e}:e,t&&new t,this.formSerializer)}}return r||a?(t.setContentType("application/json",!1),function(e){if(vte.isString(e))try{return(0,JSON.parse)(e),vte.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||_ne.transitional,n=t&&t.forcedJSONParsing,a="json"===this.responseType;if(vte.isResponse(e)||vte.isReadableStream(e))return e;if(e&&vte.isString(e)&&(n&&!this.responseType||a)){const n=!(t&&t.silentJSONParsing)&&a;try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw mne.from(e,mne.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Rne.classes.FormData,Blob:Rne.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};vte.forEach(["delete","get","head","post","put","patch"],(e=>{_ne.headers[e]={}}));const Dne=vte.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Pne=Symbol("internals");function Fne(e){return e&&String(e).trim().toLowerCase()}function Ine(e){return!1===e||null==e?e:vte.isArray(e)?e.map(Ine):String(e)}function jne(e,t,n,a,r){return vte.isFunction(a)?a.call(this,t,n):(r&&(t=n),vte.isString(t)?vte.isString(a)?-1!==t.indexOf(a):vte.isRegExp(a)?a.test(t):void 0:void 0)}class Bne{constructor(e){e&&this.set(e)}set(e,t,n){const a=this;function r(e,t,n){const r=Fne(t);if(!r)throw new Error("header name must be a non-empty string");const o=vte.findKey(a,r);(!o||void 0===a[o]||!0===n||void 0===n&&!1!==a[o])&&(a[o||t]=Ine(e))}const o=(e,t)=>vte.forEach(e,((e,n)=>r(e,n,t)));if(vte.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(vte.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))o((e=>{const t={};let n,a,r;return e&&e.split("\n").forEach((function(e){r=e.indexOf(":"),n=e.substring(0,r).trim().toLowerCase(),a=e.substring(r+1).trim(),!n||t[n]&&Dne[n]||("set-cookie"===n?t[n]?t[n].push(a):t[n]=[a]:t[n]=t[n]?t[n]+", "+a:a)})),t})(e),t);else if(vte.isHeaders(e))for(const[t,a]of e.entries())r(a,t,n);else null!=e&&r(t,e,n);return this}get(e,t){if(e=Fne(e)){const n=vte.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let a;for(;a=n.exec(e);)t[a[1]]=a[2];return t}(e);if(vte.isFunction(t))return t.call(this,e,n);if(vte.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Fne(e)){const n=vte.findKey(this,e);return!(!n||void 0===this[n]||t&&!jne(0,this[n],n,t))}return!1}delete(e,t){const n=this;let a=!1;function r(e){if(e=Fne(e)){const r=vte.findKey(n,e);!r||t&&!jne(0,n[r],r,t)||(delete n[r],a=!0)}}return vte.isArray(e)?e.forEach(r):r(e),a}clear(e){const t=Object.keys(this);let n=t.length,a=!1;for(;n--;){const r=t[n];e&&!jne(0,this[r],r,e,!0)||(delete this[r],a=!0)}return a}normalize(e){const t=this,n={};return vte.forEach(this,((a,r)=>{const o=vte.findKey(n,r);if(o)return t[o]=Ine(a),void delete t[r];const c=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,n)=>t.toUpperCase()+n))}(r):String(r).trim();c!==r&&delete t[r],t[c]=Ine(a),n[c]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return vte.forEach(this,((n,a)=>{null!=n&&!1!==n&&(t[a]=e&&vte.isArray(n)?n.join(", "):n)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach((e=>n.set(e))),n}static accessor(e){const t=(this[Pne]=this[Pne]={accessors:{}}).accessors,n=this.prototype;function a(e){const a=Fne(e);t[a]||(function(e,t){const n=vte.toCamelCase(" "+t);["get","set","has"].forEach((a=>{Object.defineProperty(e,a+n,{value:function(e,n,r){return this[a].call(this,t,e,n,r)},configurable:!0})}))}(n,e),t[a]=!0)}return vte.isArray(e)?e.forEach(a):a(e),this}}function Une(e,t){const n=this||_ne,a=t||n,r=Bne.from(a.headers);let o=a.data;return vte.forEach(e,(function(e){o=e.call(n,o,r.normalize(),t?t.status:void 0)})),r.normalize(),o}function Wne(e){return!(!e||!e.__CANCEL__)}function $ne(e,t,n){mne.call(this,null==e?"canceled":e,mne.ERR_CANCELED,t,n),this.name="CanceledError"}function qne(e,t,n){const a=n.config.validateStatus;n.status&&a&&!a(n.status)?t(new mne("Request failed with status code "+n.status,[mne.ERR_BAD_REQUEST,mne.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}Bne.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),vte.reduceDescriptors(Bne.prototype,(({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}})),vte.freezeMethods(Bne),vte.inherits($ne,mne,{__CANCEL__:!0});const Gne=(e,t,n=3)=>{let a=0;const r=function(e,t){e=e||10;const n=new Array(e),a=new Array(e);let r,o=0,c=0;return t=void 0!==t?t:1e3,function(l){const i=Date.now(),s=a[c];r||(r=i),n[o]=l,a[o]=i;let h=c,d=0;for(;h!==o;)d+=n[h++],h%=e;if(o=(o+1)%e,o===c&&(c=(c+1)%e),i-r<t)return;const u=s&&i-s;return u?Math.round(1e3*d/u):void 0}}(50,250);return function(e,t){let n,a,r=0,o=1e3/t;const c=(t,o=Date.now())=>{r=o,n=null,a&&(clearTimeout(a),a=null),e.apply(null,t)};return[(...e)=>{const t=Date.now(),l=t-r;l>=o?c(e,t):(n=e,a||(a=setTimeout((()=>{a=null,c(n)}),o-l)))},()=>n&&c(n)]}((n=>{const o=n.loaded,c=n.lengthComputable?n.total:void 0,l=o-a,i=r(l);a=o,e({loaded:o,total:c,progress:c?o/c:void 0,bytes:l,rate:i||void 0,estimated:i&&c&&o<=c?(c-o)/i:void 0,event:n,lengthComputable:null!=c,[t?"download":"upload"]:!0})}),n)},Yne=(e,t)=>{const n=null!=e;return[a=>t[0]({lengthComputable:n,total:e,loaded:a}),t[1]]},Kne=e=>(...t)=>vte.asap((()=>e(...t)));var Xne=Rne.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Rne.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Rne.origin),Rne.navigator&&/(msie|trident)/i.test(Rne.navigator.userAgent)):()=>!0,Qne=Rne.hasStandardBrowserEnv?{write(e,t,n,a,r,o){const c=[e+"="+encodeURIComponent(t)];vte.isNumber(n)&&c.push("expires="+new Date(n).toGMTString()),vte.isString(a)&&c.push("path="+a),vte.isString(r)&&c.push("domain="+r),!0===o&&c.push("secure"),document.cookie=c.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Jne(e,t){return e&&!function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}(t)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const Zne=e=>e instanceof Bne?{...e}:e;function eae(e,t){t=t||{};const n={};function a(e,t,n,a){return vte.isPlainObject(e)&&vte.isPlainObject(t)?vte.merge.call({caseless:a},e,t):vte.isPlainObject(t)?vte.merge({},t):vte.isArray(t)?t.slice():t}function r(e,t,n,r){return vte.isUndefined(t)?vte.isUndefined(e)?void 0:a(void 0,e,0,r):a(e,t,0,r)}function o(e,t){if(!vte.isUndefined(t))return a(void 0,t)}function c(e,t){return vte.isUndefined(t)?vte.isUndefined(e)?void 0:a(void 0,e):a(void 0,t)}function l(n,r,o){return o in t?a(n,r):o in e?a(void 0,n):void 0}const i={url:o,method:o,data:o,baseURL:c,transformRequest:c,transformResponse:c,paramsSerializer:c,timeout:c,timeoutMessage:c,withCredentials:c,withXSRFToken:c,adapter:c,responseType:c,xsrfCookieName:c,xsrfHeaderName:c,onUploadProgress:c,onDownloadProgress:c,decompress:c,maxContentLength:c,maxBodyLength:c,beforeRedirect:c,transport:c,httpAgent:c,httpsAgent:c,cancelToken:c,socketPath:c,responseEncoding:c,validateStatus:l,headers:(e,t,n)=>r(Zne(e),Zne(t),0,!0)};return vte.forEach(Object.keys(Object.assign({},e,t)),(function(a){const o=i[a]||r,c=o(e[a],t[a],a);vte.isUndefined(c)&&o!==l||(n[a]=c)})),n}var tae=e=>{const t=eae({},e);let n,{data:a,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:c,headers:l,auth:i}=t;if(t.headers=l=Bne.from(l),t.url=Cne(Jne(t.baseURL,t.url),e.params,e.paramsSerializer),i&&l.set("Authorization","Basic "+btoa((i.username||"")+":"+(i.password?unescape(encodeURIComponent(i.password)):""))),vte.isFormData(a))if(Rne.hasStandardBrowserEnv||Rne.hasStandardBrowserWebWorkerEnv)l.setContentType(void 0);else if(!1!==(n=l.getContentType())){const[e,...t]=n?n.split(";").map((e=>e.trim())).filter(Boolean):[];l.setContentType([e||"multipart/form-data",...t].join("; "))}if(Rne.hasStandardBrowserEnv&&(r&&vte.isFunction(r)&&(r=r(t)),r||!1!==r&&Xne(t.url))){const e=o&&c&&Qne.read(c);e&&l.set(o,e)}return t},nae="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,n){const a=tae(e);let r=a.data;const o=Bne.from(a.headers).normalize();let c,l,i,s,h,{responseType:d,onUploadProgress:u,onDownloadProgress:m}=a;function p(){s&&s(),h&&h(),a.cancelToken&&a.cancelToken.unsubscribe(c),a.signal&&a.signal.removeEventListener("abort",c)}let v=new XMLHttpRequest;function f(){if(!v)return;const a=Bne.from("getAllResponseHeaders"in v&&v.getAllResponseHeaders());qne((function(e){t(e),p()}),(function(e){n(e),p()}),{data:d&&"text"!==d&&"json"!==d?v.response:v.responseText,status:v.status,statusText:v.statusText,headers:a,config:e,request:v}),v=null}v.open(a.method.toUpperCase(),a.url,!0),v.timeout=a.timeout,"onloadend"in v?v.onloadend=f:v.onreadystatechange=function(){v&&4===v.readyState&&(0!==v.status||v.responseURL&&0===v.responseURL.indexOf("file:"))&&setTimeout(f)},v.onabort=function(){v&&(n(new mne("Request aborted",mne.ECONNABORTED,e,v)),v=null)},v.onerror=function(){n(new mne("Network Error",mne.ERR_NETWORK,e,v)),v=null},v.ontimeout=function(){let t=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded";const r=a.transitional||xne;a.timeoutErrorMessage&&(t=a.timeoutErrorMessage),n(new mne(t,r.clarifyTimeoutError?mne.ETIMEDOUT:mne.ECONNABORTED,e,v)),v=null},void 0===r&&o.setContentType(null),"setRequestHeader"in v&&vte.forEach(o.toJSON(),(function(e,t){v.setRequestHeader(t,e)})),vte.isUndefined(a.withCredentials)||(v.withCredentials=!!a.withCredentials),d&&"json"!==d&&(v.responseType=a.responseType),m&&([i,h]=Gne(m,!0),v.addEventListener("progress",i)),u&&v.upload&&([l,s]=Gne(u),v.upload.addEventListener("progress",l),v.upload.addEventListener("loadend",s)),(a.cancelToken||a.signal)&&(c=t=>{v&&(n(!t||t.type?new $ne(null,e,v):t),v.abort(),v=null)},a.cancelToken&&a.cancelToken.subscribe(c),a.signal&&(a.signal.aborted?c():a.signal.addEventListener("abort",c)));const z=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(a.url);z&&-1===Rne.protocols.indexOf(z)?n(new mne("Unsupported protocol "+z+":",mne.ERR_BAD_REQUEST,e)):v.send(r||null)}))};const aae=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,a=new AbortController;const r=function(e){if(!n){n=!0,c();const t=e instanceof Error?e:this.reason;a.abort(t instanceof mne?t:new $ne(t instanceof Error?t.message:t))}};let o=t&&setTimeout((()=>{o=null,r(new mne(`timeout ${t} of ms exceeded`,mne.ETIMEDOUT))}),t);const c=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach((e=>{e.unsubscribe?e.unsubscribe(r):e.removeEventListener("abort",r)})),e=null)};e.forEach((e=>e.addEventListener("abort",r)));const{signal:l}=a;return l.unsubscribe=()=>vte.asap(c),l}},rae=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let a,r=0;for(;r<n;)a=r+t,yield e.slice(r,a),r=a},oae=(e,t,n,a)=>{const r=async function*(e,t){for await(const n of async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}}(e))yield*rae(n,t)}(e,t);let o,c=0,l=e=>{o||(o=!0,a&&a(e))};return new ReadableStream({async pull(e){try{const{done:t,value:a}=await r.next();if(t)return l(),void e.close();let o=a.byteLength;if(n){let e=c+=o;n(e)}e.enqueue(new Uint8Array(a))}catch(e){throw l(e),e}},cancel:e=>(l(e),r.return())},{highWaterMark:2})},cae="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,lae=cae&&"function"==typeof ReadableStream,iae=cae&&("function"==typeof TextEncoder?(sae=new TextEncoder,e=>sae.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var sae;const hae=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},dae=lae&&hae((()=>{let e=!1;const t=new Request(Rne.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})),uae=lae&&hae((()=>vte.isReadableStream(new Response("").body))),mae={stream:uae&&(e=>e.body)};var pae;cae&&(pae=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((e=>{!mae[e]&&(mae[e]=vte.isFunction(pae[e])?t=>t[e]():(t,n)=>{throw new mne(`Response type '${e}' is not supported`,mne.ERR_NOT_SUPPORT,n)})})));var vae=cae&&(async e=>{let{url:t,method:n,data:a,signal:r,cancelToken:o,timeout:c,onDownloadProgress:l,onUploadProgress:i,responseType:s,headers:h,withCredentials:d="same-origin",fetchOptions:u}=tae(e);s=s?(s+"").toLowerCase():"text";let m,p=aae([r,o&&o.toAbortSignal()],c);const v=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let f;try{if(i&&dae&&"get"!==n&&"head"!==n&&0!==(f=await(async(e,t)=>{const n=vte.toFiniteNumber(e.getContentLength());return null==n?(async e=>{if(null==e)return 0;if(vte.isBlob(e))return e.size;if(vte.isSpecCompliantForm(e)){const t=new Request(Rne.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return vte.isArrayBufferView(e)||vte.isArrayBuffer(e)?e.byteLength:(vte.isURLSearchParams(e)&&(e+=""),vte.isString(e)?(await iae(e)).byteLength:void 0)})(t):n})(h,a))){let e,n=new Request(t,{method:"POST",body:a,duplex:"half"});if(vte.isFormData(a)&&(e=n.headers.get("content-type"))&&h.setContentType(e),n.body){const[e,t]=Yne(f,Gne(Kne(i)));a=oae(n.body,65536,e,t)}}vte.isString(d)||(d=d?"include":"omit");const r="credentials"in Request.prototype;m=new Request(t,{...u,signal:p,method:n.toUpperCase(),headers:h.normalize().toJSON(),body:a,duplex:"half",credentials:r?d:void 0});let o=await fetch(m);const c=uae&&("stream"===s||"response"===s);if(uae&&(l||c&&v)){const e={};["status","statusText","headers"].forEach((t=>{e[t]=o[t]}));const t=vte.toFiniteNumber(o.headers.get("content-length")),[n,a]=l&&Yne(t,Gne(Kne(l),!0))||[];o=new Response(oae(o.body,65536,n,(()=>{a&&a(),v&&v()})),e)}s=s||"text";let z=await mae[vte.findKey(mae,s)||"text"](o,e);return!c&&v&&v(),await new Promise(((t,n)=>{qne(t,n,{data:z,headers:Bne.from(o.headers),status:o.status,statusText:o.statusText,config:e,request:m})}))}catch(t){if(v&&v(),t&&"TypeError"===t.name&&/fetch/i.test(t.message))throw Object.assign(new mne("Network Error",mne.ERR_NETWORK,e,m),{cause:t.cause||t});throw mne.from(t,t&&t.code,e,m)}});const fae={http:null,xhr:nae,fetch:vae};vte.forEach(fae,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));const zae=e=>`- ${e}`,gae=e=>vte.isFunction(e)||null===e||!1===e;var yae=e=>{e=vte.isArray(e)?e:[e];const{length:t}=e;let n,a;const r={};for(let o=0;o<t;o++){let t;if(n=e[o],a=n,!gae(n)&&(a=fae[(t=String(n)).toLowerCase()],void 0===a))throw new mne(`Unknown adapter '${t}'`);if(a)break;r[t||"#"+o]=a}if(!a){const e=Object.entries(r).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));throw new mne("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(zae).join("\n"):" "+zae(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return a};function Mae(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new $ne(null,e)}function Eae(e){return Mae(e),e.headers=Bne.from(e.headers),e.data=Une.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),yae(e.adapter||_ne.adapter)(e).then((function(t){return Mae(e),t.data=Une.call(e,e.transformResponse,t),t.headers=Bne.from(t.headers),t}),(function(t){return Wne(t)||(Mae(e),t&&t.response&&(t.response.data=Une.call(e,e.transformResponse,t.response),t.response.headers=Bne.from(t.response.headers))),Promise.reject(t)}))}const bae={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{bae[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));const Hae={};bae.transitional=function(e,t,n){function a(e,t){return"[Axios v1.7.9] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,r,o)=>{if(!1===e)throw new mne(a(r," has been removed"+(t?" in "+t:"")),mne.ERR_DEPRECATED);return t&&!Hae[r]&&(Hae[r]=!0,console.warn(a(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,r,o)}},bae.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};var Vae={assertOptions:function(e,t,n){if("object"!=typeof e)throw new mne("options must be an object",mne.ERR_BAD_OPTION_VALUE);const a=Object.keys(e);let r=a.length;for(;r-- >0;){const o=a[r],c=t[o];if(c){const t=e[o],n=void 0===t||c(t,o,e);if(!0!==n)throw new mne("option "+o+" must be "+n,mne.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new mne("Unknown option "+o,mne.ERR_BAD_OPTION)}},validators:bae};const Cae=Vae.validators;class Lae{constructor(e){this.defaults=e,this.interceptors={request:new Lne,response:new Lne}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=eae(this.defaults,t);const{transitional:n,paramsSerializer:a,headers:r}=t;void 0!==n&&Vae.assertOptions(n,{silentJSONParsing:Cae.transitional(Cae.boolean),forcedJSONParsing:Cae.transitional(Cae.boolean),clarifyTimeoutError:Cae.transitional(Cae.boolean)},!1),null!=a&&(vte.isFunction(a)?t.paramsSerializer={serialize:a}:Vae.assertOptions(a,{encode:Cae.function,serialize:Cae.function},!0)),Vae.assertOptions(t,{baseUrl:Cae.spelling("baseURL"),withXsrfToken:Cae.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=r&&vte.merge(r.common,r[t.method]);r&&vte.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete r[e]})),t.headers=Bne.concat(o,r);const c=[];let l=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(l=l&&e.synchronous,c.unshift(e.fulfilled,e.rejected))}));const i=[];let s;this.interceptors.response.forEach((function(e){i.push(e.fulfilled,e.rejected)}));let h,d=0;if(!l){const e=[Eae.bind(this),void 0];for(e.unshift.apply(e,c),e.push.apply(e,i),h=e.length,s=Promise.resolve(t);d<h;)s=s.then(e[d++],e[d++]);return s}h=c.length;let u=t;for(d=0;d<h;){const t=c[d++],n=c[d++];try{u=t(u)}catch(e){n.call(this,e);break}}try{s=Eae.call(this,u)}catch(e){return Promise.reject(e)}for(d=0,h=i.length;d<h;)s=s.then(i[d++],i[d++]);return s}getUri(e){return Cne(Jne((e=eae(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}vte.forEach(["delete","get","head","options"],(function(e){Lae.prototype[e]=function(t,n){return this.request(eae(n||{},{method:e,url:t,data:(n||{}).data}))}})),vte.forEach(["post","put","patch"],(function(e){function t(t){return function(n,a,r){return this.request(eae(r||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:a}))}}Lae.prototype[e]=t(),Lae.prototype[e+"Form"]=t(!0)}));class xae{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const n=this;this.promise.then((e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null})),this.promise.then=e=>{let t;const a=new Promise((e=>{n.subscribe(e),t=e})).then(e);return a.cancel=function(){n.unsubscribe(t)},a},e((function(e,a,r){n.reason||(n.reason=new $ne(e,a,r),t(n.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new xae((function(t){e=t})),cancel:e}}}const Sae={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Sae).forEach((([e,t])=>{Sae[t]=e}));const kae=function e(t){const n=new Lae(t),a=Cee(Lae.prototype.request,n);return vte.extend(a,Lae.prototype,n,{allOwnKeys:!0}),vte.extend(a,n,null,{allOwnKeys:!0}),a.create=function(n){return e(eae(t,n))},a}(_ne);kae.Axios=Lae,kae.CanceledError=$ne,kae.CancelToken=xae,kae.isCancel=Wne,kae.VERSION="1.7.9",kae.toFormData=Mne,kae.AxiosError=mne,kae.Cancel=kae.CanceledError,kae.all=function(e){return Promise.all(e)},kae.spread=function(e){return function(t){return e.apply(null,t)}},kae.isAxiosError=function(e){return vte.isObject(e)&&!0===e.isAxiosError},kae.mergeConfig=eae,kae.AxiosHeaders=Bne,kae.formToJSON=e=>Nne(vte.isHTMLForm(e)?new FormData(e):e),kae.getAdapter=yae,kae.HttpStatusCode=Sae,kae.default=kae;var wae=function(){function e(){}return e.convertJsonToQueryParamsString=function(e){return Object.keys(e).map((function(t){return t+"="+e[t]})).join("&")},e}(),Tae=function(){function e(e){var t=this;this._backendBaseUrl="",this.updatePdf=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.put("".concat(this.getPdfApisEndPointRoute()),e)];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.fetchOnlyPdfData=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfApisEndPointRoute(),"/get"),e)];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.fetchOnlyPdfPagesData=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfPagesApisEndPointRoute(),"?").concat(wae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.createCommentThread=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfApisEndPointRoute(),"/commentThreads"),e)];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.deleteCommentThread=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfApisEndPointRoute(),"/commentThreads/delete"),e)];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.getCommentThreadById=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfApisEndPointRoute(),"/commentThreads/").concat(e.commentThreadId))];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.fetchCommentThreads=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfApisEndPointRoute(),"/commentThreads?").concat(wae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.createComment=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfApisEndPointRoute(),"/commentThreads/comments"),e)];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.fetchUsersOfPdf=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfApisEndPointRoute(),"/getUsers?").concat(wae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.createPageAnnotation=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:if(Object.keys(e.annotation||{}).length>1)throw new Error("invalid request payload");return[4,null===(n=this.api)||void 0===n?void 0:n.post(this.getPdfPagesAnnotationApisEndPointRoute(),e)];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.fetchAnnotation=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfPagesAnnotationApisEndPointRoute(),"?").concat(wae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.fetchAllAnnotationsOfThePage=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfPagesAnnotationApisEndPointRoute(),"?").concat(wae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.updatePageAnnotation=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.put(this.getPdfPagesAnnotationApisEndPointRoute(),e)];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.deletePageAnnotation=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.delete("".concat(this.getPdfPagesAnnotationApisEndPointRoute(),"?").concat(wae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.fetchPdfScales=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfScalesApisEndPointRoute(),"/get"),e)];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.createPdfScale=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfScalesApisEndPointRoute()),e)];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.deletePdfScale=function(e){return Q7(t,void 0,void 0,(function(){var t;return J7(this,(function(n){switch(n.label){case 0:return[4,null===(t=this.api)||void 0===t?void 0:t.post("".concat(this.getPdfScalesApisEndPointRoute(),"/delete"),e)];case 1:return n.sent(),[2]}}))}))},this.updatePdfScale=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.put("".concat(this.getPdfScalesApisEndPointRoute(),"/update"),e)];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.convertImageToPdf=function(e){var n=e.imageDownloadUrl,a=e.imageWidth,r=e.imageHeight;return Q7(t,void 0,void 0,(function(){var e,t,o,c,l;return J7(this,(function(i){switch(i.label){case 0:return e={pdfFileName:"image.pdf",imageDetails:{imageDownloadUrl:n,imageWidth:a,imageHeight:r}},[4,null===(o=this.api)||void 0===o?void 0:o.post("".concat(this.getPdfApisEndPointRoute()),e)];case 1:if(t=i.sent(),!(null===(c=null==t?void 0:t.data)||void 0===c?void 0:c._id))throw new Error("pdfId not found");return[4,null===(l=this.api)||void 0===l?void 0:l.post("".concat(this.getPdfApisEndPointRoute(),"/pdf-pages-as-images"),{pdfId:null==t?void 0:t.data._id})];case 2:return i.sent(),[2,{_id:null==t?void 0:t.data._id}]}}))}))},this.backendBaseUrl=e.backendBaseUrl,this.api=kae.create({baseURL:this.backendBaseUrl,headers:{"Content-type":"application/json; charset=utf-8"},withCredentials:!0})}return Object.defineProperty(e.prototype,"backendBaseUrl",{get:function(){return this._backendBaseUrl},set:function(e){this._backendBaseUrl=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"api",{get:function(){return this._api},set:function(e){this._api=e},enumerable:!1,configurable:!0}),e.prototype.getPdfApisEndPointRoute=function(){return"".concat(this.backendBaseUrl,"/pdfs")},e.prototype.getPdfPagesApisEndPointRoute=function(){return"".concat(this.getPdfApisEndPointRoute(),"/pages")},e.prototype.getPdfScalesApisEndPointRoute=function(){return"".concat(this.getPdfApisEndPointRoute(),"/scales")},e.prototype.getPdfPagesAnnotationApisEndPointRoute=function(){return"".concat(this.getPdfPagesApisEndPointRoute(),"/annotation")},e.calculateDistanceBetweenTwoCoordinatesInPdfPagePoints=function(e){var t=e.normalisedCoordinates2.x-e.normalisedCoordinates1.x,n=e.normalisedCoordinates2.y-e.normalisedCoordinates1.y;return Math.sqrt(t*t+n*n)/(e.pdfPageImageOriginalWidth/e.pdfPageOriginalWidthInPoints)},e.convertPdfPagePointsDistanceToInches=function(e){return e.pdfPagePointsDistance/72},e.convertInchesToCentimeters=function(e){return 2.54*e.inches},e.convertInchesToMeters=function(e){return e.inches/39.37},e.convertInchesToFeet=function(e){return e.inches/12},e.convertInchesDistanceToPdfPagePoints=function(e){return 72*e.inchesDistance},e.isUserMoreNearToHorizontalAxisOrVerticalAxis=function(e){var t=e.firstCoordinate,n=e.secondCoordinate,a=n.x-t.x,r=n.y-t.y;return Math.abs(a)>Math.abs(r)?"horizontal":"vertical"},e.prototype.insertPdfAndItsPagesInDb=function(e){var t,n,a;return Q7(this,void 0,void 0,(function(){var r,o,c;return J7(this,(function(l){switch(l.label){case 0:return(r=new FormData).append("pdfDownloadUrl",e.pdfSourceUrl),e.pdfFileName&&r.append("pdfFileName",e.pdfFileName),[4,null===(t=this.api)||void 0===t?void 0:t.post("".concat(this.getPdfApisEndPointRoute()),r,{headers:{"Content-Type":"multipart/form-data"}})];case 1:if(o=l.sent(),!(null===(n=null==o?void 0:o.data)||void 0===n?void 0:n._id))throw new Error("pdfId not found");return c=null===(a=this.api)||void 0===a?void 0:a.post("".concat(this.getPdfApisEndPointRoute(),"/pdf-pages-as-images"),{pdfId:null==o?void 0:o.data._id}),e.shouldWaitForPdfPagesCreation?[4,c]:[3,3];case 2:l.sent(),l.label=3;case 3:return[2,{_id:null==o?void 0:o.data._id}]}}))}))},e.convertNormalisedCoordinatesToUnNormalisedCoordinates=function(t){for(var n=t.normalisedCoordinates,a=t.normalisedXDimension,r=t.normalisedYDimension,o=t.unNormalisedXDimension,c=t.unNormalisedYDimension,l=[],i=0,s=n;i<s.length;i++){var h=s[i],d=h.x,u=h.y,m=e.convertNormalisedValueToUnNormalisedForShowingInUI({normalisedValue:d,normalisedDimension:a,unNormalisedDimension:o}),p=e.convertNormalisedValueToUnNormalisedForShowingInUI({normalisedValue:u,normalisedDimension:r,unNormalisedDimension:c});l.push({x:m,y:p})}return l},e.doNotMakeCoordinatesGoOutOfBoundary=function(e){for(var t=e.coordinates,n=e.coordinateBoundaries,a=0,r=t;a<r.length;a++){var o=r[a];o.x<n.xMin?o.x=n.xMin:o.x>n.xMax&&(o.x=n.xMax),o.y<n.yMin?o.y=n.yMin:o.y>n.yMax&&(o.y=n.yMax)}return t},e.prototype.insertPdfAndItsPagesInDBViaHTML=function(e){var t,n,a;return Q7(this,void 0,void 0,(function(){var r,o,c,l,i,s,h;return J7(this,(function(d){switch(d.label){case 0:if(!(r=document.getElementById(e.htmlElementId)))throw new Error("htmlELement corresponding to the id not found");return o=r.outerHTML,e.cssClassNamesWhichShouldBeRemovedBeforeHtmlToPdfConversion.forEach((function(e){o=o.replaceAll(e,"")})),c=Array.from(document.querySelectorAll("style")).map((function(e){return e.outerHTML})).join("\n"),l='\n <html>\n <head>\n <meta charset="UTF-8">\n '.concat(c,"\n </head>\n <body>\n ").concat(o,"\n </body>\n </html>\n "),i={pdfFileName:"react-html.pdf",htmlDocument:{document:l,width:r.clientWidth}},[4,null===(t=this.api)||void 0===t?void 0:t.post("".concat(this.getPdfApisEndPointRoute()),i)];case 1:if(s=d.sent(),!(null===(n=null==s?void 0:s.data)||void 0===n?void 0:n._id))throw new Error("pdfId not found");return h=null===(a=this.api)||void 0===a?void 0:a.post("".concat(this.getPdfApisEndPointRoute(),"/pdf-pages-as-images"),{pdfId:null==s?void 0:s.data._id}),e.shouldWaitForPdfPagesCreation?[4,h]:[3,3];case 2:d.sent(),d.label=3;case 3:return[2,{_id:null==s?void 0:s.data._id}]}}))}))},e.convertValueFromOneUnitToAnotherUnit=function(e){var t=e.valueToConvert,n=e.fromUnit,a=e.toUnit;if(n===a)return t;var r=0;if("cm"===n)if("m"===a)r=t/100;else if("inch"===a)r=t/2.54;else{if("ft"!==a)throw new Error("Invalid toUnit");r=t/30.48}else if("m"===n)if("cm"===a)r=100*t;else if("inch"===a)r=39.37*t;else{if("ft"!==a)throw new Error("Invalid toUnit");r=3.281*t}else if("inch"===n)if("cm"===a)r=2.54*t;else if("m"===a)r=t/39.37;else{if("ft"!==a)throw new Error("Invalid toUnit");r=t/12}else{if("ft"!==n)throw new Error("Invalid fromUnit");if("cm"===a)r=30.48*t;else if("m"===a)r=t/3.281;else{if("inch"!==a)throw new Error("Invalid toUnit");r=12*t}}return r},e.convertNormalisedValueToUnNormalisedForShowingInUI=function(e){var t=e.normalisedValue,n=e.normalisedDimension;return t*(e.unNormalisedDimension/n)},e.convertUnNormalisedValueToNormalised=function(e){var t=e.unNormalisedValue,n=e.normalisedDimension;return t/(e.unNormalisedDimension/n)},e.convertCoordinatesArrayToNumberArray=function(e){for(var t=e.coordinates,n=[],a=0;a<t.length;a++)n.push(t[a].x),n.push(t[a].y);return n},e}(),Oae=function(){function e(){}return e.getImageWidthHeightFromURL=function(e){return Q7(this,void 0,void 0,(function(){var t;return J7(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,new Promise((function(t,n){try{var a=new Image;a.onload=function(){return t({width:a.width,height:a.height})},a.src=e}catch(e){n(new Error(e.message))}}))];case 1:return[2,n.sent()];case 2:throw t=n.sent(),new Error(t.message);case 3:return[2]}}))}))},e.getImageHeight=function(e,t){return e/t},e.getImageWidth=function(e,t){return e*t},e.downloadImage=function(e){return new Promise((function(t,n){var a=new Image;a.onload=function(){return t(a)},a.onerror=function(){return n(new Error("Image loading having url ".concat(e," got failed")))},a.src=e}))},e}(),Aae={d:(e,t)=>{for(var n in t)Aae.o(t,n)&&!Aae.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},Rae=globalThis.pdfjsLib={};Aae.d(Rae,{AbortException:()=>ire,AnnotationEditorLayer:()=>Ile,AnnotationEditorParamsType:()=>jae,AnnotationEditorType:()=>Iae,AnnotationEditorUIManager:()=>Gre,AnnotationLayer:()=>Ele,AnnotationMode:()=>Fae,ColorPicker:()=>Tle,DOMSVGFactory:()=>Uce,DrawLayer:()=>jle,FeatureTest:()=>ure,GlobalWorkerOptions:()=>Uoe,ImageKind:()=>Uae,InvalidPDFException:()=>rre,MissingPDFException:()=>ore,OPS:()=>$ae,OutputScale:()=>Pre,PDFDataRangeTransport:()=>xce,PDFDateString:()=>Ore,PDFWorker:()=>Tce,PasswordResponses:()=>qae,PermissionFlag:()=>Bae,PixelsPerInch:()=>Mre,RenderingCancelledException:()=>Hre,TextLayer:()=>zce,TouchManager:()=>Kre,UnexpectedResponseException:()=>cre,Util:()=>pre,VerbosityLevel:()=>Wae,XfaLayer:()=>Wce,build:()=>Pce,createValidAbsoluteUrl:()=>Zae,fetchData:()=>Ere,getDocument:()=>Vce,getFilenameFromUrl:()=>Lre,getPdfFilenameFromUrl:()=>xre,getXfaPageViewport:()=>Are,isDataScheme:()=>Vre,isPdfFile:()=>Cre,noContextMenu:()=>wre,normalizeUnicode:()=>zre,setLayerDimensions:()=>Dre,shadow:()=>ere,stopEvent:()=>Tre,version:()=>Dce});const Nae=!("object"!=typeof yt||yt+""!="[object process]"||yt.versions.nw||yt.versions.electron&&yt.type&&"browser"!==yt.type),_ae=[1,0,0,1,0,0],Dae=[.001,0,0,.001,0,0],Pae=1.35,Fae={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Iae={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},jae={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},Bae={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Uae={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Wae={ERRORS:0,WARNINGS:1,INFOS:5},$ae={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93},qae={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Gae=Wae.WARNINGS;function Yae(){return Gae}function Kae(e){Gae>=Wae.INFOS&&console.log(`Info: ${e}`)}function Xae(e){Gae>=Wae.WARNINGS&&console.log(`Warning: ${e}`)}function Qae(e){throw new Error(e)}function Jae(e,t){e||Qae(t)}function Zae(e,t=null,n=null){if(!e)return null;try{if(n&&"string"==typeof e){if(n.addDefaultProtocol&&e.startsWith("www.")){const t=e.match(/\./g);t?.length>=2&&(e=`http://${e}`)}if(n.tryConvertEncoding)try{e=decodeURIComponent(escape(e))}catch{}}const a=t?new URL(e,t):new URL(e);if(function(e){switch(e?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(a))return a}catch{}return null}function ere(e,t,n,a=!1){return Object.defineProperty(e,t,{value:n,enumerable:!a,configurable:!0,writable:!1}),n}const tre=function(){function e(e,t){this.message=e,this.name=t}return e.prototype=new Error,e.constructor=e,e}();class nre extends tre{constructor(e,t){super(e,"PasswordException"),this.code=t}}class are extends tre{constructor(e,t){super(e,"UnknownErrorException"),this.details=t}}class rre extends tre{constructor(e){super(e,"InvalidPDFException")}}class ore extends tre{constructor(e){super(e,"MissingPDFException")}}class cre extends tre{constructor(e,t){super(e,"UnexpectedResponseException"),this.status=t}}class lre extends tre{constructor(e){super(e,"FormatError")}}class ire extends tre{constructor(e){super(e,"AbortException")}}function sre(e){"object"==typeof e&&void 0!==e?.length||Qae("Invalid argument for bytesToString");const t=e.length,n=8192;if(t<n)return String.fromCharCode.apply(null,e);const a=[];for(let r=0;r<t;r+=n){const o=Math.min(r+n,t),c=e.subarray(r,o);a.push(String.fromCharCode.apply(null,c))}return a.join("")}function hre(e){"string"!=typeof e&&Qae("Invalid argument for stringToBytes");const t=e.length,n=new Uint8Array(t);for(let a=0;a<t;++a)n[a]=255&e.charCodeAt(a);return n}function dre(e){const t=Object.create(null);for(const[n,a]of e)t[n]=a;return t}class ure{static get isLittleEndian(){return ere(this,"isLittleEndian",function(){const e=new Uint8Array(4);return e[0]=1,1===new Uint32Array(e.buffer,0,1)[0]}())}static get isEvalSupported(){return ere(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return ere(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return ere(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){return"undefined"!=typeof navigator&&"string"==typeof navigator?.platform?ere(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:"string"==typeof navigator?.userAgent&&navigator.userAgent.includes("Firefox")}):ere(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return ere(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const mre=Array.from(Array(256).keys(),(e=>e.toString(16).padStart(2,"0")));class pre{static makeHexColor(e,t,n){return`#${mre[e]}${mre[t]}${mre[n]}`}static scaleMinMax(e,t){let n;e[0]?(e[0]<0&&(n=t[0],t[0]=t[2],t[2]=n),t[0]*=e[0],t[2]*=e[0],e[3]<0&&(n=t[1],t[1]=t[3],t[3]=n),t[1]*=e[3],t[3]*=e[3]):(n=t[0],t[0]=t[1],t[1]=n,n=t[2],t[2]=t[3],t[3]=n,e[1]<0&&(n=t[1],t[1]=t[3],t[3]=n),t[1]*=e[1],t[3]*=e[1],e[2]<0&&(n=t[0],t[0]=t[2],t[2]=n),t[0]*=e[2],t[2]*=e[2]),t[0]+=e[4],t[1]+=e[5],t[2]+=e[4],t[3]+=e[5]}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static applyTransform(e,t){return[e[0]*t[0]+e[1]*t[2]+t[4],e[0]*t[1]+e[1]*t[3]+t[5]]}static applyInverseTransform(e,t){const n=t[0]*t[3]-t[1]*t[2];return[(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/n,(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/n]}static getAxialAlignedBoundingBox(e,t){const n=this.applyTransform(e,t),a=this.applyTransform(e.slice(2,4),t),r=this.applyTransform([e[0],e[3]],t),o=this.applyTransform([e[2],e[1]],t);return[Math.min(n[0],a[0],r[0],o[0]),Math.min(n[1],a[1],r[1],o[1]),Math.max(n[0],a[0],r[0],o[0]),Math.max(n[1],a[1],r[1],o[1])]}static inverseTransform(e){const t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e){const t=[e[0],e[2],e[1],e[3]],n=e[0]*t[0]+e[1]*t[2],a=e[0]*t[1]+e[1]*t[3],r=e[2]*t[0]+e[3]*t[2],o=e[2]*t[1]+e[3]*t[3],c=(n+o)/2,l=Math.sqrt((n+o)**2-4*(n*o-r*a))/2,i=c+l||1,s=c-l||1;return[Math.sqrt(i),Math.sqrt(s)]}static normalizeRect(e){const t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){const n=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),a=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(n>a)return null;const r=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),o=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return r>o?null:[n,r,a,o]}static#e(e,t,n,a,r,o,c,l,i,s){if(i<=0||i>=1)return;const h=1-i,d=i*i,u=d*i,m=h*(h*(h*e+3*i*t)+3*d*n)+u*a,p=h*(h*(h*r+3*i*o)+3*d*c)+u*l;s[0]=Math.min(s[0],m),s[1]=Math.min(s[1],p),s[2]=Math.max(s[2],m),s[3]=Math.max(s[3],p)}static#t(e,t,n,a,r,o,c,l,i,s,h,d){if(Math.abs(i)<1e-12)return void(Math.abs(s)>=1e-12&&this.#e(e,t,n,a,r,o,c,l,-h/s,d));const u=s**2-4*h*i;if(u<0)return;const m=Math.sqrt(u),p=2*i;this.#e(e,t,n,a,r,o,c,l,(-s+m)/p,d),this.#e(e,t,n,a,r,o,c,l,(-s-m)/p,d)}static bezierBoundingBox(e,t,n,a,r,o,c,l,i){return i?(i[0]=Math.min(i[0],e,c),i[1]=Math.min(i[1],t,l),i[2]=Math.max(i[2],e,c),i[3]=Math.max(i[3],t,l)):i=[Math.min(e,c),Math.min(t,l),Math.max(e,c),Math.max(t,l)],this.#t(e,n,r,c,t,a,o,l,3*(3*(n-r)-e+c),6*(e-2*n+r),3*(n-e),i),this.#t(e,n,r,c,t,a,o,l,3*(3*(a-o)-t+l),6*(t-2*a+o),3*(a-t),i),i}}let vre=null,fre=null;function zre(e){return vre||(vre=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,fre=new Map([["ſt","ſt"]])),e.replaceAll(vre,((e,t,n)=>t?t.normalize("NFKC"):fre.get(n)))}const gre="pdfjs_internal_id_";"function"!=typeof Promise.try&&(Promise.try=function(e,...t){return new Promise((n=>{n(e(...t))}))});const yre="http://www.w3.org/2000/svg";class Mre{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function Ere(e,t="text"){if(kre(e,document.baseURI)){const n=await fetch(e);if(!n.ok)throw new Error(n.statusText);switch(t){case"arraybuffer":return n.arrayBuffer();case"blob":return n.blob();case"json":return n.json()}return n.text()}return new Promise(((n,a)=>{const r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType=t,r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE)if(200!==r.status&&0!==r.status)a(new Error(r.statusText));else{switch(t){case"arraybuffer":case"blob":case"json":return void n(r.response)}n(r.responseText)}},r.send(null)}))}class bre{constructor({viewBox:e,userUnit:t,scale:n,rotation:a,offsetX:r=0,offsetY:o=0,dontFlip:c=!1}){this.viewBox=e,this.userUnit=t,this.scale=n,this.rotation=a,this.offsetX=r,this.offsetY=o,n*=t;const l=(e[2]+e[0])/2,i=(e[3]+e[1])/2;let s,h,d,u,m,p,v,f;switch((a%=360)<0&&(a+=360),a){case 180:s=-1,h=0,d=0,u=1;break;case 90:s=0,h=1,d=1,u=0;break;case 270:s=0,h=-1,d=-1,u=0;break;case 0:s=1,h=0,d=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}c&&(d=-d,u=-u),0===s?(m=Math.abs(i-e[1])*n+r,p=Math.abs(l-e[0])*n+o,v=(e[3]-e[1])*n,f=(e[2]-e[0])*n):(m=Math.abs(l-e[0])*n+r,p=Math.abs(i-e[1])*n+o,v=(e[2]-e[0])*n,f=(e[3]-e[1])*n),this.transform=[s*n,h*n,d*n,u*n,m-s*n*l-d*n*i,p-h*n*l-u*n*i],this.width=v,this.height=f}get rawDims(){const{userUnit:e,viewBox:t}=this,n=t.map((t=>t*e));return ere(this,"rawDims",{pageWidth:n[2]-n[0],pageHeight:n[3]-n[1],pageX:n[0],pageY:n[1]})}clone({scale:e=this.scale,rotation:t=this.rotation,offsetX:n=this.offsetX,offsetY:a=this.offsetY,dontFlip:r=!1}={}){return new bre({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:e,rotation:t,offsetX:n,offsetY:a,dontFlip:r})}convertToViewportPoint(e,t){return pre.applyTransform([e,t],this.transform)}convertToViewportRectangle(e){const t=pre.applyTransform([e[0],e[1]],this.transform),n=pre.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],n[0],n[1]]}convertToPdfPoint(e,t){return pre.applyInverseTransform([e,t],this.transform)}}class Hre extends tre{constructor(e,t=0){super(e,"RenderingCancelledException"),this.extraDelay=t}}function Vre(e){const t=e.length;let n=0;for(;n<t&&""===e[n].trim();)n++;return"data:"===e.substring(n,n+5).toLowerCase()}function Cre(e){return"string"==typeof e&&/\.pdf$/i.test(e)}function Lre(e){return[e]=e.split(/[#?]/,1),e.substring(e.lastIndexOf("/")+1)}function xre(e,t="document.pdf"){if("string"!=typeof e)return t;if(Vre(e))return Xae('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const n=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,a=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(e);let r=n.exec(a[1])||n.exec(a[2])||n.exec(a[3]);if(r&&(r=r[0],r.includes("%")))try{r=n.exec(decodeURIComponent(r))[0]}catch{}return r||t}class Sre{started=Object.create(null);times=[];time(e){e in this.started&&Xae(`Timer is already running for ${e}`),this.started[e]=Date.now()}timeEnd(e){e in this.started||Xae(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.started[e],end:Date.now()}),delete this.started[e]}toString(){const e=[];let t=0;for(const{name:e}of this.times)t=Math.max(e.length,t);for(const{name:n,start:a,end:r}of this.times)e.push(`${n.padEnd(t)} ${r-a}ms\n`);return e.join("")}}function kre(e,t){try{const{protocol:n}=t?new URL(e,t):new URL(e);return"http:"===n||"https:"===n}catch{return!1}}function wre(e){e.preventDefault()}function Tre(e){e.preventDefault(),e.stopPropagation()}class Ore{static#n;static toDateObject(e){if(!e||"string"!=typeof e)return null;this.#n||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const t=this.#n.exec(e);if(!t)return null;const n=parseInt(t[1],10);let a=parseInt(t[2],10);a=a>=1&&a<=12?a-1:0;let r=parseInt(t[3],10);r=r>=1&&r<=31?r:1;let o=parseInt(t[4],10);o=o>=0&&o<=23?o:0;let c=parseInt(t[5],10);c=c>=0&&c<=59?c:0;let l=parseInt(t[6],10);l=l>=0&&l<=59?l:0;const i=t[7]||"Z";let s=parseInt(t[8],10);s=s>=0&&s<=23?s:0;let h=parseInt(t[9],10)||0;return h=h>=0&&h<=59?h:0,"-"===i?(o+=s,c+=h):"+"===i&&(o-=s,c-=h),new Date(Date.UTC(n,a,r,o,c,l))}}function Are(e,{scale:t=1,rotation:n=0}){const{width:a,height:r}=e.attributes.style,o=[0,0,parseInt(a),parseInt(r)];return new bre({viewBox:o,userUnit:1,scale:t,rotation:n})}function Rre(e){if(e.startsWith("#")){const t=parseInt(e.slice(1),16);return[(16711680&t)>>16,(65280&t)>>8,255&t]}return e.startsWith("rgb(")?e.slice(4,-1).split(",").map((e=>parseInt(e))):e.startsWith("rgba(")?e.slice(5,-1).split(",").map((e=>parseInt(e))).slice(0,3):(Xae(`Not a valid color format: "${e}"`),[0,0,0])}function Nre(e){const{a:t,b:n,c:a,d:r,e:o,f:c}=e.getTransform();return[t,n,a,r,o,c]}function _re(e){const{a:t,b:n,c:a,d:r,e:o,f:c}=e.getTransform().invertSelf();return[t,n,a,r,o,c]}function Dre(e,t,n=!1,a=!0){if(t instanceof bre){const{pageWidth:a,pageHeight:r}=t.rawDims,{style:o}=e,c=ure.isCSSRoundSupported,l=`var(--scale-factor) * ${a}px`,i=`var(--scale-factor) * ${r}px`,s=c?`round(down, ${l}, var(--scale-round-x, 1px))`:`calc(${l})`,h=c?`round(down, ${i}, var(--scale-round-y, 1px))`:`calc(${i})`;n&&t.rotation%180!=0?(o.width=h,o.height=s):(o.width=s,o.height=h)}a&&e.setAttribute("data-main-rotation",t.rotation)}class Pre{constructor(){const e=window.devicePixelRatio||1;this.sx=e,this.sy=e}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}}class Fre{#a=null;#r=null;#o;#c=null;#l=null;static#i=null;constructor(e){this.#o=e,Fre.#i||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"})}render(){const e=this.#a=document.createElement("div");e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");const t=this.#o._uiManager._signal;e.addEventListener("contextmenu",wre,{signal:t}),e.addEventListener("pointerdown",Fre.#s,{signal:t});const n=this.#c=document.createElement("div");n.className="buttons",e.append(n);const a=this.#o.toolbarPosition;if(a){const{style:t}=e,n="ltr"===this.#o._uiManager.direction?1-a[0]:a[0];t.insetInlineEnd=100*n+"%",t.top=`calc(${100*a[1]}% + var(--editor-toolbar-vert-offset))`}return this.#h(),e}get div(){return this.#a}static#s(e){e.stopPropagation()}#d(e){this.#o._focusEventsAllowed=!1,Tre(e)}#u(e){this.#o._focusEventsAllowed=!0,Tre(e)}#m(e){const t=this.#o._uiManager._signal;e.addEventListener("focusin",this.#d.bind(this),{capture:!0,signal:t}),e.addEventListener("focusout",this.#u.bind(this),{capture:!0,signal:t}),e.addEventListener("contextmenu",wre,{signal:t})}hide(){this.#a.classList.add("hidden"),this.#r?.hideDropdown()}show(){this.#a.classList.remove("hidden"),this.#l?.shown()}#h(){const{editorType:e,_uiManager:t}=this.#o,n=document.createElement("button");n.className="delete",n.tabIndex=0,n.setAttribute("data-l10n-id",Fre.#i[e]),this.#m(n),n.addEventListener("click",(e=>{t.delete()}),{signal:t._signal}),this.#c.append(n)}get#p(){const e=document.createElement("div");return e.className="divider",e}async addAltText(e){const t=await e.render();this.#m(t),this.#c.prepend(t,this.#p),this.#l=e}addColorPicker(e){this.#r=e;const t=e.renderButton();this.#m(t),this.#c.prepend(t,this.#p)}remove(){this.#a.remove(),this.#r?.destroy(),this.#r=null}}class Ire{#c=null;#a=null;#v;constructor(e){this.#v=e}#f(){const e=this.#a=document.createElement("div");e.className="editToolbar",e.setAttribute("role","toolbar"),e.addEventListener("contextmenu",wre,{signal:this.#v._signal});const t=this.#c=document.createElement("div");return t.className="buttons",e.append(t),this.#z(),e}#g(e,t){let n=0,a=0;for(const r of e){const e=r.y+r.height;if(e<n)continue;const o=r.x+(t?r.width:0);e>n?(a=o,n=e):t?o>a&&(a=o):o<a&&(a=o)}return[t?1-a:a,n]}show(e,t,n){const[a,r]=this.#g(t,n),{style:o}=this.#a||=this.#f();e.append(this.#a),o.insetInlineEnd=100*a+"%",o.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){this.#a.remove()}#z(){const e=document.createElement("button");e.className="highlightButton",e.tabIndex=0,e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const t=document.createElement("span");e.append(t),t.className="visuallyHidden",t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const n=this.#v._signal;e.addEventListener("contextmenu",wre,{signal:n}),e.addEventListener("click",(()=>{this.#v.highlightSelection("floating_button")}),{signal:n}),this.#c.append(e)}}function jre(e,t,n){for(const a of n)t.addEventListener(a,e[a].bind(e))}class Bre{#y=0;get id(){return"pdfjs_internal_editor_"+this.#y++}}class Ure{#M=function(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const e=new Uint8Array(32);return crypto.getRandomValues(e),sre(e)}();#y=0;#E=null;static get _isSVGFittingCanvas(){const e=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),t=new Image;return t.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',ere(this,"_isSVGFittingCanvas",t.decode().then((()=>(e.drawImage(t,0,0,1,1,0,0,1,3),0===new Uint32Array(e.getImageData(0,0,1,1).data.buffer)[0]))))}async#b(e,t){this.#E||=new Map;let n=this.#E.get(e);if(null===n)return null;if(n?.bitmap)return n.refCounter+=1,n;try{let e;if(n||={bitmap:null,id:`image_${this.#M}_${this.#y++}`,refCounter:0,isSvg:!1},"string"==typeof t?(n.url=t,e=await Ere(t,"blob")):t instanceof File?e=n.file=t:t instanceof Blob&&(e=t),"image/svg+xml"===e.type){const t=Ure._isSVGFittingCanvas,a=new FileReader,r=new Image,o=new Promise(((e,o)=>{r.onload=()=>{n.bitmap=r,n.isSvg=!0,e()},a.onload=async()=>{const e=n.svgUrl=a.result;r.src=await t?`${e}#svgView(preserveAspectRatio(none))`:e},r.onerror=a.onerror=o}));a.readAsDataURL(e),await o}else n.bitmap=await createImageBitmap(e);n.refCounter=1}catch(e){Xae(e),n=null}return this.#E.set(e,n),n&&this.#E.set(n.id,n),n}async getFromFile(e){const{lastModified:t,name:n,size:a,type:r}=e;return this.#b(`${t}_${n}_${a}_${r}`,e)}async getFromUrl(e){return this.#b(e,e)}async getFromBlob(e,t){const n=await t;return this.#b(e,n)}async getFromId(e){this.#E||=new Map;const t=this.#E.get(e);if(!t)return null;if(t.bitmap)return t.refCounter+=1,t;if(t.file)return this.getFromFile(t.file);if(t.blobPromise){const{blobPromise:e}=t;return delete t.blobPromise,this.getFromBlob(t.id,e)}return this.getFromUrl(t.url)}getFromCanvas(e,t){this.#E||=new Map;let n=this.#E.get(e);if(n?.bitmap)return n.refCounter+=1,n;const a=new OffscreenCanvas(t.width,t.height);return a.getContext("2d").drawImage(t,0,0),n={bitmap:a.transferToImageBitmap(),id:`image_${this.#M}_${this.#y++}`,refCounter:1,isSvg:!1},this.#E.set(e,n),this.#E.set(n.id,n),n}getSvgUrl(e){const t=this.#E.get(e);return t?.isSvg?t.svgUrl:null}deleteId(e){this.#E||=new Map;const t=this.#E.get(e);if(!t)return;if(t.refCounter-=1,0!==t.refCounter)return;const{bitmap:n}=t;if(!t.url&&!t.file){const e=new OffscreenCanvas(n.width,n.height);e.getContext("bitmaprenderer").transferFromImageBitmap(n),t.blobPromise=e.convertToBlob()}n.close?.(),t.bitmap=null}isValidId(e){return e.startsWith(`image_${this.#M}_`)}}class Wre{#H=[];#V=!1;#C;#L=-1;constructor(e=128){this.#C=e}add({cmd:e,undo:t,post:n,mustExec:a,type:r=NaN,overwriteIfSameType:o=!1,keepUndo:c=!1}){if(a&&e(),this.#V)return;const l={cmd:e,undo:t,post:n,type:r};if(-1===this.#L)return this.#H.length>0&&(this.#H.length=0),this.#L=0,void this.#H.push(l);if(o&&this.#H[this.#L].type===r)return c&&(l.undo=this.#H[this.#L].undo),void(this.#H[this.#L]=l);const i=this.#L+1;i===this.#C?this.#H.splice(0,1):(this.#L=i,i<this.#H.length&&this.#H.splice(i)),this.#H.push(l)}undo(){if(-1===this.#L)return;this.#V=!0;const{undo:e,post:t}=this.#H[this.#L];e(),t?.(),this.#V=!1,this.#L-=1}redo(){if(this.#L<this.#H.length-1){this.#L+=1,this.#V=!0;const{cmd:e,post:t}=this.#H[this.#L];e(),t?.(),this.#V=!1}}hasSomethingToUndo(){return-1!==this.#L}hasSomethingToRedo(){return this.#L<this.#H.length-1}cleanType(e){if(-1!==this.#L){for(let t=this.#L;t>=0;t--)if(this.#H[t].type!==e)return this.#H.splice(t+1,this.#L-t),void(this.#L=t);this.#H.length=0,this.#L=-1}}destroy(){this.#H=null}}class $re{constructor(e){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:t}=ure.platform;for(const[n,a,r={}]of e)for(const e of n){const n=e.startsWith("mac+");t&&n?(this.callbacks.set(e.slice(4),{callback:a,options:r}),this.allKeys.add(e.split("+").at(-1))):t||n||(this.callbacks.set(e,{callback:a,options:r}),this.allKeys.add(e.split("+").at(-1)))}}#x(e){e.altKey&&this.buffer.push("alt"),e.ctrlKey&&this.buffer.push("ctrl"),e.metaKey&&this.buffer.push("meta"),e.shiftKey&&this.buffer.push("shift"),this.buffer.push(e.key);const t=this.buffer.join("+");return this.buffer.length=0,t}exec(e,t){if(!this.allKeys.has(t.key))return;const n=this.callbacks.get(this.#x(t));if(!n)return;const{callback:a,options:{bubbles:r=!1,args:o=[],checker:c=null}}=n;c&&!c(e,t)||(a.bind(e,...o,t)(),r||Tre(t))}}class qre{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const e=new Map([["CanvasText",null],["Canvas",null]]);return function(e){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const n of e.keys()){t.style.color=n;const a=window.getComputedStyle(t).color;e.set(n,Rre(a))}t.remove()}(e),ere(this,"_colors",e)}convert(e){const t=Rre(e);if(!window.matchMedia("(forced-colors: active)").matches)return t;for(const[e,n]of this._colors)if(n.every(((e,n)=>e===t[n])))return qre._colorsMapping.get(e);return t}getHexCode(e){const t=this._colors.get(e);return t?pre.makeHexColor(...t):e}}class Gre{#S=new AbortController;#k=null;#w=new Map;#T=new Map;#O=null;#A=null;#R=null;#N=new Wre;#_=null;#D=null;#P=0;#F=new Set;#I=null;#j=null;#B=new Set;_editorUndoBar=null;#U=!1;#W=!1;#$=!1;#q=null;#G=null;#Y=null;#K=null;#X=!1;#Q=null;#J=new Bre;#Z=!1;#ee=!1;#te=null;#ne=null;#ae=null;#re=null;#oe=Iae.NONE;#ce=new Set;#le=null;#ie=null;#se=null;#he={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#de=[0,0];#ue=null;#me=null;#pe=null;#ve=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const e=Gre.prototype,t=e=>e.#me.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&e.hasSomethingToControl(),n=(e,{target:t})=>{if(t instanceof HTMLInputElement){const{type:e}=t;return"text"!==e&&"number"!==e}return!0},a=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return ere(this,"_keyboardManager",new $re([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:n}],[["ctrl+z","mac+meta+z"],e.undo,{checker:n}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:n}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:n}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#me.contains(t)&&!e.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#me.contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-a,0],checker:t}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-r,0],checker:t}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[a,0],checker:t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[r,0],checker:t}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-a],checker:t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-r],checker:t}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,a],checker:t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,r],checker:t}]]))}constructor(e,t,n,a,r,o,c,l,i,s,h,d,u){const m=this._signal=this.#S.signal;this.#me=e,this.#pe=t,this.#O=n,this._eventBus=a,a._on("editingaction",this.onEditingAction.bind(this),{signal:m}),a._on("pagechanging",this.onPageChanging.bind(this),{signal:m}),a._on("scalechanging",this.onScaleChanging.bind(this),{signal:m}),a._on("rotationchanging",this.onRotationChanging.bind(this),{signal:m}),a._on("setpreference",this.onSetPreference.bind(this),{signal:m}),a._on("switchannotationeditorparams",(e=>this.updateParams(e.type,e.value)),{signal:m}),this.#fe(),this.#ze(),this.#ge(),this.#A=r.annotationStorage,this.#q=r.filterFactory,this.#ie=o,this.#K=c||null,this.#U=l,this.#W=i,this.#$=s,this.#re=h||null,this.viewParameters={realScale:Mre.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=d||null,this._supportsPinchToZoom=!1!==u}destroy(){this.#ve?.resolve(),this.#ve=null,this.#S?.abort(),this.#S=null,this._signal=null;for(const e of this.#T.values())e.destroy();this.#T.clear(),this.#w.clear(),this.#B.clear(),this.#k=null,this.#ce.clear(),this.#N.destroy(),this.#O?.destroy(),this.#Q?.hide(),this.#Q=null,this.#G&&(clearTimeout(this.#G),this.#G=null),this.#ue&&(clearTimeout(this.#ue),this.#ue=null),this._editorUndoBar?.destroy()}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return this.#re}get useNewAltTextFlow(){return this.#W}get useNewAltTextWhenAddingImage(){return this.#$}get hcmFilter(){return ere(this,"hcmFilter",this.#ie?this.#q.addHCMFilter(this.#ie.foreground,this.#ie.background):"none")}get direction(){return ere(this,"direction",getComputedStyle(this.#me).direction)}get highlightColors(){return ere(this,"highlightColors",this.#K?new Map(this.#K.split(",").map((e=>e.split("=").map((e=>e.trim()))))):null)}get highlightColorNames(){return ere(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(e=>e.reverse()))):null)}setCurrentDrawingSession(e){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#D=e}setMainHighlightColorPicker(e){this.#ae=e}editAltText(e,t=!1){this.#O?.editAltText(this,e,t)}switchToMode(e,t){this._eventBus.on("annotationeditormodechanged",t,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:e})}setPreference(e,t){this._eventBus.dispatch("setpreference",{source:this,name:e,value:t})}onSetPreference({name:e,value:t}){"enableNewAltTextWhenAddingImage"===e&&(this.#$=t)}onPageChanging({pageNumber:e}){this.#P=e-1}focusMainContainer(){this.#me.focus()}findParent(e,t){for(const n of this.#T.values()){const{x:a,y:r,width:o,height:c}=n.div.getBoundingClientRect();if(e>=a&&e<=a+o&&t>=r&&t<=r+c)return n}return null}disableUserSelect(e=!1){this.#pe.classList.toggle("noUserSelect",e)}addShouldRescale(e){this.#B.add(e)}removeShouldRescale(e){this.#B.delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*Mre.PDF_TO_CSS_UNITS;for(const e of this.#B)e.onScaleChanging();this.#D?.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}#ye({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e}#Me(e){const{currentLayer:t}=this;if(t.hasTextLayer(e))return t;for(const t of this.#T.values())if(t.hasTextLayer(e))return t;return null}highlightSelection(e=""){const t=document.getSelection();if(!t||t.isCollapsed)return;const{anchorNode:n,anchorOffset:a,focusNode:r,focusOffset:o}=t,c=t.toString(),l=this.#ye(t).closest(".textLayer"),i=this.getSelectionBoxes(l);if(!i)return;t.empty();const s=this.#Me(l),h=this.#oe===Iae.NONE,d=()=>{s?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:i,anchorNode:n,anchorOffset:a,focusNode:r,focusOffset:o,text:c}),h&&this.showAllEditors("highlight",!0,!0)};h?this.switchToMode(Iae.HIGHLIGHT,d):d()}#Ee(){const e=document.getSelection();if(!e||e.isCollapsed)return;const t=this.#ye(e).closest(".textLayer"),n=this.getSelectionBoxes(t);n&&(this.#Q||=new Ire(this),this.#Q.show(t,n,"ltr"===this.direction))}addToAnnotationStorage(e){e.isEmpty()||!this.#A||this.#A.has(e.id)||this.#A.setValue(e.id,e)}#be(){const e=document.getSelection();if(!e||e.isCollapsed)return void(this.#le&&(this.#Q?.hide(),this.#le=null,this.#He({hasSelectedText:!1})));const{anchorNode:t}=e;if(t===this.#le)return;const n=this.#ye(e).closest(".textLayer");if(n){if(this.#Q?.hide(),this.#le=t,this.#He({hasSelectedText:!0}),(this.#oe===Iae.HIGHLIGHT||this.#oe===Iae.NONE)&&(this.#oe===Iae.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#X=this.isShiftKeyDown,!this.isShiftKeyDown)){const e=this.#oe===Iae.HIGHLIGHT?this.#Me(n):null;e?.toggleDrawing();const t=new AbortController,a=this.combinedSignal(t),r=n=>{"pointerup"===n.type&&0!==n.button||(t.abort(),e?.toggleDrawing(!0),"pointerup"===n.type&&this.#Ve("main_toolbar"))};window.addEventListener("pointerup",r,{signal:a}),window.addEventListener("blur",r,{signal:a})}}else this.#le&&(this.#Q?.hide(),this.#le=null,this.#He({hasSelectedText:!1}))}#Ve(e=""){this.#oe===Iae.HIGHLIGHT?this.highlightSelection(e):this.#U&&this.#Ee()}#fe(){document.addEventListener("selectionchange",this.#be.bind(this),{signal:this._signal})}#Ce(){if(this.#Y)return;this.#Y=new AbortController;const e=this.combinedSignal(this.#Y);window.addEventListener("focus",this.focus.bind(this),{signal:e}),window.addEventListener("blur",this.blur.bind(this),{signal:e})}#Le(){this.#Y?.abort(),this.#Y=null}blur(){if(this.isShiftKeyDown=!1,this.#X&&(this.#X=!1,this.#Ve("main_toolbar")),!this.hasSelection)return;const{activeElement:e}=document;for(const t of this.#ce)if(t.div.contains(e)){this.#ne=[t,e],t._focusEventsAllowed=!1;break}}focus(){if(!this.#ne)return;const[e,t]=this.#ne;this.#ne=null,t.addEventListener("focusin",(()=>{e._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),t.focus()}#ge(){if(this.#te)return;this.#te=new AbortController;const e=this.combinedSignal(this.#te);window.addEventListener("keydown",this.keydown.bind(this),{signal:e}),window.addEventListener("keyup",this.keyup.bind(this),{signal:e})}#xe(){this.#te?.abort(),this.#te=null}#Se(){if(this.#_)return;this.#_=new AbortController;const e=this.combinedSignal(this.#_);document.addEventListener("copy",this.copy.bind(this),{signal:e}),document.addEventListener("cut",this.cut.bind(this),{signal:e}),document.addEventListener("paste",this.paste.bind(this),{signal:e})}#ke(){this.#_?.abort(),this.#_=null}#ze(){const e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e}),document.addEventListener("drop",this.drop.bind(this),{signal:e})}addEditListeners(){this.#ge(),this.#Se()}removeEditListeners(){this.#xe(),this.#ke()}dragOver(e){for(const{type:t}of e.dataTransfer.items)for(const n of this.#j)if(n.isHandlingMimeForPasting(t))return e.dataTransfer.dropEffect="copy",void e.preventDefault()}drop(e){for(const t of e.dataTransfer.items)for(const n of this.#j)if(n.isHandlingMimeForPasting(t.type))return n.paste(t,this.currentLayer),void e.preventDefault()}copy(e){if(e.preventDefault(),this.#k?.commitOrRemove(),!this.hasSelection)return;const t=[];for(const e of this.#ce){const n=e.serialize(!0);n&&t.push(n)}0!==t.length&&e.clipboardData.setData("application/pdfjs",JSON.stringify(t))}cut(e){this.copy(e),this.delete()}async paste(e){e.preventDefault();const{clipboardData:t}=e;for(const e of t.items)for(const t of this.#j)if(t.isHandlingMimeForPasting(e.type))return void t.paste(e,this.currentLayer);let n=t.getData("application/pdfjs");if(!n)return;try{n=JSON.parse(n)}catch(e){return void Xae(`paste: "${e.message}".`)}if(!Array.isArray(n))return;this.unselectAll();const a=this.currentLayer;try{const e=[];for(const t of n){const n=await a.deserialize(t);if(!n)return;e.push(n)}const t=()=>{for(const t of e)this.#we(t);this.#Te(e)},r=()=>{for(const t of e)t.remove()};this.addCommands({cmd:t,undo:r,mustExec:!0})}catch(e){Xae(`paste: "${e.message}".`)}}keydown(e){this.isShiftKeyDown||"Shift"!==e.key||(this.isShiftKeyDown=!0),this.#oe===Iae.NONE||this.isEditorHandlingKeyboard||Gre._keyboardManager.exec(this,e)}keyup(e){this.isShiftKeyDown&&"Shift"===e.key&&(this.isShiftKeyDown=!1,this.#X&&(this.#X=!1,this.#Ve("main_toolbar")))}onEditingAction({name:e}){switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#He(e){Object.entries(e).some((([e,t])=>this.#he[e]!==t))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#he,e)}),this.#oe===Iae.HIGHLIGHT&&!1===e.hasSelectedEditor&&this.#Oe([[jae.HIGHLIGHT_FREE,!0]]))}#Oe(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})}setEditingState(e){e?(this.#Ce(),this.#Se(),this.#He({isEditing:this.#oe!==Iae.NONE,isEmpty:this.#Ae(),hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:this.#N.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Le(),this.#ke(),this.#He({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!this.#j){this.#j=e;for(const e of this.#j)this.#Oe(e.defaultPropertiesToUpdate)}}getId(){return this.#J.id}get currentLayer(){return this.#T.get(this.#P)}getLayer(e){return this.#T.get(e)}get currentPageIndex(){return this.#P}addLayer(e){this.#T.set(e.pageIndex,e),this.#Z?e.enable():e.disable()}removeLayer(e){this.#T.delete(e.pageIndex)}async updateMode(e,t=null,n=!1){if(this.#oe!==e&&(!this.#ve||(await this.#ve.promise,this.#ve))){if(this.#ve=Promise.withResolvers(),this.#oe=e,e===Iae.NONE)return this.setEditingState(!1),this.#Re(),this._editorUndoBar?.hide(),void this.#ve.resolve();this.setEditingState(!0),await this.#Ne(),this.unselectAll();for(const t of this.#T.values())t.updateMode(e);if(!t)return n&&this.addNewEditorFromKeyboard(),void this.#ve.resolve();for(const e of this.#w.values())e.annotationElementId===t?(this.setSelected(e),e.enterInEditMode()):e.unselect();this.#ve.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e!==this.#oe&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:e})}updateParams(e,t){if(this.#j){switch(e){case jae.CREATE:return void this.currentLayer.addNewEditor();case jae.HIGHLIGHT_DEFAULT_COLOR:this.#ae?.updateColor(t);break;case jae.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#se||=new Map).set(e,t),this.showAllEditors("highlight",t)}for(const n of this.#ce)n.updateParams(e,t);for(const n of this.#j)n.updateDefaultParams(e,t)}}showAllEditors(e,t,n=!1){for(const n of this.#w.values())n.editorType===e&&n.show(t);(this.#se?.get(jae.HIGHLIGHT_SHOW_ALL)??!0)!==t&&this.#Oe([[jae.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(this.#ee!==e){this.#ee=e;for(const t of this.#T.values())e?t.disableClick():t.enableClick(),t.div.classList.toggle("waiting",e)}}async#Ne(){if(!this.#Z){this.#Z=!0;const e=[];for(const t of this.#T.values())e.push(t.enable());await Promise.all(e);for(const e of this.#w.values())e.enable()}}#Re(){if(this.unselectAll(),this.#Z){this.#Z=!1;for(const e of this.#T.values())e.disable();for(const e of this.#w.values())e.disable()}}getEditors(e){const t=[];for(const n of this.#w.values())n.pageIndex===e&&t.push(n);return t}getEditor(e){return this.#w.get(e)}addEditor(e){this.#w.set(e.id,e)}removeEditor(e){e.div.contains(document.activeElement)&&(this.#G&&clearTimeout(this.#G),this.#G=setTimeout((()=>{this.focusMainContainer(),this.#G=null}),0)),this.#w.delete(e.id),this.unselect(e),e.annotationElementId&&this.#F.has(e.annotationElementId)||this.#A?.remove(e.id)}addDeletedAnnotationElement(e){this.#F.add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return this.#F.has(e)}removeDeletedAnnotationElement(e){this.#F.delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}#we(e){const t=this.#T.get(e.pageIndex);t?t.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))}setActiveEditor(e){this.#k!==e&&(this.#k=e,e&&this.#Oe(e.propertiesToUpdate))}get#_e(){let e=null;for(e of this.#ce);return e}updateUI(e){this.#_e===e&&this.#Oe(e.propertiesToUpdate)}updateUIForDefaultProperties(e){this.#Oe(e.defaultPropertiesToUpdate)}toggleSelected(e){if(this.#ce.has(e))return this.#ce.delete(e),e.unselect(),void this.#He({hasSelectedEditor:this.hasSelection});this.#ce.add(e),e.select(),this.#Oe(e.propertiesToUpdate),this.#He({hasSelectedEditor:!0})}setSelected(e){this.#D?.commitOrRemove();for(const t of this.#ce)t!==e&&t.unselect();this.#ce.clear(),this.#ce.add(e),e.select(),this.#Oe(e.propertiesToUpdate),this.#He({hasSelectedEditor:!0})}isSelected(e){return this.#ce.has(e)}get firstSelectedEditor(){return this.#ce.values().next().value}unselect(e){e.unselect(),this.#ce.delete(e),this.#He({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#ce.size}get isEnterHandled(){return 1===this.#ce.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#N.undo(),this.#He({hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Ae()}),this._editorUndoBar?.hide()}redo(){this.#N.redo(),this.#He({hasSomethingToUndo:!0,hasSomethingToRedo:this.#N.hasSomethingToRedo(),isEmpty:this.#Ae()})}addCommands(e){this.#N.add(e),this.#He({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Ae()})}cleanUndoStack(e){this.#N.cleanType(e)}#Ae(){if(0===this.#w.size)return!0;if(1===this.#w.size)for(const e of this.#w.values())return e.isEmpty();return!1}delete(){this.commitOrRemove();const e=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!e)return;const t=e?[e]:[...this.#ce],n=()=>{for(const e of t)this.#we(e)};this.addCommands({cmd:()=>{this._editorUndoBar?.show(n,1===t.length?t[0].editorType:t.length);for(const e of t)e.remove()},undo:n,mustExec:!0})}commitOrRemove(){this.#k?.commitOrRemove()}hasSomethingToControl(){return this.#k||this.hasSelection}#Te(e){for(const e of this.#ce)e.unselect();this.#ce.clear();for(const t of e)t.isEmpty()||(this.#ce.add(t),t.select());this.#He({hasSelectedEditor:this.hasSelection})}selectAll(){for(const e of this.#ce)e.commit();this.#Te(this.#w.values())}unselectAll(){if((!this.#k||(this.#k.commitOrRemove(),this.#oe===Iae.NONE))&&!this.#D?.commitOrRemove()&&this.hasSelection){for(const e of this.#ce)e.unselect();this.#ce.clear(),this.#He({hasSelectedEditor:!1})}}translateSelectedEditors(e,t,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;this.#de[0]+=e,this.#de[1]+=t;const[a,r]=this.#de,o=[...this.#ce];this.#ue&&clearTimeout(this.#ue),this.#ue=setTimeout((()=>{this.#ue=null,this.#de[0]=this.#de[1]=0,this.addCommands({cmd:()=>{for(const e of o)this.#w.has(e.id)&&e.translateInPage(a,r)},undo:()=>{for(const e of o)this.#w.has(e.id)&&e.translateInPage(-a,-r)},mustExec:!1})}),1e3);for(const n of o)n.translateInPage(e,t)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#I=new Map;for(const e of this.#ce)this.#I.set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#I)return!1;this.disableUserSelect(!1);const e=this.#I;this.#I=null;let t=!1;for(const[{x:n,y:a,pageIndex:r},o]of e)o.newX=n,o.newY=a,o.newPageIndex=r,t||=n!==o.savedX||a!==o.savedY||r!==o.savedPageIndex;if(!t)return!1;const n=(e,t,n,a)=>{if(this.#w.has(e.id)){const r=this.#T.get(a);r?e._setParentAndPosition(r,t,n):(e.pageIndex=a,e.x=t,e.y=n)}};return this.addCommands({cmd:()=>{for(const[t,{newX:a,newY:r,newPageIndex:o}]of e)n(t,a,r,o)},undo:()=>{for(const[t,{savedX:a,savedY:r,savedPageIndex:o}]of e)n(t,a,r,o)},mustExec:!0}),!0}dragSelectedEditors(e,t){if(this.#I)for(const n of this.#I.keys())n.drag(e,t)}rebuild(e){if(null===e.parent){const t=this.getLayer(e.pageIndex);t?(t.changeParent(e),t.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#ce.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return this.#k===e}getActive(){return this.#k}getMode(){return this.#oe}get imageManager(){return ere(this,"imageManager",new Ure)}getSelectionBoxes(e){if(!e)return null;const t=document.getSelection();for(let n=0,a=t.rangeCount;n<a;n++)if(!e.contains(t.getRangeAt(n).commonAncestorContainer))return null;const{x:n,y:a,width:r,height:o}=e.getBoundingClientRect();let c;switch(e.getAttribute("data-main-rotation")){case"90":c=(e,t,c,l)=>({x:(t-a)/o,y:1-(e+c-n)/r,width:l/o,height:c/r});break;case"180":c=(e,t,c,l)=>({x:1-(e+c-n)/r,y:1-(t+l-a)/o,width:c/r,height:l/o});break;case"270":c=(e,t,c,l)=>({x:1-(t+l-a)/o,y:(e-n)/r,width:l/o,height:c/r});break;default:c=(e,t,c,l)=>({x:(e-n)/r,y:(t-a)/o,width:c/r,height:l/o})}const l=[];for(let e=0,n=t.rangeCount;e<n;e++){const n=t.getRangeAt(e);if(!n.collapsed)for(const{x:e,y:t,width:a,height:r}of n.getClientRects())0!==a&&0!==r&&l.push(c(e,t,a,r))}return 0===l.length?null:l}addChangedExistingAnnotation({annotationElementId:e,id:t}){(this.#R||=new Map).set(e,t)}removeChangedExistingAnnotation({annotationElementId:e}){this.#R?.delete(e)}renderAnnotationElement(e){const t=this.#R?.get(e.data.id);if(!t)return;const n=this.#A.getRawValue(t);n&&(this.#oe!==Iae.NONE||n.hasBeenModified)&&n.renderAnnotationElement(e)}}class Yre{#l=null;#De=!1;#Pe=null;#Fe=null;#Ie=null;#je=null;#Be=!1;#Ue=null;#o=null;#We=null;#$e=null;#qe=!1;static#Ge=null;static _l10n=null;constructor(e){this.#o=e,this.#qe=e._uiManager.useNewAltTextFlow,Yre.#Ge||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(e){Yre._l10n??=e}async render(){const e=this.#Pe=document.createElement("button");e.className="altText",e.tabIndex="0";const t=this.#Fe=document.createElement("span");e.append(t),this.#qe?(e.classList.add("new"),e.setAttribute("data-l10n-id",Yre.#Ge.missing),t.setAttribute("data-l10n-id",Yre.#Ge["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const n=this.#o._uiManager._signal;e.addEventListener("contextmenu",wre,{signal:n}),e.addEventListener("pointerdown",(e=>e.stopPropagation()),{signal:n});const a=e=>{e.preventDefault(),this.#o._uiManager.editAltText(this.#o),this.#qe&&this.#o._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#Ye}})};return e.addEventListener("click",a,{capture:!0,signal:n}),e.addEventListener("keydown",(t=>{t.target===e&&"Enter"===t.key&&(this.#Be=!0,a(t))}),{signal:n}),await this.#Ke(),e}get#Ye(){return(this.#l?"added":null===this.#l&&this.guessedText&&"review")||"missing"}finish(){this.#Pe&&(this.#Pe.focus({focusVisible:this.#Be}),this.#Be=!1)}isEmpty(){return this.#qe?null===this.#l:!this.#l&&!this.#De}hasData(){return this.#qe?null!==this.#l||!!this.#We:this.isEmpty()}get guessedText(){return this.#We}async setGuessedText(e){null===this.#l&&(this.#We=e,this.#$e=await Yre._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e}),this.#Ke())}toggleAltTextBadge(e=!1){if(!this.#qe||this.#l)return this.#Ue?.remove(),void(this.#Ue=null);if(!this.#Ue){const e=this.#Ue=document.createElement("div");e.className="noAltTextBadge",this.#o.div.append(e)}this.#Ue.classList.toggle("hidden",!e)}serialize(e){let t=this.#l;return e||this.#We!==t||(t=this.#$e),{altText:t,decorative:this.#De,guessedText:this.#We,textWithDisclaimer:this.#$e}}get data(){return{altText:this.#l,decorative:this.#De}}set data({altText:e,decorative:t,guessedText:n,textWithDisclaimer:a,cancel:r=!1}){n&&(this.#We=n,this.#$e=a),this.#l===e&&this.#De===t||(r||(this.#l=e,this.#De=t),this.#Ke())}toggle(e=!1){this.#Pe&&(!e&&this.#je&&(clearTimeout(this.#je),this.#je=null),this.#Pe.disabled=!e)}shown(){this.#o._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#Ye}})}destroy(){this.#Pe?.remove(),this.#Pe=null,this.#Fe=null,this.#Ie=null,this.#Ue?.remove(),this.#Ue=null}async#Ke(){const e=this.#Pe;if(!e)return;if(this.#qe){if(e.classList.toggle("done",!!this.#l),e.setAttribute("data-l10n-id",Yre.#Ge[this.#Ye]),this.#Fe?.setAttribute("data-l10n-id",Yre.#Ge[`${this.#Ye}-label`]),!this.#l)return void this.#Ie?.remove()}else{if(!this.#l&&!this.#De)return e.classList.remove("done"),void this.#Ie?.remove();e.classList.add("done"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let t=this.#Ie;if(!t){this.#Ie=t=document.createElement("span"),t.className="tooltip",t.setAttribute("role","tooltip"),t.id=`alt-text-tooltip-${this.#o.id}`;const n=100,a=this.#o._uiManager._signal;a.addEventListener("abort",(()=>{clearTimeout(this.#je),this.#je=null}),{once:!0}),e.addEventListener("mouseenter",(()=>{this.#je=setTimeout((()=>{this.#je=null,this.#Ie.classList.add("show"),this.#o._reportTelemetry({action:"alt_text_tooltip"})}),n)}),{signal:a}),e.addEventListener("mouseleave",(()=>{this.#je&&(clearTimeout(this.#je),this.#je=null),this.#Ie?.classList.remove("show")}),{signal:a})}this.#De?t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(t.removeAttribute("data-l10n-id"),t.textContent=this.#l),t.parentNode||e.append(t);const n=this.#o.getImageForAltText();n?.setAttribute("aria-describedby",t.id)}}class Kre{#me;#Xe=!1;#Qe=null;#Je;#Ze;#et;#tt;#nt;#at=null;#rt;#ot=null;constructor({container:e,isPinchingDisabled:t=null,isPinchingStopped:n=null,onPinchStart:a=null,onPinching:r=null,onPinchEnd:o=null,signal:c}){this.#me=e,this.#Qe=n,this.#Je=t,this.#Ze=a,this.#et=r,this.#tt=o,this.#rt=new AbortController,this.#nt=AbortSignal.any([c,this.#rt.signal]),e.addEventListener("touchstart",this.#ct.bind(this),{passive:!1,signal:this.#nt})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return ere(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#ct(e){if(this.#Je?.()||e.touches.length<2)return;if(!this.#ot){this.#ot=new AbortController;const e=AbortSignal.any([this.#nt,this.#ot.signal]),t=this.#me,n={signal:e,passive:!1};t.addEventListener("touchmove",this.#lt.bind(this),n),t.addEventListener("touchend",this.#it.bind(this),n),t.addEventListener("touchcancel",this.#it.bind(this),n),this.#Ze?.()}if(Tre(e),2!==e.touches.length||this.#Qe?.())return void(this.#at=null);let[t,n]=e.touches;t.identifier>n.identifier&&([t,n]=[n,t]),this.#at={touch0X:t.screenX,touch0Y:t.screenY,touch1X:n.screenX,touch1Y:n.screenY}}#lt(e){if(!this.#at||2!==e.touches.length)return;let[t,n]=e.touches;t.identifier>n.identifier&&([t,n]=[n,t]);const{screenX:a,screenY:r}=t,{screenX:o,screenY:c}=n,l=this.#at,{touch0X:i,touch0Y:s,touch1X:h,touch1Y:d}=l,u=h-i,m=d-s,p=o-a,v=c-r,f=Math.hypot(p,v)||1,z=Math.hypot(u,m)||1;if(!this.#Xe&&Math.abs(z-f)<=Kre.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=a,l.touch0Y=r,l.touch1X=o,l.touch1Y=c,e.preventDefault(),!this.#Xe)return void(this.#Xe=!0);const g=[(a+o)/2,(r+c)/2];this.#et?.(g,z,f)}#it(e){this.#ot.abort(),this.#ot=null,this.#tt?.(),this.#at&&(e.preventDefault(),this.#at=null,this.#Xe=!1)}destroy(){this.#rt?.abort(),this.#rt=null}}class Xre{#st=null;#ht=null;#l=null;#dt=!1;#ut=null;#mt="";#pt=!1;#vt=null;#ft=null;#zt=null;#gt=null;#yt="";#Mt=!1;#Et=null;#bt=!1;#Ht=!1;#Vt=!1;#Ct=null;#Lt=0;#xt=0;#St=null;#kt=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#wt=!1;#Tt=Xre._zIndex++;static _borderLineWidth=-1;static _colorManager=new qre;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const e=Xre.prototype._resizeWithKeyboard,t=Gre.TRANSLATE_SMALL,n=Gre.TRANSLATE_BIG;return ere(this,"_resizerKeyboardManager",new $re([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-t,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-n,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[t,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[n,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-t]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-n]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,t]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,n]}],[["Escape","mac+Escape"],Xre.prototype._stopResizingWithKeyboard]]))}constructor(e){this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null;const{rotation:t,rawDims:{pageWidth:n,pageHeight:a,pageX:r,pageY:o}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,a],this.pageTranslation=[r,o];const[c,l]=this.parentDimensions;this.x=e.x/c,this.y=e.y/l,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return ere(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){const t=new Qre({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}static initialize(e,t){if(Xre._l10n??=e,Xre._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),-1!==Xre._borderLineWidth)return;const n=getComputedStyle(document.documentElement);Xre._borderLineWidth=parseFloat(n.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){Qae("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#wt}set _isDraggable(e){this.#wt=e,this.div?.classList.toggle("draggable",e)}get isEnterHandled(){return!0}center(){const[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(2*e),this.y+=this.width*e/(2*t);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*t/(2*e),this.y-=this.width*e/(2*t);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#Tt}setParent(e){null!==e?(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions):this.#Ot(),this.parent=e}focusin(e){this._focusEventsAllowed&&(this.#Mt?this.#Mt=!1:this.parent.setSelected(this))}focusout(e){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const t=e.relatedTarget;t?.closest(`#${this.id}`)||(e.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,n,a){const[r,o]=this.parentDimensions;[n,a]=this.screenToPageTranslation(n,a),this.x=(e+n)/r,this.y=(t+a)/o,this.fixAndSetPosition()}#At([e,t],n,a){[n,a]=this.screenToPageTranslation(n,a),this.x+=n/e,this.y+=a/t,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(e,t){this.#At(this.parentDimensions,e,t)}translateInPage(e,t){this.#Et||=[this.x,this.y,this.width,this.height],this.#At(this.pageDimensions,e,t),this.div.scrollIntoView({block:"nearest"})}drag(e,t){this.#Et||=[this.x,this.y,this.width,this.height];const{div:n,parentDimensions:[a,r]}=this;if(this.x+=e/a,this.y+=t/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:e,y:t}=this.div.getBoundingClientRect();this.parent.findNewParent(this,e,t)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:o,y:c}=this;const[l,i]=this.getBaseTranslation();o+=l,c+=i;const{style:s}=n;s.left=`${(100*o).toFixed(2)}%`,s.top=`${(100*c).toFixed(2)}%`,this._onTranslating(o,c),n.scrollIntoView({block:"nearest"})}_onTranslating(e,t){}_onTranslated(e,t){}get _hasBeenMoved(){return!!this.#Et&&(this.#Et[0]!==this.x||this.#Et[1]!==this.y)}get _hasBeenResized(){return!!this.#Et&&(this.#Et[2]!==this.width||this.#Et[3]!==this.height)}getBaseTranslation(){const[e,t]=this.parentDimensions,{_borderLineWidth:n}=Xre,a=n/e,r=n/t;switch(this.rotation){case 90:return[-a,r];case 180:return[a,r];case 270:return[a,-r];default:return[-a,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){const{div:{style:t},pageDimensions:[n,a]}=this;let{x:r,y:o,width:c,height:l}=this;if(c*=n,l*=a,r*=n,o*=a,this._mustFixPosition)switch(e){case 0:r=Math.max(0,Math.min(n-c,r)),o=Math.max(0,Math.min(a-l,o));break;case 90:r=Math.max(0,Math.min(n-l,r)),o=Math.min(a,Math.max(c,o));break;case 180:r=Math.min(n,Math.max(c,r)),o=Math.min(a,Math.max(l,o));break;case 270:r=Math.min(n,Math.max(l,r)),o=Math.max(0,Math.min(a-c,o))}this.x=r/=n,this.y=o/=a;const[i,s]=this.getBaseTranslation();r+=i,o+=s,t.left=`${(100*r).toFixed(2)}%`,t.top=`${(100*o).toFixed(2)}%`,this.moveInDOM()}static#Rt(e,t,n){switch(n){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}screenToPageTranslation(e,t){return Xre.#Rt(e,t,this.parentRotation)}pageTranslationToScreen(e,t){return Xre.#Rt(e,t,360-this.parentRotation)}#Nt(e){switch(e){case 90:{const[e,t]=this.pageDimensions;return[0,-e/t,t/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,t]=this.pageDimensions;return[0,e/t,-t/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:e,pageDimensions:[t,n]}=this;return[t*e,n*e]}setDims(e,t){const[n,a]=this.parentDimensions,{style:r}=this.div;r.width=`${(100*e/n).toFixed(2)}%`,this.#pt||(r.height=`${(100*t/a).toFixed(2)}%`)}fixDims(){const{style:e}=this.div,{height:t,width:n}=e,a=n.endsWith("%"),r=!this.#pt&&t.endsWith("%");if(a&&r)return;const[o,c]=this.parentDimensions;a||(e.width=`${(100*parseFloat(n)/o).toFixed(2)}%`),this.#pt||r||(e.height=`${(100*parseFloat(t)/c).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#_t(){if(this.#vt)return;this.#vt=document.createElement("div"),this.#vt.classList.add("resizers");const e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],t=this._uiManager._signal;for(const n of e){const e=document.createElement("div");this.#vt.append(e),e.classList.add("resizer",n),e.setAttribute("data-resizer-name",n),e.addEventListener("pointerdown",this.#Dt.bind(this,n),{signal:t}),e.addEventListener("contextmenu",wre,{signal:t}),e.tabIndex=-1}this.div.prepend(this.#vt)}#Dt(e,t){t.preventDefault();const{isMac:n}=ure.platform;if(0!==t.button||t.ctrlKey&&n)return;this.#l?.toggle(!1);const a=this._isDraggable;this._isDraggable=!1,this.#ft=[t.screenX,t.screenY];const r=new AbortController,o=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#Pt.bind(this,e),{passive:!0,capture:!0,signal:o}),window.addEventListener("touchmove",Tre,{passive:!1,signal:o}),window.addEventListener("contextmenu",wre,{signal:o}),this.#zt={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const c=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;const i=()=>{r.abort(),this.parent.togglePointerEvents(!0),this.#l?.toggle(!0),this._isDraggable=a,this.parent.div.style.cursor=c,this.div.style.cursor=l,this.#Ft()};window.addEventListener("pointerup",i,{signal:o}),window.addEventListener("blur",i,{signal:o})}#It(e,t,n,a){this.width=n,this.height=a,this.x=e,this.y=t;const[r,o]=this.parentDimensions;this.setDims(r*n,o*a),this.fixAndSetPosition(),this._onResized()}_onResized(){}#Ft(){if(!this.#zt)return;const{savedX:e,savedY:t,savedWidth:n,savedHeight:a}=this.#zt;this.#zt=null;const r=this.x,o=this.y,c=this.width,l=this.height;r===e&&o===t&&c===n&&l===a||this.addCommands({cmd:this.#It.bind(this,r,o,c,l),undo:this.#It.bind(this,e,t,n,a),mustExec:!0})}static _round(e){return Math.round(1e4*e)/1e4}#Pt(e,t){const[n,a]=this.parentDimensions,r=this.x,o=this.y,c=this.width,l=this.height,i=Xre.MIN_SIZE/n,s=Xre.MIN_SIZE/a,h=this.#Nt(this.rotation),d=(e,t)=>[h[0]*e+h[2]*t,h[1]*e+h[3]*t],u=this.#Nt(360-this.rotation);let m,p,v=!1,f=!1;switch(e){case"topLeft":v=!0,m=(e,t)=>[0,0],p=(e,t)=>[e,t];break;case"topMiddle":m=(e,t)=>[e/2,0],p=(e,t)=>[e/2,t];break;case"topRight":v=!0,m=(e,t)=>[e,0],p=(e,t)=>[0,t];break;case"middleRight":f=!0,m=(e,t)=>[e,t/2],p=(e,t)=>[0,t/2];break;case"bottomRight":v=!0,m=(e,t)=>[e,t],p=(e,t)=>[0,0];break;case"bottomMiddle":m=(e,t)=>[e/2,t],p=(e,t)=>[e/2,0];break;case"bottomLeft":v=!0,m=(e,t)=>[0,t],p=(e,t)=>[e,0];break;case"middleLeft":f=!0,m=(e,t)=>[0,t/2],p=(e,t)=>[e,t/2]}const z=m(c,l),g=p(c,l);let y=d(...g);const M=Xre._round(r+y[0]),E=Xre._round(o+y[1]);let b,H,V=1,C=1;if(t.fromKeyboard)({deltaX:b,deltaY:H}=t);else{const{screenX:e,screenY:n}=t,[a,r]=this.#ft;[b,H]=this.screenToPageTranslation(e-a,n-r),this.#ft[0]=e,this.#ft[1]=n}var L,x;if([b,H]=(L=b/n,x=H/a,[u[0]*L+u[2]*x,u[1]*L+u[3]*x]),v){const e=Math.hypot(c,l);V=C=Math.max(Math.min(Math.hypot(g[0]-z[0]-b,g[1]-z[1]-H)/e,1/c,1/l),i/c,s/l)}else f?V=Math.max(i,Math.min(1,Math.abs(g[0]-z[0]-b)))/c:C=Math.max(s,Math.min(1,Math.abs(g[1]-z[1]-H)))/l;const S=Xre._round(c*V),k=Xre._round(l*C);y=d(...p(S,k));const w=M-y[0],T=E-y[1];this.#Et||=[this.x,this.y,this.width,this.height],this.width=S,this.height=k,this.x=w,this.y=T,this.setDims(n*S,a*k),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#l?.finish()}async addEditToolbar(){return this._editToolbar||this.#Ht||(this._editToolbar=new Fre(this),this.div.append(this._editToolbar.render()),this.#l&&await this._editToolbar.addAltText(this.#l)),this._editToolbar}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#l?.destroy())}addContainer(e){const t=this._editToolbar?.div;t?t.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#l||(Yre.initialize(Xre._l10n),this.#l=new Yre(this),this.#st&&(this.#l.data=this.#st,this.#st=null),await this.addEditToolbar())}get altTextData(){return this.#l?.data}set altTextData(e){this.#l&&(this.#l.data=e)}get guessedAltText(){return this.#l?.guessedText}async setGuessedAltText(e){await(this.#l?.setGuessedText(e))}serializeAltText(e){return this.#l?.serialize(e)}hasAltText(){return!!this.#l&&!this.#l.isEmpty()}hasAltTextData(){return this.#l?.hasData()??!1}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#dt?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#jt();const[e,t]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*t/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/t).toFixed(2)}%`);const[n,a]=this.getInitialTranslation();return this.translate(n,a),jre(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#kt||=new Kre({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#Bt.bind(this),onPinching:this.#Ut.bind(this),onPinchEnd:this.#Wt.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#Bt(){this.#zt={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#l?.toggle(!1),this.parent.togglePointerEvents(!1)}#Ut(e,t,n){let a=n/t*.7+1-.7;if(1===a)return;const r=this.#Nt(this.rotation),o=(e,t)=>[r[0]*e+r[2]*t,r[1]*e+r[3]*t],[c,l]=this.parentDimensions,i=this.x,s=this.y,h=this.width,d=this.height,u=Xre.MIN_SIZE/c,m=Xre.MIN_SIZE/l;a=Math.max(Math.min(a,1/h,1/d),u/h,m/d);const p=Xre._round(h*a),v=Xre._round(d*a);if(p===h&&v===d)return;this.#Et||=[i,s,h,d];const f=o(h/2,d/2),z=Xre._round(i+f[0]),g=Xre._round(s+f[1]),y=o(p/2,v/2);this.x=z-y[0],this.y=g-y[1],this.width=p,this.height=v,this.setDims(c*p,l*v),this.fixAndSetPosition(),this._onResizing()}#Wt(){this.#l?.toggle(!0),this.parent.togglePointerEvents(!0),this.#Ft()}pointerdown(e){const{isMac:t}=ure.platform;0!==e.button||e.ctrlKey&&t?e.preventDefault():(this.#Mt=!0,this._isDraggable?this.#$t(e):this.#qt(e))}get isSelected(){return this._uiManager.isSelected(this)}#qt(e){const{isMac:t}=ure.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)}#$t(e){const{isSelected:t}=this;this._uiManager.setUpDragSession();let n=!1;const a=new AbortController,r=this._uiManager.combinedSignal(a),o={capture:!0,passive:!1,signal:r},c=e=>{a.abort(),this.#ut=null,this.#Mt=!1,this._uiManager.endDragSession()||this.#qt(e),n&&this._onStopDragging()};t&&(this.#Lt=e.clientX,this.#xt=e.clientY,this.#ut=e.pointerId,this.#mt=e.pointerType,window.addEventListener("pointermove",(e=>{n||(n=!0,this._onStartDragging());const{clientX:t,clientY:a,pointerId:r}=e;if(r!==this.#ut)return void Tre(e);const[o,c]=this.screenToPageTranslation(t-this.#Lt,a-this.#xt);this.#Lt=t,this.#xt=a,this._uiManager.dragSelectedEditors(o,c)}),o),window.addEventListener("touchmove",Tre,o),window.addEventListener("pointerdown",(e=>{e.pointerType===this.#mt&&(this.#kt||e.isPrimary)&&c(e),Tre(e)}),o));const l=e=>{this.#ut&&this.#ut!==e.pointerId?Tre(e):c(e)};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#Ct&&clearTimeout(this.#Ct),this.#Ct=setTimeout((()=>{this.#Ct=null,this.parent?.moveEditorInDOM(this)}),0)}_setParentAndPosition(e,t,n){e.changeParent(this),this.x=t,this.y=n,this.fixAndSetPosition(),this._onTranslated()}getRect(e,t,n=this.rotation){const a=this.parentScale,[r,o]=this.pageDimensions,[c,l]=this.pageTranslation,i=e/a,s=t/a,h=this.x*r,d=this.y*o,u=this.width*r,m=this.height*o;switch(n){case 0:return[h+i+c,o-d-s-m+l,h+i+u+c,o-d-s+l];case 90:return[h+s+c,o-d+i+l,h+s+m+c,o-d+i+u+l];case 180:return[h-i-u+c,o-d+s+l,h-i+c,o-d+s+m+l];case 270:return[h-s-m+c,o-d-i-u+l,h-s+c,o-d-i+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,t){const[n,a,r,o]=e,c=r-n,l=o-a;switch(this.rotation){case 0:return[n,t-o,c,l];case 90:return[n,t-a,l,c];case 180:return[r,t-a,c,l];case 270:return[r,t-o,l,c];default:throw new Error("Invalid rotation")}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){this.#Ht=!0}disableEditMode(){this.#Ht=!1}isInEditMode(){return this.#Ht}shouldGetKeyboardEvents(){return this.#Vt}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:e,left:t,bottom:n,right:a}=this.getClientDimensions(),{innerHeight:r,innerWidth:o}=window;return t<o&&a>0&&e<r&&n>0}#jt(){if(this.#gt||!this.div)return;this.#gt=new AbortController;const e=this._uiManager.combinedSignal(this.#gt);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:e}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:e})}rebuild(){this.#jt()}rotate(e){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(e=!1,t=null){Qae("An editor must be serializable")}static async deserialize(e,t,n){const a=new this.prototype.constructor({parent:t,id:t.getNextId(),uiManager:n});a.rotation=e.rotation,a.#st=e.accessibilityData;const[r,o]=a.pageDimensions,[c,l,i,s]=a.getRectInCurrentCoords(e.rect,o);return a.x=c/r,a.y=l/o,a.width=i/r,a.height=s/o,a}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#gt?.abort(),this.#gt=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#Ct&&(clearTimeout(this.#Ct),this.#Ct=null),this.#Ot(),this.removeEditToolbar(),this.#St){for(const e of this.#St.values())clearTimeout(e);this.#St=null}this.parent=null,this.#kt?.destroy(),this.#kt=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#_t(),this.#vt.classList.remove("hidden"),jre(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(e){if(!this.isResizable||e.target!==this.div||"Enter"!==e.key)return;this._uiManager.setSelected(this),this.#zt={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const t=this.#vt.children;if(!this.#ht){this.#ht=Array.from(t);const e=this.#Gt.bind(this),n=this.#Yt.bind(this),a=this._uiManager._signal;for(const t of this.#ht){const r=t.getAttribute("data-resizer-name");t.setAttribute("role","spinbutton"),t.addEventListener("keydown",e,{signal:a}),t.addEventListener("blur",n,{signal:a}),t.addEventListener("focus",this.#Kt.bind(this,r),{signal:a}),t.setAttribute("data-l10n-id",Xre._l10nResizer[r])}}const n=this.#ht[0];let a=0;for(const e of t){if(e===n)break;a++}const r=(360-this.rotation+this.parentRotation)%360/90*(this.#ht.length/4);if(r!==a){if(r<a)for(let e=0;e<a-r;e++)this.#vt.append(this.#vt.firstChild);else if(r>a)for(let e=0;e<r-a;e++)this.#vt.firstChild.before(this.#vt.lastChild);let e=0;for(const n of t){const t=this.#ht[e++].getAttribute("data-resizer-name");n.setAttribute("data-l10n-id",Xre._l10nResizer[t])}}this.#Xt(0),this.#Vt=!0,this.#vt.firstChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}#Gt(e){Xre._resizerKeyboardManager.exec(this,e)}#Yt(e){this.#Vt&&e.relatedTarget?.parentNode!==this.#vt&&this.#Ot()}#Kt(e){this.#yt=this.#Vt?e:""}#Xt(e){if(this.#ht)for(const t of this.#ht)t.tabIndex=e}_resizeWithKeyboard(e,t){this.#Vt&&this.#Pt(this.#yt,{deltaX:e,deltaY:t,fromKeyboard:!0})}#Ot(){this.#Vt=!1,this.#Xt(-1),this.#Ft()}_stopResizingWithKeyboard(){this.#Ot(),this.div.focus()}select(){this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar?(this._editToolbar?.show(),this.#l?.toggleAltTextBadge(!1)):this.addEditToolbar().then((()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()}))}unselect(){this.#vt?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#l?.toggleAltTextBadge(!0)}updateParams(e,t){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#bt}set isEditing(e){this.#bt=e,this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(e,t){this.#pt=!0;const n=e/t,{style:a}=this.div;a.aspectRatio=n,a.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,t=!1){if(t){this.#St||=new Map;const{action:t}=e;let n=this.#St.get(t);return n&&clearTimeout(n),n=setTimeout((()=>{this._reportTelemetry(e),this.#St.delete(t),0===this.#St.size&&(this.#St=null)}),Xre._telemetryTimeout),void this.#St.set(t,n)}e.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(e=this._isVisible){this.div.classList.toggle("hidden",!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),this.#dt=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#dt=!0}renderAnnotationElement(e){let t=e.container.querySelector(".annotationContent");if(t){if("CANVAS"===t.nodeName){const e=t;t=document.createElement("div"),t.classList.add("annotationContent",this.editorType),e.before(t)}}else t=document.createElement("div"),t.classList.add("annotationContent",this.editorType),e.container.prepend(t);return t}resetAnnotationElement(e){const{firstChild:t}=e.container;"DIV"===t?.nodeName&&t.classList.contains("annotationContent")&&t.remove()}}class Qre extends Xre{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Jre=3285377520,Zre=4294901760,eoe=65535;class toe{constructor(e){this.h1=e?4294967295&e:Jre,this.h2=e?4294967295&e:Jre}update(e){let t,n;if("string"==typeof e){t=new Uint8Array(2*e.length),n=0;for(let a=0,r=e.length;a<r;a++){const r=e.charCodeAt(a);r<=255?t[n++]=r:(t[n++]=r>>>8,t[n++]=255&r)}}else{if(!ArrayBuffer.isView(e))throw new Error("Invalid data format, must be a string or TypedArray.");t=e.slice(),n=t.byteLength}const a=n>>2,r=n-4*a,o=new Uint32Array(t.buffer,0,a);let c=0,l=0,i=this.h1,s=this.h2;const h=3432918353,d=461845907,u=11601,m=13715;for(let e=0;e<a;e++)1&e?(c=o[e],c=c*h&Zre|c*u&eoe,c=c<<15|c>>>17,c=c*d&Zre|c*m&eoe,i^=c,i=i<<13|i>>>19,i=5*i+3864292196):(l=o[e],l=l*h&Zre|l*u&eoe,l=l<<15|l>>>17,l=l*d&Zre|l*m&eoe,s^=l,s=s<<13|s>>>19,s=5*s+3864292196);switch(c=0,r){case 3:c^=t[4*a+2]<<16;case 2:c^=t[4*a+1]<<8;case 1:c^=t[4*a],c=c*h&Zre|c*u&eoe,c=c<<15|c>>>17,c=c*d&Zre|c*m&eoe,1&a?i^=c:s^=c}this.h1=i,this.h2=s}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=3981806797*e&Zre|36045*e&eoe,t=4283543511*t&Zre|(2950163797*(t<<16|e>>>16)&Zre)>>>16,e^=t>>>1,e=444984403*e&Zre|60499*e&eoe,t=3301882366*t&Zre|(3120437893*(t<<16|e>>>16)&Zre)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,"0")+(t>>>0).toString(16).padStart(8,"0")}}const noe=Object.freeze({map:null,hash:"",transfer:void 0});class aoe{#Qt=!1;#Jt=null;#Zt=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,t){const n=this.#Zt.get(e);return void 0===n?t:Object.assign(t,n)}getRawValue(e){return this.#Zt.get(e)}remove(e){if(this.#Zt.delete(e),0===this.#Zt.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const e of this.#Zt.values())if(e instanceof Xre)return;this.onAnnotationEditor(null)}}setValue(e,t){const n=this.#Zt.get(e);let a=!1;if(void 0!==n)for(const[e,r]of Object.entries(t))n[e]!==r&&(a=!0,n[e]=r);else a=!0,this.#Zt.set(e,t);a&&this.#en(),t instanceof Xre&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(t.constructor._type)}has(e){return this.#Zt.has(e)}getAll(){return this.#Zt.size>0?dre(this.#Zt):null}setAll(e){for(const[t,n]of Object.entries(e))this.setValue(t,n)}get size(){return this.#Zt.size}#en(){this.#Qt||(this.#Qt=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#Qt&&(this.#Qt=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new roe(this)}get serializable(){if(0===this.#Zt.size)return noe;const e=new Map,t=new toe,n=[],a=Object.create(null);let r=!1;for(const[n,o]of this.#Zt){const c=o instanceof Xre?o.serialize(!1,a):o;c&&(e.set(n,c),t.update(`${n}:${JSON.stringify(c)}`),r||=!!c.bitmap)}if(r)for(const t of e.values())t.bitmap&&n.push(t.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:n}:noe}get editorStats(){let e=null;const t=new Map;for(const n of this.#Zt.values()){if(!(n instanceof Xre))continue;const a=n.telemetryFinalData;if(!a)continue;const{type:r}=a;t.has(r)||t.set(r,Object.getPrototypeOf(n).constructor),e||=Object.create(null);const o=e[r]||=new Map;for(const[e,t]of Object.entries(a)){if("type"===e)continue;let n=o.get(e);n||(n=new Map,o.set(e,n));const a=n.get(t)??0;n.set(t,a+1)}}for(const[n,a]of t)e[n]=a.computeTelemetryFinalData(e[n]);return e}resetModifiedIds(){this.#Jt=null}get modifiedIds(){if(this.#Jt)return this.#Jt;const e=[];for(const t of this.#Zt.values())t instanceof Xre&&t.annotationElementId&&t.serialize()&&e.push(t.annotationElementId);return this.#Jt={ids:new Set(e),hash:e.join(",")}}}class roe extends aoe{#tn;constructor(e){super();const{map:t,hash:n,transfer:a}=e.serializable,r=structuredClone(t,a?{transfer:a}:null);this.#tn={map:r,hash:n,transfer:a}}get print(){Qae("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#tn}get modifiedIds(){return ere(this,"modifiedIds",{ids:new Set,hash:""})}}class ooe{#nn=new Set;constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const t=this.styleElement.sheet;t.insertRule(e,t.cssRules.length)}clear(){for(const e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),this.#nn.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:e,_inspectFont:t}){if(e&&!this.#nn.has(e.loadedName))if(Jae(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:n,src:a,style:r}=e,o=new FontFace(n,a,r);this.addNativeFontFace(o);try{await o.load(),this.#nn.add(n),t?.(e)}catch{Xae(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}}else Qae("Not implemented: loadSystemFont without the Font Loading API.")}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo)return void await this.loadSystemFont(e);if(this.isFontLoadingAPISupported){const t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{await t.loaded}catch(n){throw Xae(`Failed to load font '${t.family}': '${n}'.`),e.disableFontFace=!0,n}}return}const t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;await new Promise((t=>{const n=this._queueLoadingCallback(t);this._prepareFontLoadEvent(e,n)}))}}get isFontLoadingAPISupported(){return ere(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){let e=!1;return(Nae||"undefined"!=typeof navigator&&"string"==typeof navigator?.userAgent&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(e=!0),ere(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(e){const{loadingRequests:t}=this,n={done:!1,complete:function(){for(Jae(!n.done,"completeRequest() cannot be called twice."),n.done=!0;t.length>0&&t[0].done;){const e=t.shift();setTimeout(e.callback,0)}},callback:e};return t.push(n),n}get _loadTestFont(){return ere(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(e,t){function n(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|255&e.charCodeAt(t+3)}function a(e,t,n,a){return e.substring(0,t)+a+e.substring(t+n)}let r,o;const c=this._document.createElement("canvas");c.width=1,c.height=1;const l=c.getContext("2d");let i=0;const s=`lt${Date.now()}${this.loadTestFontId++}`;let h=this._loadTestFont;h=a(h,976,s.length,s);const d=1482184792;let u=n(h,16);for(r=0,o=s.length-3;r<o;r+=4)u=u-d+n(s,r)|0;r<s.length&&(u=u-d+n(s+"XXX",r)|0),h=a(h,16,4,function(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)}(u));const m=`@font-face {font-family:"${s}";src:url(data:font/opentype;base64,${btoa(h)});}`;this.insertRule(m);const p=this._document.createElement("div");p.style.visibility="hidden",p.style.width=p.style.height="10px",p.style.position="absolute",p.style.top=p.style.left="0px";for(const t of[e.loadedName,s]){const e=this._document.createElement("span");e.textContent="Hi",e.style.fontFamily=t,p.append(e)}this._document.body.append(p),function e(t,n){if(++i>30)return Xae("Load test font never loaded."),void n();l.font="30px "+t,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0?n():setTimeout(e.bind(null,t,n))}(s,(()=>{p.remove(),t.complete()}))}}class coe{constructor(e,{disableFontFace:t=!1,fontExtraProperties:n=!1,inspectFont:a=null}){this.compiledGlyphs=Object.create(null);for(const t in e)this[t]=e[t];this.disableFontFace=!0===t,this.fontExtraProperties=!0===n,this._inspectFont=a}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let e;if(this.cssFontInfo){const t={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(t.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,t)}else e=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),e}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${t=this.data,Uint8Array.prototype.toBase64?t.toBase64():btoa(sre(t))});`;var t;let n;if(this.cssFontInfo){let t=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(t+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),n=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${t}src:${e}}`}else n=`@font-face {font-family:"${this.loadedName}";src:${e}}`;return this._inspectFont?.(this,e),n}getPathGenerator(e,t){if(void 0!==this.compiledGlyphs[t])return this.compiledGlyphs[t];const n=this.loadedName+"_path_"+t;let a;try{a=e.get(n)}catch(e){Xae(`getPathGenerator - ignoring character: "${e}".`)}const r=new Path2D(a||"");return this.fontExtraProperties||e.delete(n),this.compiledGlyphs[t]=r}}function loe(){}function ioe(e){if(e instanceof ire||e instanceof rre||e instanceof ore||e instanceof nre||e instanceof cre||e instanceof are)return e;switch(e instanceof Error||"object"==typeof e&&null!==e||Qae('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),e.name){case"AbortException":return new ire(e.message);case"InvalidPDFException":return new rre(e.message);case"MissingPDFException":return new ore(e.message);case"PasswordException":return new nre(e.message,e.code);case"UnexpectedResponseException":return new cre(e.message,e.status);case"UnknownErrorException":return new are(e.message,e.details)}return new are(e.message,e.toString())}class soe{#an=new AbortController;constructor(e,t,n){this.sourceName=e,this.targetName=t,this.comObj=n,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),n.addEventListener("message",this.#rn.bind(this),{signal:this.#an.signal})}#rn({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream)return void this.#on(e);if(e.callback){const t=e.callbackId,n=this.callbackCapabilities[t];if(!n)throw new Error(`Cannot resolve callback ${t}`);if(delete this.callbackCapabilities[t],1===e.callback)n.resolve(e.data);else{if(2!==e.callback)throw new Error("Unexpected callback case");n.reject(ioe(e.reason))}return}const t=this.actionHandler[e.action];if(!t)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const n=this.sourceName,a=e.sourceName,r=this.comObj;Promise.try(t,e.data).then((function(t){r.postMessage({sourceName:n,targetName:a,callback:1,callbackId:e.callbackId,data:t})}),(function(t){r.postMessage({sourceName:n,targetName:a,callback:2,callbackId:e.callbackId,reason:ioe(t)})}))}else e.streamId?this.#cn(e):t(e.data)}on(e,t){const n=this.actionHandler;if(n[e])throw new Error(`There is already an actionName called "${e}"`);n[e]=t}send(e,t,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},n)}sendWithPromise(e,t,n){const a=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[a]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:a,data:t},n)}catch(e){r.reject(e)}return r.promise}sendWithStream(e,t,n,a){const r=this.streamId++,o=this.sourceName,c=this.targetName,l=this.comObj;return new ReadableStream({start:n=>{const i=Promise.withResolvers();return this.streamControllers[r]={controller:n,startCall:i,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:o,targetName:c,action:e,streamId:r,data:t,desiredSize:n.desiredSize},a),i.promise},pull:e=>{const t=Promise.withResolvers();return this.streamControllers[r].pullCall=t,l.postMessage({sourceName:o,targetName:c,stream:6,streamId:r,desiredSize:e.desiredSize}),t.promise},cancel:e=>{Jae(e instanceof Error,"cancel must have a valid reason");const t=Promise.withResolvers();return this.streamControllers[r].cancelCall=t,this.streamControllers[r].isClosed=!0,l.postMessage({sourceName:o,targetName:c,stream:1,streamId:r,reason:ioe(e)}),t.promise}},n)}#cn(e){const t=e.streamId,n=this.sourceName,a=e.sourceName,r=this.comObj,o=this,c=this.actionHandler[e.action],l={enqueue(e,o=1,c){if(this.isCancelled)return;const l=this.desiredSize;this.desiredSize-=o,l>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:n,targetName:a,stream:4,streamId:t,chunk:e},c)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:n,targetName:a,stream:3,streamId:t}),delete o.streamSinks[t])},error(e){Jae(e instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:n,targetName:a,stream:5,streamId:t,reason:ioe(e)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[t]=l,Promise.try(c,e.data,l).then((function(){r.postMessage({sourceName:n,targetName:a,stream:8,streamId:t,success:!0})}),(function(e){r.postMessage({sourceName:n,targetName:a,stream:8,streamId:t,reason:ioe(e)})}))}#on(e){const t=e.streamId,n=this.sourceName,a=e.sourceName,r=this.comObj,o=this.streamControllers[t],c=this.streamSinks[t];switch(e.stream){case 8:e.success?o.startCall.resolve():o.startCall.reject(ioe(e.reason));break;case 7:e.success?o.pullCall.resolve():o.pullCall.reject(ioe(e.reason));break;case 6:if(!c){r.postMessage({sourceName:n,targetName:a,stream:7,streamId:t,success:!0});break}c.desiredSize<=0&&e.desiredSize>0&&c.sinkCapability.resolve(),c.desiredSize=e.desiredSize,Promise.try(c.onPull||loe).then((function(){r.postMessage({sourceName:n,targetName:a,stream:7,streamId:t,success:!0})}),(function(e){r.postMessage({sourceName:n,targetName:a,stream:7,streamId:t,reason:ioe(e)})}));break;case 4:if(Jae(o,"enqueue should have stream controller"),o.isClosed)break;o.controller.enqueue(e.chunk);break;case 3:if(Jae(o,"close should have stream controller"),o.isClosed)break;o.isClosed=!0,o.controller.close(),this.#ln(o,t);break;case 5:Jae(o,"error should have stream controller"),o.controller.error(ioe(e.reason)),this.#ln(o,t);break;case 2:e.success?o.cancelCall.resolve():o.cancelCall.reject(ioe(e.reason)),this.#ln(o,t);break;case 1:if(!c)break;const l=ioe(e.reason);Promise.try(c.onCancel||loe,l).then((function(){r.postMessage({sourceName:n,targetName:a,stream:2,streamId:t,success:!0})}),(function(e){r.postMessage({sourceName:n,targetName:a,stream:2,streamId:t,reason:ioe(e)})})),c.sinkCapability.reject(l),c.isCancelled=!0,delete this.streamSinks[t];break;default:throw new Error("Unexpected stream case")}}async#ln(e,t){await Promise.allSettled([e.startCall?.promise,e.pullCall?.promise,e.cancelCall?.promise]),delete this.streamControllers[t]}destroy(){this.#an?.abort(),this.#an=null}}class hoe{#in=!1;constructor({enableHWA:e=!1}){this.#in=e}create(e,t){if(e<=0||t<=0)throw new Error("Invalid canvas size");const n=this._createCanvas(e,t);return{canvas:n,context:n.getContext("2d",{willReadFrequently:!this.#in})}}reset(e,t,n){if(!e.canvas)throw new Error("Canvas is not specified");if(t<=0||n<=0)throw new Error("Invalid canvas size");e.canvas.width=t,e.canvas.height=n}destroy(e){if(!e.canvas)throw new Error("Canvas is not specified");e.canvas.width=0,e.canvas.height=0,e.canvas=null,e.context=null}_createCanvas(e,t){Qae("Abstract method `_createCanvas` called.")}}class doe{constructor({baseUrl:e=null,isCompressed:t=!0}){this.baseUrl=e,this.isCompressed=t}async fetch({name:e}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!e)throw new Error("CMap name must be specified.");const t=this.baseUrl+e+(this.isCompressed?".bcmap":"");return this._fetch(t).then((e=>({cMapData:e,isCompressed:this.isCompressed}))).catch((e=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${t}`)}))}async _fetch(e){Qae("Abstract method `_fetch` called.")}}class uoe extends doe{async _fetch(e){const t=await Ere(e,this.isCompressed?"arraybuffer":"text");return t instanceof ArrayBuffer?new Uint8Array(t):hre(t)}}class moe{addFilter(e){return"none"}addHCMFilter(e,t){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addHighlightHCMFilter(e,t,n,a,r){return"none"}destroy(e=!1){}}class poe{constructor({baseUrl:e=null}){this.baseUrl=e}async fetch({filename:e}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!e)throw new Error("Font filename must be specified.");const t=`${this.baseUrl}${e}`;return this._fetch(t).catch((e=>{throw new Error(`Unable to load font data at: ${t}`)}))}async _fetch(e){Qae("Abstract method `_fetch` called.")}}class voe extends poe{async _fetch(e){const t=await Ere(e,"arraybuffer");return new Uint8Array(t)}}async function foe(e){const t=yt.getBuiltinModule("fs"),n=await t.promises.readFile(e);return new Uint8Array(n)}Nae&&Xae("Please use the `legacy` build in Node.js environments.");const zoe="Fill",goe="Stroke",yoe="Shading";function Moe(e,t){if(!t)return;const n=t[2]-t[0],a=t[3]-t[1],r=new Path2D;r.rect(t[0],t[1],n,a),e.clip(r)}class Eoe{getPattern(){Qae("Abstract method `getPattern` called.")}}class boe extends Eoe{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}_createGradient(e){let t;"axial"===this._type?t=e.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(t=e.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const e of this._colorStops)t.addColorStop(e[0],e[1]);return t}getPattern(e,t,n,a){let r;if(a===goe||a===zoe){const o=t.current.getClippedPathBoundingBox(a,Nre(e))||[0,0,0,0],c=Math.ceil(o[2]-o[0])||1,l=Math.ceil(o[3]-o[1])||1,i=t.cachedCanvases.getCanvas("pattern",c,l),s=i.context;s.clearRect(0,0,s.canvas.width,s.canvas.height),s.beginPath(),s.rect(0,0,s.canvas.width,s.canvas.height),s.translate(-o[0],-o[1]),n=pre.transform(n,[1,0,0,1,o[0],o[1]]),s.transform(...t.baseTransform),this.matrix&&s.transform(...this.matrix),Moe(s,this._bbox),s.fillStyle=this._createGradient(s),s.fill(),r=e.createPattern(i.canvas,"no-repeat");const h=new DOMMatrix(n);r.setTransform(h)}else Moe(e,this._bbox),r=this._createGradient(e);return r}}function Hoe(e,t,n,a,r,o,c,l){const i=t.coords,s=t.colors,h=e.data,d=4*e.width;let u;i[n+1]>i[a+1]&&(u=n,n=a,a=u,u=o,o=c,c=u),i[a+1]>i[r+1]&&(u=a,a=r,r=u,u=c,c=l,l=u),i[n+1]>i[a+1]&&(u=n,n=a,a=u,u=o,o=c,c=u);const m=(i[n]+t.offsetX)*t.scaleX,p=(i[n+1]+t.offsetY)*t.scaleY,v=(i[a]+t.offsetX)*t.scaleX,f=(i[a+1]+t.offsetY)*t.scaleY,z=(i[r]+t.offsetX)*t.scaleX,g=(i[r+1]+t.offsetY)*t.scaleY;if(p>=g)return;const y=s[o],M=s[o+1],E=s[o+2],b=s[c],H=s[c+1],V=s[c+2],C=s[l],L=s[l+1],x=s[l+2],S=Math.round(p),k=Math.round(g);let w,T,O,A,R,N,_,D;for(let e=S;e<=k;e++){if(e<f){const t=e<p?0:(p-e)/(p-f);w=m-(m-v)*t,T=y-(y-b)*t,O=M-(M-H)*t,A=E-(E-V)*t}else{let t;t=e>g?1:f===g?0:(f-e)/(f-g),w=v-(v-z)*t,T=b-(b-C)*t,O=H-(H-L)*t,A=V-(V-x)*t}let t;t=e<p?0:e>g?1:(p-e)/(p-g),R=m-(m-z)*t,N=y-(y-C)*t,_=M-(M-L)*t,D=E-(E-x)*t;const n=Math.round(Math.min(w,R)),a=Math.round(Math.max(w,R));let r=d*e+4*n;for(let e=n;e<=a;e++)t=(w-e)/(w-R),t<0?t=0:t>1&&(t=1),h[r++]=T-(T-N)*t|0,h[r++]=O-(O-_)*t|0,h[r++]=A-(A-D)*t|0,h[r++]=255}}function Voe(e,t,n){const a=t.coords,r=t.colors;let o,c;switch(t.type){case"lattice":const l=t.verticesPerRow,i=Math.floor(a.length/l)-1,s=l-1;for(o=0;o<i;o++){let t=o*l;for(let o=0;o<s;o++,t++)Hoe(e,n,a[t],a[t+1],a[t+l],r[t],r[t+1],r[t+l]),Hoe(e,n,a[t+l+1],a[t+1],a[t+l],r[t+l+1],r[t+1],r[t+l])}break;case"triangles":for(o=0,c=a.length;o<c;o+=3)Hoe(e,n,a[o],a[o+1],a[o+2],r[o],r[o+1],r[o+2]);break;default:throw new Error("illegal figure")}}class Coe extends Eoe{constructor(e){super(),this._coords=e[2],this._colors=e[3],this._figures=e[4],this._bounds=e[5],this._bbox=e[7],this._background=e[8],this.matrix=null}_createMeshCanvas(e,t,n){const a=Math.floor(this._bounds[0]),r=Math.floor(this._bounds[1]),o=Math.ceil(this._bounds[2])-a,c=Math.ceil(this._bounds[3])-r,l=Math.min(Math.ceil(Math.abs(o*e[0]*1.1)),3e3),i=Math.min(Math.ceil(Math.abs(c*e[1]*1.1)),3e3),s=o/l,h=c/i,d={coords:this._coords,colors:this._colors,offsetX:-a,offsetY:-r,scaleX:1/s,scaleY:1/h},u=l+4,m=i+4,p=n.getCanvas("mesh",u,m),v=p.context,f=v.createImageData(l,i);if(t){const e=f.data;for(let n=0,a=e.length;n<a;n+=4)e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=255}for(const e of this._figures)Voe(f,e,d);return v.putImageData(f,2,2),{canvas:p.canvas,offsetX:a-2*s,offsetY:r-2*h,scaleX:s,scaleY:h}}getPattern(e,t,n,a){let r;if(Moe(e,this._bbox),a===yoe)r=pre.singularValueDecompose2dScale(Nre(e));else if(r=pre.singularValueDecompose2dScale(t.baseTransform),this.matrix){const e=pre.singularValueDecompose2dScale(this.matrix);r=[r[0]*e[0],r[1]*e[1]]}const o=this._createMeshCanvas(r,a===yoe?null:this._background,t.cachedCanvases);return a!==yoe&&(e.setTransform(...t.baseTransform),this.matrix&&e.transform(...this.matrix)),e.translate(o.offsetX,o.offsetY),e.scale(o.scaleX,o.scaleY),e.createPattern(o.canvas,"no-repeat")}}class Loe extends Eoe{getPattern(){return"hotpink"}}class xoe{static MAX_PATTERN_SIZE=3e3;constructor(e,t,n,a,r){this.operatorList=e[2],this.matrix=e[3],this.bbox=e[4],this.xstep=e[5],this.ystep=e[6],this.paintType=e[7],this.tilingType=e[8],this.color=t,this.ctx=n,this.canvasGraphicsFactory=a,this.baseTransform=r}createPatternCanvas(e){const{bbox:t,operatorList:n,paintType:a,tilingType:r,color:o,canvasGraphicsFactory:c}=this;let{xstep:l,ystep:i}=this;l=Math.abs(l),i=Math.abs(i),Kae("TilingType: "+r);const s=t[0],h=t[1],d=t[2],u=t[3],m=d-s,p=u-h,v=pre.singularValueDecompose2dScale(this.matrix),f=pre.singularValueDecompose2dScale(this.baseTransform),z=v[0]*f[0],g=v[1]*f[1];let y=m,M=p,E=!1,b=!1;const H=Math.ceil(l*z),V=Math.ceil(i*g);H>=Math.ceil(m*z)?y=l:E=!0,V>=Math.ceil(p*g)?M=i:b=!0;const C=this.getSizeAndScale(y,this.ctx.canvas.width,z),L=this.getSizeAndScale(M,this.ctx.canvas.height,g),x=e.cachedCanvases.getCanvas("pattern",C.size,L.size),S=x.context,k=c.createCanvasGraphics(S);if(k.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(k,a,o),S.translate(-C.scale*s,-L.scale*h),k.transform(C.scale,0,0,L.scale,0,0),S.save(),this.clipBbox(k,s,h,d,u),k.baseTransform=Nre(k.ctx),k.executeOperatorList(n),k.endDrawing(),S.restore(),E||b){const t=x.canvas;E&&(y=l),b&&(M=i);const n=this.getSizeAndScale(y,this.ctx.canvas.width,z),a=this.getSizeAndScale(M,this.ctx.canvas.height,g),r=n.size,o=a.size,c=e.cachedCanvases.getCanvas("pattern-workaround",r,o),d=c.context,u=E?Math.floor(m/l):0,v=b?Math.floor(p/i):0;for(let e=0;e<=u;e++)for(let n=0;n<=v;n++)d.drawImage(t,r*e,o*n,r,o,0,0,r,o);return{canvas:c.canvas,scaleX:n.scale,scaleY:a.scale,offsetX:s,offsetY:h}}return{canvas:x.canvas,scaleX:C.scale,scaleY:L.scale,offsetX:s,offsetY:h}}getSizeAndScale(e,t,n){const a=Math.max(xoe.MAX_PATTERN_SIZE,t);let r=Math.ceil(e*n);return r>=a?r=a:n=r/e,{scale:n,size:r}}clipBbox(e,t,n,a,r){const o=a-t,c=r-n;e.ctx.rect(t,n,o,c),e.current.updateRectMinMax(Nre(e.ctx),[t,n,a,r]),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,t,n){const a=e.ctx,r=e.current;switch(t){case 1:const e=this.ctx;a.fillStyle=e.fillStyle,a.strokeStyle=e.strokeStyle,r.fillColor=e.fillStyle,r.strokeColor=e.strokeStyle;break;case 2:const o=pre.makeHexColor(n[0],n[1],n[2]);a.fillStyle=o,a.strokeStyle=o,r.fillColor=o,r.strokeColor=o;break;default:throw new lre(`Unsupported paint type: ${t}`)}}getPattern(e,t,n,a){let r=n;a!==yoe&&(r=pre.transform(r,t.baseTransform),this.matrix&&(r=pre.transform(r,this.matrix)));const o=this.createPatternCanvas(t);let c=new DOMMatrix(r);c=c.translate(o.offsetX,o.offsetY),c=c.scale(1/o.scaleX,1/o.scaleY);const l=e.createPattern(o.canvas,"repeat");return l.setTransform(c),l}}function Soe({src:e,srcPos:t=0,dest:n,width:a,height:r,nonBlackColor:o=4294967295,inverseDecode:c=!1}){const l=ure.isLittleEndian?4278190080:255,[i,s]=c?[o,l]:[l,o],h=a>>3,d=7&a,u=e.length;n=new Uint32Array(n.buffer);let m=0;for(let a=0;a<r;a++){for(const a=t+h;t<a;t++){const a=t<u?e[t]:255;n[m++]=128&a?s:i,n[m++]=64&a?s:i,n[m++]=32&a?s:i,n[m++]=16&a?s:i,n[m++]=8&a?s:i,n[m++]=4&a?s:i,n[m++]=2&a?s:i,n[m++]=1&a?s:i}if(0===d)continue;const a=t<u?e[t++]:255;for(let e=0;e<d;e++)n[m++]=a&1<<7-e?s:i}return{srcPos:t,destPos:m}}const koe=16;class woe{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,t,n){let a;return void 0!==this.cache[e]?(a=this.cache[e],this.canvasFactory.reset(a,t,n)):(a=this.canvasFactory.create(t,n),this.cache[e]=a),a}delete(e){delete this.cache[e]}clear(){for(const e in this.cache){const t=this.cache[e];this.canvasFactory.destroy(t),delete this.cache[e]}}}function Toe(e,t,n,a,r,o,c,l,i,s){const[h,d,u,m,p,v]=Nre(e);if(0===d&&0===u){const f=c*h+p,z=Math.round(f),g=l*m+v,y=Math.round(g),M=(c+i)*h+p,E=Math.abs(Math.round(M)-z)||1,b=(l+s)*m+v,H=Math.abs(Math.round(b)-y)||1;return e.setTransform(Math.sign(h),0,0,Math.sign(m),z,y),e.drawImage(t,n,a,r,o,0,0,E,H),e.setTransform(h,d,u,m,p,v),[E,H]}if(0===h&&0===m){const f=l*u+p,z=Math.round(f),g=c*d+v,y=Math.round(g),M=(l+s)*u+p,E=Math.abs(Math.round(M)-z)||1,b=(c+i)*d+v,H=Math.abs(Math.round(b)-y)||1;return e.setTransform(0,Math.sign(d),Math.sign(u),0,z,y),e.drawImage(t,n,a,r,o,0,0,H,E),e.setTransform(h,d,u,m,p,v),[H,E]}return e.drawImage(t,n,a,r,o,c,l,i,s),[Math.hypot(h,d)*i,Math.hypot(u,m)*s]}class Ooe{constructor(e,t){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=_ae,this.textMatrixScale=1,this.fontMatrix=Dae,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=0,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,e,t])}clone(){const e=Object.create(this);return e.clipBox=this.clipBox.slice(),e}setCurrentPoint(e,t){this.x=e,this.y=t}updatePathMinMax(e,t,n){[t,n]=pre.applyTransform([t,n],e),this.minX=Math.min(this.minX,t),this.minY=Math.min(this.minY,n),this.maxX=Math.max(this.maxX,t),this.maxY=Math.max(this.maxY,n)}updateRectMinMax(e,t){const n=pre.applyTransform(t,e),a=pre.applyTransform(t.slice(2),e),r=pre.applyTransform([t[0],t[3]],e),o=pre.applyTransform([t[2],t[1]],e);this.minX=Math.min(this.minX,n[0],a[0],r[0],o[0]),this.minY=Math.min(this.minY,n[1],a[1],r[1],o[1]),this.maxX=Math.max(this.maxX,n[0],a[0],r[0],o[0]),this.maxY=Math.max(this.maxY,n[1],a[1],r[1],o[1])}updateScalingPathMinMax(e,t){pre.scaleMinMax(e,t),this.minX=Math.min(this.minX,t[0]),this.minY=Math.min(this.minY,t[1]),this.maxX=Math.max(this.maxX,t[2]),this.maxY=Math.max(this.maxY,t[3])}updateCurvePathMinMax(e,t,n,a,r,o,c,l,i,s){const h=pre.bezierBoundingBox(t,n,a,r,o,c,l,i,s);s||this.updateRectMinMax(e,h)}getPathBoundingBox(e=zoe,t=null){const n=[this.minX,this.minY,this.maxX,this.maxY];if(e===goe){t||Qae("Stroke bounding box must include transform.");const e=pre.singularValueDecompose2dScale(t),a=e[0]*this.lineWidth/2,r=e[1]*this.lineWidth/2;n[0]-=a,n[1]-=r,n[2]+=a,n[3]+=r}return n}updateClipFromPath(){const e=pre.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(e){this.clipBox=e,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(e=zoe,t=null){return pre.intersect(this.clipBox,this.getPathBoundingBox(e,t))}}function Aoe(e,t){if(t instanceof ImageData)return void e.putImageData(t,0,0);const n=t.height,a=t.width,r=n%koe,o=(n-r)/koe,c=0===r?o:o+1,l=e.createImageData(a,koe);let i,s=0;const h=t.data,d=l.data;let u,m,p,v;if(t.kind===Uae.GRAYSCALE_1BPP){const t=h.byteLength,n=new Uint32Array(d.buffer,0,d.byteLength>>2),v=n.length,f=a+7>>3,z=4294967295,g=ure.isLittleEndian?4278190080:255;for(u=0;u<c;u++){for(p=u<o?koe:r,i=0,m=0;m<p;m++){const e=t-s;let r=0;const o=e>f?a:8*e-7,c=-8&o;let l=0,d=0;for(;r<c;r+=8)d=h[s++],n[i++]=128&d?z:g,n[i++]=64&d?z:g,n[i++]=32&d?z:g,n[i++]=16&d?z:g,n[i++]=8&d?z:g,n[i++]=4&d?z:g,n[i++]=2&d?z:g,n[i++]=1&d?z:g;for(;r<o;r++)0===l&&(d=h[s++],l=128),n[i++]=d&l?z:g,l>>=1}for(;i<v;)n[i++]=0;e.putImageData(l,0,u*koe)}}else if(t.kind===Uae.RGBA_32BPP){for(m=0,v=a*koe*4,u=0;u<o;u++)d.set(h.subarray(s,s+v)),s+=v,e.putImageData(l,0,m),m+=koe;u<c&&(v=a*r*4,d.set(h.subarray(s,s+v)),e.putImageData(l,0,m))}else{if(t.kind!==Uae.RGB_24BPP)throw new Error(`bad image kind: ${t.kind}`);for(p=koe,v=a*p,u=0;u<c;u++){for(u>=o&&(p=r,v=a*p),i=0,m=v;m--;)d[i++]=h[s++],d[i++]=h[s++],d[i++]=h[s++],d[i++]=255;e.putImageData(l,0,u*koe)}}}function Roe(e,t){if(t.bitmap)return void e.drawImage(t.bitmap,0,0);const n=t.height,a=t.width,r=n%koe,o=(n-r)/koe,c=0===r?o:o+1,l=e.createImageData(a,koe);let i=0;const s=t.data,h=l.data;for(let t=0;t<c;t++){const n=t<o?koe:r;({srcPos:i}=Soe({src:s,srcPos:i,dest:h,width:a,height:n,nonBlackColor:0})),e.putImageData(l,0,t*koe)}}function Noe(e,t){const n=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const a of n)void 0!==e[a]&&(t[a]=e[a]);void 0!==e.setLineDash&&(t.setLineDash(e.getLineDash()),t.lineDashOffset=e.lineDashOffset)}function _oe(e){if(e.strokeStyle=e.fillStyle="#000000",e.fillRule="nonzero",e.globalAlpha=1,e.lineWidth=1,e.lineCap="butt",e.lineJoin="miter",e.miterLimit=10,e.globalCompositeOperation="source-over",e.font="10px sans-serif",void 0!==e.setLineDash&&(e.setLineDash([]),e.lineDashOffset=0),!Nae){const{filter:t}=e;"none"!==t&&""!==t&&(e.filter="none")}}function Doe(e,t){if(t)return!0;const n=pre.singularValueDecompose2dScale(e);n[0]=Math.fround(n[0]),n[1]=Math.fround(n[1]);const a=Math.fround((globalThis.devicePixelRatio||1)*Mre.PDF_TO_CSS_UNITS);return n[0]<=a&&n[1]<=a}const Poe=["butt","round","square"],Foe=["miter","round","bevel"],Ioe={},joe={};class Boe{constructor(e,t,n,a,r,{optionalContentConfig:o,markedContentStack:c=null},l,i){this.ctx=e,this.current=new Ooe(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=t,this.objs=n,this.canvasFactory=a,this.filterFactory=r,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=c||[],this.optionalContentConfig=o,this.cachedCanvases=new woe(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=i,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(e,t=null){return"string"==typeof e?e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e):t}beginDrawing({transform:e,viewport:t,transparency:n=!1,background:a=null}){const r=this.ctx.canvas.width,o=this.ctx.canvas.height,c=this.ctx.fillStyle;if(this.ctx.fillStyle=a||"#ffffff",this.ctx.fillRect(0,0,r,o),this.ctx.fillStyle=c,n){const e=this.cachedCanvases.getCanvas("transparent",r,o);this.compositeCtx=this.ctx,this.transparentCanvas=e.canvas,this.ctx=e.context,this.ctx.save(),this.ctx.transform(...Nre(this.compositeCtx))}this.ctx.save(),_oe(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...t.transform),this.viewportScale=t.scale,this.baseTransform=Nre(this.ctx)}executeOperatorList(e,t,n,a){const r=e.argsArray,o=e.fnArray;let c=t||0;const l=r.length;if(l===c)return c;const i=l-c>10&&"function"==typeof n,s=i?Date.now()+15:0;let h=0;const d=this.commonObjs,u=this.objs;let m;for(;;){if(void 0!==a&&c===a.nextBreakPoint)return a.breakIt(c,n),c;if(m=o[c],m!==$ae.dependency)this[m].apply(this,r[c]);else for(const e of r[c]){const t=e.startsWith("g_")?d:u;if(!t.has(e))return t.get(e,n),c}if(c++,c===l)return c;if(i&&++h>10){if(Date.now()>s)return n(),c;h=0}}}#sn(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#sn(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const e of this._cachedBitmapsMap.values()){for(const t of e.values())"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear(),this.#hn()}#hn(){if(this.pageColors){const e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==e){const t=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=t}}}_scaleImage(e,t){const n=e.width??e.displayWidth,a=e.height??e.displayHeight;let r,o,c=Math.max(Math.hypot(t[0],t[1]),1),l=Math.max(Math.hypot(t[2],t[3]),1),i=n,s=a,h="prescale1";for(;c>2&&i>1||l>2&&s>1;){let t=i,n=s;c>2&&i>1&&(t=i>=16384?Math.floor(i/2)-1||1:Math.ceil(i/2),c/=i/t),l>2&&s>1&&(n=s>=16384?Math.floor(s/2)-1||1:Math.ceil(s)/2,l/=s/n),r=this.cachedCanvases.getCanvas(h,t,n),o=r.context,o.clearRect(0,0,t,n),o.drawImage(e,0,0,i,s,0,0,t,n),e=r.canvas,i=t,s=n,h="prescale1"===h?"prescale2":"prescale1"}return{img:e,paintWidth:i,paintHeight:s}}_createMaskCanvas(e){const t=this.ctx,{width:n,height:a}=e,r=this.current.fillColor,o=this.current.patternFill,c=Nre(t);let l,i,s,h;if((e.bitmap||e.data)&&e.count>1){const t=e.bitmap||e.data.buffer;i=JSON.stringify(o?c:[c.slice(0,4),r]),l=this._cachedBitmapsMap.get(t),l||(l=new Map,this._cachedBitmapsMap.set(t,l));const n=l.get(i);if(n&&!o)return{canvas:n,offsetX:Math.round(Math.min(c[0],c[2])+c[4]),offsetY:Math.round(Math.min(c[1],c[3])+c[5])};s=n}s||(h=this.cachedCanvases.getCanvas("maskCanvas",n,a),Roe(h.context,e));let d=pre.transform(c,[1/n,0,0,-1/a,0,0]);d=pre.transform(d,[1,0,0,1,0,-a]);const[u,m,p,v]=pre.getAxialAlignedBoundingBox([0,0,n,a],d),f=Math.round(p-u)||1,z=Math.round(v-m)||1,g=this.cachedCanvases.getCanvas("fillCanvas",f,z),y=g.context,M=u,E=m;y.translate(-M,-E),y.transform(...d),s||(s=this._scaleImage(h.canvas,_re(y)),s=s.img,l&&o&&l.set(i,s)),y.imageSmoothingEnabled=Doe(Nre(y),e.interpolate),Toe(y,s,0,0,s.width,s.height,0,0,n,a),y.globalCompositeOperation="source-in";const b=pre.transform(_re(y),[1,0,0,1,-M,-E]);return y.fillStyle=o?r.getPattern(t,this,b,zoe):r,y.fillRect(0,0,n,a),l&&!o&&(this.cachedCanvases.delete("fillCanvas"),l.set(i,g.canvas)),{canvas:g.canvas,offsetX:Math.round(M),offsetY:Math.round(E)}}setLineWidth(e){e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(e){this.ctx.lineCap=Poe[e]}setLineJoin(e){this.ctx.lineJoin=Foe[e]}setMiterLimit(e){this.ctx.miterLimit=e}setDash(e,t){const n=this.ctx;void 0!==n.setLineDash&&(n.setLineDash(e),n.lineDashOffset=t)}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(const[t,n]of e)switch(t){case"LW":this.setLineWidth(n);break;case"LC":this.setLineCap(n);break;case"LJ":this.setLineJoin(n);break;case"ML":this.setMiterLimit(n);break;case"D":this.setDash(n[0],n[1]);break;case"RI":this.setRenderingIntent(n);break;case"FL":this.setFlatness(n);break;case"Font":this.setFont(n[0],n[1]);break;case"CA":this.current.strokeAlpha=n;break;case"ca":this.current.fillAlpha=n,this.ctx.globalAlpha=n;break;case"BM":this.ctx.globalCompositeOperation=n;break;case"SMask":this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode():!this.current.activeSMask&&e&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const e=this.ctx.canvas.width,t=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,a=this.cachedCanvases.getCanvas(n,e,t);this.suspendedCtx=this.ctx,this.ctx=a.context;const r=this.ctx;r.setTransform(...Nre(this.suspendedCtx)),Noe(this.suspendedCtx,r),function(e,t){if(e._removeMirroring)throw new Error("Context is already forwarding operations.");e.__originalSave=e.save,e.__originalRestore=e.restore,e.__originalRotate=e.rotate,e.__originalScale=e.scale,e.__originalTranslate=e.translate,e.__originalTransform=e.transform,e.__originalSetTransform=e.setTransform,e.__originalResetTransform=e.resetTransform,e.__originalClip=e.clip,e.__originalMoveTo=e.moveTo,e.__originalLineTo=e.lineTo,e.__originalBezierCurveTo=e.bezierCurveTo,e.__originalRect=e.rect,e.__originalClosePath=e.closePath,e.__originalBeginPath=e.beginPath,e._removeMirroring=()=>{e.save=e.__originalSave,e.restore=e.__originalRestore,e.rotate=e.__originalRotate,e.scale=e.__originalScale,e.translate=e.__originalTranslate,e.transform=e.__originalTransform,e.setTransform=e.__originalSetTransform,e.resetTransform=e.__originalResetTransform,e.clip=e.__originalClip,e.moveTo=e.__originalMoveTo,e.lineTo=e.__originalLineTo,e.bezierCurveTo=e.__originalBezierCurveTo,e.rect=e.__originalRect,e.closePath=e.__originalClosePath,e.beginPath=e.__originalBeginPath,delete e._removeMirroring},e.save=function(){t.save(),this.__originalSave()},e.restore=function(){t.restore(),this.__originalRestore()},e.translate=function(e,n){t.translate(e,n),this.__originalTranslate(e,n)},e.scale=function(e,n){t.scale(e,n),this.__originalScale(e,n)},e.transform=function(e,n,a,r,o,c){t.transform(e,n,a,r,o,c),this.__originalTransform(e,n,a,r,o,c)},e.setTransform=function(e,n,a,r,o,c){t.setTransform(e,n,a,r,o,c),this.__originalSetTransform(e,n,a,r,o,c)},e.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},e.rotate=function(e){t.rotate(e),this.__originalRotate(e)},e.clip=function(e){t.clip(e),this.__originalClip(e)},e.moveTo=function(e,n){t.moveTo(e,n),this.__originalMoveTo(e,n)},e.lineTo=function(e,n){t.lineTo(e,n),this.__originalLineTo(e,n)},e.bezierCurveTo=function(e,n,a,r,o,c){t.bezierCurveTo(e,n,a,r,o,c),this.__originalBezierCurveTo(e,n,a,r,o,c)},e.rect=function(e,n,a,r){t.rect(e,n,a,r),this.__originalRect(e,n,a,r)},e.closePath=function(){t.closePath(),this.__originalClosePath()},e.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}(r,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Noe(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(e){if(!this.current.activeSMask)return;e?(e[0]=Math.floor(e[0]),e[1]=Math.floor(e[1]),e[2]=Math.ceil(e[2]),e[3]=Math.ceil(e[3])):e=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const t=this.current.activeSMask,n=this.suspendedCtx;this.composeSMask(n,t,this.ctx,e),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(e,t,n,a){const r=a[0],o=a[1],c=a[2]-r,l=a[3]-o;0!==c&&0!==l&&(this.genericComposeSMask(t.context,n,c,l,t.subtype,t.backdrop,t.transferMap,r,o,t.offsetX,t.offsetY),e.save(),e.globalAlpha=1,e.globalCompositeOperation="source-over",e.setTransform(1,0,0,1,0,0),e.drawImage(n.canvas,0,0),e.restore())}genericComposeSMask(e,t,n,a,r,o,c,l,i,s,h){let d=e.canvas,u=l-s,m=i-h;if(o){const t=pre.makeHexColor(...o);if(u<0||m<0||u+n>d.width||m+a>d.height){const e=this.cachedCanvases.getCanvas("maskExtension",n,a),r=e.context;r.drawImage(d,-u,-m),r.globalCompositeOperation="destination-atop",r.fillStyle=t,r.fillRect(0,0,n,a),r.globalCompositeOperation="source-over",d=e.canvas,u=m=0}else{e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const r=new Path2D;r.rect(u,m,n,a),e.clip(r),e.globalCompositeOperation="destination-atop",e.fillStyle=t,e.fillRect(u,m,n,a),e.restore()}}t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0),"Alpha"===r&&c?t.filter=this.filterFactory.addAlphaFilter(c):"Luminosity"===r&&(t.filter=this.filterFactory.addLuminosityFilter(c));const p=new Path2D;p.rect(l,i,n,a),t.clip(p),t.globalCompositeOperation="destination-in",t.drawImage(d,u,m,n,a,l,i,n,a),t.restore()}save(){this.inSMaskMode?(Noe(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),Noe(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(e,t,n,a,r,o){this.ctx.transform(e,t,n,a,r,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,n){const a=this.ctx,r=this.current;let o,c,l=r.x,i=r.y;const s=Nre(a),h=0===s[0]&&0===s[3]||0===s[1]&&0===s[2],d=h?n.slice(0):null;for(let n=0,u=0,m=e.length;n<m;n++)switch(0|e[n]){case $ae.rectangle:l=t[u++],i=t[u++];const e=t[u++],n=t[u++],m=l+e,p=i+n;a.moveTo(l,i),0===e||0===n?a.lineTo(m,p):(a.lineTo(m,i),a.lineTo(m,p),a.lineTo(l,p)),h||r.updateRectMinMax(s,[l,i,m,p]),a.closePath();break;case $ae.moveTo:l=t[u++],i=t[u++],a.moveTo(l,i),h||r.updatePathMinMax(s,l,i);break;case $ae.lineTo:l=t[u++],i=t[u++],a.lineTo(l,i),h||r.updatePathMinMax(s,l,i);break;case $ae.curveTo:o=l,c=i,l=t[u+4],i=t[u+5],a.bezierCurveTo(t[u],t[u+1],t[u+2],t[u+3],l,i),r.updateCurvePathMinMax(s,o,c,t[u],t[u+1],t[u+2],t[u+3],l,i,d),u+=6;break;case $ae.curveTo2:o=l,c=i,a.bezierCurveTo(l,i,t[u],t[u+1],t[u+2],t[u+3]),r.updateCurvePathMinMax(s,o,c,l,i,t[u],t[u+1],t[u+2],t[u+3],d),l=t[u+2],i=t[u+3],u+=4;break;case $ae.curveTo3:o=l,c=i,l=t[u+2],i=t[u+3],a.bezierCurveTo(t[u],t[u+1],l,i,l,i),r.updateCurvePathMinMax(s,o,c,t[u],t[u+1],l,i,l,i,d),u+=4;break;case $ae.closePath:a.closePath()}h&&r.updateScalingPathMinMax(s,d),r.setCurrentPoint(l,i)}closePath(){this.ctx.closePath()}stroke(e=!0){const t=this.ctx,n=this.current.strokeColor;t.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof n&&n?.getPattern?(t.save(),t.strokeStyle=n.getPattern(t,this,_re(t),goe),this.rescaleAndStroke(!1),t.restore()):this.rescaleAndStroke(!0)),e&&this.consumePath(this.current.getClippedPathBoundingBox()),t.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(e=!0){const t=this.ctx,n=this.current.fillColor;let a=!1;this.current.patternFill&&(t.save(),t.fillStyle=n.getPattern(t,this,_re(t),zoe),a=!0);const r=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==r&&(this.pendingEOFill?(t.fill("evenodd"),this.pendingEOFill=!1):t.fill()),a&&t.restore(),e&&this.consumePath(r)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Ioe}eoClip(){this.pendingClip=joe}beginText(){this.current.textMatrix=_ae,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const e=this.pendingTextPaths,t=this.ctx;if(void 0===e)return void t.beginPath();const n=new Path2D,a=t.getTransform().invertSelf();for(const{transform:t,x:r,y:o,fontSize:c,path:l}of e)n.addPath(l,new DOMMatrix(t).preMultiplySelf(a).translate(r,o).scale(c,-c));t.clip(n),t.beginPath(),delete this.pendingTextPaths}setCharSpacing(e){this.current.charSpacing=e}setWordSpacing(e){this.current.wordSpacing=e}setHScale(e){this.current.textHScale=e/100}setLeading(e){this.current.leading=-e}setFont(e,t){const n=this.commonObjs.get(e),a=this.current;if(!n)throw new Error(`Can't find font for ${e}`);if(a.fontMatrix=n.fontMatrix||Dae,0!==a.fontMatrix[0]&&0!==a.fontMatrix[3]||Xae("Invalid font matrix for font "+e),t<0?(t=-t,a.fontDirection=-1):a.fontDirection=1,this.current.font=n,this.current.fontSize=t,n.isType3Font)return;const r=n.loadedName||"sans-serif",o=n.systemFontInfo?.css||`"${r}", ${n.fallbackName}`;let c="normal";n.black?c="900":n.bold&&(c="bold");const l=n.italic?"italic":"normal";let i=t;t<16?i=16:t>100&&(i=100),this.current.fontSizeScale=t/i,this.ctx.font=`${l} ${c} ${i}px ${o}`}setTextRenderingMode(e){this.current.textRenderingMode=e}setTextRise(e){this.current.textRise=e}moveText(e,t){this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=t}setLeadingMoveText(e,t){this.setLeading(-t),this.moveText(e,t)}setTextMatrix(e,t,n,a,r,o){this.current.textMatrix=[e,t,n,a,r,o],this.current.textMatrixScale=Math.hypot(e,t),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#dn(e,t,n){const a=new Path2D;return a.addPath(e,new DOMMatrix(n).invertSelf().multiplySelf(t)),a}paintChar(e,t,n,a,r){const o=this.ctx,c=this.current,l=c.font,i=c.textRenderingMode,s=c.fontSize/c.fontSizeScale,h=3&i,d=!!(4&i),u=c.patternFill&&!l.missingFile,m=c.patternStroke&&!l.missingFile;let p;if((l.disableFontFace||d||u||m)&&(p=l.getPathGenerator(this.commonObjs,e)),l.disableFontFace||u||m){if(o.save(),o.translate(t,n),o.scale(s,-s),0===h||2===h)if(a){const e=o.getTransform();o.setTransform(...a),o.fill(this.#dn(p,e,a))}else o.fill(p);if(1===h||2===h)if(r){const e=o.getTransform();o.setTransform(...r),o.stroke(this.#dn(p,e,r))}else o.lineWidth/=s,o.stroke(p);o.restore()}else 0!==h&&2!==h||o.fillText(e,t,n),1!==h&&2!==h||o.strokeText(e,t,n);d&&(this.pendingTextPaths||=[]).push({transform:Nre(o),x:t,y:n,fontSize:s,path:p})}get isFontSubpixelAAEnabled(){const{context:e}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);e.scale(1.5,1),e.fillText("I",0,10);const t=e.getImageData(0,0,10,10).data;let n=!1;for(let e=3;e<t.length;e+=4)if(t[e]>0&&t[e]<255){n=!0;break}return ere(this,"isFontSubpixelAAEnabled",n)}showText(e){const t=this.current,n=t.font;if(n.isType3Font)return this.showType3Text(e);const a=t.fontSize;if(0===a)return;const r=this.ctx,o=t.fontSizeScale,c=t.charSpacing,l=t.wordSpacing,i=t.fontDirection,s=t.textHScale*i,h=e.length,d=n.vertical,u=d?1:-1,m=n.defaultVMetrics,p=a*t.fontMatrix[0],v=0===t.textRenderingMode&&!n.disableFontFace&&!t.patternFill;let f,z;if(r.save(),r.transform(...t.textMatrix),r.translate(t.x,t.y+t.textRise),i>0?r.scale(s,-1):r.scale(s,1),t.patternFill){r.save();const e=t.fillColor.getPattern(r,this,_re(r),zoe);f=Nre(r),r.restore(),r.fillStyle=e}if(t.patternStroke){r.save();const e=t.strokeColor.getPattern(r,this,_re(r),goe);z=Nre(r),r.restore(),r.strokeStyle=e}let g=t.lineWidth;const y=t.textMatrixScale;if(0===y||0===g){const e=3&t.textRenderingMode;1!==e&&2!==e||(g=this.getSinglePixelWidth())}else g/=y;if(1!==o&&(r.scale(o,o),g/=o),r.lineWidth=g,n.isInvalidPDFjsFont){const n=[];let a=0;for(const t of e)n.push(t.unicode),a+=t.width;return r.fillText(n.join(""),0,0),t.x+=a*p*s,r.restore(),void this.compose()}let M,E=0;for(M=0;M<h;++M){const t=e[M];if("number"==typeof t){E+=u*t*a/1e3;continue}let s=!1;const h=(t.isSpace?l:0)+c,g=t.fontChar,y=t.accent;let b,H,V=t.width;if(d){const e=t.vmetric||m,n=-(t.vmetric?e[1]:.5*V)*p,a=e[2]*p;V=e?-e[0]:V,b=n/o,H=(E+a)/o}else b=E/o,H=0;if(n.remeasure&&V>0){const e=1e3*r.measureText(g).width/a*o;if(V<e&&this.isFontSubpixelAAEnabled){const t=V/e;s=!0,r.save(),r.scale(t,1),b/=t}else V!==e&&(b+=(V-e)/2e3*a/o)}if(this.contentVisible&&(t.isInFont||n.missingFile))if(v&&!y)r.fillText(g,b,H);else if(this.paintChar(g,b,H,f,z),y){const e=b+a*y.offset.x/o,t=H-a*y.offset.y/o;this.paintChar(y.fontChar,e,t,f,z)}E+=d?V*p-h*i:V*p+h*i,s&&r.restore()}d?t.y-=E:t.x+=E*s,r.restore(),this.compose()}showType3Text(e){const t=this.ctx,n=this.current,a=n.font,r=n.fontSize,o=n.fontDirection,c=a.vertical?1:-1,l=n.charSpacing,i=n.wordSpacing,s=n.textHScale*o,h=n.fontMatrix||Dae,d=e.length;let u,m,p,v;if(3!==n.textRenderingMode&&0!==r){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,t.save(),t.transform(...n.textMatrix),t.translate(n.x,n.y),t.scale(s,o),u=0;u<d;++u){if(m=e[u],"number"==typeof m){v=c*m*r/1e3,this.ctx.translate(v,0),n.x+=v*s;continue}const o=(m.isSpace?i:0)+l,d=a.charProcOperatorList[m.operatorListId];d?(this.contentVisible&&(this.processingType3=m,this.save(),t.scale(r,r),t.transform(...h),this.executeOperatorList(d),this.restore()),p=pre.applyTransform([m.width,0],h)[0]*r+o,t.translate(p,0),n.x+=p*s):Xae(`Type3 character "${m.operatorListId}" is not available.`)}t.restore(),this.processingType3=null}}setCharWidth(e,t){}setCharWidthAndBounds(e,t,n,a,r,o){this.ctx.rect(n,a,r-n,o-a),this.ctx.clip(),this.endPath()}getColorN_Pattern(e){let t;if("TilingPattern"===e[0]){const n=e[1],a=this.baseTransform||Nre(this.ctx),r={createCanvasGraphics:e=>new Boe(e,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};t=new xoe(e,n,this.ctx,r,a)}else t=this._getPattern(e[1],e[2]);return t}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(e,t,n){this.ctx.strokeStyle=this.current.strokeColor=pre.makeHexColor(e,t,n),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(e,t,n){this.ctx.fillStyle=this.current.fillColor=pre.makeHexColor(e,t,n),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(e,t=null){let n;return this.cachedPatterns.has(e)?n=this.cachedPatterns.get(e):(n=function(e){switch(e[0]){case"RadialAxial":return new boe(e);case"Mesh":return new Coe(e);case"Dummy":return new Loe}throw new Error(`Unknown IR type: ${e[0]}`)}(this.getObject(e)),this.cachedPatterns.set(e,n)),t&&(n.matrix=t),n}shadingFill(e){if(!this.contentVisible)return;const t=this.ctx;this.save();const n=this._getPattern(e);t.fillStyle=n.getPattern(t,this,_re(t),yoe);const a=_re(t);if(a){const{width:e,height:n}=t.canvas,[r,o,c,l]=pre.getAxialAlignedBoundingBox([0,0,e,n],a);this.ctx.fillRect(r,o,c-r,l-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){Qae("Should not call beginInlineImage")}beginImageData(){Qae("Should not call beginImageData")}paintFormXObjectBegin(e,t){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),e&&this.transform(...e),this.baseTransform=Nre(this.ctx),t)){const e=t[2]-t[0],n=t[3]-t[1];this.ctx.rect(t[0],t[1],e,n),this.current.updateRectMinMax(Nre(this.ctx),t),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const t=this.ctx;e.isolated||Kae("TODO: Support non-isolated groups."),e.knockout&&Xae("Knockout groups not supported.");const n=Nre(t);if(e.matrix&&t.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let a=pre.getAxialAlignedBoundingBox(e.bbox,Nre(t));const r=[0,0,t.canvas.width,t.canvas.height];a=pre.intersect(a,r)||[0,0,0,0];const o=Math.floor(a[0]),c=Math.floor(a[1]),l=Math.max(Math.ceil(a[2])-o,1),i=Math.max(Math.ceil(a[3])-c,1);this.current.startNewPathAndClipBox([0,0,l,i]);let s="groupAt"+this.groupLevel;e.smask&&(s+="_smask_"+this.smaskCounter++%2);const h=this.cachedCanvases.getCanvas(s,l,i),d=h.context;d.translate(-o,-c),d.transform(...n),e.smask?this.smaskStack.push({canvas:h.canvas,context:d,offsetX:o,offsetY:c,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}):(t.setTransform(1,0,0,1,0,0),t.translate(o,c),t.save()),Noe(t,d),this.ctx=d,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(t),this.groupLevel++}endGroup(e){if(!this.contentVisible)return;this.groupLevel--;const t=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,e.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const e=Nre(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...e);const n=pre.getAxialAlignedBoundingBox([0,0,t.canvas.width,t.canvas.height],e);this.ctx.drawImage(t.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(e,t,n,a,r){if(this.#sn(),_oe(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),t){const a=t[2]-t[0],o=t[3]-t[1];if(r&&this.annotationCanvasMap){(n=n.slice())[4]-=t[0],n[5]-=t[1],(t=t.slice())[0]=t[1]=0,t[2]=a,t[3]=o;const[r,c]=pre.singularValueDecompose2dScale(Nre(this.ctx)),{viewportScale:l}=this,i=Math.ceil(a*this.outputScaleX*l),s=Math.ceil(o*this.outputScaleY*l);this.annotationCanvas=this.canvasFactory.create(i,s);const{canvas:h,context:d}=this.annotationCanvas;this.annotationCanvasMap.set(e,h),this.annotationCanvas.savedCtx=this.ctx,this.ctx=d,this.ctx.save(),this.ctx.setTransform(r,0,0,-c,0,o*c),_oe(this.ctx)}else _oe(this.ctx),this.endPath(),this.ctx.rect(t[0],t[1],a,o),this.ctx.clip(),this.ctx.beginPath()}this.current=new Ooe(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...a)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#hn(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e){if(!this.contentVisible)return;const t=e.count;(e=this.getObject(e.data,e)).count=t;const n=this.ctx,a=this.processingType3;if(a&&(void 0===a.compiled&&(a.compiled=function(e){const{width:t,height:n}=e;if(t>1e3||n>1e3)return null;const a=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),r=t+1;let o,c,l,i=new Uint8Array(r*(n+1));const s=t+7&-8;let h=new Uint8Array(s*n),d=0;for(const t of e.data){let e=128;for(;e>0;)h[d++]=t&e?0:255,e>>=1}let u=0;for(d=0,0!==h[d]&&(i[0]=1,++u),c=1;c<t;c++)h[d]!==h[d+1]&&(i[c]=h[d]?2:1,++u),d++;for(0!==h[d]&&(i[c]=2,++u),o=1;o<n;o++){d=o*s,l=o*r,h[d-s]!==h[d]&&(i[l]=h[d]?1:8,++u);let e=(h[d]?4:0)+(h[d-s]?8:0);for(c=1;c<t;c++)e=(e>>2)+(h[d+1]?4:0)+(h[d-s+1]?8:0),a[e]&&(i[l+c]=a[e],++u),d++;if(h[d-s]!==h[d]&&(i[l+c]=h[d]?2:4,++u),u>1e3)return null}for(d=s*(n-1),l=o*r,0!==h[d]&&(i[l]=8,++u),c=1;c<t;c++)h[d]!==h[d+1]&&(i[l+c]=h[d]?4:8,++u),d++;if(0!==h[d]&&(i[l+c]=4,++u),u>1e3)return null;const m=new Int32Array([0,r,-1,0,-r,0,0,0,1]),p=new Path2D;for(o=0;u&&o<=n;o++){let e=o*r;const n=e+t;for(;e<n&&!i[e];)e++;if(e===n)continue;p.moveTo(e%r,o);const a=e;let c=i[e];do{const t=m[c];do{e+=t}while(!i[e]);const n=i[e];5!==n&&10!==n?(c=n,i[e]=0):(c=n&51*c>>4,i[e]&=c>>2|c<<2),p.lineTo(e%r,e/r|0),i[e]||--u}while(a!==e);--o}return h=null,i=null,function(e){e.save(),e.scale(1/t,-1/n),e.translate(0,-n),e.fill(p),e.beginPath(),e.restore()}}(e)),a.compiled))return void a.compiled(n);const r=this._createMaskCanvas(e),o=r.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(o,r.offsetX,r.offsetY),n.restore(),this.compose()}paintImageMaskXObjectRepeat(e,t,n=0,a=0,r,o){if(!this.contentVisible)return;e=this.getObject(e.data,e);const c=this.ctx;c.save();const l=Nre(c);c.transform(t,n,a,r,0,0);const i=this._createMaskCanvas(e);c.setTransform(1,0,0,1,i.offsetX-l[4],i.offsetY-l[5]);for(let e=0,s=o.length;e<s;e+=2){const s=pre.transform(l,[t,n,a,r,o[e],o[e+1]]),[h,d]=pre.applyTransform([0,0],s);c.drawImage(i.canvas,h,d)}c.restore(),this.compose()}paintImageMaskXObjectGroup(e){if(!this.contentVisible)return;const t=this.ctx,n=this.current.fillColor,a=this.current.patternFill;for(const r of e){const{data:e,width:o,height:c,transform:l}=r,i=this.cachedCanvases.getCanvas("maskCanvas",o,c),s=i.context;s.save(),Roe(s,this.getObject(e,r)),s.globalCompositeOperation="source-in",s.fillStyle=a?n.getPattern(s,this,_re(t),zoe):n,s.fillRect(0,0,o,c),s.restore(),t.save(),t.transform(...l),t.scale(1,-1),Toe(t,i.canvas,0,0,o,c,0,-1,1,1),t.restore()}this.compose()}paintImageXObject(e){if(!this.contentVisible)return;const t=this.getObject(e);t?this.paintInlineImageXObject(t):Xae("Dependent image isn't ready yet")}paintImageXObjectRepeat(e,t,n,a){if(!this.contentVisible)return;const r=this.getObject(e);if(!r)return void Xae("Dependent image isn't ready yet");const o=r.width,c=r.height,l=[];for(let e=0,r=a.length;e<r;e+=2)l.push({transform:[t,0,0,n,a[e],a[e+1]],x:0,y:0,w:o,h:c});this.paintInlineImageXObjectGroup(r,l)}applyTransferMapsToCanvas(e){return"none"!==this.current.transferMaps&&(e.filter=this.current.transferMaps,e.drawImage(e.canvas,0,0),e.filter="none"),e.canvas}applyTransferMapsToBitmap(e){if("none"===this.current.transferMaps)return e.bitmap;const{bitmap:t,width:n,height:a}=e,r=this.cachedCanvases.getCanvas("inlineImage",n,a),o=r.context;return o.filter=this.current.transferMaps,o.drawImage(t,0,0),o.filter="none",r.canvas}paintInlineImageXObject(e){if(!this.contentVisible)return;const t=e.width,n=e.height,a=this.ctx;if(this.save(),!Nae){const{filter:e}=a;"none"!==e&&""!==e&&(a.filter="none")}let r;if(a.scale(1/t,-1/n),e.bitmap)r=this.applyTransferMapsToBitmap(e);else if("function"==typeof HTMLElement&&e instanceof HTMLElement||!e.data)r=e;else{const a=this.cachedCanvases.getCanvas("inlineImage",t,n).context;Aoe(a,e),r=this.applyTransferMapsToCanvas(a)}const o=this._scaleImage(r,_re(a));a.imageSmoothingEnabled=Doe(Nre(a),e.interpolate),Toe(a,o.img,0,0,o.paintWidth,o.paintHeight,0,-n,t,n),this.compose(),this.restore()}paintInlineImageXObjectGroup(e,t){if(!this.contentVisible)return;const n=this.ctx;let a;if(e.bitmap)a=e.bitmap;else{const t=e.width,n=e.height,r=this.cachedCanvases.getCanvas("inlineImage",t,n).context;Aoe(r,e),a=this.applyTransferMapsToCanvas(r)}for(const e of t)n.save(),n.transform(...e.transform),n.scale(1,-1),Toe(n,a,e.x,e.y,e.w,e.h,0,-1,1,1),n.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(e){}markPointProps(e,t){}beginMarkedContent(e){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t){"OC"===e?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(t)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(e){const t=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(e);const n=this.ctx;this.pendingClip&&(t||(this.pendingClip===joe?n.clip("evenodd"):n.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),n.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const e=Nre(this.ctx);if(0===e[1]&&0===e[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{const t=Math.abs(e[0]*e[3]-e[2]*e[1]),n=Math.hypot(e[0],e[2]),a=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(n,a)/t}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:e}=this.current,{a:t,b:n,c:a,d:r}=this.ctx.getTransform();let o,c;if(0===n&&0===a){const n=Math.abs(t),a=Math.abs(r);if(n===a)if(0===e)o=c=1/n;else{const t=n*e;o=c=t<1?1/t:1}else if(0===e)o=1/n,c=1/a;else{const t=n*e,r=a*e;o=t<1?1/t:1,c=r<1?1/r:1}}else{const l=Math.abs(t*r-n*a),i=Math.hypot(t,n),s=Math.hypot(a,r);if(0===e)o=s/l,c=i/l;else{const t=e*l;o=s>t?s/t:1,c=i>t?i/t:1}}this._cachedScaleForStroking[0]=o,this._cachedScaleForStroking[1]=c}return this._cachedScaleForStroking}rescaleAndStroke(e){const{ctx:t}=this,{lineWidth:n}=this.current,[a,r]=this.getScaleForStroking();if(t.lineWidth=n||1,1===a&&1===r)return void t.stroke();const o=t.getLineDash();if(e&&t.save(),t.scale(a,r),o.length>0){const e=Math.max(a,r);t.setLineDash(o.map((t=>t/e))),t.lineDashOffset/=e}t.stroke(),e&&t.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}}for(const e in $ae)void 0!==Boe.prototype[e]&&(Boe.prototype[$ae[e]]=Boe.prototype[e]);class Uoe{static#un=null;static#mn="";static get workerPort(){return this.#un}static set workerPort(e){if(!("undefined"!=typeof Worker&&e instanceof Worker)&&null!==e)throw new Error("Invalid `workerPort` type.");this.#un=e}static get workerSrc(){return this.#mn}static set workerSrc(e){if("string"!=typeof e)throw new Error("Invalid `workerSrc` type.");this.#mn=e}}class Woe{#pn;#vn;constructor({parsedData:e,rawData:t}){this.#pn=e,this.#vn=t}getRaw(){return this.#vn}get(e){return this.#pn.get(e)??null}getAll(){return dre(this.#pn)}has(e){return this.#pn.has(e)}}const $oe=Symbol("INTERNAL");class qoe{#fn=!1;#zn=!1;#gn=!1;#yn=!0;constructor(e,{name:t,intent:n,usage:a,rbGroups:r}){this.#fn=!!(2&e),this.#zn=!!(4&e),this.name=t,this.intent=n,this.usage=a,this.rbGroups=r}get visible(){if(this.#gn)return this.#yn;if(!this.#yn)return!1;const{print:e,view:t}=this.usage;return this.#fn?"OFF"!==t?.viewState:!this.#zn||"OFF"!==e?.printState}_setVisible(e,t,n=!1){e!==$oe&&Qae("Internal method `_setVisible` called."),this.#gn=n,this.#yn=t}}class Goe{#Mn=null;#En=new Map;#bn=null;#Hn=null;constructor(e,t=2){if(this.renderingIntent=t,this.name=null,this.creator=null,null!==e){this.name=e.name,this.creator=e.creator,this.#Hn=e.order;for(const n of e.groups)this.#En.set(n.id,new qoe(t,n));if("OFF"===e.baseState)for(const e of this.#En.values())e._setVisible($oe,!1);for(const t of e.on)this.#En.get(t)._setVisible($oe,!0);for(const t of e.off)this.#En.get(t)._setVisible($oe,!1);this.#bn=this.getHash()}}#Vn(e){const t=e.length;if(t<2)return!0;const n=e[0];for(let a=1;a<t;a++){const t=e[a];let r;if(Array.isArray(t))r=this.#Vn(t);else{if(!this.#En.has(t))return Xae(`Optional content group not found: ${t}`),!0;r=this.#En.get(t).visible}switch(n){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return"And"===n}isVisible(e){if(0===this.#En.size)return!0;if(!e)return Kae("Optional content group not defined."),!0;if("OCG"===e.type)return this.#En.has(e.id)?this.#En.get(e.id).visible:(Xae(`Optional content group not found: ${e.id}`),!0);if("OCMD"===e.type){if(e.expression)return this.#Vn(e.expression);if(!e.policy||"AnyOn"===e.policy){for(const t of e.ids){if(!this.#En.has(t))return Xae(`Optional content group not found: ${t}`),!0;if(this.#En.get(t).visible)return!0}return!1}if("AllOn"===e.policy){for(const t of e.ids){if(!this.#En.has(t))return Xae(`Optional content group not found: ${t}`),!0;if(!this.#En.get(t).visible)return!1}return!0}if("AnyOff"===e.policy){for(const t of e.ids){if(!this.#En.has(t))return Xae(`Optional content group not found: ${t}`),!0;if(!this.#En.get(t).visible)return!0}return!1}if("AllOff"===e.policy){for(const t of e.ids){if(!this.#En.has(t))return Xae(`Optional content group not found: ${t}`),!0;if(this.#En.get(t).visible)return!1}return!0}return Xae(`Unknown optional content policy ${e.policy}.`),!0}return Xae(`Unknown group type ${e.type}.`),!0}setVisibility(e,t=!0,n=!0){const a=this.#En.get(e);if(a){if(n&&t&&a.rbGroups.length)for(const t of a.rbGroups)for(const n of t)n!==e&&this.#En.get(n)?._setVisible($oe,!1,!0);a._setVisible($oe,!!t,!0),this.#Mn=null}else Xae(`Optional content group not found: ${e}`)}setOCGState({state:e,preserveRB:t}){let n;for(const a of e){switch(a){case"ON":case"OFF":case"Toggle":n=a;continue}const e=this.#En.get(a);if(e)switch(n){case"ON":this.setVisibility(a,!0,t);break;case"OFF":this.setVisibility(a,!1,t);break;case"Toggle":this.setVisibility(a,!e.visible,t)}}this.#Mn=null}get hasInitialVisibility(){return null===this.#bn||this.getHash()===this.#bn}getOrder(){return this.#En.size?this.#Hn?this.#Hn.slice():[...this.#En.keys()]:null}getGroups(){return this.#En.size>0?dre(this.#En):null}getGroup(e){return this.#En.get(e)||null}getHash(){if(null!==this.#Mn)return this.#Mn;const e=new toe;for(const[t,n]of this.#En)e.update(`${t}:${n.visible}`);return this.#Mn=e.hexdigest()}}class Yoe{constructor(e,{disableRange:t=!1,disableStream:n=!1}){Jae(e,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:a,initialData:r,progressiveDone:o,contentDispositionFilename:c}=e;if(this._queuedChunks=[],this._progressiveDone=o,this._contentDispositionFilename=c,r?.length>0){const e=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;this._queuedChunks.push(e)}this._pdfDataRangeTransport=e,this._isStreamingSupported=!n,this._isRangeSupported=!t,this._contentLength=a,this._fullRequestReader=null,this._rangeReaders=[],e.addRangeListener(((e,t)=>{this._onReceiveData({begin:e,chunk:t})})),e.addProgressListener(((e,t)=>{this._onProgress({loaded:e,total:t})})),e.addProgressiveReadListener((e=>{this._onReceiveData({chunk:e})})),e.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),e.transportReady()}_onReceiveData({begin:e,chunk:t}){const n=t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer;void 0===e?this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n):Jae(this._rangeReaders.some((function(t){return t._begin===e&&(t._enqueue(n),!0)})),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(e){void 0===e.total?this._rangeReaders[0]?.onProgress?.({loaded:e.loaded}):this._fullRequestReader?.onProgress?.({loaded:e.loaded,total:e.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(e){const t=this._rangeReaders.indexOf(e);t>=0&&this._rangeReaders.splice(t,1)}getFullReader(){Jae(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const e=this._queuedChunks;return this._queuedChunks=null,new Koe(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const n=new Xoe(this,e,t);return this._pdfDataRangeTransport.requestDataRange(e,t),this._rangeReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeReaders.slice(0))t.cancel(e);this._pdfDataRangeTransport.abort()}}class Koe{constructor(e,t,n=!1,a=null){this._stream=e,this._done=n||!1,this._filename=Cre(a)?a:null,this._queuedChunks=t||[],this._loaded=0;for(const e of this._queuedChunks)this._loaded+=e.byteLength;this._requests=[],this._headersReady=Promise.resolve(),e._fullRequestReader=this,this.onProgress=null}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Xoe{constructor(e,t,n){this._stream=e,this._begin=t,this._end=n,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(e){if(!this._done){if(0===this._requests.length)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Qoe(e,t){const n=new Headers;if(!e||!t||"object"!=typeof t)return n;for(const e in t){const a=t[e];void 0!==a&&n.append(e,a)}return n}function Joe(e){try{return new URL(e).origin}catch{}return null}function Zoe({responseHeaders:e,isHttp:t,rangeChunkSize:n,disableRange:a}){const r={allowRangeRequests:!1,suggestedLength:void 0},o=parseInt(e.get("Content-Length"),10);return Number.isInteger(o)?(r.suggestedLength=o,o<=2*n||a||!t||"bytes"!==e.get("Accept-Ranges")||"identity"!==(e.get("Content-Encoding")||"identity")||(r.allowRangeRequests=!0),r):r}function ece(e){const t=e.get("Content-Disposition");if(t){let e=function(e){let t=!0,n=a("filename\\*","i").exec(e);if(n){n=n[1];let e=c(n);return e=unescape(e),e=l(e),e=i(e),o(e)}if(n=function(e){const t=[];let n;const r=a("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(n=r.exec(e));){let[,e,a,r]=n;if(e=parseInt(e,10),e in t){if(0===e)break}else t[e]=[a,r]}const o=[];for(let e=0;e<t.length&&e in t;++e){let[n,a]=t[e];a=c(a),n&&(a=unescape(a),0===e&&(a=l(a))),o.push(a)}return o.join("")}(e),n)return o(i(n));if(n=a("filename","i").exec(e),n){n=n[1];let e=c(n);return e=i(e),o(e)}function a(e,t){return new RegExp("(?:^|;)\\s*"+e+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',t)}function r(e,n){if(e){if(!/^[\x00-\xFF]+$/.test(n))return n;try{const a=new TextDecoder(e,{fatal:!0}),r=hre(n);n=a.decode(r),t=!1}catch{}}return n}function o(e){return t&&/[\x80-\xff]/.test(e)&&(e=r("utf-8",e),t&&(e=r("iso-8859-1",e))),e}function c(e){if(e.startsWith('"')){const t=e.slice(1).split('\\"');for(let e=0;e<t.length;++e){const n=t[e].indexOf('"');-1!==n&&(t[e]=t[e].slice(0,n),t.length=e+1),t[e]=t[e].replaceAll(/\\(.)/g,"$1")}e=t.join('"')}return e}function l(e){const t=e.indexOf("'");return-1===t?e:r(e.slice(0,t),e.slice(t+1).replace(/^[^']*'/,""))}function i(e){return!e.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(e)?e:e.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(e,t,n,a){if("q"===n||"Q"===n)return r(t,a=(a=a.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(e,t){return String.fromCharCode(parseInt(t,16))})));try{a=atob(a)}catch{}return r(t,a)}))}return""}(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Cre(e))return e}return null}function tce(e,t){return 404===e||0===e&&t.startsWith("file:")?new ore('Missing PDF "'+t+'".'):new cre(`Unexpected server response (${e}) while retrieving PDF "${t}".`,e)}function nce(e){return 200===e||206===e}function ace(e,t,n){return{method:"GET",headers:e,signal:n.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function rce(e){return e instanceof Uint8Array?e.buffer:e instanceof ArrayBuffer?e:(Xae(`getArrayBuffer - unexpected data format: ${e}`),new Uint8Array(e).buffer)}class oce{_responseOrigin=null;constructor(e){this.source=e,this.isHttp=/^https?:/i.test(e.url),this.headers=Qoe(this.isHttp,e.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return Jae(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new cce(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const n=new lce(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeRequestReaders.slice(0))t.cancel(e)}}class cce{constructor(e){this._stream=e,this._reader=null,this._loaded=0,this._filename=null;const t=e.source;this._withCredentials=t.withCredentials||!1,this._contentLength=t.length,this._headersCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange;const n=new Headers(e.headers),a=t.url;fetch(a,ace(n,this._withCredentials,this._abortController)).then((t=>{if(e._responseOrigin=Joe(t.url),!nce(t.status))throw tce(t.status,a);this._reader=t.body.getReader(),this._headersCapability.resolve();const n=t.headers,{allowRangeRequests:r,suggestedLength:o}=Zoe({responseHeaders:n,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=r,this._contentLength=o||this._contentLength,this._filename=ece(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new ire("Streaming is disabled."))})).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:rce(e),done:!1})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}}class lce{constructor(e,t,n){this._stream=e,this._reader=null,this._loaded=0;const a=e.source;this._withCredentials=a.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!a.disableStream,this._abortController=new AbortController;const r=new Headers(e.headers);r.append("Range",`bytes=${t}-${n-1}`);const o=a.url;fetch(o,ace(r,this._withCredentials,this._abortController)).then((t=>{const n=Joe(t.url);if(n!==e._responseOrigin)throw new Error(`Expected range response-origin "${n}" to match "${e._responseOrigin}".`);if(!nce(t.status))throw tce(t.status,o);this._readCapability.resolve(),this._reader=t.body.getReader()})).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded}),{value:rce(e),done:!1})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}}class ice{_responseOrigin=null;constructor({url:e,httpHeaders:t,withCredentials:n}){this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=Qoe(this.isHttp,t),this.withCredentials=n||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(e){const t=new XMLHttpRequest,n=this.currXhrId++,a=this.pendingRequests[n]={xhr:t};t.open("GET",this.url),t.withCredentials=this.withCredentials;for(const[e,n]of this.headers)t.setRequestHeader(e,n);return this.isHttp&&"begin"in e&&"end"in e?(t.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),a.expectedStatus=206):a.expectedStatus=200,t.responseType="arraybuffer",Jae(e.onError,"Expected `onError` callback to be provided."),t.onerror=()=>{e.onError(t.status)},t.onreadystatechange=this.onStateChange.bind(this,n),t.onprogress=this.onProgress.bind(this,n),a.onHeadersReceived=e.onHeadersReceived,a.onDone=e.onDone,a.onError=e.onError,a.onProgress=e.onProgress,t.send(null),n}onProgress(e,t){const n=this.pendingRequests[e];n&&n.onProgress?.(t)}onStateChange(e,t){const n=this.pendingRequests[e];if(!n)return;const a=n.xhr;if(a.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),4!==a.readyState)return;if(!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],0===a.status&&this.isHttp)return void n.onError(a.status);const r=a.status||200;if((200!==r||206!==n.expectedStatus)&&r!==n.expectedStatus)return void n.onError(a.status);const o=function(e){const t=e.response;return"string"!=typeof t?t:hre(t).buffer}(a);if(206===r){const e=a.getResponseHeader("Content-Range"),t=/bytes (\d+)-(\d+)\/(\d+)/.exec(e);t?n.onDone({begin:parseInt(t[1],10),chunk:o}):(Xae('Missing or invalid "Content-Range" header.'),n.onError(0))}else o?n.onDone({begin:0,chunk:o}):n.onError(a.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){const t=this.pendingRequests[e].xhr;delete this.pendingRequests[e],t.abort()}}class sce{constructor(e){this._source=e,this._manager=new ice(e),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){const t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)}getFullReader(){return Jae(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new hce(this._manager,this._source),this._fullRequestReader}getRangeReader(e,t){const n=new dce(this._manager,e,t);return n.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeRequestReaders.slice(0))t.cancel(e)}}class hce{constructor(e,t){this._manager=e,this._url=t.url,this._fullRequestId=e.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._contentLength=t.length,this._rangeChunkSize=t.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const e=this._fullRequestId,t=this._manager.getRequestXhr(e);this._manager._responseOrigin=Joe(t.responseURL);const n=t.getAllResponseHeaders(),a=new Headers(n?n.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((e=>{const[t,...n]=e.split(": ");return[t,n.join(": ")]})):[]),{allowRangeRequests:r,suggestedLength:o}=Zoe({responseHeaders:a,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});r&&(this._isRangeSupported=!0),this._contentLength=o||this._contentLength,this._filename=ece(a),this._isRangeSupported&&this._manager.abortRequest(e),this._headersCapability.resolve()}_onDone(e){if(e&&(this._requests.length>0?this._requests.shift().resolve({value:e.chunk,done:!1}):this._cachedChunks.push(e.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){this._storedError=tce(e,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(e){this.onProgress?.({loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._headersCapability.reject(e);for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class dce{constructor(e,t,n){this._manager=e,this._url=e.url,this._requestId=e.request({begin:t,end:n,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){const e=Joe(this._manager.getRequestXhr(this._requestId)?.responseURL);e!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${e}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(e){const t=e.chunk;this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(e){this._storedError??=tce(e,this._url);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(e){this.isStreamingSupported||this.onProgress?.({loaded:e.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const uce=/^[a-z][a-z0-9\-+.]+:/i;class mce{constructor(e){this.source=e,this.url=function(e){if(uce.test(e))return new URL(e);const t=yt.getBuiltinModule("url");return new URL(t.pathToFileURL(e))}(e.url),Jae("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return Jae(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new pce(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const n=new vce(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeRequestReaders.slice(0))t.cancel(e)}}class pce{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;const t=e.source;this._contentLength=t.length,this._loaded=0,this._filename=null,this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const n=yt.getBuiltinModule("fs");n.promises.lstat(this._url).then((e=>{this._contentLength=e.size,this._setReadableStream(n.createReadStream(this._url)),this._headersCapability.resolve()}),(e=>{"ENOENT"===e.code&&(e=new ore(`Missing PDF "${this._url}".`)),this._storedError=e,this._headersCapability.reject(e)}))}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return null===e?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){this._readableStream?this._readableStream.destroy(e):this._error(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",(()=>{this._readCapability.resolve()})),e.on("end",(()=>{e.destroy(),this._done=!0,this._readCapability.resolve()})),e.on("error",(e=>{this._error(e)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new ire("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class vce{constructor(e,t,n){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const a=e.source;this._isStreamingSupported=!a.disableStream;const r=yt.getBuiltinModule("fs");this._setReadableStream(r.createReadStream(this._url,{start:t,end:n-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return null===e?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){this._readableStream?this._readableStream.destroy(e):this._error(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",(()=>{this._readCapability.resolve()})),e.on("end",(()=>{e.destroy(),this._done=!0,this._readCapability.resolve()})),e.on("error",(e=>{this._error(e)})),this._storedError&&this._readableStream.destroy(this._storedError)}}const fce=30;class zce{#Cn=Promise.withResolvers();#me=null;#Ln=!1;#xn=!!globalThis.FontInspector?.enabled;#Sn=null;#kn=null;#wn=0;#Tn=0;#On=null;#An=null;#Rn=0;#Nn=0;#_n=Object.create(null);#Dn=[];#Pn=null;#Fn=[];#In=new WeakMap;#jn=null;static#Bn=new Map;static#Un=new Map;static#Wn=new WeakMap;static#$n=null;static#qn=new Set;constructor({textContentSource:e,container:t,viewport:n}){if(e instanceof ReadableStream)this.#Pn=e;else{if("object"!=typeof e)throw new Error('No "textContentSource" parameter specified.');this.#Pn=new ReadableStream({start(t){t.enqueue(e),t.close()}})}this.#me=this.#An=t,this.#Nn=n.scale*(globalThis.devicePixelRatio||1),this.#Rn=n.rotation,this.#kn={div:null,properties:null,ctx:null};const{pageWidth:a,pageHeight:r,pageX:o,pageY:c}=n.rawDims;this.#jn=[1,0,0,-1,-o,c+r],this.#Tn=a,this.#wn=r,zce.#Gn(),Dre(t,n),this.#Cn.promise.finally((()=>{zce.#qn.delete(this),this.#kn=null,this.#_n=null})).catch((()=>{}))}static get fontFamilyMap(){const{isWindows:e,isFirefox:t}=ure.platform;return ere(this,"fontFamilyMap",new Map([["sans-serif",(e&&t?"Calibri, ":"")+"sans-serif"],["monospace",(e&&t?"Lucida Console, ":"")+"monospace"]]))}render(){const e=()=>{this.#On.read().then((({value:t,done:n})=>{n?this.#Cn.resolve():(this.#Sn??=t.lang,Object.assign(this.#_n,t.styles),this.#Yn(t.items),e())}),this.#Cn.reject)};return this.#On=this.#Pn.getReader(),zce.#qn.add(this),e(),this.#Cn.promise}update({viewport:e,onBefore:t=null}){const n=e.scale*(globalThis.devicePixelRatio||1),a=e.rotation;if(a!==this.#Rn&&(t?.(),this.#Rn=a,Dre(this.#An,{rotation:a})),n!==this.#Nn){t?.(),this.#Nn=n;const e={div:null,properties:null,ctx:zce.#Kn(this.#Sn)};for(const t of this.#Fn)e.properties=this.#In.get(t),e.div=t,this.#Xn(e)}}cancel(){const e=new ire("TextLayer task cancelled.");this.#On?.cancel(e).catch((()=>{})),this.#On=null,this.#Cn.reject(e)}get textDivs(){return this.#Fn}get textContentItemsStr(){return this.#Dn}#Yn(e){if(this.#Ln)return;this.#kn.ctx??=zce.#Kn(this.#Sn);const t=this.#Fn,n=this.#Dn;for(const a of e){if(t.length>1e5)return Xae("Ignoring additional textDivs for performance reasons."),void(this.#Ln=!0);if(void 0!==a.str)n.push(a.str),this.#Qn(a);else if("beginMarkedContentProps"===a.type||"beginMarkedContent"===a.type){const e=this.#me;this.#me=document.createElement("span"),this.#me.classList.add("markedContent"),null!==a.id&&this.#me.setAttribute("id",`${a.id}`),e.append(this.#me)}else"endMarkedContent"===a.type&&(this.#me=this.#me.parentNode)}}#Qn(e){const t=document.createElement("span"),n={angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL,fontSize:0};this.#Fn.push(t);const a=pre.transform(this.#jn,e.transform);let r=Math.atan2(a[1],a[0]);const o=this.#_n[e.fontName];o.vertical&&(r+=Math.PI/2);let c=this.#xn&&o.fontSubstitution||o.fontFamily;c=zce.fontFamilyMap.get(c)||c;const l=Math.hypot(a[2],a[3]),i=l*zce.#Jn(c,this.#Sn);let s,h;0===r?(s=a[4],h=a[5]-i):(s=a[4]+i*Math.sin(r),h=a[5]-i*Math.cos(r));const d="calc(var(--scale-factor)*",u=t.style;this.#me===this.#An?(u.left=`${(100*s/this.#Tn).toFixed(2)}%`,u.top=`${(100*h/this.#wn).toFixed(2)}%`):(u.left=`${d}${s.toFixed(2)}px)`,u.top=`${d}${h.toFixed(2)}px)`),u.fontSize=`${d}${(zce.#$n*l).toFixed(2)}px)`,u.fontFamily=c,n.fontSize=l,t.setAttribute("role","presentation"),t.textContent=e.str,t.dir=e.dir,this.#xn&&(t.dataset.fontName=o.fontSubstitutionLoadedName||e.fontName),0!==r&&(n.angle=r*(180/Math.PI));let m=!1;if(e.str.length>1)m=!0;else if(" "!==e.str&&e.transform[0]!==e.transform[3]){const t=Math.abs(e.transform[0]),n=Math.abs(e.transform[3]);t!==n&&Math.max(t,n)/Math.min(t,n)>1.5&&(m=!0)}if(m&&(n.canvasWidth=o.vertical?e.height:e.width),this.#In.set(t,n),this.#kn.div=t,this.#kn.properties=n,this.#Xn(this.#kn),n.hasText&&this.#me.append(t),n.hasEOL){const e=document.createElement("br");e.setAttribute("role","presentation"),this.#me.append(e)}}#Xn(e){const{div:t,properties:n,ctx:a}=e,{style:r}=t;let o="";if(zce.#$n>1&&(o=`scale(${1/zce.#$n})`),0!==n.canvasWidth&&n.hasText){const{fontFamily:e}=r,{canvasWidth:c,fontSize:l}=n;zce.#Zn(a,l*this.#Nn,e);const{width:i}=a.measureText(t.textContent);i>0&&(o=`scaleX(${c*this.#Nn/i}) ${o}`)}0!==n.angle&&(o=`rotate(${n.angle}deg) ${o}`),o.length>0&&(r.transform=o)}static cleanup(){if(!(this.#qn.size>0)){this.#Bn.clear();for(const{canvas:e}of this.#Un.values())e.remove();this.#Un.clear()}}static#Kn(e=null){let t=this.#Un.get(e||="");if(!t){const n=document.createElement("canvas");n.className="hiddenCanvasElement",n.lang=e,document.body.append(n),t=n.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#Un.set(e,t),this.#Wn.set(t,{size:0,family:""})}return t}static#Zn(e,t,n){const a=this.#Wn.get(e);t===a.size&&n===a.family||(e.font=`${t}px ${n}`,a.size=t,a.family=n)}static#Gn(){if(null!==this.#$n)return;const e=document.createElement("div");e.style.opacity=0,e.style.lineHeight=1,e.style.fontSize="1px",e.style.position="absolute",e.textContent="X",document.body.append(e),this.#$n=e.getBoundingClientRect().height,e.remove()}static#Jn(e,t){const n=this.#Bn.get(e);if(n)return n;const a=this.#Kn(t);a.canvas.width=a.canvas.height=fce,this.#Zn(a,fce,e);const r=a.measureText("");let o=r.fontBoundingBoxAscent,c=Math.abs(r.fontBoundingBoxDescent);if(o){const t=o/(o+c);return this.#Bn.set(e,t),a.canvas.width=a.canvas.height=0,t}a.strokeStyle="red",a.clearRect(0,0,fce,fce),a.strokeText("g",0,0);let l=a.getImageData(0,0,fce,fce).data;c=0;for(let e=l.length-1-3;e>=0;e-=4)if(l[e]>0){c=Math.ceil(e/4/fce);break}a.clearRect(0,0,fce,fce),a.strokeText("A",0,fce),l=a.getImageData(0,0,fce,fce).data,o=0;for(let e=0,t=l.length;e<t;e+=4)if(l[e]>0){o=fce-Math.floor(e/4/fce);break}a.canvas.width=a.canvas.height=0;const i=o?o/(o+c):.8;return this.#Bn.set(e,i),i}}class gce{static textContent(e){const t=[],n={items:t,styles:Object.create(null)};return function e(n){if(!n)return;let a=null;const r=n.name;if("#text"===r)a=n.value;else{if(!gce.shouldBuildText(r))return;n?.attributes?.textContent?a=n.attributes.textContent:n.value&&(a=n.value)}if(null!==a&&t.push({str:a}),n.children)for(const t of n.children)e(t)}(e),n}static shouldBuildText(e){return!("textarea"===e||"input"===e||"option"===e||"select"===e)}}const yce=65536,Mce=Nae?class extends hoe{_createCanvas(e,t){return yt.getBuiltinModule("module").createRequire("undefined"==typeof document&&"undefined"==typeof location?new(require("url").URL)("file:"+__filename).href:"undefined"==typeof document?location.href:document.currentScript&&"SCRIPT"===document.currentScript.tagName.toUpperCase()&&document.currentScript.src||new URL("index.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(e,t)}}:class extends hoe{constructor({ownerDocument:e=globalThis.document,enableHWA:t=!1}){super({enableHWA:t}),this._document=e}_createCanvas(e,t){const n=this._document.createElement("canvas");return n.width=e,n.height=t,n}},Ece=Nae?class extends doe{async _fetch(e){return foe(e)}}:uoe,bce=Nae?class extends moe{}:class extends moe{#ea;#ta;#na;#aa;#ra;#oa;#y=0;constructor({docId:e,ownerDocument:t=globalThis.document}){super(),this.#aa=e,this.#ra=t}get#E(){return this.#ta||=new Map}get#ca(){return this.#oa||=new Map}get#la(){if(!this.#na){const e=this.#ra.createElement("div"),{style:t}=e;t.visibility="hidden",t.contain="strict",t.width=t.height=0,t.position="absolute",t.top=t.left=0,t.zIndex=-1;const n=this.#ra.createElementNS(yre,"svg");n.setAttribute("width",0),n.setAttribute("height",0),this.#na=this.#ra.createElementNS(yre,"defs"),e.append(n),n.append(this.#na),this.#ra.body.append(e)}return this.#na}#ia(e){if(1===e.length){const t=e[0],n=new Array(256);for(let e=0;e<256;e++)n[e]=t[e]/255;const a=n.join(",");return[a,a,a]}const[t,n,a]=e,r=new Array(256),o=new Array(256),c=new Array(256);for(let e=0;e<256;e++)r[e]=t[e]/255,o[e]=n[e]/255,c[e]=a[e]/255;return[r.join(","),o.join(","),c.join(",")]}#sa(e){if(void 0===this.#ea){this.#ea="";const e=this.#ra.URL;e!==this.#ra.baseURI&&(Vre(e)?Xae('#createUrl: ignore "data:"-URL for performance reasons.'):this.#ea=e.split("#",1)[0])}return`url(${this.#ea}#${e})`}addFilter(e){if(!e)return"none";let t=this.#E.get(e);if(t)return t;const[n,a,r]=this.#ia(e),o=1===e.length?n:`${n}${a}${r}`;if(t=this.#E.get(o),t)return this.#E.set(e,t),t;const c=`g_${this.#aa}_transfer_map_${this.#y++}`,l=this.#sa(c);this.#E.set(e,l),this.#E.set(o,l);const i=this.#ha(c);return this.#da(n,a,r,i),l}addHCMFilter(e,t){const n=`${e}-${t}`,a="base";let r=this.#ca.get(a);if(r?.key===n)return r.url;if(r?(r.filter?.remove(),r.key=n,r.url="none",r.filter=null):(r={key:n,url:"none",filter:null},this.#ca.set(a,r)),!e||!t)return r.url;const o=this.#ua(e);e=pre.makeHexColor(...o);const c=this.#ua(t);if(t=pre.makeHexColor(...c),this.#la.style.color="","#000000"===e&&"#ffffff"===t||e===t)return r.url;const l=new Array(256);for(let e=0;e<=255;e++){const t=e/255;l[e]=t<=.03928?t/12.92:((t+.055)/1.055)**2.4}const i=l.join(","),s=`g_${this.#aa}_hcm_filter`,h=r.filter=this.#ha(s);this.#da(i,i,i,h),this.#ma(h);const d=(e,t)=>{const n=o[e]/255,a=c[e]/255,r=new Array(t+1);for(let e=0;e<=t;e++)r[e]=n+e/t*(a-n);return r.join(",")};return this.#da(d(0,5),d(1,5),d(2,5),h),r.url=this.#sa(s),r.url}addAlphaFilter(e){let t=this.#E.get(e);if(t)return t;const[n]=this.#ia([e]),a=`alpha_${n}`;if(t=this.#E.get(a),t)return this.#E.set(e,t),t;const r=`g_${this.#aa}_alpha_map_${this.#y++}`,o=this.#sa(r);this.#E.set(e,o),this.#E.set(a,o);const c=this.#ha(r);return this.#pa(n,c),o}addLuminosityFilter(e){let t,n,a=this.#E.get(e||"luminosity");if(a)return a;if(e?([t]=this.#ia([e]),n=`luminosity_${t}`):n="luminosity",a=this.#E.get(n),a)return this.#E.set(e,a),a;const r=`g_${this.#aa}_luminosity_map_${this.#y++}`,o=this.#sa(r);this.#E.set(e,o),this.#E.set(n,o);const c=this.#ha(r);return this.#va(c),e&&this.#pa(t,c),o}addHighlightHCMFilter(e,t,n,a,r){const o=`${t}-${n}-${a}-${r}`;let c=this.#ca.get(e);if(c?.key===o)return c.url;if(c?(c.filter?.remove(),c.key=o,c.url="none",c.filter=null):(c={key:o,url:"none",filter:null},this.#ca.set(e,c)),!t||!n)return c.url;const[l,i]=[t,n].map(this.#ua.bind(this));let s=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),h=Math.round(.2126*i[0]+.7152*i[1]+.0722*i[2]),[d,u]=[a,r].map(this.#ua.bind(this));h<s&&([s,h,d,u]=[h,s,u,d]),this.#la.style.color="";const m=(e,t,n)=>{const a=new Array(256),r=(h-s)/n,o=e/255,c=(t-e)/(255*n);let l=0;for(let e=0;e<=n;e++){const t=Math.round(s+e*r),n=o+e*c;for(let e=l;e<=t;e++)a[e]=n;l=t+1}for(let e=l;e<256;e++)a[e]=a[l-1];return a.join(",")},p=`g_${this.#aa}_hcm_${e}_filter`,v=c.filter=this.#ha(p);return this.#ma(v),this.#da(m(d[0],u[0],5),m(d[1],u[1],5),m(d[2],u[2],5),v),c.url=this.#sa(p),c.url}destroy(e=!1){e&&this.#oa?.size||(this.#na?.parentNode.parentNode.remove(),this.#na=null,this.#ta?.clear(),this.#ta=null,this.#oa?.clear(),this.#oa=null,this.#y=0)}#va(e){const t=this.#ra.createElementNS(yre,"feColorMatrix");t.setAttribute("type","matrix"),t.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),e.append(t)}#ma(e){const t=this.#ra.createElementNS(yre,"feColorMatrix");t.setAttribute("type","matrix"),t.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(t)}#ha(e){const t=this.#ra.createElementNS(yre,"filter");return t.setAttribute("color-interpolation-filters","sRGB"),t.setAttribute("id",e),this.#la.append(t),t}#fa(e,t,n){const a=this.#ra.createElementNS(yre,t);a.setAttribute("type","discrete"),a.setAttribute("tableValues",n),e.append(a)}#da(e,t,n,a){const r=this.#ra.createElementNS(yre,"feComponentTransfer");a.append(r),this.#fa(r,"feFuncR",e),this.#fa(r,"feFuncG",t),this.#fa(r,"feFuncB",n)}#pa(e,t){const n=this.#ra.createElementNS(yre,"feComponentTransfer");t.append(n),this.#fa(n,"feFuncA",e)}#ua(e){return this.#la.style.color=e,Rre(getComputedStyle(this.#la).getPropertyValue("color"))}},Hce=Nae?class extends poe{async _fetch(e){return foe(e)}}:voe;function Vce(e={}){"string"==typeof e||e instanceof URL?e={url:e}:(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const t=new Lce,{docId:n}=t,a=e.url?function(e){if(e instanceof URL)return e.href;try{return new URL(e,window.location).href}catch{if(Nae&&"string"==typeof e)return e}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(e.url):null,r=e.data?function(e){if(Nae&&void 0!==gL&&e instanceof gL)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if("string"==typeof e)return hre(e);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)||"object"==typeof e&&!isNaN(e?.length))return new Uint8Array(e);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(e.data):null,o=e.httpHeaders||null,c=!0===e.withCredentials,l=e.password??null,i=e.range instanceof xce?e.range:null,s=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:yce;let h=e.worker instanceof Tce?e.worker:null;const d=e.verbosity,u="string"!=typeof e.docBaseUrl||Vre(e.docBaseUrl)?null:e.docBaseUrl,m="string"==typeof e.cMapUrl?e.cMapUrl:null,p=!1!==e.cMapPacked,v=e.CMapReaderFactory||Ece,f="string"==typeof e.standardFontDataUrl?e.standardFontDataUrl:null,z=e.StandardFontDataFactory||Hce,g=!0!==e.stopAtErrors,y=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,M=!1!==e.isEvalSupported,E="boolean"==typeof e.isOffscreenCanvasSupported?e.isOffscreenCanvasSupported:!Nae,b="boolean"==typeof e.isImageDecoderSupported?e.isImageDecoderSupported:!Nae&&(ure.platform.isFirefox||!globalThis.chrome),H=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,V="boolean"==typeof e.disableFontFace?e.disableFontFace:Nae,C=!0===e.fontExtraProperties,L=!0===e.enableXfa,x=e.ownerDocument||globalThis.document,S=!0===e.disableRange,k=!0===e.disableStream,w=!0===e.disableAutoFetch,T=!0===e.pdfBug,O=e.CanvasFactory||Mce,A=e.FilterFactory||bce,R=!0===e.enableHWA,N=i?i.length:e.length??NaN,_="boolean"==typeof e.useSystemFonts?e.useSystemFonts:!Nae&&!V,D="boolean"==typeof e.useWorkerFetch?e.useWorkerFetch:v===uoe&&z===voe&&m&&f&&kre(m,document.baseURI)&&kre(f,document.baseURI);!function(e){Number.isInteger(e)&&(Gae=e)}(d);const P={canvasFactory:new O({ownerDocument:x,enableHWA:R}),filterFactory:new A({docId:n,ownerDocument:x}),cMapReaderFactory:D?null:new v({baseUrl:m,isCompressed:p}),standardFontDataFactory:D?null:new z({baseUrl:f})};if(!h){const e={verbosity:d,port:Uoe.workerPort};h=e.port?Tce.fromPort(e):new Tce(e),t._worker=h}const F={docId:n,apiVersion:"4.10.38",data:r,password:l,disableAutoFetch:w,rangeChunkSize:s,length:N,docBaseUrl:u,enableXfa:L,evaluatorOptions:{maxImageSize:y,disableFontFace:V,ignoreErrors:g,isEvalSupported:M,isOffscreenCanvasSupported:E,isImageDecoderSupported:b,canvasMaxAreaInBytes:H,fontExtraProperties:C,useSystemFonts:_,cMapUrl:D?m:null,standardFontDataUrl:D?f:null}},I={disableFontFace:V,fontExtraProperties:C,ownerDocument:x,pdfBug:T,styleElement:null,loadingParams:{disableAutoFetch:w,enableXfa:L}};return h.promise.then((function(){if(t.destroyed)throw new Error("Loading aborted");if(h.destroyed)throw new Error("Worker was destroyed");const e=h.messageHandler.sendWithPromise("GetDocRequest",F,r?[r.buffer]:null);let l;if(i)l=new Yoe(i,{disableRange:S,disableStream:k});else if(!r){if(!a)throw new Error("getDocument - no `url` parameter provided.");let e;if(Nae)if(kre(a)){if("undefined"==typeof fetch||"undefined"==typeof Response||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");e=oce}else e=mce;else e=kre(a)?oce:sce;l=new e({url:a,length:N,httpHeaders:o,withCredentials:c,rangeChunkSize:s,disableRange:S,disableStream:k})}return e.then((e=>{if(t.destroyed)throw new Error("Loading aborted");if(h.destroyed)throw new Error("Worker was destroyed");const a=new soe(n,e,h.port),r=new Oce(a,t,l,I,P);t._transport=r,a.send("Ready",null)}))})).catch(t._capability.reject),t}function Cce(e){return"object"==typeof e&&Number.isInteger(e?.num)&&e.num>=0&&Number.isInteger(e?.gen)&&e.gen>=0}class Lce{static#aa=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+Lce.#aa++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await(this._transport?.destroy())}catch(e){throw this._worker?.port&&delete this._worker._pendingDestroy,e}this._transport=null,this._worker?.destroy(),this._worker=null}}class xce{constructor(e,t,n=!1,a=null){this.length=e,this.initialData=t,this.progressiveDone=n,this.contentDispositionFilename=a,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(e){this._rangeListeners.push(e)}addProgressListener(e){this._progressListeners.push(e)}addProgressiveReadListener(e){this._progressiveReadListeners.push(e)}addProgressiveDoneListener(e){this._progressiveDoneListeners.push(e)}onDataRange(e,t){for(const n of this._rangeListeners)n(e,t)}onDataProgress(e,t){this._readyCapability.promise.then((()=>{for(const n of this._progressListeners)n(e,t)}))}onDataProgressiveRead(e){this._readyCapability.promise.then((()=>{for(const t of this._progressiveReadListeners)t(e)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(const e of this._progressiveDoneListeners)e()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(e,t){Qae("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class Sce{constructor(e,t){this._pdfInfo=e,this._transport=t}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return ere(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:e="display"}={}){const{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(t)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class kce{#za=null;#ga=!1;constructor(e,t,n,a=!1){this._pageIndex=e,this._pageInfo=t,this._transport=n,this._stats=a?new Sre:null,this._pdfBug=a,this.commonObjs=n.commonObjs,this.objs=new Rce,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:t=this.rotate,offsetX:n=0,offsetY:a=0,dontFlip:r=!1}={}){return new bre({viewBox:this.view,userUnit:this.userUnit,scale:e,rotation:t,offsetX:n,offsetY:a,dontFlip:r})}getAnnotations({intent:e="display"}={}){const{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return ere(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:e,viewport:t,intent:n="display",annotationMode:a=Fae.ENABLE,transform:r=null,background:o=null,optionalContentConfigPromise:c=null,annotationCanvasMap:l=null,pageColors:i=null,printAnnotationStorage:s=null,isEditing:h=!1}){this._stats?.time("Overall");const d=this._transport.getRenderingIntent(n,a,s,h),{renderingIntent:u,cacheKey:m}=d;this.#ga=!1,this.#ya(),c||=this._transport.getOptionalContentConfig(u);let p=this._intentStates.get(m);p||(p=Object.create(null),this._intentStates.set(m,p)),p.streamReaderCancelTimeout&&(clearTimeout(p.streamReaderCancelTimeout),p.streamReaderCancelTimeout=null);const v=!!(4&u);p.displayReadyCapability||(p.displayReadyCapability=Promise.withResolvers(),p.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(d));const f=e=>{p.renderTasks.delete(z),(this._maybeCleanupAfterRender||v)&&(this.#ga=!0),this.#Ma(!v),e?(z.capability.reject(e),this._abortOperatorList({intentState:p,reason:e instanceof Error?e:new Error(e)})):z.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},z=new _ce({callback:f,params:{canvasContext:e,viewport:t,transform:r,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:p.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!v,pdfBug:this._pdfBug,pageColors:i});(p.renderTasks||=new Set).add(z);const g=z.task;return Promise.all([p.displayReadyCapability.promise,c]).then((([e,t])=>{if(this.destroyed)f();else{if(this._stats?.time("Rendering"),!(t.renderingIntent&u))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");z.initializeGraphics({transparency:e,optionalContentConfig:t}),z.operatorListChanged()}})).catch(f),g}getOperatorList({intent:e="display",annotationMode:t=Fae.ENABLE,printAnnotationStorage:n=null,isEditing:a=!1}={}){const r=this._transport.getRenderingIntent(e,t,n,a,!0);let o,c=this._intentStates.get(r.cacheKey);return c||(c=Object.create(null),this._intentStates.set(r.cacheKey,c)),c.opListReadCapability||(o=Object.create(null),o.operatorListChanged=function(){c.operatorList.lastChunk&&(c.opListReadCapability.resolve(c.operatorList),c.renderTasks.delete(o))},c.opListReadCapability=Promise.withResolvers(),(c.renderTasks||=new Set).add(o),c.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(r)),c.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===e,disableNormalization:!0===t},{highWaterMark:100,size:e=>e.items.length})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then((e=>gce.textContent(e)));const t=this.streamTextContent(e);return new Promise((function(e,n){const a=t.getReader(),r={items:[],styles:Object.create(null),lang:null};!function t(){a.read().then((function({value:n,done:a}){a?e(r):(r.lang??=n.lang,Object.assign(r.styles,n.styles),r.items.push(...n.items),t())}),n)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const e=[];for(const t of this._intentStates.values())if(this._abortOperatorList({intentState:t,reason:new Error("Page was destroyed."),force:!0}),!t.opListReadCapability)for(const n of t.renderTasks)e.push(n.completed),n.cancel();return this.objs.clear(),this.#ga=!1,this.#ya(),Promise.all(e)}cleanup(e=!1){this.#ga=!0;const t=this.#Ma(!1);return e&&t&&(this._stats&&=new Sre),t}#Ma(e=!1){if(this.#ya(),!this.#ga||this.destroyed)return!1;if(e)return this.#za=setTimeout((()=>{this.#za=null,this.#Ma(!1)}),5e3),!1;for(const{renderTasks:e,operatorList:t}of this._intentStates.values())if(e.size>0||!t.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#ga=!1,!0}#ya(){this.#za&&(clearTimeout(this.#za),this.#za=null)}_startRenderPage(e,t){const n=this._intentStates.get(t);n&&(this._stats?.timeEnd("Page Request"),n.displayReadyCapability?.resolve(e))}_renderPageChunk(e,t){for(let n=0,a=e.length;n<a;n++)t.operatorList.fnArray.push(e.fnArray[n]),t.operatorList.argsArray.push(e.argsArray[n]);t.operatorList.lastChunk=e.lastChunk,t.operatorList.separateAnnots=e.separateAnnots;for(const e of t.renderTasks)e.operatorListChanged();e.lastChunk&&this.#Ma(!0)}_pumpOperatorList({renderingIntent:e,cacheKey:t,annotationStorageSerializable:n,modifiedIds:a}){const{map:r,transfer:o}=n,c=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:t,annotationStorage:r,modifiedIds:a},o).getReader(),l=this._intentStates.get(t);l.streamReader=c;const i=()=>{c.read().then((({value:e,done:t})=>{t?l.streamReader=null:this._transport.destroyed||(this._renderPageChunk(e,l),i())}),(e=>{if(l.streamReader=null,!this._transport.destroyed){if(l.operatorList){l.operatorList.lastChunk=!0;for(const e of l.renderTasks)e.operatorListChanged();this.#Ma(!0)}if(l.displayReadyCapability)l.displayReadyCapability.reject(e);else{if(!l.opListReadCapability)throw e;l.opListReadCapability.reject(e)}}}))};i()}_abortOperatorList({intentState:e,reason:t,force:n=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!n){if(e.renderTasks.size>0)return;if(t instanceof Hre){let n=100;return t.extraDelay>0&&t.extraDelay<1e3&&(n+=t.extraDelay),void(e.streamReaderCancelTimeout=setTimeout((()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})}),n))}}if(e.streamReader.cancel(new ire(t.message)).catch((()=>{})),e.streamReader=null,!this._transport.destroyed){for(const[t,n]of this._intentStates)if(n===e){this._intentStates.delete(t);break}this.cleanup()}}}get stats(){return this._stats}}class wce{#Ea=new Map;#ba=Promise.resolve();postMessage(e,t){const n={data:structuredClone(e,t?{transfer:t}:null)};this.#ba.then((()=>{for(const[e]of this.#Ea)e.call(this,n)}))}addEventListener(e,t,n=null){let a=null;if(n?.signal instanceof AbortSignal){const{signal:r}=n;if(r.aborted)return void Xae("LoopbackPort - cannot use an `aborted` signal.");const o=()=>this.removeEventListener(e,t);a=()=>r.removeEventListener("abort",o),r.addEventListener("abort",o)}this.#Ea.set(t,a)}removeEventListener(e,t){const n=this.#Ea.get(t);n?.(),this.#Ea.delete(t)}terminate(){for(const[,e]of this.#Ea)e?.();this.#Ea.clear()}}class Tce{static#Ha=0;static#Va=!1;static#Ca;static{Nae&&(this.#Va=!0,Uoe.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(e,t)=>{let n;try{if(n=new URL(e),!n.origin||"null"===n.origin)return!1}catch{return!1}const a=new URL(t,n);return n.origin===a.origin},this._createCDNWrapper=e=>{const t=`await import("${e}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))}}constructor({name:e=null,port:t=null,verbosity:n=Yae()}={}){if(this.name=e,this.destroyed=!1,this.verbosity=n,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,t){if(Tce.#Ca?.has(t))throw new Error("Cannot use more than one PDFWorker per port.");return(Tce.#Ca||=new WeakMap).set(t,this),void this._initializeFromPort(t)}this._initialize()}get promise(){return this._readyCapability.promise}#La(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(e){this._port=e,this._messageHandler=new soe("main","worker",e),this._messageHandler.on("ready",(function(){})),this.#La()}_initialize(){if(Tce.#Va||Tce.#xa)return void this._setupFakeWorker();let{workerSrc:e}=Tce;try{Tce._isSameOrigin(window.location.href,e)||(e=Tce._createCDNWrapper(new URL(e,window.location).href));const t=new Worker(e,{type:"module"}),n=new soe("main","worker",t),a=()=>{r.abort(),n.destroy(),t.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},r=new AbortController;t.addEventListener("error",(()=>{this._webWorker||a()}),{signal:r.signal}),n.on("test",(e=>{r.abort(),!this.destroyed&&e?(this._messageHandler=n,this._port=t,this._webWorker=t,this.#La()):a()})),n.on("ready",(e=>{if(r.abort(),this.destroyed)a();else try{o()}catch{this._setupFakeWorker()}}));const o=()=>{const e=new Uint8Array;n.send("test",e,[e.buffer])};return void o()}catch{Kae("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){Tce.#Va||(Xae("Setting up fake worker."),Tce.#Va=!0),Tce._setupFakeWorkerGlobal.then((e=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const t=new wce;this._port=t;const n="fake"+Tce.#Ha++,a=new soe(n+"_worker",n,t);e.setup(a,t),this._messageHandler=new soe(n,n+"_worker",t),this.#La()})).catch((e=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${e.message}".`))}))}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,Tce.#Ca?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(e){if(!e?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const t=this.#Ca?.get(e.port);if(t){if(t._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return t}return new Tce(e)}static get workerSrc(){if(Uoe.workerSrc)return Uoe.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#xa(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return ere(this,"_setupFakeWorkerGlobal",(async()=>this.#xa?this.#xa:(await import(this.workerSrc)).WorkerMessageHandler)())}}class Oce{#Sa=new Map;#ka=new Map;#wa=new Map;#Ta=new Map;#Oa=null;constructor(e,t,n,a,r){this.messageHandler=e,this.loadingTask=t,this.commonObjs=new Rce,this.fontLoader=new ooe({ownerDocument:a.ownerDocument,styleElement:a.styleElement}),this.loadingParams=a.loadingParams,this._params=a,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.cMapReaderFactory=r.cMapReaderFactory,this.standardFontDataFactory=r.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=n,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#Aa(e,t=null){const n=this.#Sa.get(e);if(n)return n;const a=this.messageHandler.sendWithPromise(e,t);return this.#Sa.set(e,a),a}get annotationStorage(){return ere(this,"annotationStorage",new aoe)}getRenderingIntent(e,t=Fae.ENABLE,n=null,a=!1,r=!1){let o=2,c=noe;switch(e){case"any":o=1;break;case"display":break;case"print":o=4;break;default:Xae(`getRenderingIntent - invalid intent: ${e}`)}const l=4&o&&n instanceof roe?n:this.annotationStorage;switch(t){case Fae.DISABLE:o+=64;break;case Fae.ENABLE:break;case Fae.ENABLE_FORMS:o+=16;break;case Fae.ENABLE_STORAGE:o+=32,c=l.serializable;break;default:Xae(`getRenderingIntent - invalid annotationMode: ${t}`)}a&&(o+=128),r&&(o+=256);const{ids:i,hash:s}=l.modifiedIds;return{renderingIntent:o,cacheKey:[o,c.hash,s].join("_"),annotationStorageSerializable:c,modifiedIds:i}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#Oa?.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const t of this.#ka.values())e.push(t._destroy());this.#ka.clear(),this.#wa.clear(),this.#Ta.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const t=this.messageHandler.sendWithPromise("Terminate",null);return e.push(t),Promise.all(e).then((()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#Sa.clear(),this.filterFactory.destroy(),zce.cleanup(),this._networkStream?.cancelAllRequests(new ire("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:e,loadingTask:t}=this;e.on("GetReader",((e,t)=>{Jae(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=e=>{this._lastProgress={loaded:e.loaded,total:e.total}},t.onPull=()=>{this._fullReader.read().then((function({value:e,done:n}){n?t.close():(Jae(e instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),t.enqueue(new Uint8Array(e),1,[e]))})).catch((e=>{t.error(e)}))},t.onCancel=e=>{this._fullReader.cancel(e),t.ready.catch((e=>{if(!this.destroyed)throw e}))}})),e.on("ReaderHeadersReady",(async e=>{await this._fullReader.headersReady;const{isStreamingSupported:n,isRangeSupported:a,contentLength:r}=this._fullReader;return n&&a||(this._lastProgress&&t.onProgress?.(this._lastProgress),this._fullReader.onProgress=e=>{t.onProgress?.({loaded:e.loaded,total:e.total})}),{isStreamingSupported:n,isRangeSupported:a,contentLength:r}})),e.on("GetRangeReader",((e,t)=>{Jae(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const n=this._networkStream.getRangeReader(e.begin,e.end);n?(t.onPull=()=>{n.read().then((function({value:e,done:n}){n?t.close():(Jae(e instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),t.enqueue(new Uint8Array(e),1,[e]))})).catch((e=>{t.error(e)}))},t.onCancel=e=>{n.cancel(e),t.ready.catch((e=>{if(!this.destroyed)throw e}))}):t.close()})),e.on("GetDoc",(({pdfInfo:e})=>{this._numPages=e.numPages,this._htmlForXfa=e.htmlForXfa,delete e.htmlForXfa,t._capability.resolve(new Sce(e,this))})),e.on("DocException",(e=>{t._capability.reject(ioe(e))})),e.on("PasswordRequest",(e=>{this.#Oa=Promise.withResolvers();try{if(!t.onPassword)throw ioe(e);const n=e=>{e instanceof Error?this.#Oa.reject(e):this.#Oa.resolve({password:e})};t.onPassword(n,e.code)}catch(e){this.#Oa.reject(e)}return this.#Oa.promise})),e.on("DataLoaded",(e=>{t.onProgress?.({loaded:e.length,total:e.length}),this.downloadInfoCapability.resolve(e)})),e.on("StartRenderPage",(e=>{this.destroyed||this.#ka.get(e.pageIndex)._startRenderPage(e.transparency,e.cacheKey)})),e.on("commonobj",(([t,n,a])=>{if(this.destroyed)return null;if(this.commonObjs.has(t))return null;switch(n){case"Font":const{disableFontFace:r,fontExtraProperties:o,pdfBug:c}=this._params;if("error"in a){const e=a.error;Xae(`Error during font loading: ${e}`),this.commonObjs.resolve(t,e);break}const l=c&&globalThis.FontInspector?.enabled?(e,t)=>globalThis.FontInspector.fontAdded(e,t):null,i=new coe(a,{disableFontFace:r,fontExtraProperties:o,inspectFont:l});this.fontLoader.bind(i).catch((()=>e.sendWithPromise("FontFallback",{id:t}))).finally((()=>{!o&&i.data&&(i.data=null),this.commonObjs.resolve(t,i)}));break;case"CopyLocalImage":const{imageRef:s}=a;Jae(s,"The imageRef must be defined.");for(const e of this.#ka.values())for(const[,n]of e.objs)if(n?.ref===s)return n.dataLen?(this.commonObjs.resolve(t,structuredClone(n)),n.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(t,a);break;default:throw new Error(`Got unknown common object type ${n}`)}return null})),e.on("obj",(([e,t,n,a])=>{if(this.destroyed)return;const r=this.#ka.get(t);if(!r.objs.has(e))if(0!==r._intentStates.size)switch(n){case"Image":r.objs.resolve(e,a),a?.dataLen>1e7&&(r._maybeCleanupAfterRender=!0);break;case"Pattern":r.objs.resolve(e,a);break;default:throw new Error(`Got unknown object type ${n}`)}else a?.bitmap?.close()})),e.on("DocProgress",(e=>{this.destroyed||t.onProgress?.({loaded:e.loaded,total:e.total})})),e.on("FetchBuiltInCMap",(async e=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(e)})),e.on("FetchStandardFontData",(async e=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(e)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&Xae("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:e,transfer:t}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:this._fullReader?.filename??null},t).finally((()=>{this.annotationStorage.resetModified()}))}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(new Error("Invalid page request."));const t=e-1,n=this.#wa.get(t);if(n)return n;const a=this.messageHandler.sendWithPromise("GetPage",{pageIndex:t}).then((n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&this.#Ta.set(n.refStr,e);const a=new kce(t,n,this,this._params.pdfBug);return this.#ka.set(t,a),a}));return this.#wa.set(t,a),a}getPageIndex(e){return Cce(e)?this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:t})}getFieldObjects(){return this.#Aa("GetFieldObjects")}hasJSActions(){return this.#Aa("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return"string"!=typeof e?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#Aa("GetDocJSActions")}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:e})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:e})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(e){return this.#Aa("GetOptionalContentConfig").then((t=>new Goe(t,e)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const e="GetMetadata",t=this.#Sa.get(e);if(t)return t;const n=this.messageHandler.sendWithPromise(e,null).then((e=>({info:e[0],metadata:e[1]?new Woe(e[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));return this.#Sa.set(e,n),n}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(e=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of this.#ka.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),this.#Sa.clear(),this.filterFactory.destroy(!0),zce.cleanup()}}cachedPageNumber(e){if(!Cce(e))return null;const t=0===e.gen?`${e.num}R`:`${e.num}R${e.gen}`;return this.#Ta.get(t)??null}}const Ace=Symbol("INITIAL_DATA");class Rce{#Ra=Object.create(null);#Na(e){return this.#Ra[e]||={...Promise.withResolvers(),data:Ace}}get(e,t=null){if(t){const n=this.#Na(e);return n.promise.then((()=>t(n.data))),null}const n=this.#Ra[e];if(!n||n.data===Ace)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return n.data}has(e){const t=this.#Ra[e];return!!t&&t.data!==Ace}delete(e){const t=this.#Ra[e];return!(!t||t.data===Ace||(delete this.#Ra[e],0))}resolve(e,t=null){const n=this.#Na(e);n.data=t,n.resolve()}clear(){for(const e in this.#Ra){const{data:t}=this.#Ra[e];t?.bitmap?.close()}this.#Ra=Object.create(null)}*[Symbol.iterator](){for(const e in this.#Ra){const{data:t}=this.#Ra[e];t!==Ace&&(yield[e,t])}}}class Nce{#_a=null;constructor(e){this.#_a=e,this.onContinue=null}get promise(){return this.#_a.capability.promise}cancel(e=0){this.#_a.cancel(null,e)}get separateAnnots(){const{separateAnnots:e}=this.#_a.operatorList;if(!e)return!1;const{annotationCanvasMap:t}=this.#_a;return e.form||e.canvas&&t?.size>0}}class _ce{#Da=null;static#Pa=new WeakSet;constructor({callback:e,params:t,objs:n,commonObjs:a,annotationCanvasMap:r,operatorList:o,pageIndex:c,canvasFactory:l,filterFactory:i,useRequestAnimationFrame:s=!1,pdfBug:h=!1,pageColors:d=null}){this.callback=e,this.params=t,this.objs=n,this.commonObjs=a,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=o,this._pageIndex=c,this.canvasFactory=l,this.filterFactory=i,this._pdfBug=h,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===s&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Nce(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=t.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:e=!1,optionalContentConfig:t}){if(this.cancelled)return;if(this._canvas){if(_ce.#Pa.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");_ce.#Pa.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:n,viewport:a,transform:r,background:o}=this.params;this.gfx=new Boe(n,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:t},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:r,viewport:a,transparency:e,background:o}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(e=null,t=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#Da&&(window.cancelAnimationFrame(this.#Da),this.#Da=null),_ce.#Pa.delete(this._canvas),this.callback(e||new Hre(`Rendering cancelled, page ${this._pageIndex+1}`,t))}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#Da=window.requestAnimationFrame((()=>{this.#Da=null,this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),_ce.#Pa.delete(this._canvas),this.callback())))}}const Dce="4.10.38",Pce="f9bea397f";function Fce(e){return Math.floor(255*Math.max(0,Math.min(1,e))).toString(16).padStart(2,"0")}function Ice(e){return Math.max(0,Math.min(255,255*e))}class jce{static CMYK_G([e,t,n,a]){return["G",1-Math.min(1,.3*e+.59*n+.11*t+a)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_rgb([e]){return[e=Ice(e),e,e]}static G_HTML([e]){const t=Fce(e);return`#${t}${t}${t}`}static RGB_G([e,t,n]){return["G",.3*e+.59*t+.11*n]}static RGB_rgb(e){return e.map(Ice)}static RGB_HTML(e){return`#${e.map(Fce).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([e,t,n,a]){return["RGB",1-Math.min(1,e+a),1-Math.min(1,n+a),1-Math.min(1,t+a)]}static CMYK_rgb([e,t,n,a]){return[Ice(1-Math.min(1,e+a)),Ice(1-Math.min(1,n+a)),Ice(1-Math.min(1,t+a))]}static CMYK_HTML(e){const t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,n]){const a=1-e,r=1-t,o=1-n;return["CMYK",a,r,o,Math.min(a,r,o)]}}class Bce{create(e,t,n=!1){if(e<=0||t<=0)throw new Error("Invalid SVG dimensions");const a=this._createSVG("svg:svg");return a.setAttribute("version","1.1"),n||(a.setAttribute("width",`${e}px`),a.setAttribute("height",`${t}px`)),a.setAttribute("preserveAspectRatio","none"),a.setAttribute("viewBox",`0 0 ${e} ${t}`),a}createElement(e){if("string"!=typeof e)throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){Qae("Abstract method `_createSVG` called.")}}class Uce extends Bce{_createSVG(e){return document.createElementNS(yre,e)}}class Wce{static setupStorage(e,t,n,a,r){const o=a.getValue(t,{value:null});switch(n.name){case"textarea":if(null!==o.value&&(e.textContent=o.value),"print"===r)break;e.addEventListener("input",(e=>{a.setValue(t,{value:e.target.value})}));break;case"input":if("radio"===n.attributes.type||"checkbox"===n.attributes.type){if(o.value===n.attributes.xfaOn?e.setAttribute("checked",!0):o.value===n.attributes.xfaOff&&e.removeAttribute("checked"),"print"===r)break;e.addEventListener("change",(e=>{a.setValue(t,{value:e.target.checked?e.target.getAttribute("xfaOn"):e.target.getAttribute("xfaOff")})}))}else{if(null!==o.value&&e.setAttribute("value",o.value),"print"===r)break;e.addEventListener("input",(e=>{a.setValue(t,{value:e.target.value})}))}break;case"select":if(null!==o.value){e.setAttribute("value",o.value);for(const e of n.children)e.attributes.value===o.value?e.attributes.selected=!0:e.attributes.hasOwnProperty("selected")&&delete e.attributes.selected}e.addEventListener("input",(e=>{const n=e.target.options,r=-1===n.selectedIndex?"":n[n.selectedIndex].value;a.setValue(t,{value:r})}))}}static setAttributes({html:e,element:t,storage:n=null,intent:a,linkService:r}){const{attributes:o}=t,c=e instanceof HTMLAnchorElement;"radio"===o.type&&(o.name=`${o.name}-${a}`);for(const[t,n]of Object.entries(o))if(null!=n)switch(t){case"class":n.length&&e.setAttribute(t,n.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",n);break;case"style":Object.assign(e.style,n);break;case"textContent":e.textContent=n;break;default:(!c||"href"!==t&&"newWindow"!==t)&&e.setAttribute(t,n)}c&&r.addLinkAttributes(e,o.href,o.newWindow),n&&o.dataId&&this.setupStorage(e,o.dataId,t,n)}static render(e){const t=e.annotationStorage,n=e.linkService,a=e.xfaHtml,r=e.intent||"display",o=document.createElement(a.name);a.attributes&&this.setAttributes({html:o,element:a,intent:r,linkService:n});const c="richText"!==r,l=e.div;if(l.append(o),e.viewport){const t=`matrix(${e.viewport.transform.join(",")})`;l.style.transform=t}c&&l.setAttribute("class","xfaLayer xfaFont");const i=[];if(0===a.children.length){if(a.value){const e=document.createTextNode(a.value);o.append(e),c&&gce.shouldBuildText(a.name)&&i.push(e)}return{textDivs:i}}const s=[[a,-1,o]];for(;s.length>0;){const[e,a,o]=s.at(-1);if(a+1===e.children.length){s.pop();continue}const l=e.children[++s.at(-1)[1]];if(null===l)continue;const{name:h}=l;if("#text"===h){const e=document.createTextNode(l.value);i.push(e),o.append(e);continue}const d=l?.attributes?.xmlns?document.createElementNS(l.attributes.xmlns,h):document.createElement(h);if(o.append(d),l.attributes&&this.setAttributes({html:d,element:l,storage:t,intent:r,linkService:n}),l.children?.length>0)s.push([l,-1,d]);else if(l.value){const e=document.createTextNode(l.value);c&&gce.shouldBuildText(h)&&i.push(e),d.append(e)}}for(const e of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))e.setAttribute("readOnly",!0);return{textDivs:i}}static update(e){const t=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=t,e.div.hidden=!1}}const $ce=1e3,qce=new WeakSet;function Gce(e){return{width:e[2]-e[0],height:e[3]-e[1]}}class Yce{static create(e){switch(e.data.annotationType){case 2:return new Xce(e);case 1:return new Qce(e);case 20:switch(e.data.fieldType){case"Tx":return new Zce(e);case"Btn":return e.data.radioButton?new nle(e):e.data.checkBox?new tle(e):new ale(e);case"Ch":return new rle(e);case"Sig":return new ele(e)}return new Jce(e);case 16:return new ole(e);case 3:return new lle(e);case 4:return new ile(e);case 5:return new sle(e);case 6:return new hle(e);case 8:return new dle(e);case 14:return new mle(e);case 15:return new ple(e);case 7:return new ule(e);case 9:return new vle(e);case 10:return new fle(e);case 11:return new zle(e);case 12:return new gle(e);case 13:return new yle(e);case 17:return new Mle(e);default:return new Kce(e)}}}class Kce{#Fa=null;#Ia=!1;#ja=null;constructor(e,{isRenderable:t=!1,ignoreBorder:n=!1,createQuadrilaterals:a=!1}={}){this.isRenderable=t,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,t&&(this.container=this._createContainer(n)),a&&this._createQuadrilaterals()}static _hasPopupData({titleObj:e,contentsObj:t,richText:n}){return!!(e?.str||t?.str||n?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Kce._hasPopupData(this.data)}updateEdited(e){if(!this.container)return;this.#Fa||={rect:this.data.rect.slice(0)};const{rect:t}=e;t&&this.#Ba(t),this.#ja?.popup.updateEdited(e)}resetEdited(){this.#Fa&&(this.#Ba(this.#Fa.rect),this.#ja?.popup.resetEdited(),this.#Fa=null)}#Ba(e){const{container:{style:t},data:{rect:n,rotation:a},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:o,pageX:c,pageY:l}}}}=this;n?.splice(0,4,...e);const{width:i,height:s}=Gce(e);t.left=100*(e[0]-c)/r+"%",t.top=100*(o-e[3]+l)/o+"%",0===a?(t.width=100*i/r+"%",t.height=100*s/o+"%"):this.setRotation(a)}_createContainer(e){const{data:t,parent:{page:n,viewport:a}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",t.id),this instanceof Jce||(r.tabIndex=$ce);const{style:o}=r;if(o.zIndex=this.parent.zIndex++,t.alternativeText&&(r.title=t.alternativeText),t.noRotate&&r.classList.add("norotate"),!t.rect||this instanceof ole){const{rotation:e}=t;return t.hasOwnCanvas||0===e||this.setRotation(e,r),r}const{width:c,height:l}=Gce(t.rect);if(!e&&t.borderStyle.width>0){o.borderWidth=`${t.borderStyle.width}px`;const e=t.borderStyle.horizontalCornerRadius,n=t.borderStyle.verticalCornerRadius;if(e>0||n>0){const t=`calc(${e}px * var(--scale-factor)) / calc(${n}px * var(--scale-factor))`;o.borderRadius=t}else if(this instanceof nle){const e=`calc(${c}px * var(--scale-factor)) / calc(${l}px * var(--scale-factor))`;o.borderRadius=e}switch(t.borderStyle.style){case 1:o.borderStyle="solid";break;case 2:o.borderStyle="dashed";break;case 3:Xae("Unimplemented border style: beveled");break;case 4:Xae("Unimplemented border style: inset");break;case 5:o.borderBottomStyle="solid"}const a=t.borderColor||null;a?(this.#Ia=!0,o.borderColor=pre.makeHexColor(0|a[0],0|a[1],0|a[2])):o.borderWidth=0}const i=pre.normalizeRect([t.rect[0],n.view[3]-t.rect[1]+n.view[1],t.rect[2],n.view[3]-t.rect[3]+n.view[1]]),{pageWidth:s,pageHeight:h,pageX:d,pageY:u}=a.rawDims;o.left=100*(i[0]-d)/s+"%",o.top=100*(i[1]-u)/h+"%";const{rotation:m}=t;return t.hasOwnCanvas||0===m?(o.width=100*c/s+"%",o.height=100*l/h+"%"):this.setRotation(m,r),r}setRotation(e,t=this.container){if(!this.data.rect)return;const{pageWidth:n,pageHeight:a}=this.parent.viewport.rawDims,{width:r,height:o}=Gce(this.data.rect);let c,l;e%180==0?(c=100*r/n,l=100*o/a):(c=100*o/n,l=100*r/a),t.style.width=`${c}%`,t.style.height=`${l}%`,t.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){const e=(e,t,n)=>{const a=n.detail[e],r=a[0],o=a.slice(1);n.target.style[t]=jce[`${r}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[t]:jce[`${r}_rgb`](o)})};return ere(this,"_commonActions",{display:e=>{const{display:t}=e.detail,n=t%2==1;this.container.style.visibility=n?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:n,noPrint:1===t||2===t})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:t}=e.detail;this.container.style.visibility=t?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:t,noView:t})},focus:e=>{setTimeout((()=>e.target.focus({preventScroll:!1})),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:t=>{e("bgColor","backgroundColor",t)},fillColor:t=>{e("fillColor","backgroundColor",t)},fgColor:t=>{e("fgColor","color",t)},textColor:t=>{e("textColor","color",t)},borderColor:t=>{e("borderColor","borderColor",t)},strokeColor:t=>{e("strokeColor","borderColor",t)},rotation:e=>{const t=e.detail.rotation;this.setRotation(t),this.annotationStorage.setValue(this.data.id,{rotation:t})}})}_dispatchEventFromSandbox(e,t){const n=this._commonActions;for(const a of Object.keys(t.detail)){const r=e[a]||n[a];r?.(t)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;const t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;const n=this._commonActions;for(const[a,r]of Object.entries(t)){const o=n[a];o&&(o({detail:{[a]:r},target:e}),delete t[a])}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:e}=this.data;if(!e)return;const[t,n,a,r]=this.data.rect.map((e=>Math.fround(e)));if(8===e.length){const[o,c,l,i]=e.subarray(2,6);if(a===o&&r===c&&t===l&&n===i)return}const{style:o}=this.container;let c;if(this.#Ia){const{borderColor:e,borderWidth:t}=o;o.borderWidth=0,c=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${e}" stroke-width="${t}">`],this.container.classList.add("hasBorder")}const l=a-t,i=r-n,{svgFactory:s}=this,h=s.createElement("svg");h.classList.add("quadrilateralsContainer"),h.setAttribute("width",0),h.setAttribute("height",0);const d=s.createElement("defs");h.append(d);const u=s.createElement("clipPath"),m=`clippath_${this.data.id}`;u.setAttribute("id",m),u.setAttribute("clipPathUnits","objectBoundingBox"),d.append(u);for(let n=2,a=e.length;n<a;n+=8){const a=e[n],o=e[n+1],h=e[n+2],d=e[n+3],m=s.createElement("rect"),p=(h-t)/l,v=(r-o)/i,f=(a-h)/l,z=(o-d)/i;m.setAttribute("x",p),m.setAttribute("y",v),m.setAttribute("width",f),m.setAttribute("height",z),u.append(m),c?.push(`<rect vector-effect="non-scaling-stroke" x="${p}" y="${v}" width="${f}" height="${z}"/>`)}this.#Ia&&(c.push("</g></svg>')"),o.backgroundImage=c.join("")),this.container.append(h),this.container.style.clipPath=`url(#${m})`}_createPopup(){const{data:e}=this,t=this.#ja=new ole({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]});this.parent.div.append(t.render())}render(){Qae("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){const n=[];if(this._fieldObjects){const a=this._fieldObjects[e];if(a)for(const{page:e,id:r,exportValues:o}of a){if(-1===e)continue;if(r===t)continue;const a="string"==typeof o?o:null,c=document.querySelector(`[data-element-id="${r}"]`);!c||qce.has(c)?n.push({id:r,exportValue:a,domElement:c}):Xae(`_getElementsByName - element not allowed: ${r}`)}return n}for(const a of document.getElementsByName(e)){const{exportValue:e}=a,r=a.getAttribute("data-element-id");r!==t&&qce.has(a)&&n.push({id:r,exportValue:e,domElement:a})}return n}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(const t of e)t.classList.add("highlightArea");else e.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:e,data:{id:t}}=this;this.container.addEventListener("dblclick",(()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:e,editId:t})}))}}class Xce extends Kce{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!!t?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:t}=this,n=document.createElement("a");n.setAttribute("data-element-id",e.id);let a=!1;return e.url?(t.addLinkAttributes(n,e.url,e.newWindow),a=!0):e.action?(this._bindNamedAction(n,e.action),a=!0):e.attachment?(this.#Ua(n,e.attachment,e.attachmentDest),a=!0):e.setOCGState?(this.#Wa(n,e.setOCGState),a=!0):e.dest?(this._bindLink(n,e.dest),a=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,e),a=!0),e.resetForm?(this._bindResetFormAction(n,e.resetForm),a=!0):this.isTooltipOnly&&!a&&(this._bindLink(n,""),a=!0)),this.container.classList.add("linkAnnotation"),a&&this.container.append(n),this.container}#$a(){this.container.setAttribute("data-internal-link","")}_bindLink(e,t){e.href=this.linkService.getDestinationHash(t),e.onclick=()=>(t&&this.linkService.goToDestination(t),!1),(t||""===t)&&this.#$a()}_bindNamedAction(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),this.#$a()}#Ua(e,t,n=null){e.href=this.linkService.getAnchorUrl(""),t.description&&(e.title=t.description),e.onclick=()=>(this.downloadManager?.openOrDownloadData(t.content,t.filename,n),!1),this.#$a()}#Wa(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(t),!1),this.#$a()}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl("");const n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const a of Object.keys(t.actions)){const r=n.get(a);r&&(e[r]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t.id,name:a}}),!1))}e.onclick||(e.onclick=()=>!1),this.#$a()}_bindResetFormAction(e,t){const n=e.onclick;if(n||(e.href=this.linkService.getAnchorUrl("")),this.#$a(),!this._fieldObjects)return Xae('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(n||(e.onclick=()=>!1));e.onclick=()=>{n?.();const{fields:e,refs:a,include:r}=t,o=[];if(0!==e.length||0!==a.length){const t=new Set(a);for(const n of e){const e=this._fieldObjects[n]||[];for(const{id:n}of e)t.add(n)}for(const e of Object.values(this._fieldObjects))for(const n of e)t.has(n.id)===r&&o.push(n)}else for(const e of Object.values(this._fieldObjects))o.push(...e);const c=this.annotationStorage,l=[];for(const e of o){const{id:t}=e;switch(l.push(t),e.type){case"text":{const n=e.defaultValue||"";c.setValue(t,{value:n});break}case"checkbox":case"radiobutton":{const n=e.defaultValue===e.exportValues;c.setValue(t,{value:n});break}case"combobox":case"listbox":{const n=e.defaultValue||"";c.setValue(t,{value:n});break}default:continue}const n=document.querySelector(`[data-element-id="${t}"]`);n&&(qce.has(n)?n.dispatchEvent(new Event("resetform")):Xae(`_bindResetFormAction - element not allowed: ${t}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:l,name:"ResetForm"}}),!1}}}class Qce extends Kce{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const e=document.createElement("img");return e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",e.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),e.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(e),this.container}}class Jce extends Kce{render(){return this.container}showElementAndHideCanvas(e){this.data.hasOwnCanvas&&("CANVAS"===e.previousSibling?.nodeName&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){return ure.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,n,a,r){n.includes("mouse")?e.addEventListener(n,(e=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:a,value:r(e),shift:e.shiftKey,modifier:this._getKeyModifier(e)}})})):e.addEventListener(n,(e=>{if("blur"===n){if(!t.focused||!e.relatedTarget)return;t.focused=!1}else if("focus"===n){if(t.focused)return;t.focused=!0}r&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:a,value:r(e)}})}))}_setEventListeners(e,t,n,a){for(const[r,o]of n)("Action"===o||this.data.actions?.[o])&&("Focus"!==o&&"Blur"!==o||(t||={focused:!1}),this._setEventListener(e,t,r,o,a),"Focus"!==o||this.data.actions?.Blur?"Blur"!==o||this.data.actions?.Focus||this._setEventListener(e,t,"focus","Focus",null):this._setEventListener(e,t,"blur","Blur",null))}_setBackgroundColor(e){const t=this.data.backgroundColor||null;e.style.backgroundColor=null===t?"transparent":pre.makeHexColor(t[0],t[1],t[2])}_setTextStyle(e){const{fontColor:t}=this.data.defaultAppearanceData,n=this.data.defaultAppearanceData.fontSize||9,a=e.style;let r;const o=e=>Math.round(10*e)/10;if(this.data.multiLine){const e=Math.abs(this.data.rect[3]-this.data.rect[1]-2),t=e/(Math.round(e/(Pae*n))||1);r=Math.min(n,o(t/Pae))}else{const e=Math.abs(this.data.rect[3]-this.data.rect[1]-2);r=Math.min(n,o(e/Pae))}a.fontSize=`calc(${r}px * var(--scale-factor))`,a.color=pre.makeHexColor(t[0],t[1],t[2]),null!==this.data.textAlignment&&(a.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute("required",!0):e.removeAttribute("required"),e.setAttribute("aria-required",t)}}class Zce extends Jce{constructor(e){super(e,{isRenderable:e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue})}setPropertyOnSiblings(e,t,n,a){const r=this.annotationStorage;for(const o of this._getElementsByName(e.name,e.id))o.domElement&&(o.domElement[t]=n),r.setValue(o.id,{[a]:n})}render(){const e=this.annotationStorage,t=this.data.id;this.container.classList.add("textWidgetAnnotation");let n=null;if(this.renderForms){const a=e.getValue(t,{value:this.data.fieldValue});let r=a.value||"";const o=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;o&&r.length>o&&(r=r.slice(0,o));let c=a.formattedValue||this.data.textContent?.join("\n")||null;c&&this.data.comb&&(c=c.replaceAll(/\s+/g,""));const l={userValue:r,formattedValue:c,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(n=document.createElement("textarea"),n.textContent=c??r,this.data.doNotScroll&&(n.style.overflowY="hidden")):(n=document.createElement("input"),n.type="text",n.setAttribute("value",c??r),this.data.doNotScroll&&(n.style.overflowX="hidden")),this.data.hasOwnCanvas&&(n.hidden=!0),qce.add(n),n.setAttribute("data-element-id",t),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=$ce,this._setRequired(n,this.data.required),o&&(n.maxLength=o),n.addEventListener("input",(a=>{e.setValue(t,{value:a.target.value}),this.setPropertyOnSiblings(n,"value",a.target.value,"value"),l.formattedValue=null})),n.addEventListener("resetform",(e=>{const t=this.data.defaultFieldValue??"";n.value=l.userValue=t,l.formattedValue=null}));let i=e=>{const{formattedValue:t}=l;null!=t&&(e.target.value=t),e.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){n.addEventListener("focus",(e=>{if(l.focused)return;const{target:t}=e;l.userValue&&(t.value=l.userValue),l.lastCommittedValue=t.value,l.commitKey=1,this.data.actions?.Focus||(l.focused=!0)})),n.addEventListener("updatefromsandbox",(n=>{this.showElementAndHideCanvas(n.target);const a={value(n){l.userValue=n.detail.value??"",e.setValue(t,{value:l.userValue.toString()}),n.target.value=l.userValue},formattedValue(n){const{formattedValue:a}=n.detail;l.formattedValue=a,null!=a&&n.target!==document.activeElement&&(n.target.value=a),e.setValue(t,{formattedValue:a})},selRange(e){e.target.setSelectionRange(...e.detail.selRange)},charLimit:n=>{const{charLimit:a}=n.detail,{target:r}=n;if(0===a)return void r.removeAttribute("maxLength");r.setAttribute("maxLength",a);let o=l.userValue;!o||o.length<=a||(o=o.slice(0,a),r.value=l.userValue=o,e.setValue(t,{value:o}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:o,willCommit:!0,commitKey:1,selStart:r.selectionStart,selEnd:r.selectionEnd}}))}};this._dispatchEventFromSandbox(a,n)})),n.addEventListener("keydown",(e=>{l.commitKey=1;let n=-1;if("Escape"===e.key?n=0:"Enter"!==e.key||this.data.multiLine?"Tab"===e.key&&(l.commitKey=3):n=2,-1===n)return;const{value:a}=e.target;l.lastCommittedValue!==a&&(l.lastCommittedValue=a,l.userValue=a,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:a,willCommit:!0,commitKey:n,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}))}));const a=i;i=null,n.addEventListener("blur",(e=>{if(!l.focused||!e.relatedTarget)return;this.data.actions?.Blur||(l.focused=!1);const{value:n}=e.target;l.userValue=n,l.lastCommittedValue!==n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:n,willCommit:!0,commitKey:l.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}),a(e)})),this.data.actions?.Keystroke&&n.addEventListener("beforeinput",(e=>{l.lastCommittedValue=null;const{data:n,target:a}=e,{value:r,selectionStart:o,selectionEnd:c}=a;let i=o,s=c;switch(e.inputType){case"deleteWordBackward":{const e=r.substring(0,o).match(/\w*[^\w]*$/);e&&(i-=e[0].length);break}case"deleteWordForward":{const e=r.substring(o).match(/^[^\w]*\w*/);e&&(s+=e[0].length);break}case"deleteContentBackward":o===c&&(i-=1);break;case"deleteContentForward":o===c&&(s+=1)}e.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:r,change:n||"",willCommit:!1,selStart:i,selEnd:s}})})),this._setEventListeners(n,l,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.value))}if(i&&n.addEventListener("blur",i),this.data.comb){const e=(this.data.rect[2]-this.data.rect[0])/o;n.classList.add("comb"),n.style.letterSpacing=`calc(${e}px * var(--scale-factor) - 1ch)`}}else n=document.createElement("div"),n.textContent=this.data.fieldValue,n.style.verticalAlign="middle",n.style.display="table-cell",this.data.hasOwnCanvas&&(n.hidden=!0);return this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class ele extends Jce{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class tle extends Jce{constructor(e){super(e,{isRenderable:e.renderForms})}render(){const e=this.annotationStorage,t=this.data,n=t.id;let a=e.getValue(n,{value:t.exportValue===t.fieldValue}).value;"string"==typeof a&&(a="Off"!==a,e.setValue(n,{value:a})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const r=document.createElement("input");return qce.add(r),r.setAttribute("data-element-id",n),r.disabled=t.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=t.fieldName,a&&r.setAttribute("checked",!0),r.setAttribute("exportValue",t.exportValue),r.tabIndex=$ce,r.addEventListener("change",(a=>{const{name:r,checked:o}=a.target;for(const a of this._getElementsByName(r,n)){const n=o&&a.exportValue===t.exportValue;a.domElement&&(a.domElement.checked=n),e.setValue(a.id,{value:n})}e.setValue(n,{value:o})})),r.addEventListener("resetform",(e=>{const n=t.defaultFieldValue||"Off";e.target.checked=n===t.exportValue})),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",(t=>{const a={value(t){t.target.checked="Off"!==t.detail.value,e.setValue(n,{value:t.target.checked})}};this._dispatchEventFromSandbox(a,t)})),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.checked))),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class nle extends Jce{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const e=this.annotationStorage,t=this.data,n=t.id;let a=e.getValue(n,{value:t.fieldValue===t.buttonValue}).value;if("string"==typeof a&&(a=a!==t.buttonValue,e.setValue(n,{value:a})),a)for(const a of this._getElementsByName(t.fieldName,n))e.setValue(a.id,{value:!1});const r=document.createElement("input");if(qce.add(r),r.setAttribute("data-element-id",n),r.disabled=t.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=t.fieldName,a&&r.setAttribute("checked",!0),r.tabIndex=$ce,r.addEventListener("change",(t=>{const{name:a,checked:r}=t.target;for(const t of this._getElementsByName(a,n))e.setValue(t.id,{value:!1});e.setValue(n,{value:r})})),r.addEventListener("resetform",(e=>{const n=t.defaultFieldValue;e.target.checked=null!=n&&n===t.buttonValue})),this.enableScripting&&this.hasJSActions){const a=t.buttonValue;r.addEventListener("updatefromsandbox",(t=>{const r={value:t=>{const r=a===t.detail.value;for(const a of this._getElementsByName(t.target.name)){const t=r&&a.id===n;a.domElement&&(a.domElement.checked=t),e.setValue(a.id,{value:t})}}};this._dispatchEventFromSandbox(r,t)})),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.checked))}return this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class ale extends Xce{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){const e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton");const t=e.lastChild;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener("updatefromsandbox",(e=>{this._dispatchEventFromSandbox({},e)}))),e}}class rle extends Jce{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const e=this.annotationStorage,t=this.data.id,n=e.getValue(t,{value:this.data.fieldValue}),a=document.createElement("select");qce.add(a),a.setAttribute("data-element-id",t),a.disabled=this.data.readOnly,this._setRequired(a,this.data.required),a.name=this.data.fieldName,a.tabIndex=$ce;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(a.size=this.data.options.length,this.data.multiSelect&&(a.multiple=!0)),a.addEventListener("resetform",(e=>{const t=this.data.defaultFieldValue;for(const e of a.options)e.selected=e.value===t}));for(const e of this.data.options){const t=document.createElement("option");t.textContent=e.displayValue,t.value=e.exportValue,n.value.includes(e.exportValue)&&(t.setAttribute("selected",!0),r=!1),a.append(t)}let o=null;if(r){const e=document.createElement("option");e.value=" ",e.setAttribute("hidden",!0),e.setAttribute("selected",!0),a.prepend(e),o=()=>{e.remove(),a.removeEventListener("input",o),o=null},a.addEventListener("input",o)}const c=e=>{const t=e?"value":"textContent",{options:n,multiple:r}=a;return r?Array.prototype.filter.call(n,(e=>e.selected)).map((e=>e[t])):-1===n.selectedIndex?null:n[n.selectedIndex][t]};let l=c(!1);const i=e=>{const t=e.target.options;return Array.prototype.map.call(t,(e=>({displayValue:e.textContent,exportValue:e.value})))};return this.enableScripting&&this.hasJSActions?(a.addEventListener("updatefromsandbox",(n=>{const r={value(n){o?.();const r=n.detail.value,i=new Set(Array.isArray(r)?r:[r]);for(const e of a.options)e.selected=i.has(e.value);e.setValue(t,{value:c(!0)}),l=c(!1)},multipleSelection(e){a.multiple=!0},remove(n){const r=a.options,o=n.detail.remove;r[o].selected=!1,a.remove(o),r.length>0&&-1===Array.prototype.findIndex.call(r,(e=>e.selected))&&(r[0].selected=!0),e.setValue(t,{value:c(!0),items:i(n)}),l=c(!1)},clear(n){for(;0!==a.length;)a.remove(0);e.setValue(t,{value:null,items:[]}),l=c(!1)},insert(n){const{index:r,displayValue:o,exportValue:s}=n.detail.insert,h=a.children[r],d=document.createElement("option");d.textContent=o,d.value=s,h?h.before(d):a.append(d),e.setValue(t,{value:c(!0),items:i(n)}),l=c(!1)},items(n){const{items:r}=n.detail;for(;0!==a.length;)a.remove(0);for(const e of r){const{displayValue:t,exportValue:n}=e,r=document.createElement("option");r.textContent=t,r.value=n,a.append(r)}a.options.length>0&&(a.options[0].selected=!0),e.setValue(t,{value:c(!0),items:i(n)}),l=c(!1)},indices(n){const a=new Set(n.detail.indices);for(const e of n.target.options)e.selected=a.has(e.index);e.setValue(t,{value:c(!0)}),l=c(!1)},editable(e){e.target.disabled=!e.detail.editable}};this._dispatchEventFromSandbox(r,n)})),a.addEventListener("input",(n=>{const a=c(!0),r=c(!1);e.setValue(t,{value:a}),n.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:l,change:r,changeEx:a,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(a,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(e=>e.target.value))):a.addEventListener("input",(function(n){e.setValue(t,{value:c(!0)})})),this.data.combo&&this._setTextStyle(a),this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class ole extends Kce{constructor(e){const{data:t,elements:n}=e;super(e,{isRenderable:Kce._hasPopupData(t)}),this.elements=n,this.popup=null}render(){this.container.classList.add("popupAnnotation");const e=this.popup=new cle({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),t=[];for(const n of this.elements)n.popup=e,n.container.ariaHasPopup="dialog",t.push(n.data.id),n.addHighlightArea();return this.container.setAttribute("aria-controls",t.map((e=>`${gre}${e}`)).join(",")),this.container}}class cle{#qa=this.#Ga.bind(this);#Ya=this.#Ka.bind(this);#Xa=this.#Qa.bind(this);#Ja=this.#Za.bind(this);#er=null;#me=null;#tr=null;#nr=null;#ar=null;#rr=null;#or=null;#cr=!1;#lr=null;#L=null;#ir=null;#sr=null;#hr=null;#Fa=null;#dr=!1;constructor({container:e,color:t,elements:n,titleObj:a,modificationDate:r,contentsObj:o,richText:c,parent:l,rect:i,parentRect:s,open:h}){this.#me=e,this.#hr=a,this.#tr=o,this.#sr=c,this.#rr=l,this.#er=t,this.#ir=i,this.#or=s,this.#ar=n,this.#nr=Ore.toDateObject(r),this.trigger=n.flatMap((e=>e.getElementsToTriggerPopup()));for(const e of this.trigger)e.addEventListener("click",this.#Ja),e.addEventListener("mouseenter",this.#Xa),e.addEventListener("mouseleave",this.#Ya),e.classList.add("popupTriggerArea");for(const e of n)e.container?.addEventListener("keydown",this.#qa);this.#me.hidden=!0,h&&this.#Za()}render(){if(this.#lr)return;const e=this.#lr=document.createElement("div");if(e.className="popup",this.#er){const t=e.style.outlineColor=pre.makeHexColor(...this.#er);if(CSS.supports("background-color","color-mix(in srgb, red 30%, white)"))e.style.backgroundColor=`color-mix(in srgb, ${t} 30%, white)`;else{const t=.7;e.style.backgroundColor=pre.makeHexColor(...this.#er.map((e=>Math.floor(t*(255-e)+e))))}}const t=document.createElement("span");t.className="header";const n=document.createElement("h1");if(t.append(n),({dir:n.dir,str:n.textContent}=this.#hr),e.append(t),this.#nr){const e=document.createElement("span");e.classList.add("popupDate"),e.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),e.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#nr.valueOf()})),t.append(e)}const a=this.#ur;if(a)Wce.render({xfaHtml:a,intent:"richText",div:e}),e.lastChild.classList.add("richText","popupContent");else{const t=this._formatContents(this.#tr);e.append(t)}this.#me.append(e)}get#ur(){const e=this.#sr,t=this.#tr;return!e?.str||t?.str&&t.str!==e.str?null:this.#sr.html||null}get#mr(){return this.#ur?.attributes?.style?.fontSize||0}get#pr(){return this.#ur?.attributes?.style?.color||null}#vr(e){const t=[],n={str:e,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:t}]}},a={style:{color:this.#pr,fontSize:this.#mr?`calc(${this.#mr}px * var(--scale-factor))`:""}};for(const n of e.split("\n"))t.push({name:"span",value:n,attributes:a});return n}_formatContents({str:e,dir:t}){const n=document.createElement("p");n.classList.add("popupContent"),n.dir=t;const a=e.split(/(?:\r\n?|\n)/);for(let e=0,t=a.length;e<t;++e){const r=a[e];n.append(document.createTextNode(r)),e<t-1&&n.append(document.createElement("br"))}return n}#Ga(e){e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||("Enter"===e.key||"Escape"===e.key&&this.#cr)&&this.#Za()}updateEdited({rect:e,popupContent:t}){this.#Fa||={contentsObj:this.#tr,richText:this.#sr},e&&(this.#L=null),t&&(this.#sr=this.#vr(t),this.#tr=null),this.#lr?.remove(),this.#lr=null}resetEdited(){this.#Fa&&(({contentsObj:this.#tr,richText:this.#sr}=this.#Fa),this.#Fa=null,this.#lr?.remove(),this.#lr=null,this.#L=null)}#fr(){if(null!==this.#L)return;const{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:n,pageX:a,pageY:r}}}=this.#rr;let o=!!this.#or,c=o?this.#or:this.#ir;for(const e of this.#ar)if(!c||null!==pre.intersect(e.data.rect,c)){c=e.data.rect,o=!0;break}const l=pre.normalizeRect([c[0],e[3]-c[1]+e[1],c[2],e[3]-c[3]+e[1]]),i=o?c[2]-c[0]+5:0,s=l[0]+i,h=l[1];this.#L=[100*(s-a)/t,100*(h-r)/n];const{style:d}=this.#me;d.left=`${this.#L[0]}%`,d.top=`${this.#L[1]}%`}#Za(){this.#cr=!this.#cr,this.#cr?(this.#Qa(),this.#me.addEventListener("click",this.#Ja),this.#me.addEventListener("keydown",this.#qa)):(this.#Ka(),this.#me.removeEventListener("click",this.#Ja),this.#me.removeEventListener("keydown",this.#qa))}#Qa(){this.#lr||this.render(),this.isVisible?this.#cr&&this.#me.classList.add("focused"):(this.#fr(),this.#me.hidden=!1,this.#me.style.zIndex=parseInt(this.#me.style.zIndex)+1e3)}#Ka(){this.#me.classList.remove("focused"),!this.#cr&&this.isVisible&&(this.#me.hidden=!0,this.#me.style.zIndex=parseInt(this.#me.style.zIndex)-1e3)}forceHide(){this.#dr=this.isVisible,this.#dr&&(this.#me.hidden=!0)}maybeShow(){this.#dr&&(this.#lr||this.#Qa(),this.#dr=!1,this.#me.hidden=!1)}get isVisible(){return!1===this.#me.hidden}}class lle extends Kce{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.textContent=e.data.textContent,this.textPosition=e.data.textPosition,this.annotationEditorType=Iae.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const e=document.createElement("div");e.classList.add("annotationTextContent"),e.setAttribute("role","comment");for(const t of this.textContent){const n=document.createElement("span");n.textContent=t,e.append(n)}this.container.append(e)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class ile extends Kce{#zr=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const e=this.data,{width:t,height:n}=Gce(e.rect),a=this.svgFactory.create(t,n,!0),r=this.#zr=this.svgFactory.createElement("svg:line");return r.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),r.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),r.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),r.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),r.setAttribute("stroke-width",e.borderStyle.width||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),a.append(r),this.container.append(a),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#zr}addHighlightArea(){this.container.classList.add("highlightArea")}}class sle extends Kce{#gr=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const e=this.data,{width:t,height:n}=Gce(e.rect),a=this.svgFactory.create(t,n,!0),r=e.borderStyle.width,o=this.#gr=this.svgFactory.createElement("svg:rect");return o.setAttribute("x",r/2),o.setAttribute("y",r/2),o.setAttribute("width",t-r),o.setAttribute("height",n-r),o.setAttribute("stroke-width",r||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),a.append(o),this.container.append(a),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#gr}addHighlightArea(){this.container.classList.add("highlightArea")}}class hle extends Kce{#yr=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const e=this.data,{width:t,height:n}=Gce(e.rect),a=this.svgFactory.create(t,n,!0),r=e.borderStyle.width,o=this.#yr=this.svgFactory.createElement("svg:ellipse");return o.setAttribute("cx",t/2),o.setAttribute("cy",n/2),o.setAttribute("rx",t/2-r/2),o.setAttribute("ry",n/2-r/2),o.setAttribute("stroke-width",r||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),a.append(o),this.container.append(a),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#yr}addHighlightArea(){this.container.classList.add("highlightArea")}}class dle extends Kce{#Mr=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:t,borderStyle:n,popupRef:a}}=this;if(!t)return this.container;const{width:r,height:o}=Gce(e),c=this.svgFactory.create(r,o,!0);let l=[];for(let n=0,a=t.length;n<a;n+=2){const a=t[n]-e[0],r=e[3]-t[n+1];l.push(`${a},${r}`)}l=l.join(" ");const i=this.#Mr=this.svgFactory.createElement(this.svgElementName);return i.setAttribute("points",l),i.setAttribute("stroke-width",n.width||1),i.setAttribute("stroke","transparent"),i.setAttribute("fill","transparent"),c.append(i),this.container.append(c),!a&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Mr}addHighlightArea(){this.container.classList.add("highlightArea")}}class ule extends dle{constructor(e){super(e),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class mle extends Kce{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class ple extends Kce{#Er=null;#br=[];constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?Iae.HIGHLIGHT:Iae.INK}#Hr(e,t){switch(e){case 90:return{transform:`rotate(90) translate(${-t[0]},${t[1]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};case 180:return{transform:`rotate(180) translate(${-t[2]},${t[1]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]};case 270:return{transform:`rotate(270) translate(${-t[2]},${t[3]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};default:return{transform:`translate(${-t[0]},${t[3]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]}}}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,rotation:t,inkLists:n,borderStyle:a,popupRef:r}}=this,{transform:o,width:c,height:l}=this.#Hr(t,e),i=this.svgFactory.create(c,l,!0),s=this.#Er=this.svgFactory.createElement("svg:g");i.append(s),s.setAttribute("stroke-width",a.width||1),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),s.setAttribute("stroke-miterlimit",10),s.setAttribute("stroke","transparent"),s.setAttribute("fill","transparent"),s.setAttribute("transform",o);for(let e=0,t=n.length;e<t;e++){const t=this.svgFactory.createElement(this.svgElementName);this.#br.push(t),t.setAttribute("points",n[e].join(",")),s.append(t)}return!r&&this.hasPopupData&&this._createPopup(),this.container.append(i),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);const{thickness:t,points:n,rect:a}=e,r=this.#Er;if(t>=0&&r.setAttribute("stroke-width",t||1),n)for(let e=0,t=this.#br.length;e<t;e++)this.#br[e].setAttribute("points",n[e].join(","));if(a){const{transform:e,width:t,height:n}=this.#Hr(this.data.rotation,a);r.parentElement.setAttribute("viewBox",`0 0 ${t} ${n}`),r.setAttribute("transform",e)}}getElementsToTriggerPopup(){return this.#br}addHighlightArea(){this.container.classList.add("highlightArea")}}class vle extends Kce{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=Iae.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class fle extends Kce{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class zle extends Kce{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class gle extends Kce{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class yle extends Kce{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=Iae.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class Mle extends Kce{#Vr=null;constructor(e){super(e,{isRenderable:!0});const{file:t}=this.data;this.filename=t.filename,this.content=t.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...t})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:t}=this;let n;t.hasAppearance||0===t.fillAlpha?n=document.createElement("div"):(n=document.createElement("img"),n.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(t.name)?"paperclip":"pushpin"}.svg`,t.fillAlpha&&t.fillAlpha<1&&(n.style=`filter: opacity(${Math.round(100*t.fillAlpha)}%);`)),n.addEventListener("dblclick",this.#Cr.bind(this)),this.#Vr=n;const{isMac:a}=ure.platform;return e.addEventListener("keydown",(e=>{"Enter"===e.key&&(a?e.metaKey:e.ctrlKey)&&this.#Cr()})),!t.popupRef&&this.hasPopupData?this._createPopup():n.classList.add("popupTriggerArea"),e.append(n),e}getElementsToTriggerPopup(){return this.#Vr}addHighlightArea(){this.container.classList.add("highlightArea")}#Cr(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class Ele{#Lr=null;#xr=null;#Sr=new Map;#kr=null;constructor({div:e,accessibilityManager:t,annotationCanvasMap:n,annotationEditorUIManager:a,page:r,viewport:o,structTreeLayer:c}){this.div=e,this.#Lr=t,this.#xr=n,this.#kr=c||null,this.page=r,this.viewport=o,this.zIndex=0,this._annotationEditorUIManager=a}hasEditableAnnotations(){return this.#Sr.size>0}async#wr(e,t){const n=e.firstChild||e,a=n.id=`${gre}${t}`,r=await(this.#kr?.getAriaAttributes(a));if(r)for(const[e,t]of r)n.setAttribute(e,t);this.div.append(e),this.#Lr?.moveElementInDOM(this.div,e,n,!1)}async render(e){const{annotations:t}=e,n=this.div;Dre(n,this.viewport);const a=new Map,r={data:null,layer:n,linkService:e.linkService,downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:!1!==e.renderForms,svgFactory:new Uce,annotationStorage:e.annotationStorage||new aoe,enableScripting:!0===e.enableScripting,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(const e of t){if(e.noHTML)continue;const t=16===e.annotationType;if(t){const t=a.get(e.id);if(!t)continue;r.elements=t}else{const{width:t,height:n}=Gce(e.rect);if(t<=0||n<=0)continue}r.data=e;const n=Yce.create(r);if(!n.isRenderable)continue;if(!t&&e.popupRef){const t=a.get(e.popupRef);t?t.push(n):a.set(e.popupRef,[n])}const o=n.render();e.hidden&&(o.style.visibility="hidden"),await this.#wr(o,e.id),n._isEditable&&(this.#Sr.set(n.data.id,n),this._annotationEditorUIManager?.renderAnnotationElement(n))}this.#Tr()}update({viewport:e}){const t=this.div;this.viewport=e,Dre(t,{rotation:e.rotation}),this.#Tr(),t.hidden=!1}#Tr(){if(!this.#xr)return;const e=this.div;for(const[t,n]of this.#xr){const a=e.querySelector(`[data-annotation-id="${t}"]`);if(!a)continue;n.className="annotationContent";const{firstChild:r}=a;r?"CANVAS"===r.nodeName?r.replaceWith(n):r.classList.contains("annotationContent")?r.after(n):r.before(n):a.append(n)}this.#xr.clear()}getEditableAnnotations(){return Array.from(this.#Sr.values())}getEditableAnnotation(e){return this.#Sr.get(e)}}const ble=/\r\n?|\n/g;class Hle extends Xre{#er;#Or="";#Ar=`${this.id}-editor`;#Rr=null;#mr;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const e=Hle.prototype,t=e=>e.isEmpty(),n=Gre.TRANSLATE_SMALL,a=Gre.TRANSLATE_BIG;return ere(this,"_keyboardManager",new $re([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],e.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],e._translateEmpty,{args:[-n,0],checker:t}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-a,0],checker:t}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[n,0],checker:t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[a,0],checker:t}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-n],checker:t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-a],checker:t}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,n],checker:t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,a],checker:t}]]))}static _type="freetext";static _editorType=Iae.FREETEXT;constructor(e){super({...e,name:"freeTextEditor"}),this.#er=e.color||Hle._defaultColor||Xre._defaultLineColor,this.#mr=e.fontSize||Hle._defaultFontSize}static initialize(e,t){Xre.initialize(e,t);const n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,t){switch(e){case jae.FREETEXT_SIZE:Hle._defaultFontSize=t;break;case jae.FREETEXT_COLOR:Hle._defaultColor=t}}updateParams(e,t){switch(e){case jae.FREETEXT_SIZE:this.#Nr(t);break;case jae.FREETEXT_COLOR:this.#_r(t)}}static get defaultPropertiesToUpdate(){return[[jae.FREETEXT_SIZE,Hle._defaultFontSize],[jae.FREETEXT_COLOR,Hle._defaultColor||Xre._defaultLineColor]]}get propertiesToUpdate(){return[[jae.FREETEXT_SIZE,this.#mr],[jae.FREETEXT_COLOR,this.#er]]}#Nr(e){const t=e=>{this.editorDiv.style.fontSize=`calc(${e}px * var(--scale-factor))`,this.translate(0,-(e-this.#mr)*this.parentScale),this.#mr=e,this.#Dr()},n=this.#mr;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:jae.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#_r(e){const t=e=>{this.#er=this.editorDiv.style.color=e},n=this.#er;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:jae.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(e,t){this._uiManager.translateSelectedEditors(e,t,!0)}getInitialTranslation(){const e=this.parentScale;return[-Hle._internalPadding*e,-(Hle._internalPadding+this.#mr)*e]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(Iae.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#Rr=new AbortController;const e=this._uiManager.combinedSignal(this.#Rr);this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#Ar),this._isDraggable=!0,this.#Rr?.abort(),this.#Rr=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#Pr(){const e=[];this.editorDiv.normalize();let t=null;for(const n of this.editorDiv.childNodes)t?.nodeType===Node.TEXT_NODE&&"BR"===n.nodeName||(e.push(Hle.#Fr(n)),t=n);return e.join("\n")}#Dr(){const[e,t]=this.parentDimensions;let n;if(this.isAttachedToDOM)n=this.div.getBoundingClientRect();else{const{currentLayer:e,div:t}=this,a=t.style.display,r=t.classList.contains("hidden");t.classList.remove("hidden"),t.style.display="hidden",e.div.append(this.div),n=t.getBoundingClientRect(),t.remove(),t.style.display=a,t.classList.toggle("hidden",r)}this.rotation%180==this.parentRotation%180?(this.width=n.width/e,this.height=n.height/t):(this.width=n.height/e,this.height=n.width/t),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=this.#Or,t=this.#Or=this.#Pr().trimEnd();if(e===t)return;const n=e=>{this.#Or=e,e?(this.#Ir(),this._uiManager.rebuild(this),this.#Dr()):this.remove()};this.addCommands({cmd:()=>{n(t)},undo:()=>{n(e)},mustExec:!1}),this.#Dr()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(e){this.enterInEditMode()}keydown(e){e.target===this.div&&"Enter"===e.key&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){Hle._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let e,t;this.width&&(e=this.x,t=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#Ar),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:n}=this.editorDiv;if(n.fontSize=`calc(${this.#mr}px * var(--scale-factor))`,n.color=this.#er,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),jre(this,this.div,["dblclick","keydown"]),this.width){const[n,a]=this.parentDimensions;if(this.annotationElementId){const{position:r}=this._initialData;let[o,c]=this.getInitialTranslation();[o,c]=this.pageTranslationToScreen(o,c);const[l,i]=this.pageDimensions,[s,h]=this.pageTranslation;let d,u;switch(this.rotation){case 0:d=e+(r[0]-s)/l,u=t+this.height-(r[1]-h)/i;break;case 90:d=e+(r[0]-s)/l,u=t-(r[1]-h)/i,[o,c]=[c,-o];break;case 180:d=e-this.width+(r[0]-s)/l,u=t-(r[1]-h)/i,[o,c]=[-o,-c];break;case 270:d=e+(r[0]-s-this.height*i)/l,u=t+(r[1]-h-this.width*l)/i,[o,c]=[-c,o]}this.setAt(d*n,u*a,o,c)}else this.setAt(e*n,t*a,this.width*n,this.height*a);this.#Ir(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#Fr(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(ble,"")}editorDivPaste(e){const t=e.clipboardData||window.clipboardData,{types:n}=t;if(1===n.length&&"text/plain"===n[0])return;e.preventDefault();const a=Hle.#jr(t.getData("text")||"").replaceAll(ble,"\n");if(!a)return;const r=window.getSelection();if(!r.rangeCount)return;this.editorDiv.normalize(),r.deleteFromDocument();const o=r.getRangeAt(0);if(!a.includes("\n"))return o.insertNode(document.createTextNode(a)),this.editorDiv.normalize(),void r.collapseToStart();const{startContainer:c,startOffset:l}=o,i=[],s=[];if(c.nodeType===Node.TEXT_NODE){const e=c.parentElement;if(s.push(c.nodeValue.slice(l).replaceAll(ble,"")),e!==this.editorDiv){let t=i;for(const n of this.editorDiv.childNodes)n!==e?t.push(Hle.#Fr(n)):t=s}i.push(c.nodeValue.slice(0,l).replaceAll(ble,""))}else if(c===this.editorDiv){let e=i,t=0;for(const n of this.editorDiv.childNodes)t++===l&&(e=s),e.push(Hle.#Fr(n))}this.#Or=`${i.join("\n")}${a}${s.join("\n")}`,this.#Ir();const h=new Range;let d=i.reduce(((e,t)=>e+t.length),0);for(const{firstChild:e}of this.editorDiv.childNodes)if(e.nodeType===Node.TEXT_NODE){const t=e.nodeValue.length;if(d<=t){h.setStart(e,d),h.setEnd(e,d);break}d-=t}r.removeAllRanges(),r.addRange(h)}#Ir(){if(this.editorDiv.replaceChildren(),this.#Or)for(const e of this.#Or.split("\n")){const t=document.createElement("div");t.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(t)}}#Br(){return this.#Or.replaceAll(" "," ")}static#jr(e){return e.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static async deserialize(e,t,n){let a=null;if(e instanceof lle){const{data:{defaultAppearanceData:{fontSize:t,fontColor:n},rect:r,rotation:o,id:c,popupRef:l},textContent:i,textPosition:s,parent:{page:{pageNumber:h}}}=e;if(!i||0===i.length)return null;a=e={annotationType:Iae.FREETEXT,color:Array.from(n),fontSize:t,value:i.join("\n"),position:s,pageIndex:h-1,rect:r.slice(0),rotation:o,id:c,deleted:!1,popupRef:l}}const r=await super.deserialize(e,t,n);return r.#mr=e.fontSize,r.#er=pre.makeHexColor(...e.color),r.#Or=Hle.#jr(e.value),r.annotationElementId=e.id||null,r._initialData=a,r}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const t=Hle._internalPadding*this.parentScale,n=this.getRect(t,t),a=Xre._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#er),r={annotationType:Iae.FREETEXT,color:a,fontSize:this.#mr,value:this.#Br(),pageIndex:this.pageIndex,rect:n,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?r:this.annotationElementId&&!this.#Ur(r)?null:(r.id=this.annotationElementId,r)}#Ur(e){const{value:t,fontSize:n,color:a,pageIndex:r}=this._initialData;return this._hasBeenMoved||e.value!==t||e.fontSize!==n||e.color.some(((e,t)=>e!==a[t]))||e.pageIndex!==r}renderAnnotationElement(e){const t=super.renderAnnotationElement(e);if(this.deleted)return t;const{style:n}=t;n.fontSize=`calc(${this.#mr}px * var(--scale-factor))`,n.color=this.#er,t.replaceChildren();for(const e of this.#Or.split("\n")){const n=document.createElement("div");n.append(e?document.createTextNode(e):document.createElement("br")),t.append(n)}const a=Hle._internalPadding*this.parentScale;return e.updateEdited({rect:this.getRect(a,a),popupContent:this.#Or}),t}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}}class Vle{static PRECISION=1e-4;toSVGPath(){Qae("Abstract method `toSVGPath` must be implemented.")}get box(){Qae("Abstract getter `box` must be implemented.")}serialize(e,t){Qae("Abstract method `serialize` must be implemented.")}static _rescale(e,t,n,a,r,o){o||=new Float32Array(e.length);for(let c=0,l=e.length;c<l;c+=2)o[c]=t+e[c]*a,o[c+1]=n+e[c+1]*r;return o}static _rescaleAndSwap(e,t,n,a,r,o){o||=new Float32Array(e.length);for(let c=0,l=e.length;c<l;c+=2)o[c]=t+e[c+1]*a,o[c+1]=n+e[c]*r;return o}static _translate(e,t,n,a){a||=new Float32Array(e.length);for(let r=0,o=e.length;r<o;r+=2)a[r]=t+e[r],a[r+1]=n+e[r+1];return a}static svgRound(e){return Math.round(1e4*e)}static _normalizePoint(e,t,n,a,r){switch(r){case 90:return[1-t/n,e/a];case 180:return[1-e/n,1-t/a];case 270:return[t/n,1-e/a];default:return[e/n,t/a]}}static _normalizePagePoint(e,t,n){switch(n){case 90:return[1-t,e];case 180:return[1-e,1-t];case 270:return[t,1-e];default:return[e,t]}}static createBezierPoints(e,t,n,a,r,o){return[(e+5*n)/6,(t+5*a)/6,(5*n+r)/6,(5*a+o)/6,(n+r)/2,(a+o)/2]}}class Cle{#Wr;#$r=[];#qr;#Gr;#Yr=[];#Kr=new Float32Array(18);#Xr;#Qr;#Jr;#Zr;#eo;#to;#no=[];static#ao=8;static#ro=2;static#oo=Cle.#ao+Cle.#ro;constructor({x:e,y:t},n,a,r,o,c=0){this.#Wr=n,this.#to=r*a,this.#Gr=o,this.#Kr.set([NaN,NaN,NaN,NaN,e,t],6),this.#qr=c,this.#Zr=Cle.#ao*a,this.#Jr=Cle.#oo*a,this.#eo=a,this.#no.push(e,t)}isEmpty(){return isNaN(this.#Kr[8])}#co(){const e=this.#Kr.subarray(4,6),t=this.#Kr.subarray(16,18),[n,a,r,o]=this.#Wr;return[(this.#Xr+(e[0]-t[0])/2-n)/r,(this.#Qr+(e[1]-t[1])/2-a)/o,(this.#Xr+(t[0]-e[0])/2-n)/r,(this.#Qr+(t[1]-e[1])/2-a)/o]}add({x:e,y:t}){this.#Xr=e,this.#Qr=t;const[n,a,r,o]=this.#Wr;let[c,l,i,s]=this.#Kr.subarray(8,12);const h=e-i,d=t-s,u=Math.hypot(h,d);if(u<this.#Jr)return!1;const m=u-this.#Zr,p=m/u,v=p*h,f=p*d;let z=c,g=l;c=i,l=s,i+=v,s+=f,this.#no?.push(e,t);const y=v/m,M=-f/m*this.#to,E=y*this.#to;return this.#Kr.set(this.#Kr.subarray(2,8),0),this.#Kr.set([i+M,s+E],4),this.#Kr.set(this.#Kr.subarray(14,18),12),this.#Kr.set([i-M,s-E],16),isNaN(this.#Kr[6])?(0===this.#Yr.length&&(this.#Kr.set([c+M,l+E],2),this.#Yr.push(NaN,NaN,NaN,NaN,(c+M-n)/r,(l+E-a)/o),this.#Kr.set([c-M,l-E],14),this.#$r.push(NaN,NaN,NaN,NaN,(c-M-n)/r,(l-E-a)/o)),this.#Kr.set([z,g,c,l,i,s],6),!this.isEmpty()):(this.#Kr.set([z,g,c,l,i,s],6),Math.abs(Math.atan2(g-l,z-c)-Math.atan2(f,v))<Math.PI/2?([c,l,i,s]=this.#Kr.subarray(2,6),this.#Yr.push(NaN,NaN,NaN,NaN,((c+i)/2-n)/r,((l+s)/2-a)/o),[c,l,z,g]=this.#Kr.subarray(14,18),this.#$r.push(NaN,NaN,NaN,NaN,((z+c)/2-n)/r,((g+l)/2-a)/o),!0):([z,g,c,l,i,s]=this.#Kr.subarray(0,6),this.#Yr.push(((z+5*c)/6-n)/r,((g+5*l)/6-a)/o,((5*c+i)/6-n)/r,((5*l+s)/6-a)/o,((c+i)/2-n)/r,((l+s)/2-a)/o),[i,s,c,l,z,g]=this.#Kr.subarray(12,18),this.#$r.push(((z+5*c)/6-n)/r,((g+5*l)/6-a)/o,((5*c+i)/6-n)/r,((5*l+s)/6-a)/o,((c+i)/2-n)/r,((l+s)/2-a)/o),!0))}toSVGPath(){if(this.isEmpty())return"";const e=this.#Yr,t=this.#$r;if(isNaN(this.#Kr[6])&&!this.isEmpty())return this.#lo();const n=[];n.push(`M${e[4]} ${e[5]}`);for(let t=6;t<e.length;t+=6)isNaN(e[t])?n.push(`L${e[t+4]} ${e[t+5]}`):n.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);this.#io(n);for(let e=t.length-6;e>=6;e-=6)isNaN(t[e])?n.push(`L${t[e+4]} ${t[e+5]}`):n.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);return this.#so(n),n.join(" ")}#lo(){const[e,t,n,a]=this.#Wr,[r,o,c,l]=this.#co();return`M${(this.#Kr[2]-e)/n} ${(this.#Kr[3]-t)/a} L${(this.#Kr[4]-e)/n} ${(this.#Kr[5]-t)/a} L${r} ${o} L${c} ${l} L${(this.#Kr[16]-e)/n} ${(this.#Kr[17]-t)/a} L${(this.#Kr[14]-e)/n} ${(this.#Kr[15]-t)/a} Z`}#so(e){const t=this.#$r;e.push(`L${t[4]} ${t[5]} Z`)}#io(e){const[t,n,a,r]=this.#Wr,o=this.#Kr.subarray(4,6),c=this.#Kr.subarray(16,18),[l,i,s,h]=this.#co();e.push(`L${(o[0]-t)/a} ${(o[1]-n)/r} L${l} ${i} L${s} ${h} L${(c[0]-t)/a} ${(c[1]-n)/r}`)}newFreeDrawOutline(e,t,n,a,r,o){return new Lle(e,t,n,a,r,o)}getOutlines(){const e=this.#Yr,t=this.#$r,n=this.#Kr,[a,r,o,c]=this.#Wr,l=new Float32Array((this.#no?.length??0)+2);for(let e=0,t=l.length-2;e<t;e+=2)l[e]=(this.#no[e]-a)/o,l[e+1]=(this.#no[e+1]-r)/c;if(l[l.length-2]=(this.#Xr-a)/o,l[l.length-1]=(this.#Qr-r)/c,isNaN(n[6])&&!this.isEmpty())return this.#ho(l);const i=new Float32Array(this.#Yr.length+24+this.#$r.length);let s=e.length;for(let t=0;t<s;t+=2)isNaN(e[t])?i[t]=i[t+1]=NaN:(i[t]=e[t],i[t+1]=e[t+1]);s=this.#do(i,s);for(let e=t.length-6;e>=6;e-=6)for(let n=0;n<6;n+=2)isNaN(t[e+n])?(i[s]=i[s+1]=NaN,s+=2):(i[s]=t[e+n],i[s+1]=t[e+n+1],s+=2);return this.#uo(i,s),this.newFreeDrawOutline(i,l,this.#Wr,this.#eo,this.#qr,this.#Gr)}#ho(e){const t=this.#Kr,[n,a,r,o]=this.#Wr,[c,l,i,s]=this.#co(),h=new Float32Array(36);return h.set([NaN,NaN,NaN,NaN,(t[2]-n)/r,(t[3]-a)/o,NaN,NaN,NaN,NaN,(t[4]-n)/r,(t[5]-a)/o,NaN,NaN,NaN,NaN,c,l,NaN,NaN,NaN,NaN,i,s,NaN,NaN,NaN,NaN,(t[16]-n)/r,(t[17]-a)/o,NaN,NaN,NaN,NaN,(t[14]-n)/r,(t[15]-a)/o],0),this.newFreeDrawOutline(h,e,this.#Wr,this.#eo,this.#qr,this.#Gr)}#uo(e,t){const n=this.#$r;return e.set([NaN,NaN,NaN,NaN,n[4],n[5]],t),t+6}#do(e,t){const n=this.#Kr.subarray(4,6),a=this.#Kr.subarray(16,18),[r,o,c,l]=this.#Wr,[i,s,h,d]=this.#co();return e.set([NaN,NaN,NaN,NaN,(n[0]-r)/c,(n[1]-o)/l,NaN,NaN,NaN,NaN,i,s,NaN,NaN,NaN,NaN,h,d,NaN,NaN,NaN,NaN,(a[0]-r)/c,(a[1]-o)/l],t),t+24}}class Lle extends Vle{#Wr;#mo=new Float32Array(4);#qr;#Gr;#no;#eo;#po;constructor(e,t,n,a,r,o){super(),this.#po=e,this.#no=t,this.#Wr=n,this.#eo=a,this.#qr=r,this.#Gr=o,this.lastPoint=[NaN,NaN],this.#vo(o);const[c,l,i,s]=this.#mo;for(let t=0,n=e.length;t<n;t+=2)e[t]=(e[t]-c)/i,e[t+1]=(e[t+1]-l)/s;for(let e=0,n=t.length;e<n;e+=2)t[e]=(t[e]-c)/i,t[e+1]=(t[e+1]-l)/s}toSVGPath(){const e=[`M${this.#po[4]} ${this.#po[5]}`];for(let t=6,n=this.#po.length;t<n;t+=6)isNaN(this.#po[t])?e.push(`L${this.#po[t+4]} ${this.#po[t+5]}`):e.push(`C${this.#po[t]} ${this.#po[t+1]} ${this.#po[t+2]} ${this.#po[t+3]} ${this.#po[t+4]} ${this.#po[t+5]}`);return e.push("Z"),e.join(" ")}serialize([e,t,n,a],r){const o=n-e,c=a-t;let l,i;switch(r){case 0:l=Vle._rescale(this.#po,e,a,o,-c),i=Vle._rescale(this.#no,e,a,o,-c);break;case 90:l=Vle._rescaleAndSwap(this.#po,e,t,o,c),i=Vle._rescaleAndSwap(this.#no,e,t,o,c);break;case 180:l=Vle._rescale(this.#po,n,t,-o,c),i=Vle._rescale(this.#no,n,t,-o,c);break;case 270:l=Vle._rescaleAndSwap(this.#po,n,a,-o,-c),i=Vle._rescaleAndSwap(this.#no,n,a,-o,-c)}return{outline:Array.from(l),points:[Array.from(i)]}}#vo(e){const t=this.#po;let n=t[4],a=t[5],r=n,o=a,c=n,l=a,i=n,s=a;const h=e?Math.max:Math.min;for(let e=6,d=t.length;e<d;e+=6){if(isNaN(t[e]))r=Math.min(r,t[e+4]),o=Math.min(o,t[e+5]),c=Math.max(c,t[e+4]),l=Math.max(l,t[e+5]),s<t[e+5]?(i=t[e+4],s=t[e+5]):s===t[e+5]&&(i=h(i,t[e+4]));else{const d=pre.bezierBoundingBox(n,a,...t.slice(e,e+6));r=Math.min(r,d[0]),o=Math.min(o,d[1]),c=Math.max(c,d[2]),l=Math.max(l,d[3]),s<d[3]?(i=d[2],s=d[3]):s===d[3]&&(i=h(i,d[2]))}n=t[e+4],a=t[e+5]}const d=this.#mo;d[0]=r-this.#qr,d[1]=o-this.#qr,d[2]=c-r+2*this.#qr,d[3]=l-o+2*this.#qr,this.lastPoint=[i,s]}get box(){return this.#mo}newOutliner(e,t,n,a,r,o=0){return new Cle(e,t,n,a,r,o)}getNewOutline(e,t){const[n,a,r,o]=this.#mo,[c,l,i,s]=this.#Wr,h=r*i,d=o*s,u=n*i+c,m=a*s+l,p=this.newOutliner({x:this.#no[0]*h+u,y:this.#no[1]*d+m},this.#Wr,this.#eo,e,this.#Gr,t??this.#qr);for(let e=2;e<this.#no.length;e+=2)p.add({x:this.#no[e]*h+u,y:this.#no[e+1]*d+m});return p.getOutlines()}}class xle{#Wr;#fo;#zo=[];#go=[];constructor(e,t=0,n=0,a=!0){let r=1/0,o=-1/0,c=1/0,l=-1/0;const i=10**-4;for(const{x:n,y:a,width:s,height:h}of e){const e=Math.floor((n-t)/i)*i,d=Math.ceil((n+s+t)/i)*i,u=Math.floor((a-t)/i)*i,m=Math.ceil((a+h+t)/i)*i,p=[e,u,m,!0],v=[d,u,m,!1];this.#zo.push(p,v),r=Math.min(r,e),o=Math.max(o,d),c=Math.min(c,u),l=Math.max(l,m)}const s=o-r+2*n,h=l-c+2*n,d=r-n,u=c-n,m=this.#zo.at(a?-1:-2),p=[m[0],m[2]];for(const e of this.#zo){const[t,n,a]=e;e[0]=(t-d)/s,e[1]=(n-u)/h,e[2]=(a-u)/h}this.#Wr=new Float32Array([d,u,s,h]),this.#fo=p}getOutlines(){this.#zo.sort(((e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2]));const e=[];for(const t of this.#zo)t[3]?(e.push(...this.#yo(t)),this.#Mo(t)):(this.#Eo(t),e.push(...this.#yo(t)));return this.#bo(e)}#bo(e){const t=[],n=new Set;for(const n of e){const[e,a,r]=n;t.push([e,a,n],[e,r,n])}t.sort(((e,t)=>e[1]-t[1]||e[0]-t[0]));for(let e=0,a=t.length;e<a;e+=2){const a=t[e][2],r=t[e+1][2];a.push(r),r.push(a),n.add(a),n.add(r)}const a=[];let r;for(;n.size>0;){const e=n.values().next().value;let[t,o,c,l,i]=e;n.delete(e);let s=t,h=o;for(r=[t,c],a.push(r);;){let e;if(n.has(l))e=l;else{if(!n.has(i))break;e=i}n.delete(e),[t,o,c,l,i]=e,s!==t&&(r.push(s,h,t,h===o?o:c),s=t),h=h===o?c:o}r.push(s,h)}return new Sle(a,this.#Wr,this.#fo)}#Ho(e){const t=this.#go;let n=0,a=t.length-1;for(;n<=a;){const r=n+a>>1,o=t[r][0];if(o===e)return r;o<e?n=r+1:a=r-1}return a+1}#Mo([,e,t]){const n=this.#Ho(e);this.#go.splice(n,0,[e,t])}#Eo([,e,t]){const n=this.#Ho(e);for(let a=n;a<this.#go.length;a++){const[n,r]=this.#go[a];if(n!==e)break;if(n===e&&r===t)return void this.#go.splice(a,1)}for(let a=n-1;a>=0;a--){const[n,r]=this.#go[a];if(n!==e)break;if(n===e&&r===t)return void this.#go.splice(a,1)}}#yo(e){const[t,n,a]=e,r=[[t,n,a]],o=this.#Ho(a);for(let e=0;e<o;e++){const[n,a]=this.#go[e];for(let e=0,o=r.length;e<o;e++){const[,c,l]=r[e];if(!(a<=c||l<=n))if(c>=n)if(l>a)r[e][1]=a;else{if(1===o)return[];r.splice(e,1),e--,o--}else r[e][2]=n,l>a&&r.push([t,a,l])}}return r}}class Sle extends Vle{#Wr;#Vo;constructor(e,t,n){super(),this.#Vo=e,this.#Wr=t,this.lastPoint=n}toSVGPath(){const e=[];for(const t of this.#Vo){let[n,a]=t;e.push(`M${n} ${a}`);for(let r=2;r<t.length;r+=2){const o=t[r],c=t[r+1];o===n?(e.push(`V${c}`),a=c):c===a&&(e.push(`H${o}`),n=o)}e.push("Z")}return e.join(" ")}serialize([e,t,n,a],r){const o=[],c=n-e,l=a-t;for(const t of this.#Vo){const n=new Array(t.length);for(let r=0;r<t.length;r+=2)n[r]=e+t[r]*c,n[r+1]=a-t[r+1]*l;o.push(n)}return o}get box(){return this.#Wr}get classNamesForOutlining(){return["highlightOutline"]}}class kle extends Cle{newFreeDrawOutline(e,t,n,a,r,o){return new wle(e,t,n,a,r,o)}}class wle extends Lle{newOutliner(e,t,n,a,r,o=0){return new kle(e,t,n,a,r,o)}}class Tle{#Co=null;#Lo=null;#xo;#So=null;#ko=!1;#wo=!1;#o=null;#To;#Oo=null;#v=null;#Ao;static#Ro=null;static get _keyboardManager(){return ere(this,"_keyboardManager",new $re([[["Escape","mac+Escape"],Tle.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Tle.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Tle.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Tle.prototype._moveToPrevious],[["Home","mac+Home"],Tle.prototype._moveToBeginning],[["End","mac+End"],Tle.prototype._moveToEnd]]))}constructor({editor:e=null,uiManager:t=null}){e?(this.#wo=!1,this.#Ao=jae.HIGHLIGHT_COLOR,this.#o=e):(this.#wo=!0,this.#Ao=jae.HIGHLIGHT_DEFAULT_COLOR),this.#v=e?._uiManager||t,this.#To=this.#v._eventBus,this.#xo=e?.color||this.#v?.highlightColors.values().next().value||"#FFFF98",Tle.#Ro||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){const e=this.#Co=document.createElement("button");e.className="colorPicker",e.tabIndex="0",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),e.setAttribute("aria-haspopup",!0);const t=this.#v._signal;e.addEventListener("click",this.#No.bind(this),{signal:t}),e.addEventListener("keydown",this.#Ga.bind(this),{signal:t});const n=this.#Lo=document.createElement("span");return n.className="swatch",n.setAttribute("aria-hidden",!0),n.style.backgroundColor=this.#xo,e.append(n),e}renderMainDropdown(){const e=this.#So=this.#_o();return e.setAttribute("aria-orientation","horizontal"),e.setAttribute("aria-labelledby","highlightColorPickerLabel"),e}#_o(){const e=document.createElement("div"),t=this.#v._signal;e.addEventListener("contextmenu",wre,{signal:t}),e.className="dropdown",e.role="listbox",e.setAttribute("aria-multiselectable",!1),e.setAttribute("aria-orientation","vertical"),e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[n,a]of this.#v.highlightColors){const r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",a),r.title=n,r.setAttribute("data-l10n-id",Tle.#Ro[n]);const o=document.createElement("span");r.append(o),o.className="swatch",o.style.backgroundColor=a,r.setAttribute("aria-selected",a===this.#xo),r.addEventListener("click",this.#Do.bind(this,a),{signal:t}),e.append(r)}return e.addEventListener("keydown",this.#Ga.bind(this),{signal:t}),e}#Do(e,t){t.stopPropagation(),this.#To.dispatch("switchannotationeditorparams",{source:this,type:this.#Ao,value:e})}_colorSelectFromKeyboard(e){if(e.target===this.#Co)return void this.#No(e);const t=e.target.getAttribute("data-color");t&&this.#Do(t,e)}_moveToNext(e){this.#Po?e.target!==this.#Co?e.target.nextSibling?.focus():this.#So.firstChild?.focus():this.#No(e)}_moveToPrevious(e){e.target!==this.#So?.firstChild&&e.target!==this.#Co?(this.#Po||this.#No(e),e.target.previousSibling?.focus()):this.#Po&&this._hideDropdownFromKeyboard()}_moveToBeginning(e){this.#Po?this.#So.firstChild?.focus():this.#No(e)}_moveToEnd(e){this.#Po?this.#So.lastChild?.focus():this.#No(e)}#Ga(e){Tle._keyboardManager.exec(this,e)}#No(e){if(this.#Po)return void this.hideDropdown();if(this.#ko=0===e.detail,this.#Oo||(this.#Oo=new AbortController,window.addEventListener("pointerdown",this.#s.bind(this),{signal:this.#v.combinedSignal(this.#Oo)})),this.#So)return void this.#So.classList.remove("hidden");const t=this.#So=this.#_o();this.#Co.append(t)}#s(e){this.#So?.contains(e.target)||this.hideDropdown()}hideDropdown(){this.#So?.classList.add("hidden"),this.#Oo?.abort(),this.#Oo=null}get#Po(){return this.#So&&!this.#So.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#wo||(this.#Po?(this.hideDropdown(),this.#Co.focus({preventScroll:!0,focusVisible:this.#ko})):this.#o?.unselect())}updateColor(e){if(this.#Lo&&(this.#Lo.style.backgroundColor=e),!this.#So)return;const t=this.#v.highlightColors.values();for(const n of this.#So.children)n.setAttribute("aria-selected",t.next().value===e)}destroy(){this.#Co?.remove(),this.#Co=null,this.#Lo=null,this.#So?.remove(),this.#So=null}}class Ole extends Xre{#Fo=null;#Io=0;#jo;#Bo=null;#r=null;#Uo=null;#Wo=null;#$o=0;#qo=null;#Go=null;#y=null;#Yo=!1;#fo=null;#Ko;#Xo=null;#Qo="";#to;#Jo="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=Iae.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const e=Ole.prototype;return ere(this,"_keyboardManager",new $re([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}constructor(e){super({...e,name:"highlightEditor"}),this.color=e.color||Ole._defaultColor,this.#to=e.thickness||Ole._defaultThickness,this.#Ko=e.opacity||Ole._defaultOpacity,this.#jo=e.boxes||null,this.#Jo=e.methodOfCreation||"",this.#Qo=e.text||"",this._isDraggable=!1,e.highlightId>-1?(this.#Yo=!0,this.#Zo(e),this.#ec()):this.#jo&&(this.#Fo=e.anchorNode,this.#Io=e.anchorOffset,this.#Wo=e.focusNode,this.#$o=e.focusOffset,this.#tc(),this.#ec(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#Yo?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#to,methodOfCreation:this.#Jo}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}#tc(){const e=new xle(this.#jo,.001);this.#Go=e.getOutlines(),[this.x,this.y,this.width,this.height]=this.#Go.box;const t=new xle(this.#jo,.0025,.001,"ltr"===this._uiManager.direction);this.#Uo=t.getOutlines();const{lastPoint:n}=this.#Uo;this.#fo=[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]}#Zo({highlightOutlines:e,highlightId:t,clipPathId:n}){if(this.#Go=e,this.#Uo=e.getNewOutline(this.#to/2+1.5,.0025),t>=0)this.#y=t,this.#Bo=n,this.parent.drawLayer.finalizeDraw(t,{bbox:e.box,path:{d:e.toSVGPath()}}),this.#Xo=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#Uo.box,path:{d:this.#Uo.toSVGPath()}},!0);else if(this.parent){const t=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#y,{bbox:Ole.#nc(this.#Go.box,(t-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#Xo,{bbox:Ole.#nc(this.#Uo.box,t),path:{d:this.#Uo.toSVGPath()}})}const[a,r,o,c]=e.box;switch(this.rotation){case 0:this.x=a,this.y=r,this.width=o,this.height=c;break;case 90:{const[e,t]=this.parentDimensions;this.x=r,this.y=1-a,this.width=o*t/e,this.height=c*e/t;break}case 180:this.x=1-a,this.y=1-r,this.width=o,this.height=c;break;case 270:{const[e,t]=this.parentDimensions;this.x=1-r,this.y=a,this.width=o*t/e,this.height=c*e/t;break}}const{lastPoint:l}=this.#Uo;this.#fo=[(l[0]-a)/o,(l[1]-r)/c]}static initialize(e,t){Xre.initialize(e,t),Ole._defaultColor||=t.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(e,t){switch(e){case jae.HIGHLIGHT_DEFAULT_COLOR:Ole._defaultColor=t;break;case jae.HIGHLIGHT_THICKNESS:Ole._defaultThickness=t}}translateInPage(e,t){}get toolbarPosition(){return this.#fo}updateParams(e,t){switch(e){case jae.HIGHLIGHT_COLOR:this.#_r(t);break;case jae.HIGHLIGHT_THICKNESS:this.#ac(t)}}static get defaultPropertiesToUpdate(){return[[jae.HIGHLIGHT_DEFAULT_COLOR,Ole._defaultColor],[jae.HIGHLIGHT_THICKNESS,Ole._defaultThickness]]}get propertiesToUpdate(){return[[jae.HIGHLIGHT_COLOR,this.color||Ole._defaultColor],[jae.HIGHLIGHT_THICKNESS,this.#to||Ole._defaultThickness],[jae.HIGHLIGHT_FREE,this.#Yo]]}#_r(e){const t=(e,t)=>{this.color=e,this.#Ko=t,this.parent?.drawLayer.updateProperties(this.#y,{root:{fill:e,"fill-opacity":t}}),this.#r?.updateColor(e)},n=this.color,a=this.#Ko;this.addCommands({cmd:t.bind(this,e,Ole._defaultOpacity),undo:t.bind(this,n,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:jae.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(e)},!0)}#ac(e){const t=this.#to,n=e=>{this.#to=e,this.#rc(e)};this.addCommands({cmd:n.bind(this,e),undo:n.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:jae.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)}async addEditToolbar(){const e=await super.addEditToolbar();return e?(this._uiManager.highlightColors&&(this.#r=new Tle({editor:this}),e.addColorPicker(this.#r)),e):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#oc())}getBaseTranslation(){return[0,0]}getRect(e,t){return super.getRect(e,t,this.#oc())}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){this.#cc(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#ec(),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let t=!1;this.parent&&!e?this.#cc():e&&(this.#ec(e),t=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(e),this.show(this._isVisible),t&&this.select()}#rc(e){if(!this.#Yo)return;this.#Zo({highlightOutlines:this.#Go.getNewOutline(e/2)}),this.fixAndSetPosition();const[t,n]=this.parentDimensions;this.setDims(this.width*t,this.height*n)}#cc(){null!==this.#y&&this.parent&&(this.parent.drawLayer.remove(this.#y),this.#y=null,this.parent.drawLayer.remove(this.#Xo),this.#Xo=null)}#ec(e=this.parent){null===this.#y&&(({id:this.#y,clipPathId:this.#Bo}=e.drawLayer.draw({bbox:this.#Go.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#Ko},rootClass:{highlight:!0,free:this.#Yo},path:{d:this.#Go.toSVGPath()}},!1,!0)),this.#Xo=e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#Yo},bbox:this.#Uo.box,path:{d:this.#Uo.toSVGPath()}},this.#Yo),this.#qo&&(this.#qo.style.clipPath=this.#Bo))}static#nc([e,t,n,a],r){switch(r){case 90:return[1-t-a,e,a,n];case 180:return[1-e-n,1-t-a,n,a];case 270:return[t,1-e-n,a,n]}return[e,t,n,a]}rotate(e){const{drawLayer:t}=this.parent;let n;this.#Yo?(e=(e-this.rotation+360)%360,n=Ole.#nc(this.#Go.box,e)):n=Ole.#nc([this.x,this.y,this.width,this.height],e),t.updateProperties(this.#y,{bbox:n,root:{"data-main-rotation":e}}),t.updateProperties(this.#Xo,{bbox:Ole.#nc(this.#Uo.box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();this.#Qo&&(e.setAttribute("aria-label",this.#Qo),e.setAttribute("role","mark")),this.#Yo?e.classList.add("free"):this.div.addEventListener("keydown",this.#lc.bind(this),{signal:this._uiManager._signal});const t=this.#qo=document.createElement("div");e.append(t),t.setAttribute("aria-hidden","true"),t.className="internal",t.style.clipPath=this.#Bo;const[n,a]=this.parentDimensions;return this.setDims(this.width*n,this.height*a),jre(this,this.#qo,["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Xo,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Xo,{rootClass:{hovered:!1}})}#lc(e){Ole._keyboardManager.exec(this,e)}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:this.#ic(!0);break;case 1:case 3:this.#ic(!1)}}#ic(e){if(!this.#Fo)return;const t=window.getSelection();e?t.setPosition(this.#Fo,this.#Io):t.setPosition(this.#Wo,this.#$o)}select(){super.select(),this.#Xo&&this.parent?.drawLayer.updateProperties(this.#Xo,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#Xo&&(this.parent?.drawLayer.updateProperties(this.#Xo,{rootClass:{selected:!1}}),this.#Yo||this.#ic(!1))}get _mustFixPosition(){return!this.#Yo}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(this.#y,{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(this.#Xo,{rootClass:{hidden:!e}}))}#oc(){return this.#Yo?this.rotation:0}#sc(){if(this.#Yo)return null;const[e,t]=this.pageDimensions,[n,a]=this.pageTranslation,r=this.#jo,o=new Float32Array(8*r.length);let c=0;for(const{x:l,y:i,width:s,height:h}of r){const r=l*e+n,d=(1-i)*t+a;o[c]=o[c+4]=r,o[c+1]=o[c+3]=d,o[c+2]=o[c+6]=r+s*e,o[c+5]=o[c+7]=d-h*t,c+=8}return o}#hc(e){return this.#Go.serialize(e,this.#oc())}static startHighlighting(e,t,{target:n,x:a,y:r}){const{x:o,y:c,width:l,height:i}=n.getBoundingClientRect(),s=new AbortController,h=e.combinedSignal(s),d=t=>{s.abort(),this.#dc(e,t)};window.addEventListener("blur",d,{signal:h}),window.addEventListener("pointerup",d,{signal:h}),window.addEventListener("pointerdown",Tre,{capture:!0,passive:!1,signal:h}),window.addEventListener("contextmenu",wre,{signal:h}),n.addEventListener("pointermove",this.#uc.bind(this,e),{signal:h}),this._freeHighlight=new kle({x:a,y:r},[o,c,l,i],e.scale,this._defaultThickness/2,t,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static#uc(e,t){this._freeHighlight.add(t)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#dc(e,t){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(t,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(e,t,n){let a=null;if(e instanceof vle){const{data:{quadPoints:t,rect:n,rotation:r,id:o,color:c,opacity:l,popupRef:i},parent:{page:{pageNumber:s}}}=e;a=e={annotationType:Iae.HIGHLIGHT,color:Array.from(c),opacity:l,quadPoints:t,boxes:null,pageIndex:s-1,rect:n.slice(0),rotation:r,id:o,deleted:!1,popupRef:i}}else if(e instanceof ple){const{data:{inkLists:t,rect:n,rotation:r,id:o,color:c,borderStyle:{rawWidth:l},popupRef:i},parent:{page:{pageNumber:s}}}=e;a=e={annotationType:Iae.HIGHLIGHT,color:Array.from(c),thickness:l,inkLists:t,boxes:null,pageIndex:s-1,rect:n.slice(0),rotation:r,id:o,deleted:!1,popupRef:i}}const{color:r,quadPoints:o,inkLists:c,opacity:l}=e,i=await super.deserialize(e,t,n);i.color=pre.makeHexColor(...r),i.#Ko=l||1,c&&(i.#to=e.thickness),i.annotationElementId=e.id||null,i._initialData=a;const[s,h]=i.pageDimensions,[d,u]=i.pageTranslation;if(o){const e=i.#jo=[];for(let t=0;t<o.length;t+=8)e.push({x:(o[t]-d)/s,y:1-(o[t+1]-u)/h,width:(o[t+2]-o[t])/s,height:(o[t+1]-o[t+5])/h});i.#tc(),i.#ec(),i.rotate(i.rotation)}else if(c){i.#Yo=!0;const e=c[0],n={x:e[0]-d,y:h-(e[1]-u)},a=new kle(n,[0,0,s,h],1,i.#to/2,!0,.001);for(let t=0,r=e.length;t<r;t+=2)n.x=e[t]-d,n.y=h-(e[t+1]-u),a.add(n);const{id:r,clipPathId:o}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:i.color,"fill-opacity":i._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:a.toSVGPath()}},!0,!0);i.#Zo({highlightOutlines:a.getOutlines(),highlightId:r,clipPathId:o}),i.#ec()}return i}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const t=this.getRect(0,0),n=Xre._colorManager.convert(this.color),a={annotationType:Iae.HIGHLIGHT,color:n,opacity:this.#Ko,thickness:this.#to,quadPoints:this.#sc(),outlines:this.#hc(t),pageIndex:this.pageIndex,rect:t,rotation:this.#oc(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#Ur(a)?null:(a.id=this.annotationElementId,a)}#Ur(e){const{color:t}=this._initialData;return e.color.some(((e,n)=>e!==t[n]))}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class Ale{#mc=Object.create(null);updateProperty(e,t){this[e]=t,this.updateSVGProperty(e,t)}updateProperties(e){if(e)for(const[t,n]of Object.entries(e))this.updateProperty(t,n)}updateSVGProperty(e,t){this.#mc[e]=t}toSVGProperties(){const e=this.#mc;return this.#mc=Object.create(null),{root:e}}reset(){this.#mc=Object.create(null)}updateAll(e=this){this.updateProperties(e)}clone(){Qae("Not implemented")}}class Rle extends Xre{#pc=null;#vc;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#fc=null;static#zc=null;static#gc=null;static#yc=NaN;static#Mc=null;static#Ec=null;static#bc=NaN;static _INNER_MARGIN=3;constructor(e){super(e),this.#vc=e.mustBeCommitted||!1,e.drawOutlines&&(this.#Hc(e),this.#ec())}#Hc({drawOutlines:e,drawId:t,drawingOptions:n}){this.#pc=e,this._drawingOptions||=n,t>=0?(this._drawId=t,this.parent.drawLayer.finalizeDraw(t,e.defaultProperties)):this._drawId=this.#Vc(e,this.parent),this.#Cc(e.box)}#Vc(e,t){const{id:n}=t.drawLayer.draw(Rle._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return n}static _mergeSVGProperties(e,t){const n=new Set(Object.keys(e));for(const[a,r]of Object.entries(t))n.has(a)?Object.assign(e[a],r):e[a]=r;return e}static getDefaultDrawingOptions(e){Qae("Not implemented")}static get typesMap(){Qae("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,t){const n=this.typesMap.get(e);n&&this._defaultDrawingOptions.updateProperty(n,t),this._currentParent&&(Rle.#fc.updateProperty(n,t),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,t){const n=this.constructor.typesMap.get(e);n&&this._updateProperty(e,n,t)}static get defaultPropertiesToUpdate(){const e=[],t=this._defaultDrawingOptions;for(const[n,a]of this.typesMap)e.push([n,t[a]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:t}=this;for(const[n,a]of this.constructor.typesMap)e.push([n,t[a]]);return e}_updateProperty(e,t,n){const a=this._drawingOptions,r=a[t],o=e=>{a.updateProperty(t,e);const n=this.#pc.updateProperty(t,e);n&&this.#Cc(n),this.parent?.drawLayer.updateProperties(this._drawId,a.toSVGProperties())};this.addCommands({cmd:o.bind(this,n),undo:o.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,Rle._mergeSVGProperties(this.#pc.getPathResizingSVGProperties(this.#Lc()),{bbox:this.#xc()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,Rle._mergeSVGProperties(this.#pc.getPathResizedSVGProperties(this.#Lc()),{bbox:this.#xc()}))}_onTranslating(e,t){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#xc(e,t)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,Rle._mergeSVGProperties(this.#pc.getPathTranslatedSVGProperties(this.#Lc(),this.parentDimensions),{bbox:this.#xc()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#vc&&(this.#vc=!1,this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){this.#cc(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#ec(),this.#Cc(this.#pc.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let t=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),this.#cc()):e&&(this._uiManager.addShouldRescale(this),this.#ec(e),t=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(e),t&&this.select()}#cc(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#ec(e=this.parent){null!==this._drawId&&this.parent===e||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#Vc(this.#pc,e)):this.parent.drawLayer.updateParent(this._drawId,e.drawLayer))}#Sc([e,t,n,a]){const{parentDimensions:[r,o],rotation:c}=this;switch(c){case 90:return[t,1-e,n*(o/r),a*(r/o)];case 180:return[1-e,1-t,n,a];case 270:return[1-t,e,n*(o/r),a*(r/o)];default:return[e,t,n,a]}}#Lc(){const{x:e,y:t,width:n,height:a,parentDimensions:[r,o],rotation:c}=this;switch(c){case 90:return[1-t,e,n*(r/o),a*(o/r)];case 180:return[1-e,1-t,n,a];case 270:return[t,1-e,n*(r/o),a*(o/r)];default:return[e,t,n,a]}}#Cc(e){if([this.x,this.y,this.width,this.height]=this.#Sc(e),this.div){this.fixAndSetPosition();const[e,t]=this.parentDimensions;this.setDims(this.width*e,this.height*t)}this._onResized()}#xc(){const{x:e,y:t,width:n,height:a,rotation:r,parentRotation:o,parentDimensions:[c,l]}=this;switch((4*r+o)/90){case 1:return[1-t-a,e,a,n];case 2:return[1-e-n,1-t-a,n,a];case 3:return[t,1-e-n,a,n];case 4:return[e,t-n*(c/l),a*(l/c),n*(c/l)];case 5:return[1-t,e,n*(c/l),a*(l/c)];case 6:return[1-e-a*(l/c),1-t,a*(l/c),n*(c/l)];case 7:return[t-n*(c/l),1-e-a*(l/c),n*(c/l),a*(l/c)];case 8:return[e-n,t-a,n,a];case 9:return[1-t,e-n,a,n];case 10:return[1-e,1-t,n,a];case 11:return[t-a,1-e,a,n];case 12:return[e-a*(l/c),t,a*(l/c),n*(c/l)];case 13:return[1-t-n*(c/l),e-a*(l/c),n*(c/l),a*(l/c)];case 14:return[1-e,1-t-n*(c/l),a*(l/c),n*(c/l)];case 15:return[t,1-e,n*(c/l),a*(l/c)];default:return[e,t,n,a]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,Rle._mergeSVGProperties({bbox:this.#xc()},this.#pc.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#Cc(this.#pc.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;const e=super.render();e.classList.add("draw");const t=document.createElement("div");e.append(t),t.setAttribute("aria-hidden","true"),t.className="internal";const[n,a]=this.parentDimensions;return this.setDims(this.width*n,this.height*a),this._uiManager.addShouldRescale(this),this.disableEditing(),e}static createDrawerInstance(e,t,n,a,r){Qae("Not implemented")}static startDrawing(e,t,n,a){const{target:r,offsetX:o,offsetY:c,pointerId:l,pointerType:i}=a;if(Rle.#Mc&&Rle.#Mc!==i)return;const{viewport:{rotation:s}}=e,{width:h,height:d}=r.getBoundingClientRect(),u=Rle.#zc=new AbortController,m=e.combinedSignal(u);Rle.#yc||=l,Rle.#Mc??=i,window.addEventListener("pointerup",(e=>{Rle.#yc===e.pointerId?this._endDraw(e):Rle.#Ec?.delete(e.pointerId)}),{signal:m}),window.addEventListener("pointercancel",(e=>{Rle.#yc===e.pointerId?this._currentParent.endDrawingSession():Rle.#Ec?.delete(e.pointerId)}),{signal:m}),window.addEventListener("pointerdown",(e=>{Rle.#Mc===e.pointerType&&((Rle.#Ec||=new Set).add(e.pointerId),Rle.#fc.isCancellable()&&(Rle.#fc.removeLastElement(),Rle.#fc.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:m}),window.addEventListener("contextmenu",wre,{signal:m}),r.addEventListener("pointermove",this._drawMove.bind(this),{signal:m}),r.addEventListener("touchmove",(e=>{e.timeStamp===Rle.#bc&&Tre(e)}),{signal:m}),e.toggleDrawing(),t._editorUndoBar?.hide(),Rle.#fc?e.drawLayer.updateProperties(this._currentDrawId,Rle.#fc.startNew(o,c,h,d,s)):(t.updateUIForDefaultProperties(this),Rle.#fc=this.createDrawerInstance(o,c,h,d,s),Rle.#gc=this.getDefaultDrawingOptions(),this._currentParent=e,({id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(Rle.#gc.toSVGProperties(),Rle.#fc.defaultSVGProperties),!0,!1)))}static _drawMove(e){if(Rle.#bc=-1,!Rle.#fc)return;const{offsetX:t,offsetY:n,pointerId:a}=e;Rle.#yc===a&&(Rle.#Ec?.size>=1?this._endDraw(e):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,Rle.#fc.add(t,n)),Rle.#bc=e.timeStamp,Tre(e)))}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,Rle.#fc=null,Rle.#gc=null,Rle.#Mc=null,Rle.#bc=NaN),Rle.#zc&&(Rle.#zc.abort(),Rle.#zc=null,Rle.#yc=NaN,Rle.#Ec=null)}static _endDraw(e){const t=this._currentParent;if(t)if(t.toggleDrawing(!0),this._cleanup(!1),e&&t.drawLayer.updateProperties(this._currentDrawId,Rle.#fc.end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const e=Rle.#fc,n=this._currentDrawId,a=e.getLastElement();t.addCommands({cmd:()=>{t.drawLayer.updateProperties(n,e.setLastElement(a))},undo:()=>{t.drawLayer.updateProperties(n,e.removeLastElement())},mustExec:!1,type:jae.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(e){const t=this._currentParent;if(!t)return null;if(t.toggleDrawing(!0),t.cleanUndoStack(jae.DRAW_STEP),!Rle.#fc.isEmpty()){const{pageDimensions:[n,a],scale:r}=t,o=t.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:Rle.#fc.getOutlines(n*r,a*r,r,this._INNER_MARGIN),drawingOptions:Rle.#gc,mustBeCommitted:!e});return this._cleanup(!0),o}return t.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,t,n,a,r,o){Qae("Not implemented")}static async deserialize(e,t,n){const{rawDims:{pageWidth:a,pageHeight:r,pageX:o,pageY:c}}=t.viewport,l=this.deserializeDraw(o,c,a,r,this._INNER_MARGIN,e),i=await super.deserialize(e,t,n);return i.createDrawingOptions(e),i.#Hc({drawOutlines:l}),i.#ec(),i.onScaleChanging(),i.rotate(),i}serializeDraw(e){const[t,n]=this.pageTranslation,[a,r]=this.pageDimensions;return this.#pc.serialize([t,n,a,r],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class Nle{#Kr=new Float64Array(6);#zr;#kc;#Rn;#to;#no;#wc="";#Tc=0;#Vo=new _le;#Oc;#Ac;constructor(e,t,n,a,r,o){this.#Oc=n,this.#Ac=a,this.#Rn=r,this.#to=o,[e,t]=this.#Rc(e,t);const c=this.#zr=[NaN,NaN,NaN,NaN,e,t];this.#no=[e,t],this.#kc=[{line:c,points:this.#no}],this.#Kr.set(c,0)}updateProperty(e,t){"stroke-width"===e&&(this.#to=t)}#Rc(e,t){return Vle._normalizePoint(e,t,this.#Oc,this.#Ac,this.#Rn)}isEmpty(){return!this.#kc||0===this.#kc.length}isCancellable(){return this.#no.length<=10}add(e,t){[e,t]=this.#Rc(e,t);const[n,a,r,o]=this.#Kr.subarray(2,6),c=e-r,l=t-o;return Math.hypot(this.#Oc*c,this.#Ac*l)<=2?null:(this.#no.push(e,t),isNaN(n)?(this.#Kr.set([r,o,e,t],2),this.#zr.push(NaN,NaN,NaN,NaN,e,t),{path:{d:this.toSVGPath()}}):(isNaN(this.#Kr[0])&&this.#zr.splice(6,6),this.#Kr.set([n,a,r,o,e,t],0),this.#zr.push(...Vle.createBezierPoints(n,a,r,o,e,t)),{path:{d:this.toSVGPath()}}))}end(e,t){return this.add(e,t)||(2===this.#no.length?{path:{d:this.toSVGPath()}}:null)}startNew(e,t,n,a,r){this.#Oc=n,this.#Ac=a,this.#Rn=r,[e,t]=this.#Rc(e,t);const o=this.#zr=[NaN,NaN,NaN,NaN,e,t];this.#no=[e,t];const c=this.#kc.at(-1);return c&&(c.line=new Float32Array(c.line),c.points=new Float32Array(c.points)),this.#kc.push({line:o,points:this.#no}),this.#Kr.set(o,0),this.#Tc=0,this.toSVGPath(),null}getLastElement(){return this.#kc.at(-1)}setLastElement(e){return this.#kc?(this.#kc.push(e),this.#zr=e.line,this.#no=e.points,this.#Tc=0,{path:{d:this.toSVGPath()}}):this.#Vo.setLastElement(e)}removeLastElement(){if(!this.#kc)return this.#Vo.removeLastElement();this.#kc.pop(),this.#wc="";for(let e=0,t=this.#kc.length;e<t;e++){const{line:t,points:n}=this.#kc[e];this.#zr=t,this.#no=n,this.#Tc=0,this.toSVGPath()}return{path:{d:this.#wc}}}toSVGPath(){const e=Vle.svgRound(this.#zr[4]),t=Vle.svgRound(this.#zr[5]);if(2===this.#no.length)return this.#wc=`${this.#wc} M ${e} ${t} Z`,this.#wc;if(this.#no.length<=6){const n=this.#wc.lastIndexOf("M");this.#wc=`${this.#wc.slice(0,n)} M ${e} ${t}`,this.#Tc=6}if(4===this.#no.length){const e=Vle.svgRound(this.#zr[10]),t=Vle.svgRound(this.#zr[11]);return this.#wc=`${this.#wc} L ${e} ${t}`,this.#Tc=12,this.#wc}const n=[];0===this.#Tc&&(n.push(`M ${e} ${t}`),this.#Tc=6);for(let e=this.#Tc,t=this.#zr.length;e<t;e+=6){const[t,a,r,o,c,l]=this.#zr.slice(e,e+6).map(Vle.svgRound);n.push(`C${t} ${a} ${r} ${o} ${c} ${l}`)}return this.#wc+=n.join(" "),this.#Tc=this.#zr.length,this.#wc}getOutlines(e,t,n,a){const r=this.#kc.at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),this.#Vo.build(this.#kc,e,t,n,this.#Rn,this.#to,a),this.#Kr=null,this.#zr=null,this.#kc=null,this.#wc=null,this.#Vo}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class _le extends Vle{#mo;#Nc=0;#qr;#kc;#Oc;#Ac;#_c;#Rn;#to;build(e,t,n,a,r,o,c){this.#Oc=t,this.#Ac=n,this.#_c=a,this.#Rn=r,this.#to=o,this.#qr=c??0,this.#kc=e,this.#Dc()}setLastElement(e){return this.#kc.push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#kc.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:t}of this.#kc)if(e.push(`M${Vle.svgRound(t[4])} ${Vle.svgRound(t[5])}`),6!==t.length)if(12!==t.length)for(let n=6,a=t.length;n<a;n+=6){const[a,r,o,c,l,i]=t.subarray(n,n+6).map(Vle.svgRound);e.push(`C${a} ${r} ${o} ${c} ${l} ${i}`)}else e.push(`L${Vle.svgRound(t[10])} ${Vle.svgRound(t[11])}`);else e.push("Z");return e.join("")}serialize([e,t,n,a],r){const o=[],c=[],[l,i,s,h]=this.#Pc();let d,u,m,p,v,f,z,g,y;switch(this.#Rn){case 0:y=Vle._rescale,d=e,u=t+a,m=n,p=-a,v=e+l*n,f=t+(1-i-h)*a,z=e+(l+s)*n,g=t+(1-i)*a;break;case 90:y=Vle._rescaleAndSwap,d=e,u=t,m=n,p=a,v=e+i*n,f=t+l*a,z=e+(i+h)*n,g=t+(l+s)*a;break;case 180:y=Vle._rescale,d=e+n,u=t,m=-n,p=a,v=e+(1-l-s)*n,f=t+i*a,z=e+(1-l)*n,g=t+(i+h)*a;break;case 270:y=Vle._rescaleAndSwap,d=e+n,u=t+a,m=-n,p=-a,v=e+(1-i-h)*n,f=t+(1-l-s)*a,z=e+(1-i)*n,g=t+(1-l)*a}for(const{line:e,points:t}of this.#kc)o.push(y(e,d,u,m,p,r?new Array(e.length):null)),c.push(y(t,d,u,m,p,r?new Array(t.length):null));return{lines:o,points:c,rect:[v,f,z,g]}}static deserialize(e,t,n,a,r,{paths:{lines:o,points:c},rotation:l,thickness:i}){const s=[];let h,d,u,m,p;switch(l){case 0:p=Vle._rescale,h=-e/n,d=t/a+1,u=1/n,m=-1/a;break;case 90:p=Vle._rescaleAndSwap,h=-t/a,d=-e/n,u=1/a,m=1/n;break;case 180:p=Vle._rescale,h=e/n+1,d=-t/a,u=-1/n,m=1/a;break;case 270:p=Vle._rescaleAndSwap,h=t/a+1,d=e/n+1,u=-1/a,m=-1/n}if(!o){o=[];for(const e of c){const t=e.length;if(2===t){o.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1]]));continue}if(4===t){o.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1],NaN,NaN,NaN,NaN,e[2],e[3]]));continue}const n=new Float32Array(3*(t-2));o.push(n);let[a,r,c,l]=e.subarray(0,4);n.set([NaN,NaN,NaN,NaN,a,r],0);for(let o=4;o<t;o+=2){const t=e[o],i=e[o+1];n.set(Vle.createBezierPoints(a,r,c,l,t,i),3*(o-2)),[a,r,c,l]=[c,l,t,i]}}}for(let e=0,t=o.length;e<t;e++)s.push({line:p(o[e].map((e=>e??NaN)),h,d,u,m),points:p(c[e].map((e=>e??NaN)),h,d,u,m)});const v=new _le;return v.build(s,n,a,1,l,i,r),v}#Fc(e=this.#to){const t=this.#qr+e/2*this.#_c;return this.#Rn%180==0?[t/this.#Oc,t/this.#Ac]:[t/this.#Ac,t/this.#Oc]}#Pc(){const[e,t,n,a]=this.#mo,[r,o]=this.#Fc(0);return[e+r,t+o,n-2*r,a-2*o]}#Dc(){const e=this.#mo=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:t}of this.#kc){if(t.length<=12){for(let n=4,a=t.length;n<a;n+=6){const[a,r]=t.subarray(n,n+2);e[0]=Math.min(e[0],a),e[1]=Math.min(e[1],r),e[2]=Math.max(e[2],a),e[3]=Math.max(e[3],r)}continue}let n=t[4],a=t[5];for(let r=6,o=t.length;r<o;r+=6){const[o,c,l,i,s,h]=t.subarray(r,r+6);pre.bezierBoundingBox(n,a,o,c,l,i,s,h,e),n=s,a=h}}const[t,n]=this.#Fc();e[0]=Math.min(1,Math.max(0,e[0]-t)),e[1]=Math.min(1,Math.max(0,e[1]-n)),e[2]=Math.min(1,Math.max(0,e[2]+t)),e[3]=Math.min(1,Math.max(0,e[3]+n)),e[2]-=e[0],e[3]-=e[1]}get box(){return this.#mo}updateProperty(e,t){return"stroke-width"===e?this.#ac(t):null}#ac(e){const[t,n]=this.#Fc();this.#to=e;const[a,r]=this.#Fc(),[o,c]=[a-t,r-n],l=this.#mo;return l[0]-=o,l[1]-=c,l[2]+=2*o,l[3]+=2*c,l}updateParentDimensions([e,t],n){const[a,r]=this.#Fc();this.#Oc=e,this.#Ac=t,this.#_c=n;const[o,c]=this.#Fc(),l=o-a,i=c-r,s=this.#mo;return s[0]-=l,s[1]-=i,s[2]+=2*l,s[3]+=2*i,s}updateRotation(e){return this.#Nc=e,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#mo.map(Vle.svgRound).join(" ")}get defaultProperties(){const[e,t]=this.#mo;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Vle.svgRound(e)} ${Vle.svgRound(t)}`}}}get rotationTransform(){const[,,e,t]=this.#mo;let n=0,a=0,r=0,o=0,c=0,l=0;switch(this.#Nc){case 90:a=t/e,r=-e/t,c=e;break;case 180:n=-1,o=-1,c=e,l=t;break;case 270:a=-t/e,r=e/t,l=t;break;default:return""}return`matrix(${n} ${a} ${r} ${o} ${Vle.svgRound(c)} ${Vle.svgRound(l)})`}getPathResizingSVGProperties([e,t,n,a]){const[r,o]=this.#Fc(),[c,l,i,s]=this.#mo;if(Math.abs(i-r)<=Vle.PRECISION||Math.abs(s-o)<=Vle.PRECISION){const r=e+n/2-(c+i/2),o=t+a/2-(l+s/2);return{path:{"transform-origin":`${Vle.svgRound(e)} ${Vle.svgRound(t)}`,transform:`${this.rotationTransform} translate(${r} ${o})`}}}const h=(n-2*r)/(i-2*r),d=(a-2*o)/(s-2*o),u=i/n,m=s/a;return{path:{"transform-origin":`${Vle.svgRound(c)} ${Vle.svgRound(l)}`,transform:`${this.rotationTransform} scale(${u} ${m}) translate(${Vle.svgRound(r)} ${Vle.svgRound(o)}) scale(${h} ${d}) translate(${Vle.svgRound(-r)} ${Vle.svgRound(-o)})`}}}getPathResizedSVGProperties([e,t,n,a]){const[r,o]=this.#Fc(),c=this.#mo,[l,i,s,h]=c;if(c[0]=e,c[1]=t,c[2]=n,c[3]=a,Math.abs(s-r)<=Vle.PRECISION||Math.abs(h-o)<=Vle.PRECISION){const r=e+n/2-(l+s/2),o=t+a/2-(i+h/2);for(const{line:e,points:t}of this.#kc)Vle._translate(e,r,o,e),Vle._translate(t,r,o,t);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Vle.svgRound(e)} ${Vle.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const d=(n-2*r)/(s-2*r),u=(a-2*o)/(h-2*o),m=-d*(l+r)+e+r,p=-u*(i+o)+t+o;if(1!==d||1!==u||0!==m||0!==p)for(const{line:e,points:t}of this.#kc)Vle._rescale(e,m,p,d,u,e),Vle._rescale(t,m,p,d,u,t);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Vle.svgRound(e)} ${Vle.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,t],n){const[a,r]=n,o=this.#mo,c=e-o[0],l=t-o[1];if(this.#Oc===a&&this.#Ac===r)for(const{line:e,points:t}of this.#kc)Vle._translate(e,c,l,e),Vle._translate(t,c,l,t);else{const e=this.#Oc/a,t=this.#Ac/r;this.#Oc=a,this.#Ac=r;for(const{line:n,points:a}of this.#kc)Vle._rescale(n,c,l,e,t,n),Vle._rescale(a,c,l,e,t,a);o[2]*=e,o[3]*=t}return o[0]=e,o[1]=t,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Vle.svgRound(e)} ${Vle.svgRound(t)}`}}}get defaultSVGProperties(){const e=this.#mo;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Vle.svgRound(e[0])} ${Vle.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}class Dle extends Ale{#Ic;constructor(e){super(),this.#Ic=e,super.updateProperties({fill:"none",stroke:Xre._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(e,t){"stroke-width"===e&&(t??=this["stroke-width"],t*=this.#Ic.realScale),super.updateSVGProperty(e,t)}clone(){const e=new Dle(this.#Ic);return e.updateAll(this),e}}class Ple extends Rle{static _type="ink";static _editorType=Iae.INK;static _defaultDrawingOptions=null;constructor(e){super({...e,name:"inkEditor"}),this._willKeepAspectRatio=!0}static initialize(e,t){Xre.initialize(e,t),this._defaultDrawingOptions=new Dle(t.viewParameters)}static getDefaultDrawingOptions(e){const t=this._defaultDrawingOptions.clone();return t.updateProperties(e),t}static get supportMultipleDrawings(){return!0}static get typesMap(){return ere(this,"typesMap",new Map([[jae.INK_THICKNESS,"stroke-width"],[jae.INK_COLOR,"stroke"],[jae.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,t,n,a,r){return new Nle(e,t,n,a,r,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,t,n,a,r,o){return _le.deserialize(e,t,n,a,r,o)}static async deserialize(e,t,n){let a=null;if(e instanceof ple){const{data:{inkLists:t,rect:n,rotation:r,id:o,color:c,opacity:l,borderStyle:{rawWidth:i},popupRef:s},parent:{page:{pageNumber:h}}}=e;a=e={annotationType:Iae.INK,color:Array.from(c),thickness:i,opacity:l,paths:{points:t},boxes:null,pageIndex:h-1,rect:n.slice(0),rotation:r,id:o,deleted:!1,popupRef:s}}const r=await super.deserialize(e,t,n);return r.annotationElementId=e.id||null,r._initialData=a,r}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:e,_drawingOptions:t,parent:n}=this;t.updateSVGProperty("stroke-width"),n.drawLayer.updateProperties(e,t.toSVGProperties())}static onScaleChangingWhenDrawing(){const e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:t,opacity:n}){this._drawingOptions=Ple.getDefaultDrawingOptions({stroke:pre.makeHexColor(...e),"stroke-width":t,"stroke-opacity":n})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:t,points:n,rect:a}=this.serializeDraw(e),{_drawingOptions:{stroke:r,"stroke-opacity":o,"stroke-width":c}}=this,l={annotationType:Iae.INK,color:Xre._colorManager.convert(r),opacity:o,thickness:c,paths:{lines:t,points:n},pageIndex:this.pageIndex,rect:a,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?l:this.annotationElementId&&!this.#Ur(l)?null:(l.id=this.annotationElementId,l)}#Ur(e){const{color:t,thickness:n,opacity:a,pageIndex:r}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||e.color.some(((e,n)=>e!==t[n]))||e.thickness!==n||e.opacity!==a||e.pageIndex!==r}renderAnnotationElement(e){const{points:t,rect:n}=this.serializeDraw(!1);return e.updateEdited({rect:n,thickness:this._drawingOptions["stroke-width"],points:t}),null}}class Fle extends Xre{#jc=null;#Bc=null;#Uc=null;#Wc=null;#$c=null;#qc="";#Gc=null;#Yc=null;#Kc=!1;#Xc=!1;static _type="stamp";static _editorType=Iae.STAMP;constructor(e){super({...e,name:"stampEditor"}),this.#Wc=e.bitmapUrl,this.#$c=e.bitmapFile}static initialize(e,t){Xre.initialize(e,t)}static get supportedTypes(){return ere(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map((e=>`image/${e}`)))}static get supportedTypesStr(){return ere(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(e){return this.supportedTypes.includes(e)}static paste(e,t){t.pasteEditor(Iae.STAMP,{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(e){const t=e.get("hasAltText");return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}#Qc(e,t=!1){e?(this.#jc=e.bitmap,t||(this.#Bc=e.id,this.#Kc=e.isSvg),e.file&&(this.#qc=e.file.name),this.#Jc()):this.remove()}#Zc(){if(this.#Uc=null,this._uiManager.enableWaiting(!1),this.#Gc){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#jc)return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#jc){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(e=null,t=!0){if(this.hasAltTextData())return null;const{mlManager:n}=this._uiManager;if(!n)throw new Error("No ML.");if(!await n.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:a,width:r,height:o}=e||this.copyCanvas(null,null,!0).imageData,c=await n.guess({name:"altText",request:{data:a,width:r,height:o,channels:a.length/(r*o)}});if(!c)throw new Error("No response from the AI service.");if(c.error)throw new Error("Error from the AI service.");if(c.cancel)return null;if(!c.output)throw new Error("No valid response from the AI service.");const l=c.output;return await this.setGuessedAltText(l),t&&!this.hasAltTextData()&&(this.altTextData={alt:l,decorative:!1}),l}#el(){if(this.#Bc)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#Bc).then((e=>this.#Qc(e,!0))).finally((()=>this.#Zc()));if(this.#Wc){const e=this.#Wc;return this.#Wc=null,this._uiManager.enableWaiting(!0),void(this.#Uc=this._uiManager.imageManager.getFromUrl(e).then((e=>this.#Qc(e))).finally((()=>this.#Zc())))}if(this.#$c){const e=this.#$c;return this.#$c=null,this._uiManager.enableWaiting(!0),void(this.#Uc=this._uiManager.imageManager.getFromFile(e).then((e=>this.#Qc(e))).finally((()=>this.#Zc())))}const e=document.createElement("input");e.type="file",e.accept=Fle.supportedTypesStr;const t=this._uiManager._signal;this.#Uc=new Promise((n=>{e.addEventListener("change",(async()=>{if(e.files&&0!==e.files.length){this._uiManager.enableWaiting(!0);const t=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#Qc(t)}else this.remove();n()}),{signal:t}),e.addEventListener("cancel",(()=>{this.remove(),n()}),{signal:t})})).finally((()=>this.#Zc())),e.click()}remove(){this.#Bc&&(this.#jc=null,this._uiManager.imageManager.deleteId(this.#Bc),this.#Gc?.remove(),this.#Gc=null,this.#Yc&&(clearTimeout(this.#Yc),this.#Yc=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#Bc&&null===this.#Gc&&this.#el(),this.isAttachedToDOM||this.parent.add(this))):this.#Bc&&this.#el()}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(this.#Uc||this.#jc||this.#Wc||this.#$c||this.#Bc)}get isResizable(){return!0}render(){if(this.div)return this.div;let e,t;if(this.width&&(e=this.x,t=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#jc?this.#Jc():this.#el(),this.width&&!this.annotationElementId){const[n,a]=this.parentDimensions;this.setAt(e*n,t*a,this.width*n,this.height*a)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(null!==this.#Yc&&clearTimeout(this.#Yc),this.#Yc=setTimeout((()=>{this.#Yc=null,this.#tl()}),200))}#Jc(){const{div:e}=this;let{width:t,height:n}=this.#jc;const[a,r]=this.pageDimensions,o=.75;if(this.width)t=this.width*a,n=this.height*r;else if(t>o*a||n>o*r){const e=Math.min(o*a/t,o*r/n);t*=e,n*=e}const[c,l]=this.parentDimensions;this.setDims(t*c/a,n*l/r),this._uiManager.enableWaiting(!1);const i=this.#Gc=document.createElement("canvas");i.setAttribute("role","img"),this.addContainer(i),this.width=t/a,this.height=n/r,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(e.hidden=!1),this.#tl(),this.#Xc||(this.parent.addUndoableEditor(this),this.#Xc=!0),this._reportTelemetry({action:"inserted_image"}),this.#qc&&i.setAttribute("aria-label",this.#qc)}copyCanvas(e,t,n=!1){e||(e=224);const{width:a,height:r}=this.#jc,o=new Pre;let c=this.#jc,l=a,i=r,s=null;if(t){if(a>t||r>t){const e=Math.min(t/a,t/r);l=Math.floor(a*e),i=Math.floor(r*e)}s=document.createElement("canvas");const e=s.width=Math.ceil(l*o.sx),n=s.height=Math.ceil(i*o.sy);this.#Kc||(c=this.#nl(e,n));const h=s.getContext("2d");h.filter=this._uiManager.hcmFilter;let d="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(d="#8f8f9d",u="#42414d");const m=15,p=m*o.sx,v=m*o.sy,f=new OffscreenCanvas(2*p,2*v),z=f.getContext("2d");z.fillStyle=d,z.fillRect(0,0,2*p,2*v),z.fillStyle=u,z.fillRect(0,0,p,v),z.fillRect(p,v,p,v),h.fillStyle=h.createPattern(f,"repeat"),h.fillRect(0,0,e,n),h.drawImage(c,0,0,c.width,c.height,0,0,e,n)}let h=null;if(n){let t,n;if(o.symmetric&&c.width<e&&c.height<e)t=c.width,n=c.height;else if(c=this.#jc,a>e||r>e){const o=Math.min(e/a,e/r);t=Math.floor(a*o),n=Math.floor(r*o),this.#Kc||(c=this.#nl(t,n))}const l=new OffscreenCanvas(t,n).getContext("2d",{willReadFrequently:!0});l.drawImage(c,0,0,c.width,c.height,0,0,t,n),h={width:t,height:n,data:l.getImageData(0,0,t,n).data}}return{canvas:s,width:l,height:i,imageData:h}}#nl(e,t){const{width:n,height:a}=this.#jc;let r=n,o=a,c=this.#jc;for(;r>2*e||o>2*t;){const n=r,a=o;r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2)),o>2*t&&(o=o>=16384?Math.floor(o/2)-1:Math.ceil(o/2));const l=new OffscreenCanvas(r,o);l.getContext("2d").drawImage(c,0,0,n,a,0,0,r,o),c=l.transferToImageBitmap()}return c}#tl(){const[e,t]=this.parentDimensions,{width:n,height:a}=this,r=new Pre,o=Math.ceil(n*e*r.sx),c=Math.ceil(a*t*r.sy),l=this.#Gc;if(!l||l.width===o&&l.height===c)return;l.width=o,l.height=c;const i=this.#Kc?this.#jc:this.#nl(o,c),s=l.getContext("2d");s.filter=this._uiManager.hcmFilter,s.drawImage(i,0,0,i.width,i.height,0,0,o,c)}getImageForAltText(){return this.#Gc}#al(e){if(e){if(this.#Kc){const e=this._uiManager.imageManager.getSvgUrl(this.#Bc);if(e)return e}const e=document.createElement("canvas");return({width:e.width,height:e.height}=this.#jc),e.getContext("2d").drawImage(this.#jc,0,0),e.toDataURL()}if(this.#Kc){const[e,t]=this.pageDimensions,n=Math.round(this.width*e*Mre.PDF_TO_CSS_UNITS),a=Math.round(this.height*t*Mre.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(n,a);return r.getContext("2d").drawImage(this.#jc,0,0,this.#jc.width,this.#jc.height,0,0,n,a),r.transferToImageBitmap()}return structuredClone(this.#jc)}static async deserialize(e,t,n){let a=null;if(e instanceof yle){const{data:{rect:r,rotation:o,id:c,structParent:l,popupRef:i},container:s,parent:{page:{pageNumber:h}}}=e,d=s.querySelector("canvas"),u=n.imageManager.getFromCanvas(s.id,d);d.remove();const m=(await t._structTree.getAriaAttributes(`${gre}${c}`))?.get("aria-label")||"";a=e={annotationType:Iae.STAMP,bitmapId:u.id,bitmap:u.bitmap,pageIndex:h-1,rect:r.slice(0),rotation:o,id:c,deleted:!1,accessibilityData:{decorative:!1,altText:m},isSvg:!1,structParent:l,popupRef:i}}const r=await super.deserialize(e,t,n),{rect:o,bitmap:c,bitmapUrl:l,bitmapId:i,isSvg:s,accessibilityData:h}=e;i&&n.imageManager.isValidId(i)?(r.#Bc=i,c&&(r.#jc=c)):r.#Wc=l,r.#Kc=s;const[d,u]=r.pageDimensions;return r.width=(o[2]-o[0])/d,r.height=(o[3]-o[1])/u,r.annotationElementId=e.id||null,h&&(r.altTextData=h),r._initialData=a,r.#Xc=!!a,r}serialize(e=!1,t=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const n={annotationType:Iae.STAMP,bitmapId:this.#Bc,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#Kc,structTreeParentId:this._structTreeParentId};if(e)return n.bitmapUrl=this.#al(!0),n.accessibilityData=this.serializeAltText(!0),n;const{decorative:a,altText:r}=this.serializeAltText(!1);if(!a&&r&&(n.accessibilityData={type:"Figure",alt:r}),this.annotationElementId){const e=this.#Ur(n);if(e.isSame)return null;e.isSameAltText?delete n.accessibilityData:n.accessibilityData.structParent=this._initialData.structParent??-1}if(n.id=this.annotationElementId,null===t)return n;t.stamps||=new Map;const o=this.#Kc?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(t.stamps.has(this.#Bc)){if(this.#Kc){const e=t.stamps.get(this.#Bc);o>e.area&&(e.area=o,e.serialized.bitmap.close(),e.serialized.bitmap=this.#al(!1))}}else t.stamps.set(this.#Bc,{area:o,serialized:n}),n.bitmap=this.#al(!1);return n}#Ur(e){const{pageIndex:t,accessibilityData:{altText:n}}=this._initialData,a=e.pageIndex===t,r=(e.accessibilityData?.alt||"")===n;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&a&&r,isSameAltText:r}}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}}class Ile{#Lr;#rl=!1;#ol=null;#cl=null;#ll=null;#il=new Map;#sl=!1;#hl=!1;#dl=!1;#ul=null;#ml=null;#pl=null;#vl=null;#v;static _initialized=!1;static#j=new Map([Hle,Ple,Fle,Ole].map((e=>[e._editorType,e])));constructor({uiManager:e,pageIndex:t,div:n,structTreeLayer:a,accessibilityManager:r,annotationLayer:o,drawLayer:c,textLayer:l,viewport:i,l10n:s}){const h=[...Ile.#j.values()];if(!Ile._initialized){Ile._initialized=!0;for(const t of h)t.initialize(s,e)}e.registerEditorTypes(h),this.#v=e,this.pageIndex=t,this.div=n,this.#Lr=r,this.#ol=o,this.viewport=i,this.#pl=l,this.drawLayer=c,this._structTree=a,this.#v.addLayer(this)}get isEmpty(){return 0===this.#il.size}get isInvisible(){return this.isEmpty&&this.#v.getMode()===Iae.NONE}updateToolbar(e){this.#v.updateToolbar(e)}updateMode(e=this.#v.getMode()){switch(this.#fl(),e){case Iae.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case Iae.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Iae.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:t}=this.div;for(const n of Ile.#j.values())t.toggle(`${n._type}Editing`,e===n._editorType);this.div.hidden=!1}hasTextLayer(e){return e===this.#pl?.div}setEditingState(e){this.#v.setEditingState(e)}addCommands(e){this.#v.addCommands(e)}cleanUndoStack(e){this.#v.cleanUndoStack(e)}toggleDrawing(e=!1){this.div.classList.toggle("drawing",!e)}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}toggleAnnotationLayerPointerEvents(e=!1){this.#ol?.div.classList.toggle("disabled",!e)}async enable(){this.#dl=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);const e=new Set;for(const t of this.#il.values())t.enableEditing(),t.show(!0),t.annotationElementId&&(this.#v.removeChangedExistingAnnotation(t),e.add(t.annotationElementId));if(!this.#ol)return void(this.#dl=!1);const t=this.#ol.getEditableAnnotations();for(const n of t){if(n.hide(),this.#v.isDeletedAnnotationElement(n.data.id))continue;if(e.has(n.data.id))continue;const t=await this.deserialize(n);t&&(this.addOrRebuild(t),t.enableEditing())}this.#dl=!1}disable(){this.#hl=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,t=new Map;for(const n of this.#il.values())n.disableEditing(),n.annotationElementId&&(null===n.serialize()?(t.set(n.annotationElementId,n),this.getEditableAnnotation(n.annotationElementId)?.show(),n.remove()):e.set(n.annotationElementId,n));if(this.#ol){const n=this.#ol.getEditableAnnotations();for(const a of n){const{id:n}=a.data;if(this.#v.isDeletedAnnotationElement(n))continue;let r=t.get(n);r?(r.resetAnnotationElement(a),r.show(!1),a.show()):(r=e.get(n),r&&(this.#v.addChangedExistingAnnotation(r),r.renderAnnotationElement(a)&&r.show(!1)),a.show())}}this.#fl(),this.isEmpty&&(this.div.hidden=!0);const{classList:n}=this.div;for(const e of Ile.#j.values())n.remove(`${e._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#hl=!1}getEditableAnnotation(e){return this.#ol?.getEditableAnnotation(e)||null}setActiveEditor(e){this.#v.getActive()!==e&&this.#v.setActiveEditor(e)}enableTextSelection(){if(this.div.tabIndex=-1,this.#pl?.div&&!this.#vl){this.#vl=new AbortController;const e=this.#v.combinedSignal(this.#vl);this.#pl.div.addEventListener("pointerdown",this.#zl.bind(this),{signal:e}),this.#pl.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#pl?.div&&this.#vl&&(this.#vl.abort(),this.#vl=null,this.#pl.div.classList.remove("highlighting"))}#zl(e){this.#v.unselectAll();const{target:t}=e;if(t===this.#pl.div||("img"===t.getAttribute("role")||t.classList.contains("endOfContent"))&&this.#pl.div.contains(t)){const{isMac:t}=ure.platform;if(0!==e.button||e.ctrlKey&&t)return;this.#v.showAllEditors("highlight",!0,!0),this.#pl.div.classList.add("free"),this.toggleDrawing(),Ole.startHighlighting(this,"ltr"===this.#v.direction,{target:this.#pl.div,x:e.x,y:e.y}),this.#pl.div.addEventListener("pointerup",(()=>{this.#pl.div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:this.#v._signal}),e.preventDefault()}}enableClick(){if(this.#cl)return;this.#cl=new AbortController;const e=this.#v.combinedSignal(this.#cl);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:e});const t=this.pointerup.bind(this);this.div.addEventListener("pointerup",t,{signal:e}),this.div.addEventListener("pointercancel",t,{signal:e})}disableClick(){this.#cl?.abort(),this.#cl=null}attach(e){this.#il.set(e.id,e);const{annotationElementId:t}=e;t&&this.#v.isDeletedAnnotationElement(t)&&this.#v.removeDeletedAnnotationElement(e)}detach(e){this.#il.delete(e.id),this.#Lr?.removePointerInTextLayer(e.contentDiv),!this.#hl&&e.annotationElementId&&this.#v.addDeletedAnnotationElement(e)}remove(e){this.detach(e),this.#v.removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1}changeParent(e){e.parent!==this&&(e.parent&&e.annotationElementId&&(this.#v.addDeletedAnnotationElement(e.annotationElementId),Xre.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),e.parent?.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))}add(e){if(e.parent!==this||!e.isAttachedToDOM){if(this.changeParent(e),this.#v.addEditor(e),this.attach(e),!e.isAttachedToDOM){const t=e.render();this.div.append(t),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(!this.#dl),this.#v.addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){if(!e.isAttachedToDOM)return;const{activeElement:t}=document;e.div.contains(t)&&!this.#ll&&(e._focusEventsAllowed=!1,this.#ll=setTimeout((()=>{this.#ll=null,e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener("focusin",(()=>{e._focusEventsAllowed=!0}),{once:!0,signal:this.#v._signal}),t.focus())}),0)),e._structTreeParentId=this.#Lr?.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?(e.parent||=this,e.rebuild(),e.show()):this.add(e)}addUndoableEditor(e){this.addCommands({cmd:()=>e._uiManager.rebuild(e),undo:()=>{e.remove()},mustExec:!1})}getNextId(){return this.#v.getId()}get#gl(){return Ile.#j.get(this.#v.getMode())}combinedSignal(e){return this.#v.combinedSignal(e)}#yl(e){const t=this.#gl;return t?new t.prototype.constructor(e):null}canCreateNewEmptyEditor(){return this.#gl?.canCreateNewEmptyEditor()}pasteEditor(e,t){this.#v.updateToolbar(e),this.#v.updateMode(e);const{offsetX:n,offsetY:a}=this.#Ml(),r=this.getNextId(),o=this.#yl({parent:this,id:r,x:n,y:a,uiManager:this.#v,isCentered:!0,...t});o&&this.add(o)}async deserialize(e){return await(Ile.#j.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,this.#v))||null}createAndAddNewEditor(e,t,n={}){const a=this.getNextId(),r=this.#yl({parent:this,id:a,x:e.offsetX,y:e.offsetY,uiManager:this.#v,isCentered:t,...n});return r&&this.add(r),r}#Ml(){const{x:e,y:t,width:n,height:a}=this.div.getBoundingClientRect(),r=Math.max(0,e),o=Math.max(0,t),c=(r+Math.min(window.innerWidth,e+n))/2-e,l=(o+Math.min(window.innerHeight,t+a))/2-t,[i,s]=this.viewport.rotation%180==0?[c,l]:[l,c];return{offsetX:i,offsetY:s}}addNewEditor(){this.createAndAddNewEditor(this.#Ml(),!0)}setSelected(e){this.#v.setSelected(e)}toggleSelected(e){this.#v.toggleSelected(e)}unselect(e){this.#v.unselect(e)}pointerup(e){const{isMac:t}=ure.platform;0!==e.button||e.ctrlKey&&t||e.target===this.div&&this.#sl&&(this.#sl=!1,this.#gl?.isDrawer&&this.#gl.supportMultipleDrawings||(this.#rl?this.#v.getMode()!==Iae.STAMP?this.createAndAddNewEditor(e,!1):this.#v.unselectAll():this.#rl=!0))}pointerdown(e){if(this.#v.getMode()===Iae.HIGHLIGHT&&this.enableTextSelection(),this.#sl)return void(this.#sl=!1);const{isMac:t}=ure.platform;if(0!==e.button||e.ctrlKey&&t)return;if(e.target!==this.div)return;if(this.#sl=!0,this.#gl?.isDrawer)return void this.startDrawingSession(e);const n=this.#v.getActive();this.#rl=!n||n.isEmpty()}startDrawingSession(e){if(this.div.focus(),this.#ul)return void this.#gl.startDrawing(this,this.#v,!1,e);this.#v.setCurrentDrawingSession(this),this.#ul=new AbortController;const t=this.#v.combinedSignal(this.#ul);this.div.addEventListener("blur",(({relatedTarget:e})=>{e&&!this.div.contains(e)&&(this.#ml=null,this.commitOrRemove())}),{signal:t}),this.#gl.startDrawing(this,this.#v,!1,e)}pause(e){if(e){const{activeElement:e}=document;this.div.contains(e)&&(this.#ml=e)}else this.#ml&&setTimeout((()=>{this.#ml?.focus(),this.#ml=null}),0)}endDrawingSession(e=!1){return this.#ul?(this.#v.setCurrentDrawingSession(null),this.#ul.abort(),this.#ul=null,this.#ml=null,this.#gl.endDrawing(e)):null}findNewParent(e,t,n){const a=this.#v.findParent(t,n);return null!==a&&a!==this&&(a.changeParent(e),!0)}commitOrRemove(){return!!this.#ul&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#ul&&this.#gl.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#v.getActive()?.parent===this&&(this.#v.commitOrRemove(),this.#v.setActiveEditor(null)),this.#ll&&(clearTimeout(this.#ll),this.#ll=null);for(const e of this.#il.values())this.#Lr?.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove();this.div=null,this.#il.clear(),this.#v.removeLayer(this)}#fl(){for(const e of this.#il.values())e.isEmpty()&&e.remove()}render({viewport:e}){this.viewport=e,Dre(this.div,e);for(const e of this.#v.getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:e}){this.#v.commitOrRemove(),this.#fl();const t=this.viewport.rotation,n=e.rotation;if(this.viewport=e,Dre(this.div,{rotation:n}),t!==n)for(const e of this.#il.values())e.rotate(n)}get pageDimensions(){const{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return this.#v.viewParameters.realScale}}class jle{#rr=null;#y=0;#El=new Map;#bl=new Map;constructor({pageIndex:e}){this.pageIndex=e}setParent(e){if(this.#rr){if(this.#rr!==e){if(this.#El.size>0)for(const t of this.#El.values())t.remove(),e.append(t);this.#rr=e}}else this.#rr=e}static get _svgFactory(){return ere(this,"_svgFactory",new Uce)}static#Hl(e,[t,n,a,r]){const{style:o}=e;o.top=100*n+"%",o.left=100*t+"%",o.width=100*a+"%",o.height=100*r+"%"}#Vl(){const e=jle._svgFactory.create(1,1,!0);return this.#rr.append(e),e.setAttribute("aria-hidden",!0),e}#Cl(e,t){const n=jle._svgFactory.createElement("clipPath");e.append(n);const a=`clip_${t}`;n.setAttribute("id",a),n.setAttribute("clipPathUnits","objectBoundingBox");const r=jle._svgFactory.createElement("use");return n.append(r),r.setAttribute("href",`#${t}`),r.classList.add("clip"),a}#Ll(e,t){for(const[n,a]of Object.entries(t))null===a?e.removeAttribute(n):e.setAttribute(n,a)}draw(e,t=!1,n=!1){const a=this.#y++,r=this.#Vl(),o=jle._svgFactory.createElement("defs");r.append(o);const c=jle._svgFactory.createElement("path");o.append(c);const l=`path_p${this.pageIndex}_${a}`;c.setAttribute("id",l),c.setAttribute("vector-effect","non-scaling-stroke"),t&&this.#bl.set(a,c);const i=n?this.#Cl(o,l):null,s=jle._svgFactory.createElement("use");return r.append(s),s.setAttribute("href",`#${l}`),this.updateProperties(r,e),this.#El.set(a,r),{id:a,clipPathId:`url(#${i})`}}drawOutline(e,t){const n=this.#y++,a=this.#Vl(),r=jle._svgFactory.createElement("defs");a.append(r);const o=jle._svgFactory.createElement("path");r.append(o);const c=`path_p${this.pageIndex}_${n}`;let l;if(o.setAttribute("id",c),o.setAttribute("vector-effect","non-scaling-stroke"),t){const e=jle._svgFactory.createElement("mask");r.append(e),l=`mask_p${this.pageIndex}_${n}`,e.setAttribute("id",l),e.setAttribute("maskUnits","objectBoundingBox");const t=jle._svgFactory.createElement("rect");e.append(t),t.setAttribute("width","1"),t.setAttribute("height","1"),t.setAttribute("fill","white");const a=jle._svgFactory.createElement("use");e.append(a),a.setAttribute("href",`#${c}`),a.setAttribute("stroke","none"),a.setAttribute("fill","black"),a.setAttribute("fill-rule","nonzero"),a.classList.add("mask")}const i=jle._svgFactory.createElement("use");a.append(i),i.setAttribute("href",`#${c}`),l&&i.setAttribute("mask",`url(#${l})`);const s=i.cloneNode();return a.append(s),i.classList.add("mainOutline"),s.classList.add("secondaryOutline"),this.updateProperties(a,e),this.#El.set(n,a),n}finalizeDraw(e,t){this.#bl.delete(e),this.updateProperties(e,t)}updateProperties(e,t){if(!t)return;const{root:n,bbox:a,rootClass:r,path:o}=t,c="number"==typeof e?this.#El.get(e):e;if(c){if(n&&this.#Ll(c,n),a&&jle.#Hl(c,a),r){const{classList:e}=c;for(const[t,n]of Object.entries(r))e.toggle(t,n)}if(o){const e=c.firstChild.firstChild;this.#Ll(e,o)}}}updateParent(e,t){if(t===this)return;const n=this.#El.get(e);n&&(t.#rr.append(n),this.#El.delete(e),t.#El.set(e,n))}remove(e){this.#bl.delete(e),null!==this.#rr&&(this.#El.get(e).remove(),this.#El.delete(e))}destroy(){this.#rr=null;for(const e of this.#El.values())e.remove();this.#El.clear(),this.#bl.clear()}}globalThis.pdfjsTestingUtils={HighlightOutliner:xle};var Ble=Rae.GlobalWorkerOptions,Ule=Rae.TextLayer,Wle=Rae.getDocument;function $le(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var a=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===n&&a.firstChild?a.insertBefore(r,a.firstChild):a.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}$le('.messageBar{--closing-button-icon:url(images/messageBar_closingButton.svg);--message-bar-close-button-color:var(--text-primary-color);--message-bar-close-button-color-hover:var(--text-primary-color);--message-bar-close-button-border-radius:4px;--message-bar-close-button-border:none;--message-bar-close-button-hover-bg-color:#15141a24;--message-bar-close-button-active-bg-color:#15141a36;--message-bar-close-button-focus-bg-color:#15141a12}@media (prefers-color-scheme:dark){.messageBar{--message-bar-close-button-hover-bg-color:#fbfbfe24;--message-bar-close-button-active-bg-color:#fbfbfe36;--message-bar-close-button-focus-bg-color:#fbfbfe12}}@media screen and (forced-colors:active){.messageBar{--message-bar-close-button-color:ButtonText;--message-bar-close-button-border:1px solid ButtonText;--message-bar-close-button-hover-bg-color:ButtonText;--message-bar-close-button-active-bg-color:ButtonText;--message-bar-close-button-focus-bg-color:ButtonText;--message-bar-close-button-color-hover:HighlightText}}.messageBar{align-items:center;background:var(--message-bar-bg-color);border:1px solid var(--message-bar-border-color);border-radius:4px;color:var(--message-bar-fg-color);display:flex;flex-direction:column;gap:8px;justify-content:center;padding:8px 8px 8px 16px;position:relative;-webkit-user-select:none;-moz-user-select:none;user-select:none}.messageBar>div{align-items:flex-start;align-self:stretch;display:flex;gap:8px}:is(.messageBar>div):before{background-color:var(--message-bar-icon-color);content:"";display:inline-block;flex-shrink:0;height:16px;-webkit-mask-image:var(--message-bar-icon);mask-image:var(--message-bar-icon);-webkit-mask-size:cover;mask-size:cover;width:16px}.messageBar button{cursor:pointer}:is(.messageBar button):focus-visible{outline:var(--focus-ring-outline);outline-offset:2px}.messageBar .closeButton{align-items:center;background:none;border:var(--message-bar-close-button-border);border-radius:var(--message-bar-close-button-border-radius);display:flex;height:32px;justify-content:center;width:32px}:is(.messageBar .closeButton):before{background-color:var(--message-bar-close-button-color);content:"";display:inline-block;height:16px;-webkit-mask-image:var(--closing-button-icon);mask-image:var(--closing-button-icon);-webkit-mask-size:cover;mask-size:cover;width:16px}:is(.messageBar .closeButton):is(:hover,:active,:focus):before{background-color:var(--message-bar-close-button-color-hover)}:is(.messageBar .closeButton):hover{background-color:var(--message-bar-close-button-hover-bg-color)}:is(.messageBar .closeButton):active{background-color:var(--message-bar-close-button-active-bg-color)}:is(.messageBar .closeButton):focus{background-color:var(--message-bar-close-button-focus-bg-color)}:is(.messageBar .closeButton)>span{display:inline-block;height:0;overflow:hidden;width:0}#editorUndoBar{--text-primary-color:#15141a;--message-bar-icon:url(images/secondaryToolbarButton-documentProperties.svg);--message-bar-icon-color:#0060df;--message-bar-bg-color:#deeafc;--message-bar-fg-color:var(--text-primary-color);--message-bar-border-color:#00000014;--undo-button-bg-color:#15141a12;--undo-button-bg-color-hover:#15141a24;--undo-button-bg-color-active:#15141a36;--undo-button-fg-color:var(--message-bar-fg-color);--undo-button-fg-color-hover:var(--undo-button-fg-color);--undo-button-fg-color-active:var(--undo-button-fg-color);--focus-ring-color:#0060df;--focus-ring-outline:2px solid var(--focus-ring-color)}@media (prefers-color-scheme:dark){#editorUndoBar{--text-primary-color:#fbfbfe;--message-bar-icon-color:#73a7f3;--message-bar-bg-color:#003070;--message-bar-border-color:#ffffff14;--undo-button-bg-color:#ffffff14;--undo-button-bg-color-hover:#ffffff24;--undo-button-bg-color-active:#ffffff36}}@media screen and (forced-colors:active){#editorUndoBar{--text-primary-color:CanvasText;--message-bar-icon-color:CanvasText;--message-bar-bg-color:Canvas;--message-bar-border-color:CanvasText;--undo-button-bg-color:ButtonText;--undo-button-bg-color-hover:SelectedItem;--undo-button-bg-color-active:SelectedItem;--undo-button-fg-color:ButtonFace;--undo-button-fg-color-hover:SelectedItemText;--undo-button-fg-color-active:SelectedItemText;--focus-ring-color:CanvasText}}#editorUndoBar{cursor:default;font:menu;font-size:15px;left:50%;padding-block:8px;padding-inline:16px 8px;position:fixed;top:50px;transform:translateX(-50%);z-index:10}#editorUndoBar button{cursor:pointer}#editorUndoBar #editorUndoBarUndoButton{background-color:var(--undo-button-bg-color);border:none;border-radius:4px;color:var(--undo-button-fg-color);font-weight:590;height:32px;line-height:19.5px;margin-inline-start:8px;padding:4px 16px}:is(#editorUndoBar #editorUndoBarUndoButton):hover{background-color:var(--undo-button-bg-color-hover);color:var(--undo-button-fg-color-hover)}:is(#editorUndoBar #editorUndoBarUndoButton):active{background-color:var(--undo-button-bg-color-active);color:var(--undo-button-fg-color-active)}#editorUndoBar>div{align-items:center}.dialog{--dialog-bg-color:#fff;--dialog-border-color:#fff;--dialog-shadow:0 2px 14px 0 #3a394433;--text-primary-color:#15141a;--text-secondary-color:#5b5b66;--hover-filter:brightness(0.9);--focus-ring-color:#0060df;--focus-ring-outline:2px solid var(--focus-ring-color);--link-fg-color:#0060df;--link-hover-fg-color:#0250bb;--separator-color:#f0f0f4;--textarea-border-color:#8f8f9d;--textarea-bg-color:#fff;--textarea-fg-color:var(--text-secondary-color);--radio-bg-color:#f0f0f4;--radio-checked-bg-color:#fbfbfe;--radio-border-color:#8f8f9d;--radio-checked-border-color:#0060df;--button-secondary-bg-color:#f0f0f4;--button-secondary-fg-color:var(--text-primary-color);--button-secondary-border-color:var(--button-secondary-bg-color);--button-secondary-hover-bg-color:var(--button-secondary-bg-color);--button-secondary-hover-fg-color:var(--button-secondary-fg-color);--button-secondary-hover-border-color:var(--button-secondary-hover-bg-color);--button-primary-bg-color:#0060df;--button-primary-fg-color:#fbfbfe;--button-primary-border-color:var(--button-primary-bg-color);--button-primary-hover-bg-color:var(--button-primary-bg-color);--button-primary-hover-fg-color:var(--button-primary-fg-color);--button-primary-hover-border-color:var(--button-primary-hover-bg-color)}@media (prefers-color-scheme:dark){.dialog{--dialog-bg-color:#1c1b22;--dialog-border-color:#1c1b22;--dialog-shadow:0 2px 14px 0 #15141a;--text-primary-color:#fbfbfe;--text-secondary-color:#cfcfd8;--focus-ring-color:#0df;--hover-filter:brightness(1.4);--link-fg-color:#0df;--link-hover-fg-color:#80ebff;--separator-color:#52525e;--textarea-bg-color:#42414d;--radio-bg-color:#2b2a33;--radio-checked-bg-color:#15141a;--radio-checked-border-color:#0df;--button-secondary-bg-color:#2b2a33;--button-primary-bg-color:#0df;--button-primary-fg-color:#15141a}}@media screen and (forced-colors:active){.dialog{--dialog-bg-color:Canvas;--dialog-border-color:CanvasText;--dialog-shadow:none;--text-primary-color:CanvasText;--text-secondary-color:CanvasText;--hover-filter:none;--focus-ring-color:ButtonBorder;--link-fg-color:LinkText;--link-hover-fg-color:LinkText;--separator-color:CanvasText;--textarea-border-color:ButtonBorder;--textarea-bg-color:Field;--textarea-fg-color:ButtonText;--radio-bg-color:ButtonFace;--radio-checked-bg-color:ButtonFace;--radio-border-color:ButtonText;--radio-checked-border-color:ButtonText;--button-secondary-bg-color:ButtonFace;--button-secondary-fg-color:ButtonText;--button-secondary-border-color:ButtonText;--button-secondary-hover-bg-color:AccentColor;--button-secondary-hover-fg-color:AccentColorText;--button-primary-bg-color:ButtonText;--button-primary-fg-color:ButtonFace;--button-primary-hover-bg-color:AccentColor;--button-primary-hover-fg-color:AccentColorText}}.dialog{background:var(--dialog-bg-color);border:1px solid var(--dialog-border-color);border-radius:4px;box-shadow:var(--dialog-shadow);color:var(--text-primary-color);font:message-box;font-size:13px;font-weight:400;line-height:150%;padding:12px 16px}:is(.dialog .mainContainer) :focus-visible{outline:var(--focus-ring-outline);outline-offset:2px}:is(.dialog .mainContainer) .title{align-items:flex-start;display:flex;flex-direction:column;gap:12px;justify-content:flex-end;width:auto}:is(:is(.dialog .mainContainer) .title)>span{font-size:13px;font-style:normal;font-weight:590;line-height:150%}:is(.dialog .mainContainer) .dialogSeparator{border-bottom:none;border-top:1px solid var(--separator-color);height:0;margin-block:4px;width:100%}:is(.dialog .mainContainer) .dialogButtonsGroup{align-self:flex-end;display:flex;gap:12px}:is(.dialog .mainContainer) .radio{align-items:flex-start;display:flex;flex-direction:column;gap:4px}:is(:is(.dialog .mainContainer) .radio)>.radioButton{align-items:center;align-self:stretch;display:flex;gap:8px}:is(:is(:is(.dialog .mainContainer) .radio)>.radioButton) input{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:var(--radio-bg-color);border:1px solid var(--radio-border-color);border-radius:50%;box-sizing:border-box;height:16px;width:16px}:is(:is(:is(:is(.dialog .mainContainer) .radio)>.radioButton) input):hover{filter:var(--hover-filter)}:is(:is(:is(:is(.dialog .mainContainer) .radio)>.radioButton) input):checked{background-color:var(--radio-checked-bg-color);border:4px solid var(--radio-checked-border-color)}:is(:is(.dialog .mainContainer) .radio)>.radioLabel{align-items:flex-start;align-self:stretch;display:flex;gap:10px;padding-inline-start:24px}:is(:is(:is(.dialog .mainContainer) .radio)>.radioLabel)>span{color:var(--text-secondary-color);flex:1 0 0;font-size:11px}:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton)){border:1px solid;border-radius:4px;font:menu;font-weight:600;height:32px;padding:4px 16px;width:auto}:is(:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton))):hover{cursor:pointer;filter:var(--hover-filter)}.secondaryButton:is(:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton))){background-color:var(--button-secondary-bg-color);border-color:var(--button-secondary-border-color);color:var(--button-secondary-fg-color)}.secondaryButton:is(:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton))):hover{background-color:var(--button-secondary-hover-bg-color);border-color:var(--button-secondary-hover-border-color);color:var(--button-secondary-hover-fg-color)}.primaryButton:is(:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton))){background-color:var(--button-primary-bg-color);border-color:var(--button-primary-border-color);color:var(--button-primary-fg-color);opacity:1}.primaryButton:is(:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton))):hover{background-color:var(--button-primary-hover-bg-color);border-color:var(--button-primary-hover-border-color);color:var(--button-primary-hover-fg-color)}:is(.dialog .mainContainer) a{color:var(--link-fg-color)}:is(:is(.dialog .mainContainer) a):hover{color:var(--link-hover-fg-color)}:is(.dialog .mainContainer) textarea{background:var(--textarea-bg-color);border:1px solid var(--textarea-border-color);border-radius:4px;box-sizing:border-box;color:var(--textarea-fg-color);font:inherit;margin:0;padding:8px;resize:none}:is(:is(.dialog .mainContainer) textarea):focus{border-color:#0000;outline-offset:0}:is(:is(.dialog .mainContainer) textarea):disabled{opacity:.4;pointer-events:none}:is(.dialog .mainContainer) .messageBar{--message-bar-bg-color:#ffebcd;--message-bar-fg-color:#15141a;--message-bar-border-color:#00000014;--message-bar-icon:url(images/messageBar_warning.svg);--message-bar-icon-color:#cd411e}@media (prefers-color-scheme:dark){:is(.dialog .mainContainer) .messageBar{--message-bar-bg-color:#5a3100;--message-bar-fg-color:#fbfbfe;--message-bar-border-color:#ffffff14;--message-bar-icon-color:#e49c49}}@media screen and (forced-colors:active){:is(.dialog .mainContainer) .messageBar{--message-bar-bg-color:HighlightText;--message-bar-fg-color:CanvasText;--message-bar-border-color:CanvasText;--message-bar-icon-color:CanvasText}}:is(.dialog .mainContainer) .messageBar{align-self:stretch}:is(:is(:is(.dialog .mainContainer) .messageBar)>div):before,:is(:is(:is(.dialog .mainContainer) .messageBar)>div)>div{margin-block:4px}:is(:is(:is(.dialog .mainContainer) .messageBar)>div)>div{align-items:flex-start;display:flex;flex:1 0 0;flex-direction:column;gap:8px}:is(:is(:is(:is(.dialog .mainContainer) .messageBar)>div)>div) .title{font-size:13px;font-weight:590}:is(:is(:is(:is(.dialog .mainContainer) .messageBar)>div)>div) .description{font-size:13px}:is(.dialog .mainContainer) .toggler{align-items:center;align-self:stretch;display:flex;gap:8px}:is(:is(.dialog .mainContainer) .toggler)>.togglerLabel{-webkit-user-select:none;-moz-user-select:none;user-select:none}.textLayer{-webkit-text-size-adjust:none;-moz-text-size-adjust:none;text-size-adjust:none;caret-color:CanvasText;forced-color-adjust:none;inset:0;line-height:1;opacity:1;overflow:clip;position:absolute;text-align:initial;transform-origin:0 0;z-index:0}.textLayer.highlighting{touch-action:none}.textLayer :is(span,br){color:#0000;cursor:text;position:absolute;transform-origin:0 0;white-space:pre}.textLayer .markedContent span:not(.markedContent),.textLayer>:not(.markedContent){z-index:1}.textLayer span.markedContent{height:0;top:0}.textLayer span[role=img]{cursor:default;-webkit-user-select:none;-moz-user-select:none;user-select:none}.textLayer .highlight{--highlight-bg-color:#b400aa40;--highlight-selected-bg-color:#00640040;--highlight-backdrop-filter:none;--highlight-selected-backdrop-filter:none}@media screen and (forced-colors:active){.textLayer .highlight{--highlight-bg-color:#0000;--highlight-selected-bg-color:#0000;--highlight-backdrop-filter:var(--hcm-highlight-filter);--highlight-selected-backdrop-filter:var(\n --hcm-highlight-selected-filter\n )}}.textLayer .highlight{-webkit-backdrop-filter:var(--highlight-backdrop-filter);backdrop-filter:var(--highlight-backdrop-filter);background-color:var(--highlight-bg-color);border-radius:4px;margin:-1px;padding:1px}.appended:is(.textLayer .highlight){position:static}.begin:is(.textLayer .highlight){border-radius:4px 0 0 4px}.end:is(.textLayer .highlight){border-radius:0 4px 4px 0}.middle:is(.textLayer .highlight){border-radius:0}.selected:is(.textLayer .highlight){-webkit-backdrop-filter:var(--highlight-selected-backdrop-filter);backdrop-filter:var(--highlight-selected-backdrop-filter);background-color:var(--highlight-selected-bg-color)}.textLayer ::-moz-selection{background:#0000ff40;background:color-mix(in srgb,AccentColor,#0000 75%)}.textLayer ::selection{background:#0000ff40;background:color-mix(in srgb,AccentColor,#0000 75%)}.textLayer br::-moz-selection{background:#0000}.textLayer br::selection{background:#0000}.textLayer .endOfContent{cursor:default;display:block;inset:100% 0 0;position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:0}.textLayer.selecting .endOfContent{top:0}.annotationLayer{--annotation-unfocused-field-background:url(\'data:image/svg+xml;charset=utf-8,<svg width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%" style="fill:rgba(0,54,255,.13)"/></svg>\');--input-focus-border-color:Highlight;--input-focus-outline:1px solid Canvas;--input-unfocused-border-color:#0000;--input-disabled-border-color:#0000;--input-hover-border-color:#000;--link-outline:none}@media screen and (forced-colors:active){.annotationLayer{--input-focus-border-color:CanvasText;--input-unfocused-border-color:ActiveText;--input-disabled-border-color:GrayText;--input-hover-border-color:Highlight;--link-outline:1.5px solid LinkText}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input:required,.annotationLayer .choiceWidgetAnnotation select:required,.annotationLayer .textWidgetAnnotation :is(input,textarea):required{outline:1.5px solid selectedItem}.annotationLayer .linkAnnotation{outline:var(--link-outline)}:is(.annotationLayer .linkAnnotation):hover{-webkit-backdrop-filter:var(--hcm-highlight-filter);backdrop-filter:var(--hcm-highlight-filter)}:is(.annotationLayer .linkAnnotation)>a:hover{background:none!important;box-shadow:none;opacity:0!important}.annotationLayer .popupAnnotation .popup{background-color:ButtonFace!important;color:ButtonText!important;outline:calc(1.5px*var(--scale-factor)) solid CanvasText!important}.annotationLayer .highlightArea:hover:after{-webkit-backdrop-filter:var(--hcm-highlight-filter);backdrop-filter:var(--hcm-highlight-filter);content:"";height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%}.annotationLayer .popupAnnotation.focused .popup{outline:calc(3px*var(--scale-factor)) solid Highlight!important}}.annotationLayer{left:0;pointer-events:none;position:absolute;top:0;transform-origin:0 0}.annotationLayer[data-main-rotation="90"] .norotate{transform:rotate(270deg) translateX(-100%)}.annotationLayer[data-main-rotation="180"] .norotate{transform:rotate(180deg) translate(-100%,-100%)}.annotationLayer[data-main-rotation="270"] .norotate{transform:rotate(90deg) translateY(-100%)}.annotationLayer.disabled .popup,.annotationLayer.disabled section{pointer-events:none}.annotationLayer .annotationContent{height:100%;pointer-events:none;position:absolute;width:100%}.freetext:is(.annotationLayer .annotationContent){background:#0000;border:none;font:10px sans-serif;inset:0;line-height:1.35;overflow:visible;-webkit-user-select:none;-moz-user-select:none;user-select:none;white-space:nowrap}.annotationLayer section{box-sizing:border-box;pointer-events:auto;position:absolute;text-align:initial;transform-origin:0 0}:is(.annotationLayer section):has(div.annotationContent) canvas.annotationContent{display:none}.textLayer.selecting~.annotationLayer section{pointer-events:none}.annotationLayer :is(.linkAnnotation,.buttonWidgetAnnotation.pushButton)>a{font-size:1em;height:100%;left:0;position:absolute;top:0;width:100%}.annotationLayer :is(.linkAnnotation,.buttonWidgetAnnotation.pushButton):not(.hasBorder)>a:hover{background-color:#ff0;box-shadow:0 2px 10px #ff0;opacity:.2}.annotationLayer .linkAnnotation.hasBorder:hover{background-color:#ff03}.annotationLayer .hasBorder{background-size:100% 100%}.annotationLayer .textAnnotation img{cursor:pointer;height:100%;left:0;position:absolute;top:0;width:100%}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input,.annotationLayer .choiceWidgetAnnotation select,.annotationLayer .textWidgetAnnotation :is(input,textarea){background-image:var(--annotation-unfocused-field-background);border:2px solid var(--input-unfocused-border-color);box-sizing:border-box;font:calc(9px*var(--scale-factor)) sans-serif;height:100%;margin:0;vertical-align:top;width:100%}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input:required,.annotationLayer .choiceWidgetAnnotation select:required,.annotationLayer .textWidgetAnnotation :is(input,textarea):required{outline:1.5px solid red}.annotationLayer .choiceWidgetAnnotation select option{padding:0}.annotationLayer .buttonWidgetAnnotation.radioButton input{border-radius:50%}.annotationLayer .textWidgetAnnotation textarea{resize:none}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input[disabled],.annotationLayer .choiceWidgetAnnotation select[disabled],.annotationLayer .textWidgetAnnotation [disabled]:is(input,textarea){background:none;border:2px solid var(--input-disabled-border-color);cursor:not-allowed}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input:hover,.annotationLayer .choiceWidgetAnnotation select:hover,.annotationLayer .textWidgetAnnotation :is(input,textarea):hover{border:2px solid var(--input-hover-border-color)}.annotationLayer .buttonWidgetAnnotation.checkBox input:hover,.annotationLayer .choiceWidgetAnnotation select:hover,.annotationLayer .textWidgetAnnotation :is(input,textarea):hover{border-radius:2px}.annotationLayer .choiceWidgetAnnotation select:focus,.annotationLayer .textWidgetAnnotation :is(input,textarea):focus{background:none;border:2px solid var(--input-focus-border-color);border-radius:2px;outline:var(--input-focus-outline)}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) :focus{background-color:initial;background-image:none}.annotationLayer .buttonWidgetAnnotation.checkBox :focus{border:2px solid var(--input-focus-border-color);border-radius:2px;outline:var(--input-focus-outline)}.annotationLayer .buttonWidgetAnnotation.radioButton :focus{border:2px solid var(--input-focus-border-color);outline:var(--input-focus-outline)}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after,.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before,.annotationLayer .buttonWidgetAnnotation.radioButton input:checked:before{background-color:CanvasText;content:"";display:block;position:absolute}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after,.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before{height:80%;left:45%;width:1px}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before{transform:rotate(45deg)}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after{transform:rotate(-45deg)}.annotationLayer .buttonWidgetAnnotation.radioButton input:checked:before{border-radius:50%;height:50%;left:25%;top:25%;width:50%}.annotationLayer .textWidgetAnnotation input.comb{font-family:monospace;padding-left:2px;padding-right:0}.annotationLayer .textWidgetAnnotation input.comb:focus{width:103%}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input{-webkit-appearance:none;-moz-appearance:none;appearance:none}.annotationLayer .fileAttachmentAnnotation .popupTriggerArea{height:100%;width:100%}.annotationLayer .popupAnnotation{font-size:calc(9px*var(--scale-factor));height:auto;max-width:45%;pointer-events:none;position:absolute;width:-moz-max-content;width:max-content}.annotationLayer .popup{word-wrap:break-word;background-color:#ff9;border-radius:calc(2px*var(--scale-factor));box-shadow:0 calc(2px*var(--scale-factor)) calc(5px*var(--scale-factor)) #888;cursor:pointer;font:message-box;outline:1.5px solid #ffff4a;padding:calc(6px*var(--scale-factor));pointer-events:auto;white-space:normal}.annotationLayer .popupAnnotation.focused .popup{outline-width:3px}.annotationLayer .popup *{font-size:calc(9px*var(--scale-factor))}.annotationLayer .popup>.header{display:inline-block}.annotationLayer .popup>.header h1{display:inline}.annotationLayer .popup>.header .popupDate{display:inline-block;margin-left:calc(5px*var(--scale-factor));width:-moz-fit-content;width:fit-content}.annotationLayer .popupContent{border-top:1px solid #333;margin-top:calc(2px*var(--scale-factor));padding-top:calc(2px*var(--scale-factor))}.annotationLayer .richText>*{font-size:calc(9px*var(--scale-factor));white-space:pre-wrap}.annotationLayer .popupTriggerArea{cursor:pointer}.annotationLayer section svg{height:100%;left:0;position:absolute;top:0;width:100%}.annotationLayer .annotationTextContent{color:#0000;height:100%;opacity:0;pointer-events:none;position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100%}:is(.annotationLayer .annotationTextContent) span{display:inline-block;width:100%}.annotationLayer svg.quadrilateralsContainer{contain:strict;height:0;left:0;position:absolute;top:0;width:0;z-index:-1}:root{--xfa-unfocused-field-background:url(\'data:image/svg+xml;charset=utf-8,<svg width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%" style="fill:rgba(0,54,255,.13)"/></svg>\');--xfa-focus-outline:auto}@media screen and (forced-colors:active){:root{--xfa-focus-outline:2px solid CanvasText}.xfaLayer :required{outline:1.5px solid selectedItem}}.xfaLayer{background-color:initial}.xfaLayer .highlight{background-color:#efcbed;border-radius:4px;margin:-1px;padding:1px}.xfaLayer .highlight.appended{position:static}.xfaLayer .highlight.begin{border-radius:4px 0 0 4px}.xfaLayer .highlight.end{border-radius:0 4px 4px 0}.xfaLayer .highlight.middle{border-radius:0}.xfaLayer .highlight.selected{background-color:#cbdfcb}.xfaPage{overflow:hidden;position:relative}.xfaContentarea{position:absolute}.xfaPrintOnly{display:none}.xfaLayer{left:0;line-height:1.2;position:absolute;text-align:initial;top:0;transform-origin:0 0}.xfaLayer *{background-color:initial;box-sizing:border-box;color:inherit;font:inherit;font-kerning:inherit;font-style:inherit;font-weight:inherit;letter-spacing:-.01px;line-height:inherit;margin:0;padding:0;pointer-events:auto;text-align:inherit;text-decoration:inherit}.xfaLayer :required{outline:1.5px solid red}.xfaLayer div,.xfaLayer svg,.xfaLayer svg *{pointer-events:none}.xfaLayer a{color:blue}.xfaRich li{margin-left:3em}.xfaFont{color:#000;font-kerning:none;font-size:10px;font-style:normal;font-weight:400;letter-spacing:0;text-decoration:none;vertical-align:0}.xfaCaption{flex:0 0 auto;overflow:hidden}.xfaCaptionForCheckButton{flex:1 1 auto;overflow:hidden}.xfaLabel{height:100%;width:100%}.xfaLeft{flex-direction:row}.xfaLeft,.xfaRight{align-items:center;display:flex}.xfaRight{flex-direction:row-reverse}:is(.xfaLeft,.xfaRight)>:is(.xfaCaption,.xfaCaptionForCheckButton){max-height:100%}.xfaTop{flex-direction:column}.xfaBottom,.xfaTop{align-items:flex-start;display:flex}.xfaBottom{flex-direction:column-reverse}:is(.xfaTop,.xfaBottom)>:is(.xfaCaption,.xfaCaptionForCheckButton){width:100%}.xfaBorder{background-color:initial;pointer-events:none;position:absolute}.xfaWrapped{height:100%;width:100%}:is(.xfaTextfield,.xfaSelect):focus{background-color:initial;background-image:none;outline:var(--xfa-focus-outline);outline-offset:-1px}:is(.xfaCheckbox,.xfaRadio):focus{outline:var(--xfa-focus-outline)}.xfaSelect,.xfaTextfield{background-image:var(--xfa-unfocused-field-background);border:none;flex:1 1 auto;height:100%;resize:none;width:100%}.xfaSelect{padding-inline:2px}:is(.xfaTop,.xfaBottom)>:is(.xfaTextfield,.xfaSelect){flex:0 1 auto}.xfaButton{border:none;cursor:pointer;text-align:center}.xfaButton,.xfaLink{height:100%;width:100%}.xfaLink{left:0;position:absolute;top:0}.xfaCheckbox,.xfaRadio{border:none;flex:0 0 auto;height:100%;width:100%}.xfaRich{white-space:pre-wrap}.xfaImage,.xfaRich{height:100%;width:100%}.xfaImage{-o-object-fit:contain;object-fit:contain;-o-object-position:left top;object-position:left top}.xfaLrTb,.xfaRlTb,.xfaTb{flex-direction:column}.xfaLr,.xfaLrTb,.xfaRlTb,.xfaTb{align-items:stretch;display:flex}.xfaLr{flex-direction:row}.xfaRl{align-items:stretch;display:flex;flex-direction:row-reverse}.xfaTb>div{justify-content:left}.xfaArea,.xfaPosition{position:relative}.xfaValignMiddle{align-items:center;display:flex}.xfaTable{flex-direction:column}.xfaTable,.xfaTable .xfaRow{align-items:stretch;display:flex}.xfaTable .xfaRow{flex-direction:row}.xfaTable .xfaRlRow{align-items:stretch;display:flex;flex:1;flex-direction:row-reverse}.xfaTable .xfaRlRow>div{flex:1}:is(.xfaNonInteractive,.xfaDisabled,.xfaReadOnly) :is(input,textarea){background:initial}@media print{.xfaSelect,.xfaTextfield{background:#0000}.xfaSelect{-webkit-appearance:none;-moz-appearance:none;appearance:none;text-indent:1px;text-overflow:""}}.canvasWrapper svg{transform:none}.moving:is(.canvasWrapper svg){z-index:100000}[data-main-rotation="90"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) mask,[data-main-rotation="90"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) use:not(.clip,.mask){transform:matrix(0,1,-1,0,1,0)}[data-main-rotation="180"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) mask,[data-main-rotation="180"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) use:not(.clip,.mask){transform:matrix(-1,0,0,-1,1,1)}[data-main-rotation="270"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) mask,[data-main-rotation="270"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) use:not(.clip,.mask){transform:matrix(0,-1,1,0,0,1)}.draw:is(.canvasWrapper svg){mix-blend-mode:normal;position:absolute}.draw[data-draw-rotation="90"]:is(.canvasWrapper svg){transform:rotate(90deg)}.draw[data-draw-rotation="180"]:is(.canvasWrapper svg){transform:rotate(180deg)}.draw[data-draw-rotation="270"]:is(.canvasWrapper svg){transform:rotate(270deg)}.highlight:is(.canvasWrapper svg){--blend-mode:multiply}@media screen and (forced-colors:active){.highlight:is(.canvasWrapper svg){--blend-mode:difference}}.highlight:is(.canvasWrapper svg){mix-blend-mode:var(--blend-mode);position:absolute}.highlight:is(.canvasWrapper svg):not(.free){fill-rule:evenodd}.highlightOutline:is(.canvasWrapper svg){fill-rule:evenodd;fill:none;mix-blend-mode:normal;position:absolute}.highlightOutline.hovered:is(.canvasWrapper svg):not(.free):not(.selected){stroke:var(--hover-outline-color);stroke-width:var(--outline-width)}.highlightOutline.selected:is(.canvasWrapper svg):not(.free) .mainOutline{stroke:var(--outline-around-color);stroke-width:calc(var(--outline-width) + var(--outline-around-width)*2)}.highlightOutline.selected:is(.canvasWrapper svg):not(.free) .secondaryOutline{stroke:var(--outline-color);stroke-width:var(--outline-width)}.highlightOutline.free.hovered:is(.canvasWrapper svg):not(.selected){stroke:var(--hover-outline-color);stroke-width:calc(var(--outline-width)*2)}.highlightOutline.free.selected:is(.canvasWrapper svg) .mainOutline{stroke:var(--outline-around-color);stroke-width:calc((var(--outline-width) + var(--outline-around-width))*2)}.highlightOutline.free.selected:is(.canvasWrapper svg) .secondaryOutline{stroke:var(--outline-color);stroke-width:calc(var(--outline-width)*2)}.toggle-button{--button-background-color:#f0f0f4;--button-background-color-hover:#e0e0e6;--button-background-color-active:#cfcfd8;--color-accent-primary:#0060df;--color-accent-primary-hover:#0250bb;--color-accent-primary-active:#054096;--border-interactive-color:#8f8f9d;--border-radius-circle:9999px;--border-width:1px;--size-item-small:16px;--size-item-large:32px;--color-canvas:#fff}@media (prefers-color-scheme:dark){.toggle-button{--button-background-color:color-mix(in srgb,currentColor 7%,#0000);--button-background-color-hover:color-mix(in srgb,currentColor 14%,#0000);--button-background-color-active:color-mix(in srgb,currentColor 21%,#0000);--color-accent-primary:#0df;--color-accent-primary-hover:#80ebff;--color-accent-primary-active:#aaf2ff;--border-interactive-color:#bfbfc9;--color-canvas:#1c1b22}}@media (forced-colors:active){.toggle-button{--color-accent-primary:ButtonText;--color-accent-primary-hover:SelectedItem;--color-accent-primary-active:SelectedItem;--border-interactive-color:ButtonText;--button-background-color:ButtonFace;--border-interactive-color-hover:SelectedItem;--border-interactive-color-active:SelectedItem;--border-interactive-color-disabled:GrayText;--color-canvas:ButtonText}}.toggle-button{--toggle-background-color:var(--button-background-color);--toggle-background-color-hover:var(--button-background-color-hover);--toggle-background-color-active:var(--button-background-color-active);--toggle-background-color-pressed:var(--color-accent-primary);--toggle-background-color-pressed-hover:var(--color-accent-primary-hover);--toggle-background-color-pressed-active:var(--color-accent-primary-active);--toggle-border-color:var(--border-interactive-color);--toggle-border-color-hover:var(--toggle-border-color);--toggle-border-color-active:var(--toggle-border-color);--toggle-border-radius:var(--border-radius-circle);--toggle-border-width:var(--border-width);--toggle-height:var(--size-item-small);--toggle-width:var(--size-item-large);--toggle-dot-background-color:var(--toggle-border-color);--toggle-dot-background-color-hover:var(--toggle-dot-background-color);--toggle-dot-background-color-active:var(--toggle-dot-background-color);--toggle-dot-background-color-on-pressed:var(--color-canvas);--toggle-dot-margin:1px;--toggle-dot-height:calc(var(--toggle-height) - var(--toggle-dot-margin)*2 - var(--toggle-border-width)*2);--toggle-dot-width:var(--toggle-dot-height);--toggle-dot-transform-x:calc(var(--toggle-width) - var(--toggle-dot-margin)*4 - var(--toggle-dot-width));-webkit-appearance:none;-moz-appearance:none;appearance:none;background:var(--toggle-background-color);border:var(--toggle-border-width) solid var(--toggle-border-color);border-radius:var(--toggle-border-radius);box-sizing:border-box;flex-shrink:0;height:var(--toggle-height);margin:0;padding:0;width:var(--toggle-width)}.toggle-button:focus-visible{outline:var(--focus-outline);outline-offset:var(--focus-outline-offset)}.toggle-button:enabled:hover{background:var(--toggle-background-color-hover);border-color:var(--toggle-border-color)}.toggle-button:enabled:active{background:var(--toggle-background-color-active);border-color:var(--toggle-border-color)}.toggle-button[aria-pressed=true]{background:var(--toggle-background-color-pressed);border-color:#0000}.toggle-button[aria-pressed=true]:enabled:hover{background:var(--toggle-background-color-pressed-hover);border-color:#0000}.toggle-button[aria-pressed=true]:enabled:active{background:var(--toggle-background-color-pressed-active);border-color:#0000}.toggle-button:before{background-color:var(--toggle-dot-background-color);border-radius:var(--toggle-border-radius);content:"";display:block;height:var(--toggle-dot-height);margin:var(--toggle-dot-margin);translate:0;width:var(--toggle-dot-width)}.toggle-button[aria-pressed=true]:before{translate:var(--toggle-dot-transform-x)}.toggle-button[aria-pressed=true]:before,.toggle-button[aria-pressed=true]:enabled:active:before,.toggle-button[aria-pressed=true]:enabled:hover:before{background-color:var(--toggle-dot-background-color-on-pressed)}[dir=rtl] .toggle-button[aria-pressed=true]:before{translate:calc(var(--toggle-dot-transform-x)*-1)}@media (prefers-reduced-motion:no-preference){.toggle-button:before{transition:translate .1s}}@media (prefers-contrast){.toggle-button:enabled:hover{border-color:var(--toggle-border-color-hover)}.toggle-button:enabled:active{border-color:var(--toggle-border-color-active)}.toggle-button[aria-pressed=true]:enabled{border-color:var(--toggle-border-color);position:relative}.toggle-button[aria-pressed=true]:enabled:hover,.toggle-button[aria-pressed=true]:enabled:hover:active{border-color:var(--toggle-border-color-hover)}.toggle-button[aria-pressed=true]:enabled:active{background-color:var(--toggle-dot-background-color-active);border-color:var(--toggle-dot-background-color-hover)}.toggle-button:active:before,.toggle-button:hover:before{background-color:var(--toggle-dot-background-color-hover)}}@media (forced-colors){.toggle-button{--toggle-dot-background-color:var(--color-accent-primary);--toggle-dot-background-color-hover:var(--color-accent-primary-hover);--toggle-dot-background-color-active:var(--color-accent-primary-active);--toggle-dot-background-color-on-pressed:var(--button-background-color);--toggle-background-color-disabled:var(--button-background-color-disabled);--toggle-border-color-hover:var(--border-interactive-color-hover);--toggle-border-color-active:var(--border-interactive-color-active);--toggle-border-color-disabled:var(--border-interactive-color-disabled)}.toggle-button[aria-pressed=true]:enabled:after{border:1px solid var(--button-background-color);border-radius:var(--toggle-border-radius);content:"";display:block;height:var(--toggle-height);inset:-2px;position:absolute;width:var(--toggle-width)}.toggle-button[aria-pressed=true]:enabled:active:after{border-color:var(--toggle-border-color-active)}}:root{--outline-width:2px;--outline-color:#0060df;--outline-around-width:1px;--outline-around-color:#f0f0f4;--hover-outline-around-color:var(--outline-around-color);--focus-outline:solid var(--outline-width) var(--outline-color);--unfocus-outline:solid var(--outline-width) #0000;--focus-outline-around:solid var(--outline-around-width) var(--outline-around-color);--hover-outline-color:#8f8f9d;--hover-outline:solid var(--outline-width) var(--hover-outline-color);--hover-outline-around:solid var(--outline-around-width) var(--hover-outline-around-color);--freetext-line-height:1.35;--freetext-padding:2px;--resizer-bg-color:var(--outline-color);--resizer-size:6px;--resizer-shift:calc(0px - (var(--outline-width) + var(--resizer-size))/2 - var(--outline-around-width));--editorFreeText-editing-cursor:text;--editorInk-editing-cursor:url(images/cursor-editorInk.svg) 0 16,pointer;--editorHighlight-editing-cursor:url(images/cursor-editorTextHighlight.svg) 24 24,text;--editorFreeHighlight-editing-cursor:url(images/cursor-editorFreeHighlight.svg) 1 18,pointer;--new-alt-text-warning-image:url(images/altText_warning.svg)}.visuallyHidden{border:0;font-size:0;height:0;left:0;margin:0;overflow:hidden;padding:0;position:absolute;top:0;white-space:nowrap;width:0}.textLayer.highlighting{cursor:var(--editorFreeHighlight-editing-cursor)}.textLayer.highlighting:not(.free) span{cursor:var(--editorHighlight-editing-cursor)}.textLayer.highlighting.free span,[role=img]:is(.textLayer.highlighting:not(.free) span){cursor:var(--editorFreeHighlight-editing-cursor)}:is(#viewerContainer.pdfPresentationMode:fullscreen,.annotationEditorLayer.disabled) .noAltTextBadge{display:none!important}@media (min-resolution:1.1dppx){:root{--editorFreeText-editing-cursor:url(images/cursor-editorFreeText.svg) 0 16,text}}@media screen and (forced-colors:active){:root{--outline-color:CanvasText;--outline-around-color:ButtonFace;--resizer-bg-color:ButtonText;--hover-outline-color:Highlight;--hover-outline-around-color:SelectedItemText}}[data-editor-rotation="90"]{transform:rotate(90deg)}[data-editor-rotation="180"]{transform:rotate(180deg)}[data-editor-rotation="270"]{transform:rotate(270deg)}.annotationEditorLayer{background:#0000;cursor:auto;font-size:calc(100px*var(--scale-factor));inset:0;position:absolute;transform-origin:0 0}.annotationEditorLayer .selectedEditor{z-index:100000!important}.annotationEditorLayer.drawing *{pointer-events:none!important}.annotationEditorLayer.waiting{content:"";cursor:wait;height:100%;inset:0;position:absolute;width:100%}.annotationEditorLayer.disabled{pointer-events:none}.annotationEditorLayer.freetextEditing{cursor:var(--editorFreeText-editing-cursor)}.annotationEditorLayer.inkEditing{cursor:var(--editorInk-editing-cursor)}.annotationEditorLayer .draw{box-sizing:border-box}.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor){background:#0000;border:var(--unfocus-outline);cursor:auto;max-height:100%;max-width:100%;position:absolute;transform-origin:0 0;z-index:1}.draggable.selectedEditor:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor)){cursor:move}.selectedEditor:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor)){border:var(--focus-outline);outline:var(--focus-outline-around)}.selectedEditor:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor)):before{border:var(--focus-outline-around);content:"";inset:0;pointer-events:none;position:absolute}:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor)):hover:not(.selectedEditor){border:var(--hover-outline);outline:var(--hover-outline-around)}:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor)):hover:not(.selectedEditor):before{border:var(--focus-outline-around);content:"";inset:0;position:absolute}:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar{--editor-toolbar-delete-image:url(images/editor-toolbar-delete.svg);--editor-toolbar-bg-color:#f0f0f4;--editor-toolbar-highlight-image:url(images/toolbarButton-editorHighlight.svg);--editor-toolbar-fg-color:#2e2e56;--editor-toolbar-border-color:#8f8f9d;--editor-toolbar-hover-border-color:var(--editor-toolbar-border-color);--editor-toolbar-hover-bg-color:#e0e0e6;--editor-toolbar-hover-fg-color:var(--editor-toolbar-fg-color);--editor-toolbar-hover-outline:none;--editor-toolbar-focus-outline-color:#0060df;--editor-toolbar-shadow:0 2px 6px 0 #3a394433;--editor-toolbar-vert-offset:6px;--editor-toolbar-height:28px;--editor-toolbar-padding:2px;--alt-text-done-color:#2ac3a2;--alt-text-warning-color:#0090ed;--alt-text-hover-done-color:var(--alt-text-done-color);--alt-text-hover-warning-color:var(--alt-text-warning-color)}@media (prefers-color-scheme:dark){:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar{--editor-toolbar-bg-color:#2b2a33;--editor-toolbar-fg-color:#fbfbfe;--editor-toolbar-hover-bg-color:#52525e;--editor-toolbar-focus-outline-color:#0df;--alt-text-done-color:#54ffbd;--alt-text-warning-color:#80ebff}}@media screen and (forced-colors:active){:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar{--editor-toolbar-bg-color:ButtonFace;--editor-toolbar-fg-color:ButtonText;--editor-toolbar-border-color:ButtonText;--editor-toolbar-hover-border-color:AccentColor;--editor-toolbar-hover-bg-color:ButtonFace;--editor-toolbar-hover-fg-color:AccentColor;--editor-toolbar-hover-outline:2px solid var(--editor-toolbar-hover-border-color);--editor-toolbar-focus-outline-color:ButtonBorder;--editor-toolbar-shadow:none;--alt-text-done-color:var(--editor-toolbar-fg-color);--alt-text-warning-color:var(--editor-toolbar-fg-color);--alt-text-hover-done-color:var(--editor-toolbar-hover-fg-color);--alt-text-hover-warning-color:var(--editor-toolbar-hover-fg-color)}}:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar{align-items:center;background-color:var(--editor-toolbar-bg-color);border:1px solid var(--editor-toolbar-border-color);border-radius:6px;box-shadow:var(--editor-toolbar-shadow);box-sizing:initial;cursor:default;display:flex;flex-direction:column;height:var(--editor-toolbar-height);inset-block-start:calc(100% + var(--editor-toolbar-vert-offset));inset-inline-end:0;justify-content:center;padding:var(--editor-toolbar-padding);pointer-events:auto;position:absolute;width:-moz-fit-content;width:fit-content}.hidden:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar){display:none}:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar):has(:focus-visible){border-color:#0000}[dir=ltr] :is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar){transform-origin:100% 0}[dir=rtl] :is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar){transform-origin:0 0}:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons{align-items:center;display:flex;gap:0;height:100%;justify-content:center}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) button{padding:0}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .divider{border-left:1px solid var(--editor-toolbar-border-color);border-right:none;display:inline-block;height:calc(var(--editor-toolbar-padding)*2 + var(--editor-toolbar-height));margin-inline:2px;width:0}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .highlightButton{width:var(--editor-toolbar-height)}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .highlightButton):before{background-color:var(--editor-toolbar-fg-color);content:"";display:inline-block;height:100%;-webkit-mask-image:var(--editor-toolbar-highlight-image);mask-image:var(--editor-toolbar-highlight-image);-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;width:100%}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .highlightButton):hover:before{background-color:var(--editor-toolbar-hover-fg-color)}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .delete{width:var(--editor-toolbar-height)}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .delete):before{background-color:var(--editor-toolbar-fg-color);content:"";display:inline-block;height:100%;-webkit-mask-image:var(--editor-toolbar-delete-image);mask-image:var(--editor-toolbar-delete-image);-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;width:100%}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .delete):hover:before{background-color:var(--editor-toolbar-hover-fg-color)}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons)>*{height:var(--editor-toolbar-height)}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons)>:not(.divider){background-color:initial;border:none;cursor:pointer}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons)>:not(.divider)):hover{background-color:var(--editor-toolbar-hover-bg-color);border-radius:2px;color:var(--editor-toolbar-hover-fg-color);outline:var(--editor-toolbar-hover-outline);outline-offset:1px}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons)>:not(.divider)):hover:active{outline:none}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons)>:not(.divider)):focus-visible{border-radius:2px;outline:2px solid var(--editor-toolbar-focus-outline-color)}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText{--alt-text-add-image:url(images/altText_add.svg);--alt-text-done-image:url(images/altText_done.svg);align-items:center;color:var(--editor-toolbar-fg-color);display:flex;font:menu;font-size:12px;font-weight:590;justify-content:center;padding-inline:8px;pointer-events:all;width:-moz-max-content;width:max-content}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):disabled{pointer-events:none}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):before{background-color:var(--editor-toolbar-fg-color);content:"";display:inline-block;height:13px;margin-inline-end:4px;-webkit-mask-image:var(--alt-text-add-image);mask-image:var(--alt-text-add-image);-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;width:12px}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):hover:before{background-color:var(--editor-toolbar-hover-fg-color)}.done:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):before{-webkit-mask-image:var(--alt-text-done-image);mask-image:var(--alt-text-done-image)}.new:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):before{background-color:var(--alt-text-warning-color);height:16px;-webkit-mask-image:var(--new-alt-text-warning-image);mask-image:var(--new-alt-text-warning-image);-webkit-mask-size:cover;mask-size:cover;width:16px}.new:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):hover:before{background-color:var(--alt-text-hover-warning-color)}.new.done:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):before{background-color:var(--alt-text-done-color);-webkit-mask-image:var(--alt-text-done-image);mask-image:var(--alt-text-done-image)}.new.done:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):hover:before{background-color:var(--alt-text-hover-done-color)}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText) .tooltip{word-wrap:anywhere;display:none}.show:is(:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText) .tooltip){--alt-text-tooltip-bg:#f0f0f4;--alt-text-tooltip-fg:#15141a;--alt-text-tooltip-border:#8f8f9d;--alt-text-tooltip-shadow:0px 2px 6px 0px #3a394433}@media (prefers-color-scheme:dark){.show:is(:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText) .tooltip){--alt-text-tooltip-bg:#1c1b22;--alt-text-tooltip-fg:#fbfbfe;--alt-text-tooltip-shadow:0px 2px 6px 0px #15141a}}@media screen and (forced-colors:active){.show:is(:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText) .tooltip){--alt-text-tooltip-bg:Canvas;--alt-text-tooltip-fg:CanvasText;--alt-text-tooltip-border:CanvasText;--alt-text-tooltip-shadow:none}}.show:is(:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText) .tooltip){align-items:center;background:var(--alt-text-tooltip-bg);border:.5px solid var(--alt-text-tooltip-border);box-shadow:var(--alt-text-tooltip-shadow);color:var(--alt-text-tooltip-fg);display:inline-flex;flex-direction:column;font-size:12px;height:auto;inset-inline-start:0;justify-content:center;max-width:300px;padding-block:2px 3px;padding-inline:3px;pointer-events:none;position:absolute;top:calc(100% + 2px);width:-moz-max-content;width:max-content}.annotationEditorLayer .freeTextEditor{height:auto;padding:calc(var(--freetext-padding)*var(--scale-factor));touch-action:none;width:auto}.annotationEditorLayer .freeTextEditor .internal{background:#0000;border:none;font:10px sans-serif;inset:0;line-height:var(--freetext-line-height);overflow:visible;-webkit-user-select:none;-moz-user-select:none;user-select:none;white-space:nowrap}.annotationEditorLayer .freeTextEditor .overlay{background:#0000;display:none;height:100%;inset:0;position:absolute;width:100%}.annotationEditorLayer freeTextEditor .overlay.enabled{display:block}.annotationEditorLayer .freeTextEditor .internal:empty:before{color:gray;content:attr(default-content)}.annotationEditorLayer .freeTextEditor .internal:focus{outline:none;-webkit-user-select:auto;-moz-user-select:auto;user-select:auto}.annotationEditorLayer .inkEditor{height:100%;width:100%}.annotationEditorLayer .inkEditor.editing{cursor:inherit}.annotationEditorLayer .inkEditor .inkEditorCanvas{height:100%;inset:0;position:absolute;touch-action:none;width:100%}.annotationEditorLayer .stampEditor{height:auto;width:auto}:is(.annotationEditorLayer .stampEditor) canvas{height:100%;left:0;margin:0;position:absolute;top:0;width:100%}:is(.annotationEditorLayer .stampEditor) .noAltTextBadge{--no-alt-text-badge-border-color:#f0f0f4;--no-alt-text-badge-bg-color:#cfcfd8;--no-alt-text-badge-fg-color:#5b5b66}@media (prefers-color-scheme:dark){:is(.annotationEditorLayer .stampEditor) .noAltTextBadge{--no-alt-text-badge-border-color:#52525e;--no-alt-text-badge-bg-color:#fbfbfe;--no-alt-text-badge-fg-color:#15141a}}@media screen and (forced-colors:active){:is(.annotationEditorLayer .stampEditor) .noAltTextBadge{--no-alt-text-badge-border-color:ButtonText;--no-alt-text-badge-bg-color:ButtonFace;--no-alt-text-badge-fg-color:ButtonText}}:is(.annotationEditorLayer .stampEditor) .noAltTextBadge{align-items:center;background:var(--no-alt-text-badge-bg-color);border:1px solid var(--no-alt-text-badge-border-color);border-radius:2px;display:inline-flex;height:32px;inset-block-end:5px;inset-inline-end:5px;justify-content:center;padding:3px;pointer-events:none;position:absolute;width:32px;z-index:1}:is(:is(.annotationEditorLayer .stampEditor) .noAltTextBadge):before{background-color:var(--no-alt-text-badge-fg-color);content:"";display:inline-block;height:16px;-webkit-mask-image:var(--new-alt-text-warning-image);mask-image:var(--new-alt-text-warning-image);-webkit-mask-size:cover;mask-size:cover;width:16px}:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers{inset:0;position:absolute}.hidden:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers){display:none}:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer{background:content-box var(--resizer-bg-color);border:var(--focus-outline-around);border-radius:2px;height:var(--resizer-size);position:absolute;width:var(--resizer-size)}.topLeft:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){left:var(--resizer-shift);top:var(--resizer-shift)}.topMiddle:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){left:calc(50% + var(--resizer-shift));top:var(--resizer-shift)}.topRight:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){right:var(--resizer-shift);top:var(--resizer-shift)}.middleRight:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){right:var(--resizer-shift);top:calc(50% + var(--resizer-shift))}.bottomRight:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){bottom:var(--resizer-shift);right:var(--resizer-shift)}.bottomMiddle:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){bottom:var(--resizer-shift);left:calc(50% + var(--resizer-shift))}.bottomLeft:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){bottom:var(--resizer-shift);left:var(--resizer-shift)}.middleLeft:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){left:var(--resizer-shift);top:calc(50% + var(--resizer-shift))}.bottomRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer),.topLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer){cursor:nwse-resize}.bottomMiddle:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer),.topMiddle:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer){cursor:ns-resize}.bottomLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer),.topRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer){cursor:nesw-resize}.middleLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer),.middleRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer){cursor:ew-resize}.bottomRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer),.topLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer){cursor:nesw-resize}.bottomMiddle:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer),.topMiddle:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer){cursor:ew-resize}.bottomLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer),.topRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer){cursor:nwse-resize}.middleLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer),.middleRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer){cursor:ns-resize}:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="90"],[data-main-rotation="90"] [data-editor-rotation="0"],[data-main-rotation="180"] [data-editor-rotation="270"],[data-main-rotation="270"] [data-editor-rotation="180"])) .editToolbar{rotate:270deg}[dir=ltr] :is(:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="90"],[data-main-rotation="90"] [data-editor-rotation="0"],[data-main-rotation="180"] [data-editor-rotation="270"],[data-main-rotation="270"] [data-editor-rotation="180"])) .editToolbar){inset-block-start:0;inset-inline-end:calc(0px - var(--editor-toolbar-vert-offset))}[dir=rtl] :is(:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="90"],[data-main-rotation="90"] [data-editor-rotation="0"],[data-main-rotation="180"] [data-editor-rotation="270"],[data-main-rotation="270"] [data-editor-rotation="180"])) .editToolbar){inset-block-start:0;inset-inline-end:calc(100% + var(--editor-toolbar-vert-offset))}:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="180"],[data-main-rotation="90"] [data-editor-rotation="90"],[data-main-rotation="180"] [data-editor-rotation="0"],[data-main-rotation="270"] [data-editor-rotation="270"])) .editToolbar{inset-block-start:calc(0pc - var(--editor-toolbar-vert-offset));inset-inline-end:100%;rotate:180deg}:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="270"],[data-main-rotation="90"] [data-editor-rotation="180"],[data-main-rotation="180"] [data-editor-rotation="90"],[data-main-rotation="270"] [data-editor-rotation="0"])) .editToolbar{rotate:90deg}[dir=ltr] :is(:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="270"],[data-main-rotation="90"] [data-editor-rotation="180"],[data-main-rotation="180"] [data-editor-rotation="90"],[data-main-rotation="270"] [data-editor-rotation="0"])) .editToolbar){inset-block-start:100%;inset-inline-end:calc(100% + var(--editor-toolbar-vert-offset))}[dir=rtl] :is(:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="270"],[data-main-rotation="90"] [data-editor-rotation="180"],[data-main-rotation="180"] [data-editor-rotation="90"],[data-main-rotation="270"] [data-editor-rotation="0"])) .editToolbar){inset-block-start:0;inset-inline-start:calc(0px - var(--editor-toolbar-vert-offset))}.dialog.altText::backdrop{-webkit-mask:url(#alttext-manager-mask);mask:url(#alttext-manager-mask)}.dialog.altText.positioned{margin:0}.dialog.altText #altTextContainer{align-items:flex-start;display:inline-flex;flex-direction:column;gap:16px;height:-moz-fit-content;height:fit-content;width:300px}:is(.dialog.altText #altTextContainer) #overallDescription{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:4px}:is(:is(.dialog.altText #altTextContainer) #overallDescription) span{align-self:stretch}:is(:is(.dialog.altText #altTextContainer) #overallDescription) .title{font-size:13px;font-style:normal;font-weight:590}:is(.dialog.altText #altTextContainer) #addDescription{align-items:stretch;display:flex;flex-direction:column;gap:8px}:is(:is(.dialog.altText #altTextContainer) #addDescription) .descriptionArea{flex:1;padding-inline:24px 10px}:is(:is(:is(.dialog.altText #altTextContainer) #addDescription) .descriptionArea) textarea{min-height:75px;width:100%}:is(.dialog.altText #altTextContainer) #buttons{align-items:flex-start;align-self:stretch;display:flex;gap:8px;justify-content:flex-end}.dialog.newAltText{--new-alt-text-ai-disclaimer-icon:url(images/altText_disclaimer.svg);--new-alt-text-spinner-icon:url(images/altText_spinner.svg);--preview-image-bg-color:#f0f0f4;--preview-image-border:none}@media (prefers-color-scheme:dark){.dialog.newAltText{--preview-image-bg-color:#2b2a33}}@media screen and (forced-colors:active){.dialog.newAltText{--preview-image-bg-color:ButtonFace;--preview-image-border:1px solid ButtonText}}.dialog.newAltText{max-width:570px;min-width:300px;padding:0;width:80%}.dialog.newAltText.aiInstalling #newAltTextCreateAutomatically,.dialog.newAltText.noAi #newAltTextCreateAutomatically,.dialog.newAltText.noAi #newAltTextDisclaimer{display:none!important}.dialog.newAltText.aiInstalling #newAltTextDownloadModel{display:flex!important}.dialog.newAltText.error #newAltTextNotNow{display:none!important}.dialog.newAltText.error #newAltTextCancel{display:inline-block!important}.dialog.newAltText:not(.error) #newAltTextError{display:none!important}.dialog.newAltText #newAltTextContainer{align-items:flex-start;display:flex;flex:0 1 auto;flex-direction:column;gap:12px;justify-content:flex-end;line-height:normal;padding:16px;width:auto}:is(.dialog.newAltText #newAltTextContainer) #mainContent{align-items:flex-start;align-self:stretch;display:flex;flex:1 1 auto;gap:12px;justify-content:flex-end}:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionAndSettings{align-items:flex-start;align-self:stretch;display:flex;flex:1 0 0;flex-direction:column;gap:16px}:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction{align-items:flex-start;align-self:stretch;display:flex;flex:1 1 auto;flex-direction:column;gap:8px}:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer{height:70px;position:relative;width:100%}:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) textarea{height:100%;padding:8px;width:100%}:is(:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) textarea)::-moz-placeholder{color:var(--text-secondary-color)}:is(:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) textarea)::placeholder{color:var(--text-secondary-color)}:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) .altTextSpinner{background-color:var(--text-secondary-color);display:none;height:16px;inset-block-start:8px;inset-inline-start:8px;-webkit-mask-size:cover;mask-size:cover;pointer-events:none;position:absolute;width:16px}.loading:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) textarea::-moz-placeholder{color:#0000}.loading:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) textarea::placeholder{color:#0000}.loading:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) .altTextSpinner{display:inline-block;-webkit-mask-image:var(--new-alt-text-spinner-icon);mask-image:var(--new-alt-text-spinner-icon)}:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescription{font-size:11px}:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDisclaimer{align-items:flex-start;display:flex;flex-direction:row;font-size:11px;gap:4px}:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDisclaimer):before{background-color:var(--text-secondary-color);content:"";display:inline-block;flex:1 0 auto;height:16px;-webkit-mask-image:var(--new-alt-text-ai-disclaimer-icon);mask-image:var(--new-alt-text-ai-disclaimer-icon);-webkit-mask-size:cover;mask-size:cover;width:17px}:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #newAltTextDownloadModel{align-items:center;align-self:stretch;display:flex;gap:4px}:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #newAltTextDownloadModel):before{background-color:var(--text-secondary-color);content:"";display:inline-block;height:16px;-webkit-mask-image:var(--new-alt-text-spinner-icon);mask-image:var(--new-alt-text-spinner-icon);-webkit-mask-size:cover;mask-size:cover;width:16px}:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #newAltTextImagePreview{align-items:center;aspect-ratio:1;background-color:var(--preview-image-bg-color);border:var(--preview-image-border);display:flex;flex:0 0 auto;justify-content:center;width:180px}:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #newAltTextImagePreview)>canvas{max-height:100%;max-width:100%}.colorPicker{--hover-outline-color:#0250bb;--selected-outline-color:#0060df;--swatch-border-color:#cfcfd8}@media (prefers-color-scheme:dark){.colorPicker{--hover-outline-color:#80ebff;--selected-outline-color:#aaf2ff;--swatch-border-color:#52525e}}@media screen and (forced-colors:active){.colorPicker{--hover-outline-color:Highlight;--selected-outline-color:var(--hover-outline-color);--swatch-border-color:ButtonText}}.colorPicker .swatch{border:1px solid var(--swatch-border-color);border-radius:100%;box-sizing:border-box;forced-color-adjust:none;height:16px;outline-offset:2px;width:16px}.colorPicker button:is(:hover,.selected)>.swatch{border:none}.annotationEditorLayer[data-main-rotation="0"] .highlightEditor:not(.free)>.editToolbar{rotate:0deg}.annotationEditorLayer[data-main-rotation="90"] .highlightEditor:not(.free)>.editToolbar{rotate:270deg}.annotationEditorLayer[data-main-rotation="180"] .highlightEditor:not(.free)>.editToolbar{rotate:180deg}.annotationEditorLayer[data-main-rotation="270"] .highlightEditor:not(.free)>.editToolbar{rotate:90deg}.annotationEditorLayer .highlightEditor{background:#0000;border:none;cursor:auto;max-height:100%;max-width:100%;outline:none;pointer-events:none;position:absolute;transform-origin:0 0;z-index:1}:is(.annotationEditorLayer .highlightEditor):not(.free){transform:none}:is(.annotationEditorLayer .highlightEditor) .internal{height:100%;left:0;pointer-events:auto;position:absolute;top:0;width:100%}.disabled:is(.annotationEditorLayer .highlightEditor) .internal{pointer-events:none}.selectedEditor:is(.annotationEditorLayer .highlightEditor) .internal{cursor:pointer}:is(.annotationEditorLayer .highlightEditor) .editToolbar{--editor-toolbar-colorpicker-arrow-image:url(images/toolbarButton-menuArrow.svg);transform-origin:center!important}:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker{align-items:center;display:flex;gap:4px;justify-content:center;padding:4px;position:relative;width:auto}:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker):after{background-color:var(--editor-toolbar-fg-color);content:"";display:inline-block;height:12px;-webkit-mask-image:var(--editor-toolbar-colorpicker-arrow-image);mask-image:var(--editor-toolbar-colorpicker-arrow-image);-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;width:12px}:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker):hover:after{background-color:var(--editor-toolbar-hover-fg-color)}:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker):has(.dropdown:not(.hidden)){background-color:var(--editor-toolbar-hover-bg-color)}:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker):has(.dropdown:not(.hidden)):after{scale:-1}:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown{align-items:center;background-color:var(--editor-toolbar-bg-color);border:1px solid var(--editor-toolbar-border-color);border-radius:6px;box-shadow:var(--editor-toolbar-shadow);display:flex;flex-direction:column;gap:11px;inset-block-start:calc(100% + 4px);justify-content:center;padding-block:8px;position:absolute;width:calc(100% + var(--editor-toolbar-padding)*2)}:is(:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown) button{align-items:center;background:none;border:none;cursor:pointer;display:flex;height:auto;justify-content:center;width:100%}:is(:is(:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown) button):is(:active,:focus-visible){outline:none}:is(:is(:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown) button)>.swatch{outline-offset:2px}[aria-selected=true]:is(:is(:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown) button)>.swatch{outline:2px solid var(--selected-outline-color)}:is(:is(:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown) button):is(:hover,:active,:focus-visible)>.swatch{outline:2px solid var(--hover-outline-color)}.editorParamsToolbar:has(#highlightParamsToolbarContainer){padding:unset}#highlightParamsToolbarContainer{gap:16px;padding-block-end:12px;padding-inline:10px}#highlightParamsToolbarContainer .colorPicker{display:flex;flex-direction:column;gap:8px}:is(#highlightParamsToolbarContainer .colorPicker) .dropdown{align-items:center;display:flex;flex-direction:row;height:auto;justify-content:space-between}:is(:is(#highlightParamsToolbarContainer .colorPicker) .dropdown) button{align-items:center;background:none;border:none;cursor:pointer;display:flex;flex:0 0 auto;height:auto;justify-content:center;padding:0;width:auto}:is(:is(:is(#highlightParamsToolbarContainer .colorPicker) .dropdown) button) .swatch{height:24px;width:24px}:is(:is(:is(#highlightParamsToolbarContainer .colorPicker) .dropdown) button):is(:active,:focus-visible){outline:none}[aria-selected=true]:is(:is(:is(#highlightParamsToolbarContainer .colorPicker) .dropdown) button)>.swatch{outline:2px solid var(--selected-outline-color)}:is(:is(:is(#highlightParamsToolbarContainer .colorPicker) .dropdown) button):is(:hover,:active,:focus-visible)>.swatch{outline:2px solid var(--hover-outline-color)}#highlightParamsToolbarContainer #editorHighlightThickness{align-items:center;align-self:stretch;display:flex;flex-direction:column;gap:4px}:is(#highlightParamsToolbarContainer #editorHighlightThickness) .editorParamsLabel{align-self:stretch;height:auto}:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker{--example-color:#bfbfc9;align-items:center;align-self:stretch;display:flex;justify-content:space-between}@media (prefers-color-scheme:dark){:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker{--example-color:#80808e}}@media screen and (forced-colors:active){:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker{--example-color:CanvasText}}:is(:is(:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker)>.editorParamsSlider[disabled]){opacity:.4}:is(:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker):after,:is(:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker):before{aspect-ratio:1;background-color:var(--example-color);border-radius:100%;content:"";display:block;width:8px}:is(:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker):after{width:24px}:is(:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker) .editorParamsSlider{height:14px;width:unset}#highlightParamsToolbarContainer #editorHighlightVisibility{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:8px}:is(#highlightParamsToolbarContainer #editorHighlightVisibility) .divider{--divider-color:#d7d7db}@media (prefers-color-scheme:dark){:is(#highlightParamsToolbarContainer #editorHighlightVisibility) .divider{--divider-color:#8f8f9d}}@media screen and (forced-colors:active){:is(#highlightParamsToolbarContainer #editorHighlightVisibility) .divider{--divider-color:CanvasText}}:is(#highlightParamsToolbarContainer #editorHighlightVisibility) .divider{background-color:var(--divider-color);height:1px;margin-block:4px;width:100%}:is(#highlightParamsToolbarContainer #editorHighlightVisibility) .toggler{align-items:center;align-self:stretch;display:flex;justify-content:space-between}#altTextSettingsDialog{padding:16px}#altTextSettingsDialog #altTextSettingsContainer{display:flex;flex-direction:column;gap:16px;width:573px}:is(#altTextSettingsDialog #altTextSettingsContainer) .mainContainer{gap:16px}:is(#altTextSettingsDialog #altTextSettingsContainer) .description{color:var(--text-secondary-color)}:is(#altTextSettingsDialog #altTextSettingsContainer) #aiModelSettings{display:flex;flex-direction:column;gap:12px}:is(:is(#altTextSettingsDialog #altTextSettingsContainer) #aiModelSettings) button{width:-moz-fit-content;width:fit-content}.download:is(:is(#altTextSettingsDialog #altTextSettingsContainer) #aiModelSettings) #deleteModelButton,:is(:is(#altTextSettingsDialog #altTextSettingsContainer) #aiModelSettings):not(.download) #downloadModelButton{display:none}:is(#altTextSettingsDialog #altTextSettingsContainer) #altTextEditor,:is(#altTextSettingsDialog #altTextSettingsContainer) #automaticAltText{display:flex;flex-direction:column;gap:8px}:is(#altTextSettingsDialog #altTextSettingsContainer) #aiModelSettings,:is(#altTextSettingsDialog #altTextSettingsContainer) #createModelDescription,:is(#altTextSettingsDialog #altTextSettingsContainer) #showAltTextDialogDescription{padding-inline-start:40px}:is(#altTextSettingsDialog #altTextSettingsContainer) #automaticSettings{display:flex;flex-direction:column;gap:16px}:root{--viewer-container-height:0;--pdfViewer-padding-bottom:0;--page-margin:1px auto -8px;--page-border:9px solid #0000;--spreadHorizontalWrapped-margin-LR:-3.5px;--loading-icon-delay:400ms}@media screen and (forced-colors:active){:root{--pdfViewer-padding-bottom:9px;--page-margin:8px auto -1px;--page-border:1px solid CanvasText;--spreadHorizontalWrapped-margin-LR:3.5px}}[data-main-rotation="90"]{transform:rotate(90deg) translateY(-100%)}[data-main-rotation="180"]{transform:rotate(180deg) translate(-100%,-100%)}[data-main-rotation="270"]{transform:rotate(270deg) translateX(-100%)}#hiddenCopyElement,.hiddenCanvasElement{display:none;height:0;left:0;position:absolute;top:0;width:0}.pdfViewer{--scale-factor:1;--page-bg-color:unset;--hcm-highlight-filter:none;--hcm-highlight-selected-filter:none;padding-bottom:var(--pdfViewer-padding-bottom)}@media screen and (forced-colors:active){.pdfViewer{--hcm-highlight-filter:invert(100%)}}.pdfViewer.copyAll{cursor:wait}.pdfViewer .canvasWrapper{height:100%;overflow:hidden;width:100%}:is(.pdfViewer .canvasWrapper) canvas{contain:content;display:block;height:100%;left:0;margin:0;position:absolute;top:0;width:100%}:is(:is(.pdfViewer .canvasWrapper) canvas) .structTree{contain:strict}.pdfViewer .page{--scale-round-x:1px;--scale-round-y:1px;background-clip:content-box;background-color:var(--page-bg-color,#fff);border:var(--page-border);direction:ltr;height:1056px;margin:var(--page-margin);overflow:visible;position:relative;width:816px}.pdfViewer .dummyPage{height:var(--viewer-container-height);position:relative;width:0}.pdfViewer.noUserSelect{-webkit-user-select:none;-moz-user-select:none;user-select:none}.pdfViewer.removePageBorders .page{border:none;margin:0 auto 10px}.pdfViewer.singlePageView{display:inline-block}.pdfViewer.singlePageView .page{border:none;margin:0}.pdfViewer:is(.scrollHorizontal,.scrollWrapped),.spread{margin-inline:3.5px;text-align:center}.pdfViewer.scrollHorizontal,.spread{white-space:nowrap}.pdfViewer.removePageBorders,.pdfViewer:is(.scrollHorizontal,.scrollWrapped) .spread{margin-inline:0}.pdfViewer:is(.scrollHorizontal,.scrollWrapped) :is(.page,.spread),.spread :is(.page,.dummyPage){display:inline-block;vertical-align:middle}.pdfViewer:is(.scrollHorizontal,.scrollWrapped) .page,.spread .page{margin-inline:var(--spreadHorizontalWrapped-margin-LR)}.pdfViewer.removePageBorders .spread .page,.pdfViewer.removePageBorders:is(.scrollHorizontal,.scrollWrapped) .page{margin-inline:5px}.pdfViewer .page.loadingIcon:after{background:url(images/loading-icon.gif) 50% no-repeat;contain:strict;content:"";display:none;height:100%;left:0;position:absolute;top:0;transition-delay:var(--loading-icon-delay);transition-property:display;width:100%;z-index:5}.pdfViewer .page.loading:after{display:block}.pdfViewer .page:not(.loading):after{display:none;transition-property:none}.pdfPresentationMode .pdfViewer{padding-bottom:0}.pdfPresentationMode .spread{margin:0}.pdfPresentationMode .pdfViewer .page{border:2px solid #0000;margin:0 auto}');var qle=function(){function e(){}return e.generateUniqueId=function(){var e=Date.now().toString(36),t=Math.random().toString(36).substring(2,8);return"".concat(e,"-").concat(t)},e}(),Gle=Symbol.for("immer-nothing"),Yle=Symbol.for("immer-draftable"),Kle=Symbol.for("immer-state"),Xle="production"!==yt.env.NODE_ENV?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function Qle(e,...t){if("production"!==yt.env.NODE_ENV){const n=Xle[e],a="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${a}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Jle=Object.getPrototypeOf;function Zle(e){return!!e&&!!e[Kle]}function eie(e){return!!e&&(nie(e)||Array.isArray(e)||!!e[Yle]||!!e.constructor?.[Yle]||lie(e)||iie(e))}var tie=Object.prototype.constructor.toString();function nie(e){if(!e||"object"!=typeof e)return!1;const t=Jle(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===tie}function aie(e,t){0===rie(e)?Reflect.ownKeys(e).forEach((n=>{t(n,e[n],e)})):e.forEach(((n,a)=>t(a,n,e)))}function rie(e){const t=e[Kle];return t?t.type_:Array.isArray(e)?1:lie(e)?2:iie(e)?3:0}function oie(e,t){return 2===rie(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function cie(e,t,n){const a=rie(e);2===a?e.set(t,n):3===a?e.add(n):e[t]=n}function lie(e){return e instanceof Map}function iie(e){return e instanceof Set}function sie(e){return e.copy_||e.base_}function hie(e,t){if(lie(e))return new Map(e);if(iie(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=nie(e);if(!0===t||"class_only"===t&&!n){const t=Object.getOwnPropertyDescriptors(e);delete t[Kle];let n=Reflect.ownKeys(t);for(let a=0;a<n.length;a++){const r=n[a],o=t[r];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(t[r]={configurable:!0,writable:!0,enumerable:o.enumerable,value:e[r]})}return Object.create(Jle(e),t)}{const t=Jle(e);if(null!==t&&n)return{...e};const a=Object.create(t);return Object.assign(a,e)}}function die(e,t=!1){return mie(e)||Zle(e)||!eie(e)||(rie(e)>1&&(e.set=e.add=e.clear=e.delete=uie),Object.freeze(e),t&&Object.entries(e).forEach((([e,t])=>die(t,!0)))),e}function uie(){Qle(2)}function mie(e){return Object.isFrozen(e)}var pie,vie={};function fie(e){const t=vie[e];return t||Qle(0,e),t}function zie(){return pie}function gie(e,t){t&&(fie("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function yie(e){Mie(e),e.drafts_.forEach(bie),e.drafts_=null}function Mie(e){e===pie&&(pie=e.parent_)}function Eie(e){return pie={drafts_:[],parent_:pie,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function bie(e){const t=e[Kle];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Hie(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Kle].modified_&&(yie(t),Qle(4)),eie(e)&&(e=Vie(t,e),t.parent_||Lie(t,e)),t.patches_&&fie("Patches").generateReplacementPatches_(n[Kle].base_,e,t.patches_,t.inversePatches_)):e=Vie(t,n,[]),yie(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Gle?e:void 0}function Vie(e,t,n){if(mie(t))return t;const a=t[Kle];if(!a)return aie(t,((r,o)=>Cie(e,a,t,r,o,n))),t;if(a.scope_!==e)return t;if(!a.modified_)return Lie(e,a.base_,!0),a.base_;if(!a.finalized_){a.finalized_=!0,a.scope_.unfinalizedDrafts_--;const t=a.copy_;let r=t,o=!1;3===a.type_&&(r=new Set(t),t.clear(),o=!0),aie(r,((r,c)=>Cie(e,a,t,r,c,n,o))),Lie(e,t,!1),n&&e.patches_&&fie("Patches").generatePatches_(a,n,e.patches_,e.inversePatches_)}return a.copy_}function Cie(e,t,n,a,r,o,c){if("production"!==yt.env.NODE_ENV&&r===n&&Qle(5),Zle(r)){const c=Vie(e,r,o&&t&&3!==t.type_&&!oie(t.assigned_,a)?o.concat(a):void 0);if(cie(n,a,c),!Zle(c))return;e.canAutoFreeze_=!1}else c&&n.add(r);if(eie(r)&&!mie(r)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Vie(e,r),t&&t.scope_.parent_||"symbol"==typeof a||!Object.prototype.propertyIsEnumerable.call(n,a)||Lie(e,r)}}function Lie(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&die(t,n)}var xie={get(e,t){if(t===Kle)return e;const n=sie(e);if(!oie(n,t))return function(e,t,n){const a=wie(t,n);return a?"value"in a?a.value:a.get?.call(e.draft_):void 0}(e,n,t);const a=n[t];return e.finalized_||!eie(a)?a:a===kie(e.base_,t)?(Oie(e),e.copy_[t]=Aie(a,e)):a},has:(e,t)=>t in sie(e),ownKeys:e=>Reflect.ownKeys(sie(e)),set(e,t,n){const a=wie(sie(e),t);if(a?.set)return a.set.call(e.draft_,n),!0;if(!e.modified_){const a=kie(sie(e),t),c=a?.[Kle];if(c&&c.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(((r=n)===(o=a)?0!==r||1/r==1/o:r!=r&&o!=o)&&(void 0!==n||oie(e.base_,t)))return!0;Oie(e),Tie(e)}var r,o;return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==kie(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,Oie(e),Tie(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=sie(e),a=Reflect.getOwnPropertyDescriptor(n,t);return a?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:a.enumerable,value:n[t]}:a},defineProperty(){Qle(11)},getPrototypeOf:e=>Jle(e.base_),setPrototypeOf(){Qle(12)}},Sie={};function kie(e,t){const n=e[Kle];return(n?sie(n):e)[t]}function wie(e,t){if(!(t in e))return;let n=Jle(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Jle(n)}}function Tie(e){e.modified_||(e.modified_=!0,e.parent_&&Tie(e.parent_))}function Oie(e){e.copy_||(e.copy_=hie(e.base_,e.scope_.immer_.useStrictShallowCopy_))}function Aie(e,t){const n=lie(e)?fie("MapSet").proxyMap_(e,t):iie(e)?fie("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),a={type_:n?1:0,scope_:t?t.scope_:zie(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let r=a,o=xie;n&&(r=[a],o=Sie);const{revoke:c,proxy:l}=Proxy.revocable(r,o);return a.draft_=l,a.revoke_=c,l}(e,t);return(t?t.scope_:zie()).drafts_.push(n),n}function Rie(e){if(!eie(e)||mie(e))return e;const t=e[Kle];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=hie(e,t.scope_.immer_.useStrictShallowCopy_)}else n=hie(e,!0);return aie(n,((e,t)=>{cie(n,e,Rie(t))})),t&&(t.finalized_=!1),n}aie(xie,((e,t)=>{Sie[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),Sie.deleteProperty=function(e,t){return"production"!==yt.env.NODE_ENV&&isNaN(parseInt(t))&&Qle(13),Sie.set.call(this,e,t,void 0)},Sie.set=function(e,t,n){return"production"!==yt.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&Qle(14),xie.set.call(this,e[0],t,n,e[0])};var Nie=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const a=this;return function(e=n,...r){return a.produce(e,(e=>t.call(this,e,...r)))}}let a;if("function"!=typeof t&&Qle(6),void 0!==n&&"function"!=typeof n&&Qle(7),eie(e)){const r=Eie(this),o=Aie(e,void 0);let c=!0;try{a=t(o),c=!1}finally{c?yie(r):Mie(r)}return gie(r,n),Hie(a,r)}if(!e||"object"!=typeof e){if(a=t(e),void 0===a&&(a=e),a===Gle&&(a=void 0),this.autoFreeze_&&die(a,!0),n){const t=[],r=[];fie("Patches").generateReplacementPatches_(e,a,t,r),n(t,r)}return a}Qle(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,a;return[this.produce(e,t,((e,t)=>{n=e,a=t})),n,a]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){eie(e)||Qle(8),Zle(e)&&(e=function(e){return Zle(e)||Qle(10,e),Rie(e)}(e));const t=Eie(this),n=Aie(e,void 0);return n[Kle].isManual_=!0,Mie(t),n}finishDraft(e,t){const n=e&&e[Kle];n&&n.isManual_||Qle(9);const{scope_:a}=n;return gie(a,t),Hie(void 0,a)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const a=t[n];if(0===a.path.length&&"replace"===a.op){e=a.value;break}}n>-1&&(t=t.slice(n+1));const a=fie("Patches").applyPatches_;return Zle(e)?a(e,t):this.produce(e,(e=>a(e,t)))}},_ie=Nie.produce;Nie.produceWithPatches.bind(Nie);var Die=Nie.setAutoFreeze.bind(Nie);Nie.setUseStrictShallowCopy.bind(Nie),Nie.applyPatches.bind(Nie),Nie.createDraft.bind(Nie),Nie.finishDraft.bind(Nie);var Pie={isScaleSaveHappening:!1,isAddNewScaleFormPopupOpen:!1,scaleName:"",paperDimension:{unitOfMeasurement:"inch",scalarQuantity:1},displayDimension:{unitOfMeasurement:"inch",scalarQuantity:1},precision:.1,userCalibratingScaleOnPdfPageDetails:{isHappening:!1,coordinates:[]},isCalibrationScaleFormPopupOpen:!1,pdfPageId:""},Fie={scaleId:"",popup:{isOpen:!1},paperDimension:{unitOfMeasurement:"inch",scalarQuantity:0},displayDimension:{unitOfMeasurement:"inch",scalarQuantity:0},scaleName:"",precision:.1,isScaleSaveHappening:!1},Iie=function(){function e(){}return e.getEnvValue=function(e){var t,n=null===(t=null===window||void 0===window?void 0:window._env_)||void 0===t?void 0:t[e];return n&&"default"!==n?n:""},e}(),jie=function(){function e(){}return e.BACKEND_BASE_URL=Iie.getEnvValue("BACKEND_BASE_URL"),e.scalePrecisionOptions=[.1,.01,.001],e.annotationAvalaibleColors=[{color:"#E34234"},{color:"#FF8D02"},{color:"#FFCD44"},{color:"#5BC96D"},{color:"#26D2D2"},{color:"#587CE2"},{color:"#C544CE"},{color:"#7D2E25"},{color:"#A84F1C"},{color:"#E99E38"},{color:"#347842"},{color:"#167E7D"},{color:"#354A87"},{color:"#76287B"},{color:"#000"},{color:"#CDCDCD"},{color:"#9C9C9C"},{color:"#696969"},{color:"#272727"},{color:"#FFFFFF"}],e.pdfPagesElementId="pdf-pages-container",e}(),Bie={isOpen:!1,sections:{color:{collapsedStatus:"collapsed",currentlySelectedColor:jie.annotationAvalaibleColors[0].color},coordinates:{collapsedStatus:"collapsed",shouldHighlightFirstCoordinate:!1,shouldHighlightSecondCoordinate:!1,x1:0,x2:0,y1:0,y2:0}}};Ble.workerSrc="https://unpkg.com/pdfjs-dist@4.10.38/build/pdf.worker.min.mjs",Die(!1);var Uie={options:{showDividerBetweenToolSections:!0,alignmentOfFirstRowToolSections:"space-between"},sections:[[{name:"fullScreen"},{name:"zoomTool"}],[{name:"Annotation",children:[{name:"highlight"},{name:"callout"}]},{name:"Shapes",children:[{name:"rectangle"}]},{name:"Measure",children:[{name:"measureDistance"}]}],[{name:"toggleTextSelectionTool"},{name:"eyeTool"},{name:"comment"}]]};function Wie(e){var a=this,r=n.useState([]),o=r[0],c=r[1],l=n.useState(""),i=l[0],s=l[1],h=n.useState(""),d=h[0],u=h[1],m=n.useState({pdfEditorToolsToShow:e.toolsToShow||Uie,toolsRelatedData:{},measureToolRelatedData:{scaleIdSelected:"",addNewScaleDetails:Pie,editScaleDetails:Fie,distanceAnnotation:{configurationsDrawer:Bie,isFirstPointSelected:!1,isSecondPointSelected:!1}},textHighlightToolRelatedData:{isTextSelectionEnabled:!0,selectedTextToolBoxDetails:{pdfPageId:"",x:0,y:0}}}),p=m[0],v=m[1],f=n.useState(e.currentUserId),z=f[0],g=f[1],y=n.useState([]),M=y[0],E=y[1],b=n.useState([]),H=b[0],V=b[1],C=n.useState(!1),L=C[0],x=C[1],S=n.useState(0),k=S[0],w=S[1],T=n.useState(!1),O=T[0],A=T[1],R=n.useState(!1),N=R[0],_=R[1],D=n.useState(e.areAnnotationsVisibleByDefault),P=D[0],F=D[1],I=n.useState(""),j=I[0],B=I[1],U=n.useState(""),W=U[0],$=U[1],q=e.rectangleAnnotationToolOptions,G=e.backendBaseUrl,Y=e.rlefEventServiceBaseUrl,K=n.useRef(new Tae({backendBaseUrl:G})),X=n.useState(qle.generateUniqueId()),Q=X[0];X[1];var J=n.useState([]),Z=J[0],ee=J[1],te=n.useCallback((function(e){ee((function(t){return Z7(Z7([],t,!0),[e],!1)}))}),[ee]),ne=n.useCallback((function(e,t){return Q7(a,void 0,void 0,(function(){var n,a;return J7(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,3,4]),x(!0),[4,K.current.fetchUsersOfPdf({pdfId:t,userNameSearchKey:e,limit:10,offset:1})];case 1:return(n=r.sent())&&V(n),[3,4];case 2:return a=r.sent(),console.error("Error fetching suggested users: ",a),[3,4];case 3:return x(!1),[7];case 4:return[2]}}))}))}),[]),ae=n.useCallback((function(e){ee((function(t){return Z7([],t.filter((function(t){return t!==e})),!0)}))}),[ee]),re=n.useCallback((function(){return Q7(a,void 0,void 0,(function(){var t,n,a,r,c;return J7(this,(function(l){switch(l.label){case 0:if(!(t=(null===(c=o[0])||void 0===c?void 0:c._id)||""))return[2];l.label=1;case 1:return l.trys.push([1,5,,6]),_(!0),[4,K.current.fetchUsersOfPdf({pdfId:t})];case 2:return(n=l.sent())?-1!==n.findIndex((function(t){return t._id===e.currentUserId}))?[3,4]:[4,K.current.fetchUsersOfPdf({pdfId:t,userIds:[e.currentUserId]})]:[2];case 3:(a=l.sent())&&a.length>0&&n.push(a[0]),l.label=4;case 4:return E(n),[3,6];case 5:return r=l.sent(),console.error("Error fetching users: ",r),[3,6];case 6:return[2]}}))}))}),[o]);n.useEffect((function(){N||re()}),[re,N]);var oe=n.useState([]);oe[0];var ce=oe[1],le=n.useState({isEditingText:!1,annotationId:"",pdfId:"",pdfPageId:"",color:"",points:[],text:""}),ie=le[0],se=le[1],he=n.useCallback((function(e,t){return Q7(a,void 0,void 0,(function(){var n,a,r,o,l,i,s,h,d,u,m,f,z;return J7(this,(function(g){switch(g.label){case 0:return n=(t||{}).pdfSourceUrl,e&&te(e),a={},e&&(a.pdfId=e),n&&(a.pdfSourceUrl=n),r=K.current.fetchOnlyPdfData(X7(X7({},a),{getPdfDownloadUrl:"true"})),o={pdfs:[]},n?[4,r]:[3,6];case 1:return(o=g.sent()).pdfs.length>0?(e=o.pdfs[0]._id,[3,5]):[3,2];case 2:return ce((function(e){return Z7(Z7([],e,!0),[n],!1)})),[4,K.current.insertPdfAndItsPagesInDb({pdfSourceUrl:n,pdfFileName:"sourceUrl.pdf"})];case 3:return l=g.sent(),e=l._id,[4,K.current.fetchOnlyPdfData(X7(X7({},a),{getPdfDownloadUrl:"true"}))];case 4:o=g.sent(),ce((function(e){return Z7([],e.filter((function(e){return e!==n})),!0)})),g.label=5;case 5:return[3,8];case 6:return[4,r];case 7:o=g.sent(),g.label=8;case 8:return i=K.current.fetchOnlyPdfPagesData({pdfId:e,getPdfPageImageDownloadUrl:"true",pdfPageImageUploaded:"true"}),s=K.current.fetchPdfScales({pdfId:e}),[4,i];case 9:return h=g.sent(),[4,s];case 10:return d=g.sent(),!p.measureToolRelatedData.scaleIdSelected&&d.scales.length>0&&v(_ie((function(e){var t;e.measureToolRelatedData.scaleIdSelected=(null===(t=d.scales[0])||void 0===t?void 0:t._id)||""}))),(u=null===(z=null==o?void 0:o.pdfs[0])||void 0===z?void 0:z.pdfDownloadUrl)?[4,Wle(u).promise]:[3,12];case 11:return f=g.sent(),[3,13];case 12:f=null,g.label=13;case 13:return(m=f)&&c((function(t){var a,r,c=Z7([],t,!0),l=c.length>0?c.findIndex((function(t){return t._id===e})):-1,i=-1!==l,s={_id:null===(r=null===(a=null==o?void 0:o.pdfs)||void 0===a?void 0:a[0])||void 0===r?void 0:r._id,sourcePdfUrl:n||"",pdfPagesImageGenerationStatus:o.pdfs[0].pdfPagesImageGenerationStatus,pdfDownloadUrl:o.pdfs[0].pdfDownloadUrl,pdfDocument:m,pages:h.pages.map((function(e){return{_id:null==e?void 0:e._id,pdfId:e.pdfId,annotations:[],commentThreads:[],pageImageUrl:e.pageAsImageDetails.pageImageDownloadUrl||"",pageNumber:e.pageNumber,pdfPageWidthInPoints:e.pdfPageWidthInPoints,pdfPageHeightInPoints:e.pdfPageHeightInPoints,pageAsImageDetails:e.pageAsImageDetails}})),scales:d.scales.map((function(e){return X7({},e)}))};return i?c[l]=X7({},s):c.push(s),c})),ae(e),[2]}}))}))}),[te,K,ae,c]),de=n.useCallback((function(e){v((function(t){var n=X7({},t);return n.toolsRelatedData=X7(X7({},n.toolsRelatedData),{comment:X7(X7({},n.toolsRelatedData.comment),{selectedThreadId:e})}),n}))}),[v]),ue=p.measureToolRelatedData.addNewScaleDetails,me=p.measureToolRelatedData.editScaleDetails,pe=n.useCallback((function(){return Q7(a,void 0,void 0,(function(){return J7(this,(function(e){return v((function(e){var t,n;return X7(X7({},e),{measureToolRelatedData:X7(X7({},e.measureToolRelatedData),{addNewScaleDetails:X7(X7({},e.measureToolRelatedData.addNewScaleDetails),{isAddNewScaleFormPopupOpen:!0,pdfPageId:null===(n=null===(t=null==o?void 0:o[0])||void 0===t?void 0:t.pages[0])||void 0===n?void 0:n._id})})})})),[2]}))}))}),[o]),ve=n.useState([]),fe=ve[0],ze=ve[1],ge=n.useCallback((function(e){return Q7(a,void 0,void 0,(function(){var t,n,a;return J7(this,(function(r){switch(r.label){case 0:return(t=o.find((function(t){return t._id===e.pdfIdOfPage})))&&(n=t.pages.find((function(t){return t._id===e.pdfPageId})))?n.pageImageElement||fe.includes(n._id)?[2]:(ze((function(e){return Z7(Z7([],e,!0),[n._id],!1)})),[4,Oae.downloadImage(n.pageImageUrl)]):[2];case 1:return a=r.sent(),c((function(t){var n=t.map((function(e){return X7(X7({},e),{pages:e.pages.map((function(e){return X7({},e)}))})})),r=n.findIndex((function(t){return t._id===e.pdfIdOfPage})),o=n[r].pages.findIndex((function(t){return t._id===e.pdfPageId}));return n[r].pages[o].pageImageElement=a,n})),ze((function(e){return Z7([],e.filter((function(e){return e!==n._id})),!0)})),[2]}}))}))}),[fe,o]),ye=n.useCallback((function(e){return Q7(a,void 0,void 0,(function(){var t,n,a,r;return J7(this,(function(l){switch(l.label){case 0:return t=e.pdfId,(n=o.find((function(e){return e._id===t})))?(a=n.pages.map((function(e){return e._id})),[4,K.current.fetchOnlyPdfPagesData({excludePdfPageIds:a,pdfId:t,getPdfPageImageDownloadUrl:"true",pdfPageImageUploaded:"true"})]):[2];case 1:return r=l.sent(),c((function(e){var n=e.findIndex((function(e){return e._id===t}));return-1===n?e:(e[n].pages=Z7(Z7([],e[n].pages,!0),r.pages.map((function(e){return{_id:e._id,pdfId:e.pdfId,pageNumber:e.pageNumber,annotations:[],commentThreads:[],pageAsImageDetails:e.pageAsImageDetails,pageImageUrl:e.pageAsImageDetails.pageImageDownloadUrl||"",pdfPageWidthInPoints:e.pdfPageWidthInPoints,pdfPageHeightInPoints:e.pdfPageHeightInPoints}})),!0),Z7([],e,!0))})),[2]}}))}))}),[o,K]),Me=n.useCallback((function(e){var t=e.pdfId,n=e.pdfPageId,r=e.annotationIds;return Q7(a,void 0,void 0,(function(){return J7(this,(function(e){return c((function(e){return e.map((function(e){return e._id===t?X7(X7({},e),{pages:e.pages.map((function(e){return e._id===n?X7(X7({},e),{annotations:e.annotations.filter((function(e){return!r.includes(e._id)||(K.current.deletePageAnnotation({annotationId:e._id}),!1)}))}):X7({},e)}))}):X7({},e)}))})),[2]}))}))}),[K]),Ee=n.useCallback((function(e){var t=e.pdfId,n=e.pdfPageId,a=e.annotations;c((function(e){return e.map((function(e){return e._id===t?X7(X7({},e),{pages:e.pages.map((function(e){return e._id===n?X7(X7({},e),{annotations:Z7(Z7([],e.annotations,!0),a,!0)}):X7({pdfPageId:e._id},e)}))}):X7({},e)}))}))}),[]),be=n.useState({rectangleAnnotationOptions:q,rectangleAnnotationData:{_id:"",color:"",height:0,width:0,pdfId:"",pdfPageId:"",rotationAngle:0,x:0,y:0},rectangleAnnotationConfigurationDrawer:{isOpen:!1,sections:{color:{collapsedStatus:"collapsed",currentlySelectedColor:""}}}}),He=be[0],Ve=be[1],Ce=n.useMemo((function(){for(var e=null,t=0,n=o||[];t<n.length;t++)for(var a=0,r=n[t].pages||[];a<r.length;a++)for(var c=0,l=r[a].annotations||[];c<l.length;c++){var s=l[c];if(s._id===i)return s}return e}),[i]);n.useEffect((function(){(null==Ce?void 0:Ce.rectangleAnnotation)?Ve(_ie((function(e){var t;e.rectangleAnnotationConfigurationDrawer.sections.color.currentlySelectedColor=(null===(t=Ce.rectangleAnnotation)||void 0===t?void 0:t.color)||""}))):(v(_ie((function(e){e.measureToolRelatedData.distanceAnnotation.configurationsDrawer.isOpen=!1}))),Ve(_ie((function(e){e.rectangleAnnotationConfigurationDrawer.isOpen=!1}))))}),[Ce]);var Le=n.useMemo((function(){return{pdfs:o,setPdfs:c,annotationSelectedId:i,setAnnotationSelectedId:s,toolSelected:d,setToolSelected:u,tools:p,setTools:v,currentUserId:z,setCurrentUserId:g,users:M,setUsers:E,isLeftBarOpen:O,setIsLeftBarOpen:A,isAnnotationsVisible:P,setIsAnnotationsVisible:F,backendBaseUrl:G,fetchPdfRelatedData:he,removeAnnotationsFromPdfPageAndDb:Me,addAnnotationsToPdfPage:Ee,addPdfPageImageElementIfNotPresentAlready:ge,setSelectedCommentThreadId:de,pageZoomPercentage:k,setPageZoomPercentage:w,rlefEventServiceBaseUrl:Y,addNewScaleDetails:ue,addScaleButtonClickedFromToolbar:pe,pdfEditorServiceRef:K,fetchAndSetPdfPagesInPdfWhichAreCreatedInDB:ye,pdfPageIdsForWhichPageImageElementIsBeingFetched:fe,callOutToolRelatedDataWhenSelected:ie,setCallOutToolRelatedDataWhenSelected:se,pdfEditorElementId:Q,selectedToolGroup:j,setSelectedToolGroup:B,pdfIdsWhoseDataBeingFetched:Z,annotationSelected:Ce,editScaleDetails:me,suggestedUsersForMention:H,fetchAndSetSuggestedUsersForMention:ne,isFetchingSuggestedUsersForMention:L,customCursorToShow:W,setCustomCursorToShow:$,rectangleRelatedData:He,setRectangleRelatedData:Ve}}),[o,i,d,p,z,M,O,P,G,he,ge,de,k,w,Y,ue,pe,ye,fe,ie,Q,j,Z,Ce,me,H,ne,L,W,He]);return t.jsx($ie.Provider,X7({value:Le},{children:e.children}))}var $ie=c.default.createContext({}),qie=function(){var e=c.default.useContext($ie);if(!e)throw new Error("usePdfAnnotationContext must be used within a PdfEditorContextProvider");return e};$le(".ContentArea-module_content-area-container__otXm-{align-items:center;background-color:#e3e6e8;display:flex;flex:1;justify-content:center;overflow:auto;position:relative}");$le(".PdfPage-module_pageContainer__-Q0sD{display:flex;flex-grow:1;height:100%;width:100%}.PdfPage-module_pageContainerWhenHorizontallyOverflowingAndIsVisibleInViewport__8onR1{align-self:flex-start}.PdfPage-module_justifyContentCenter__-7ATB{justify-content:center}.PdfPage-module_selectedText__m7jFl span::selection{background-color:#ffff0045!important}.PdfPage-module_selectedText__m7jFl span::-moz-selection{background-color:#ffff0045!important}.PdfPage-module_displayNone__cHRJo{display:none}.PdfPage-module_handCursor__vsE7b{cursor:grab!important}.PdfPage-module_handCursor__vsE7b:active{cursor:grabbing!important}");var Gie=Math.PI/180;const Yie=void 0!==eee?eee:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},Kie={_global:Yie,version:"8.4.3",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(e){}.toString()),dblClickWindow:400,getAngle:e=>Kie.angleDeg?e*Gie:e,enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>Kie.DD.isDragging,isDragReady:()=>!!Kie.DD.node,releaseCanvasOnDestroy:!0,document:Yie.document,_injectGlobal(e){Yie.Konva=e}},Xie=e=>{Kie[e.prototype.getClassName()]=e};Kie._injectGlobal(Kie);class Qie{constructor(e=[1,0,0,1,0,0]){this.dirty=!1,this.m=e&&e.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new Qie(this.m)}copyInto(e){e.m[0]=this.m[0],e.m[1]=this.m[1],e.m[2]=this.m[2],e.m[3]=this.m[3],e.m[4]=this.m[4],e.m[5]=this.m[5]}point(e){var t=this.m;return{x:t[0]*e.x+t[2]*e.y+t[4],y:t[1]*e.x+t[3]*e.y+t[5]}}translate(e,t){return this.m[4]+=this.m[0]*e+this.m[2]*t,this.m[5]+=this.m[1]*e+this.m[3]*t,this}scale(e,t){return this.m[0]*=e,this.m[1]*=e,this.m[2]*=t,this.m[3]*=t,this}rotate(e){var t=Math.cos(e),n=Math.sin(e),a=this.m[0]*t+this.m[2]*n,r=this.m[1]*t+this.m[3]*n,o=this.m[0]*-n+this.m[2]*t,c=this.m[1]*-n+this.m[3]*t;return this.m[0]=a,this.m[1]=r,this.m[2]=o,this.m[3]=c,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(e,t){var n=this.m[0]+this.m[2]*t,a=this.m[1]+this.m[3]*t,r=this.m[2]+this.m[0]*e,o=this.m[3]+this.m[1]*e;return this.m[0]=n,this.m[1]=a,this.m[2]=r,this.m[3]=o,this}multiply(e){var t=this.m[0]*e.m[0]+this.m[2]*e.m[1],n=this.m[1]*e.m[0]+this.m[3]*e.m[1],a=this.m[0]*e.m[2]+this.m[2]*e.m[3],r=this.m[1]*e.m[2]+this.m[3]*e.m[3],o=this.m[0]*e.m[4]+this.m[2]*e.m[5]+this.m[4],c=this.m[1]*e.m[4]+this.m[3]*e.m[5]+this.m[5];return this.m[0]=t,this.m[1]=n,this.m[2]=a,this.m[3]=r,this.m[4]=o,this.m[5]=c,this}invert(){var e=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),t=this.m[3]*e,n=-this.m[1]*e,a=-this.m[2]*e,r=this.m[0]*e,o=e*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),c=e*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=t,this.m[1]=n,this.m[2]=a,this.m[3]=r,this.m[4]=o,this.m[5]=c,this}getMatrix(){return this.m}decompose(){var e=this.m[0],t=this.m[1],n=this.m[2],a=this.m[3],r=e*a-t*n;let o={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=e||0!=t){var c=Math.sqrt(e*e+t*t);o.rotation=t>0?Math.acos(e/c):-Math.acos(e/c),o.scaleX=c,o.scaleY=r/c,o.skewX=(e*n+t*a)/r,o.skewY=0}else if(0!=n||0!=a){var l=Math.sqrt(n*n+a*a);o.rotation=Math.PI/2-(a>0?Math.acos(-n/l):-Math.acos(n/l)),o.scaleX=r/l,o.scaleY=l,o.skewX=0,o.skewY=(e*n+t*a)/r}return o.rotation=ose._getRotation(o.rotation),o}}var Jie=Math.PI/180,Zie=180/Math.PI,ese="Konva error: ",tse={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},nse=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,ase=[];const rse="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(e){setTimeout(e,60)},ose={_isElement:e=>!(!e||1!=e.nodeType),_isFunction:e=>!!(e&&e.constructor&&e.call&&e.apply),_isPlainObject:e=>!!e&&e.constructor===Object,_isArray:e=>"[object Array]"===Object.prototype.toString.call(e),_isNumber:e=>"[object Number]"===Object.prototype.toString.call(e)&&!isNaN(e)&&isFinite(e),_isString:e=>"[object String]"===Object.prototype.toString.call(e),_isBoolean:e=>"[object Boolean]"===Object.prototype.toString.call(e),isObject:e=>e instanceof Object,isValidSelector(e){if("string"!=typeof e)return!1;var t=e[0];return"#"===t||"."===t||t===t.toUpperCase()},_sign:e=>0===e||e>0?1:-1,requestAnimFrame(e){ase.push(e),1===ase.length&&rse((function(){const e=ase;ase=[],e.forEach((function(e){e()}))}))},createCanvasElement(){var e=document.createElement("canvas");try{e.style=e.style||{}}catch(e){}return e},createImageElement:()=>document.createElement("img"),_isInDocument(e){for(;e=e.parentNode;)if(e==document)return!0;return!1},_urlToImage(e,t){var n=ose.createImageElement();n.onload=function(){t(n)},n.src=e},_rgbToHex:(e,t,n)=>((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1),_hexToRgb(e){e=e.replace("#","");var t=parseInt(e,16);return{r:t>>16&255,g:t>>8&255,b:255&t}},getRandomColor(){for(var e=(16777215*Math.random()|0).toString(16);e.length<6;)e="0"+e;return"#"+e},getRGB(e){var t;return e in tse?{r:(t=tse[e])[0],g:t[1],b:t[2]}:"#"===e[0]?this._hexToRgb(e.substring(1)):"rgb("===e.substr(0,4)?(t=nse.exec(e.replace(/ /g,"")),{r:parseInt(t[1],10),g:parseInt(t[2],10),b:parseInt(t[3],10)}):{r:0,g:0,b:0}},colorToRGBA:e=>(e=e||"black",ose._namedColorToRBA(e)||ose._hex3ColorToRGBA(e)||ose._hex4ColorToRGBA(e)||ose._hex6ColorToRGBA(e)||ose._hex8ColorToRGBA(e)||ose._rgbColorToRGBA(e)||ose._rgbaColorToRGBA(e)||ose._hslColorToRGBA(e)),_namedColorToRBA(e){var t=tse[e.toLowerCase()];return t?{r:t[0],g:t[1],b:t[2],a:1}:null},_rgbColorToRGBA(e){if(0===e.indexOf("rgb(")){var t=(e=e.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:t[0],g:t[1],b:t[2],a:1}}},_rgbaColorToRGBA(e){if(0===e.indexOf("rgba(")){var t=(e=e.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map(((e,t)=>"%"===e.slice(-1)?3===t?parseInt(e)/100:parseInt(e)/100*255:Number(e)));return{r:t[0],g:t[1],b:t[2],a:t[3]}}},_hex8ColorToRGBA(e){if("#"===e[0]&&9===e.length)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:parseInt(e.slice(7,9),16)/255}},_hex6ColorToRGBA(e){if("#"===e[0]&&7===e.length)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:1}},_hex4ColorToRGBA(e){if("#"===e[0]&&5===e.length)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:parseInt(e[4]+e[4],16)/255}},_hex3ColorToRGBA(e){if("#"===e[0]&&4===e.length)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:1}},_hslColorToRGBA(e){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(e)){const[t,...n]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e),a=Number(n[0])/360,r=Number(n[1])/100,o=Number(n[2])/100;let c,l,i;if(0===r)return i=255*o,{r:Math.round(i),g:Math.round(i),b:Math.round(i),a:1};c=o<.5?o*(1+r):o+r-o*r;const s=2*o-c,h=[0,0,0];for(let e=0;e<3;e++)l=a+1/3*-(e-1),l<0&&l++,l>1&&l--,i=6*l<1?s+6*(c-s)*l:2*l<1?c:3*l<2?s+(c-s)*(2/3-l)*6:s,h[e]=255*i;return{r:Math.round(h[0]),g:Math.round(h[1]),b:Math.round(h[2]),a:1}}},haveIntersection:(e,t)=>!(t.x>e.x+e.width||t.x+t.width<e.x||t.y>e.y+e.height||t.y+t.height<e.y),cloneObject(e){var t={};for(var n in e)this._isPlainObject(e[n])?t[n]=this.cloneObject(e[n]):this._isArray(e[n])?t[n]=this.cloneArray(e[n]):t[n]=e[n];return t},cloneArray:e=>e.slice(0),degToRad:e=>e*Jie,radToDeg:e=>e*Zie,_degToRad:e=>(ose.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),ose.degToRad(e)),_radToDeg:e=>(ose.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),ose.radToDeg(e)),_getRotation:e=>Kie.angleDeg?ose.radToDeg(e):e,_capitalize:e=>e.charAt(0).toUpperCase()+e.slice(1),throw(e){throw new Error(ese+e)},error(e){console.error(ese+e)},warn(e){Kie.showWarnings&&console.warn("Konva warning: "+e)},each(e,t){for(var n in e)t(n,e[n])},_inRange:(e,t,n)=>t<=e&&e<n,_getProjectionToSegment(e,t,n,a,r,o){var c,l,i,s=(e-n)*(e-n)+(t-a)*(t-a);if(0==s)c=e,l=t,i=(r-n)*(r-n)+(o-a)*(o-a);else{var h=((r-e)*(n-e)+(o-t)*(a-t))/s;h<0?(c=e,l=t,i=(e-r)*(e-r)+(t-o)*(t-o)):h>1?(c=n,l=a,i=(n-r)*(n-r)+(a-o)*(a-o)):i=((c=e+h*(n-e))-r)*(c-r)+((l=t+h*(a-t))-o)*(l-o)}return[c,l,i]},_getProjectionToLine(e,t,n){var a=ose.cloneObject(e),r=Number.MAX_VALUE;return t.forEach((function(o,c){if(n||c!==t.length-1){var l=t[(c+1)%t.length],i=ose._getProjectionToSegment(o.x,o.y,l.x,l.y,e.x,e.y),s=i[0],h=i[1],d=i[2];d<r&&(a.x=s,a.y=h,r=d)}})),a},_prepareArrayForTween(e,t,n){var a,r=[],o=[];if(e.length>t.length){var c=t;t=e,e=c}for(a=0;a<e.length;a+=2)r.push({x:e[a],y:e[a+1]});for(a=0;a<t.length;a+=2)o.push({x:t[a],y:t[a+1]});var l=[];return o.forEach((function(e){var t=ose._getProjectionToLine(e,r,n);l.push(t.x),l.push(t.y)})),l},_prepareToStringify(e){var t;for(var n in e.visitedByCircularReferenceRemoval=!0,e)if(e.hasOwnProperty(n)&&e[n]&&"object"==typeof e[n])if(t=Object.getOwnPropertyDescriptor(e,n),e[n].visitedByCircularReferenceRemoval||ose._isElement(e[n])){if(!t.configurable)return null;delete e[n]}else if(null===ose._prepareToStringify(e[n])){if(!t.configurable)return null;delete e[n]}return delete e.visitedByCircularReferenceRemoval,e},_assign(e,t){for(var n in t)e[n]=t[n];return e},_getFirstPointerId:e=>e.touches?e.changedTouches[0].identifier:e.pointerId||999,releaseCanvas(...e){Kie.releaseCanvasOnDestroy&&e.forEach((e=>{e.width=0,e.height=0}))},drawRoundedRectPath(e,t,n,a){let r=0,o=0,c=0,l=0;"number"==typeof a?r=o=c=l=Math.min(a,t/2,n/2):(r=Math.min(a[0]||0,t/2,n/2),o=Math.min(a[1]||0,t/2,n/2),l=Math.min(a[2]||0,t/2,n/2),c=Math.min(a[3]||0,t/2,n/2)),e.moveTo(r,0),e.lineTo(t-o,0),e.arc(t-o,o,o,3*Math.PI/2,0,!1),e.lineTo(t,n-l),e.arc(t-l,n-l,l,0,Math.PI/2,!1),e.lineTo(c,n),e.arc(c,n-c,c,Math.PI/2,Math.PI,!1),e.lineTo(0,r),e.arc(r,r,r,Math.PI,3*Math.PI/2,!1)}};function cse(e){return ose._isString(e)?'"'+e+'"':"[object Number]"===Object.prototype.toString.call(e)||ose._isBoolean(e)?e:Object.prototype.toString.call(e)}function lse(e){return e>255?255:e<0?0:Math.round(e)}function ise(){if(Kie.isUnminified)return function(e,t){return ose._isNumber(e)||ose.warn(cse(e)+' is a not valid value for "'+t+'" attribute. The value should be a number.'),e}}function sse(e){if(Kie.isUnminified)return function(t,n){let a=ose._isNumber(t),r=ose._isArray(t)&&t.length==e;return a||r||ose.warn(cse(t)+' is a not valid value for "'+n+'" attribute. The value should be a number or Array<number>('+e+")"),t}}function hse(){if(Kie.isUnminified)return function(e,t){return ose._isNumber(e)||"auto"===e||ose.warn(cse(e)+' is a not valid value for "'+t+'" attribute. The value should be a number or "auto".'),e}}function dse(){if(Kie.isUnminified)return function(e,t){return ose._isString(e)||ose.warn(cse(e)+' is a not valid value for "'+t+'" attribute. The value should be a string.'),e}}function use(){if(Kie.isUnminified)return function(e,t){const n=ose._isString(e),a="[object CanvasGradient]"===Object.prototype.toString.call(e)||e&&e.addColorStop;return n||a||ose.warn(cse(e)+' is a not valid value for "'+t+'" attribute. The value should be a string or a native gradient.'),e}}function mse(){if(Kie.isUnminified)return function(e,t){return!0===e||!1===e||ose.warn(cse(e)+' is a not valid value for "'+t+'" attribute. The value should be a boolean.'),e}}var pse="get",vse="set";const fse={addGetterSetter(e,t,n,a,r){fse.addGetter(e,t,n),fse.addSetter(e,t,a,r),fse.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){var a=pse+ose._capitalize(t);e.prototype[a]=e.prototype[a]||function(){var e=this.attrs[t];return void 0===e?n:e}},addSetter(e,t,n,a){var r=vse+ose._capitalize(t);e.prototype[r]||fse.overWriteSetter(e,t,n,a)},overWriteSetter(e,t,n,a){var r=vse+ose._capitalize(t);e.prototype[r]=function(e){return n&&null!=e&&(e=n.call(this,e,t)),this._setAttr(t,e),a&&a.call(this),this}},addComponentsGetterSetter(e,t,n,a,r){var o,c,l=n.length,i=ose._capitalize,s=pse+i(t),h=vse+i(t);e.prototype[s]=function(){var e={};for(o=0;o<l;o++)e[c=n[o]]=this.getAttr(t+i(c));return e};var d=function(e){if(Kie.isUnminified)return function(t,n){return null==t||ose.isObject(t)||ose.warn(cse(t)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+e),t}}(n);e.prototype[h]=function(e){var o,c=this.attrs[t];for(o in a&&(e=a.call(this,e)),d&&d.call(this,e,t),e)e.hasOwnProperty(o)&&this._setAttr(t+i(o),e[o]);return e||n.forEach((e=>{this._setAttr(t+i(e),void 0)})),this._fireChangeEvent(t,c,e),r&&r.call(this),this},fse.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){var n=ose._capitalize(t),a=vse+n,r=pse+n;e.prototype[t]=function(){return arguments.length?(this[a](arguments[0]),this):this[r]()}},addDeprecatedGetterSetter(e,t,n,a){ose.error("Adding deprecated "+t);var r=pse+ose._capitalize(t),o=t+" property is deprecated and will be removed soon. Look at Konva change log for more information.";e.prototype[r]=function(){ose.error(o);var e=this.attrs[t];return void 0===e?n:e},fse.addSetter(e,t,a,(function(){ose.error(o)})),fse.addOverloadedGetterSetter(e,t)},backCompat(e,t){ose.each(t,(function(t,n){var a=e.prototype[n],r=pse+ose._capitalize(t),o=vse+ose._capitalize(t);function c(){a.apply(this,arguments),ose.error('"'+t+'" method is deprecated and will be removed soon. Use ""'+n+'" instead.')}e.prototype[t]=c,e.prototype[r]=c,e.prototype[o]=c}))},afterSetFilter(){this._filterUpToDate=!1}};var zse,gse=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];class yse{constructor(e){this.canvas=e,Kie.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(e){e.fillEnabled()&&this._fill(e)}_fill(e){}strokeShape(e){e.hasStroke()&&this._stroke(e)}_stroke(e){}fillStrokeShape(e){e.attrs.fillAfterStrokeEnabled?(this.strokeShape(e),this.fillShape(e)):(this.fillShape(e),this.strokeShape(e))}getTrace(e,t){var n,a,r,o,c=this.traceArr,l=c.length,i="";for(n=0;n<l;n++)(r=(a=c[n]).method)?(o=a.args,i+=r,e?i+="()":ose._isArray(o[0])?i+="(["+o.join(",")+"])":(t&&(o=o.map((e=>"number"==typeof e?Math.floor(e):e))),i+="("+o.join(",")+")")):(i+=a.property,e||(i+="="+a.val)),i+=";";return i}clearTrace(){this.traceArr=[]}_trace(e){var t=this.traceArr;t.push(e),t.length>=100&&t.shift()}reset(){var e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){var t=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,t.getWidth()/t.pixelRatio,t.getHeight()/t.pixelRatio)}_applyLineCap(e){const t=e.attrs.lineCap;t&&this.setAttr("lineCap",t)}_applyOpacity(e){var t=e.getAbsoluteOpacity();1!==t&&this.setAttr("globalAlpha",t)}_applyLineJoin(e){const t=e.attrs.lineJoin;t&&this.setAttr("lineJoin",t)}setAttr(e,t){this._context[e]=t}arc(e,t,n,a,r,o){this._context.arc(e,t,n,a,r,o)}arcTo(e,t,n,a,r){this._context.arcTo(e,t,n,a,r)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,n,a,r,o){this._context.bezierCurveTo(e,t,n,a,r,o)}clearRect(e,t,n,a){this._context.clearRect(e,t,n,a)}clip(){this._context.clip()}closePath(){this._context.closePath()}createImageData(e,t){var n=arguments;return 2===n.length?this._context.createImageData(e,t):1===n.length?this._context.createImageData(e):void 0}createLinearGradient(e,t,n,a){return this._context.createLinearGradient(e,t,n,a)}createPattern(e,t){return this._context.createPattern(e,t)}createRadialGradient(e,t,n,a,r,o){return this._context.createRadialGradient(e,t,n,a,r,o)}drawImage(e,t,n,a,r,o,c,l,i){var s=arguments,h=this._context;3===s.length?h.drawImage(e,t,n):5===s.length?h.drawImage(e,t,n,a,r):9===s.length&&h.drawImage(e,t,n,a,r,o,c,l,i)}ellipse(e,t,n,a,r,o,c,l){this._context.ellipse(e,t,n,a,r,o,c,l)}isPointInPath(e,t,n,a){return n?this._context.isPointInPath(n,e,t,a):this._context.isPointInPath(e,t,a)}fill(e){e?this._context.fill(e):this._context.fill()}fillRect(e,t,n,a){this._context.fillRect(e,t,n,a)}strokeRect(e,t,n,a){this._context.strokeRect(e,t,n,a)}fillText(e,t,n,a){a?this._context.fillText(e,t,n,a):this._context.fillText(e,t,n)}measureText(e){return this._context.measureText(e)}getImageData(e,t,n,a){return this._context.getImageData(e,t,n,a)}lineTo(e,t){this._context.lineTo(e,t)}moveTo(e,t){this._context.moveTo(e,t)}rect(e,t,n,a){this._context.rect(e,t,n,a)}putImageData(e,t,n){this._context.putImageData(e,t,n)}quadraticCurveTo(e,t,n,a){this._context.quadraticCurveTo(e,t,n,a)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,t){this._context.scale(e,t)}setLineDash(e){this._context.setLineDash?this._context.setLineDash(e):"mozDash"in this._context?this._context.mozDash=e:"webkitLineDash"in this._context&&(this._context.webkitLineDash=e)}getLineDash(){return this._context.getLineDash()}setTransform(e,t,n,a,r,o){this._context.setTransform(e,t,n,a,r,o)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,t,n,a){this._context.strokeText(e,t,n,a)}transform(e,t,n,a,r,o){this._context.transform(e,t,n,a,r,o)}translate(e,t){this._context.translate(e,t)}_enableTrace(){var e,t,n=this,a=gse.length,r=this.setAttr,o=function(e){var a,r=n[e];n[e]=function(){return t=function(e){var t,n,a=[],r=e.length,o=ose;for(t=0;t<r;t++)n=e[t],o._isNumber(n)?n=Math.round(1e3*n)/1e3:o._isString(n)||(n+=""),a.push(n);return a}(Array.prototype.slice.call(arguments,0)),a=r.apply(n,arguments),n._trace({method:e,args:t}),a}};for(e=0;e<a;e++)o(gse[e]);n.setAttr=function(){r.apply(n,arguments);var e=arguments[0],t=arguments[1];"shadowOffsetX"!==e&&"shadowOffsetY"!==e&&"shadowBlur"!==e||(t/=this.canvas.getPixelRatio()),n._trace({property:e,val:t})}}_applyGlobalCompositeOperation(e){const t=e.attrs.globalCompositeOperation;!t||"source-over"===t||this.setAttr("globalCompositeOperation",t)}}["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach((function(e){Object.defineProperty(yse.prototype,e,{get(){return this._context[e]},set(t){this._context[e]=t}})}));class Mse extends yse{constructor(e){super(e),this._context=e._canvas.getContext("2d")}_fillColor(e){var t=e.fill();this.setAttr("fillStyle",t),e._fillFunc(this)}_fillPattern(e){this.setAttr("fillStyle",e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){var t=e._getLinearGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fillRadialGradient(e){const t=e._getRadialGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fill(e){const t=e.fill(),n=e.getFillPriority();if(t&&"color"===n)return void this._fillColor(e);const a=e.getFillPatternImage();if(a&&"pattern"===n)return void this._fillPattern(e);const r=e.getFillLinearGradientColorStops();if(r&&"linear-gradient"===n)return void this._fillLinearGradient(e);const o=e.getFillRadialGradientColorStops();o&&"radial-gradient"===n?this._fillRadialGradient(e):t?this._fillColor(e):a?this._fillPattern(e):r?this._fillLinearGradient(e):o&&this._fillRadialGradient(e)}_strokeLinearGradient(e){const t=e.getStrokeLinearGradientStartPoint(),n=e.getStrokeLinearGradientEndPoint(),a=e.getStrokeLinearGradientColorStops(),r=this.createLinearGradient(t.x,t.y,n.x,n.y);if(a){for(var o=0;o<a.length;o+=2)r.addColorStop(a[o],a[o+1]);this.setAttr("strokeStyle",r)}}_stroke(e){var t=e.dash(),n=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!n){this.save();var a=this.getCanvas().getPixelRatio();this.setTransform(a,0,0,a,0,0)}this._applyLineCap(e),t&&e.dashEnabled()&&(this.setLineDash(t),this.setAttr("lineDashOffset",e.dashOffset())),this.setAttr("lineWidth",e.strokeWidth()),e.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)"),e.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(e):this.setAttr("strokeStyle",e.stroke()),e._strokeFunc(this),n||this.restore()}}_applyShadow(e){var t,n,a,r=null!==(t=e.getShadowRGBA())&&void 0!==t?t:"black",o=null!==(n=e.getShadowBlur())&&void 0!==n?n:5,c=null!==(a=e.getShadowOffset())&&void 0!==a?a:{x:0,y:0},l=e.getAbsoluteScale(),i=this.canvas.getPixelRatio(),s=l.x*i,h=l.y*i;this.setAttr("shadowColor",r),this.setAttr("shadowBlur",o*Math.min(Math.abs(s),Math.abs(h))),this.setAttr("shadowOffsetX",c.x*s),this.setAttr("shadowOffsetY",c.y*h)}}class Ese extends yse{constructor(e){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:!0})}_fill(e){this.save(),this.setAttr("fillStyle",e.colorKey),e._fillFuncHit(this),this.restore()}strokeShape(e){e.hasHitStroke()&&this._stroke(e)}_stroke(e){if(e.hasHitStroke()){const r=e.getStrokeScaleEnabled();if(!r){this.save();var t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(e);var n=e.hitStrokeWidth(),a="auto"===n?e.strokeWidth():n;this.setAttr("lineWidth",a),this.setAttr("strokeStyle",e.colorKey),e._strokeFuncHit(this),r||this.restore()}}}class bse{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var t=(e||{}).pixelRatio||Kie.pixelRatio||function(){if(zse)return zse;var e=ose.createCanvasElement(),t=e.getContext("2d");return zse=(Kie._global.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1),ose.releaseCanvas(e),zse}();this.pixelRatio=t,this._canvas=ose.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(e){var t=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/t,this.getHeight()/t)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+"px";var t=this.pixelRatio;this.getContext()._context.scale(t,t)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+"px";var t=this.pixelRatio;this.getContext()._context.scale(t,t)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,t){this.setWidth(e||0),this.setHeight(t||0)}toDataURL(e,t){try{return this._canvas.toDataURL(e,t)}catch(e){try{return this._canvas.toDataURL()}catch(e){return ose.error("Unable to get data URL. "+e.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}fse.addGetterSetter(bse,"pixelRatio",void 0,ise());class Hse extends bse{constructor(e={width:0,height:0}){super(e),this.context=new Mse(this),this.setSize(e.width,e.height)}}class Vse extends bse{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new Ese(this),this.setSize(e.width,e.height)}}const Cse={get isDragging(){var e=!1;return Cse._dragElements.forEach((t=>{"dragging"===t.dragStatus&&(e=!0)})),e},justDragged:!1,get node(){var e;return Cse._dragElements.forEach((t=>{e=t.node})),e},_dragElements:new Map,_drag(e){const t=[];Cse._dragElements.forEach(((n,a)=>{const{node:r}=n,o=r.getStage();o.setPointersPositions(e),void 0===n.pointerId&&(n.pointerId=ose._getFirstPointerId(e));const c=o._changedPointerPositions.find((e=>e.id===n.pointerId));if(c){if("dragging"!==n.dragStatus){var l=r.dragDistance();if(Math.max(Math.abs(c.x-n.startPointerPos.x),Math.abs(c.y-n.startPointerPos.y))<l)return;if(r.startDrag({evt:e}),!r.isDragging())return}r._setDragPosition(e,n),t.push(r)}})),t.forEach((t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:e},!0)}))},_endDragBefore(e){const t=[];Cse._dragElements.forEach((n=>{const{node:a}=n,r=a.getStage();if(e&&r.setPointersPositions(e),!r._changedPointerPositions.find((e=>e.id===n.pointerId)))return;"dragging"!==n.dragStatus&&"stopped"!==n.dragStatus||(Cse.justDragged=!0,Kie._mouseListenClick=!1,Kie._touchListenClick=!1,Kie._pointerListenClick=!1,n.dragStatus="stopped");const o=n.node.getLayer()||n.node instanceof Kie.Stage&&n.node;o&&-1===t.indexOf(o)&&t.push(o)})),t.forEach((e=>{e.draw()}))},_endDragAfter(e){Cse._dragElements.forEach(((t,n)=>{"stopped"===t.dragStatus&&t.node.fire("dragend",{type:"dragend",target:t.node,evt:e},!0),"dragging"!==t.dragStatus&&Cse._dragElements.delete(n)}))}};Kie.isBrowser&&(window.addEventListener("mouseup",Cse._endDragBefore,!0),window.addEventListener("touchend",Cse._endDragBefore,!0),window.addEventListener("mousemove",Cse._drag),window.addEventListener("touchmove",Cse._drag),window.addEventListener("mouseup",Cse._endDragAfter,!1),window.addEventListener("touchend",Cse._endDragAfter,!1));var Lse="absoluteOpacity",xse="allEventListeners",Sse="absoluteTransform",kse="absoluteScale",wse="canvas",Tse="listening",Ose="mouseenter",Ase="mouseleave",Rse="Shape",Nse=" ",_se="stage",Dse="transform",Pse="visible",Fse=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(Nse);let Ise=1;class jse{constructor(e){this._id=Ise++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(e),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(e){e!==Dse&&e!==Sse||!this._cache.get(e)?e?this._cache.delete(e):this._cache.clear():this._cache.get(e).dirty=!0}_getCache(e,t){var n=this._cache.get(e);return(void 0===n||(e===Dse||e===Sse)&&!0===n.dirty)&&(n=t.call(this),this._cache.set(e,n)),n}_calculate(e,t,n){if(!this._attachedDepsListeners.get(e)){const n=t.map((e=>e+"Change.konva")).join(Nse);this.on(n,(()=>{this._clearCache(e)})),this._attachedDepsListeners.set(e,!0)}return this._getCache(e,n)}_getCanvasCache(){return this._cache.get(wse)}_clearSelfAndDescendantCache(e){this._clearCache(e),e===Sse&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(wse)){const{scene:e,filter:t,hit:n}=this._cache.get(wse);ose.releaseCanvas(e,t,n),this._cache.delete(wse)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){var t=e||{},n={};void 0!==t.x&&void 0!==t.y&&void 0!==t.width&&void 0!==t.height||(n=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()}));var a=Math.ceil(t.width||n.width),r=Math.ceil(t.height||n.height),o=t.pixelRatio,c=void 0===t.x?Math.floor(n.x):t.x,l=void 0===t.y?Math.floor(n.y):t.y,i=t.offset||0,s=t.drawBorder||!1,h=t.hitCanvasPixelRatio||1;if(a&&r){c-=i,l-=i;var d=new Hse({pixelRatio:o,width:a+=2*i+1,height:r+=2*i+1}),u=new Hse({pixelRatio:o,width:0,height:0}),m=new Vse({pixelRatio:h,width:a,height:r}),p=d.getContext(),v=m.getContext();return m.isCache=!0,d.isCache=!0,this._cache.delete(wse),this._filterUpToDate=!1,!1===t.imageSmoothingEnabled&&(d.getContext()._context.imageSmoothingEnabled=!1,u.getContext()._context.imageSmoothingEnabled=!1),p.save(),v.save(),p.translate(-c,-l),v.translate(-c,-l),this._isUnderCache=!0,this._clearSelfAndDescendantCache(Lse),this._clearSelfAndDescendantCache(kse),this.drawScene(d,this),this.drawHit(m,this),this._isUnderCache=!1,p.restore(),v.restore(),s&&(p.save(),p.beginPath(),p.rect(0,0,a,r),p.closePath(),p.setAttr("strokeStyle","red"),p.setAttr("lineWidth",5),p.stroke(),p.restore()),this._cache.set(wse,{scene:d,filter:u,hit:m,x:c,y:l}),this._requestDraw(),this}ose.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.")}isCached(){return this._cache.has(wse)}getClientRect(e){throw new Error('abstract "getClientRect" method call')}_transformedRect(e,t){var n,a,r,o,c=[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}],l=this.getAbsoluteTransform(t);return c.forEach((function(e){var t=l.point(e);void 0===n&&(n=r=t.x,a=o=t.y),n=Math.min(n,t.x),a=Math.min(a,t.y),r=Math.max(r,t.x),o=Math.max(o,t.y)})),{x:n,y:a,width:r-n,height:o-a}}_drawCachedSceneCanvas(e){e.save(),e._applyOpacity(this),e._applyGlobalCompositeOperation(this);const t=this._getCanvasCache();e.translate(t.x,t.y);var n=this._getCachedSceneCanvas(),a=n.pixelRatio;e.drawImage(n._canvas,0,0,n.width/a,n.height/a),e.restore()}_drawCachedHitCanvas(e){var t=this._getCanvasCache(),n=t.hit;e.save(),e.translate(t.x,t.y),e.drawImage(n._canvas,0,0,n.width/n.pixelRatio,n.height/n.pixelRatio),e.restore()}_getCachedSceneCanvas(){var e,t,n,a,r=this.filters(),o=this._getCanvasCache(),c=o.scene,l=o.filter,i=l.getContext();if(r){if(!this._filterUpToDate){var s=c.pixelRatio;l.setSize(c.width/c.pixelRatio,c.height/c.pixelRatio);try{for(e=r.length,i.clear(),i.drawImage(c._canvas,0,0,c.getWidth()/s,c.getHeight()/s),t=i.getImageData(0,0,l.getWidth(),l.getHeight()),n=0;n<e;n++)"function"==typeof(a=r[n])?(a.call(this,t),i.putImageData(t,0,0)):ose.error("Filter should be type of function, but got "+typeof a+" instead. Please check correct filters")}catch(e){ose.error("Unable to apply filter. "+e.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return l}return c}on(e,t){if(this._cache&&this._cache.delete(xse),3===arguments.length)return this._delegate.apply(this,arguments);var n,a,r,o,c=e.split(Nse),l=c.length;for(n=0;n<l;n++)r=(a=c[n].split("."))[0],o=a[1]||"",this.eventListeners[r]||(this.eventListeners[r]=[]),this.eventListeners[r].push({name:o,handler:t});return this}off(e,t){var n,a,r,o,c,l=(e||"").split(Nse),i=l.length;if(this._cache&&this._cache.delete(xse),!e)for(a in this.eventListeners)this._off(a);for(n=0;n<i;n++)if(o=(r=l[n].split("."))[0],c=r[1],o)this.eventListeners[o]&&this._off(o,c,t);else for(a in this.eventListeners)this._off(a,c,t);return this}dispatchEvent(e){var t={target:this,type:e.type,evt:e};return this.fire(e.type,t),this}addEventListener(e,t){return this.on(e,(function(e){t.call(this,e.evt)})),this}removeEventListener(e){return this.off(e),this}_delegate(e,t,n){var a=this;this.on(e,(function(e){for(var r=e.target.findAncestors(t,!0,a),o=0;o<r.length;o++)(e=ose.cloneObject(e)).currentTarget=r[o],n.call(r[o],e)}))}remove(){return this.isDragging()&&this.stopDrag(),Cse._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(Sse),this._clearSelfAndDescendantCache(Lse),this._clearSelfAndDescendantCache(kse),this._clearSelfAndDescendantCache(_se),this._clearSelfAndDescendantCache(Pse),this._clearSelfAndDescendantCache(Tse)}_remove(){this._clearCaches();var e=this.getParent();e&&e.children&&(e.children.splice(this.index,1),e._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(e){var t="get"+ose._capitalize(e);return ose._isFunction(this[t])?this[t]():this.attrs[e]}getAncestors(){for(var e=this.getParent(),t=[];e;)t.push(e),e=e.getParent();return t}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges((()=>{var t,n;if(!e)return this;for(t in e)"children"!==t&&(n="set"+ose._capitalize(t),ose._isFunction(this[n])?this[n](e[t]):this._setAttr(t,e[t]))})),this}isListening(){return this._getCache(Tse,this._isListening)}_isListening(e){if(!this.listening())return!1;const t=this.getParent();return!t||t===e||this===e||t._isListening(e)}isVisible(){return this._getCache(Pse,this._isVisible)}_isVisible(e){if(!this.visible())return!1;const t=this.getParent();return!t||t===e||this===e||t._isVisible(e)}shouldDrawHit(e,t=!1){if(e)return this._isVisible(e)&&this._isListening(e);var n=this.getLayer(),a=!1;Cse._dragElements.forEach((e=>{"dragging"===e.dragStatus&&("Stage"===e.node.nodeType||e.node.getLayer()===n)&&(a=!0)}));var r=!t&&!Kie.hitOnDragEnabled&&a;return this.isListening()&&this.isVisible()&&!r}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){var e,t,n,a,r=this.getDepth(),o=this,c=0;return"Stage"!==o.nodeType&&function l(i){for(e=[],t=i.length,n=0;n<t;n++)a=i[n],c++,a.nodeType!==Rse&&(e=e.concat(a.getChildren().slice())),a._id===o._id&&(n=t);e.length>0&&e[0].getDepth()<=r&&l(e)}(o.getStage().getChildren()),c}getDepth(){for(var e=0,t=this.parent;t;)e++,t=t.parent;return e}_batchTransformChanges(e){this._batchingTransformChange=!0,e(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(Dse),this._clearSelfAndDescendantCache(Sse)),this._needClearTransformCache=!1}setPosition(e){return this._batchTransformChanges((()=>{this.x(e.x),this.y(e.y)})),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){if(!this.getStage())return null;var e=this.getStage().getPointerPosition();if(!e)return null;var t=this.getAbsoluteTransform().copy();return t.invert(),t.point(e)}getAbsolutePosition(e){let t=!1,n=this.parent;for(;n;){if(n.isCached()){t=!0;break}n=n.parent}t&&!e&&(e=!0);var a=this.getAbsoluteTransform(e).getMatrix(),r=new Qie,o=this.offset();return r.m=a.slice(),r.translate(o.x,o.y),r.getTranslation()}setAbsolutePosition(e){var t=this._clearTransform();this.attrs.x=t.x,this.attrs.y=t.y,delete t.x,delete t.y,this._clearCache(Dse);var n=this._getAbsoluteTransform().copy();return n.invert(),n.translate(e.x,e.y),e={x:this.attrs.x+n.getTranslation().x,y:this.attrs.y+n.getTranslation().y},this._setTransform(t),this.setPosition({x:e.x,y:e.y}),this._clearCache(Dse),this._clearSelfAndDescendantCache(Sse),this}_setTransform(e){var t;for(t in e)this.attrs[t]=e[t]}_clearTransform(){var e={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,e}move(e){var t=e.x,n=e.y,a=this.x(),r=this.y();return void 0!==t&&(a+=t),void 0!==n&&(r+=n),this.setPosition({x:a,y:r}),this}_eachAncestorReverse(e,t){var n,a,r=[],o=this.getParent();if(!t||t._id!==this._id){for(r.unshift(this);o&&(!t||o._id!==t._id);)r.unshift(o),o=o.parent;for(n=r.length,a=0;a<n;a++)e(r[a])}}rotate(e){return this.rotation(this.rotation()+e),this}moveToTop(){if(!this.parent)return ose.warn("Node has no parent. moveToTop function is ignored."),!1;var e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return ose.warn("Node has no parent. moveUp function is ignored."),!1;var e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return ose.warn("Node has no parent. moveDown function is ignored."),!1;var e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return ose.warn("Node has no parent. moveToBottom function is ignored."),!1;var e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(e){if(!this.parent)return ose.warn("Node has no parent. zIndex parameter is ignored."),this;(e<0||e>=this.parent.children.length)&&ose.warn("Unexpected value "+e+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");var t=this.index;return this.parent.children.splice(t,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(Lse,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){var e=this.opacity(),t=this.getParent();return t&&!t._isUnderCache&&(e*=t.getAbsoluteOpacity()),e}moveTo(e){return this.getParent()!==e&&(this._remove(),e.add(this)),this}toObject(){var e,t,n,a,r={},o=this.getAttrs();for(e in r.attrs={},o)t=o[e],ose.isObject(t)&&!ose._isPlainObject(t)&&!ose._isArray(t)||(n="function"==typeof this[e]&&this[e],delete o[e],a=n?n.call(this):null,o[e]=t,a!==t&&(r.attrs[e]=t));return r.className=this.getClassName(),ose._prepareToStringify(r)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,t,n){var a=[];t&&this._isMatch(e)&&a.push(this);for(var r=this.parent;r;){if(r===n)return a;r._isMatch(e)&&a.push(r),r=r.parent}return a}isAncestorOf(e){return!1}findAncestor(e,t,n){return this.findAncestors(e,t,n)[0]}_isMatch(e){if(!e)return!1;if("function"==typeof e)return e(this);var t,n,a=e.replace(/ /g,"").split(","),r=a.length;for(t=0;t<r;t++)if(n=a[t],ose.isValidSelector(n)||(ose.warn('Selector "'+n+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),ose.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),ose.warn("Konva is awesome, right?")),"#"===n.charAt(0)){if(this.id()===n.slice(1))return!0}else if("."===n.charAt(0)){if(this.hasName(n.slice(1)))return!0}else if(this.className===n||this.nodeType===n)return!0;return!1}getLayer(){var e=this.getParent();return e?e.getLayer():null}getStage(){return this._getCache(_se,this._getStage)}_getStage(){var e=this.getParent();return e?e.getStage():void 0}fire(e,t={},n){return t.target=t.target||this,n?this._fireAndBubble(e,t):this._fire(e,t),this}getAbsoluteTransform(e){return e?this._getAbsoluteTransform(e):this._getCache(Sse,this._getAbsoluteTransform)}_getAbsoluteTransform(e){var t;if(e)return t=new Qie,this._eachAncestorReverse((function(e){var n=e.transformsEnabled();"all"===n?t.multiply(e.getTransform()):"position"===n&&t.translate(e.x()-e.offsetX(),e.y()-e.offsetY())}),e),t;t=this._cache.get(Sse)||new Qie,this.parent?this.parent.getAbsoluteTransform().copyInto(t):t.reset();var n=this.transformsEnabled();if("all"===n)t.multiply(this.getTransform());else if("position"===n){const e=this.attrs.x||0,n=this.attrs.y||0,a=this.attrs.offsetX||0,r=this.attrs.offsetY||0;t.translate(e-a,n-r)}return t.dirty=!1,t}getAbsoluteScale(e){for(var t=this;t;)t._isUnderCache&&(e=t),t=t.getParent();const n=this.getAbsoluteTransform(e).decompose();return{x:n.scaleX,y:n.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(Dse,this._getTransform)}_getTransform(){var e,t,n=this._cache.get(Dse)||new Qie;n.reset();var a=this.x(),r=this.y(),o=Kie.getAngle(this.rotation()),c=null!==(e=this.attrs.scaleX)&&void 0!==e?e:1,l=null!==(t=this.attrs.scaleY)&&void 0!==t?t:1,i=this.attrs.skewX||0,s=this.attrs.skewY||0,h=this.attrs.offsetX||0,d=this.attrs.offsetY||0;return 0===a&&0===r||n.translate(a,r),0!==o&&n.rotate(o),0===i&&0===s||n.skew(i,s),1===c&&1===l||n.scale(c,l),0===h&&0===d||n.translate(-1*h,-1*d),n.dirty=!1,n}clone(e){var t,n,a,r,o,c=ose.cloneObject(this.attrs);for(t in e)c[t]=e[t];var l=new this.constructor(c);for(t in this.eventListeners)for(a=(n=this.eventListeners[t]).length,r=0;r<a;r++)(o=n[r]).name.indexOf("konva")<0&&(l.eventListeners[t]||(l.eventListeners[t]=[]),l.eventListeners[t].push(o));return l}_toKonvaCanvas(e){e=e||{};var t=this.getClientRect(),n=this.getStage(),a=void 0!==e.x?e.x:Math.floor(t.x),r=void 0!==e.y?e.y:Math.floor(t.y),o=e.pixelRatio||1,c=new Hse({width:e.width||Math.ceil(t.width)||(n?n.width():0),height:e.height||Math.ceil(t.height)||(n?n.height():0),pixelRatio:o}),l=c.getContext();return!1===e.imageSmoothingEnabled&&(l._context.imageSmoothingEnabled=!1),l.save(),(a||r)&&l.translate(-1*a,-1*r),this.drawScene(c),l.restore(),c}toCanvas(e){return this._toKonvaCanvas(e)._canvas}toDataURL(e){var t=(e=e||{}).mimeType||null,n=e.quality||null,a=this._toKonvaCanvas(e).toDataURL(t,n);return e.callback&&e.callback(a),a}toImage(e){return new Promise(((t,n)=>{try{const n=null==e?void 0:e.callback;n&&delete e.callback,ose._urlToImage(this.toDataURL(e),(function(e){t(e),null==n||n(e)}))}catch(e){n(e)}}))}toBlob(e){return new Promise(((t,n)=>{try{const n=null==e?void 0:e.callback;n&&delete e.callback,this.toCanvas(e).toBlob((e=>{t(e),null==n||n(e)}))}catch(e){n(e)}}))}setSize(e){return this.width(e.width),this.height(e.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():Kie.dragDistance}_off(e,t,n){var a,r,o,c=this.eventListeners[e];for(a=0;a<c.length;a++)if(r=c[a].name,o=c[a].handler,!("konva"===r&&"konva"!==t||t&&r!==t||n&&n!==o)){if(c.splice(a,1),0===c.length){delete this.eventListeners[e];break}a--}}_fireChangeEvent(e,t,n){this._fire(e+"Change",{oldVal:t,newVal:n})}addName(e){if(!this.hasName(e)){var t=this.name(),n=t?t+" "+e:e;this.name(n)}return this}hasName(e){if(!e)return!1;const t=this.name();return!!t&&-1!==(t||"").split(/\s/g).indexOf(e)}removeName(e){var t=(this.name()||"").split(/\s/g),n=t.indexOf(e);return-1!==n&&(t.splice(n,1),this.name(t.join(" "))),this}setAttr(e,t){var n=this["set"+ose._capitalize(e)];return ose._isFunction(n)?n.call(this,t):this._setAttr(e,t),this}_requestDraw(){if(Kie.autoDrawEnabled){const e=this.getLayer()||this.getStage();null==e||e.batchDraw()}}_setAttr(e,t){var n=this.attrs[e];(n!==t||ose.isObject(t))&&(null==t?delete this.attrs[e]:this.attrs[e]=t,this._shouldFireChangeEvents&&this._fireChangeEvent(e,n,t),this._requestDraw())}_setComponentAttr(e,t,n){var a;void 0!==n&&((a=this.attrs[e])||(this.attrs[e]=this.getAttr(e)),this.attrs[e][t]=n,this._fireChangeEvent(e,a,n))}_fireAndBubble(e,t,n){if(t&&this.nodeType===Rse&&(t.target=this),e!==Ose&&e!==Ase||!(n&&(this===n||this.isAncestorOf&&this.isAncestorOf(n))||"Stage"===this.nodeType&&!n)){this._fire(e,t);var a=(e===Ose||e===Ase)&&n&&n.isAncestorOf&&n.isAncestorOf(this)&&!n.isAncestorOf(this.parent);(t&&!t.cancelBubble||!t)&&this.parent&&this.parent.isListening()&&!a&&(n&&n.parent?this._fireAndBubble.call(this.parent,e,t,n):this._fireAndBubble.call(this.parent,e,t))}}_getProtoListeners(e){let t=this._cache.get(xse);if(!t){t={};let e=Object.getPrototypeOf(this);for(;e;)if(e.eventListeners){for(var n in e.eventListeners){const a=e.eventListeners[n],r=t[n]||[];t[n]=a.concat(r)}e=Object.getPrototypeOf(e)}else e=Object.getPrototypeOf(e);this._cache.set(xse,t)}return t[e]}_fire(e,t){(t=t||{}).currentTarget=this,t.type=e;const n=this._getProtoListeners(e);if(n)for(var a=0;a<n.length;a++)n[a].handler.call(this,t);const r=this.eventListeners[e];if(r)for(a=0;a<r.length;a++)r[a].handler.call(this,t)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(e){var t=e?e.pointerId:void 0,n=this.getStage(),a=this.getAbsolutePosition(),r=n._getPointerById(t)||n._changedPointerPositions[0]||a;Cse._dragElements.set(this._id,{node:this,startPointerPos:r,offset:{x:r.x-a.x,y:r.y-a.y},dragStatus:"ready",pointerId:t})}startDrag(e,t=!0){Cse._dragElements.has(this._id)||this._createDragElement(e),Cse._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:e&&e.evt},t)}_setDragPosition(e,t){const n=this.getStage()._getPointerById(t.pointerId);if(n){var a={x:n.x-t.offset.x,y:n.y-t.offset.y},r=this.dragBoundFunc();if(void 0!==r){const t=r.call(this,a,e);t?a=t:ose.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===a.x&&this._lastPos.y===a.y||(this.setAbsolutePosition(a),this._requestDraw()),this._lastPos=a}}stopDrag(e){const t=Cse._dragElements.get(this._id);t&&(t.dragStatus="stopped"),Cse._endDragBefore(e),Cse._endDragAfter(e)}setDraggable(e){this._setAttr("draggable",e),this._dragChange()}isDragging(){const e=Cse._dragElements.get(this._id);return!!e&&"dragging"===e.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",(function(e){if((void 0===e.evt.button||Kie.dragButtons.indexOf(e.evt.button)>=0)&&!this.isDragging()){var t=!1;Cse._dragElements.forEach((e=>{this.isAncestorOf(e.node)&&(t=!0)})),t||this._createDragElement(e)}}))}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;const e=Cse._dragElements.get(this._id),t=e&&"dragging"===e.dragStatus,n=e&&"ready"===e.dragStatus;t?this.stopDrag():n&&Cse._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(e={x:0,y:0}){const t=this.getStage();if(!t)return!1;const n={x:-e.x,y:-e.y,width:t.width()+2*e.x,height:t.height()+2*e.y};return ose.haveIntersection(n,this.getClientRect())}static create(e,t){return ose._isString(e)&&(e=JSON.parse(e)),this._createNode(e,t)}static _createNode(e,t){var n,a,r,o=jse.prototype.getClassName.call(e),c=e.children;if(t&&(e.attrs.container=t),Kie[o]||(ose.warn('Can not find a node with class name "'+o+'". Fallback to "Shape".'),o="Shape"),n=new Kie[o](e.attrs),c)for(a=c.length,r=0;r<a;r++)n.add(jse._createNode(c[r]));return n}}jse.prototype.nodeType="Node",jse.prototype._attrsAffectingSize=[],jse.prototype.eventListeners={},jse.prototype.on.call(jse.prototype,Fse,(function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(Dse),this._clearSelfAndDescendantCache(Sse))})),jse.prototype.on.call(jse.prototype,"visibleChange.konva",(function(){this._clearSelfAndDescendantCache(Pse)})),jse.prototype.on.call(jse.prototype,"listeningChange.konva",(function(){this._clearSelfAndDescendantCache(Tse)})),jse.prototype.on.call(jse.prototype,"opacityChange.konva",(function(){this._clearSelfAndDescendantCache(Lse)}));const Bse=fse.addGetterSetter;Bse(jse,"zIndex"),Bse(jse,"absolutePosition"),Bse(jse,"position"),Bse(jse,"x",0,ise()),Bse(jse,"y",0,ise()),Bse(jse,"globalCompositeOperation","source-over",dse()),Bse(jse,"opacity",1,ise()),Bse(jse,"name","",dse()),Bse(jse,"id","",dse()),Bse(jse,"rotation",0,ise()),fse.addComponentsGetterSetter(jse,"scale",["x","y"]),Bse(jse,"scaleX",1,ise()),Bse(jse,"scaleY",1,ise()),fse.addComponentsGetterSetter(jse,"skew",["x","y"]),Bse(jse,"skewX",0,ise()),Bse(jse,"skewY",0,ise()),fse.addComponentsGetterSetter(jse,"offset",["x","y"]),Bse(jse,"offsetX",0,ise()),Bse(jse,"offsetY",0,ise()),Bse(jse,"dragDistance",null,ise()),Bse(jse,"width",0,ise()),Bse(jse,"height",0,ise()),Bse(jse,"listening",!0,mse()),Bse(jse,"preventDefault",!0,mse()),Bse(jse,"filters",null,(function(e){return this._filterUpToDate=!1,e})),Bse(jse,"visible",!0,mse()),Bse(jse,"transformsEnabled","all",dse()),Bse(jse,"size"),Bse(jse,"dragBoundFunc"),Bse(jse,"draggable",!1,mse()),fse.backCompat(jse,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});class Use extends jse{constructor(){super(...arguments),this.children=[]}getChildren(e){if(!e)return this.children||[];const t=this.children||[];var n=[];return t.forEach((function(t){e(t)&&n.push(t)})),n}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach((e=>{e.parent=null,e.index=0,e.remove()})),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach((e=>{e.parent=null,e.index=0,e.destroy()})),this.children=[],this._requestDraw(),this}add(...e){if(0===e.length)return this;if(e.length>1){for(var t=0;t<e.length;t++)this.add(e[t]);return this}const n=e[0];return n.getParent()?(n.moveTo(this),this):(this._validateAdd(n),n.index=this.getChildren().length,n.parent=this,n._clearCaches(),this.getChildren().push(n),this._fire("add",{child:n}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(e){return this._generalFind(e,!1)}findOne(e){var t=this._generalFind(e,!0);return t.length>0?t[0]:void 0}_generalFind(e,t){var n=[];return this._descendants((a=>{const r=a._isMatch(e);return r&&n.push(a),!(!r||!t)})),n}_descendants(e){let t=!1;const n=this.getChildren();for(const a of n){if(t=e(a),t)return!0;if(a.hasChildren()&&(t=a._descendants(e),t))return!0}return!1}toObject(){var e=jse.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach((t=>{e.children.push(t.toObject())})),e}isAncestorOf(e){for(var t=e.getParent();t;){if(t._id===this._id)return!0;t=t.getParent()}return!1}clone(e){var t=jse.prototype.clone.call(this,e);return this.getChildren().forEach((function(e){t.add(e.clone())})),t}getAllIntersections(e){var t=[];return this.find("Shape").forEach((function(n){n.isVisible()&&n.intersects(e)&&t.push(n)})),t}_clearSelfAndDescendantCache(e){var t;super._clearSelfAndDescendantCache(e),this.isCached()||null===(t=this.children)||void 0===t||t.forEach((function(t){t._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;null===(e=this.children)||void 0===e||e.forEach((function(e,t){e.index=t})),this._requestDraw()}drawScene(e,t){var n=this.getLayer(),a=e||n&&n.getCanvas(),r=a&&a.getContext(),o=this._getCanvasCache(),c=o&&o.scene,l=a&&a.isCache;if(!this.isVisible()&&!l)return this;if(c){r.save();var i=this.getAbsoluteTransform(t).getMatrix();r.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this._drawCachedSceneCanvas(r),r.restore()}else this._drawChildren("drawScene",a,t);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;var n=this.getLayer(),a=e||n&&n.hitCanvas,r=a&&a.getContext(),o=this._getCanvasCache();if(o&&o.hit){r.save();var c=this.getAbsoluteTransform(t).getMatrix();r.transform(c[0],c[1],c[2],c[3],c[4],c[5]),this._drawCachedHitCanvas(r),r.restore()}else this._drawChildren("drawHit",a,t);return this}_drawChildren(e,t,n){var a,r=t&&t.getContext(),o=this.clipWidth(),c=this.clipHeight(),l=this.clipFunc(),i=o&&c||l;const s=n===this;if(i){r.save();var h=this.getAbsoluteTransform(n),d=h.getMatrix();if(r.transform(d[0],d[1],d[2],d[3],d[4],d[5]),r.beginPath(),l)l.call(this,r,this);else{var u=this.clipX(),m=this.clipY();r.rect(u,m,o,c)}r.clip(),d=h.copy().invert().getMatrix(),r.transform(d[0],d[1],d[2],d[3],d[4],d[5])}var p=!s&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===e;p&&(r.save(),r._applyGlobalCompositeOperation(this)),null===(a=this.children)||void 0===a||a.forEach((function(a){a[e](t,n)})),p&&r.restore(),i&&r.restore()}getClientRect(e){var t,n,a,r,o,c,l=(e=e||{}).skipTransform,i=e.relativeTo,s=this;null===(t=this.children)||void 0===t||t.forEach((function(t){if(t.visible()){var c=t.getClientRect({relativeTo:s,skipShadow:e.skipShadow,skipStroke:e.skipStroke});0===c.width&&0===c.height||(void 0===n?(n=c.x,a=c.y,r=c.x+c.width,o=c.y+c.height):(n=Math.min(n,c.x),a=Math.min(a,c.y),r=Math.max(r,c.x+c.width),o=Math.max(o,c.y+c.height)))}}));for(var h=this.find("Shape"),d=!1,u=0;u<h.length;u++)if(h[u]._isVisible(this)){d=!0;break}return c=d&&void 0!==n?{x:n,y:a,width:r-n,height:o-a}:{x:0,y:0,width:0,height:0},l?c:this._transformedRect(c,i)}}fse.addComponentsGetterSetter(Use,"clip",["x","y","width","height"]),fse.addGetterSetter(Use,"clipX",void 0,ise()),fse.addGetterSetter(Use,"clipY",void 0,ise()),fse.addGetterSetter(Use,"clipWidth",void 0,ise()),fse.addGetterSetter(Use,"clipHeight",void 0,ise()),fse.addGetterSetter(Use,"clipFunc");const Wse=new Map,$se=void 0!==Kie._global.PointerEvent;function qse(e){return Wse.get(e)}function Gse(e){return{evt:e,pointerId:e.pointerId}}function Yse(e,t){return Wse.get(e)===t}function Kse(e,t){Xse(e),t.getStage()&&(Wse.set(e,t),$se&&t._fire("gotpointercapture",Gse(new PointerEvent("gotpointercapture"))))}function Xse(e,t){const n=Wse.get(e);if(!n)return;const a=n.getStage();a&&a.content,Wse.delete(e),$se&&n._fire("lostpointercapture",Gse(new PointerEvent("lostpointercapture")))}var Qse="mouseleave",Jse="mouseover",Zse="mouseenter",ehe="mousemove",the="mousedown",nhe="mouseup",ahe="pointermove",rhe="pointerdown",ohe="pointerup",che="pointercancel",lhe="pointerout",ihe="pointerleave",she="pointerover",hhe="pointerenter",dhe="contextmenu",uhe="touchstart",mhe="touchend",phe="touchmove",vhe="touchcancel",fhe="wheel",zhe=[[Zse,"_pointerenter"],[the,"_pointerdown"],[ehe,"_pointermove"],[nhe,"_pointerup"],[Qse,"_pointerleave"],[uhe,"_pointerdown"],[phe,"_pointermove"],[mhe,"_pointerup"],[vhe,"_pointercancel"],[Jse,"_pointerover"],[fhe,"_wheel"],[dhe,"_contextmenu"],[rhe,"_pointerdown"],[ahe,"_pointermove"],[ohe,"_pointerup"],[che,"_pointercancel"],["lostpointercapture","_lostpointercapture"]];const ghe={mouse:{[lhe]:"mouseout",[ihe]:Qse,[she]:Jse,[hhe]:Zse,[ahe]:ehe,[rhe]:the,[ohe]:nhe,[che]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[lhe]:"touchout",[ihe]:"touchleave",[she]:"touchover",[hhe]:"touchenter",[ahe]:phe,[rhe]:uhe,[ohe]:mhe,[che]:vhe,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[lhe]:lhe,[ihe]:ihe,[she]:she,[hhe]:hhe,[ahe]:ahe,[rhe]:rhe,[ohe]:ohe,[che]:che,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},yhe=e=>e.indexOf("pointer")>=0?"pointer":e.indexOf("touch")>=0?"touch":"mouse",Mhe=e=>{const t=yhe(e);return"pointer"===t?Kie.pointerEventsEnabled&&ghe.pointer:"touch"===t?ghe.touch:"mouse"===t?ghe.mouse:void 0};function Ehe(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&&ose.warn("Stage does not support clipping. Please use clip for Layers or Groups."),e}const bhe=[];class Hhe extends Use{constructor(e){super(Ehe(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),bhe.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",(()=>{Ehe(this.attrs)})),this._checkVisibility()}_validateAdd(e){const t="Layer"===e.getType(),n="FastLayer"===e.getType();t||n||ose.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const e=this.visible()?"":"none";this.content.style.display=e}setContainer(e){if("string"==typeof e){if("."===e.charAt(0)){var t=e.slice(1);e=document.getElementsByClassName(t)[0]}else{var n;n="#"!==e.charAt(0)?e:e.slice(1),e=document.getElementById(n)}if(!e)throw"Can not find container in document with id "+n}return this._setAttr("container",e),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),e.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){var e,t=this.children,n=t.length;for(e=0;e<n;e++)t[e].clear();return this}clone(e){return e||(e={}),e.container="undefined"!=typeof document&&document.createElement("div"),Use.prototype.clone.call(this,e)}destroy(){super.destroy();var e=this.content;e&&ose._isInDocument(e)&&this.container().removeChild(e);var t=bhe.indexOf(this);return t>-1&&bhe.splice(t,1),ose.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(ose.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}_getPointerById(e){return this._pointerPositions.find((t=>t.id===e))}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(e){(e=e||{}).x=e.x||0,e.y=e.y||0,e.width=e.width||this.width(),e.height=e.height||this.height();var t=new Hse({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),n=t.getContext()._context,a=this.children;return(e.x||e.y)&&n.translate(-1*e.x,-1*e.y),a.forEach((function(t){if(t.isVisible()){var a=t._toKonvaCanvas(e);n.drawImage(a._canvas,e.x,e.y,a.getWidth()/a.getPixelRatio(),a.getHeight()/a.getPixelRatio())}})),t}getIntersection(e){if(!e)return null;var t,n=this.children;for(t=n.length-1;t>=0;t--){const a=n[t].getIntersection(e);if(a)return a}return null}_resizeDOM(){var e=this.width(),t=this.height();this.content&&(this.content.style.width=e+"px",this.content.style.height=t+"px"),this.bufferCanvas.setSize(e,t),this.bufferHitCanvas.setSize(e,t),this.children.forEach((n=>{n.setSize({width:e,height:t}),n.draw()}))}add(e,...t){if(arguments.length>1){for(var n=0;n<arguments.length;n++)this.add(arguments[n]);return this}super.add(e);var a=this.children.length;return a>5&&ose.warn("The stage has "+a+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),e.setSize({width:this.width(),height:this.height()}),e.draw(),Kie.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return Yse(e,this)}setPointerCapture(e){Kse(e,this)}releaseCapture(e){Xse(e)}getLayers(){return this.children}_bindContentEvents(){Kie.isBrowser&&zhe.forEach((([e,t])=>{this.content.addEventListener(e,(e=>{this[t](e)}),{passive:!1})}))}_pointerenter(e){this.setPointersPositions(e);const t=Mhe(e.type);this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);const t=Mhe(e.type);this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_getTargetShape(e){let t=this[e+"targetShape"];return t&&!t.getStage()&&(t=null),t}_pointerleave(e){const t=Mhe(e.type),n=yhe(e.type);if(t){this.setPointersPositions(e);var a=this._getTargetShape(n),r=!Cse.isDragging||Kie.hitOnDragEnabled;a&&r?(a._fireAndBubble(t.pointerout,{evt:e}),a._fireAndBubble(t.pointerleave,{evt:e}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this[n+"targetShape"]=null):r&&(this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(t.pointerout,{evt:e,target:this,currentTarget:this})),this.pointerPos=void 0,this._pointerPositions=[]}}_pointerdown(e){const t=Mhe(e.type),n=yhe(e.type);if(t){this.setPointersPositions(e);var a=!1;this._changedPointerPositions.forEach((r=>{var o=this.getIntersection(r);if(Cse.justDragged=!1,Kie["_"+n+"ListenClick"]=!0,!o||!o.isListening())return;Kie.capturePointerEventsEnabled&&o.setPointerCapture(r.id),this[n+"ClickStartShape"]=o,o._fireAndBubble(t.pointerdown,{evt:e,pointerId:r.id}),a=!0;const c=e.type.indexOf("touch")>=0;o.preventDefault()&&e.cancelable&&c&&e.preventDefault()})),a||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}_pointermove(e){const t=Mhe(e.type),n=yhe(e.type);if(!t)return;if(Cse.isDragging&&Cse.node.preventDefault()&&e.cancelable&&e.preventDefault(),this.setPointersPositions(e),Cse.isDragging&&!Kie.hitOnDragEnabled)return;var a={};let r=!1;var o=this._getTargetShape(n);this._changedPointerPositions.forEach((c=>{const l=qse(c.id)||this.getIntersection(c),i=c.id,s={evt:e,pointerId:i};var h=o!==l;if(h&&o&&(o._fireAndBubble(t.pointerout,Object.assign({},s),l),o._fireAndBubble(t.pointerleave,Object.assign({},s),l)),l){if(a[l._id])return;a[l._id]=!0}l&&l.isListening()?(r=!0,h&&(l._fireAndBubble(t.pointerover,Object.assign({},s),o),l._fireAndBubble(t.pointerenter,Object.assign({},s),o),this[n+"targetShape"]=l),l._fireAndBubble(t.pointermove,Object.assign({},s))):o&&(this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:i}),this[n+"targetShape"]=null)})),r||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){const t=Mhe(e.type),n=yhe(e.type);if(!t)return;this.setPointersPositions(e);const a=this[n+"ClickStartShape"],r=this[n+"ClickEndShape"];var o={};let c=!1;this._changedPointerPositions.forEach((l=>{const i=qse(l.id)||this.getIntersection(l);if(i){if(i.releaseCapture(l.id),o[i._id])return;o[i._id]=!0}const s=l.id,h={evt:e,pointerId:s};let d=!1;Kie["_"+n+"InDblClickWindow"]?(d=!0,clearTimeout(this[n+"DblTimeout"])):Cse.justDragged||(Kie["_"+n+"InDblClickWindow"]=!0,clearTimeout(this[n+"DblTimeout"])),this[n+"DblTimeout"]=setTimeout((function(){Kie["_"+n+"InDblClickWindow"]=!1}),Kie.dblClickWindow),i&&i.isListening()?(c=!0,this[n+"ClickEndShape"]=i,i._fireAndBubble(t.pointerup,Object.assign({},h)),Kie["_"+n+"ListenClick"]&&a&&a===i&&(i._fireAndBubble(t.pointerclick,Object.assign({},h)),d&&r&&r===i&&i._fireAndBubble(t.pointerdblclick,Object.assign({},h)))):(this[n+"ClickEndShape"]=null,Kie["_"+n+"ListenClick"]&&this._fire(t.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:s}),d&&this._fire(t.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:s}))})),c||this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),Kie["_"+n+"ListenClick"]=!1,e.cancelable&&"touch"!==n&&e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);var t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(dhe,{evt:e}):this._fire(dhe,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);var t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(fhe,{evt:e}):this._fire(fhe,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);const t=qse(e.pointerId)||this.getIntersection(this.getPointerPosition());t&&t._fireAndBubble(ohe,Gse(e)),Xse(e.pointerId)}_lostpointercapture(e){Xse(e.pointerId)}setPointersPositions(e){var t=this._getContentPosition(),n=null,a=null;void 0!==(e=e||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(e.touches,(e=>{this._pointerPositions.push({id:e.identifier,x:(e.clientX-t.left)/t.scaleX,y:(e.clientY-t.top)/t.scaleY})})),Array.prototype.forEach.call(e.changedTouches||e.touches,(e=>{this._changedPointerPositions.push({id:e.identifier,x:(e.clientX-t.left)/t.scaleX,y:(e.clientY-t.top)/t.scaleY})}))):(n=(e.clientX-t.left)/t.scaleX,a=(e.clientY-t.top)/t.scaleY,this.pointerPos={x:n,y:a},this._pointerPositions=[{x:n,y:a,id:ose._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:a,id:ose._getFirstPointerId(e)}])}_setPointerPosition(e){ose.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(e)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};var e=this.content.getBoundingClientRect();return{top:e.top,left:e.left,scaleX:e.width/this.content.clientWidth||1,scaleY:e.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new Hse({width:this.width(),height:this.height()}),this.bufferHitCanvas=new Vse({pixelRatio:1,width:this.width(),height:this.height()}),Kie.isBrowser){var e=this.container();if(!e)throw"Stage has no container. A container is required.";e.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),e.appendChild(this.content),this._resizeDOM()}}cache(){return ose.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach((function(e){e.batchDraw()})),this}}Hhe.prototype.nodeType="Stage",Xie(Hhe),fse.addGetterSetter(Hhe,"container");var Vhe="hasShadow",Che="shadowRGBA",Lhe="patternImage",xhe="linearGradient",She="radialGradient";let khe;function whe(){return khe||(khe=ose.createCanvasElement().getContext("2d"),khe)}const The={};class Ohe extends jse{constructor(e){let t;for(super(e);t=ose.getRandomColor(),!t||t in The;);this.colorKey=t,The[t]=this}getContext(){return ose.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return ose.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(Vhe,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(Lhe,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const e=whe().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(e&&e.setTransform){const t=new Qie;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(Kie.getAngle(this.fillPatternRotation())),t.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),t.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const n=t.getMatrix(),a="undefined"==typeof DOMMatrix?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);e.setTransform(a)}return e}}_getLinearGradient(){return this._getCache(xhe,this.__getLinearGradient)}__getLinearGradient(){var e=this.fillLinearGradientColorStops();if(e){for(var t=whe(),n=this.fillLinearGradientStartPoint(),a=this.fillLinearGradientEndPoint(),r=t.createLinearGradient(n.x,n.y,a.x,a.y),o=0;o<e.length;o+=2)r.addColorStop(e[o],e[o+1]);return r}}_getRadialGradient(){return this._getCache(She,this.__getRadialGradient)}__getRadialGradient(){var e=this.fillRadialGradientColorStops();if(e){for(var t=whe(),n=this.fillRadialGradientStartPoint(),a=this.fillRadialGradientEndPoint(),r=t.createRadialGradient(n.x,n.y,this.fillRadialGradientStartRadius(),a.x,a.y,this.fillRadialGradientEndRadius()),o=0;o<e.length;o+=2)r.addColorStop(e[o],e[o+1]);return r}}getShadowRGBA(){return this._getCache(Che,this._getShadowRGBA)}_getShadowRGBA(){if(this.hasShadow()){var e=ose.colorToRGBA(this.shadowColor());return e?"rgba("+e.r+","+e.g+","+e.b+","+e.a*(this.shadowOpacity()||1)+")":void 0}}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],(()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops())))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],(()=>this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops())))}hasHitStroke(){const e=this.hitStrokeWidth();return"auto"===e?this.hasStroke():this.strokeEnabled()&&!!e}intersects(e){var t=this.getStage().bufferHitCanvas;return t.getContext().clear(),this.drawHit(t,null,!0),t.context.getImageData(Math.round(e.x),Math.round(e.y),1,1).data[3]>0}destroy(){return jse.prototype.destroy.call(this),delete The[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e){var t;if(!this.getStage())return!1;if(null!==(t=this.attrs.perfectDrawEnabled)&&void 0!==t&&!t)return!1;const n=e||this.hasFill(),a=this.hasStroke(),r=1!==this.getAbsoluteOpacity();if(n&&a&&r)return!0;const o=this.hasShadow(),c=this.shadowForStrokeEnabled();return!!(n&&a&&o&&c)}setStrokeHitEnabled(e){ose.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),e?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){var e=this.size();return{x:this._centroid?-e.width/2:0,y:this._centroid?-e.height/2:0,width:e.width,height:e.height}}getClientRect(e={}){const t=e.skipTransform,n=e.relativeTo,a=this.getSelfRect(),r=!e.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=a.width+r,c=a.height+r,l=!e.skipShadow&&this.hasShadow(),i=l?this.shadowOffsetX():0,s=l?this.shadowOffsetY():0,h=o+Math.abs(i),d=c+Math.abs(s),u=l&&this.shadowBlur()||0,m={width:h+2*u,height:d+2*u,x:-(r/2+u)+Math.min(i,0)+a.x,y:-(r/2+u)+Math.min(s,0)+a.y};return t?m:this._transformedRect(m,n)}drawScene(e,t){var n,a,r=this.getLayer(),o=e||r.getCanvas(),c=o.getContext(),l=this._getCanvasCache(),i=this.getSceneFunc(),s=this.hasShadow(),h=o.isCache,d=t===this;if(!this.isVisible()&&!d)return this;if(l){c.save();var u=this.getAbsoluteTransform(t).getMatrix();return c.transform(u[0],u[1],u[2],u[3],u[4],u[5]),this._drawCachedSceneCanvas(c),c.restore(),this}if(!i)return this;if(c.save(),this._useBufferCanvas()&&!h){(a=(n=this.getStage().bufferCanvas).getContext()).clear(),a.save(),a._applyLineJoin(this);var m=this.getAbsoluteTransform(t).getMatrix();a.transform(m[0],m[1],m[2],m[3],m[4],m[5]),i.call(this,a,this),a.restore();var p=n.pixelRatio;s&&c._applyShadow(this),c._applyOpacity(this),c._applyGlobalCompositeOperation(this),c.drawImage(n._canvas,0,0,n.width/p,n.height/p)}else c._applyLineJoin(this),d||(m=this.getAbsoluteTransform(t).getMatrix(),c.transform(m[0],m[1],m[2],m[3],m[4],m[5]),c._applyOpacity(this),c._applyGlobalCompositeOperation(this)),s&&c._applyShadow(this),i.call(this,c,this);return c.restore(),this}drawHit(e,t,n=!1){if(!this.shouldDrawHit(t,n))return this;var a=this.getLayer(),r=e||a.hitCanvas,o=r&&r.getContext(),c=this.hitFunc()||this.sceneFunc(),l=this._getCanvasCache(),i=l&&l.hit;if(this.colorKey||ose.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),i){o.save();var s=this.getAbsoluteTransform(t).getMatrix();return o.transform(s[0],s[1],s[2],s[3],s[4],s[5]),this._drawCachedHitCanvas(o),o.restore(),this}if(!c)return this;if(o.save(),o._applyLineJoin(this),this!==t){var h=this.getAbsoluteTransform(t).getMatrix();o.transform(h[0],h[1],h[2],h[3],h[4],h[5])}return c.call(this,o,this),o.restore(),this}drawHitFromCache(e=0){var t,n,a,r,o,c=this._getCanvasCache(),l=this._getCachedSceneCanvas(),i=c.hit,s=i.getContext(),h=i.getWidth(),d=i.getHeight();s.clear(),s.drawImage(l._canvas,0,0,h,d);try{for(a=(n=(t=s.getImageData(0,0,h,d)).data).length,r=ose._hexToRgb(this.colorKey),o=0;o<a;o+=4)n[o+3]>e?(n[o]=r.r,n[o+1]=r.g,n[o+2]=r.b,n[o+3]=255):n[o+3]=0;s.putImageData(t,0,0)}catch(e){ose.error("Unable to draw hit graph from cached scene canvas. "+e.message)}return this}hasPointerCapture(e){return Yse(e,this)}setPointerCapture(e){Kse(e,this)}releaseCapture(e){Xse(e)}}Ohe.prototype._fillFunc=function(e){e.fill()},Ohe.prototype._strokeFunc=function(e){e.stroke()},Ohe.prototype._fillFuncHit=function(e){e.fill()},Ohe.prototype._strokeFuncHit=function(e){e.stroke()},Ohe.prototype._centroid=!1,Ohe.prototype.nodeType="Shape",Xie(Ohe),Ohe.prototype.eventListeners={},Ohe.prototype.on.call(Ohe.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(Vhe)})),Ohe.prototype.on.call(Ohe.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(Che)})),Ohe.prototype.on.call(Ohe.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",(function(){this._clearCache(Lhe)})),Ohe.prototype.on.call(Ohe.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",(function(){this._clearCache(xhe)})),Ohe.prototype.on.call(Ohe.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",(function(){this._clearCache(She)})),fse.addGetterSetter(Ohe,"stroke",void 0,use()),fse.addGetterSetter(Ohe,"strokeWidth",2,ise()),fse.addGetterSetter(Ohe,"fillAfterStrokeEnabled",!1),fse.addGetterSetter(Ohe,"hitStrokeWidth","auto",hse()),fse.addGetterSetter(Ohe,"strokeHitEnabled",!0,mse()),fse.addGetterSetter(Ohe,"perfectDrawEnabled",!0,mse()),fse.addGetterSetter(Ohe,"shadowForStrokeEnabled",!0,mse()),fse.addGetterSetter(Ohe,"lineJoin"),fse.addGetterSetter(Ohe,"lineCap"),fse.addGetterSetter(Ohe,"sceneFunc"),fse.addGetterSetter(Ohe,"hitFunc"),fse.addGetterSetter(Ohe,"dash"),fse.addGetterSetter(Ohe,"dashOffset",0,ise()),fse.addGetterSetter(Ohe,"shadowColor",void 0,dse()),fse.addGetterSetter(Ohe,"shadowBlur",0,ise()),fse.addGetterSetter(Ohe,"shadowOpacity",1,ise()),fse.addComponentsGetterSetter(Ohe,"shadowOffset",["x","y"]),fse.addGetterSetter(Ohe,"shadowOffsetX",0,ise()),fse.addGetterSetter(Ohe,"shadowOffsetY",0,ise()),fse.addGetterSetter(Ohe,"fillPatternImage"),fse.addGetterSetter(Ohe,"fill",void 0,use()),fse.addGetterSetter(Ohe,"fillPatternX",0,ise()),fse.addGetterSetter(Ohe,"fillPatternY",0,ise()),fse.addGetterSetter(Ohe,"fillLinearGradientColorStops"),fse.addGetterSetter(Ohe,"strokeLinearGradientColorStops"),fse.addGetterSetter(Ohe,"fillRadialGradientStartRadius",0),fse.addGetterSetter(Ohe,"fillRadialGradientEndRadius",0),fse.addGetterSetter(Ohe,"fillRadialGradientColorStops"),fse.addGetterSetter(Ohe,"fillPatternRepeat","repeat"),fse.addGetterSetter(Ohe,"fillEnabled",!0),fse.addGetterSetter(Ohe,"strokeEnabled",!0),fse.addGetterSetter(Ohe,"shadowEnabled",!0),fse.addGetterSetter(Ohe,"dashEnabled",!0),fse.addGetterSetter(Ohe,"strokeScaleEnabled",!0),fse.addGetterSetter(Ohe,"fillPriority","color"),fse.addComponentsGetterSetter(Ohe,"fillPatternOffset",["x","y"]),fse.addGetterSetter(Ohe,"fillPatternOffsetX",0,ise()),fse.addGetterSetter(Ohe,"fillPatternOffsetY",0,ise()),fse.addComponentsGetterSetter(Ohe,"fillPatternScale",["x","y"]),fse.addGetterSetter(Ohe,"fillPatternScaleX",1,ise()),fse.addGetterSetter(Ohe,"fillPatternScaleY",1,ise()),fse.addComponentsGetterSetter(Ohe,"fillLinearGradientStartPoint",["x","y"]),fse.addComponentsGetterSetter(Ohe,"strokeLinearGradientStartPoint",["x","y"]),fse.addGetterSetter(Ohe,"fillLinearGradientStartPointX",0),fse.addGetterSetter(Ohe,"strokeLinearGradientStartPointX",0),fse.addGetterSetter(Ohe,"fillLinearGradientStartPointY",0),fse.addGetterSetter(Ohe,"strokeLinearGradientStartPointY",0),fse.addComponentsGetterSetter(Ohe,"fillLinearGradientEndPoint",["x","y"]),fse.addComponentsGetterSetter(Ohe,"strokeLinearGradientEndPoint",["x","y"]),fse.addGetterSetter(Ohe,"fillLinearGradientEndPointX",0),fse.addGetterSetter(Ohe,"strokeLinearGradientEndPointX",0),fse.addGetterSetter(Ohe,"fillLinearGradientEndPointY",0),fse.addGetterSetter(Ohe,"strokeLinearGradientEndPointY",0),fse.addComponentsGetterSetter(Ohe,"fillRadialGradientStartPoint",["x","y"]),fse.addGetterSetter(Ohe,"fillRadialGradientStartPointX",0),fse.addGetterSetter(Ohe,"fillRadialGradientStartPointY",0),fse.addComponentsGetterSetter(Ohe,"fillRadialGradientEndPoint",["x","y"]),fse.addGetterSetter(Ohe,"fillRadialGradientEndPointX",0),fse.addGetterSetter(Ohe,"fillRadialGradientEndPointY",0),fse.addGetterSetter(Ohe,"fillPatternRotation",0),fse.backCompat(Ohe,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});var Ahe=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],Rhe=Ahe.length;class Nhe extends Use{constructor(e){super(e),this.canvas=new Hse,this.hitCanvas=new Vse({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);var t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),e<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[e+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){jse.prototype.moveToTop.call(this);var e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!jse.prototype.moveUp.call(this))return!1;var e=this.getStage();return!(!e||!e.content||(e.content.removeChild(this.getNativeCanvasElement()),this.index<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[this.index+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement()),0))}moveDown(){if(jse.prototype.moveDown.call(this)){var e=this.getStage();if(e){var t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(jse.prototype.moveToBottom.call(this)){var e=this.getStage();if(e){var t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){var e=this.getNativeCanvasElement();return jse.prototype.remove.call(this),e&&e.parentNode&&ose._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:e,height:t}){return this.canvas.setSize(e,t),this.hitCanvas.setSize(e,t),this._setSmoothEnabled(),this}_validateAdd(e){var t=e.getType();"Group"!==t&&"Shape"!==t&&ose.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(e){return(e=e||{}).width=e.width||this.getWidth(),e.height=e.height||this.getHeight(),e.x=void 0!==e.x?e.x:this.x(),e.y=void 0!==e.y?e.y:this.y(),jse.prototype._toKonvaCanvas.call(this,e)}_checkVisibility(){const e=this.visible();this.canvas._canvas.style.display=e?"block":"none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){ose.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){ose.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,ose.requestAnimFrame((()=>{this.draw(),this._waitingForDraw=!1}))),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;for(var t=1,n=!1;;){for(let a=0;a<Rhe;a++){const r=Ahe[a],o=this._getIntersection({x:e.x+r.x*t,y:e.y+r.y*t}),c=o.shape;if(c)return c;if(n=!!o.antialiased,!o.antialiased)break}if(!n)return null;t+=1}}_getIntersection(e){const t=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.round(e.x*t),Math.round(e.y*t),1,1).data,a=n[3];if(255===a){const e=ose._rgbToHex(n[0],n[1],n[2]),t=The["#"+e];return t?{shape:t}:{antialiased:!0}}return a>0?{antialiased:!0}:{}}drawScene(e,t){var n=this.getLayer(),a=e||n&&n.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&a.getContext().clear(),Use.prototype.drawScene.call(this,a,t),this._fire("draw",{node:this}),this}drawHit(e,t){var n=this.getLayer(),a=e||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),Use.prototype.drawHit.call(this,a,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){ose.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return ose.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(this.parent&&this.parent.content){var e=this.parent;this.hitCanvas._canvas.parentNode?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}}destroy(){return ose.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}Nhe.prototype.nodeType="Layer",Xie(Nhe),fse.addGetterSetter(Nhe,"imageSmoothingEnabled",!0),fse.addGetterSetter(Nhe,"clearBeforeDraw",!0),fse.addGetterSetter(Nhe,"hitGraphEnabled",!0,mse());class _he extends Nhe{constructor(e){super(e),this.listening(!1),ose.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}_he.prototype.nodeType="FastLayer",Xie(_he);class Dhe extends Use{_validateAdd(e){var t=e.getType();"Group"!==t&&"Shape"!==t&&ose.throw("You may only add groups and shapes to groups.")}}Dhe.prototype.nodeType="Group",Xie(Dhe);var Phe=Yie.performance&&Yie.performance.now?function(){return Yie.performance.now()}:function(){return(new Date).getTime()};class Fhe{constructor(e,t){this.id=Fhe.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:Phe(),frameRate:0},this.func=e,this.setLayers(t)}setLayers(e){var t;return t=e?e.length>0?e:[e]:[],this.layers=t,this}getLayers(){return this.layers}addLayer(e){var t,n=this.layers,a=n.length;for(t=0;t<a;t++)if(n[t]._id===e._id)return!1;return this.layers.push(e),!0}isRunning(){var e,t=Fhe.animations,n=t.length;for(e=0;e<n;e++)if(t[e].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=Phe(),Fhe._addAnimation(this),this}stop(){return Fhe._removeAnimation(this),this}_updateFrameObject(e){this.frame.timeDiff=e-this.frame.lastTime,this.frame.lastTime=e,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(e){this.animations.push(e),this._handleAnimation()}static _removeAnimation(e){var t,n=e.id,a=this.animations,r=a.length;for(t=0;t<r;t++)if(a[t].id===n){this.animations.splice(t,1);break}}static _runFrames(){var e,t,n,a,r,o,c,l,i={},s=this.animations;for(a=0;a<s.length;a++)if(t=(e=s[a]).layers,n=e.func,e._updateFrameObject(Phe()),o=t.length,!n||!1!==n.call(e,e.frame))for(r=0;r<o;r++)void 0!==(c=t[r])._id&&(i[c._id]=c);for(l in i)i.hasOwnProperty(l)&&i[l].batchDraw()}static _animationLoop(){var e=Fhe;e.animations.length?(e._runFrames(),ose.requestAnimFrame(e._animationLoop)):e.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,ose.requestAnimFrame(this._animationLoop))}}Fhe.animations=[],Fhe.animIdCounter=0,Fhe.animRunning=!1;var Ihe={node:1,duration:1,easing:1,onFinish:1,yoyo:1},jhe=0,Bhe=["fill","stroke","shadowColor"];class Uhe{constructor(e,t,n,a,r,o,c){this.prop=e,this.propFunc=t,this.begin=a,this._pos=a,this.duration=o,this._change=0,this.prevPos=0,this.yoyo=c,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=r-this.begin,this.pause()}fire(e){var t=this[e];t&&t()}setTime(e){e>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():e<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=e,this.update())}getTime(){return this._time}setPosition(e){this.prevPos=this._pos,this.propFunc(e),this._pos=e}getPosition(e){return void 0===e&&(e=this._time),this.func(e,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(e){this.pause(),this._time=e,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){var e=this.getTimer()-this._startTime;2===this.state?this.setTime(e):3===this.state&&this.setTime(this.duration-e)}pause(){this.state=1,this.fire("onPause")}getTimer(){return(new Date).getTime()}}class Whe{constructor(e){var t,n,a=this,r=e.node,o=r._id,c=e.easing||$he.Linear,l=!!e.yoyo;t=void 0===e.duration?.3:0===e.duration?.001:e.duration,this.node=r,this._id=jhe++;var i=r.getLayer()||(r instanceof Kie.Stage?r.getLayers():null);for(n in i||ose.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new Fhe((function(){a.tween.onEnterFrame()}),i),this.tween=new Uhe(n,(function(e){a._tweenFunc(e)}),c,0,1,1e3*t,l),this._addListeners(),Whe.attrs[o]||(Whe.attrs[o]={}),Whe.attrs[o][this._id]||(Whe.attrs[o][this._id]={}),Whe.tweens[o]||(Whe.tweens[o]={}),e)void 0===Ihe[n]&&this._addAttr(n,e[n]);this.reset(),this.onFinish=e.onFinish,this.onReset=e.onReset,this.onUpdate=e.onUpdate}_addAttr(e,t){var n,a,r,o,c,l,i,s,h=this.node,d=h._id;if((r=Whe.tweens[d][e])&&delete Whe.attrs[d][r][e],n=h.getAttr(e),ose._isArray(t))if(a=[],c=Math.max(t.length,n.length),"points"===e&&t.length!==n.length&&(t.length>n.length?(i=n,n=ose._prepareArrayForTween(n,t,h.closed())):(l=t,t=ose._prepareArrayForTween(t,n,h.closed()))),0===e.indexOf("fill"))for(o=0;o<c;o++)if(o%2==0)a.push(t[o]-n[o]);else{var u=ose.colorToRGBA(n[o]);s=ose.colorToRGBA(t[o]),n[o]=u,a.push({r:s.r-u.r,g:s.g-u.g,b:s.b-u.b,a:s.a-u.a})}else for(o=0;o<c;o++)a.push(t[o]-n[o]);else-1!==Bhe.indexOf(e)?(n=ose.colorToRGBA(n),a={r:(s=ose.colorToRGBA(t)).r-n.r,g:s.g-n.g,b:s.b-n.b,a:s.a-n.a}):a=t-n;Whe.attrs[d][this._id][e]={start:n,diff:a,end:t,trueEnd:l,trueStart:i},Whe.tweens[d][e]=this._id}_tweenFunc(e){var t,n,a,r,o,c,l,i,s=this.node,h=Whe.attrs[s._id][this._id];for(t in h){if(a=(n=h[t]).start,r=n.diff,i=n.end,ose._isArray(a))if(o=[],l=Math.max(a.length,i.length),0===t.indexOf("fill"))for(c=0;c<l;c++)c%2==0?o.push((a[c]||0)+r[c]*e):o.push("rgba("+Math.round(a[c].r+r[c].r*e)+","+Math.round(a[c].g+r[c].g*e)+","+Math.round(a[c].b+r[c].b*e)+","+(a[c].a+r[c].a*e)+")");else for(c=0;c<l;c++)o.push((a[c]||0)+r[c]*e);else o=-1!==Bhe.indexOf(t)?"rgba("+Math.round(a.r+r.r*e)+","+Math.round(a.g+r.g*e)+","+Math.round(a.b+r.b*e)+","+(a.a+r.a*e)+")":a+r*e;s.setAttr(t,o)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{var e=this.node,t=Whe.attrs[e._id][this._id];t.points&&t.points.trueEnd&&e.setAttr("points",t.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{var e=this.node,t=Whe.attrs[e._id][this._id];t.points&&t.points.trueStart&&e.points(t.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(e){return this.tween.seek(1e3*e),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){var e,t=this.node._id,n=this._id,a=Whe.tweens[t];for(e in this.pause(),a)delete Whe.tweens[t][e];delete Whe.attrs[t][n]}}Whe.attrs={},Whe.tweens={},jse.prototype.to=function(e){var t=e.onFinish;e.node=this,e.onFinish=function(){this.destroy(),t&&t()},new Whe(e).play()};const $he={BackEaseIn(e,t,n,a){var r=1.70158;return n*(e/=a)*e*((r+1)*e-r)+t},BackEaseOut(e,t,n,a){var r=1.70158;return n*((e=e/a-1)*e*((r+1)*e+r)+1)+t},BackEaseInOut(e,t,n,a){var r=1.70158;return(e/=a/2)<1?n/2*(e*e*((1+(r*=1.525))*e-r))+t:n/2*((e-=2)*e*((1+(r*=1.525))*e+r)+2)+t},ElasticEaseIn(e,t,n,a,r,o){var c=0;return 0===e?t:1==(e/=a)?t+n:(o||(o=.3*a),!r||r<Math.abs(n)?(r=n,c=o/4):c=o/(2*Math.PI)*Math.asin(n/r),-r*Math.pow(2,10*(e-=1))*Math.sin((e*a-c)*(2*Math.PI)/o)+t)},ElasticEaseOut(e,t,n,a,r,o){var c=0;return 0===e?t:1==(e/=a)?t+n:(o||(o=.3*a),!r||r<Math.abs(n)?(r=n,c=o/4):c=o/(2*Math.PI)*Math.asin(n/r),r*Math.pow(2,-10*e)*Math.sin((e*a-c)*(2*Math.PI)/o)+n+t)},ElasticEaseInOut(e,t,n,a,r,o){var c=0;return 0===e?t:2==(e/=a/2)?t+n:(o||(o=a*(.3*1.5)),!r||r<Math.abs(n)?(r=n,c=o/4):c=o/(2*Math.PI)*Math.asin(n/r),e<1?r*Math.pow(2,10*(e-=1))*Math.sin((e*a-c)*(2*Math.PI)/o)*-.5+t:r*Math.pow(2,-10*(e-=1))*Math.sin((e*a-c)*(2*Math.PI)/o)*.5+n+t)},BounceEaseOut:(e,t,n,a)=>(e/=a)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t,BounceEaseIn:(e,t,n,a)=>n-$he.BounceEaseOut(a-e,0,n,a)+t,BounceEaseInOut:(e,t,n,a)=>e<a/2?.5*$he.BounceEaseIn(2*e,0,n,a)+t:.5*$he.BounceEaseOut(2*e-a,0,n,a)+.5*n+t,EaseIn:(e,t,n,a)=>n*(e/=a)*e+t,EaseOut:(e,t,n,a)=>-n*(e/=a)*(e-2)+t,EaseInOut:(e,t,n,a)=>(e/=a/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t,StrongEaseIn:(e,t,n,a)=>n*(e/=a)*e*e*e*e+t,StrongEaseOut:(e,t,n,a)=>n*((e=e/a-1)*e*e*e*e+1)+t,StrongEaseInOut:(e,t,n,a)=>(e/=a/2)<1?n/2*e*e*e*e*e+t:n/2*((e-=2)*e*e*e*e+2)+t,Linear:(e,t,n,a)=>n*e/a+t},qhe=ose._assign(Kie,{Util:ose,Transform:Qie,Node:jse,Container:Use,Stage:Hhe,stages:bhe,Layer:Nhe,FastLayer:_he,Group:Dhe,DD:Cse,Shape:Ohe,shapes:The,Animation:Fhe,Tween:Whe,Easings:$he,Context:yse,Canvas:bse});class Ghe extends Ohe{_sceneFunc(e){var t=Kie.getAngle(this.angle()),n=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,t,n),e.arc(0,0,this.innerRadius(),t,0,!n),e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){const e=this.innerRadius(),t=this.outerRadius(),n=this.clockwise(),a=Kie.getAngle(n?360-this.angle():this.angle()),r=Math.cos(Math.min(a,Math.PI)),o=Math.sin(Math.min(Math.max(Math.PI,a),3*Math.PI/2)),c=Math.sin(Math.min(a,Math.PI/2)),l=r*(r>0?e:t),i=o*(o>0?e:t),s=c*(c>0?t:e);return{x:l,y:n?-1*s:i,width:1*t-l,height:s-i}}}function Yhe(e,t,n,a,r,o,c){var l=Math.sqrt(Math.pow(n-e,2)+Math.pow(a-t,2)),i=Math.sqrt(Math.pow(r-n,2)+Math.pow(o-a,2)),s=c*l/(l+i),h=c*i/(l+i);return[n-s*(r-e),a-s*(o-t),n+h*(r-e),a+h*(o-t)]}function Khe(e,t){var n,a,r=e.length,o=[];for(n=2;n<r-2;n+=2)a=Yhe(e[n-2],e[n-1],e[n],e[n+1],e[n+2],e[n+3],t),isNaN(a[0])||(o.push(a[0]),o.push(a[1]),o.push(e[n]),o.push(e[n+1]),o.push(a[2]),o.push(a[3]));return o}Ghe.prototype._centroid=!0,Ghe.prototype.className="Arc",Ghe.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Xie(Ghe),fse.addGetterSetter(Ghe,"innerRadius",0,ise()),fse.addGetterSetter(Ghe,"outerRadius",0,ise()),fse.addGetterSetter(Ghe,"angle",0,ise()),fse.addGetterSetter(Ghe,"clockwise",!1,mse());class Xhe extends Ohe{constructor(e){super(e),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",(function(){this._clearCache("tensionPoints")}))}_sceneFunc(e){var t,n,a,r=this.points(),o=r.length,c=this.tension(),l=this.closed(),i=this.bezier();if(o){if(e.beginPath(),e.moveTo(r[0],r[1]),0!==c&&o>4){for(n=(t=this.getTensionPoints()).length,a=l?0:4,l||e.quadraticCurveTo(t[0],t[1],t[2],t[3]);a<n-2;)e.bezierCurveTo(t[a++],t[a++],t[a++],t[a++],t[a++],t[a++]);l||e.quadraticCurveTo(t[n-2],t[n-1],r[o-2],r[o-1])}else if(i)for(a=2;a<o;)e.bezierCurveTo(r[a++],r[a++],r[a++],r[a++],r[a++],r[a++]);else for(a=2;a<o;a+=2)e.lineTo(r[a],r[a+1]);l?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():Khe(this.points(),this.tension())}_getTensionPointsClosed(){var e=this.points(),t=e.length,n=this.tension(),a=Yhe(e[t-2],e[t-1],e[0],e[1],e[2],e[3],n),r=Yhe(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],n),o=Khe(e,n);return[a[2],a[3]].concat(o).concat([r[0],r[1],e[t-2],e[t-1],r[2],r[3],a[0],a[1],e[0],e[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){var e=this.points();if(e.length<4)return{x:e[0]||0,y:e[1]||0,width:0,height:0};for(var t,n,a=(e=0!==this.tension()?[e[0],e[1],...this._getTensionPoints(),e[e.length-2],e[e.length-1]]:this.points())[0],r=e[0],o=e[1],c=e[1],l=0;l<e.length/2;l++)t=e[2*l],n=e[2*l+1],a=Math.min(a,t),r=Math.max(r,t),o=Math.min(o,n),c=Math.max(c,n);return{x:a,y:o,width:r-a,height:c-o}}}Xhe.prototype.className="Line",Xhe.prototype._attrsAffectingSize=["points","bezier","tension"],Xie(Xhe),fse.addGetterSetter(Xhe,"closed",!1),fse.addGetterSetter(Xhe,"bezier",!1),fse.addGetterSetter(Xhe,"tension",0,ise()),fse.addGetterSetter(Xhe,"points",[],function(){if(Kie.isUnminified)return function(e,t){const n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&e instanceof n||(ose._isArray(e)?e.forEach((function(e){ose._isNumber(e)||ose.warn('"'+t+'" attribute has non numeric element '+e+". Make sure that all elements are numbers.")})):ose.warn(cse(e)+' is a not valid value for "'+t+'" attribute. The value should be a array of numbers.')),e}}());class Qhe extends Ohe{constructor(e){super(e),this.dataArray=[],this.pathLength=0,this.dataArray=Qhe.parsePathData(this.data()),this.pathLength=0;for(var t=0;t<this.dataArray.length;++t)this.pathLength+=this.dataArray[t].pathLength;this.on("dataChange.konva",(function(){this.dataArray=Qhe.parsePathData(this.data()),this.pathLength=0;for(var e=0;e<this.dataArray.length;++e)this.pathLength+=this.dataArray[e].pathLength}))}_sceneFunc(e){var t=this.dataArray;e.beginPath();for(var n=!1,a=0;a<t.length;a++){var r=t[a].command,o=t[a].points;switch(r){case"L":e.lineTo(o[0],o[1]);break;case"M":e.moveTo(o[0],o[1]);break;case"C":e.bezierCurveTo(o[0],o[1],o[2],o[3],o[4],o[5]);break;case"Q":e.quadraticCurveTo(o[0],o[1],o[2],o[3]);break;case"A":var c=o[0],l=o[1],i=o[2],s=o[3],h=o[4],d=o[5],u=o[6],m=o[7],p=i>s?i:s,v=i>s?1:i/s,f=i>s?s/i:1;e.translate(c,l),e.rotate(u),e.scale(v,f),e.arc(0,0,p,h,h+d,1-m),e.scale(1/v,1/f),e.rotate(-u),e.translate(-c,-l);break;case"z":n=!0,e.closePath()}}n||this.hasFill()?e.fillStrokeShape(this):e.strokeShape(this)}getSelfRect(){var e=[];this.dataArray.forEach((function(t){if("A"===t.command){var n=t.points[4],a=t.points[5],r=t.points[4]+a,o=Math.PI/180;if(Math.abs(n-r)<o&&(o=Math.abs(n-r)),a<0)for(let a=n-o;a>r;a-=o){const n=Qhe.getPointOnEllipticalArc(t.points[0],t.points[1],t.points[2],t.points[3],a,0);e.push(n.x,n.y)}else for(let a=n+o;a<r;a+=o){const n=Qhe.getPointOnEllipticalArc(t.points[0],t.points[1],t.points[2],t.points[3],a,0);e.push(n.x,n.y)}}else if("C"===t.command)for(let n=0;n<=1;n+=.01){const a=Qhe.getPointOnCubicBezier(n,t.start.x,t.start.y,t.points[0],t.points[1],t.points[2],t.points[3],t.points[4],t.points[5]);e.push(a.x,a.y)}else e=e.concat(t.points)}));for(var t,n,a=e[0],r=e[0],o=e[1],c=e[1],l=0;l<e.length/2;l++)t=e[2*l],n=e[2*l+1],isNaN(t)||(a=Math.min(a,t),r=Math.max(r,t)),isNaN(n)||(o=Math.min(o,n),c=Math.max(c,n));return{x:a,y:o,width:r-a,height:c-o}}getLength(){return this.pathLength}getPointAtLength(e){var t,n=0,a=this.dataArray.length;if(!a)return null;for(;n<a&&e>this.dataArray[n].pathLength;)e-=this.dataArray[n].pathLength,++n;if(n===a)return{x:(t=this.dataArray[n-1].points.slice(-2))[0],y:t[1]};if(e<.01)return{x:(t=this.dataArray[n].points.slice(0,2))[0],y:t[1]};var r=this.dataArray[n],o=r.points;switch(r.command){case"L":return Qhe.getPointOnLine(e,r.start.x,r.start.y,o[0],o[1]);case"C":return Qhe.getPointOnCubicBezier(e/r.pathLength,r.start.x,r.start.y,o[0],o[1],o[2],o[3],o[4],o[5]);case"Q":return Qhe.getPointOnQuadraticBezier(e/r.pathLength,r.start.x,r.start.y,o[0],o[1],o[2],o[3]);case"A":var c=o[0],l=o[1],i=o[2],s=o[3],h=o[4],d=o[5],u=o[6];return h+=d*e/r.pathLength,Qhe.getPointOnEllipticalArc(c,l,i,s,h,u)}return null}static getLineLength(e,t,n,a){return Math.sqrt((n-e)*(n-e)+(a-t)*(a-t))}static getPointOnLine(e,t,n,a,r,o,c){void 0===o&&(o=t),void 0===c&&(c=n);var l=(r-n)/(a-t+1e-8),i=Math.sqrt(e*e/(1+l*l));a<t&&(i*=-1);var s,h=l*i;if(a===t)s={x:o,y:c+h};else if((c-n)/(o-t+1e-8)===l)s={x:o+i,y:c+h};else{var d,u,m=this.getLineLength(t,n,a,r),p=(o-t)*(a-t)+(c-n)*(r-n);d=t+(p/=m*m)*(a-t),u=n+p*(r-n);var v=this.getLineLength(o,c,d,u),f=Math.sqrt(e*e-v*v);i=Math.sqrt(f*f/(1+l*l)),a<t&&(i*=-1),s={x:d+i,y:u+(h=l*i)}}return s}static getPointOnCubicBezier(e,t,n,a,r,o,c,l,i){function s(e){return e*e*e}function h(e){return 3*e*e*(1-e)}function d(e){return 3*e*(1-e)*(1-e)}function u(e){return(1-e)*(1-e)*(1-e)}return{x:l*s(e)+o*h(e)+a*d(e)+t*u(e),y:i*s(e)+c*h(e)+r*d(e)+n*u(e)}}static getPointOnQuadraticBezier(e,t,n,a,r,o,c){function l(e){return e*e}function i(e){return 2*e*(1-e)}function s(e){return(1-e)*(1-e)}return{x:o*l(e)+a*i(e)+t*s(e),y:c*l(e)+r*i(e)+n*s(e)}}static getPointOnEllipticalArc(e,t,n,a,r,o){var c=Math.cos(o),l=Math.sin(o),i=n*Math.cos(r),s=a*Math.sin(r);return{x:e+(i*c-s*l),y:t+(i*l+s*c)}}static parsePathData(e){if(!e)return[];var t=e,n=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];t=t.replace(new RegExp(" ","g"),",");for(var a=0;a<n.length;a++)t=t.replace(new RegExp(n[a],"g"),"|"+n[a]);var r,o=t.split("|"),c=[],l=[],i=0,s=0,h=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;for(a=1;a<o.length;a++){var d=o[a],u=d.charAt(0);for(d=d.slice(1),l.length=0;r=h.exec(d);)l.push(r[0]);for(var m=[],p=0,v=l.length;p<v;p++)if("00"!==l[p]){var f=parseFloat(l[p]);isNaN(f)?m.push(0):m.push(f)}else m.push(0,0);for(;m.length>0&&!isNaN(m[0]);){var z,g,y,M,E,b,H,V,C,L,x=null,S=[],k=i,w=s;switch(u){case"l":i+=m.shift(),s+=m.shift(),x="L",S.push(i,s);break;case"L":i=m.shift(),s=m.shift(),S.push(i,s);break;case"m":var T=m.shift(),O=m.shift();if(i+=T,s+=O,x="M",c.length>2&&"z"===c[c.length-1].command)for(var A=c.length-2;A>=0;A--)if("M"===c[A].command){i=c[A].points[0]+T,s=c[A].points[1]+O;break}S.push(i,s),u="l";break;case"M":i=m.shift(),s=m.shift(),x="M",S.push(i,s),u="L";break;case"h":i+=m.shift(),x="L",S.push(i,s);break;case"H":i=m.shift(),x="L",S.push(i,s);break;case"v":s+=m.shift(),x="L",S.push(i,s);break;case"V":s=m.shift(),x="L",S.push(i,s);break;case"C":S.push(m.shift(),m.shift(),m.shift(),m.shift()),i=m.shift(),s=m.shift(),S.push(i,s);break;case"c":S.push(i+m.shift(),s+m.shift(),i+m.shift(),s+m.shift()),i+=m.shift(),s+=m.shift(),x="C",S.push(i,s);break;case"S":g=i,y=s,"C"===(z=c[c.length-1]).command&&(g=i+(i-z.points[2]),y=s+(s-z.points[3])),S.push(g,y,m.shift(),m.shift()),i=m.shift(),s=m.shift(),x="C",S.push(i,s);break;case"s":g=i,y=s,"C"===(z=c[c.length-1]).command&&(g=i+(i-z.points[2]),y=s+(s-z.points[3])),S.push(g,y,i+m.shift(),s+m.shift()),i+=m.shift(),s+=m.shift(),x="C",S.push(i,s);break;case"Q":S.push(m.shift(),m.shift()),i=m.shift(),s=m.shift(),S.push(i,s);break;case"q":S.push(i+m.shift(),s+m.shift()),i+=m.shift(),s+=m.shift(),x="Q",S.push(i,s);break;case"T":g=i,y=s,"Q"===(z=c[c.length-1]).command&&(g=i+(i-z.points[0]),y=s+(s-z.points[1])),i=m.shift(),s=m.shift(),x="Q",S.push(g,y,i,s);break;case"t":g=i,y=s,"Q"===(z=c[c.length-1]).command&&(g=i+(i-z.points[0]),y=s+(s-z.points[1])),i+=m.shift(),s+=m.shift(),x="Q",S.push(g,y,i,s);break;case"A":M=m.shift(),E=m.shift(),b=m.shift(),H=m.shift(),V=m.shift(),C=i,L=s,i=m.shift(),s=m.shift(),x="A",S=this.convertEndpointToCenterParameterization(C,L,i,s,H,V,M,E,b);break;case"a":M=m.shift(),E=m.shift(),b=m.shift(),H=m.shift(),V=m.shift(),C=i,L=s,i+=m.shift(),s+=m.shift(),x="A",S=this.convertEndpointToCenterParameterization(C,L,i,s,H,V,M,E,b)}c.push({command:x||u,points:S,start:{x:k,y:w},pathLength:this.calcLength(k,w,x||u,S)})}"z"!==u&&"Z"!==u||c.push({command:"z",points:[],start:void 0,pathLength:0})}return c}static calcLength(e,t,n,a){var r,o,c,l,i=Qhe;switch(n){case"L":return i.getLineLength(e,t,a[0],a[1]);case"C":for(r=0,o=i.getPointOnCubicBezier(0,e,t,a[0],a[1],a[2],a[3],a[4],a[5]),l=.01;l<=1;l+=.01)c=i.getPointOnCubicBezier(l,e,t,a[0],a[1],a[2],a[3],a[4],a[5]),r+=i.getLineLength(o.x,o.y,c.x,c.y),o=c;return r;case"Q":for(r=0,o=i.getPointOnQuadraticBezier(0,e,t,a[0],a[1],a[2],a[3]),l=.01;l<=1;l+=.01)c=i.getPointOnQuadraticBezier(l,e,t,a[0],a[1],a[2],a[3]),r+=i.getLineLength(o.x,o.y,c.x,c.y),o=c;return r;case"A":r=0;var s=a[4],h=a[5],d=a[4]+h,u=Math.PI/180;if(Math.abs(s-d)<u&&(u=Math.abs(s-d)),o=i.getPointOnEllipticalArc(a[0],a[1],a[2],a[3],s,0),h<0)for(l=s-u;l>d;l-=u)c=i.getPointOnEllipticalArc(a[0],a[1],a[2],a[3],l,0),r+=i.getLineLength(o.x,o.y,c.x,c.y),o=c;else for(l=s+u;l<d;l+=u)c=i.getPointOnEllipticalArc(a[0],a[1],a[2],a[3],l,0),r+=i.getLineLength(o.x,o.y,c.x,c.y),o=c;return c=i.getPointOnEllipticalArc(a[0],a[1],a[2],a[3],d,0),r+i.getLineLength(o.x,o.y,c.x,c.y)}return 0}static convertEndpointToCenterParameterization(e,t,n,a,r,o,c,l,i){var s=i*(Math.PI/180),h=Math.cos(s)*(e-n)/2+Math.sin(s)*(t-a)/2,d=-1*Math.sin(s)*(e-n)/2+Math.cos(s)*(t-a)/2,u=h*h/(c*c)+d*d/(l*l);u>1&&(c*=Math.sqrt(u),l*=Math.sqrt(u));var m=Math.sqrt((c*c*(l*l)-c*c*(d*d)-l*l*(h*h))/(c*c*(d*d)+l*l*(h*h)));r===o&&(m*=-1),isNaN(m)&&(m=0);var p=m*c*d/l,v=m*-l*h/c,f=(e+n)/2+Math.cos(s)*p-Math.sin(s)*v,z=(t+a)/2+Math.sin(s)*p+Math.cos(s)*v,g=function(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])},y=function(e,t){return(e[0]*t[0]+e[1]*t[1])/(g(e)*g(t))},M=function(e,t){return(e[0]*t[1]<e[1]*t[0]?-1:1)*Math.acos(y(e,t))},E=M([1,0],[(h-p)/c,(d-v)/l]),b=[(h-p)/c,(d-v)/l],H=[(-1*h-p)/c,(-1*d-v)/l],V=M(b,H);return y(b,H)<=-1&&(V=Math.PI),y(b,H)>=1&&(V=0),0===o&&V>0&&(V-=2*Math.PI),1===o&&V<0&&(V+=2*Math.PI),[f,z,c,l,E,V,s,o]}}Qhe.prototype.className="Path",Qhe.prototype._attrsAffectingSize=["data"],Xie(Qhe),fse.addGetterSetter(Qhe,"data");class Jhe extends Xhe{_sceneFunc(e){super._sceneFunc(e);var t=2*Math.PI,n=this.points(),a=n,r=0!==this.tension()&&n.length>4;r&&(a=this.getTensionPoints());var o,c,l=this.pointerLength(),i=n.length;if(r){const e=[a[a.length-4],a[a.length-3],a[a.length-2],a[a.length-1],n[i-2],n[i-1]],t=Qhe.calcLength(a[a.length-4],a[a.length-3],"C",e),r=Qhe.getPointOnQuadraticBezier(Math.min(1,1-l/t),e[0],e[1],e[2],e[3],e[4],e[5]);o=n[i-2]-r.x,c=n[i-1]-r.y}else o=n[i-2]-n[i-4],c=n[i-1]-n[i-3];var s=(Math.atan2(c,o)+t)%t,h=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(n[i-2],n[i-1]),e.rotate(s),e.moveTo(0,0),e.lineTo(-l,h/2),e.lineTo(-l,-h/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(n[0],n[1]),r?(o=(a[0]+a[2])/2-n[0],c=(a[1]+a[3])/2-n[1]):(o=n[2]-n[0],c=n[3]-n[1]),e.rotate((Math.atan2(-c,-o)+t)%t),e.moveTo(0,0),e.lineTo(-l,h/2),e.lineTo(-l,-h/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){var t=this.dashEnabled();t&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),t&&(this.attrs.dashEnabled=!0)}getSelfRect(){const e=super.getSelfRect(),t=this.pointerWidth()/2;return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}}Jhe.prototype.className="Arrow",Xie(Jhe),fse.addGetterSetter(Jhe,"pointerLength",10,ise()),fse.addGetterSetter(Jhe,"pointerWidth",10,ise()),fse.addGetterSetter(Jhe,"pointerAtBeginning",!1),fse.addGetterSetter(Jhe,"pointerAtEnding",!0);class Zhe extends Ohe{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(e){this.radius()!==e/2&&this.radius(e/2)}setHeight(e){this.radius()!==e/2&&this.radius(e/2)}}Zhe.prototype._centroid=!0,Zhe.prototype.className="Circle",Zhe.prototype._attrsAffectingSize=["radius"],Xie(Zhe),fse.addGetterSetter(Zhe,"radius",0,ise());class ede extends Ohe{_sceneFunc(e){var t=this.radiusX(),n=this.radiusY();e.beginPath(),e.save(),t!==n&&e.scale(1,n/t),e.arc(0,0,t,0,2*Math.PI,!1),e.restore(),e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.radiusX()}getHeight(){return 2*this.radiusY()}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}}ede.prototype.className="Ellipse",ede.prototype._centroid=!0,ede.prototype._attrsAffectingSize=["radiusX","radiusY"],Xie(ede),fse.addComponentsGetterSetter(ede,"radius",["x","y"]),fse.addGetterSetter(ede,"radiusX",0,ise()),fse.addGetterSetter(ede,"radiusY",0,ise());class tde extends Ohe{constructor(e){super(e),this.on("imageChange.konva",(()=>{this._setImageLoad()})),this._setImageLoad()}_setImageLoad(){const e=this.image();e&&e.complete||e&&4===e.readyState||e&&e.addEventListener&&e.addEventListener("load",(()=>{this._requestDraw()}))}_useBufferCanvas(){return super._useBufferCanvas(!0)}_sceneFunc(e){const t=this.getWidth(),n=this.getHeight(),a=this.cornerRadius(),r=this.attrs.image;let o;if(r){const e=this.attrs.cropWidth,a=this.attrs.cropHeight;o=e&&a?[r,this.cropX(),this.cropY(),e,a,0,0,t,n]:[r,0,0,t,n]}(this.hasFill()||this.hasStroke()||a)&&(e.beginPath(),a?ose.drawRoundedRectPath(e,t,n,a):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)),r&&(a&&e.clip(),e.drawImage.apply(e,o))}_hitFunc(e){var t=this.width(),n=this.height(),a=this.cornerRadius();e.beginPath(),a?ose.drawRoundedRectPath(e,t,n,a):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}getWidth(){var e,t;return null!==(e=this.attrs.width)&&void 0!==e?e:null===(t=this.image())||void 0===t?void 0:t.width}getHeight(){var e,t;return null!==(e=this.attrs.height)&&void 0!==e?e:null===(t=this.image())||void 0===t?void 0:t.height}static fromURL(e,t,n=null){var a=ose.createImageElement();a.onload=function(){var e=new tde({image:a});t(e)},a.onerror=n,a.crossOrigin="Anonymous",a.src=e}}tde.prototype.className="Image",Xie(tde),fse.addGetterSetter(tde,"cornerRadius",0,sse(4)),fse.addGetterSetter(tde,"image"),fse.addComponentsGetterSetter(tde,"crop",["x","y","width","height"]),fse.addGetterSetter(tde,"cropX",0,ise()),fse.addGetterSetter(tde,"cropY",0,ise()),fse.addGetterSetter(tde,"cropWidth",0,ise()),fse.addGetterSetter(tde,"cropHeight",0,ise());var nde=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],ade="up",rde="right",ode="down",cde="left",lde=nde.length;class ide extends Dhe{constructor(e){super(e),this.on("add.konva",(function(e){this._addListeners(e.child),this._sync()}))}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(e){var t,n=this,a=function(){n._sync()};for(t=0;t<lde;t++)e.on(nde[t]+"Change.konva",a)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){var e,t,n,a,r,o,c,l=this.getText(),i=this.getTag();if(l&&i){switch(e=l.width(),t=l.height(),n=i.pointerDirection(),a=i.pointerWidth(),c=i.pointerHeight(),r=0,o=0,n){case ade:r=e/2,o=-1*c;break;case rde:r=e+a,o=t/2;break;case ode:r=e/2,o=t+c;break;case cde:r=-1*a,o=t/2}i.setAttrs({x:-1*r,y:-1*o,width:e,height:t}),l.setAttrs({x:-1*r,y:-1*o})}}}ide.prototype.className="Label",Xie(ide);class sde extends Ohe{_sceneFunc(e){var t=this.width(),n=this.height(),a=this.pointerDirection(),r=this.pointerWidth(),o=this.pointerHeight(),c=this.cornerRadius();let l=0,i=0,s=0,h=0;"number"==typeof c?l=i=s=h=Math.min(c,t/2,n/2):(l=Math.min(c[0]||0,t/2,n/2),i=Math.min(c[1]||0,t/2,n/2),h=Math.min(c[2]||0,t/2,n/2),s=Math.min(c[3]||0,t/2,n/2)),e.beginPath(),e.moveTo(l,0),a===ade&&(e.lineTo((t-r)/2,0),e.lineTo(t/2,-1*o),e.lineTo((t+r)/2,0)),e.lineTo(t-i,0),e.arc(t-i,i,i,3*Math.PI/2,0,!1),a===rde&&(e.lineTo(t,(n-o)/2),e.lineTo(t+r,n/2),e.lineTo(t,(n+o)/2)),e.lineTo(t,n-h),e.arc(t-h,n-h,h,0,Math.PI/2,!1),a===ode&&(e.lineTo((t+r)/2,n),e.lineTo(t/2,n+o),e.lineTo((t-r)/2,n)),e.lineTo(s,n),e.arc(s,n-s,s,Math.PI/2,Math.PI,!1),a===cde&&(e.lineTo(0,(n+o)/2),e.lineTo(-1*r,n/2),e.lineTo(0,(n-o)/2)),e.lineTo(0,l),e.arc(l,l,l,Math.PI,3*Math.PI/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){var e=0,t=0,n=this.pointerWidth(),a=this.pointerHeight(),r=this.pointerDirection(),o=this.width(),c=this.height();return r===ade?(t-=a,c+=a):r===ode?c+=a:r===cde?(e-=1.5*n,o+=n):r===rde&&(o+=1.5*n),{x:e,y:t,width:o,height:c}}}sde.prototype.className="Tag",Xie(sde),fse.addGetterSetter(sde,"pointerDirection","none"),fse.addGetterSetter(sde,"pointerWidth",0,ise()),fse.addGetterSetter(sde,"pointerHeight",0,ise()),fse.addGetterSetter(sde,"cornerRadius",0,sse(4));class hde extends Ohe{_sceneFunc(e){var t=this.cornerRadius(),n=this.width(),a=this.height();e.beginPath(),t?ose.drawRoundedRectPath(e,n,a,t):e.rect(0,0,n,a),e.closePath(),e.fillStrokeShape(this)}}hde.prototype.className="Rect",Xie(hde),fse.addGetterSetter(hde,"cornerRadius",0,sse(4));class dde extends Ohe{_sceneFunc(e){const t=this._getPoints();e.beginPath(),e.moveTo(t[0].x,t[0].y);for(var n=1;n<t.length;n++)e.lineTo(t[n].x,t[n].y);e.closePath(),e.fillStrokeShape(this)}_getPoints(){const e=this.attrs.sides,t=this.attrs.radius||0,n=[];for(var a=0;a<e;a++)n.push({x:t*Math.sin(2*a*Math.PI/e),y:-1*t*Math.cos(2*a*Math.PI/e)});return n}getSelfRect(){const e=this._getPoints();var t=e[0].x,n=e[0].y,a=e[0].x,r=e[0].y;return e.forEach((e=>{t=Math.min(t,e.x),n=Math.max(n,e.x),a=Math.min(a,e.y),r=Math.max(r,e.y)})),{x:t,y:a,width:n-t,height:r-a}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}dde.prototype.className="RegularPolygon",dde.prototype._centroid=!0,dde.prototype._attrsAffectingSize=["radius"],Xie(dde),fse.addGetterSetter(dde,"radius",0,ise()),fse.addGetterSetter(dde,"sides",0,ise());var ude=2*Math.PI;class mde extends Ohe{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,ude,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),ude,0,!0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}mde.prototype.className="Ring",mde.prototype._centroid=!0,mde.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Xie(mde),fse.addGetterSetter(mde,"innerRadius",0,ise()),fse.addGetterSetter(mde,"outerRadius",0,ise());class pde extends Ohe{constructor(e){super(e),this._updated=!0,this.anim=new Fhe((()=>{var e=this._updated;return this._updated=!1,e})),this.on("animationChange.konva",(function(){this.frameIndex(0)})),this.on("frameIndexChange.konva",(function(){this._updated=!0})),this.on("frameRateChange.konva",(function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())}))}_sceneFunc(e){var t=this.animation(),n=this.frameIndex(),a=4*n,r=this.animations()[t],o=this.frameOffsets(),c=r[a+0],l=r[a+1],i=r[a+2],s=r[a+3],h=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,i,s),e.closePath(),e.fillStrokeShape(this)),h)if(o){var d=o[t],u=2*n;e.drawImage(h,c,l,i,s,d[u+0],d[u+1],i,s)}else e.drawImage(h,c,l,i,s,0,0,i,s)}_hitFunc(e){var t=this.animation(),n=this.frameIndex(),a=4*n,r=this.animations()[t],o=this.frameOffsets(),c=r[a+2],l=r[a+3];if(e.beginPath(),o){var i=o[t],s=2*n;e.rect(i[s+0],i[s+1],c,l)}else e.rect(0,0,c,l);e.closePath(),e.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){var e=this;this.interval=setInterval((function(){e._updateIndex()}),1e3/this.frameRate())}start(){if(!this.isRunning()){var e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){var e=this.frameIndex(),t=this.animation();e<this.animations()[t].length/4-1?this.frameIndex(e+1):this.frameIndex(0)}}pde.prototype.className="Sprite",Xie(pde),fse.addGetterSetter(pde,"animation"),fse.addGetterSetter(pde,"animations"),fse.addGetterSetter(pde,"frameOffsets"),fse.addGetterSetter(pde,"image"),fse.addGetterSetter(pde,"frameIndex",0,ise()),fse.addGetterSetter(pde,"frameRate",17,ise()),fse.backCompat(pde,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});class vde extends Ohe{_sceneFunc(e){var t=this.innerRadius(),n=this.outerRadius(),a=this.numPoints();e.beginPath(),e.moveTo(0,0-n);for(var r=1;r<2*a;r++){var o=r%2==0?n:t,c=o*Math.sin(r*Math.PI/a),l=-1*o*Math.cos(r*Math.PI/a);e.lineTo(c,l)}e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}function fde(e){return Array.from(e)}vde.prototype.className="Star",vde.prototype._centroid=!0,vde.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Xie(vde),fse.addGetterSetter(vde,"numPoints",5,ise()),fse.addGetterSetter(vde,"innerRadius",0,ise()),fse.addGetterSetter(vde,"outerRadius",0,ise());var zde,gde="auto",yde="justify",Mde="left",Ede="middle",bde="normal",Hde=" ",Vde="none",Cde=["fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],Lde=Cde.length;function xde(){return zde||(zde=ose.createCanvasElement().getContext("2d"))}class Sde extends Ohe{constructor(e){super(function(e){return(e=e||{}).fillLinearGradientColorStops||e.fillRadialGradientColorStops||e.fillPatternImage||(e.fill=e.fill||"black"),e}(e)),this._partialTextX=0,this._partialTextY=0;for(var t=0;t<Lde;t++)this.on(Cde[t]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(e){var t=this.textArr,n=t.length;if(this.text()){var a,r=this.padding(),o=this.fontSize(),c=this.lineHeight()*o,l=this.verticalAlign(),i=0,s=this.align(),h=this.getWidth(),d=this.letterSpacing(),u=this.fill(),m=this.textDecoration(),p=-1!==m.indexOf("underline"),v=-1!==m.indexOf("line-through"),f=0,z=(f=c/2,0),g=0;for(e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",Ede),e.setAttr("textAlign",Mde),l===Ede?i=(this.getHeight()-n*c-2*r)/2:"bottom"===l&&(i=this.getHeight()-n*c-2*r),e.translate(r,i+r),a=0;a<n;a++){z=0,g=0;var y,M,E,b=t[a],H=b.text,V=b.width,C=b.lastInParagraph;if(e.save(),"right"===s?z+=h-V-2*r:"center"===s&&(z+=(h-V-2*r)/2),p){e.save(),e.beginPath(),e.moveTo(z,f+g+Math.round(o/2)),M=0==(y=H.split(" ").length-1),E=s!==yde||C?V:h-2*r,e.lineTo(z+Math.round(E),f+g+Math.round(o/2)),e.lineWidth=o/15;const t=this._getLinearGradient();e.strokeStyle=t||u,e.stroke(),e.restore()}if(v){e.save(),e.beginPath(),e.moveTo(z,f+g),M=0==(y=H.split(" ").length-1),E=s===yde&&C&&!M?h-2*r:V,e.lineTo(z+Math.round(E),f+g),e.lineWidth=o/15;const t=this._getLinearGradient();e.strokeStyle=t||u,e.stroke(),e.restore()}if(0!==d||s===yde){y=H.split(" ").length-1;for(var L=fde(H),x=0;x<L.length;x++){var S=L[x];" "!==S||C||s!==yde||(z+=(h-2*r-V)/y),this._partialTextX=z,this._partialTextY=f+g,this._partialText=S,e.fillStrokeShape(this),z+=this.measureSize(S).width+d}}else this._partialTextX=z,this._partialTextY=f+g,this._partialText=H,e.fillStrokeShape(this);e.restore(),n>1&&(f+=c)}}}_hitFunc(e){var t=this.getWidth(),n=this.getHeight();e.beginPath(),e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}setText(e){var t=ose._isString(e)?e:null==e?"":e+"";return this._setAttr("text",t),this}getWidth(){return this.attrs.width===gde||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===gde||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return ose.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(e){var t,n=xde(),a=this.fontSize();return n.save(),n.font=this._getContextFont(),t=n.measureText(e),n.restore(),{width:t.width,height:a}}_getContextFont(){return this.fontStyle()+Hde+this.fontVariant()+Hde+(this.fontSize()+"px ")+function(e){return e.split(",").map((e=>{const t=(e=e.trim()).indexOf(" ")>=0,n=e.indexOf('"')>=0||e.indexOf("'")>=0;return t&&!n&&(e=`"${e}"`),e})).join(", ")}(this.fontFamily())}_addTextLine(e){this.align()===yde&&(e=e.trim());var t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e){var t=this.letterSpacing(),n=e.length;return xde().measureText(e).width+(n?t*(n-1):0)}_setTextData(){var e=this.text().split("\n"),t=+this.fontSize(),n=0,a=this.lineHeight()*t,r=this.attrs.width,o=this.attrs.height,c=r!==gde&&void 0!==r,l=o!==gde&&void 0!==o,i=this.padding(),s=r-2*i,h=o-2*i,d=0,u=this.wrap(),m="char"!==u&&u!==Vde,p=this.ellipsis();this.textArr=[],xde().font=this._getContextFont();for(var v=p?this._getTextWidth("…"):0,f=0,z=e.length;f<z;++f){var g=e[f],y=this._getTextWidth(g);if(c&&y>s)for(;g.length>0;){for(var M=0,E=g.length,b="",H=0;M<E;){var V=M+E>>>1,C=g.slice(0,V+1),L=this._getTextWidth(C)+v;L<=s?(M=V+1,b=C,H=L):E=V}if(!b)break;if(m){var x,S=g[b.length];(x=(S===Hde||"-"===S)&&H<=s?b.length:Math.max(b.lastIndexOf(Hde),b.lastIndexOf("-"))+1)>0&&(M=x,b=b.slice(0,M),H=this._getTextWidth(b))}if(b=b.trimRight(),this._addTextLine(b),n=Math.max(n,H),d+=a,this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if((g=(g=g.slice(M)).trimLeft()).length>0&&(y=this._getTextWidth(g))<=s){this._addTextLine(g),d+=a,n=Math.max(n,y);break}}else this._addTextLine(g),d+=a,n=Math.max(n,y),this._shouldHandleEllipsis(d)&&f<z-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),l&&d+a>h)break}this.textHeight=t,this.textWidth=n}_shouldHandleEllipsis(e){var t=+this.fontSize(),n=this.lineHeight()*t,a=this.attrs.height,r=a!==gde&&void 0!==a,o=a-2*this.padding();return!(this.wrap()!==Vde)||r&&e+n>o}_tryToAddEllipsisToLastLine(){var e=this.attrs.width,t=e!==gde&&void 0!==e,n=e-2*this.padding(),a=this.ellipsis(),r=this.textArr[this.textArr.length-1];r&&a&&(t&&(this._getTextWidth(r.text+"…")<n||(r.text=r.text.slice(0,r.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(r.text+"…"))}getStrokeScaleEnabled(){return!0}}Sde.prototype._fillFunc=function(e){e.fillText(this._partialText,this._partialTextX,this._partialTextY)},Sde.prototype._strokeFunc=function(e){e.strokeText(this._partialText,this._partialTextX,this._partialTextY)},Sde.prototype.className="Text",Sde.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],Xie(Sde),fse.overWriteSetter(Sde,"width",hse()),fse.overWriteSetter(Sde,"height",hse()),fse.addGetterSetter(Sde,"fontFamily","Arial"),fse.addGetterSetter(Sde,"fontSize",12,ise()),fse.addGetterSetter(Sde,"fontStyle",bde),fse.addGetterSetter(Sde,"fontVariant",bde),fse.addGetterSetter(Sde,"padding",0,ise()),fse.addGetterSetter(Sde,"align",Mde),fse.addGetterSetter(Sde,"verticalAlign","top"),fse.addGetterSetter(Sde,"lineHeight",1,ise()),fse.addGetterSetter(Sde,"wrap","word"),fse.addGetterSetter(Sde,"ellipsis",!1,mse()),fse.addGetterSetter(Sde,"letterSpacing",0,ise()),fse.addGetterSetter(Sde,"text","",dse()),fse.addGetterSetter(Sde,"textDecoration","");var kde="normal";function wde(e){e.fillText(this.partialText,0,0)}function Tde(e){e.strokeText(this.partialText,0,0)}class Ode extends Ohe{constructor(e){super(e),this.dummyCanvas=ose.createCanvasElement(),this.dataArray=[],this.dataArray=Qhe.parsePathData(this.attrs.data),this.on("dataChange.konva",(function(){this.dataArray=Qhe.parsePathData(this.attrs.data),this._setTextData()})),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_sceneFunc(e){e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",this.textBaseline()),e.setAttr("textAlign","left"),e.save();var t=this.textDecoration(),n=this.fill(),a=this.fontSize(),r=this.glyphInfo;"underline"===t&&e.beginPath();for(var o=0;o<r.length;o++){e.save();var c=r[o].p0;e.translate(c.x,c.y),e.rotate(r[o].rotation),this.partialText=r[o].text,e.fillStrokeShape(this),"underline"===t&&(0===o&&e.moveTo(0,a/2+1),e.lineTo(a,a/2+1)),e.restore()}"underline"===t&&(e.strokeStyle=n,e.lineWidth=a/20,e.stroke()),e.restore()}_hitFunc(e){e.beginPath();var t=this.glyphInfo;if(t.length>=1){var n=t[0].p0;e.moveTo(n.x,n.y)}for(var a=0;a<t.length;a++){var r=t[a].p1;e.lineTo(r.x,r.y)}e.setAttr("lineWidth",this.fontSize()),e.setAttr("strokeStyle",this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return ose.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return Sde.prototype.setText.call(this,e)}_getContextFont(){return Sde.prototype._getContextFont.call(this)}_getTextSize(e){var t=this.dummyCanvas.getContext("2d");t.save(),t.font=this._getContextFont();var n=t.measureText(e);return t.restore(),{width:n.width,height:parseInt(this.attrs.fontSize,10)}}_setTextData(){var e=this,t=this._getTextSize(this.attrs.text),n=this.letterSpacing(),a=this.align(),r=this.kerningFunc();this.textWidth=t.width,this.textHeight=t.height;var o=Math.max(this.textWidth+((this.attrs.text||"").length-1)*n,0);this.glyphInfo=[];for(var c=0,l=0;l<e.dataArray.length;l++)e.dataArray[l].pathLength>0&&(c+=e.dataArray[l].pathLength);var i=0;"center"===a&&(i=Math.max(0,c/2-o/2)),"right"===a&&(i=Math.max(0,c-o));for(var s,h,d,u=fde(this.text()),m=this.text().split(" ").length-1,p=-1,v=0,f=function(){v=0;for(var t=e.dataArray,n=p+1;n<t.length;n++){if(t[n].pathLength>0)return p=n,t[n];"M"===t[n].command&&(s={x:t[n].points[0],y:t[n].points[1]})}return{}},z=function(t){var r=e._getTextSize(t).width+n;" "===t&&"justify"===a&&(r+=(c-o)/m);var l=0,i=0;for(h=void 0;Math.abs(r-l)/r>.01&&i<20;){i++;for(var u=l;void 0===d;)(d=f())&&u+d.pathLength<r&&(u+=d.pathLength,d=void 0);if(0===Object.keys(d).length||void 0===s)return;var p=!1;switch(d.command){case"L":Qhe.getLineLength(s.x,s.y,d.points[0],d.points[1])>r?h=Qhe.getPointOnLine(r,s.x,s.y,d.points[0],d.points[1],s.x,s.y):d=void 0;break;case"A":var z=d.points[4],g=d.points[5],y=d.points[4]+g;0===v?v=z+1e-8:r>l?v+=Math.PI/180*g/Math.abs(g):v-=Math.PI/360*g/Math.abs(g),(g<0&&v<y||g>=0&&v>y)&&(v=y,p=!0),h=Qhe.getPointOnEllipticalArc(d.points[0],d.points[1],d.points[2],d.points[3],v,d.points[6]);break;case"C":0===v?v=r>d.pathLength?1e-8:r/d.pathLength:r>l?v+=(r-l)/d.pathLength/2:v=Math.max(v-(l-r)/d.pathLength/2,0),v>1&&(v=1,p=!0),h=Qhe.getPointOnCubicBezier(v,d.start.x,d.start.y,d.points[0],d.points[1],d.points[2],d.points[3],d.points[4],d.points[5]);break;case"Q":0===v?v=r/d.pathLength:r>l?v+=(r-l)/d.pathLength:v-=(l-r)/d.pathLength,v>1&&(v=1,p=!0),h=Qhe.getPointOnQuadraticBezier(v,d.start.x,d.start.y,d.points[0],d.points[1],d.points[2],d.points[3])}void 0!==h&&(l=Qhe.getLineLength(s.x,s.y,h.x,h.y)),p&&(p=!1,d=void 0)}},g=i/(e._getTextSize("C").width+n)-1,y=0;y<g&&(z("C"),void 0!==s&&void 0!==h);y++)s=h;for(var M=0;M<u.length&&(z(u[M]),void 0!==s&&void 0!==h);M++){var E=Qhe.getLineLength(s.x,s.y,h.x,h.y),b=0;if(r)try{b=r(u[M-1],u[M])*this.fontSize()}catch(e){b=0}s.x+=b,h.x+=b,this.textWidth+=b;var H=Qhe.getPointOnLine(b+E/2,s.x,s.y,h.x,h.y),V=Math.atan2(h.y-s.y,h.x-s.x);this.glyphInfo.push({transposeX:H.x,transposeY:H.y,text:u[M],rotation:V,p0:s,p1:h}),s=h}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};var e=[];this.glyphInfo.forEach((function(t){e.push(t.p0.x),e.push(t.p0.y),e.push(t.p1.x),e.push(t.p1.y)}));for(var t,n,a=e[0]||0,r=e[0]||0,o=e[1]||0,c=e[1]||0,l=0;l<e.length/2;l++)t=e[2*l],n=e[2*l+1],a=Math.min(a,t),r=Math.max(r,t),o=Math.min(o,n),c=Math.max(c,n);var i=this.fontSize();return{x:a-i/2,y:o-i/2,width:r-a+i,height:c-o+i}}destroy(){return ose.releaseCanvas(this.dummyCanvas),super.destroy()}}Ode.prototype._fillFunc=wde,Ode.prototype._strokeFunc=Tde,Ode.prototype._fillFuncHit=wde,Ode.prototype._strokeFuncHit=Tde,Ode.prototype.className="TextPath",Ode.prototype._attrsAffectingSize=["text","fontSize","data"],Xie(Ode),fse.addGetterSetter(Ode,"data"),fse.addGetterSetter(Ode,"fontFamily","Arial"),fse.addGetterSetter(Ode,"fontSize",12,ise()),fse.addGetterSetter(Ode,"fontStyle",kde),fse.addGetterSetter(Ode,"align","left"),fse.addGetterSetter(Ode,"letterSpacing",0,ise()),fse.addGetterSetter(Ode,"textBaseline","middle"),fse.addGetterSetter(Ode,"fontVariant",kde),fse.addGetterSetter(Ode,"text",""),fse.addGetterSetter(Ode,"textDecoration",null),fse.addGetterSetter(Ode,"kerningFunc",null);var Ade="tr-konva",Rde=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange"].map((e=>e+`.${Ade}`)).join(" "),Nde="nodesRect",_de=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],Dde={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135};const Pde="ontouchstart"in Kie._global;var Fde=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function Ide(e,t,n){const a=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),r=n.y+(e.x-n.x)*Math.sin(t)+(e.y-n.y)*Math.cos(t);return Object.assign(Object.assign({},e),{rotation:e.rotation+t,x:a,y:r})}class jde extends Dhe{constructor(e){super(e),this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(Rde,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return ose.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return Ade+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();const t=e.filter((e=>!e.isAncestorOf(this)||(ose.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1)));return this._nodes=e=t,1===e.length&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach((e=>{const t=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()},n=e._attrsAffectingSize.map((e=>e+"Change."+this._getEventNamespace())).join(" ");e.on(n,t),e.on(_de.map((e=>e+`.${this._getEventNamespace()}`)).join(" "),t),e.on(`absoluteTransformChange.${this._getEventNamespace()}`,t),this._proxyDrag(e)})),this._resetTransformCache(),!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,(n=>{t=e.getAbsolutePosition(),this.isDragging()||e===this.findOne(".back")||this.startDrag(n,!1)})),e.on(`dragmove.${this._getEventNamespace()}`,(n=>{if(!t)return;const a=e.getAbsolutePosition(),r=a.x-t.x,o=a.y-t.y;this.nodes().forEach((t=>{if(t===e)return;if(t.isDragging())return;const a=t.getAbsolutePosition();t.setAbsolutePosition({x:a.x+r,y:a.y+o}),t.startDrag(n)})),t=null}))}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach((e=>{e.off("."+this._getEventNamespace())})),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(Nde),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(Nde,this.__getNodeRect)}__getNodeShape(e,t=this.rotation(),n){var a=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=e.getAbsoluteScale(n),o=e.getAbsolutePosition(n),c=a.x*r.x-e.offsetX()*r.x,l=a.y*r.y-e.offsetY()*r.y;const i=(Kie.getAngle(e.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return Ide({x:o.x+c*Math.cos(i)+l*Math.sin(-i),y:o.y+l*Math.cos(i)+c*Math.sin(i),width:a.width*r.x,height:a.height*r.y,rotation:i},-Kie.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const e=[];this.nodes().map((t=>{const n=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()});var a=[{x:n.x,y:n.y},{x:n.x+n.width,y:n.y},{x:n.x+n.width,y:n.y+n.height},{x:n.x,y:n.y+n.height}],r=t.getAbsoluteTransform();a.forEach((function(t){var n=r.point(t);e.push(n)}))}));const t=new Qie;var n,a,r,o;t.rotate(-Kie.getAngle(this.rotation())),e.forEach((function(e){var c=t.point(e);void 0===n&&(n=r=c.x,a=o=c.y),n=Math.min(n,c.x),a=Math.min(a,c.y),r=Math.max(r,c.x),o=Math.max(o,c.y)})),t.invert();const c=t.point({x:n,y:a});return{x:c.x,y:c.y,width:r-n,height:o-a,rotation:Kie.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),Fde.forEach(function(e){this._createAnchor(e)}.bind(this)),this._createAnchor("rotater")}_createAnchor(e){var t=new hde({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:Pde?10:"auto"}),n=this;t.on("mousedown touchstart",(function(e){n._handleMouseDown(e)})),t.on("dragstart",(e=>{t.stopDrag(),e.cancelBubble=!0})),t.on("dragend",(e=>{e.cancelBubble=!0})),t.on("mouseenter",(()=>{var n=Kie.getAngle(this.rotation()),a=function(e,t){if("rotater"===e)return"crosshair";t+=ose.degToRad(Dde[e]||0);var n=(ose.radToDeg(t)%360+360)%360;return ose._inRange(n,337.5,360)||ose._inRange(n,0,22.5)?"ns-resize":ose._inRange(n,22.5,67.5)?"nesw-resize":ose._inRange(n,67.5,112.5)?"ew-resize":ose._inRange(n,112.5,157.5)?"nwse-resize":ose._inRange(n,157.5,202.5)?"ns-resize":ose._inRange(n,202.5,247.5)?"nesw-resize":ose._inRange(n,247.5,292.5)?"ew-resize":ose._inRange(n,292.5,337.5)?"nwse-resize":(ose.error("Transformer has unknown angle for cursor detection: "+n),"pointer")}(e,n);t.getStage().content&&(t.getStage().content.style.cursor=a),this._cursorChange=!0})),t.on("mouseout",(()=>{t.getStage().content&&(t.getStage().content.style.cursor=""),this._cursorChange=!1})),this.add(t)}_createBack(){var e=new Ohe({name:"back",width:0,height:0,draggable:!0,sceneFunc(e){var t=this.getParent(),n=t.padding();e.beginPath(),e.rect(-n,-n,this.width()+2*n,this.height()+2*n),e.moveTo(this.width()/2,-n),t.rotateEnabled()&&e.lineTo(this.width()/2,-t.rotateAnchorOffset()*ose._sign(this.height())-n),e.fillStrokeShape(this)},hitFunc:(e,t)=>{if(this.shouldOverdrawWholeArea()){var n=this.padding();e.beginPath(),e.rect(-n,-n,t.width()+2*n,t.height()+2*n),e.fillStrokeShape(t)}}});this.add(e),this._proxyDrag(e),e.on("dragstart",(e=>{e.cancelBubble=!0})),e.on("dragmove",(e=>{e.cancelBubble=!0})),e.on("dragend",(e=>{e.cancelBubble=!0})),this.on("dragmove",(e=>{this.update()}))}_handleMouseDown(e){this._movingAnchorName=e.target.name().split(" ")[0];var t=this._getNodeRect(),n=t.width,a=t.height,r=Math.sqrt(Math.pow(n,2)+Math.pow(a,2));this.sin=Math.abs(a/r),this.cos=Math.abs(n/r),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;var o=e.target.getAbsolutePosition(),c=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:c.x-o.x,y:c.y-o.y},this._fire("transformstart",{evt:e.evt,target:this.getNode()}),this._nodes.forEach((t=>{t._fire("transformstart",{evt:e.evt,target:t})}))}_handleMouseMove(e){var t,n,a,r=this.findOne("."+this._movingAnchorName),o=r.getStage();o.setPointersPositions(e);const c=o.getPointerPosition();let l={x:c.x-this._anchorDragOffset.x,y:c.y-this._anchorDragOffset.y};const i=r.getAbsolutePosition();this.anchorDragBoundFunc()&&(l=this.anchorDragBoundFunc()(i,l,e)),r.setAbsolutePosition(l);const s=r.getAbsolutePosition();if(i.x!==s.x||i.y!==s.y)if("rotater"!==this._movingAnchorName){var h=this.keepRatio()||e.shiftKey,d=this.centeredScaling()||e.altKey;if("top-left"===this._movingAnchorName){if(h){var u=d?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};a=Math.sqrt(Math.pow(u.x-r.x(),2)+Math.pow(u.y-r.y(),2));var m=this.findOne(".top-left").x()>u.x?-1:1,p=this.findOne(".top-left").y()>u.y?-1:1;t=a*this.cos*m,n=a*this.sin*p,this.findOne(".top-left").x(u.x-t),this.findOne(".top-left").y(u.y-n)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(r.y());else if("top-right"===this._movingAnchorName){h&&(u=d?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()},a=Math.sqrt(Math.pow(r.x()-u.x,2)+Math.pow(u.y-r.y(),2)),m=this.findOne(".top-right").x()<u.x?-1:1,p=this.findOne(".top-right").y()>u.y?-1:1,t=a*this.cos*m,n=a*this.sin*p,this.findOne(".top-right").x(u.x+t),this.findOne(".top-right").y(u.y-n));var v=r.position();this.findOne(".top-left").y(v.y),this.findOne(".bottom-right").x(v.x)}else"middle-left"===this._movingAnchorName?this.findOne(".top-left").x(r.x()):"middle-right"===this._movingAnchorName?this.findOne(".bottom-right").x(r.x()):"bottom-left"===this._movingAnchorName?(h&&(u=d?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()},a=Math.sqrt(Math.pow(u.x-r.x(),2)+Math.pow(r.y()-u.y,2)),m=u.x<r.x()?-1:1,p=r.y()<u.y?-1:1,t=a*this.cos*m,n=a*this.sin*p,r.x(u.x-t),r.y(u.y+n)),v=r.position(),this.findOne(".top-left").x(v.x),this.findOne(".bottom-right").y(v.y)):"bottom-center"===this._movingAnchorName?this.findOne(".bottom-right").y(r.y()):"bottom-right"===this._movingAnchorName?h&&(u=d?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()},a=Math.sqrt(Math.pow(r.x()-u.x,2)+Math.pow(r.y()-u.y,2)),m=this.findOne(".bottom-right").x()<u.x?-1:1,p=this.findOne(".bottom-right").y()<u.y?-1:1,t=a*this.cos*m,n=a*this.sin*p,this.findOne(".bottom-right").x(u.x+t),this.findOne(".bottom-right").y(u.y+n)):console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(d=this.centeredScaling()||e.altKey){var f=this.findOne(".top-left"),z=this.findOne(".bottom-right"),g=f.x(),y=f.y(),M=this.getWidth()-z.x(),E=this.getHeight()-z.y();z.move({x:-g,y:-y}),f.move({x:M,y:E})}var b=this.findOne(".top-left").getAbsolutePosition();t=b.x,n=b.y;var H=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),V=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:t,y:n,width:H,height:V,rotation:Kie.getAngle(this.rotation())},e)}else{var C=this._getNodeRect();t=r.x()-C.width/2,n=-r.y()+C.height/2;let a=Math.atan2(-n,t)+Math.PI/2;C.height<0&&(a-=Math.PI);const o=Kie.getAngle(this.rotation())+a,c=Kie.getAngle(this.rotationSnapTolerance()),l=function(e,t){const n=function(e){return{x:e.x+e.width/2*Math.cos(e.rotation)+e.height/2*Math.sin(-e.rotation),y:e.y+e.height/2*Math.cos(e.rotation)+e.width/2*Math.sin(e.rotation)}}(e);return Ide(e,t,n)}(C,function(e,t,n){let a=t;for(let r=0;r<e.length;r++){const o=Kie.getAngle(e[r]),c=Math.abs(o-t)%(2*Math.PI);Math.min(c,2*Math.PI-c)<n&&(a=o)}return a}(this.rotationSnaps(),o,c)-C.rotation);this._fitNodesInto(l,e)}}_handleMouseUp(e){this._removeEvents(e)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(e){if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));var t=this.getNode();this._fire("transformend",{evt:e,target:t}),t&&this._nodes.forEach((t=>{t._fire("transformend",{evt:e,target:t})})),this._movingAnchorName=null}}_fitNodesInto(e,t){var n=this._getNodeRect();if(ose._inRange(e.width,2*-this.padding()-1,1))return void this.update();if(ose._inRange(e.height,2*-this.padding()-1,1))return void this.update();const a=this.flipEnabled();var r=new Qie;if(r.rotate(Kie.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const t=r.point({x:2*-this.padding(),y:0});if(e.x+=t.x,e.y+=t.y,e.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,!a)return void this.update()}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const t=r.point({x:2*this.padding(),y:0});if(this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.width+=2*this.padding(),!a)return void this.update()}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const t=r.point({x:0,y:2*-this.padding()});if(e.x+=t.x,e.y+=t.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding(),!a)return void this.update()}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const t=r.point({x:0,y:2*this.padding()});if(this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding(),!a)return void this.update()}if(this.boundBoxFunc()){const t=this.boundBoxFunc()(n,e);t?e=t:ose.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const o=1e7,c=new Qie;c.translate(n.x,n.y),c.rotate(n.rotation),c.scale(n.width/o,n.height/o);const l=new Qie;l.translate(e.x,e.y),l.rotate(e.rotation),l.scale(e.width/o,e.height/o);const i=l.multiply(c.invert());this._nodes.forEach((e=>{var n;const a=e.getParent().getAbsoluteTransform(),r=e.getTransform().copy();r.translate(e.offsetX(),e.offsetY());const o=new Qie;o.multiply(a.copy().invert()).multiply(i).multiply(a).multiply(r);const c=o.decompose();e.setAttrs(c),this._fire("transform",{evt:t,target:e}),e._fire("transform",{evt:t,target:e}),null===(n=e.getLayer())||void 0===n||n.batchDraw()})),this.rotation(ose._getRotation(e.rotation)),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,t){this.findOne(e).setAttrs(t)}update(){var e,t=this._getNodeRect();this.rotation(ose._getRotation(t.rotation));var n=t.width,a=t.height,r=this.enabledAnchors(),o=this.resizeEnabled(),c=this.padding(),l=this.anchorSize();this.find("._anchor").forEach((e=>{e.setAttrs({width:l,height:l,offsetX:l/2,offsetY:l/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})})),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:l/2+c,offsetY:l/2+c,visible:o&&r.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:n/2,y:0,offsetY:l/2+c,visible:o&&r.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:n,y:0,offsetX:l/2-c,offsetY:l/2+c,visible:o&&r.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:a/2,offsetX:l/2+c,visible:o&&r.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:n,y:a/2,offsetX:l/2-c,visible:o&&r.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:a,offsetX:l/2+c,offsetY:l/2-c,visible:o&&r.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:n/2,y:a,offsetY:l/2-c,visible:o&&r.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:n,y:a,offsetX:l/2-c,offsetY:l/2-c,visible:o&&r.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:n/2,y:-this.rotateAnchorOffset()*ose._sign(a)-c,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:n,height:a,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0}),null===(e=this.getLayer())||void 0===e||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();var e=this.findOne("."+this._movingAnchorName);e&&e.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),Dhe.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return jse.prototype.toObject.call(this)}clone(e){return jse.prototype.clone.call(this,e)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}jde.prototype.className="Transformer",Xie(jde),fse.addGetterSetter(jde,"enabledAnchors",Fde,(function(e){return e instanceof Array||ose.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach((function(e){-1===Fde.indexOf(e)&&ose.warn("Unknown anchor name: "+e+". Available names are: "+Fde.join(", "))})),e||[]})),fse.addGetterSetter(jde,"flipEnabled",!0,mse()),fse.addGetterSetter(jde,"resizeEnabled",!0),fse.addGetterSetter(jde,"anchorSize",10,ise()),fse.addGetterSetter(jde,"rotateEnabled",!0),fse.addGetterSetter(jde,"rotationSnaps",[]),fse.addGetterSetter(jde,"rotateAnchorOffset",50,ise()),fse.addGetterSetter(jde,"rotationSnapTolerance",5,ise()),fse.addGetterSetter(jde,"borderEnabled",!0),fse.addGetterSetter(jde,"anchorStroke","rgb(0, 161, 255)"),fse.addGetterSetter(jde,"anchorStrokeWidth",1,ise()),fse.addGetterSetter(jde,"anchorFill","white"),fse.addGetterSetter(jde,"anchorCornerRadius",0,ise()),fse.addGetterSetter(jde,"borderStroke","rgb(0, 161, 255)"),fse.addGetterSetter(jde,"borderStrokeWidth",1,ise()),fse.addGetterSetter(jde,"borderDash"),fse.addGetterSetter(jde,"keepRatio",!0),fse.addGetterSetter(jde,"centeredScaling",!1),fse.addGetterSetter(jde,"ignoreStroke",!1),fse.addGetterSetter(jde,"padding",0,ise()),fse.addGetterSetter(jde,"node"),fse.addGetterSetter(jde,"nodes"),fse.addGetterSetter(jde,"boundBoxFunc"),fse.addGetterSetter(jde,"anchorDragBoundFunc"),fse.addGetterSetter(jde,"shouldOverdrawWholeArea",!1),fse.addGetterSetter(jde,"useSingleNodeRotation",!0),fse.backCompat(jde,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});class Bde extends Ohe{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,Kie.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}function Ude(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}Bde.prototype.className="Wedge",Bde.prototype._centroid=!0,Bde.prototype._attrsAffectingSize=["radius"],Xie(Bde),fse.addGetterSetter(Bde,"radius",0,ise()),fse.addGetterSetter(Bde,"angle",0,ise()),fse.addGetterSetter(Bde,"clockwise",!1),fse.backCompat(Bde,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});var Wde=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],$de=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function qde(e,t,n,a,r){var o=n-t,c=r-a;return 0===o?a+c/2:0===c?a:c*((e-t)/o)+a}function Gde(e,t,n){var a=4*(n*e.width+t),r=[];return r.push(e.data[a++],e.data[a++],e.data[a++],e.data[a++]),r}function Yde(e,t){return Math.sqrt(Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)+Math.pow(e[2]-t[2],2))}function Kde(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}fse.addGetterSetter(jse,"blurRadius",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"brightness",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"contrast",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"embossStrength",.5,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"embossWhiteLevel",.5,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"embossDirection","top-left",null,fse.afterSetFilter),fse.addGetterSetter(jse,"embossBlend",!1,null,fse.afterSetFilter),fse.addGetterSetter(jse,"enhance",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"hue",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"saturation",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"luminance",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"hue",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"saturation",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"value",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"kaleidoscopePower",2,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"kaleidoscopeAngle",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"threshold",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"noise",.2,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"pixelSize",8,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"levels",.5,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"red",0,(function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)})),fse.addGetterSetter(jse,"green",0,(function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)})),fse.addGetterSetter(jse,"blue",0,lse,fse.afterSetFilter),fse.addGetterSetter(jse,"red",0,(function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)})),fse.addGetterSetter(jse,"green",0,(function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)})),fse.addGetterSetter(jse,"blue",0,lse,fse.afterSetFilter),fse.addGetterSetter(jse,"alpha",1,(function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e})),fse.addGetterSetter(jse,"threshold",.5,ise(),fse.afterSetFilter),qhe.Util._assign(qhe,{Arc:Ghe,Arrow:Jhe,Circle:Zhe,Ellipse:ede,Image:tde,Label:ide,Tag:sde,Line:Xhe,Path:Qhe,Rect:hde,RegularPolygon:dde,Ring:mde,Sprite:pde,Star:vde,Text:Sde,TextPath:Ode,Transformer:jde,Wedge:Bde,Filters:{Blur:function(e){var t=Math.round(this.blurRadius());t>0&&function(e,t){var n,a,r,o,c,l,i,s,h,d,u,m,p,v,f,z,g,y,M,E,b,H,V,C,L=e.data,x=e.width,S=e.height,k=t+t+1,w=x-1,T=S-1,O=t+1,A=O*(O+1)/2,R=new Ude,N=null,_=R,D=null,P=null,F=Wde[t],I=$de[t];for(r=1;r<k;r++)_=_.next=new Ude,r===O&&(N=_);for(_.next=R,i=l=0,a=0;a<S;a++){for(z=g=y=M=s=h=d=u=0,m=O*(E=L[l]),p=O*(b=L[l+1]),v=O*(H=L[l+2]),f=O*(V=L[l+3]),s+=A*E,h+=A*b,d+=A*H,u+=A*V,_=R,r=0;r<O;r++)_.r=E,_.g=b,_.b=H,_.a=V,_=_.next;for(r=1;r<O;r++)o=l+((w<r?w:r)<<2),s+=(_.r=E=L[o])*(C=O-r),h+=(_.g=b=L[o+1])*C,d+=(_.b=H=L[o+2])*C,u+=(_.a=V=L[o+3])*C,z+=E,g+=b,y+=H,M+=V,_=_.next;for(D=R,P=N,n=0;n<x;n++)L[l+3]=V=u*F>>I,0!==V?(V=255/V,L[l]=(s*F>>I)*V,L[l+1]=(h*F>>I)*V,L[l+2]=(d*F>>I)*V):L[l]=L[l+1]=L[l+2]=0,s-=m,h-=p,d-=v,u-=f,m-=D.r,p-=D.g,v-=D.b,f-=D.a,o=i+((o=n+t+1)<w?o:w)<<2,s+=z+=D.r=L[o],h+=g+=D.g=L[o+1],d+=y+=D.b=L[o+2],u+=M+=D.a=L[o+3],D=D.next,m+=E=P.r,p+=b=P.g,v+=H=P.b,f+=V=P.a,z-=E,g-=b,y-=H,M-=V,P=P.next,l+=4;i+=x}for(n=0;n<x;n++){for(g=y=M=z=h=d=u=s=0,m=O*(E=L[l=n<<2]),p=O*(b=L[l+1]),v=O*(H=L[l+2]),f=O*(V=L[l+3]),s+=A*E,h+=A*b,d+=A*H,u+=A*V,_=R,r=0;r<O;r++)_.r=E,_.g=b,_.b=H,_.a=V,_=_.next;for(c=x,r=1;r<=t;r++)l=c+n<<2,s+=(_.r=E=L[l])*(C=O-r),h+=(_.g=b=L[l+1])*C,d+=(_.b=H=L[l+2])*C,u+=(_.a=V=L[l+3])*C,z+=E,g+=b,y+=H,M+=V,_=_.next,r<T&&(c+=x);for(l=n,D=R,P=N,a=0;a<S;a++)L[3+(o=l<<2)]=V=u*F>>I,V>0?(V=255/V,L[o]=(s*F>>I)*V,L[o+1]=(h*F>>I)*V,L[o+2]=(d*F>>I)*V):L[o]=L[o+1]=L[o+2]=0,s-=m,h-=p,d-=v,u-=f,m-=D.r,p-=D.g,v-=D.b,f-=D.a,o=n+((o=a+O)<T?o:T)*x<<2,s+=z+=D.r=L[o],h+=g+=D.g=L[o+1],d+=y+=D.b=L[o+2],u+=M+=D.a=L[o+3],D=D.next,m+=E=P.r,p+=b=P.g,v+=H=P.b,f+=V=P.a,z-=E,g-=b,y-=H,M-=V,P=P.next,l+=x}}(e,t)},Brighten:function(e){var t,n=255*this.brightness(),a=e.data,r=a.length;for(t=0;t<r;t+=4)a[t]+=n,a[t+1]+=n,a[t+2]+=n},Contrast:function(e){var t,n=Math.pow((this.contrast()+100)/100,2),a=e.data,r=a.length,o=150,c=150,l=150;for(t=0;t<r;t+=4)o=a[t],c=a[t+1],l=a[t+2],o/=255,o-=.5,o*=n,o+=.5,c/=255,c-=.5,c*=n,c+=.5,l/=255,l-=.5,l*=n,l+=.5,o=(o*=255)<0?0:o>255?255:o,c=(c*=255)<0?0:c>255?255:c,l=(l*=255)<0?0:l>255?255:l,a[t]=o,a[t+1]=c,a[t+2]=l},Emboss:function(e){var t=10*this.embossStrength(),n=255*this.embossWhiteLevel(),a=this.embossDirection(),r=this.embossBlend(),o=0,c=0,l=e.data,i=e.width,s=e.height,h=4*i,d=s;switch(a){case"top-left":o=-1,c=-1;break;case"top":o=-1,c=0;break;case"top-right":o=-1,c=1;break;case"right":o=0,c=1;break;case"bottom-right":o=1,c=1;break;case"bottom":o=1,c=0;break;case"bottom-left":o=1,c=-1;break;case"left":o=0,c=-1;break;default:ose.error("Unknown emboss direction: "+a)}do{var u=(d-1)*h,m=o;d+m<1&&(m=0),d+m>s&&(m=0);var p=(d-1+m)*i*4,v=i;do{var f=u+4*(v-1),z=c;v+z<1&&(z=0),v+z>i&&(z=0);var g=p+4*(v-1+z),y=l[f]-l[g],M=l[f+1]-l[g+1],E=l[f+2]-l[g+2],b=y,H=b>0?b:-b;if((M>0?M:-M)>H&&(b=M),(E>0?E:-E)>H&&(b=E),b*=t,r){var V=l[f]+b,C=l[f+1]+b,L=l[f+2]+b;l[f]=V>255?255:V<0?0:V,l[f+1]=C>255?255:C<0?0:C,l[f+2]=L>255?255:L<0?0:L}else{var x=n-b;x<0?x=0:x>255&&(x=255),l[f]=l[f+1]=l[f+2]=x}}while(--v)}while(--d)},Enhance:function(e){var t,n,a,r,o=e.data,c=o.length,l=o[0],i=l,s=o[1],h=s,d=o[2],u=d,m=this.enhance();if(0!==m){for(r=0;r<c;r+=4)(t=o[r+0])<l?l=t:t>i&&(i=t),(n=o[r+1])<s?s=n:n>h&&(h=n),(a=o[r+2])<d?d=a:a>u&&(u=a);var p,v,f,z,g,y,M,E,b;for(i===l&&(i=255,l=0),h===s&&(h=255,s=0),u===d&&(u=255,d=0),m>0?(v=i+m*(255-i),f=l-m*(l-0),g=h+m*(255-h),y=s-m*(s-0),E=u+m*(255-u),b=d-m*(d-0)):(v=i+m*(i-(p=.5*(i+l))),f=l+m*(l-p),g=h+m*(h-(z=.5*(h+s))),y=s+m*(s-z),E=u+m*(u-(M=.5*(u+d))),b=d+m*(d-M)),r=0;r<c;r+=4)o[r+0]=qde(o[r+0],l,i,f,v),o[r+1]=qde(o[r+1],s,h,y,g),o[r+2]=qde(o[r+2],d,u,b,E)}},Grayscale:function(e){var t,n,a=e.data,r=a.length;for(t=0;t<r;t+=4)n=.34*a[t]+.5*a[t+1]+.16*a[t+2],a[t]=n,a[t+1]=n,a[t+2]=n},HSL:function(e){var t,n,a,r,o,c=e.data,l=c.length,i=Math.pow(2,this.saturation()),s=Math.abs(this.hue()+360)%360,h=127*this.luminance(),d=1*i*Math.cos(s*Math.PI/180),u=1*i*Math.sin(s*Math.PI/180),m=.299+.701*d+.167*u,p=.587-.587*d+.33*u,v=.114-.114*d-.497*u,f=.299-.299*d-.328*u,z=.587+.413*d+.035*u,g=.114-.114*d+.293*u,y=.299-.3*d+1.25*u,M=.587-.586*d-1.05*u,E=.114+.886*d-.2*u;for(t=0;t<l;t+=4)n=c[t+0],a=c[t+1],r=c[t+2],o=c[t+3],c[t+0]=m*n+p*a+v*r+h,c[t+1]=f*n+z*a+g*r+h,c[t+2]=y*n+M*a+E*r+h,c[t+3]=o},HSV:function(e){var t,n,a,r,o,c=e.data,l=c.length,i=Math.pow(2,this.value()),s=Math.pow(2,this.saturation()),h=Math.abs(this.hue()+360)%360,d=i*s*Math.cos(h*Math.PI/180),u=i*s*Math.sin(h*Math.PI/180),m=.299*i+.701*d+.167*u,p=.587*i-.587*d+.33*u,v=.114*i-.114*d-.497*u,f=.299*i-.299*d-.328*u,z=.587*i+.413*d+.035*u,g=.114*i-.114*d+.293*u,y=.299*i-.3*d+1.25*u,M=.587*i-.586*d-1.05*u,E=.114*i+.886*d-.2*u;for(t=0;t<l;t+=4)n=c[t+0],a=c[t+1],r=c[t+2],o=c[t+3],c[t+0]=m*n+p*a+v*r,c[t+1]=f*n+z*a+g*r,c[t+2]=y*n+M*a+E*r,c[t+3]=o},Invert:function(e){var t,n=e.data,a=n.length;for(t=0;t<a;t+=4)n[t]=255-n[t],n[t+1]=255-n[t+1],n[t+2]=255-n[t+2]},Kaleidoscope:function(e){var t,n,a,r,o,c,l,i,s,h=e.width,d=e.height,u=Math.round(this.kaleidoscopePower()),m=Math.round(this.kaleidoscopeAngle()),p=Math.floor(h*(m%360)/360);if(!(u<1)){var v=ose.createCanvasElement();v.width=h,v.height=d;var f=v.getContext("2d").getImageData(0,0,h,d);ose.releaseCanvas(v),function(e,t,n){var a,r,o,c,l=e.data,i=t.data,s=e.width,h=e.height,d=n.polarCenterX||s/2,u=n.polarCenterY||h/2,m=0,p=0,v=0,f=0,z=Math.sqrt(d*d+u*u);r=s-d,o=h-u,z=(c=Math.sqrt(r*r+o*o))>z?c:z;var g,y,M,E,b=h,H=s,V=360/H*Math.PI/180;for(y=0;y<H;y+=1)for(M=Math.sin(y*V),E=Math.cos(y*V),g=0;g<b;g+=1)r=Math.floor(d+z*g/b*E),m=l[0+(a=4*((o=Math.floor(u+z*g/b*M))*s+r))],p=l[a+1],v=l[a+2],f=l[a+3],i[0+(a=4*(y+g*s))]=m,i[a+1]=p,i[a+2]=v,i[a+3]=f}(e,f,{polarCenterX:h/2,polarCenterY:d/2});for(var z=h/Math.pow(2,u);z<=8;)z*=2,u-=1;var g=z=Math.ceil(z),y=0,M=g,E=1;for(p+z>h&&(y=g,M=0,E=-1),n=0;n<d;n+=1)for(t=y;t!==M;t+=E)i=4*(h*n+Math.round(t+p)%h),r=f.data[i+0],o=f.data[i+1],c=f.data[i+2],l=f.data[i+3],s=4*(h*n+t),f.data[s+0]=r,f.data[s+1]=o,f.data[s+2]=c,f.data[s+3]=l;for(n=0;n<d;n+=1)for(g=Math.floor(z),a=0;a<u;a+=1){for(t=0;t<g+1;t+=1)i=4*(h*n+t),r=f.data[i+0],o=f.data[i+1],c=f.data[i+2],l=f.data[i+3],s=4*(h*n+2*g-t-1),f.data[s+0]=r,f.data[s+1]=o,f.data[s+2]=c,f.data[s+3]=l;g*=2}!function(e,t,n){var a,r,o,c,l,i,s=e.data,h=t.data,d=e.width,u=e.height,m=n.polarCenterX||d/2,p=n.polarCenterY||u/2,v=0,f=0,z=0,g=0,y=Math.sqrt(m*m+p*p);r=d-m,o=u-p,y=(i=Math.sqrt(r*r+o*o))>y?i:y;var M,E,b,H=u,V=d,C=n.polarRotation||0;for(r=0;r<d;r+=1)for(o=0;o<u;o+=1)c=r-m,l=o-p,M=Math.sqrt(c*c+l*l)*H/y,E=(E=(180*Math.atan2(l,c)/Math.PI+360+C)%360)*V/360,b=Math.floor(E),v=s[0+(a=4*(Math.floor(M)*d+b))],f=s[a+1],z=s[a+2],g=s[a+3],h[0+(a=4*(o*d+r))]=v,h[a+1]=f,h[a+2]=z,h[a+3]=g}(f,e,{polarRotation:0})}},Mask:function(e){var t=function(e,t){var n=Gde(e,0,0),a=Gde(e,e.width-1,0),r=Gde(e,0,e.height-1),o=Gde(e,e.width-1,e.height-1),c=t||10;if(Yde(n,a)<c&&Yde(a,o)<c&&Yde(o,r)<c&&Yde(r,n)<c){for(var l=function(e){for(var t=[0,0,0],n=0;n<e.length;n++)t[0]+=e[n][0],t[1]+=e[n][1],t[2]+=e[n][2];return t[0]/=e.length,t[1]/=e.length,t[2]/=e.length,t}([a,n,o,r]),i=[],s=0;s<e.width*e.height;s++){var h=Yde(l,[e.data[4*s],e.data[4*s+1],e.data[4*s+2]]);i[s]=h<c?0:255}return i}}(e,this.threshold());return t&&function(e,t){for(var n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}(e,t=function(e,t,n){for(var a=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],r=Math.round(Math.sqrt(a.length)),o=Math.floor(r/2),c=[],l=0;l<n;l++)for(var i=0;i<t;i++){for(var s=l*t+i,h=0,d=0;d<r;d++)for(var u=0;u<r;u++){var m=l+d-o,p=i+u-o;if(m>=0&&m<n&&p>=0&&p<t){var v=a[d*r+u];h+=e[m*t+p]*v}}c[s]=h}return c}(t=function(e,t,n){for(var a=[1,1,1,1,1,1,1,1,1],r=Math.round(Math.sqrt(a.length)),o=Math.floor(r/2),c=[],l=0;l<n;l++)for(var i=0;i<t;i++){for(var s=l*t+i,h=0,d=0;d<r;d++)for(var u=0;u<r;u++){var m=l+d-o,p=i+u-o;if(m>=0&&m<n&&p>=0&&p<t){var v=a[d*r+u];h+=e[m*t+p]*v}}c[s]=h>=1020?255:0}return c}(t=function(e,t,n){for(var a=[1,1,1,1,0,1,1,1,1],r=Math.round(Math.sqrt(a.length)),o=Math.floor(r/2),c=[],l=0;l<n;l++)for(var i=0;i<t;i++){for(var s=l*t+i,h=0,d=0;d<r;d++)for(var u=0;u<r;u++){var m=l+d-o,p=i+u-o;if(m>=0&&m<n&&p>=0&&p<t){var v=a[d*r+u];h+=e[m*t+p]*v}}c[s]=2040===h?255:0}return c}(t,e.width,e.height),e.width,e.height),e.width,e.height)),e},Noise:function(e){var t,n=255*this.noise(),a=e.data,r=a.length,o=n/2;for(t=0;t<r;t+=4)a[t+0]+=o-2*o*Math.random(),a[t+1]+=o-2*o*Math.random(),a[t+2]+=o-2*o*Math.random()},Pixelate:function(e){var t,n,a,r,o,c,l,i,s,h,d,u,m,p,v=Math.ceil(this.pixelSize()),f=e.width,z=e.height,g=Math.ceil(f/v),y=Math.ceil(z/v),M=e.data;if(v<=0)ose.error("pixelSize value can not be <= 0");else for(u=0;u<g;u+=1)for(m=0;m<y;m+=1){for(r=0,o=0,c=0,l=0,s=(i=u*v)+v,d=(h=m*v)+v,p=0,t=i;t<s;t+=1)if(!(t>=f))for(n=h;n<d;n+=1)n>=z||(r+=M[0+(a=4*(f*n+t))],o+=M[a+1],c+=M[a+2],l+=M[a+3],p+=1);for(r/=p,o/=p,c/=p,l/=p,t=i;t<s;t+=1)if(!(t>=f))for(n=h;n<d;n+=1)n>=z||(M[0+(a=4*(f*n+t))]=r,M[a+1]=o,M[a+2]=c,M[a+3]=l)}},Posterize:function(e){var t,n=Math.round(254*this.levels())+1,a=e.data,r=a.length,o=255/n;for(t=0;t<r;t+=1)a[t]=Math.floor(a[t]/o)*o},RGB:function(e){var t,n,a=e.data,r=a.length,o=this.red(),c=this.green(),l=this.blue();for(t=0;t<r;t+=4)n=(.34*a[t]+.5*a[t+1]+.16*a[t+2])/255,a[t]=n*o,a[t+1]=n*c,a[t+2]=n*l,a[t+3]=a[t+3]},RGBA:function(e){var t,n,a=e.data,r=a.length,o=this.red(),c=this.green(),l=this.blue(),i=this.alpha();for(t=0;t<r;t+=4)n=1-i,a[t]=o*i+a[t]*n,a[t+1]=c*i+a[t+1]*n,a[t+2]=l*i+a[t+2]*n},Sepia:function(e){var t,n,a,r,o=e.data,c=o.length;for(t=0;t<c;t+=4)n=o[t+0],a=o[t+1],r=o[t+2],o[t+0]=Math.min(255,.393*n+.769*a+.189*r),o[t+1]=Math.min(255,.349*n+.686*a+.168*r),o[t+2]=Math.min(255,.272*n+.534*a+.131*r)},Solarize:function(e){var t=e.data,n=e.width,a=4*n,r=e.height;do{var o=(r-1)*a,c=n;do{var l=o+4*(c-1),i=t[l],s=t[l+1],h=t[l+2];i>127&&(i=255-i),s>127&&(s=255-s),h>127&&(h=255-h),t[l]=i,t[l+1]=s,t[l+2]=h}while(--c)}while(--r)},Threshold:function(e){var t,n=255*this.threshold(),a=e.data,r=a.length;for(t=0;t<r;t+=1)a[t]=a[t]<n?0:255}}});var Xde,Qde,Jde={exports:{}},Zde={exports:{}};function eue(){if(Qde)return Xde;Qde=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;return Xde=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var a={};return"abcdefghijklmnopqrst".split("").forEach((function(e){a[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},a)).join("")}catch(e){return!1}}()?Object.assign:function(a,r){for(var o,c,l=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(a),i=1;i<arguments.length;i++){for(var s in o=Object(arguments[i]))t.call(o,s)&&(l[s]=o[s]);if(e){c=e(o);for(var h=0;h<c.length;h++)n.call(o,c[h])&&(l[c[h]]=o[c[h]])}}return l},Xde}var tue,nue,aue,rue,oue={exports:{}},cue={},lue={};function iue(){return aue||(aue=1,"production"===Vee.env.NODE_ENV?oue.exports=(tue||(tue=1,function(e){var t,n,a,r;if("object"==typeof performance&&"function"==typeof performance.now){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,l=c.now();e.unstable_now=function(){return c.now()-l}}if("undefined"==typeof window||"function"!=typeof MessageChannel){var i=null,s=null,h=function(){if(null!==i)try{var t=e.unstable_now();i(!0,t),i=null}catch(e){throw setTimeout(h,0),e}};t=function(e){null!==i?setTimeout(t,0,e):(i=e,setTimeout(h,0))},n=function(e,t){s=setTimeout(e,t)},a=function(){clearTimeout(s)},e.unstable_shouldYield=function(){return!1},r=e.unstable_forceFrameRate=function(){}}else{var d=window.setTimeout,u=window.clearTimeout;if("undefined"!=typeof console){var m=window.cancelAnimationFrame;"function"!=typeof window.requestAnimationFrame&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"),"function"!=typeof m&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills")}var p=!1,v=null,f=-1,z=5,g=0;e.unstable_shouldYield=function(){return e.unstable_now()>=g},r=function(){},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):z=0<e?Math.floor(1e3/e):5};var y=new MessageChannel,M=y.port2;y.port1.onmessage=function(){if(null!==v){var t=e.unstable_now();g=t+z;try{v(!0,t)?M.postMessage(null):(p=!1,v=null)}catch(e){throw M.postMessage(null),e}}else p=!1},t=function(e){v=e,p||(p=!0,M.postMessage(null))},n=function(t,n){f=d((function(){t(e.unstable_now())}),n)},a=function(){u(f),f=-1}}function E(e,t){var n=e.length;e.push(t);e:for(;;){var a=n-1>>>1,r=e[a];if(!(void 0!==r&&0<V(r,t)))break e;e[a]=t,e[n]=r,n=a}}function b(e){return void 0===(e=e[0])?null:e}function H(e){var t=e[0];if(void 0!==t){var n=e.pop();if(n!==t){e[0]=n;e:for(var a=0,r=e.length;a<r;){var o=2*(a+1)-1,c=e[o],l=o+1,i=e[l];if(void 0!==c&&0>V(c,n))void 0!==i&&0>V(i,c)?(e[a]=i,e[l]=n,a=l):(e[a]=c,e[o]=n,a=o);else{if(!(void 0!==i&&0>V(i,n)))break e;e[a]=i,e[l]=n,a=l}}}return t}return null}function V(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}var C=[],L=[],x=1,S=null,k=3,w=!1,T=!1,O=!1;function A(e){for(var t=b(L);null!==t;){if(null===t.callback)H(L);else{if(!(t.startTime<=e))break;H(L),t.sortIndex=t.expirationTime,E(C,t)}t=b(L)}}function R(e){if(O=!1,A(e),!T)if(null!==b(C))T=!0,t(N);else{var a=b(L);null!==a&&n(R,a.startTime-e)}}function N(t,r){T=!1,O&&(O=!1,a()),w=!0;var o=k;try{for(A(r),S=b(C);null!==S&&(!(S.expirationTime>r)||t&&!e.unstable_shouldYield());){var c=S.callback;if("function"==typeof c){S.callback=null,k=S.priorityLevel;var l=c(S.expirationTime<=r);r=e.unstable_now(),"function"==typeof l?S.callback=l:S===b(C)&&H(C),A(r)}else H(C);S=b(C)}if(null!==S)var i=!0;else{var s=b(L);null!==s&&n(R,s.startTime-r),i=!1}return i}finally{S=null,k=o,w=!1}}var _=r;e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_continueExecution=function(){T||w||(T=!0,t(N))},e.unstable_getCurrentPriorityLevel=function(){return k},e.unstable_getFirstCallbackNode=function(){return b(C)},e.unstable_next=function(e){switch(k){case 1:case 2:case 3:var t=3;break;default:t=k}var n=k;k=t;try{return e()}finally{k=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=_,e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=k;k=e;try{return t()}finally{k=n}},e.unstable_scheduleCallback=function(r,o,c){var l=e.unstable_now();switch(c="object"==typeof c&&null!==c&&"number"==typeof(c=c.delay)&&0<c?l+c:l,r){case 1:var i=-1;break;case 2:i=250;break;case 5:i=1073741823;break;case 4:i=1e4;break;default:i=5e3}return r={id:x++,callback:o,priorityLevel:r,startTime:c,expirationTime:i=c+i,sortIndex:-1},c>l?(r.sortIndex=c,E(L,r),null===b(C)&&r===b(L)&&(O?a():O=!0,n(R,c-l))):(r.sortIndex=i,E(C,r),T||w||(T=!0,t(N))),r},e.unstable_wrapCallback=function(e){var t=k;return function(){var n=k;k=t;try{return e.apply(this,arguments)}finally{k=n}}}}(cue)),cue):oue.exports=function(){return nue||(nue=1,e=lue,"production"!==Vee.env.NODE_ENV&&function(){var t,n,a,r;if("object"==typeof performance&&"function"==typeof performance.now){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,l=c.now();e.unstable_now=function(){return c.now()-l}}if("undefined"==typeof window||"function"!=typeof MessageChannel){var i=null,s=null,h=function(){if(null!==i)try{var t=e.unstable_now();i(!0,t),i=null}catch(e){throw setTimeout(h,0),e}};t=function(e){null!==i?setTimeout(t,0,e):(i=e,setTimeout(h,0))},n=function(e,t){s=setTimeout(e,t)},a=function(){clearTimeout(s)},e.unstable_shouldYield=function(){return!1},r=e.unstable_forceFrameRate=function(){}}else{var d=window.setTimeout,u=window.clearTimeout;if("undefined"!=typeof console){var m=window.requestAnimationFrame,p=window.cancelAnimationFrame;"function"!=typeof m&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"),"function"!=typeof p&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills")}var v=!1,f=null,z=-1,g=5,y=0;e.unstable_shouldYield=function(){return e.unstable_now()>=y},r=function(){},e.unstable_forceFrameRate=function(e){e<0||e>125?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):g=e>0?Math.floor(1e3/e):5};var M=new MessageChannel,E=M.port2;M.port1.onmessage=function(){if(null!==f){var t=e.unstable_now();y=t+g;try{f(!0,t)?E.postMessage(null):(v=!1,f=null)}catch(e){throw E.postMessage(null),e}}else v=!1},t=function(e){f=e,v||(v=!0,E.postMessage(null))},n=function(t,n){z=d((function(){t(e.unstable_now())}),n)},a=function(){u(z),z=-1}}function b(e,t){var n=e.length;e.push(t),function(e,t,n){for(var a=n;;){var r=a-1>>>1,o=e[r];if(!(void 0!==o&&C(o,t)>0))return;e[r]=t,e[a]=o,a=r}}(e,t,n)}function H(e){var t=e[0];return void 0===t?null:t}function V(e){var t=e[0];if(void 0!==t){var n=e.pop();return n!==t&&(e[0]=n,function(e,t){for(var n=0,a=e.length;n<a;){var r=2*(n+1)-1,o=e[r],c=r+1,l=e[c];if(void 0!==o&&C(o,t)<0)void 0!==l&&C(l,o)<0?(e[n]=l,e[c]=t,n=c):(e[n]=o,e[r]=t,n=r);else{if(!(void 0!==l&&C(l,t)<0))return;e[n]=l,e[c]=t,n=c}}}(e,n)),t}return null}function C(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}var L=[],x=[],S=1,k=null,w=3,T=!1,O=!1,A=!1;function R(e){for(var t=H(x);null!==t;){if(null===t.callback)V(x);else{if(!(t.startTime<=e))return;V(x),t.sortIndex=t.expirationTime,b(L,t)}t=H(x)}}function N(e){if(A=!1,R(e),!O)if(null!==H(L))O=!0,t(_);else{var a=H(x);null!==a&&n(N,a.startTime-e)}}function _(t,r){O=!1,A&&(A=!1,a()),T=!0;var o=w;try{return function(t,a){var r=a;for(R(r),k=H(L);null!==k&&(!(k.expirationTime>r)||t&&!e.unstable_shouldYield());){var o=k.callback;if("function"==typeof o){k.callback=null,w=k.priorityLevel;var c=o(k.expirationTime<=r);r=e.unstable_now(),"function"==typeof c?k.callback=c:k===H(L)&&V(L),R(r)}else V(L);k=H(L)}if(null!==k)return!0;var l=H(x);return null!==l&&n(N,l.startTime-r),!1}(t,r)}finally{k=null,w=o,T=!1}}var D=r;e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_continueExecution=function(){O||T||(O=!0,t(_))},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_getFirstCallbackNode=function(){return H(L)},e.unstable_next=function(e){var t;switch(w){case 1:case 2:case 3:t=3;break;default:t=w}var n=w;w=t;try{return e()}finally{w=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=D,e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=w;w=e;try{return t()}finally{w=n}},e.unstable_scheduleCallback=function(r,o,c){var l,i,s=e.unstable_now();if("object"==typeof c&&null!==c){var h=c.delay;l="number"==typeof h&&h>0?s+h:s}else l=s;switch(r){case 1:i=-1;break;case 2:i=250;break;case 5:i=1073741823;break;case 4:i=1e4;break;default:i=5e3}var d=l+i,u={id:S++,callback:o,priorityLevel:r,startTime:l,expirationTime:d,sortIndex:-1};return l>s?(u.sortIndex=l,b(x,u),null===H(L)&&u===H(x)&&(A?a():A=!0,n(N,l-s))):(u.sortIndex=d,b(L,u),O||T||(O=!0,t(_))),u},e.unstable_wrapCallback=function(e){var t=w;return function(){var n=w;w=t;try{return e.apply(this,arguments)}finally{w=n}}}}()),lue;var e}()),oue.exports}
301
+ const q8=B8("volume-2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]),G8=B8("volume-off",[["path",{d:"M16 9a5 5 0 0 1 .95 2.293",key:"1fgyg8"}],["path",{d:"M19.364 5.636a9 9 0 0 1 1.889 9.96",key:"l3zxae"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"m7 7-.587.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298V11",key:"1gbwow"}],["path",{d:"M9.828 4.172A.686.686 0 0 1 11 4.657v.686",key:"s2je0y"}]]);B8("volume-x",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);B8("volume",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}]]);B8("vote",[["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}],["path",{d:"M5 7c0-1.1.9-2 2-2h10a2 2 0 0 1 2 2v12H5V7Z",key:"1ezoue"}],["path",{d:"M22 19H2",key:"nuriw5"}]]);B8("wallet-cards",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2",key:"4125el"}],["path",{d:"M3 11h3c.8 0 1.6.3 2.1.9l1.1.9c1.6 1.6 4.1 1.6 5.7 0l1.1-.9c.5-.5 1.3-.9 2.1-.9H21",key:"1dpki6"}]]);B8("wallet-minimal",[["path",{d:"M17 14h.01",key:"7oqj8z"}],["path",{d:"M7 7h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14",key:"u1rqew"}]]);B8("wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]);B8("wallpaper",[["circle",{cx:"8",cy:"9",r:"2",key:"gjzl9d"}],["path",{d:"m9 17 6.1-6.1a2 2 0 0 1 2.81.01L22 15V5a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2",key:"69xh40"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}]]);B8("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);B8("wand",[["path",{d:"M15 4V2",key:"z1p9b7"}],["path",{d:"M15 16v-2",key:"px0unx"}],["path",{d:"M8 9h2",key:"1g203m"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M17.8 11.8 19 13",key:"yihg8r"}],["path",{d:"M15 9h.01",key:"x1ddxp"}],["path",{d:"M17.8 6.2 19 5",key:"fd4us0"}],["path",{d:"m3 21 9-9",key:"1jfql5"}],["path",{d:"M12.2 6.2 11 5",key:"i3da3b"}]]);B8("warehouse",[["path",{d:"M18 21V10a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1v11",key:"pb2vm6"}],["path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 1.132-1.803l7.95-3.974a2 2 0 0 1 1.837 0l7.948 3.974A2 2 0 0 1 22 8z",key:"doq5xv"}],["path",{d:"M6 13h12",key:"yf64js"}],["path",{d:"M6 17h12",key:"1jwigz"}]]);B8("washing-machine",[["path",{d:"M3 6h3",key:"155dbl"}],["path",{d:"M17 6h.01",key:"e2y6kg"}],["rect",{width:"18",height:"20",x:"3",y:"2",rx:"2",key:"od3kk9"}],["circle",{cx:"12",cy:"13",r:"5",key:"nlbqau"}],["path",{d:"M12 18a2.5 2.5 0 0 0 0-5 2.5 2.5 0 0 1 0-5",key:"17lach"}]]);B8("watch",[["path",{d:"M12 10v2.2l1.6 1",key:"n3r21l"}],["path",{d:"m16.13 7.66-.81-4.05a2 2 0 0 0-2-1.61h-2.68a2 2 0 0 0-2 1.61l-.78 4.05",key:"18k57s"}],["path",{d:"m7.88 16.36.8 4a2 2 0 0 0 2 1.61h2.72a2 2 0 0 0 2-1.61l.81-4.05",key:"16ny36"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}]]);B8("waves-ladder",[["path",{d:"M19 5a2 2 0 0 0-2 2v11",key:"s41o68"}],["path",{d:"M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"rd2r6e"}],["path",{d:"M7 13h10",key:"1rwob1"}],["path",{d:"M7 9h10",key:"12czzb"}],["path",{d:"M9 5a2 2 0 0 0-2 2v11",key:"x0q4gh"}]]);B8("waves",[["path",{d:"M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"knzxuh"}],["path",{d:"M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"2jd2cc"}],["path",{d:"M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"rd2r6e"}]]);B8("waypoints",[["circle",{cx:"12",cy:"4.5",r:"2.5",key:"r5ysbb"}],["path",{d:"m10.2 6.3-3.9 3.9",key:"1nzqf6"}],["circle",{cx:"4.5",cy:"12",r:"2.5",key:"jydg6v"}],["path",{d:"M7 12h10",key:"b7w52i"}],["circle",{cx:"19.5",cy:"12",r:"2.5",key:"1piiel"}],["path",{d:"m13.8 17.7 3.9-3.9",key:"1wyg1y"}],["circle",{cx:"12",cy:"19.5",r:"2.5",key:"13o1pw"}]]);B8("webcam",[["circle",{cx:"12",cy:"10",r:"8",key:"1gshiw"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 22h10",key:"10w4w3"}],["path",{d:"M12 22v-4",key:"1utk9m"}]]);B8("webhook-off",[["path",{d:"M17 17h-5c-1.09-.02-1.94.92-2.5 1.9A3 3 0 1 1 2.57 15",key:"1tvl6x"}],["path",{d:"M9 3.4a4 4 0 0 1 6.52.66",key:"q04jfq"}],["path",{d:"m6 17 3.1-5.8a2.5 2.5 0 0 0 .057-2.05",key:"azowf0"}],["path",{d:"M20.3 20.3a4 4 0 0 1-2.3.7",key:"5joiws"}],["path",{d:"M18.6 13a4 4 0 0 1 3.357 3.414",key:"cangb8"}],["path",{d:"m12 6 .6 1",key:"tpjl1n"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);B8("webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]);B8("weight",[["circle",{cx:"12",cy:"5",r:"3",key:"rqqgnr"}],["path",{d:"M6.5 8a2 2 0 0 0-1.905 1.46L2.1 18.5A2 2 0 0 0 4 21h16a2 2 0 0 0 1.925-2.54L19.4 9.5A2 2 0 0 0 17.48 8Z",key:"56o5sh"}]]);B8("wheat-off",[["path",{d:"m2 22 10-10",key:"28ilpk"}],["path",{d:"m16 8-1.17 1.17",key:"1qqm82"}],["path",{d:"M3.47 12.53 5 11l1.53 1.53a3.5 3.5 0 0 1 0 4.94L5 19l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1rdhi6"}],["path",{d:"m8 8-.53.53a3.5 3.5 0 0 0 0 4.94L9 15l1.53-1.53c.55-.55.88-1.25.98-1.97",key:"4wz8re"}],["path",{d:"M10.91 5.26c.15-.26.34-.51.56-.73L13 3l1.53 1.53a3.5 3.5 0 0 1 .28 4.62",key:"rves66"}],["path",{d:"M20 2h2v2a4 4 0 0 1-4 4h-2V6a4 4 0 0 1 4-4Z",key:"19rau1"}],["path",{d:"M11.47 17.47 13 19l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L5 19l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"tc8ph9"}],["path",{d:"m16 16-.53.53a3.5 3.5 0 0 1-4.94 0L9 15l1.53-1.53a3.49 3.49 0 0 1 1.97-.98",key:"ak46r"}],["path",{d:"M18.74 13.09c.26-.15.51-.34.73-.56L21 11l-1.53-1.53a3.5 3.5 0 0 0-4.62-.28",key:"1tw520"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);B8("wheat",[["path",{d:"M2 22 16 8",key:"60hf96"}],["path",{d:"M3.47 12.53 5 11l1.53 1.53a3.5 3.5 0 0 1 0 4.94L5 19l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1rdhi6"}],["path",{d:"M7.47 8.53 9 7l1.53 1.53a3.5 3.5 0 0 1 0 4.94L9 15l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1sdzmb"}],["path",{d:"M11.47 4.53 13 3l1.53 1.53a3.5 3.5 0 0 1 0 4.94L13 11l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"eoatbi"}],["path",{d:"M20 2h2v2a4 4 0 0 1-4 4h-2V6a4 4 0 0 1 4-4Z",key:"19rau1"}],["path",{d:"M11.47 17.47 13 19l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L5 19l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"tc8ph9"}],["path",{d:"M15.47 13.47 17 15l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L9 15l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"2m8kc5"}],["path",{d:"M19.47 9.47 21 11l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L13 11l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"vex3ng"}]]);B8("whole-word",[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]]);B8("wifi-cog",[["path",{d:"m14.305 19.53.923-.382",key:"3m78fa"}],["path",{d:"m15.228 16.852-.923-.383",key:"npixar"}],["path",{d:"m16.852 15.228-.383-.923",key:"5xggr7"}],["path",{d:"m16.852 20.772-.383.924",key:"dpfhf9"}],["path",{d:"m19.148 15.228.383-.923",key:"1reyyz"}],["path",{d:"m19.53 21.696-.382-.924",key:"1goivc"}],["path",{d:"M2 7.82a15 15 0 0 1 20 0",key:"1ovjuk"}],["path",{d:"m20.772 16.852.924-.383",key:"htqkph"}],["path",{d:"m20.772 19.148.924.383",key:"9w9pjp"}],["path",{d:"M5 11.858a10 10 0 0 1 11.5-1.785",key:"3sn16i"}],["path",{d:"M8.5 15.429a5 5 0 0 1 2.413-1.31",key:"1pxovh"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]]);B8("wifi-high",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);B8("wifi-low",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);B8("wifi-off",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);B8("wifi-pen",[["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1817ys"}],["path",{d:"M5 12.859a10 10 0 0 1 10.5-2.222",key:"rpb7oy"}],["path",{d:"M8.5 16.429a5 5 0 0 1 3-1.406",key:"r8bmzl"}]]);B8("wifi-zero",[["path",{d:"M12 20h.01",key:"zekei9"}]]);B8("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);B8("wind-arrow-down",[["path",{d:"M10 2v8",key:"d4bbey"}],["path",{d:"M12.8 21.6A2 2 0 1 0 14 18H2",key:"19kp1d"}],["path",{d:"M17.5 10a2.5 2.5 0 1 1 2 4H2",key:"19kpjc"}],["path",{d:"m6 6 4 4 4-4",key:"k13n16"}]]);B8("wine-off",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M7 10h3m7 0h-1.343",key:"v48bem"}],["path",{d:"M12 15v7",key:"t2xh3l"}],["path",{d:"M7.307 7.307A12.33 12.33 0 0 0 7 10a5 5 0 0 0 7.391 4.391M8.638 2.981C8.75 2.668 8.872 2.34 9 2h6c1.5 4 2 6 2 8 0 .407-.05.809-.145 1.198",key:"1ymjlu"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);B8("wind",[["path",{d:"M12.8 19.6A2 2 0 1 0 14 16H2",key:"148xed"}],["path",{d:"M17.5 8a2.5 2.5 0 1 1 2 4H2",key:"1u4tom"}],["path",{d:"M9.8 4.4A2 2 0 1 1 11 8H2",key:"75valh"}]]);B8("wine",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M12 15v7",key:"t2xh3l"}],["path",{d:"M12 15a5 5 0 0 0 5-5c0-2-.5-4-2-8H9c-1.5 4-2 6-2 8a5 5 0 0 0 5 5Z",key:"10ffi3"}]]);B8("workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);B8("worm",[["path",{d:"m19 12-1.5 3",key:"9bcu4o"}],["path",{d:"M19.63 18.81 22 20",key:"121v98"}],["path",{d:"M6.47 8.23a1.68 1.68 0 0 1 2.44 1.93l-.64 2.08a6.76 6.76 0 0 0 10.16 7.67l.42-.27a1 1 0 1 0-2.73-4.21l-.42.27a1.76 1.76 0 0 1-2.63-1.99l.64-2.08A6.66 6.66 0 0 0 3.94 3.9l-.7.4a1 1 0 1 0 2.55 4.34z",key:"1tij6q"}]]);B8("wrap-text",[["path",{d:"m16 16-2 2 2 2",key:"kkc6pm"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["path",{d:"M3 18h7",key:"sq21v6"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]);B8("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);B8("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);B8("youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]);B8("zap-off",[["path",{d:"M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317",key:"193nxd"}],["path",{d:"M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773",key:"27a7lr"}],["path",{d:"M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643",key:"1e0qe9"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);B8("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);B8("zoom-in",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);B8("zoom-out",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);var Y8=function(e){var a=e.amplitude,r=e.variant,o=e.isActive,c=e.className,l=void 0===c?"":c,i=e.onClick,s=e.disabled,d=void 0!==s&&s,u=e.isConnecting,m=n.useState(Array(40).fill(4)),p=m[0],v=m[1],f=n.useRef(null),z=function(){var e=Math.min(Math.max(a,0),1),t=Math.max(e,.2),n=Array(40).fill(0).map((function(e,n){var a=Math.sin(n+Date.now()/100)+.5*Math.random();return 5+9*Math.abs(a)*t}));v(n),f.current=requestAnimationFrame(z)};n.useEffect((function(){return o?f.current=requestAnimationFrame(z):(v(Array(40).fill(4)),f.current&&cancelAnimationFrame(f.current)),function(){f.current&&cancelAnimationFrame(f.current)}}),[o,a]);var g=o?"#364152":"#D0D4DB",y="microphone"===r?o||u?$8:W8:o?q8:G8;return t.jsxs("div",h({className:l,style:{position:"relative",height:"3rem",zIndex:50,width:"100%",overflow:"hidden",display:"flex",alignItems:"center"}},{children:[t.jsx("div",h({style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",height:"2rem",gap:"0.25rem"}},{children:p.map((function(e,n){return t.jsx("div",{style:{flexShrink:0,width:"4px",borderRadius:"9999px",transition:"all 100ms",backgroundColor:g,height:"".concat(e,"px"),opacity:o?1:.4}},n)}))})),t.jsx("button",h({onClick:i,disabled:d,"aria-label":"".concat(r," button"),style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",width:"2rem",height:"2rem",borderRadius:"9999px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 200ms",backgroundColor:"white",border:"1px solid ".concat(g),cursor:d?"not-allowed":"pointer"}},{children:t.jsx(y,{color:g,className:u?"animate-spin":"",style:{width:"1.25rem",height:"1.25rem"}})}))]}))};v(".welcome-message{align-items:flex-start;animation:fadeSlideIn 1.2s ease-out forwards;border-radius:.5rem;color:#333;display:fixed;font-size:1rem;line-height:1.75rem;max-width:100%;opacity:0;overflow-wrap:break-word;padding:1rem;transform:translateY(10px);white-space:pre-wrap;word-break:break-word}@keyframes fadeSlideIn{to{opacity:1;transform:translateY(0)}}");var K8=function(e){var a=e.label,r=e.onToggle,o=n.useState(!1),c=o[0],l=o[1],i=n.useRef(null);return n.useEffect((function(){var e=i.current;e&&c&&(e.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.1)",e.style.transform="scale(1)",e.style.backgroundColor="#E8F5E9",e.style.color="#2E7D32")}),[c]),t.jsxs("span",h({ref:i,onClick:function(){var e=!c;console.log("newstate: ",e),l(e),r(a,e)},style:{cursor:"pointer",backgroundColor:c?"#E8F5E9":"#fff",color:c?"#2E7D32":"#000000de",transition:"all 0.2s ease-in-out",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.2)",transform:"scale(1)"},onMouseEnter:function(e){c||(e.currentTarget.style.boxShadow="0 4px 12px rgba(30, 136, 229, 0.3)",e.currentTarget.style.transform="scale(1.02)",e.currentTarget.style.backgroundColor="#f0f7ff",e.currentTarget.style.color="#1E88E5")},onMouseLeave:function(e){c||(e.currentTarget.style.boxShadow="0 2px 4px rgba(0, 0, 0, 0.2)",e.currentTarget.style.transform="scale(1)",e.currentTarget.style.backgroundColor="#fbfaff",e.currentTarget.style.color="#000000de")}},{children:[t.jsx("span",h({style:{fontWeight:"bold",fontSize:"16px",transition:"all 0.3s ease",transform:c?"scale(1.2)":"scale(1)",opacity:c?1:.9,paddingLeft:"0.25rem",paddingRight:"0.25rem"}},{children:c?"✓":"+"})),t.jsx("span",{children:a})]}))};function X8(e){return"string"==typeof e?e:Array.isArray(e)?e.map(X8).join(""):"object"==typeof e&&null!==e&&"props"in e?X8(e.props.children):""}var Q8=function(e){var a=e.label,r=e.onToggle,o=n.useState(!1),c=o[0],l=o[1],i=n.useRef(null);return n.useEffect((function(){var e=i.current;e&&c&&(e.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.1)",e.style.transform="scale(1)",e.style.backgroundColor="#E8F5E9",e.style.color="#2E7D32")}),[c]),t.jsxs("span",h({ref:i,onClick:function(){var e=!c;console.log("newstate: ",e),l(e),r(X8(a),e)},style:{cursor:"pointer",backgroundColor:c?"#E8F5E9":"#fff",color:c?"#2E7D32":"#000000de",transition:"all 0.2s ease-in-out",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.2)",transform:"scale(1)"},onMouseEnter:function(e){c||(e.currentTarget.style.boxShadow="0 4px 12px rgba(30, 136, 229, 0.3)",e.currentTarget.style.transform="scale(1.02)",e.currentTarget.style.backgroundColor="#f0f7ff",e.currentTarget.style.color="#1E88E5")},onMouseLeave:function(e){c||(e.currentTarget.style.boxShadow="0 2px 4px rgba(0, 0, 0, 0.2)",e.currentTarget.style.transform="scale(1)",e.currentTarget.style.backgroundColor="#fbfaff",e.currentTarget.style.color="#000000de")}},{children:[t.jsx("span",h({style:{fontWeight:"bold",fontSize:"16px",transition:"all 0.3s ease",transform:c?"scale(1.2)":"scale(1)",opacity:c?1:.9,paddingLeft:"0.25rem",paddingRight:"0.25rem"}},{children:c?"✓":"+"})),t.jsx("span",{children:a})]}))},J8=function(e){var a=e.index,r=e.content,o=e.messages,c=e.handleStream,l=e.scrollToBottom,i=n.useState([]),s=i[0],u=i[1],m=n.useState(!1),v=m[0],f=m[1],z=n.useState([]),g=z[0],y=z[1],M=n.useState(!1),E=M[0],b=M[1],H=n.useState([]),V=H[0],C=H[1],L=n.useState([]),x=L[0],S=L[1],k=n.useMemo((function(){return{img:function(e){e.node;var n=d(e,["node"]);return t.jsx("img",h({},n,{style:{height:"100%",width:"100%",objectFit:"contain"},alt:(null==n?void 0:n.alt)||"",className:"w-full sm:max-w-lg md:max-w-2xl lg:max-w-4xl mx-auto"}))},p:function(e){e.node;var n=d(e,["node"]);return t.jsx("p",h({},n,{style:{maxWidth:"100%",wordWrap:"break-word",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal",overflow:"hidden",display:"block",fontSize:"1rem",lineHeight:"1.625rem",marginBottom:"1rem",marginTop:"10px"}},{children:null==n?void 0:n.children}))},code:function(e){e.node;var n=d(e,["node"]);return t.jsx("span",h({},n,{style:{maxWidth:"100%",wordWrap:"break-word",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal",overflow:"hidden",display:"inline-flex",fontSize:"1rem",lineHeight:"1.625rem"}},{children:null==n?void 0:n.children}))},ol:function(e){e.node;var n=d(e,["node"]);return t.jsx("ol",h({},n,{style:{display:"flex",flexDirection:"column",gap:"1rem",listStyle:"decimal",paddingLeft:"2.5rem"}},{children:null==n?void 0:n.children}))},ul:function(e){e.node;var n=d(e,["node"]);return t.jsx("ul",h({},n,{style:{display:"flex",flexDirection:"column",gap:"1rem",listStyle:"decimal",paddingLeft:"2.5rem"}},{children:null==n?void 0:n.children}))},wta:function(e){e.node;var n=d(e,["node"]);n.key||n["data-key"];var a=n.label||n.children||"Unknown label";return t.jsx(K8,{label:a,onToggle:function(e,t){!function(e,t){console.log(e,t);var n=Array.isArray(e)?e[0]:e;f(!0),u((function(e){return t?e.includes(n)?e:p(p([],e,!0),[n],!1):e.filter((function(e){return e!==n}))}))}(e,t)}})},editwta:function(e){e.node;var n=d(e,["node"]);n.key||n["data-key"];var a=n.label||n.children||"Unknown label";return t.jsx(Q8,{label:a,onToggle:function(e,t){!function(e,t){var n=Array.isArray(e)?e[0]:e;b(!0),y((function(e){return t?e.includes(n)?e:p(p([],e,!0),[n],!1):e.filter((function(e){return e!==n}))})),null==l||l()}(e,t)}})}}}),[r,o,x]);!function(e,t){n.useEffect((function(){for(var n,a=0,r=(null===(n=e[e.length-1])||void 0===n?void 0:n.orchestratorAndAgentsMessages)||[];a<r.length;a++){for(var o=r[a],c=(null==o?void 0:o.responsedata)||"",l=/<wta>([\s\S]*?)<\/wta>/gi,i=[],s=void 0;null!==(s=l.exec(c));)console.log("match wta suggestion",s),i.push(s[1]);i.length&&t(i)}}),[e,t])}(o,C);!function(e){n.useEffect((function(){for(var t,n=0,a=(null===(t=e[e.length-1])||void 0===t?void 0:t.orchestratorAndAgentsMessages)||[];n<a.length;n++){for(var r=a[n],o=(null==r?void 0:r.responsedata)||"",c=/<editwta>([\s\S]*?)<\/editwta>/gi,l=[],i=void 0;null!==(i=c.exec(o));)console.log("match wta suggestion",i),l.push(i[1]);l.length&&S(l)}}),[e,S])}(o);var w=n.useMemo((function(){if(!Array.isArray(s)||!Array.isArray(V))return"";var e=s.map((function(e){return V.indexOf(e)})).filter((function(e){return-1!==e})).map((function(e){return e+1}));return e.join(" and ")}),[s,V]),T=n.useMemo((function(){if(!Array.isArray(g)||!Array.isArray(x))return"";var e=g.map((function(e){var t;return null===(t=x.map((function(e){return null==e?void 0:e.replaceAll("**","")})))||void 0===t?void 0:t.indexOf(e)})).filter((function(e){return-1!==e})).map((function(e){return e+1}));return e.join(" and ")}),[g,x]);return t.jsxs(t.Fragment,{children:[t.jsx(cM,h({components:k,rehypePlugins:[eC]},{children:r}),a),t.jsx("div",h({style:{display:"flex",maxWidth:"100%"}},{children:t.jsx("div",h({style:{width:"100%"}},{children:(null==s?void 0:s.length)>0&&v?t.jsxs("span",{children:["It looks like you’ve chosen ",s.length>1?"suggestions":"suggestion"," ",w,". Would you like me to proceed with them?",t.jsx("p",{children:t.jsx("button",h({style:{padding:"0.5rem 1rem",margin:"1rem 0rem",backgroundColor:"#4CAF50",color:"white",border:"none",borderRadius:"8px",cursor:"pointer",fontSize:"0.75rem",fontWeight:"500",boxShadow:"0 2px 5px rgba(0, 0, 0, 0.2)",transition:"background-color 0.3s",fontFamily:"Plus Jakarta Sans, sans-serif"},onClick:function(e){c(new KeyboardEvent("keydown",{key:"Enter"}),!1,"Add when to apply conditions ".concat(s.join(" or "))),f(!1)}},{children:"Yes"}))})]}):t.jsx("span",{})}))})),t.jsx("div",h({style:{display:"flex",maxWidth:"100%"}},{children:t.jsx("div",h({style:{width:"100%"}},{children:(null==g?void 0:g.length)>0&&E?t.jsxs("span",{children:["It looks like you’ve chosen ",g.length>1?"options":"option"," ",T,". Would you like me to proceed with them?",t.jsx("p",{children:t.jsx("button",h({style:{padding:"0.5rem 1rem",margin:"1rem 0rem",backgroundColor:"#4CAF50",color:"white",border:"none",borderRadius:"8px",cursor:"pointer",fontSize:"0.75rem",fontWeight:"500",boxShadow:"0 2px 5px rgba(0, 0, 0, 0.2)",transition:"background-color 0.3s",fontFamily:"Plus Jakarta Sans, sans-serif"},onClick:function(e){var t;c(new KeyboardEvent("keydown",{key:"Enter"}),!1,"".concat(null===(t=g.join(" or "))||void 0===t?void 0:t.replace(/\b\d+[A-Z]?\.\s*/g,""))),y([]),b(!1)}},{children:"Yes"}))})]}):t.jsx("span",{})}))}))]})};function Z8(e){return e.replace(/\bFalse\b/g,"false").replace(/\bTrue\b/g,"true").replace(/([{,]\s*)'([^']+?)'\s*:/g,'$1"$2":').replace(/:\s*'([^']*?)'/g,(function(e,t){var n=t.replace(/"/g,'\\"');return': "'.concat(n,'"')})).replace(/\bNone\b/g,"null")}var e7,t7,n7=function(){return t.jsx("svg",h({width:"20px",height:"20px",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:t.jsx("path",{d:"M9.91158 12H7.45579H4L2.02268 4.13539C2.0111 4.0893 2.00193 4.04246 2.00046 3.99497C1.97811 3.27397 2.77209 2.77366 3.46029 3.10388L22 12L3.46029 20.8961C2.77983 21.2226 1.99597 20.7372 2.00002 20.0293C2.00038 19.9658 2.01455 19.9032 2.03296 19.8425L3.5 15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}))},a7=function(e){var n=e.resetChatHistory,a=e.isStreamEnd;return t.jsxs("div",h({className:T8,style:{width:"100%",padding:"0.75rem 0rem",display:"flex",alignItems:"center",justifyContent:"space-between",backgroundColor:"#fff",borderBottom:"1px solid #e5e7eb",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.04)"}},{children:[t.jsxs("span",h({style:{fontSize:"1.25rem",fontWeight:700,color:"#1f2937",flex:1,marginLeft:"0.5rem",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:[t.jsx("span",h({style:{color:"#5928ED"}},{children:"InstantLearning.AI"}))," Chat"]})),t.jsx(vJ,h({title:"New chat",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx("div",h({onClick:function(){console.log(w8,"hello"),a&&n()},style:{height:"1.8rem",width:"1.8rem",marginLeft:"1rem",marginRight:"0.5rem",cursor:a?"pointer":"not-allowed",backgroundColor:"transparent",transition:"transform 0.2s ease-in-out, opacity 0.2s",opacity:a?.8:.4,pointerEvents:a?"auto":"none"},onMouseOver:function(e){a&&(e.currentTarget.style.opacity="1")},onMouseOut:function(e){a&&(e.currentTarget.style.opacity="0.8")}},{children:t.jsx(w8,{})}))}))]}))},r7=function(e){var a=e.label,r=e.onToggle,o=n.useState(!1),c=o[0],l=o[1],i=n.useRef(null);return n.useEffect((function(){var e=i.current;e&&c&&(e.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.1)",e.style.transform="scale(1)",e.style.backgroundColor="#E8F5E9",e.style.color="#2E7D32")}),[c]),t.jsxs("span",h({ref:i,onClick:function(){var e=!c;l(e),r(a,e)},style:{cursor:"pointer",backgroundColor:c?"#E8F5E9":"#fbfaff",color:c?"#2E7D32":"#000000de",transition:"all 0.2s ease-in-out",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.2)",transform:"scale(1)"},onMouseEnter:function(e){c||(e.currentTarget.style.boxShadow="0 4px 12px rgba(30, 136, 229, 0.3)",e.currentTarget.style.transform="scale(1.02)",e.currentTarget.style.backgroundColor="#f0f7ff",e.currentTarget.style.color="#1E88E5")},onMouseLeave:function(e){c||(e.currentTarget.style.boxShadow="0 2px 4px rgba(0, 0, 0, 0.2)",e.currentTarget.style.transform="scale(1)",e.currentTarget.style.backgroundColor="#fbfaff",e.currentTarget.style.color="#000000de")}},{children:[t.jsx("span",h({style:{fontWeight:"bold",fontSize:"16px",transition:"all 0.3s ease",transform:c?"scale(1.2)":"scale(1)",opacity:c?1:.9,paddingLeft:"0.25rem",paddingRight:"0.25rem"}},{children:c?"✓":"+"})),t.jsx("span",{children:a})]}))},o7=function(e){e.chatAssistantLogoUrl;var a=e.chatAssistantName,r=e.organizationName,o=e.baseUrl,c=e.setInstantLearningSuggestions,l=e.formDataState,i=e.setFormDataState;e.hasUserFilledForm;var s=e.setHasUserFilledForm,v=e.baseWebsocketUrl,f=e.setIsNewChatClicked;e.selectedText,e.ChatIconComponent,e.ggcAssistantName;var z=e.ThinkingBulbIconComponent;e.hasUserWrittenModification;var g=e.setExtractedModification,y=e.setSave,M=e.setExtractedTooltip,E=e.setIsSaveLoading;e.isSaveLoading,e.save,e.instantLearningSuggestions,e.template;var b=e.setShouldTriggerSave,H=e.validationWtaResponse,V=e.setValidationWtaResponse,C=e.learningWtaResponse,L=e.setLearningWtaResponse,x=e.isFormSaveClicked,S=e.setIsFormSavedClicked,k=a,w=n.useRef("".concat(k,"-").concat(r,"-").concat(V8())),T=n.useRef("".concat(V8())),O=o,A=n.useRef(null),R=n.useRef(null),N=n.useState([]),_=N[0],D=N[1],P=n.useState(!1);P[0];var F=P[1],I=n.useState(""),j=I[0],B=I[1],U=n.useState(""),W=U[0],$=U[1],q=n.useState([]),G=q[0],Y=q[1],K=n.useState(!1),X=K[0],Q=K[1],J=n.useState(!1);J[0];var Z=J[1],ee=n.useState(!0),te=ee[0],ne=ee[1],ae=n.useState(!0),re=ae[0],oe=ae[1],ce=n.useState("");ce[0];var le=ce[1],ie=n.useState(""),se=ie[0],he=ie[1],de=n.useState(!1),ue=de[0],me=de[1],pe=n.useState(!1),ve=pe[0],fe=pe[1],ze=n.useState(!1),ge=ze[0],ye=ze[1],Me=n.useState([]);Me[0];var Ee=Me[1],be=n.useMemo((function(){return""===(null==j?void 0:j.trim())||ue}),[j,ue]),He=n.useRef(null),Ve=n.useState("100%"),Ce=Ve[0],Le=Ve[1];n.useMemo((function(){var e,t,n;return!(""===(null===(e=null==l?void 0:l.original)||void 0===e?void 0:e.trim())||(null==l?void 0:l.isTooltipEnabled)&&""===(null===(t=null==l?void 0:l.tooltip)||void 0===t?void 0:t.trim())||(null==l?void 0:l.isModificationEnabled)&&""===(null===(n=null==l?void 0:l.modification)||void 0===n?void 0:n.trim()))}),[l]),n.useEffect((function(){var e="Please tell me how I should correct “".concat((null==l?void 0:l.original)||"","”? ");$(e)}),[l]),n.useEffect((function(){var e=A.current,t=function(){var e=A.current;if(e){var t=e.scrollTop,n=e.scrollHeight,a=e.clientHeight;ye(!(n-(t+a)<=35))}};return e&&(e.addEventListener("scroll",t),t()),function(){e&&e.removeEventListener("scroll",t)}}),[ge,te,G]);var xe=function(e){return n.useMemo((function(){for(var t,n=[],a=/['"]conditions_whentoapply['"]\s*:\s*(\[\s*\]|\[\s*\{\s*['"]when_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\2).)*\2\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\}(?:\s*,\s*\{\s*['"]when_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\3).)*\3\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\})*\s*\])\s*,\s*['"]conditions_whennottoapply['"]\s*:\s*(\[\s*\]|\[\s*\{\s*['"]when_not_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\5).)*\5\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\}(?:\s*,\s*\{\s*['"]when_not_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\6).)*\6\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\})*\s*\])/,r=/['"]is_valid['"]\s*:\s*(true|false|True|False)\s*,\s*['"]conflictingConditions['"]\s*:\s*\[\s*(\{[\s\S]*?['"]conflictType['"]\s*:\s*['"][^'"]+['"][\s\S]*?\}\s*,?\s*)*\]/,o=/['"]is_valid_db['"]\s*:\s*(true|false|True|False)\s*,\s*['"]conflicting_learnings['"]\s*:\s*\[[\s\S]*?\]\s*,\s*['"]similar_learnings['"]\s*:\s*\[[\s\S]*?\]/,c=0,l=(null===(t=e[e.length-1])||void 0===t?void 0:t.orchestratorAndAgentsMessages)||[];c<l.length;c++){var i=l[c],s=(null==i?void 0:i.responsedata)||"";console.log("Ressponse Data",String(s));var h=s.match(a);if(h)try{var d=N8.parse("{".concat(h[0],"}"));n.push(d)}catch(e){console.error("Failed to parse JSON:",e)}var u=s.match(r);if(console.log("validationObj before cond "),u)try{var m=Z8(u[0]||""),p=N8.parse("{".concat(m,"}"));console.log("validationObj before set ",p),V(p),console.log("validationObj after set in chat",H)}catch(e){console.error("Failed to parse validation JSON:",e)}var v=s.match(o);if(v)try{var f=Z8(v[0]||""),z=N8.parse("{".concat(f,"}"));L(z),console.log("dbVal after set in chat",C)}catch(e){console.error("Failed to parse validation JSON:",e)}}return n}),[e])}(G);n.useEffect((function(){var e=(null==xe?void 0:xe[(null==xe?void 0:xe.length)-1])||null;e&&(c(e),console.log("Parsed suggestions:",xe))}),[xe]);var Se=function(e){return n.useMemo((function(){for(var t,n=[],a=/['"](\w+)['"]\s*:\s*['"](.*?)['"]/g,r=0,o=(null===(t=e[e.length-1])||void 0===t?void 0:t.orchestratorAndAgentsMessages)||[];r<o.length;r++){var c=o[r],l=((null==c?void 0:c.responsedata)||"").match(a);if(l)try{var i=N8.parse("{".concat(l[0],"}"));n.push(i)}catch(e){console.error("Failed to parse JSON for header message:",e)}}return n}),[e])}(G);n.useEffect((function(){var e=(null==Se?void 0:Se[(null==Se?void 0:Se.length)-1])||null;e&&g(e.modification)}),[Se]);!function(e,t){n.useEffect((function(){for(var n,a=0,r=(null===(n=e[e.length-1])||void 0===n?void 0:n.orchestratorAndAgentsMessages)||[];a<r.length;a++){for(var o=r[a],c=(null==o?void 0:o.responsedata)||"",l=/<wta>([\s\S]*?)<\/wta>/gi,i=[],s=void 0;null!==(s=l.exec(c));)console.log("match wta suggestion",s),i.push(s[1]);i.length&&t(i)}}),[e,t])}(G,Ee);var ke=function(e){return n.useMemo((function(){for(var t,n=[],a=/^\{\s*(['"])(\w+)\1\s*:\s*(['"])(.*?)\3\s*\}$/,r=0,o=(null===(t=e[e.length-1])||void 0===t?void 0:t.orchestratorAndAgentsMessages)||[];r<o.length;r++){var c=o[r],l=((null==c?void 0:c.responsedata)||"").match(a);if(l){console.log("match: ",l[0]);try{var i=N8.parse(l[0]);n.push(i)}catch(e){console.error("Failed to parse JSON:",e)}}}return n}),[e])}(G);n.useEffect((function(){var e=(null==ke?void 0:ke[(null==ke?void 0:ke.length)-1])||null;e&&(console.log("latestParseTooltip: ",e),M(null==e?void 0:e.tooltip))}),[ke]);var we=function(e){var t=n.useState([]),a=t[0],r=t[1];return n.useEffect((function(){for(var t,n=[],a=/\{\s*['"]save['"]\s*:\s*(True|False|true|false)\s*\}/,o=0,c=(null===(t=e[e.length-1])||void 0===t?void 0:t.orchestratorAndAgentsMessages)||[];o<c.length;o++){var l=c[o],i=((null==l?void 0:l.responsedata)||"").match(a);if(i)try{var s=i[0].replace(/\bTrue\b/,"true").replace(/\bFalse\b/,"false").replace(/'/g,'"');console.log("corrected:",s);var h=N8.parse(s);!0===h.save&&b(!0),n.push(h)}catch(e){console.error("Failed to parse JSON:",e)}}r(n)}),[e]),a}(G);n.useEffect((function(){var e=(null==we?void 0:we[(null==we?void 0:we.length)-1])||null;if(e&&"boolean"==typeof e.save){E(!0);var t=setTimeout((function(){E(!1),y(e.save)}),200);return function(){clearTimeout(t)}}}),[we]),n.useEffect((function(){x&&(_e(new KeyboardEvent("keydown",{key:"Enter"}),!1,"Save it"),S(!1))}),[x]),n.useEffect((function(){Oe(),Ae();var e=function(){var e,t=(null===(e=null==He?void 0:He.current)||void 0===e?void 0:e.clientHeight)||0,n="calc(100% - ".concat(t,"px - 10px");Le(n)};return e(),window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[]);var Te=n.useCallback((function(){var e=A.current;e&&setTimeout((function(){e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),ye(!1)}),100)}),[]);n.useEffect((function(){(null==_?void 0:_.length)>0&&Te()}),[_]);var Oe=function(){var e={method:"get",maxBodyLength:1/0,url:"".concat(O,"/api/chatbot/getChatSettings?name=").concat(k,"&organizationName=").concat(r),headers:{}};ES.request(e).then((function(e){var t,n,a;(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.chatSettings)&&""!==(null===(a=null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.chatSettings)||void 0===a?void 0:a.chatInitialMessage)&&oe(!0)})).catch((function(e){console.error(e)}))},Ae=function(){return u(void 0,void 0,void 0,(function(){var e,t;return m(this,(function(n){e="".concat(O,"/api/chat/history?name=").concat(k,"&organizationName=").concat(r);try{t={method:"GET",params:{guestSessionId:w.current},withCredentials:!0},ES.get(e,t).then((function(e){var t=e.data;t.length>0?(Y(t),Te()):oe(!0)})).catch((function(e){console.error(e)}))}catch(e){Q(!1),console.error(e)}return[2]}))}))};function Re(e){var t=null==e?void 0:e.replace(/<a [^>]*>.*?<\/a>/g,(function(e){return null==e?void 0:e.replace(/\*/g,"&ast;")}));return t}var Ne=function(e,t,n,a,r,o){var c,l,i,s,d,u,m,v,f,z,g,y,M,E,b,H,V,C;console.log("userInput: ",r);var L={role:"assistant",content:"",id:V8()};if(null===(s=null===(i=null===(l=null===(c=null==e?void 0:e.chatStream)||void 0===c?void 0:c.continueChatResult)||void 0===l?void 0:l.message)||void 0===i?void 0:i.content)||void 0===s?void 0:s.includes("WaitMessage: "))Q(!1),Z(!0),L.content=function(e){var t="WaitMessage: ",n=e.indexOf(t);if(-1!==n){var a=e.substring(n+13);return null==a?void 0:a.replaceAll("WaitMessage: ","")}return""}((null===(m=null===(u=null===(d=null==e?void 0:e.chatStream)||void 0===d?void 0:d.continueChatResult)||void 0===u?void 0:u.message)||void 0===m?void 0:m.content)+"\n\n"),Y(p(p([],G,!0),[{role:"user",content:r,time:a,isFirstQuestionSent:o||!1,id:(null===(f=null===(v=null==e?void 0:e.chatStream)||void 0===v?void 0:v.continueChatResult)||void 0===f?void 0:f.requestId)||"",reply:""},L],!1));else{Q(!1),Z(!1),L.content=null===(M=Re(null===(y=null===(g=null===(z=null==e?void 0:e.chatStream)||void 0===z?void 0:z.continueChatResult)||void 0===g?void 0:g.message)||void 0===y?void 0:y.content))||void 0===M?void 0:M.replaceAll("WaitMessage: ","");var x=function(e,t,n){var a,r,o,c,l,i,s,d,u,m,v,f,z,g,y,M,E,b,H,V,C,L,x,S,k,w,T,O,A,R,N,_,D,P,F,I,j,B,U,W,$,q,G,Y,K,X,Q,J,Z,ee,te,ne,ae,re,oe,ce,le,ie,se,he,de,ue,me,pe,ve,fe,ze,ge,ye,Me,Ee,be,He,Ve,Ce,Le,xe,Se,ke,we,Te,Oe,Ae,Ne,_e,De,Pe,Fe,Ie,je,Be,Ue,We,$e,qe,Ge,Ye,Ke,Xe,Qe,Je,Ze,et,tt,nt,at,rt,ot,ct,lt,it,st,ht,dt,ut,mt,pt,vt,ft,zt,gt,yt,Mt,Et,bt,Ht,Vt,Ct,Lt,xt,St,kt,wt,Tt,Ot,At,Rt,Nt,_t,Dt,Pt,Ft,It,jt,Bt,Ut,Wt,$t,qt,Gt,Yt,Kt,Xt,Qt,Jt,Zt,en,tn,nn,an,rn,on,cn,ln,sn,hn,dn,un,mn,pn;console.log("event",e,Object.keys(e)),console.log("content: ",null==e?void 0:e.data);var vn={role:"assistant",content:"",id:V8()};if(!1===(null===(o=null===(r=null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.chatStream)||void 0===r?void 0:r.continueChatResult)||void 0===o?void 0:o.thinking_break)&&!0===(null===(i=null===(l=null===(c=null==e?void 0:e.data)||void 0===c?void 0:c.chatStream)||void 0===l?void 0:l.continueChatResult)||void 0===i?void 0:i.is_orchestrator)&&!1===(null===(u=null===(d=null===(s=null==e?void 0:e.data)||void 0===s?void 0:s.chatStream)||void 0===d?void 0:d.continueChatResult)||void 0===u?void 0:u.isEnd)&&(vn.content=null===(g=Re(null===(z=null===(f=null===(v=null===(m=null==e?void 0:e.data)||void 0===m?void 0:m.chatStream)||void 0===v?void 0:v.continueChatResult)||void 0===f?void 0:f.message)||void 0===z?void 0:z.content))||void 0===g?void 0:g.replaceAll("WaitMessage: ","")),!0===(null===(E=null===(M=null===(y=null==e?void 0:e.data)||void 0===y?void 0:y.chatStream)||void 0===M?void 0:M.continueChatResult)||void 0===E?void 0:E.thinking_break)&&!0===(null===(V=null===(H=null===(b=null==e?void 0:e.data)||void 0===b?void 0:b.chatStream)||void 0===H?void 0:H.continueChatResult)||void 0===V?void 0:V.is_orchestrator)&&!1===(null===(x=null===(L=null===(C=null==e?void 0:e.data)||void 0===C?void 0:C.chatStream)||void 0===L?void 0:L.continueChatResult)||void 0===x?void 0:x.isEnd)&&(vn.content="",t.push({responsedata:null===(T=null===(w=null===(k=null===(S=null==e?void 0:e.data)||void 0===S?void 0:S.chatStream)||void 0===k?void 0:k.continueChatResult)||void 0===w?void 0:w.message)||void 0===T?void 0:T.content,responseFrom:null===(R=null===(A=null===(O=null==e?void 0:e.data)||void 0===O?void 0:O.chatStream)||void 0===A?void 0:A.continueChatResult)||void 0===R?void 0:R.responded_by,header_message:null===(D=null===(_=null===(N=null==e?void 0:e.data)||void 0===N?void 0:N.chatStream)||void 0===_?void 0:_.continueChatResult)||void 0===D?void 0:D.header_message,finalResponseStatus:!1,explainability_id:null!==(j=null===(I=null===(F=null===(P=null==e?void 0:e.data)||void 0===P?void 0:P.chatStream)||void 0===F?void 0:F.continueChatResult)||void 0===I?void 0:I.explainability_id)&&void 0!==j?j:"",isParallelToolResponse:!1})),!1===(null===(W=null===(U=null===(B=null==e?void 0:e.data)||void 0===B?void 0:B.chatStream)||void 0===U?void 0:U.continueChatResult)||void 0===W?void 0:W.thinking_break)&&!0===(null===(G=null===(q=null===($=null==e?void 0:e.data)||void 0===$?void 0:$.chatStream)||void 0===q?void 0:q.continueChatResult)||void 0===G?void 0:G.is_orchestrator)&&!0===(null===(X=null===(K=null===(Y=null==e?void 0:e.data)||void 0===Y?void 0:Y.chatStream)||void 0===K?void 0:K.continueChatResult)||void 0===X?void 0:X.isEnd)&&(vn.content=null===(te=Re(null===(ee=null===(Z=null===(J=null===(Q=null==e?void 0:e.data)||void 0===Q?void 0:Q.chatStream)||void 0===J?void 0:J.continueChatResult)||void 0===Z?void 0:Z.message)||void 0===ee?void 0:ee.content))||void 0===te?void 0:te.replaceAll("WaitMessage: ","")),!1===(null===(re=null===(ae=null===(ne=null==e?void 0:e.data)||void 0===ne?void 0:ne.chatStream)||void 0===ae?void 0:ae.continueChatResult)||void 0===re?void 0:re.thinking_break)&&!1===(null===(le=null===(ce=null===(oe=null==e?void 0:e.data)||void 0===oe?void 0:oe.chatStream)||void 0===ce?void 0:ce.continueChatResult)||void 0===le?void 0:le.is_orchestrator)&&!1===(null===(he=null===(se=null===(ie=null==e?void 0:e.data)||void 0===ie?void 0:ie.chatStream)||void 0===se?void 0:se.continueChatResult)||void 0===he?void 0:he.isEnd)){if((gn=null===(ue=null===(de=null==e?void 0:e.data)||void 0===de?void 0:de.chatStream)||void 0===ue?void 0:ue.continueChatResult).explainability_id&&gn.responded_by){var fn=gn.explainability_id,zn=gn.responded_by;n.has(fn)||n.set(fn,{responded_by:zn,index:t.length})}n.has(null===(pe=null===(me=null==e?void 0:e.data)||void 0===me?void 0:me.chatStream)||void 0===pe?void 0:pe.continueChatResult.explainability_id)?t[Hn=null==(yn=n.get(null===(ze=null===(fe=null===(ve=null==e?void 0:e.data)||void 0===ve?void 0:ve.chatStream)||void 0===fe?void 0:fe.continueChatResult)||void 0===ze?void 0:ze.explainability_id))?void 0:yn.index]={responsedata:null===(Ee=null===(Me=null===(ye=null===(ge=null==e?void 0:e.data)||void 0===ge?void 0:ge.chatStream)||void 0===ye?void 0:ye.continueChatResult)||void 0===Me?void 0:Me.message)||void 0===Ee?void 0:Ee.content,responseFrom:null===(Ve=null===(He=null===(be=null==e?void 0:e.data)||void 0===be?void 0:be.chatStream)||void 0===He?void 0:He.continueChatResult)||void 0===Ve?void 0:Ve.responded_by,header_message:null===(xe=null===(Le=null===(Ce=null==e?void 0:e.data)||void 0===Ce?void 0:Ce.chatStream)||void 0===Le?void 0:Le.continueChatResult)||void 0===xe?void 0:xe.header_message,finalResponseStatus:!0,explainability_id:null!==(Te=null===(we=null===(ke=null===(Se=null==e?void 0:e.data)||void 0===Se?void 0:Se.chatStream)||void 0===ke?void 0:ke.continueChatResult)||void 0===we?void 0:we.explainability_id)&&void 0!==Te?Te:"",isParallelToolResponse:!0}:t=p(p([],t,!0),[{responsedata:null===(_e=null===(Ne=null===(Ae=null===(Oe=null==e?void 0:e.data)||void 0===Oe?void 0:Oe.chatStream)||void 0===Ae?void 0:Ae.continueChatResult)||void 0===Ne?void 0:Ne.message)||void 0===_e?void 0:_e.content,responseFrom:null===(Fe=null===(Pe=null===(De=null==e?void 0:e.data)||void 0===De?void 0:De.chatStream)||void 0===Pe?void 0:Pe.continueChatResult)||void 0===Fe?void 0:Fe.responded_by,header_message:null===(Be=null===(je=null===(Ie=null==e?void 0:e.data)||void 0===Ie?void 0:Ie.chatStream)||void 0===je?void 0:je.continueChatResult)||void 0===Be?void 0:Be.header_message,finalResponseStatus:!0,explainability_id:null!==(qe=null===($e=null===(We=null===(Ue=null==e?void 0:e.data)||void 0===Ue?void 0:Ue.chatStream)||void 0===We?void 0:We.continueChatResult)||void 0===$e?void 0:$e.explainability_id)&&void 0!==qe?qe:"",isParallelToolResponse:!1}],!1)}if(!0===(null===(Ke=null===(Ye=null===(Ge=null==e?void 0:e.data)||void 0===Ge?void 0:Ge.chatStream)||void 0===Ye?void 0:Ye.continueChatResult)||void 0===Ke?void 0:Ke.thinking_break)&&!1===(null===(Je=null===(Qe=null===(Xe=null==e?void 0:e.data)||void 0===Xe?void 0:Xe.chatStream)||void 0===Qe?void 0:Qe.continueChatResult)||void 0===Je?void 0:Je.is_orchestrator)&&!1===(null===(tt=null===(et=null===(Ze=null==e?void 0:e.data)||void 0===Ze?void 0:Ze.chatStream)||void 0===et?void 0:et.continueChatResult)||void 0===tt?void 0:tt.isEnd)){var gn,yn;(gn=null===(at=null===(nt=null==e?void 0:e.data)||void 0===nt?void 0:nt.chatStream)||void 0===at?void 0:at.continueChatResult).explainability_id&&gn.responded_by&&(fn=gn.explainability_id,zn=gn.responded_by,n.has(fn)||n.set(fn,{responded_by:zn,index:t.length})),n.has(null===(ct=null===(ot=null===(rt=null==e?void 0:e.data)||void 0===rt?void 0:rt.chatStream)||void 0===ot?void 0:ot.continueChatResult)||void 0===ct?void 0:ct.explainability_id)?t[Hn=null==(yn=n.get(null===(st=null===(it=null===(lt=null==e?void 0:e.data)||void 0===lt?void 0:lt.chatStream)||void 0===it?void 0:it.continueChatResult)||void 0===st?void 0:st.explainability_id))?void 0:yn.index]={responsedata:null===(mt=null===(ut=null===(dt=null===(ht=null==e?void 0:e.data)||void 0===ht?void 0:ht.chatStream)||void 0===dt?void 0:dt.continueChatResult)||void 0===ut?void 0:ut.message)||void 0===mt?void 0:mt.content,responseFrom:null===(ft=null===(vt=null===(pt=null==e?void 0:e.data)||void 0===pt?void 0:pt.chatStream)||void 0===vt?void 0:vt.continueChatResult)||void 0===ft?void 0:ft.responded_by,header_message:null===(yt=null===(gt=null===(zt=null==e?void 0:e.data)||void 0===zt?void 0:zt.chatStream)||void 0===gt?void 0:gt.continueChatResult)||void 0===yt?void 0:yt.header_message,finalResponseStatus:!1,explainability_id:null!==(Ht=null===(bt=null===(Et=null===(Mt=null==e?void 0:e.data)||void 0===Mt?void 0:Mt.chatStream)||void 0===Et?void 0:Et.continueChatResult)||void 0===bt?void 0:bt.explainability_id)&&void 0!==Ht?Ht:"",isParallelToolResponse:!0}:t.push({responsedata:null===(xt=null===(Lt=null===(Ct=null===(Vt=null==e?void 0:e.data)||void 0===Vt?void 0:Vt.chatStream)||void 0===Ct?void 0:Ct.continueChatResult)||void 0===Lt?void 0:Lt.message)||void 0===xt?void 0:xt.content,responseFrom:null===(wt=null===(kt=null===(St=null==e?void 0:e.data)||void 0===St?void 0:St.chatStream)||void 0===kt?void 0:kt.continueChatResult)||void 0===wt?void 0:wt.responded_by,header_message:null===(At=null===(Ot=null===(Tt=null==e?void 0:e.data)||void 0===Tt?void 0:Tt.chatStream)||void 0===Ot?void 0:Ot.continueChatResult)||void 0===At?void 0:At.header_message,finalResponseStatus:!1,explainability_id:null!==(Dt=null===(_t=null===(Nt=null===(Rt=null==e?void 0:e.data)||void 0===Rt?void 0:Rt.chatStream)||void 0===Nt?void 0:Nt.continueChatResult)||void 0===_t?void 0:_t.explainability_id)&&void 0!==Dt?Dt:"",isParallelToolResponse:!1})}var Mn=null===(jt=null===(It=null===(Ft=null===(Pt=null==e?void 0:e.data)||void 0===Pt?void 0:Pt.chatStream)||void 0===Ft?void 0:Ft.continueChatResult)||void 0===It?void 0:It.message)||void 0===jt?void 0:jt.annotations,En=(null===($t=null===(Wt=null===(Ut=null===(Bt=null==e?void 0:e.data)||void 0===Bt?void 0:Bt.chatStream)||void 0===Ut?void 0:Ut.continueChatResult)||void 0===Wt?void 0:Wt.message)||void 0===$t?void 0:$t.userFeedbackId)||"",bn={role:"assistant",content:vn.content,orchestratorAndAgentsMessages:t,time:new Date,requestId:null!==(Kt=null===(Yt=null===(Gt=null===(qt=null==e?void 0:e.data)||void 0===qt?void 0:qt.chatStream)||void 0===Gt?void 0:Gt.continueChatResult)||void 0===Yt?void 0:Yt.requestId)&&void 0!==Kt?Kt:"",citations:null===(Zt=null===(Jt=null===(Qt=null===(Xt=null==e?void 0:e.data)||void 0===Xt?void 0:Xt.chatStream)||void 0===Qt?void 0:Qt.continueChatResult)||void 0===Jt?void 0:Jt.message)||void 0===Zt?void 0:Zt.citations,guides_utilized:null!==(rn=null===(an=null===(nn=null===(tn=null===(en=null==e?void 0:e.data)||void 0===en?void 0:en.chatStream)||void 0===tn?void 0:tn.continueChatResult)||void 0===nn?void 0:nn.message)||void 0===an?void 0:an.guides_utilized)&&void 0!==rn?rn:[],annotations:Mn,resourceId:null===(ln=null===(cn=null===(on=null==e?void 0:e.data)||void 0===on?void 0:on.chatStream)||void 0===cn?void 0:cn.continueChatResult)||void 0===ln?void 0:ln.resourceId,userFeedbackId:En,citationDisplayType:null!==(mn=null===(un=null===(dn=null===(hn=null===(sn=null==e?void 0:e.data)||void 0===sn?void 0:sn.chatStream)||void 0===hn?void 0:hn.continueChatResult)||void 0===dn?void 0:dn.message)||void 0===un?void 0:un.citationDisplayType)&&void 0!==mn?mn:""};if(Mn)for(var Hn=0;Hn<(null==Mn?void 0:Mn.length);Hn++){var Vn=Mn[Hn];bn=h(h({},bn),{content:null===(pn=null==bn?void 0:bn.content)||void 0===pn?void 0:pn.replace(null==Vn?void 0:Vn.text,(null==Vn?void 0:Vn.text)+"<sup>".concat(Hn,"</sup>"))})}return bn}({data:e},n,t);console.log("assistantObject",x),Y(p(p([],G,!0),[{role:"user",content:r||"",time:a,isFirstQuestionSent:o||!1,requestId:null!==(H=null===(b=null===(E=null==e?void 0:e.chatStream)||void 0===E?void 0:E.continueChatResult)||void 0===b?void 0:b.requestId)&&void 0!==H?H:""},x],!1)),ne(null===(C=null===(V=null==e?void 0:e.chatStream)||void 0===V?void 0:V.continueChatResult)||void 0===C?void 0:C.isEnd)}},_e=function(e,t,n){var a,o,c,i,s,d,u,m=(null==n?void 0:n.trim())||(null==j?void 0:j.trim())||"";if(!("Enter"!==e.key||e.shiftKey||""===(null==n?void 0:n.trim())&&""===(null==j?void 0:j.trim())||ue)){me(!0);var f=new Date;Y(p(p([],G.map((function(e,t){var n;return h(h({},e),{content:null===(n=Re(e.content))||void 0===n?void 0:n.replace("WaitMessage: ","")})})),!0),[{role:"user",content:m,time:f,isFirstQuestionSent:!1}],!1));var z=new Map,g=[];F(!1);var y={WEBSOCKET_URL:v,organizationName:r,chatAssistantName:k,selectedAIModel:"gpt-4",replyMessage:"",userName:"Guest User",userEmailId:"guestUser@example.com",userId:"Guest User",query:(null==n?void 0:n.trim())||(null==j?void 0:j.trim())||"",requestId:"requestId-".concat(V8()),customPrompt:"",enableForBackend:!1,guestSessionId:w.current,chatPreviewId:T.current,customMetaData:h(h({},l),{whenToApply:null===(o=null===(a=null==l?void 0:l.whenToApply)||void 0===a?void 0:a.split("OR"))||void 0===o?void 0:o.filter((function(e){return""!==e})),whenNotToApply:null===(i=null===(c=null==l?void 0:l.whenNotToApply)||void 0===c?void 0:c.split("OR"))||void 0===i?void 0:i.filter((function(e){return""!==e})),isFirstQuestion:0===G.length,validation:null!=H?H:null,conflicting_learnings:null!==(s=null==C?void 0:C.conflicting_learnings)&&void 0!==s?s:"",similar_learnings:null!==(d=null==C?void 0:C.similar_learnings)&&void 0!==d?d:""}),aiModel:"",onStreamEvent:function(e){return Ne(e,z,g,f,m,t)},onStreamEnd:function(e){me(!1)},onError:function(e){return console.error("Stream error:",e)}};if(""!==(null==j?void 0:j.trim())||(null==n?void 0:n.trim())){Q(!0),null===(u=R.current)||void 0===u||u.blur(),B(""),Te();for(var M="Thanks for sharing your thoughts. I’m putting together the most helpful suggestions now, so we can make sure this really fits your needs.".split(" "),E="",b=function(e){setTimeout((function(){E+=M[e]+" ",he(E.trim())}),25*e)},V=0;V<M.length;V++)b(V);y8.startChatStream(y)}}};return n.useMemo((function(){return{img:function(e){e.node;var n=d(e,["node"]);return t.jsx("img",h({},n,{style:{height:"100%",width:"100%",objectFit:"contain"},alt:(null==n?void 0:n.alt)||"",className:"w-full sm:max-w-lg md:max-w-2xl lg:max-w-4xl mx-auto"}))},p:function(e){e.node;var n=d(e,["node"]);return t.jsx("p",h({},n,{style:{maxWidth:"100%",wordWrap:"break-word",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal",overflow:"hidden",display:"block",fontSize:"1rem",lineHeight:"1.625rem",marginBottom:"1rem",marginTop:"10px"}},{children:null==n?void 0:n.children}))},code:function(e){e.node;var n=d(e,["node"]);return t.jsx("span",h({},n,{style:{maxWidth:"100%",wordWrap:"break-word",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal",overflow:"hidden",display:"inline-flex",fontSize:"1rem",lineHeight:"1.625rem"}},{children:null==n?void 0:n.children}))},ol:function(e){e.node;var n=d(e,["node"]);return t.jsx("ol",h({},n,{style:{display:"flex",flexDirection:"column",gap:"1rem",listStyle:"decimal",paddingLeft:"2.5rem"}},{children:null==n?void 0:n.children}))},ul:function(e){e.node;var n=d(e,["node"]);return t.jsx("ul",h({},n,{style:{display:"flex",flexDirection:"column",gap:"1rem",listStyle:"decimal",paddingLeft:"2.5rem"}},{children:null==n?void 0:n.children}))},wta:function(e){e.node;var n=d(e,["node"]);n.key||n["data-key"];var a=n.label||n.children||"Unknown label";return t.jsx(r7,{label:a,onToggle:function(e,t){!function(e,t){var n=Array.isArray(e)?e[0]:e;null==_||_.length,F(!0),D((function(e){return t?e.includes(n)?e:p(p([],e,!0),[n],!1):e.filter((function(e){return e!==n}))}))}(e,t)}})}}}),[]),t.jsxs("div",h({className:T8,style:{height:"100%",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",fontFamily:"Plus Jakarta Sans, sans-serif",backgroundColor:"#fbfaff",border:"1px solid #d1d5db",overflow:"hidden"}},{children:[t.jsxs("div",h({style:{width:"100%",height:"100%",backgroundColor:"#fbfaff",maxWidth:"100%",overflow:"hidden"}},{children:[t.jsx("div",h({ref:He},{children:t.jsx(a7,{resetChatHistory:function(){var e="".concat(O,"/api/chat/resetHistory?name=").concat(k,"&organizationName=").concat(r);V(null),L(null);try{var t={method:"GET",params:{guestSessionId:w.current},withCredentials:!0};ES.get(e,t).then((function(){g(""),M(""),f(!0),F(!1),D([]),le(""),T.current="".concat(V8()),s(!1),Y([]),oe(!0),i((function(e){return h(h({},e),{modification:"",tooltip:"",whenToApply:"",whenNotToApply:"",isTooltipEnabled:!1,isModificationEnabled:!0})}))})).catch((function(e){console.error(e)}))}catch(e){Q(!1),console.error(e)}},isStreamEnd:te})})),t.jsxs("div",h({style:{width:"100%",height:Ce,maxHeight:Ce,overflowY:"auto",backgroundColor:"#fbfaff"},ref:A},{children:[t.jsx("div",h({className:"welcome-message",style:{alignItems:"flex-start",paddingLeft:"0.5rem",paddingTop:"1rem",maxWidth:"70%",fontSize:"1rem",lineHeight:"1.75rem",borderRadius:"0.5rem",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"pre-wrap",color:"#333",fontWeight:"700",textAlign:"left"}},{children:t.jsx("span",{children:"I’m here to help fine-tune your learning so it works as accurately as it should."})})),t.jsxs("div",h({style:{display:"flex",flexDirection:"row",fontFamily:"inherit",padding:"16px 10px 0px 16px",maxWidth:"80%"}},{children:[t.jsx("div",h({style:{maxHeight:"32px",maxWidth:"32px",marginTop:"0.3rem"}},{children:t.jsxs("svg",h({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[t.jsx("g",h({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:t.jsx("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),t.jsx("defs",{children:t.jsx("clipPath",h({id:"clip0_6004_60631"},{children:t.jsx("rect",{width:"24",height:"24",fill:"white"})}))})]}))})),t.jsx("div",h({style:{display:"flex",flexDirection:"column",fontWeight:400,color:"#000"}},{children:t.jsx("div",h({style:{display:"inline-flex",flexDirection:"column",alignItems:"flex-start",paddingLeft:"1rem",paddingRight:"1rem",width:"100%",maxWidth:"100%",fontSize:"1rem",lineHeight:"1.75rem",marginBottom:"1rem",borderRadius:"0.5rem",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"pre-wrap",color:"#333"}},{children:t.jsx("span",{children:t.jsx(cM,h({components:{p:function(e){e.node;var n=d(e,["node"]);return t.jsx("p",h({},n,{style:{margin:0}},{children:null==n?void 0:n.children}))}}},{children:W}))})}))}))]})),G.length?G.map((function(e,n){return t.jsxs("div",h({style:{display:"flex",padding:"0.5rem 1rem",maxWidth:"100%"}},{children:["assistant"==(null==e?void 0:e.role)&&t.jsx("div",h({style:{maxHeight:"32px",maxWidth:"32px",marginTop:"0.5rem",marginRight:"1rem"}},{children:t.jsxs("svg",h({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[t.jsx("g",h({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:t.jsx("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),t.jsx("defs",{children:t.jsx("clipPath",h({id:"clip0_6004_60631"},{children:t.jsx("rect",{width:"24",height:"24",fill:"white"})}))})]}))})),t.jsxs("div",h({style:{width:"100%"}},{children:["assistant"===e.role&&e.orchestratorAndAgentsMessages&&e.orchestratorAndAgentsMessages.length>0&&t.jsx(k8,{orchestratorAndAgentsMessages:null==e?void 0:e.orchestratorAndAgentsMessages,isStreamEnd:te,isCurrentMessage:n===G.length-1,ThinkingBulbIconComponent:z}),"assistant"===(null==e?void 0:e.role)?t.jsx(J8,{index:n,content:null==e?void 0:e.content,messages:G,handleStream:_e}):t.jsx("span",{}),t.jsx("div",h({style:{display:"flex",justifyContent:"flex-end"}},{children:"user"===e.role?t.jsx("div",h({style:{backgroundColor:"#8694A10D",padding:"0 1rem",borderRadius:"8px",maxWidth:"80%"}},{children:t.jsx(J8,{index:n,content:null==e?void 0:e.content,messages:G,handleStream:_e,scrollToBottom:Te})})):t.jsx("span",{})}))]}))]}))})):re&&t.jsx(t.Fragment,{}),X&&t.jsxs("div",h({style:{display:"flex",padding:"16px 16px 0px 16px"}},{children:[t.jsx("div",h({style:{maxHeight:"32px",maxWidth:"32px",marginTop:"0.2rem"}},{children:t.jsxs("svg",h({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[t.jsx("g",h({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:t.jsx("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),t.jsx("defs",{children:t.jsx("clipPath",h({id:"clip0_6004_60631"},{children:t.jsx("rect",{width:"24",height:"24",fill:"white"})}))})]}))})),t.jsx("div",h({style:{display:"inline-flex",alignItems:"flex-start",paddingLeft:"1rem",paddingRight:"1rem",paddingBottom:"1rem",width:"100%",maxWidth:"100%",fontSize:"1rem",lineHeight:"1.75rem",marginBottom:"1rem",borderRadius:"0.5rem",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"pre-wrap",color:"#333"}},{children:t.jsx("span",{children:se})}))]}))]}))]})),t.jsxs("div",h({style:{width:"95%",height:"content-fit",backgroundColor:"#fbfaff",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"end",position:"relative"}},{children:[t.jsx("div",h({style:{visibility:ge?"visible":"hidden",position:"absolute",top:"-3rem",zIndex:0,pointerEvents:"none"}},{children:t.jsx("button",h({onClick:Te,style:{borderRadius:"9999px",padding:0,backgroundColor:"#fff",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",border:"1px solid #d1d5db",pointerEvents:"auto",cursor:"pointer",display:"flex",justifyContent:"center",alignItems:"center",zIndex:1,height:"2.25rem",width:"2.25rem",margin:"0.3rem"}},{children:t.jsx("svg",h({fill:"#000000",width:"16px",height:"16px",viewBox:"0 0 24 24",id:"down","data-name":"Flat Color",xmlns:"http://www.w3.org/2000/svg"},{children:t.jsx("path",{id:"primary",d:"M19.71,13.29a1,1,0,0,0-1.42,0L13,18.59V3a1,1,0,0,0-2,0V18.59l-5.29-5.3a1,1,0,0,0-1.42,1.42l7,7a1,1,0,0,0,1.42,0l7-7A1,1,0,0,0,19.71,13.29Z"})}))}))})),t.jsx("div",h({style:{width:"100%",backgroundColor:"#fff",display:"flex",alignItems:"end",gap:"0.5rem",border:"1px solid #E5E7EB",borderRadius:"8px"}},{children:t.jsxs("div",h({style:{width:"100%",display:"flex"}},{children:[t.jsx("textarea",{ref:R,placeholder:"Tell me more about this learning...",value:j||"",onChange:function(e){return B(e.target.value)},onFocus:function(){return fe(!0)},onBlur:function(){return fe(!1)},onKeyDown:function(e){return _e(e)},style:{flexGrow:1,padding:"0.5rem",borderRadius:"0.5rem",border:"none",fontSize:"1rem",lineHeight:"1.5rem",resize:"none",backgroundColor:"#fff",color:"inherit",minHeight:ve?"120px":"50px",height:ve?"120px":"50px",maxHeight:"120px",overflowY:"auto",fontFamily:"inherit",outline:"none",transition:"min-height 0.3s ease, background-color 0.3s ease",boxSizing:"border-box"}}),t.jsxs("span",h({style:{display:"flex",flexDirection:"column",justifyContent:"end",alignItems:"end"}},{children:[" ",t.jsx("button",h({onClick:function(e){_e(new KeyboardEvent("keydown",{key:"Enter"}))},disabled:be,style:{padding:"0.5rem 0.75rem",borderRadius:"0.375rem",border:"none",backgroundColor:"white",color:be?"#d1d5db":"#5928ed",fontWeight:"bold",fontSize:"1rem",cursor:be?"not-allowed":"pointer",transition:"background-color 0.3s, color 0.3s",height:"50px"}},{children:t.jsx(n7,{})}))]}))]}))}))]})),t.jsxs("div",h({style:{width:"95%",display:"flex",gap:"0.25rem",flexDirection:"row"}},{children:[t.jsx(vJ,h({title:"Coming soon",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx("span",h({style:{width:"50%"}},{children:t.jsx(Y8,{amplitude:1,variant:"speaker",isActive:!1,onClick:function(){return null},disabled:!1})}))})),t.jsx(vJ,h({title:"Coming soon",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx("span",h({style:{width:"50%"}},{children:t.jsx(Y8,{amplitude:1,variant:"microphone",isActive:!1,onClick:function(){return null},disabled:!1})}))}))]}))]}))},c7={},l7={exports:{}},i7={exports:{}};function s7(){return e7||(e7=1,function(e){function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(i7)),i7.exports}function h7(){return t7||(t7=1,function(e){var t=s7().default;function n(a,r){if("function"==typeof WeakMap)var o=new WeakMap,c=new WeakMap;return(e.exports=n=function(e,n){if(!n&&e&&e.__esModule)return e;var a,r,l={__proto__:null,default:e};if(null===e||"object"!=t(e)&&"function"!=typeof e)return l;if(a=n?c:o){if(a.has(e))return a.get(e);a.set(e,l)}for(var i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((r=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,i))&&(r.get||r.set)?a(l,i,r):l[i]=e[i]);return l},e.exports.__esModule=!0,e.exports.default=e.exports)(a,r)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}(l7)),l7.exports}var d7,u7,m7={},p7=Ee(Gl);function v7(){return d7||(d7=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t.createSvgIcon}});var t=p7}(m7)),m7}var f7,z7=function(){if(u7)return c7;u7=1;var e=a_(),t=h7();Object.defineProperty(c7,"__esModule",{value:!0}),c7.default=void 0;var n=t(c.default),a=(0,e(v7()).default)(n.createElement("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"}),"Delete");return c7.default=a,c7}(),g7=Me(z7),y7={};var M7,E7=function(){if(f7)return y7;f7=1;var e=a_(),t=h7();Object.defineProperty(y7,"__esModule",{value:!0}),y7.default=void 0;var n=t(c.default),a=(0,e(v7()).default)(n.createElement("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z"}),"Lock");return y7.default=a,y7}(),b7=Me(E7),H7={};var V7,C7=function(){if(M7)return H7;M7=1;var e=a_(),t=h7();Object.defineProperty(H7,"__esModule",{value:!0}),H7.default=void 0;var n=t(c.default),a=(0,e(v7()).default)(n.createElement("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"}),"Edit");return H7.default=a,H7}(),L7=Me(C7),x7={};var S7,k7=function(){if(V7)return x7;V7=1;var e=a_(),t=h7();Object.defineProperty(x7,"__esModule",{value:!0}),x7.default=void 0;var n=t(c.default),a=(0,e(v7()).default)(n.createElement("path",{d:"M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z"}),"KeyboardArrowUp");return x7.default=a,x7}(),w7=Me(k7),T7=function(e){var n=e.similarLearnings,a=void 0===n?[]:n,r=e.formData,o=c.default.useState((function(){return(a||[]).reduce((function(e,t){return e[t.id]=!0,e}),{})})),l=o[0],i=o[1];return a.length?t.jsx(DB,h({sx:{marginTop:3}},{children:t.jsxs(DB,h({sx:{borderRadius:"8px",padding:"16px",border:"1px solid #3b82f6",backgroundColor:"#dbeafe"}},{children:[t.jsx(DB,h({sx:{display:"flex",alignItems:"center",marginBottom:1}},{children:t.jsxs(XP,h({sx:{fontSize:"1rem",fontWeight:600,fontFamily:"Plus Jakarta Sans",color:"#111827"}},{children:["Found ",a.length," similar Instant ",a.length>1?"Learnings":"Learning"]}))})),t.jsx(DB,h({sx:{display:"flex",flexDirection:"column",gap:2,maxHeight:"300px",overflowY:"auto",pr:1,mt:2}},{children:a.map((function(e,n){var a,o,c,s=e.id,d=e.feedback,u=null===(a=d.when_to_apply)||void 0===a?void 0:a.trim(),m=null===(o=d.when_not_to_apply)||void 0===o?void 0:o.trim(),p=l[s];return t.jsxs(DB,h({sx:{border:"1px solid #D1D5DB",borderRadius:"8px",padding:"16px",backgroundColor:"#fff",flexShrink:0}},{children:[t.jsxs(DB,h({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:2,gap:1}},{children:[t.jsx(XP,h({sx:{fontSize:"1rem",fontFamily:"Plus Jakarta Sans",minWidth:"130px",flexShrink:0,fontWeight:700}},{children:"Instant Learning:"})),t.jsx(DB,h({sx:{flex:1,overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal"}},{children:t.jsx(XP,h({sx:{fontSize:"0.95rem",fontFamily:"Plus Jakarta Sans",color:"#111827"}},{children:d.variant}))})),t.jsx(vJ,h({title:null===(c=r.scope)||void 0===c?void 0:c.split(" ").map((function(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()})).join(" "),placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsxs(XP,h({sx:{fontSize:"0.875rem",fontFamily:"Plus Jakarta Sans",flexShrink:0,border:"1px solid #D1D5DB",borderRadius:"25px",padding:"10px",display:"flex",alignItems:"center",cursor:"pointer"}},{children:["Section: ","Custom",t.jsx(U8,{size:16,style:{paddingLeft:"0.25rem"}})]}))})),t.jsx(w7,{onClick:function(){return function(e){i((function(t){var n;return h(h({},t),((n={})[e]=!t[e],n))}))}(s)},style:{fontSize:30,transform:p?"rotate(0deg)":"rotate(180deg)",transition:"transform 0.3s ease-in-out",cursor:"pointer"}})]})),t.jsx(TD,h({in:p,timeout:"auto",unmountOnExit:!0},{children:t.jsxs(DB,h({sx:{display:"flex",gap:2,mb:3}},{children:[t.jsx(DB,h({sx:{flex:1,display:"flex",flexDirection:"column"}},{children:u&&t.jsxs(t.Fragment,{children:[t.jsx(XP,h({sx:{fontFamily:"Plus Jakarta Sans",fontSize:"1rem",marginBottom:1,fontWeight:700}},{children:"When to apply"})),t.jsx(T2,{fullWidth:!0,multiline:!0,value:d.when_to_apply,placeholder:"When to apply",sx:{pointerEvents:"none",fontFamily:"Plus Jakarta Sans","& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"}}})]})})),t.jsx(DB,h({sx:{flex:1,display:"flex",flexDirection:"column",fontFamily:"Plus Jakarta Sans"}},{children:m&&t.jsxs(t.Fragment,{children:[t.jsx(XP,h({sx:{fontFamily:"Plus Jakarta Sans",fontSize:"1rem",marginBottom:1,fontWeight:700}},{children:"When not to apply"})),t.jsx(T2,{fullWidth:!0,multiline:!0,value:d.when_not_to_apply,placeholder:"When not to apply",sx:{pointerEvents:"none",fontFamily:"Plus Jakarta Sans","& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"}}})]})}))]}))}))]}),s)}))}))]}))})):null},O7={};var A7=function(){if(S7)return O7;S7=1;var e=a_(),t=h7();Object.defineProperty(O7,"__esModule",{value:!0}),O7.default=void 0;var n=t(c.default),a=(0,e(v7()).default)(n.createElement("path",{d:"M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z"}),"KeyboardArrowDown");return O7.default=a,O7}(),R7=Me(A7),N7=function(e){var a=e.conflictingConditions,r=n.useState((function(){return a.map((function(e,t){return t}))})),o=r[0],c=r[1],l=function(e){switch(e){case"whenToApply_vs_whenNotToApply":return"When to apply & When not to apply";case"whenToApply_internal":return"When to apply";case"whenNotToApply_internal":return"When not to apply";default:return e.replace(/_/g," ")}};return a&&0!==a.length?t.jsxs(DB,h({sx:{backgroundColor:"#FEF2F2",border:"1px solid #FCA5A5",boxShadow:"0 1px 4px rgba(0, 0, 0, 0.04)",padding:3,borderRadius:2,mt:3,mb:3,fontFamily:"Plus Jakarta Sans"}},{children:[t.jsx(XP,h({sx:{fontSize:"1.15rem",fontWeight:700,color:"#B91C1C",mb:2,fontFamily:"Plus Jakarta Sans"}},{children:"Conflicting Conditions Found"})),t.jsx(DB,h({sx:{maxHeight:360,overflowY:"auto",pr:1.5}},{children:a.map((function(e,n){var a=[];e.condition_wta&&a.push({label:"When To Apply",value:e.condition_wta}),e.condition_wnta&&a.push({label:"When Not To Apply",value:e.condition_wnta}),1===a.length&&a.push(h({},a[0]));var r=o.includes(n);return t.jsxs($D,h({expanded:r,onChange:function(){return function(e){c((function(t){return t.includes(e)?t.filter((function(t){return t!==e})):p(p([],t,!0),[e],!1)}))}(n)},disableGutters:!0,sx:{mb:2,border:"1px solid #FCA5A5",fontFamily:"Plus Jakarta Sans",borderRadius:2,"&::before":{display:"none"}}},{children:[t.jsxs(CP,h({expandIcon:t.jsx(R7,{style:{color:"#991B1B",transition:"transform 0.3s ease-in-out"}}),"aria-controls":"panel-".concat(n,"-content"),id:"panel-".concat(n,"-header"),sx:{fontFamily:"Plus Jakarta Sans",color:"#991B1B",fontWeight:600,px:2,py:1.5}},{children:["Conflict in: ",l(e.conflictType)]})),t.jsxs(ZD,h({sx:{px:2,pb:2}},{children:[t.jsx(DB,h({sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},gap:2,mb:2}},{children:a.map((function(e,n){return t.jsxs(DB,h({sx:{flex:1,border:"1px solid #FCA5A5",borderRadius:2,padding:2,backgroundColor:"#FFFFFF"}},{children:[t.jsx(XP,h({variant:"caption",sx:{fontSize:"0.9rem",color:"#6B7280",fontWeight:600,mb:.5,display:"block",fontFamily:"Plus Jakarta Sans"}},{children:e.label})),t.jsx(XP,h({variant:"body2",sx:{fontSize:"1rem",color:"#374151",whiteSpace:"pre-line",fontFamily:"Plus Jakarta Sans"}},{children:e.value}))]}),n)}))})),t.jsxs(XP,h({variant:"body2",sx:{fontSize:"1rem",color:"#1F2937",lineHeight:1.6,fontFamily:"Plus Jakarta Sans"}},{children:[t.jsx("strong",{children:"Reason:"})," ",e.reason]}))]}))]}),n)}))}))]})):null},_7=function(e){var a=e.conflictingConditions||[],r=a[0],o=a[1],c=r||[],l=o||[],i=n.useState((function(){return c.map((function(e,t){return t}))})),s=i[0],d=i[1],u=n.useState((function(){return l.map((function(e,t){return t}))})),m=u[0],v=u[1],f=function(e,n,a){var r="conflict"===a?s.includes(n):m.includes(n),o="conflict"===a?"#991B1B":"#F87171",c="conflict"===a?"Conflicting with: ".concat(e.feedback.variant):"Similar to: ".concat(e.feedback.variant),l=[];return e.feedback.when_to_apply&&l.push({label:"When To Apply",value:e.feedback.when_to_apply}),e.feedback.when_not_to_apply&&l.push({label:"When Not To Apply",value:e.feedback.when_not_to_apply}),1===l.length&&l.push(h({},l[0])),t.jsxs($D,h({expanded:r,onChange:function(){return function(e,t){"conflict"===t?d((function(t){return t.includes(e)?t.filter((function(t){return t!==e})):p(p([],t,!0),[e],!1)})):v((function(t){return t.includes(e)?t.filter((function(t){return t!==e})):p(p([],t,!0),[e],!1)}))}(n,a)},disableGutters:!0,sx:{mb:2,border:"1px solid #FCA5A5",borderRadius:2,fontFamily:"Plus Jakarta Sans","&::before":{display:"none"}}},{children:[t.jsx(CP,h({expandIcon:t.jsx(R7,{style:{color:o}}),"aria-controls":"panel-".concat(a,"-").concat(n,"-content"),id:"panel-".concat(a,"-").concat(n,"-header"),sx:{fontFamily:"Plus Jakarta Sans",color:o,fontWeight:600,px:2,py:1.5}},{children:c})),t.jsx(ZD,h({sx:{px:2,pb:2}},{children:t.jsx(DB,h({sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},gap:2,mb:2}},{children:l.map((function(e,n){return t.jsxs(DB,h({sx:{flex:1,border:"1px solid #FCA5A5",borderRadius:2,padding:2,backgroundColor:"#FFFFFF"}},{children:[t.jsx(XP,h({variant:"caption",sx:{fontSize:"0.9rem",color:"#6B7280",fontWeight:600,mb:.5,display:"block",fontFamily:"Plus Jakarta Sans"}},{children:e.label})),t.jsx(XP,h({variant:"body2",sx:{fontSize:"1rem",color:"#374151",whiteSpace:"pre-line",fontFamily:"Plus Jakarta Sans"}},{children:Array.isArray(e.value)?e.value.join("\n"):e.value}))]}),n)}))}))}))]}),"".concat(a,"-").concat(n))};return c&&0!==c.length||l&&0!==l.length?t.jsxs(DB,h({sx:{backgroundColor:"#FEF2F2",border:"1px solid #FCA5A5",boxShadow:"0 1px 4px rgba(0, 0, 0, 0.04)",padding:3,borderRadius:2,mt:3,mb:3,fontFamily:"Plus Jakarta Sans"}},{children:[t.jsx(XP,h({sx:{fontSize:"1.15rem",fontWeight:700,color:"#B91C1C",mb:2,fontFamily:"Plus Jakarta Sans"}},{children:"Conflciting/Similar Learning Found"})),t.jsxs(DB,h({sx:{maxHeight:360,overflowY:"auto",pr:1.5}},{children:[c.map((function(e,t){return f(e,t,"conflict")})),l.map((function(e,t){return f(e,t,"similar")}))]}))]})):null},D7=function(e){var a;e.organizationName;var r=e.selectedText,o=e.scopeOptions,c=e.devModeTag,l=e.chatLogo,i=void 0===l?null:l,s=e.submitFunction;e.setShowChat,e.showChat;var d=e.setFormDataState,v=e.instantLearningSuggestions;e.setHasUserFilledForm,e.hasUserFilledForm;var f=e.isNewChatClicked,z=e.setIsNewChatClicked,g=e.setHasUserWrittenModification,y=e.extractedModification,M=e.save,E=e.extractedTooltip;e.isSaveLoading,e.shouldTriggerSave;var b=e.baseUrl,H=e.topic_table,V=e.variant_table,C=e.scope_table,L=e.embedding_column_name,x=e.embedding_model,S=e.validationWtaResponse,k=e.setValidationWtaResponse,w=e.learningWtaResponse,T=e.setLearningWtaResponse,O=e.setIsFormSavedClicked,A=n.useState({context:"",issue_with_response:"",original:null!=r?r:"",modification:"",whenToApply:"",whenNotToApply:"",tooltip:"",scope:o[0].value,isTooltipEnabled:!1,isModificationEnabled:!0,isDevMode:!1}),R=A[0],N=A[1],_=n.useState(!1),D=_[0],P=_[1],F=n.useState(!1),I=F[0],j=F[1],B=n.useState(!1),U=B[0],W=B[1],$=n.useState(!1),q=$[0],G=$[1],Y=n.useState([]),K=Y[0],X=Y[1],Q=n.useState([]),J=Q[0],Z=Q[1],ee=n.useState(!1),te=ee[0],ne=ee[1],ae=n.useState(!1),re=ae[0],oe=ae[1],ce=n.useState(!1),le=ce[0],ie=ce[1],se=n.useState(!1),he=se[0],de=se[1],ue=n.useState(null),me=ue[0],pe=ue[1],ve=n.useState(!1);ve[0],ve[1];var fe=n.useState(null);fe[0];var ze=fe[1],ge=n.useState(null),ye=ge[0],Me=ge[1],Ee=n.useState(!1),be=Ee[0],He=Ee[1],Ve=n.useState(!1),Ce=Ve[0],Le=Ve[1],xe=n.useState(null),Se=xe[0],ke=xe[1],we=n.useState(null),Te=we[0],Oe=we[1],Ae=n.useMemo((function(){var e,t,n,a,r=""!==(null===(e=null==R?void 0:R.original)||void 0===e?void 0:e.trim()),o=""!==(null===(t=null==R?void 0:R.whenToApply)||void 0===t?void 0:t.trim()),c=(null==K?void 0:K.length)>0,l=!(null==R?void 0:R.isTooltipEnabled)||""!==(null===(n=null==R?void 0:R.tooltip)||void 0===n?void 0:n.trim()),i=!0;return(null==R?void 0:R.isModificationEnabled)&&(i=""!==(null===(a=null==R?void 0:R.modification)||void 0===a?void 0:a.trim())),r&&o&&c&&(l||i)}),[R,K,v]),Re=n.useRef(null);n.useEffect((function(){R.isModificationEnabled||N((function(e){return h(h({},e),{modification:""})})),R.isTooltipEnabled||N((function(e){return h(h({},e),{tooltip:""})}))}),[R.isModificationEnabled,R.isTooltipEnabled]),n.useEffect((function(){if(""===y&&(null==R?void 0:R.isTooltipEnabled)&&N((function(e){return h(h({},e),{isModificationEnabled:!1})})),""!==y||(null==R?void 0:R.isTooltipEnabled)||N((function(e){return h(h({},e),{modification:""})})),y&&""!==y){N((function(e){return h(h({},e),{modification:y,isModificationEnabled:!0})})),G(!0);var e=setTimeout((function(){G(!1)}),400);return function(){return clearTimeout(e)}}}),[y]),n.useEffect((function(){""===E&&N((function(e){return h(h({},e),{isTooltipEnabled:!1})})),E&&""!==E&&N((function(e){return h(h({},e),{tooltip:E,isTooltipEnabled:!0})}))}),[E]),n.useEffect((function(){f&&(N((function(e){return h(h({},e),{modification:"",tooltip:"",isTooltipEnabled:!1,isModificationEnabled:!0,whenToApply:"",whenNotToApply:""})})),X([]),Z([]),z(!1),de(!1),He(!1),Le(!1))}),[f]),n.useEffect((function(){d(R)}),[R]),n.useEffect((function(){""===R.original.trim()||""===R.modification.trim()&&""===R.tooltip.trim()||D||P(!0)}),[R]),n.useEffect((function(){if((null==K?void 0:K.length)>0&&!te){j(!0);var e=setTimeout((function(){j(!1)}),400);return function(){return clearTimeout(e)}}}),[JSON.stringify(K)]),n.useEffect((function(){if((null==J?void 0:J.length)>0&&!re){W(!0);var e=setTimeout((function(){W(!1)}),400);return function(){return clearTimeout(e)}}}),[JSON.stringify(J)]),n.useEffect((function(){var e,t,n,a;if(v){ne(!1),oe(!1);var r=null===(e=null==v?void 0:v.conditions_whentoapply)||void 0===e?void 0:e.map((function(e){return e.when_to_apply})),o=null===(t=null==v?void 0:v.conditions_whennottoapply)||void 0===t?void 0:t.map((function(e){return e.when_not_to_apply}));(null===(n=null==v?void 0:v.conditions_whentoapply)||void 0===n?void 0:n.length)&&(X(r.filter((function(e){return""!==e}))),N((function(e){return h(h({},e),{whenToApply:null==r?void 0:r.join(" OR ")})}))),(null===(a=null==v?void 0:v.conditions_whennottoapply)||void 0===a?void 0:a.length)&&(Z(o.filter((function(e){return""!==e}))),N((function(e){return h(h({},e),{whenNotToApply:null==o?void 0:o.join(" OR ")})})))}}),[v]);var Ne=n.useRef(null),_e=n.useCallback((function(){Ne.current&&clearTimeout(Ne.current),Ne.current=setTimeout((function(){g(!0)}),1e3)}),[]),De=n.useCallback((function(e){return function(t){N((function(n){var a;return h(h({},n),((a={})[e]=t.target.value,a))})),_e()}}),[_e]),Pe=function(e){return e.replace(new RegExp("<".concat(c,">"),"gi"),"").replace(new RegExp("</".concat(c,">"),"gi"),"").replace(/<\/?[^>]+(>|$)/g,"")},Fe=n.useCallback((function(e){var t=Pe(e);N((function(e){return h(h({},e),{tooltip:t})})),_e()}),[_e]),Ie=function(e){return function(t){var n=t.target.checked,a={};"isTooltipEnabled"===e?a={tooltip:n?R.tooltip:"",isModificationEnabled:!n||R.isModificationEnabled}:"isModificationEnabled"===e&&(a={modification:n?R.modification:""}),N((function(t){var r;return h(h(h({},t),a),((r={})[e]=n,r))}))}},je=function(){console.log("Form submitted:",R),ie(!0),""===(null==R?void 0:R.modification)&&N((function(e){return h(h({},e),{isModificationEnabled:!1})})),""===(null==R?void 0:R.tooltip)&&N((function(e){return h(h({},e),{isTooltipEnabled:!1})})),s(R,ie)};n.useEffect((function(){if(M){O(!0);u(void 0,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,We()];case 1:return e.sent()?[4,Ue()]:[3,3];case 2:e.sent(),e.label=3;case 3:return[2]}}))}))}}),[M]);n.useEffect((function(){S&&!1===S.is_valid?(He(!0),Me(S.conflictingConditions),Ke()):S&&S.is_valid&&(He(!1),Me(null))}),[S]),n.useEffect((function(){w&&!1===w.is_valid_db?(Le(!0),ke(w.conflicting_learnings),Oe(w.similar_learnings),Ke()):w&&w.is_valid_db&&(Le(!1),ke(null),Oe(null))}),[w]);var Be,Ue=function(){return u(void 0,void 0,void 0,(function(){var e,t,n,a,r;return m(this,(function(o){switch(o.label){case 0:ie(!0),o.label=1;case 1:return o.trys.push([1,4,,5]),[4,fetch("".concat(b,"/instant_learning/similar-variants"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topic_table:null!=H?H:"techolution-instantLearning-topics",variant_table:null!=V?V:"techolution-instantLearning-variants",scope_table:null!=C?C:"techolution-instantLearning-scopes",embedding_column_name:null!=L?L:"variant_embedding",embedding_model:null!=x?x:"mxbai-embed-large-v1",scope_id:[R.scope],topic:R.original,variants:{variant:"Replace ".concat(R.original," with ").concat(R.modification),conditions_whentoapply:R.whenToApply,conditions_whennottoapply:R.whenNotToApply},similarity_threshold:.4})})];case 2:return[4,o.sent().json()];case 3:return e=o.sent(),ie(!1),e.response&&e.response.similar_learnings&&e.response.similar_learnings.length>0?(console.log("API response:",e),t=(null===(r=null==e?void 0:e.response)||void 0===r?void 0:r.similar_learnings)||{},n=Object.keys(t).length>0,de(n),pe(e)):(de(!1),je()),[3,5];case 4:return a=o.sent(),ie(!1),console.error("API error:",a),de(!1),[3,5];case 5:return[2]}}))}))},We=function(){return u(void 0,void 0,void 0,(function(){var e,t,n,a,r,o,c,l;return m(this,(function(i){switch(i.label){case 0:ie(!0),i.label=1;case 1:return i.trys.push([1,4,,5]),[4,fetch("".concat(b,"/instant_learning/validate-wta"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({whenToApply:null===(a=null===(n=null==R?void 0:R.whenToApply)||void 0===n?void 0:n.split("OR"))||void 0===a?void 0:a.filter((function(e){return""!==e})),whenNotToApply:null===(o=null===(r=null==R?void 0:R.whenNotToApply)||void 0===r?void 0:r.split("OR"))||void 0===o?void 0:o.filter((function(e){return""!==e}))})})];case 2:return[4,i.sent().json()];case 3:return e=i.sent(),ie(!1),e.response&&k(e.response),e&&e.response&&e.response.is_valid?(ze(null),He(!1),Me(null),je()):e&&e.response&&!e.response.is_valid&&(ze(null===(c=e.response)||void 0===c?void 0:c.reason),He(!0),Me(e.response.conflictingConditions),Ke()),[2,null===(l=null==e?void 0:e.response)||void 0===l?void 0:l.is_valid];case 4:return t=i.sent(),ie(!1),console.error("API error:",t),[3,5];case 5:return[2]}}))}))},$e=n.useRef(null),qe=n.useState(!1),Ge=qe[0],Ye=qe[1],Ke=function(){var e=$e.current;e&&setTimeout((function(){e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),Ye(!1)}),200)};return n.useEffect((function(){var e=$e.current,t=function(){var e=$e.current;if(e){var t=e.scrollTop,n=e.scrollHeight,a=e.clientHeight;Ye(!(n-(t+a)<=35))}};return e&&(e.addEventListener("scroll",t),t()),function(){e&&e.removeEventListener("scroll",t)}}),[Ge]),t.jsxs(DB,h({p:0,className:T8,sx:{display:"flex",flexDirection:"column",height:"100%",width:"100%"}},{children:[t.jsx(DB,{children:t.jsx(XP,h({sx:{fontSize:20,fontWeight:600,fontFamily:"Plus Jakarta Sans"}},{children:"Instant Learning"}))}),t.jsxs(DB,h({sx:{fontFamily:"Plus Jakarta Sans",display:"flex",flexDirection:"column",gap:2,justifyContent:"space-between",flexGrow:1,paddingTop:"20px",height:"calc(100% - 30px)",overflow:"auto"}},{children:[t.jsxs(DB,h({sx:{display:"flex",flexDirection:"column",gap:"20px",height:"calc(100% - 90px)",overflow:"auto",position:"relative"},ref:$e},{children:[t.jsxs(DB,h({sx:{display:"flex",gap:2}},{children:[t.jsxs(DB,h({sx:{flex:1}},{children:[t.jsxs(DB,h({sx:{display:"flex",alignItems:"center"}},{children:[t.jsxs(XP,h({sx:{fontFamily:"Plus Jakarta Sans",fontSize:"1rem",fontWeight:600,display:"flex",alignItems:"center"}},{children:["Original"," ",t.jsx(DB,h({component:"span",sx:{color:"red"}},{children:"*"})),t.jsx(vJ,h({title:"Original word/phrase which needs to be replaced",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx(U8,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),t.jsx(DZ,{sx:{visibility:"hidden"},disabled:!0})]})),t.jsx(T2,{sx:{"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"}},id:"original",value:R.original,onChange:De("original"),fullWidth:!0,placeholder:"Enter original"})]})),t.jsxs(DB,h({sx:{flex:1}},{children:[t.jsxs(DB,h({sx:{display:"flex",alignItems:"center"}},{children:[t.jsxs(XP,h({sx:{fontFamily:"Plus Jakarta Sans",fontWeight:600,fontSize:"1rem",display:"flex",alignItems:"center"}},{children:["Modification",R.isModificationEnabled&&!R.isTooltipEnabled&&t.jsx(DB,h({component:"span",sx:{color:"red"}},{children:"*"})),t.jsx(vJ,h({title:"Modified word/phrase which Original needs to be replaced with",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx(U8,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),t.jsx(DZ,{checked:R.isModificationEnabled,disabled:!R.isTooltipEnabled,onChange:Ie("isModificationEnabled"),sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"#5928ed"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{backgroundColor:"#5928ed"}}})]})),R.isModificationEnabled&&t.jsx(T2,{sx:{"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},boxShadow:q?"0 0 12px 3px rgba(34, 197, 94, 0.6)":"none",transition:"box-shadow 0.3s ease-in-out"},id:"modification",value:R.modification,onChange:De("modification"),fullWidth:!0,placeholder:"Change ".concat(r," to...")})]}))]})),t.jsxs(DB,h({sx:{display:"flex",gap:2}},{children:[t.jsx(DB,{sx:{flex:1}}),t.jsxs(DB,h({sx:{flex:1}},{children:[t.jsxs(DB,h({sx:{display:"flex",justifyContent:"space-between"}},{children:[t.jsxs(DB,h({sx:{display:"flex",alignItems:"center"}},{children:[t.jsxs(XP,h({sx:{fontSize:"1rem",fontWeight:600,fontFamily:"Plus Jakarta Sans",display:"flex",alignItems:"center"}},{children:["Tooltip",R.isTooltipEnabled&&t.jsx(DB,h({component:"span",sx:{color:"red"}},{children:"*"})),t.jsx(vJ,h({title:"Adds a tooltip to the modification or the original word",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx(U8,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),t.jsx(DZ,{checked:R.isTooltipEnabled,onChange:Ie("isTooltipEnabled"),sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"#5928ed"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{backgroundColor:"#5928ed"}}})]})),R.isTooltipEnabled&&t.jsxs(DB,h({sx:{display:"flex",alignItems:"center"}},{children:[t.jsx(XP,h({sx:{fontSize:14,fontWeight:600,fontFamily:"Plus Jakarta Sans"}},{children:"Dev Mode"})),t.jsx(DZ,{checked:R.isDevMode,onChange:Ie("isDevMode"),sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"#4b5563"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{backgroundColor:"#4b5563"}}})]}))]})),R.isTooltipEnabled&&t.jsx(T2,{id:"tooltip",inputRef:Re,value:function(){var e=Pe(R.tooltip);return R.isDevMode?"<".concat(c,">").concat(e,"</").concat(c,">"):e}(),onChange:function(e){return Fe(e.target.value)},onFocus:function(){setTimeout((function(){if(R.isDevMode){var e=Pe(R.tooltip),t="<".concat(c,">").length+e.length,n=Re.current;n&&n.setSelectionRange(t,t)}}),0)},fullWidth:!0,placeholder:R.isDevMode?"<".concat(c,">Enter tooltip content</").concat(c,">"):"Enter tooltip content",sx:{"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"}}})]}))]})),t.jsxs(DB,h({sx:{display:"flex",gap:2,height:"".concat(R.isTooltipEnabled?"calc(100% - 248px)":"calc(100% - 200px)")}},{children:[!(null==K?void 0:K.length)&&t.jsxs(DB,h({sx:{flex:1}},{children:[t.jsxs(XP,h({sx:{fontSize:"1rem",fontWeight:600,marginBottom:"8px",fontFamily:"Plus Jakarta Sans",display:"flex",alignItems:"center"},gutterBottom:!0},{children:["When To Apply",t.jsx(DB,h({component:"span",sx:{color:"red"}},{children:"*"})),t.jsx(vJ,h({title:"Specific situations or conditions where this learning should be applied.",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx(U8,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),t.jsxs(DB,h({sx:{border:"1px solid #ccc",borderRadius:"8px",padding:2,height:"calc(100% - 64px)",display:"flex",flexDirection:"column"}},{children:[t.jsxs("div",h({style:{width:"100%",display:"flex",gap:"0.25rem"}},{children:[t.jsxs("svg",h({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[t.jsx("g",h({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:t.jsx("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),t.jsx("defs",{children:t.jsx("clipPath",h({id:"clip0_6004_60631"},{children:t.jsx("rect",{width:"24",height:"24",fill:"white"})}))})]})),t.jsx(XP,h({variant:"body1",sx:{ml:i?1:0,fontWeight:"600",fontFamily:"Plus Jakarta Sans",color:"#5928ed"}},{children:"AI Suggestions"}))]})),t.jsx("div",h({style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"}},{children:t.jsxs("div",h({style:{width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:"0.5rem",paddingTop:"1rem",paddingBottom:"1rem"}},{children:[t.jsx("div",h({style:{fontWeight:"700",color:"#6b7280"}},{children:"No suggestions found"})),t.jsxs("div",h({style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",gap:"0.25rem",fontSize:"1rem",flexFlow:"wrap"}},{children:[t.jsx("div",h({style:{}},{children:"Tell us about your learning in "})),t.jsx("span",h({style:{color:"#5928ED",fontWeight:"700"}},{children:"InstantLearning.AI"}))," ",t.jsx("span",{children:"Chat"})]}))]}))}))]}))]})),(null==K?void 0:K.length)>0&&t.jsxs(DB,h({sx:{flex:1,height:"100%"}},{children:[t.jsxs(XP,h({sx:{fontSize:"1rem",fontWeight:600,marginBottom:"8px",fontFamily:"Plus Jakarta Sans, sans-serif",display:"flex",alignItems:"center"},gutterBottom:!0},{children:["When To Apply",t.jsx(DB,h({component:"span",sx:{color:"red"}},{children:"*"})),t.jsx(vJ,h({title:"Specific situations or conditions where this learning should be applied.",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx(U8,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),t.jsxs(DB,h({sx:{border:"1px solid #ccc",borderRadius:"8px",padding:2,height:"calc(100% - 64px)",boxShadow:I?"0 0 12px 3px rgba(34, 197, 94, 0.6)":"none",transition:"box-shadow 0.3s ease-in-out"}},{children:[t.jsxs(DB,h({display:"flex",alignItems:"center",justifyContent:"space-between",sx:{mb:"8px"}},{children:[t.jsxs(DB,h({display:"flex",gap:"0.25rem",alignItems:"center"},{children:[i&&t.jsx(DB,{component:"img",src:i,alt:"Chat",sx:{width:14,height:14}}),t.jsxs("svg",h({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[t.jsx("g",h({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:t.jsx("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),t.jsx("defs",{children:t.jsx("clipPath",h({id:"clip0_6004_60631"},{children:t.jsx("rect",{width:"24",height:"24",fill:"white"})}))})]})),t.jsx(XP,h({variant:"body1",sx:{ml:i?1:0,fontWeight:"600",fontFamily:"Plus Jakarta Sans",color:"#5928ed"}},{children:"AI Suggestions"}))]})),(null==K?void 0:K.length)>0&&t.jsx(vJ,h({title:te?"Save & Lock":"Edit",componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx(OP,h({disabled:K.some((function(e){return""===(null==e?void 0:e.trim())})),onClick:function(){return ne((function(e){return!e}))},size:"small",sx:{color:"gray","&:hover":{color:"black"}}},{children:te?t.jsx(b7,{fontSize:"small"}):t.jsx(L7,{fontSize:"small"})}))}))]})),t.jsx(DB,h({sx:{height:"calc(100% - 38px)",overflow:"auto"}},{children:t.jsx("ol",h({style:{paddingLeft:"0rem",fontFamily:"Plus Jakarta Sans",margin:0}},{children:I?t.jsxs(DB,h({sx:{display:"flex",justifyContent:"center",py:2,gap:2}},{children:[t.jsx(yW,{size:24}),t.jsx("span",{children:"Generating When to apply..."})]})):t.jsx(DB,h({sx:{pt:"16px"}},{children:K.map((function(e,t){return{value:e,index:t}})).map((function(e,n){var a=e.value,r=e.index;return t.jsxs(DB,h({sx:{display:"flex",alignItems:"flex-start",gap:1,mb:r<K.length-1?2:0,fontFamily:"Plus Jakarta Sans"},component:"li"},{children:[t.jsx(T2,{variant:"outlined",disabled:!te,fullWidth:!0,multiline:!0,value:"".concat(a),onChange:function(e){var t=p([],K,!0);t[r]=e.target.value,k(null),T({similar_learnings:"",conflicting_learnings:""}),X(t),N((function(e){return h(h({},e),{whenToApply:t.join(" OR ")})}))},sx:{backgroundColor:"#f9fafb",borderRadius:1,"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputBase-input.Mui-disabled":{color:"#000",WebkitTextFillColor:"#000"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root.Mui-disabled":{color:"rgba(0, 0, 0, 0.6)"}},InputProps:{startAdornment:t.jsxs(mG,h({position:"start",sx:{color:"#000",alignSelf:"flex-start",paddingTop:"12px"}},{children:[r+1,"."]}))}}),te&&t.jsx(OP,h({onClick:function(){if(K.length>1){var e=K.filter((function(e,t){return t!==r}));X(e),N((function(t){return h(h({},t),{whenToApply:e.join(" OR ")})}))}},sx:{mt:1}},{children:t.jsx(g7,{})}))]}),r)}))}))}))}))]}))]})),!(null==J?void 0:J.length)&&t.jsxs(DB,h({sx:{flex:1}},{children:[t.jsxs(XP,h({sx:{fontSize:"1rem",fontWeight:600,marginBottom:"8px",fontFamily:"Plus Jakarta Sans",display:"flex",alignItems:"center"},gutterBottom:!0},{children:["When Not To Apply",t.jsx(vJ,h({title:"Cases where this learning should not be applied to avoid incorrect responses.",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx(U8,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),t.jsxs(DB,h({sx:{border:"1px solid #ccc",borderRadius:"8px",padding:2,flex:1,display:"flex",flexDirection:"column",height:"calc(100% - 64px)"}},{children:[t.jsxs("div",h({style:{width:"100%",display:"flex",gap:"0.25rem"}},{children:[t.jsxs("svg",h({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[t.jsx("g",h({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:t.jsx("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),t.jsx("defs",{children:t.jsx("clipPath",h({id:"clip0_6004_60631"},{children:t.jsx("rect",{width:"24",height:"24",fill:"white"})}))})]})),t.jsx(XP,h({variant:"body1",sx:{ml:i?1:0,fontWeight:"600",fontFamily:"Plus Jakarta Sans",color:"#5928ed"}},{children:"AI Suggestions"}))]})),t.jsx("div",h({style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"}},{children:t.jsxs("div",h({style:{width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:"0.5rem",paddingTop:"1rem",paddingBottom:"1rem"}},{children:[t.jsx("div",h({style:{fontWeight:"700",color:"#6b7280"}},{children:"No suggestions found"})),t.jsxs("div",h({style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",gap:"0.25rem",fontSize:"1rem",flexFlow:"wrap"}},{children:[t.jsx("div",h({style:{}},{children:"Tell us about your learning in "})),t.jsx("span",h({style:{color:"#5928ED",fontWeight:"700"}},{children:"InstantLearning.AI"}))," ",t.jsx("span",{children:"Chat"})]}))]}))}))]}))]})),(null==J?void 0:J.length)>0&&t.jsxs(DB,h({sx:{flex:1,height:"100%"}},{children:[t.jsxs(XP,h({sx:{fontSize:"1rem",fontWeight:600,marginBottom:"8px",fontFamily:"Plus Jakarta Sans",display:"flex",alignItems:"center"},gutterBottom:!0},{children:["When Not To Apply",t.jsx(vJ,h({title:"Cases where this learning should not be applied to avoid incorrect responses.",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx(U8,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),t.jsxs(DB,h({sx:{border:"1px solid #ccc",borderRadius:"8px",padding:2,height:"calc(100% - 64px)",boxShadow:U?"0 0 12px 3px rgba(34, 197, 94, 0.6)":"none",transition:"box-shadow 0.3s ease-in-out"}},{children:[t.jsxs(DB,h({display:"flex",alignItems:"center",justifyContent:"space-between",sx:{mb:"8px"}},{children:[t.jsxs(DB,h({display:"flex",gap:"0.25rem",alignItems:"center"},{children:[i&&t.jsx(DB,{component:"img",src:i,alt:"Chat",sx:{width:14,height:14}}),t.jsxs("svg",h({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[t.jsx("g",h({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:t.jsx("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),t.jsx("defs",{children:t.jsx("clipPath",h({id:"clip0_6004_60631"},{children:t.jsx("rect",{width:"24",height:"24",fill:"white"})}))})]})),t.jsx(XP,h({variant:"body1",sx:{ml:i?1:0,fontWeight:"600",fontFamily:"Plus Jakarta Sans",color:"#5928ed"}},{children:"AI Suggestions"}))]})),(null==J?void 0:J.length)>0&&t.jsx(vJ,h({placement:"top",arrow:!0,title:re?"Save & Lock":"Edit",componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:t.jsx(OP,h({disabled:J.some((function(e){return""===(null==e?void 0:e.trim())})),onClick:function(){return oe((function(e){return!e}))},size:"small",sx:{color:"gray","&:hover":{color:"black"}}},{children:re?t.jsx(b7,{fontSize:"small"}):t.jsx(L7,{fontSize:"small"})}))}))]})),t.jsx(DB,h({sx:{height:"calc(100% - 38px)",overflow:"auto"}},{children:t.jsx("ol",h({style:{paddingLeft:"0rem",margin:0}},{children:U?t.jsxs(DB,h({sx:{display:"flex",justifyContent:"center",py:2,gap:2}},{children:[t.jsx(yW,{size:24}),t.jsx("span",{children:"Generating When not to apply..."})]})):t.jsx(DB,h({sx:{pt:"16px"}},{children:J.map((function(e,t){return{value:e,index:t}})).map((function(e,n){var a=e.value,r=e.index;return t.jsxs(DB,h({sx:{display:"flex",alignItems:"flex-start",gap:1,mb:r<J.length-1?2:0},component:"li"},{children:[t.jsx(T2,{variant:"outlined",disabled:!re,fullWidth:!0,multiline:!0,value:"".concat(a),error:!a.trim(),onChange:function(e){var t=p([],J,!0);t[r]=e.target.value,k(null),T({similar_learnings:"",conflicting_learnings:""}),Z(t),N((function(e){return h(h({},e),{whenNotToApply:t.join(" OR ")})}))},sx:{backgroundColor:"#f9fafb",borderRadius:1,"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputBase-input.Mui-disabled":{color:"#000",WebkitTextFillColor:"#000"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root.Mui-disabled":{color:"rgba(0, 0, 0, 0.6)"}},InputProps:{startAdornment:t.jsxs(mG,h({position:"start",sx:{color:"#000",alignSelf:"flex-start",paddingTop:"12px"}},{children:[r+1,"."]}))}}),re&&t.jsx(OP,h({onClick:function(){if(J.length>1){var e=J.filter((function(e,t){return t!==r}));Z(e),N((function(t){return h(h({},t),{whenNotToApply:e.join(" OR ")})}))}},disabled:1===J.length,sx:{mt:1}},{children:t.jsx(g7,{})}))]}),r)}))}))}))}))]}))]}))]})),he&&t.jsx(T7,{similarLearnings:null===(a=null==me?void 0:me.response)||void 0===a?void 0:a.similar_learnings,formData:R}),be&&ye&&t.jsx(N7,{conflictingConditions:ye}),!be&&Ce&&t.jsx(_7,{conflictingConditions:[Se,Te]})]})),t.jsxs(DB,h({sx:{display:"flex",gap:2}},{children:[t.jsxs(DB,h({sx:{flex:1}},{children:[t.jsx(XP,h({sx:{fontSize:"1rem",fontWeight:600,fontFamily:"Plus Jakarta Sans"},gutterBottom:!0},{children:"Scope"})),t.jsx(W$,h({sx:{width:"50%",fontFamily:"Plus Jakarta Sans"},variant:"outlined"},{children:t.jsxs(XX,h({id:"scope",value:R.scope,onChange:(Be="scope",function(e){N((function(t){var n;return h(h({},t),((n={})[Be]=e.target.value,n))}))}),displayEmpty:!0,sx:{fontFamily:"Plus Jakarta Sans"},fullWidth:!0},{children:[t.jsx(eK,h({value:"",disabled:!0},{children:"Select scope"})),o.map((function(e,n){return t.jsx(eK,h({value:e.value,sx:{fontFamily:"Plus Jakarta Sans"}},{children:e.labelText}),n)}))]}))}))]})),t.jsx(DB,h({sx:{flex:1,display:"flex",alignItems:"flex-end",justifyContent:"flex-end"}},{children:t.jsxs(cU,h({variant:"contained",onClick:function(){return u(void 0,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return O(!0),[4,We()];case 1:return e.sent()?[4,Ue()]:[3,3];case 2:e.sent(),e.label=3;case 3:return[2]}}))}))},sx:{width:"30%",height:"56px",fontFamily:"Plus Jakarta Sans",backgroundColor:"green",textTransform:"capitalize","&:hover":{backgroundColor:"#006400"},pointerEvents:le?"none":"auto"},disabled:!Ae},{children:[le&&t.jsx(yW,{sx:{marginRight:"8px",color:"#fff"},size:16}),le?"Saving":"Save"]}))}))]}))]}))]}))},P7="PdfEditorCitation-module_citationRoot__5OtUI",F7="PdfEditorCitation-module_citationTitle__X9kQm",I7="PdfEditorCitation-module_citationBody__C99jX",j7="PdfEditorCitation-module_citationBodyWhenCollapsed__8vG0V";v(".PdfEditorCitation-module_citationRoot__5OtUI{display:flex;flex-direction:column}.PdfEditorCitation-module_citationTitle__X9kQm{align-items:center;background-color:#eff6ff;border:1px solid #000;border-radius:10px;cursor:pointer;display:inline-flex;gap:10px;padding:5px 8px;width:fit-content}.PdfEditorCitation-module_citationBody__C99jX{background-color:#fff;flex-grow:1}.PdfEditorCitation-module_citationBodyWhenCollapsed__8vG0V{display:none}.PdfEditorCitation-module_citationBodyWhenFullScreen__VKtop{bottom:0;height:100%!important;left:0;max-height:100%;position:absolute;right:0;top:0;width:100%!important}");var B7,U7={};var W7,$7=function(){if(B7)return U7;B7=1;var e=a_(),t=h7();Object.defineProperty(U7,"__esModule",{value:!0}),U7.default=void 0;var n=t(c.default),a=(0,e(v7()).default)(n.createElement("path",{d:"M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"}),"ExpandLess");return U7.default=a,U7}(),q7=Me($7),G7={};var Y7=function(){if(W7)return G7;W7=1;var e=a_(),t=h7();Object.defineProperty(G7,"__esModule",{value:!0}),G7.default=void 0;var n=t(c.default),a=(0,e(v7()).default)(n.createElement("path",{d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"}),"ExpandMore");return G7.default=a,G7}(),K7=Me(Y7),X7=function(){return X7=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},X7.apply(this,arguments)};function Q7(e,t,n,a){return new(n||(n=Promise))((function(r,o){function c(e){try{i(a.next(e))}catch(e){o(e)}}function l(e){try{i(a.throw(e))}catch(e){o(e)}}function i(e){e.done?r(e.value):function(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(c,l)}i((a=a.apply(e,t||[])).next())}))}function J7(e,t){var n,a,r,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return c.next=l(0),c.throw=l(1),c.return=l(2),"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function l(l){return function(i){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;c&&(c=0,l[0]&&(o=0)),o;)try{if(n=1,a&&(r=2&l[0]?a.return:l[0]?a.throw||((r=a.return)&&r.call(a),0):a.next)&&!(r=r.call(a,l[1])).done)return r;switch(a=0,r&&(l=[2&l[0],r.value]),l[0]){case 0:case 1:r=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,a=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]<r[3])){o.label=l[1];break}if(6===l[0]&&o.label<r[1]){o.label=r[1],r=l;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(l);break}r[2]&&o.ops.pop(),o.trys.pop();continue}l=t.call(e,o)}catch(e){l=[6,e],a=0}finally{n=r=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,i])}}}function Z7(e,t,n){if(n||2===arguments.length)for(var a,r=0,o=t.length;r<o;r++)!a&&r in t||(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var eee=void 0!==Ke?Ke:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function tee(){throw new Error("setTimeout has not been defined")}function nee(){throw new Error("clearTimeout has not been defined")}var aee=tee,ree=nee;function oee(e){if(aee===setTimeout)return setTimeout(e,0);if((aee===tee||!aee)&&setTimeout)return aee=setTimeout,setTimeout(e,0);try{return aee(e,0)}catch(t){try{return aee.call(null,e,0)}catch(t){return aee.call(this,e,0)}}}"function"==typeof eee.setTimeout&&(aee=setTimeout),"function"==typeof eee.clearTimeout&&(ree=clearTimeout);var cee,lee=[],iee=!1,see=-1;function hee(){iee&&cee&&(iee=!1,cee.length?lee=cee.concat(lee):see=-1,lee.length&&dee())}function dee(){if(!iee){var e=oee(hee);iee=!0;for(var t=lee.length;t;){for(cee=lee,lee=[];++see<t;)cee&&cee[see].run();see=-1,t=lee.length}cee=null,iee=!1,function(e){if(ree===clearTimeout)return clearTimeout(e);if((ree===nee||!ree)&&clearTimeout)return ree=clearTimeout,clearTimeout(e);try{return ree(e)}catch(t){try{return ree.call(null,e)}catch(t){return ree.call(this,e)}}}(e)}}function uee(e,t){this.fun=e,this.array=t}function mee(){}uee.prototype.run=function(){this.fun.apply(null,this.array)};var pee=mee,vee=mee,fee=mee,zee=mee,gee=mee,yee=mee,Mee=mee,Eee=eee.performance||{},bee=Eee.now||Eee.mozNow||Eee.msNow||Eee.oNow||Eee.webkitNow||function(){return(new Date).getTime()},Hee=new Date,Vee={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];lee.push(new uee(e,t)),1!==lee.length||iee||oee(dee)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:pee,addListener:vee,once:fee,off:zee,removeListener:gee,removeAllListeners:yee,emit:Mee,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*bee.call(Eee),n=Math.floor(t),a=Math.floor(t%1*1e9);return e&&(n-=e[0],(a-=e[1])<0&&(n--,a+=1e9)),[n,a]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-Hee)/1e3}};function Cee(e,t){return function(){return e.apply(t,arguments)}}const{toString:Lee}=Object.prototype,{getPrototypeOf:xee}=Object,See=(Aee=Object.create(null),e=>{const t=Lee.call(e);return Aee[t]||(Aee[t]=t.slice(8,-1).toLowerCase())}),kee=e=>(e=e.toLowerCase(),t=>See(t)===e),wee=e=>t=>typeof t===e,{isArray:Tee}=Array,Oee=wee("undefined");var Aee;const Ree=kee("ArrayBuffer"),Nee=wee("string"),_ee=wee("function"),Dee=wee("number"),Pee=e=>null!==e&&"object"==typeof e,Fee=e=>{if("object"!==See(e))return!1;const t=xee(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},Iee=kee("Date"),jee=kee("File"),Bee=kee("Blob"),Uee=kee("FileList"),Wee=kee("URLSearchParams"),[$ee,qee,Gee,Yee]=["ReadableStream","Request","Response","Headers"].map(kee);function Kee(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let a,r;if("object"!=typeof e&&(e=[e]),Tee(e))for(a=0,r=e.length;a<r;a++)t.call(null,e[a],a,e);else{const r=n?Object.getOwnPropertyNames(e):Object.keys(e),o=r.length;let c;for(a=0;a<o;a++)c=r[a],t.call(null,e[c],c,e)}}function Xee(e,t){t=t.toLowerCase();const n=Object.keys(e);let a,r=n.length;for(;r-- >0;)if(a=n[r],t===a.toLowerCase())return a;return null}const Qee="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:eee,Jee=e=>!Oee(e)&&e!==Qee,Zee=(ete="undefined"!=typeof Uint8Array&&xee(Uint8Array),e=>ete&&e instanceof ete);var ete;const tte=kee("HTMLFormElement"),nte=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),ate=kee("RegExp"),rte=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),a={};Kee(n,((n,r)=>{let o;!1!==(o=t(n,r,e))&&(a[r]=o||n)})),Object.defineProperties(e,a)},ote="abcdefghijklmnopqrstuvwxyz",cte="0123456789",lte={DIGIT:cte,ALPHA:ote,ALPHA_DIGIT:ote+ote.toUpperCase()+cte},ite=kee("AsyncFunction"),ste=(hte="function"==typeof setImmediate,dte=_ee(Qee.postMessage),hte?setImmediate:dte?(ute=`axios@${Math.random()}`,mte=[],Qee.addEventListener("message",(({source:e,data:t})=>{e===Qee&&t===ute&&mte.length&&mte.shift()()}),!1),e=>{mte.push(e),Qee.postMessage(ute,"*")}):e=>setTimeout(e));var hte,dte,ute,mte;const pte="undefined"!=typeof queueMicrotask?queueMicrotask.bind(Qee):Vee.nextTick||ste;var vte={isArray:Tee,isArrayBuffer:Ree,isBuffer:function(e){return null!==e&&!Oee(e)&&null!==e.constructor&&!Oee(e.constructor)&&_ee(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||_ee(e.append)&&("formdata"===(t=See(e))||"object"===t&&_ee(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Ree(e.buffer),t},isString:Nee,isNumber:Dee,isBoolean:e=>!0===e||!1===e,isObject:Pee,isPlainObject:Fee,isReadableStream:$ee,isRequest:qee,isResponse:Gee,isHeaders:Yee,isUndefined:Oee,isDate:Iee,isFile:jee,isBlob:Bee,isRegExp:ate,isFunction:_ee,isStream:e=>Pee(e)&&_ee(e.pipe),isURLSearchParams:Wee,isTypedArray:Zee,isFileList:Uee,forEach:Kee,merge:function e(){const{caseless:t}=Jee(this)&&this||{},n={},a=(a,r)=>{const o=t&&Xee(n,r)||r;Fee(n[o])&&Fee(a)?n[o]=e(n[o],a):Fee(a)?n[o]=e({},a):Tee(a)?n[o]=a.slice():n[o]=a};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&Kee(arguments[e],a);return n},extend:(e,t,n,{allOwnKeys:a}={})=>(Kee(t,((t,a)=>{n&&_ee(t)?e[a]=Cee(t,n):e[a]=t}),{allOwnKeys:a}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,a)=>{e.prototype=Object.create(t.prototype,a),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,a)=>{let r,o,c;const l={};if(t=t||{},null==e)return t;do{for(r=Object.getOwnPropertyNames(e),o=r.length;o-- >0;)c=r[o],a&&!a(c,e,t)||l[c]||(t[c]=e[c],l[c]=!0);e=!1!==n&&xee(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:See,kindOfTest:kee,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const a=e.indexOf(t,n);return-1!==a&&a===n},toArray:e=>{if(!e)return null;if(Tee(e))return e;let t=e.length;if(!Dee(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let a;for(;(a=n.next())&&!a.done;){const n=a.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const a=[];for(;null!==(n=e.exec(t));)a.push(n);return a},isHTMLForm:tte,hasOwnProperty:nte,hasOwnProp:nte,reduceDescriptors:rte,freezeMethods:e=>{rte(e,((t,n)=>{if(_ee(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const a=e[n];_ee(a)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))}))},toObjectSet:(e,t)=>{const n={},a=e=>{e.forEach((e=>{n[e]=!0}))};return Tee(e)?a(e):a(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n})),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:Xee,global:Qee,isContextDefined:Jee,ALPHABET:lte,generateString:(e=16,t=lte.ALPHA_DIGIT)=>{let n="";const{length:a}=t;for(;e--;)n+=t[Math.random()*a|0];return n},isSpecCompliantForm:function(e){return!!(e&&_ee(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),n=(e,a)=>{if(Pee(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[a]=e;const r=Tee(e)?[]:{};return Kee(e,((e,t)=>{const o=n(e,a+1);!Oee(o)&&(r[t]=o)})),t[a]=void 0,r}}return e};return n(e,0)},isAsyncFn:ite,isThenable:e=>e&&(Pee(e)||_ee(e))&&_ee(e.then)&&_ee(e.catch),setImmediate:ste,asap:pte},fte=[],zte=[],gte="undefined"!=typeof Uint8Array?Uint8Array:Array,yte=!1;function Mte(){yte=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)fte[t]=e[t],zte[e.charCodeAt(t)]=t;zte["-".charCodeAt(0)]=62,zte["_".charCodeAt(0)]=63}function Ete(e,t,n){for(var a,r,o=[],c=t;c<n;c+=3)a=(e[c]<<16)+(e[c+1]<<8)+e[c+2],o.push(fte[(r=a)>>18&63]+fte[r>>12&63]+fte[r>>6&63]+fte[63&r]);return o.join("")}function bte(e){var t;yte||Mte();for(var n=e.length,a=n%3,r="",o=[],c=16383,l=0,i=n-a;l<i;l+=c)o.push(Ete(e,l,l+c>i?i:l+c));return 1===a?(t=e[n-1],r+=fte[t>>2],r+=fte[t<<4&63],r+="=="):2===a&&(t=(e[n-2]<<8)+e[n-1],r+=fte[t>>10],r+=fte[t>>4&63],r+=fte[t<<2&63],r+="="),o.push(r),o.join("")}function Hte(e,t,n,a,r){var o,c,l=8*r-a-1,i=(1<<l)-1,s=i>>1,h=-7,d=n?r-1:0,u=n?-1:1,m=e[t+d];for(d+=u,o=m&(1<<-h)-1,m>>=-h,h+=l;h>0;o=256*o+e[t+d],d+=u,h-=8);for(c=o&(1<<-h)-1,o>>=-h,h+=a;h>0;c=256*c+e[t+d],d+=u,h-=8);if(0===o)o=1-s;else{if(o===i)return c?NaN:1/0*(m?-1:1);c+=Math.pow(2,a),o-=s}return(m?-1:1)*c*Math.pow(2,o-a)}function Vte(e,t,n,a,r,o){var c,l,i,s=8*o-r-1,h=(1<<s)-1,d=h>>1,u=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,m=a?0:o-1,p=a?1:-1,v=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(l=isNaN(t)?1:0,c=h):(c=Math.floor(Math.log(t)/Math.LN2),t*(i=Math.pow(2,-c))<1&&(c--,i*=2),(t+=c+d>=1?u/i:u*Math.pow(2,1-d))*i>=2&&(c++,i/=2),c+d>=h?(l=0,c=h):c+d>=1?(l=(t*i-1)*Math.pow(2,r),c+=d):(l=t*Math.pow(2,d-1)*Math.pow(2,r),c=0));r>=8;e[n+m]=255&l,m+=p,l/=256,r-=8);for(c=c<<r|l,s+=r;s>0;e[n+m]=255&c,m+=p,c/=256,s-=8);e[n+m-p]|=128*v}var Cte={}.toString,Lte=Array.isArray||function(e){return"[object Array]"==Cte.call(e)};function xte(){return kte.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Ste(e,t){if(xte()<t)throw new RangeError("Invalid typed array length");return kte.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=kte.prototype:(null===e&&(e=new kte(t)),e.length=t),e}function kte(e,t,n){if(!(kte.TYPED_ARRAY_SUPPORT||this instanceof kte))return new kte(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return Ote(this,e)}return wte(this,e,t,n)}function wte(e,t,n,a){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,a){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(a||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===a?new Uint8Array(t):void 0===a?new Uint8Array(t,n):new Uint8Array(t,n,a),kte.TYPED_ARRAY_SUPPORT?(e=t).__proto__=kte.prototype:e=Ate(e,t),e}(e,t,n,a):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!kte.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var a=0|_te(t,n),r=(e=Ste(e,a)).write(t,n);return r!==a&&(e=e.slice(0,r)),e}(e,t,n):function(e,t){if(Nte(t)){var n=0|Rte(t.length);return 0===(e=Ste(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(a=t.length)!=a?Ste(e,0):Ate(e,t);if("Buffer"===t.type&&Lte(t.data))return Ate(e,t.data)}var a;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function Tte(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function Ote(e,t){if(Tte(t),e=Ste(e,t<0?0:0|Rte(t)),!kte.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function Ate(e,t){var n=t.length<0?0:0|Rte(t.length);e=Ste(e,n);for(var a=0;a<n;a+=1)e[a]=255&t[a];return e}function Rte(e){if(e>=xte())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+xte().toString(16)+" bytes");return 0|e}function Nte(e){return!(null==e||!e._isBuffer)}function _te(e,t){if(Nte(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var a=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return sne(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return hne(e).length;default:if(a)return sne(e).length;t=(""+t).toLowerCase(),a=!0}}function Dte(e,t,n){var a=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Jte(this,t,n);case"utf8":case"utf-8":return Yte(this,t,n);case"ascii":return Xte(this,t,n);case"latin1":case"binary":return Qte(this,t,n);case"base64":return Gte(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Zte(this,t,n);default:if(a)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),a=!0}}function Pte(e,t,n){var a=e[t];e[t]=e[n],e[n]=a}function Fte(e,t,n,a,r){if(0===e.length)return-1;if("string"==typeof n?(a=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=r?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(r)return-1;n=e.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof t&&(t=kte.from(t,a)),Nte(t))return 0===t.length?-1:Ite(e,t,n,a,r);if("number"==typeof t)return t&=255,kte.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):Ite(e,[t],n,a,r);throw new TypeError("val must be string, number or Buffer")}function Ite(e,t,n,a,r){var o,c=1,l=e.length,i=t.length;if(void 0!==a&&("ucs2"===(a=String(a).toLowerCase())||"ucs-2"===a||"utf16le"===a||"utf-16le"===a)){if(e.length<2||t.length<2)return-1;c=2,l/=2,i/=2,n/=2}function s(e,t){return 1===c?e[t]:e.readUInt16BE(t*c)}if(r){var h=-1;for(o=n;o<l;o++)if(s(e,o)===s(t,-1===h?0:o-h)){if(-1===h&&(h=o),o-h+1===i)return h*c}else-1!==h&&(o-=o-h),h=-1}else for(n+i>l&&(n=l-i),o=n;o>=0;o--){for(var d=!0,u=0;u<i;u++)if(s(e,o+u)!==s(t,u)){d=!1;break}if(d)return o}return-1}function jte(e,t,n,a){n=Number(n)||0;var r=e.length-n;a?(a=Number(a))>r&&(a=r):a=r;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");a>o/2&&(a=o/2);for(var c=0;c<a;++c){var l=parseInt(t.substr(2*c,2),16);if(isNaN(l))return c;e[n+c]=l}return c}function Bte(e,t,n,a){return dne(sne(t,e.length-n),e,n,a)}function Ute(e,t,n,a){return dne(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,a)}function Wte(e,t,n,a){return Ute(e,t,n,a)}function $te(e,t,n,a){return dne(hne(t),e,n,a)}function qte(e,t,n,a){return dne(function(e,t){for(var n,a,r,o=[],c=0;c<e.length&&!((t-=2)<0);++c)a=(n=e.charCodeAt(c))>>8,r=n%256,o.push(r),o.push(a);return o}(t,e.length-n),e,n,a)}function Gte(e,t,n){return 0===t&&n===e.length?bte(e):bte(e.slice(t,n))}function Yte(e,t,n){n=Math.min(e.length,n);for(var a=[],r=t;r<n;){var o,c,l,i,s=e[r],h=null,d=s>239?4:s>223?3:s>191?2:1;if(r+d<=n)switch(d){case 1:s<128&&(h=s);break;case 2:128==(192&(o=e[r+1]))&&(i=(31&s)<<6|63&o)>127&&(h=i);break;case 3:o=e[r+1],c=e[r+2],128==(192&o)&&128==(192&c)&&(i=(15&s)<<12|(63&o)<<6|63&c)>2047&&(i<55296||i>57343)&&(h=i);break;case 4:o=e[r+1],c=e[r+2],l=e[r+3],128==(192&o)&&128==(192&c)&&128==(192&l)&&(i=(15&s)<<18|(63&o)<<12|(63&c)<<6|63&l)>65535&&i<1114112&&(h=i)}null===h?(h=65533,d=1):h>65535&&(h-=65536,a.push(h>>>10&1023|55296),h=56320|1023&h),a.push(h),r+=d}return function(e){var t=e.length;if(t<=Kte)return String.fromCharCode.apply(String,e);for(var n="",a=0;a<t;)n+=String.fromCharCode.apply(String,e.slice(a,a+=Kte));return n}(a)}kte.TYPED_ARRAY_SUPPORT=void 0===eee.TYPED_ARRAY_SUPPORT||eee.TYPED_ARRAY_SUPPORT,xte(),kte.poolSize=8192,kte._augment=function(e){return e.__proto__=kte.prototype,e},kte.from=function(e,t,n){return wte(null,e,t,n)},kte.TYPED_ARRAY_SUPPORT&&(kte.prototype.__proto__=Uint8Array.prototype,kte.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&kte[Symbol.species]),kte.alloc=function(e,t,n){return function(e,t,n,a){return Tte(t),t<=0?Ste(e,t):void 0!==n?"string"==typeof a?Ste(e,t).fill(n,a):Ste(e,t).fill(n):Ste(e,t)}(null,e,t,n)},kte.allocUnsafe=function(e){return Ote(null,e)},kte.allocUnsafeSlow=function(e){return Ote(null,e)},kte.isBuffer=function(e){return null!=e&&(!!e._isBuffer||une(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&une(e.slice(0,0))}(e))},kte.compare=function(e,t){if(!Nte(e)||!Nte(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,a=t.length,r=0,o=Math.min(n,a);r<o;++r)if(e[r]!==t[r]){n=e[r],a=t[r];break}return n<a?-1:a<n?1:0},kte.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},kte.concat=function(e,t){if(!Lte(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return kte.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var a=kte.allocUnsafe(t),r=0;for(n=0;n<e.length;++n){var o=e[n];if(!Nte(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(a,r),r+=o.length}return a},kte.byteLength=_te,kte.prototype._isBuffer=!0,kte.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)Pte(this,t,t+1);return this},kte.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)Pte(this,t,t+3),Pte(this,t+1,t+2);return this},kte.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)Pte(this,t,t+7),Pte(this,t+1,t+6),Pte(this,t+2,t+5),Pte(this,t+3,t+4);return this},kte.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?Yte(this,0,e):Dte.apply(this,arguments)},kte.prototype.equals=function(e){if(!Nte(e))throw new TypeError("Argument must be a Buffer");return this===e||0===kte.compare(this,e)},kte.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},kte.prototype.compare=function(e,t,n,a,r){if(!Nte(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===a&&(a=0),void 0===r&&(r=this.length),t<0||n>e.length||a<0||r>this.length)throw new RangeError("out of range index");if(a>=r&&t>=n)return 0;if(a>=r)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(r>>>=0)-(a>>>=0),c=(n>>>=0)-(t>>>=0),l=Math.min(o,c),i=this.slice(a,r),s=e.slice(t,n),h=0;h<l;++h)if(i[h]!==s[h]){o=i[h],c=s[h];break}return o<c?-1:c<o?1:0},kte.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},kte.prototype.indexOf=function(e,t,n){return Fte(this,e,t,n,!0)},kte.prototype.lastIndexOf=function(e,t,n){return Fte(this,e,t,n,!1)},kte.prototype.write=function(e,t,n,a){if(void 0===t)a="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)a=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===a&&(a="utf8")):(a=n,n=void 0)}var r=this.length-t;if((void 0===n||n>r)&&(n=r),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");a||(a="utf8");for(var o=!1;;)switch(a){case"hex":return jte(this,e,t,n);case"utf8":case"utf-8":return Bte(this,e,t,n);case"ascii":return Ute(this,e,t,n);case"latin1":case"binary":return Wte(this,e,t,n);case"base64":return $te(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return qte(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+a);a=(""+a).toLowerCase(),o=!0}},kte.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Kte=4096;function Xte(e,t,n){var a="";n=Math.min(e.length,n);for(var r=t;r<n;++r)a+=String.fromCharCode(127&e[r]);return a}function Qte(e,t,n){var a="";n=Math.min(e.length,n);for(var r=t;r<n;++r)a+=String.fromCharCode(e[r]);return a}function Jte(e,t,n){var a=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>a)&&(n=a);for(var r="",o=t;o<n;++o)r+=ine(e[o]);return r}function Zte(e,t,n){for(var a=e.slice(t,n),r="",o=0;o<a.length;o+=2)r+=String.fromCharCode(a[o]+256*a[o+1]);return r}function ene(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function tne(e,t,n,a,r,o){if(!Nte(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>r||t<o)throw new RangeError('"value" argument is out of bounds');if(n+a>e.length)throw new RangeError("Index out of range")}function nne(e,t,n,a){t<0&&(t=65535+t+1);for(var r=0,o=Math.min(e.length-n,2);r<o;++r)e[n+r]=(t&255<<8*(a?r:1-r))>>>8*(a?r:1-r)}function ane(e,t,n,a){t<0&&(t=4294967295+t+1);for(var r=0,o=Math.min(e.length-n,4);r<o;++r)e[n+r]=t>>>8*(a?r:3-r)&255}function rne(e,t,n,a,r,o){if(n+a>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function one(e,t,n,a,r){return r||rne(e,0,n,4),Vte(e,t,n,a,23,4),n+4}function cne(e,t,n,a,r){return r||rne(e,0,n,8),Vte(e,t,n,a,52,8),n+8}kte.prototype.slice=function(e,t){var n,a=this.length;if((e=~~e)<0?(e+=a)<0&&(e=0):e>a&&(e=a),(t=void 0===t?a:~~t)<0?(t+=a)<0&&(t=0):t>a&&(t=a),t<e&&(t=e),kte.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=kte.prototype;else{var r=t-e;n=new kte(r,void 0);for(var o=0;o<r;++o)n[o]=this[o+e]}return n},kte.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||ene(e,t,this.length);for(var a=this[e],r=1,o=0;++o<t&&(r*=256);)a+=this[e+o]*r;return a},kte.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||ene(e,t,this.length);for(var a=this[e+--t],r=1;t>0&&(r*=256);)a+=this[e+--t]*r;return a},kte.prototype.readUInt8=function(e,t){return t||ene(e,1,this.length),this[e]},kte.prototype.readUInt16LE=function(e,t){return t||ene(e,2,this.length),this[e]|this[e+1]<<8},kte.prototype.readUInt16BE=function(e,t){return t||ene(e,2,this.length),this[e]<<8|this[e+1]},kte.prototype.readUInt32LE=function(e,t){return t||ene(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},kte.prototype.readUInt32BE=function(e,t){return t||ene(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},kte.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||ene(e,t,this.length);for(var a=this[e],r=1,o=0;++o<t&&(r*=256);)a+=this[e+o]*r;return a>=(r*=128)&&(a-=Math.pow(2,8*t)),a},kte.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||ene(e,t,this.length);for(var a=t,r=1,o=this[e+--a];a>0&&(r*=256);)o+=this[e+--a]*r;return o>=(r*=128)&&(o-=Math.pow(2,8*t)),o},kte.prototype.readInt8=function(e,t){return t||ene(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},kte.prototype.readInt16LE=function(e,t){t||ene(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},kte.prototype.readInt16BE=function(e,t){t||ene(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},kte.prototype.readInt32LE=function(e,t){return t||ene(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},kte.prototype.readInt32BE=function(e,t){return t||ene(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},kte.prototype.readFloatLE=function(e,t){return t||ene(e,4,this.length),Hte(this,e,!0,23,4)},kte.prototype.readFloatBE=function(e,t){return t||ene(e,4,this.length),Hte(this,e,!1,23,4)},kte.prototype.readDoubleLE=function(e,t){return t||ene(e,8,this.length),Hte(this,e,!0,52,8)},kte.prototype.readDoubleBE=function(e,t){return t||ene(e,8,this.length),Hte(this,e,!1,52,8)},kte.prototype.writeUIntLE=function(e,t,n,a){e=+e,t|=0,n|=0,a||tne(this,e,t,n,Math.pow(2,8*n)-1,0);var r=1,o=0;for(this[t]=255&e;++o<n&&(r*=256);)this[t+o]=e/r&255;return t+n},kte.prototype.writeUIntBE=function(e,t,n,a){e=+e,t|=0,n|=0,a||tne(this,e,t,n,Math.pow(2,8*n)-1,0);var r=n-1,o=1;for(this[t+r]=255&e;--r>=0&&(o*=256);)this[t+r]=e/o&255;return t+n},kte.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||tne(this,e,t,1,255,0),kte.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},kte.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||tne(this,e,t,2,65535,0),kte.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):nne(this,e,t,!0),t+2},kte.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||tne(this,e,t,2,65535,0),kte.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):nne(this,e,t,!1),t+2},kte.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||tne(this,e,t,4,4294967295,0),kte.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ane(this,e,t,!0),t+4},kte.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||tne(this,e,t,4,4294967295,0),kte.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ane(this,e,t,!1),t+4},kte.prototype.writeIntLE=function(e,t,n,a){if(e=+e,t|=0,!a){var r=Math.pow(2,8*n-1);tne(this,e,t,n,r-1,-r)}var o=0,c=1,l=0;for(this[t]=255&e;++o<n&&(c*=256);)e<0&&0===l&&0!==this[t+o-1]&&(l=1),this[t+o]=(e/c|0)-l&255;return t+n},kte.prototype.writeIntBE=function(e,t,n,a){if(e=+e,t|=0,!a){var r=Math.pow(2,8*n-1);tne(this,e,t,n,r-1,-r)}var o=n-1,c=1,l=0;for(this[t+o]=255&e;--o>=0&&(c*=256);)e<0&&0===l&&0!==this[t+o+1]&&(l=1),this[t+o]=(e/c|0)-l&255;return t+n},kte.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||tne(this,e,t,1,127,-128),kte.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},kte.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||tne(this,e,t,2,32767,-32768),kte.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):nne(this,e,t,!0),t+2},kte.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||tne(this,e,t,2,32767,-32768),kte.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):nne(this,e,t,!1),t+2},kte.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||tne(this,e,t,4,2147483647,-2147483648),kte.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ane(this,e,t,!0),t+4},kte.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||tne(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),kte.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ane(this,e,t,!1),t+4},kte.prototype.writeFloatLE=function(e,t,n){return one(this,e,t,!0,n)},kte.prototype.writeFloatBE=function(e,t,n){return one(this,e,t,!1,n)},kte.prototype.writeDoubleLE=function(e,t,n){return cne(this,e,t,!0,n)},kte.prototype.writeDoubleBE=function(e,t,n){return cne(this,e,t,!1,n)},kte.prototype.copy=function(e,t,n,a){if(n||(n=0),a||0===a||(a=this.length),t>=e.length&&(t=e.length),t||(t=0),a>0&&a<n&&(a=n),a===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(a<0)throw new RangeError("sourceEnd out of bounds");a>this.length&&(a=this.length),e.length-t<a-n&&(a=e.length-t+n);var r,o=a-n;if(this===e&&n<t&&t<a)for(r=o-1;r>=0;--r)e[r+t]=this[r+n];else if(o<1e3||!kte.TYPED_ARRAY_SUPPORT)for(r=0;r<o;++r)e[r+t]=this[r+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},kte.prototype.fill=function(e,t,n,a){if("string"==typeof e){if("string"==typeof t?(a=t,t=0,n=this.length):"string"==typeof n&&(a=n,n=this.length),1===e.length){var r=e.charCodeAt(0);r<256&&(e=r)}if(void 0!==a&&"string"!=typeof a)throw new TypeError("encoding must be a string");if("string"==typeof a&&!kte.isEncoding(a))throw new TypeError("Unknown encoding: "+a)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var c=Nte(e)?e:sne(new kte(e,a).toString()),l=c.length;for(o=0;o<n-t;++o)this[o+t]=c[o%l]}return this};var lne=/[^+\/0-9A-Za-z-_]/g;function ine(e){return e<16?"0"+e.toString(16):e.toString(16)}function sne(e,t){var n;t=t||1/0;for(var a=e.length,r=null,o=[],c=0;c<a;++c){if((n=e.charCodeAt(c))>55295&&n<57344){if(!r){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(c+1===a){(t-=3)>-1&&o.push(239,191,189);continue}r=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),r=n;continue}n=65536+(r-55296<<10|n-56320)}else r&&(t-=3)>-1&&o.push(239,191,189);if(r=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function hne(e){return function(e){var t,n,a,r,o,c;yte||Mte();var l=e.length;if(l%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[l-2]?2:"="===e[l-1]?1:0,c=new gte(3*l/4-o),a=o>0?l-4:l;var i=0;for(t=0,n=0;t<a;t+=4,n+=3)r=zte[e.charCodeAt(t)]<<18|zte[e.charCodeAt(t+1)]<<12|zte[e.charCodeAt(t+2)]<<6|zte[e.charCodeAt(t+3)],c[i++]=r>>16&255,c[i++]=r>>8&255,c[i++]=255&r;return 2===o?(r=zte[e.charCodeAt(t)]<<2|zte[e.charCodeAt(t+1)]>>4,c[i++]=255&r):1===o&&(r=zte[e.charCodeAt(t)]<<10|zte[e.charCodeAt(t+1)]<<4|zte[e.charCodeAt(t+2)]>>2,c[i++]=r>>8&255,c[i++]=255&r),c}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(lne,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function dne(e,t,n,a){for(var r=0;r<a&&!(r+n>=t.length||r>=e.length);++r)t[r+n]=e[r];return r}function une(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function mne(e,t,n,a,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),a&&(this.request=a),r&&(this.response=r,this.status=r.status?r.status:null)}vte.inherits(mne,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:vte.toJSONObject(this.config),code:this.code,status:this.status}}});const pne=mne.prototype,vne={};function fne(e){return vte.isPlainObject(e)||vte.isArray(e)}function zne(e){return vte.endsWith(e,"[]")?e.slice(0,-2):e}function gne(e,t,n){return e?e.concat(t).map((function(e,t){return e=zne(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{vne[e]={value:e}})),Object.defineProperties(mne,vne),Object.defineProperty(pne,"isAxiosError",{value:!0}),mne.from=(e,t,n,a,r,o)=>{const c=Object.create(pne);return vte.toFlatObject(e,c,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),mne.call(c,e.message,t,n,a,r),c.cause=e,c.name=e.name,o&&Object.assign(c,o),c};const yne=vte.toFlatObject(vte,{},null,(function(e){return/^is[A-Z]/.test(e)}));function Mne(e,t,n){if(!vte.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const a=(n=vte.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!vte.isUndefined(t[e])}))).metaTokens,r=n.visitor||s,o=n.dots,c=n.indexes,l=(n.Blob||"undefined"!=typeof Blob&&Blob)&&vte.isSpecCompliantForm(t);if(!vte.isFunction(r))throw new TypeError("visitor must be a function");function i(e){if(null===e)return"";if(vte.isDate(e))return e.toISOString();if(!l&&vte.isBlob(e))throw new mne("Blob is not supported. Use a Buffer instead.");return vte.isArrayBuffer(e)||vte.isTypedArray(e)?l&&"function"==typeof Blob?new Blob([e]):kte.from(e):e}function s(e,n,r){let l=e;if(e&&!r&&"object"==typeof e)if(vte.endsWith(n,"{}"))n=a?n:n.slice(0,-2),e=JSON.stringify(e);else if(vte.isArray(e)&&function(e){return vte.isArray(e)&&!e.some(fne)}(e)||(vte.isFileList(e)||vte.endsWith(n,"[]"))&&(l=vte.toArray(e)))return n=zne(n),l.forEach((function(e,a){!vte.isUndefined(e)&&null!==e&&t.append(!0===c?gne([n],a,o):null===c?n:n+"[]",i(e))})),!1;return!!fne(e)||(t.append(gne(r,n,o),i(e)),!1)}const h=[],d=Object.assign(yne,{defaultVisitor:s,convertValue:i,isVisitable:fne});if(!vte.isObject(e))throw new TypeError("data must be an object");return function e(n,a){if(!vte.isUndefined(n)){if(-1!==h.indexOf(n))throw Error("Circular reference detected in "+a.join("."));h.push(n),vte.forEach(n,(function(n,o){!0===(!(vte.isUndefined(n)||null===n)&&r.call(t,n,vte.isString(o)?o.trim():o,a,d))&&e(n,a?a.concat(o):[o])})),h.pop()}}(e),t}function Ene(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function bne(e,t){this._pairs=[],e&&Mne(e,this,t)}const Hne=bne.prototype;function Vne(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Cne(e,t,n){if(!t)return e;const a=n&&n.encode||Vne;vte.isFunction(n)&&(n={serialize:n});const r=n&&n.serialize;let o;if(o=r?r(t,n):vte.isURLSearchParams(t)?t.toString():new bne(t,n).toString(a),o){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}Hne.append=function(e,t){this._pairs.push([e,t])},Hne.toString=function(e){const t=e?function(t){return e.call(this,t,Ene)}:Ene;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};class Lne{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){vte.forEach(this.handlers,(function(t){null!==t&&e(t)}))}}var xne={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Sne={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:bne,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const kne="undefined"!=typeof window&&"undefined"!=typeof document,wne="object"==typeof navigator&&navigator||void 0,Tne=kne&&(!wne||["ReactNative","NativeScript","NS"].indexOf(wne.product)<0),One="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Ane=kne&&window.location.href||"http://localhost";var Rne={...Object.freeze({__proto__:null,hasBrowserEnv:kne,hasStandardBrowserWebWorkerEnv:One,hasStandardBrowserEnv:Tne,navigator:wne,origin:Ane}),...Sne};function Nne(e){function t(e,n,a,r){let o=e[r++];if("__proto__"===o)return!0;const c=Number.isFinite(+o),l=r>=e.length;return o=!o&&vte.isArray(a)?a.length:o,l?(vte.hasOwnProp(a,o)?a[o]=[a[o],n]:a[o]=n,!c):(a[o]&&vte.isObject(a[o])||(a[o]=[]),t(e,n,a[o],r)&&vte.isArray(a[o])&&(a[o]=function(e){const t={},n=Object.keys(e);let a;const r=n.length;let o;for(a=0;a<r;a++)o=n[a],t[o]=e[o];return t}(a[o])),!c)}if(vte.isFormData(e)&&vte.isFunction(e.entries)){const n={};return vte.forEachEntry(e,((e,a)=>{t(function(e){return vte.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),a,n,0)})),n}return null}const _ne={transitional:xne,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",a=n.indexOf("application/json")>-1,r=vte.isObject(e);if(r&&vte.isHTMLForm(e)&&(e=new FormData(e)),vte.isFormData(e))return a?JSON.stringify(Nne(e)):e;if(vte.isArrayBuffer(e)||vte.isBuffer(e)||vte.isStream(e)||vte.isFile(e)||vte.isBlob(e)||vte.isReadableStream(e))return e;if(vte.isArrayBufferView(e))return e.buffer;if(vte.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(r){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Mne(e,new Rne.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,a){return Rne.isNode&&vte.isBuffer(e)?(this.append(t,e.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((o=vte.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return Mne(o?{"files[]":e}:e,t&&new t,this.formSerializer)}}return r||a?(t.setContentType("application/json",!1),function(e){if(vte.isString(e))try{return(0,JSON.parse)(e),vte.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||_ne.transitional,n=t&&t.forcedJSONParsing,a="json"===this.responseType;if(vte.isResponse(e)||vte.isReadableStream(e))return e;if(e&&vte.isString(e)&&(n&&!this.responseType||a)){const n=!(t&&t.silentJSONParsing)&&a;try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw mne.from(e,mne.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Rne.classes.FormData,Blob:Rne.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};vte.forEach(["delete","get","head","post","put","patch"],(e=>{_ne.headers[e]={}}));const Dne=vte.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Pne=Symbol("internals");function Fne(e){return e&&String(e).trim().toLowerCase()}function Ine(e){return!1===e||null==e?e:vte.isArray(e)?e.map(Ine):String(e)}function jne(e,t,n,a,r){return vte.isFunction(a)?a.call(this,t,n):(r&&(t=n),vte.isString(t)?vte.isString(a)?-1!==t.indexOf(a):vte.isRegExp(a)?a.test(t):void 0:void 0)}class Bne{constructor(e){e&&this.set(e)}set(e,t,n){const a=this;function r(e,t,n){const r=Fne(t);if(!r)throw new Error("header name must be a non-empty string");const o=vte.findKey(a,r);(!o||void 0===a[o]||!0===n||void 0===n&&!1!==a[o])&&(a[o||t]=Ine(e))}const o=(e,t)=>vte.forEach(e,((e,n)=>r(e,n,t)));if(vte.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(vte.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))o((e=>{const t={};let n,a,r;return e&&e.split("\n").forEach((function(e){r=e.indexOf(":"),n=e.substring(0,r).trim().toLowerCase(),a=e.substring(r+1).trim(),!n||t[n]&&Dne[n]||("set-cookie"===n?t[n]?t[n].push(a):t[n]=[a]:t[n]=t[n]?t[n]+", "+a:a)})),t})(e),t);else if(vte.isHeaders(e))for(const[t,a]of e.entries())r(a,t,n);else null!=e&&r(t,e,n);return this}get(e,t){if(e=Fne(e)){const n=vte.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let a;for(;a=n.exec(e);)t[a[1]]=a[2];return t}(e);if(vte.isFunction(t))return t.call(this,e,n);if(vte.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Fne(e)){const n=vte.findKey(this,e);return!(!n||void 0===this[n]||t&&!jne(0,this[n],n,t))}return!1}delete(e,t){const n=this;let a=!1;function r(e){if(e=Fne(e)){const r=vte.findKey(n,e);!r||t&&!jne(0,n[r],r,t)||(delete n[r],a=!0)}}return vte.isArray(e)?e.forEach(r):r(e),a}clear(e){const t=Object.keys(this);let n=t.length,a=!1;for(;n--;){const r=t[n];e&&!jne(0,this[r],r,e,!0)||(delete this[r],a=!0)}return a}normalize(e){const t=this,n={};return vte.forEach(this,((a,r)=>{const o=vte.findKey(n,r);if(o)return t[o]=Ine(a),void delete t[r];const c=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,n)=>t.toUpperCase()+n))}(r):String(r).trim();c!==r&&delete t[r],t[c]=Ine(a),n[c]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return vte.forEach(this,((n,a)=>{null!=n&&!1!==n&&(t[a]=e&&vte.isArray(n)?n.join(", "):n)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach((e=>n.set(e))),n}static accessor(e){const t=(this[Pne]=this[Pne]={accessors:{}}).accessors,n=this.prototype;function a(e){const a=Fne(e);t[a]||(function(e,t){const n=vte.toCamelCase(" "+t);["get","set","has"].forEach((a=>{Object.defineProperty(e,a+n,{value:function(e,n,r){return this[a].call(this,t,e,n,r)},configurable:!0})}))}(n,e),t[a]=!0)}return vte.isArray(e)?e.forEach(a):a(e),this}}function Une(e,t){const n=this||_ne,a=t||n,r=Bne.from(a.headers);let o=a.data;return vte.forEach(e,(function(e){o=e.call(n,o,r.normalize(),t?t.status:void 0)})),r.normalize(),o}function Wne(e){return!(!e||!e.__CANCEL__)}function $ne(e,t,n){mne.call(this,null==e?"canceled":e,mne.ERR_CANCELED,t,n),this.name="CanceledError"}function qne(e,t,n){const a=n.config.validateStatus;n.status&&a&&!a(n.status)?t(new mne("Request failed with status code "+n.status,[mne.ERR_BAD_REQUEST,mne.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}Bne.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),vte.reduceDescriptors(Bne.prototype,(({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}})),vte.freezeMethods(Bne),vte.inherits($ne,mne,{__CANCEL__:!0});const Gne=(e,t,n=3)=>{let a=0;const r=function(e,t){e=e||10;const n=new Array(e),a=new Array(e);let r,o=0,c=0;return t=void 0!==t?t:1e3,function(l){const i=Date.now(),s=a[c];r||(r=i),n[o]=l,a[o]=i;let h=c,d=0;for(;h!==o;)d+=n[h++],h%=e;if(o=(o+1)%e,o===c&&(c=(c+1)%e),i-r<t)return;const u=s&&i-s;return u?Math.round(1e3*d/u):void 0}}(50,250);return function(e,t){let n,a,r=0,o=1e3/t;const c=(t,o=Date.now())=>{r=o,n=null,a&&(clearTimeout(a),a=null),e.apply(null,t)};return[(...e)=>{const t=Date.now(),l=t-r;l>=o?c(e,t):(n=e,a||(a=setTimeout((()=>{a=null,c(n)}),o-l)))},()=>n&&c(n)]}((n=>{const o=n.loaded,c=n.lengthComputable?n.total:void 0,l=o-a,i=r(l);a=o,e({loaded:o,total:c,progress:c?o/c:void 0,bytes:l,rate:i||void 0,estimated:i&&c&&o<=c?(c-o)/i:void 0,event:n,lengthComputable:null!=c,[t?"download":"upload"]:!0})}),n)},Yne=(e,t)=>{const n=null!=e;return[a=>t[0]({lengthComputable:n,total:e,loaded:a}),t[1]]},Kne=e=>(...t)=>vte.asap((()=>e(...t)));var Xne=Rne.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Rne.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Rne.origin),Rne.navigator&&/(msie|trident)/i.test(Rne.navigator.userAgent)):()=>!0,Qne=Rne.hasStandardBrowserEnv?{write(e,t,n,a,r,o){const c=[e+"="+encodeURIComponent(t)];vte.isNumber(n)&&c.push("expires="+new Date(n).toGMTString()),vte.isString(a)&&c.push("path="+a),vte.isString(r)&&c.push("domain="+r),!0===o&&c.push("secure"),document.cookie=c.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Jne(e,t){return e&&!function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}(t)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const Zne=e=>e instanceof Bne?{...e}:e;function eae(e,t){t=t||{};const n={};function a(e,t,n,a){return vte.isPlainObject(e)&&vte.isPlainObject(t)?vte.merge.call({caseless:a},e,t):vte.isPlainObject(t)?vte.merge({},t):vte.isArray(t)?t.slice():t}function r(e,t,n,r){return vte.isUndefined(t)?vte.isUndefined(e)?void 0:a(void 0,e,0,r):a(e,t,0,r)}function o(e,t){if(!vte.isUndefined(t))return a(void 0,t)}function c(e,t){return vte.isUndefined(t)?vte.isUndefined(e)?void 0:a(void 0,e):a(void 0,t)}function l(n,r,o){return o in t?a(n,r):o in e?a(void 0,n):void 0}const i={url:o,method:o,data:o,baseURL:c,transformRequest:c,transformResponse:c,paramsSerializer:c,timeout:c,timeoutMessage:c,withCredentials:c,withXSRFToken:c,adapter:c,responseType:c,xsrfCookieName:c,xsrfHeaderName:c,onUploadProgress:c,onDownloadProgress:c,decompress:c,maxContentLength:c,maxBodyLength:c,beforeRedirect:c,transport:c,httpAgent:c,httpsAgent:c,cancelToken:c,socketPath:c,responseEncoding:c,validateStatus:l,headers:(e,t,n)=>r(Zne(e),Zne(t),0,!0)};return vte.forEach(Object.keys(Object.assign({},e,t)),(function(a){const o=i[a]||r,c=o(e[a],t[a],a);vte.isUndefined(c)&&o!==l||(n[a]=c)})),n}var tae=e=>{const t=eae({},e);let n,{data:a,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:c,headers:l,auth:i}=t;if(t.headers=l=Bne.from(l),t.url=Cne(Jne(t.baseURL,t.url),e.params,e.paramsSerializer),i&&l.set("Authorization","Basic "+btoa((i.username||"")+":"+(i.password?unescape(encodeURIComponent(i.password)):""))),vte.isFormData(a))if(Rne.hasStandardBrowserEnv||Rne.hasStandardBrowserWebWorkerEnv)l.setContentType(void 0);else if(!1!==(n=l.getContentType())){const[e,...t]=n?n.split(";").map((e=>e.trim())).filter(Boolean):[];l.setContentType([e||"multipart/form-data",...t].join("; "))}if(Rne.hasStandardBrowserEnv&&(r&&vte.isFunction(r)&&(r=r(t)),r||!1!==r&&Xne(t.url))){const e=o&&c&&Qne.read(c);e&&l.set(o,e)}return t},nae="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,n){const a=tae(e);let r=a.data;const o=Bne.from(a.headers).normalize();let c,l,i,s,h,{responseType:d,onUploadProgress:u,onDownloadProgress:m}=a;function p(){s&&s(),h&&h(),a.cancelToken&&a.cancelToken.unsubscribe(c),a.signal&&a.signal.removeEventListener("abort",c)}let v=new XMLHttpRequest;function f(){if(!v)return;const a=Bne.from("getAllResponseHeaders"in v&&v.getAllResponseHeaders());qne((function(e){t(e),p()}),(function(e){n(e),p()}),{data:d&&"text"!==d&&"json"!==d?v.response:v.responseText,status:v.status,statusText:v.statusText,headers:a,config:e,request:v}),v=null}v.open(a.method.toUpperCase(),a.url,!0),v.timeout=a.timeout,"onloadend"in v?v.onloadend=f:v.onreadystatechange=function(){v&&4===v.readyState&&(0!==v.status||v.responseURL&&0===v.responseURL.indexOf("file:"))&&setTimeout(f)},v.onabort=function(){v&&(n(new mne("Request aborted",mne.ECONNABORTED,e,v)),v=null)},v.onerror=function(){n(new mne("Network Error",mne.ERR_NETWORK,e,v)),v=null},v.ontimeout=function(){let t=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded";const r=a.transitional||xne;a.timeoutErrorMessage&&(t=a.timeoutErrorMessage),n(new mne(t,r.clarifyTimeoutError?mne.ETIMEDOUT:mne.ECONNABORTED,e,v)),v=null},void 0===r&&o.setContentType(null),"setRequestHeader"in v&&vte.forEach(o.toJSON(),(function(e,t){v.setRequestHeader(t,e)})),vte.isUndefined(a.withCredentials)||(v.withCredentials=!!a.withCredentials),d&&"json"!==d&&(v.responseType=a.responseType),m&&([i,h]=Gne(m,!0),v.addEventListener("progress",i)),u&&v.upload&&([l,s]=Gne(u),v.upload.addEventListener("progress",l),v.upload.addEventListener("loadend",s)),(a.cancelToken||a.signal)&&(c=t=>{v&&(n(!t||t.type?new $ne(null,e,v):t),v.abort(),v=null)},a.cancelToken&&a.cancelToken.subscribe(c),a.signal&&(a.signal.aborted?c():a.signal.addEventListener("abort",c)));const z=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(a.url);z&&-1===Rne.protocols.indexOf(z)?n(new mne("Unsupported protocol "+z+":",mne.ERR_BAD_REQUEST,e)):v.send(r||null)}))};const aae=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,a=new AbortController;const r=function(e){if(!n){n=!0,c();const t=e instanceof Error?e:this.reason;a.abort(t instanceof mne?t:new $ne(t instanceof Error?t.message:t))}};let o=t&&setTimeout((()=>{o=null,r(new mne(`timeout ${t} of ms exceeded`,mne.ETIMEDOUT))}),t);const c=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach((e=>{e.unsubscribe?e.unsubscribe(r):e.removeEventListener("abort",r)})),e=null)};e.forEach((e=>e.addEventListener("abort",r)));const{signal:l}=a;return l.unsubscribe=()=>vte.asap(c),l}},rae=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let a,r=0;for(;r<n;)a=r+t,yield e.slice(r,a),r=a},oae=(e,t,n,a)=>{const r=async function*(e,t){for await(const n of async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}}(e))yield*rae(n,t)}(e,t);let o,c=0,l=e=>{o||(o=!0,a&&a(e))};return new ReadableStream({async pull(e){try{const{done:t,value:a}=await r.next();if(t)return l(),void e.close();let o=a.byteLength;if(n){let e=c+=o;n(e)}e.enqueue(new Uint8Array(a))}catch(e){throw l(e),e}},cancel:e=>(l(e),r.return())},{highWaterMark:2})},cae="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,lae=cae&&"function"==typeof ReadableStream,iae=cae&&("function"==typeof TextEncoder?(sae=new TextEncoder,e=>sae.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var sae;const hae=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},dae=lae&&hae((()=>{let e=!1;const t=new Request(Rne.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})),uae=lae&&hae((()=>vte.isReadableStream(new Response("").body))),mae={stream:uae&&(e=>e.body)};var pae;cae&&(pae=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((e=>{!mae[e]&&(mae[e]=vte.isFunction(pae[e])?t=>t[e]():(t,n)=>{throw new mne(`Response type '${e}' is not supported`,mne.ERR_NOT_SUPPORT,n)})})));var vae=cae&&(async e=>{let{url:t,method:n,data:a,signal:r,cancelToken:o,timeout:c,onDownloadProgress:l,onUploadProgress:i,responseType:s,headers:h,withCredentials:d="same-origin",fetchOptions:u}=tae(e);s=s?(s+"").toLowerCase():"text";let m,p=aae([r,o&&o.toAbortSignal()],c);const v=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let f;try{if(i&&dae&&"get"!==n&&"head"!==n&&0!==(f=await(async(e,t)=>{const n=vte.toFiniteNumber(e.getContentLength());return null==n?(async e=>{if(null==e)return 0;if(vte.isBlob(e))return e.size;if(vte.isSpecCompliantForm(e)){const t=new Request(Rne.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return vte.isArrayBufferView(e)||vte.isArrayBuffer(e)?e.byteLength:(vte.isURLSearchParams(e)&&(e+=""),vte.isString(e)?(await iae(e)).byteLength:void 0)})(t):n})(h,a))){let e,n=new Request(t,{method:"POST",body:a,duplex:"half"});if(vte.isFormData(a)&&(e=n.headers.get("content-type"))&&h.setContentType(e),n.body){const[e,t]=Yne(f,Gne(Kne(i)));a=oae(n.body,65536,e,t)}}vte.isString(d)||(d=d?"include":"omit");const r="credentials"in Request.prototype;m=new Request(t,{...u,signal:p,method:n.toUpperCase(),headers:h.normalize().toJSON(),body:a,duplex:"half",credentials:r?d:void 0});let o=await fetch(m);const c=uae&&("stream"===s||"response"===s);if(uae&&(l||c&&v)){const e={};["status","statusText","headers"].forEach((t=>{e[t]=o[t]}));const t=vte.toFiniteNumber(o.headers.get("content-length")),[n,a]=l&&Yne(t,Gne(Kne(l),!0))||[];o=new Response(oae(o.body,65536,n,(()=>{a&&a(),v&&v()})),e)}s=s||"text";let z=await mae[vte.findKey(mae,s)||"text"](o,e);return!c&&v&&v(),await new Promise(((t,n)=>{qne(t,n,{data:z,headers:Bne.from(o.headers),status:o.status,statusText:o.statusText,config:e,request:m})}))}catch(t){if(v&&v(),t&&"TypeError"===t.name&&/fetch/i.test(t.message))throw Object.assign(new mne("Network Error",mne.ERR_NETWORK,e,m),{cause:t.cause||t});throw mne.from(t,t&&t.code,e,m)}});const fae={http:null,xhr:nae,fetch:vae};vte.forEach(fae,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));const zae=e=>`- ${e}`,gae=e=>vte.isFunction(e)||null===e||!1===e;var yae=e=>{e=vte.isArray(e)?e:[e];const{length:t}=e;let n,a;const r={};for(let o=0;o<t;o++){let t;if(n=e[o],a=n,!gae(n)&&(a=fae[(t=String(n)).toLowerCase()],void 0===a))throw new mne(`Unknown adapter '${t}'`);if(a)break;r[t||"#"+o]=a}if(!a){const e=Object.entries(r).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));throw new mne("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(zae).join("\n"):" "+zae(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return a};function Mae(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new $ne(null,e)}function Eae(e){return Mae(e),e.headers=Bne.from(e.headers),e.data=Une.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),yae(e.adapter||_ne.adapter)(e).then((function(t){return Mae(e),t.data=Une.call(e,e.transformResponse,t),t.headers=Bne.from(t.headers),t}),(function(t){return Wne(t)||(Mae(e),t&&t.response&&(t.response.data=Une.call(e,e.transformResponse,t.response),t.response.headers=Bne.from(t.response.headers))),Promise.reject(t)}))}const bae={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{bae[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));const Hae={};bae.transitional=function(e,t,n){function a(e,t){return"[Axios v1.7.9] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,r,o)=>{if(!1===e)throw new mne(a(r," has been removed"+(t?" in "+t:"")),mne.ERR_DEPRECATED);return t&&!Hae[r]&&(Hae[r]=!0,console.warn(a(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,r,o)}},bae.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};var Vae={assertOptions:function(e,t,n){if("object"!=typeof e)throw new mne("options must be an object",mne.ERR_BAD_OPTION_VALUE);const a=Object.keys(e);let r=a.length;for(;r-- >0;){const o=a[r],c=t[o];if(c){const t=e[o],n=void 0===t||c(t,o,e);if(!0!==n)throw new mne("option "+o+" must be "+n,mne.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new mne("Unknown option "+o,mne.ERR_BAD_OPTION)}},validators:bae};const Cae=Vae.validators;class Lae{constructor(e){this.defaults=e,this.interceptors={request:new Lne,response:new Lne}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=eae(this.defaults,t);const{transitional:n,paramsSerializer:a,headers:r}=t;void 0!==n&&Vae.assertOptions(n,{silentJSONParsing:Cae.transitional(Cae.boolean),forcedJSONParsing:Cae.transitional(Cae.boolean),clarifyTimeoutError:Cae.transitional(Cae.boolean)},!1),null!=a&&(vte.isFunction(a)?t.paramsSerializer={serialize:a}:Vae.assertOptions(a,{encode:Cae.function,serialize:Cae.function},!0)),Vae.assertOptions(t,{baseUrl:Cae.spelling("baseURL"),withXsrfToken:Cae.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=r&&vte.merge(r.common,r[t.method]);r&&vte.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete r[e]})),t.headers=Bne.concat(o,r);const c=[];let l=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(l=l&&e.synchronous,c.unshift(e.fulfilled,e.rejected))}));const i=[];let s;this.interceptors.response.forEach((function(e){i.push(e.fulfilled,e.rejected)}));let h,d=0;if(!l){const e=[Eae.bind(this),void 0];for(e.unshift.apply(e,c),e.push.apply(e,i),h=e.length,s=Promise.resolve(t);d<h;)s=s.then(e[d++],e[d++]);return s}h=c.length;let u=t;for(d=0;d<h;){const t=c[d++],n=c[d++];try{u=t(u)}catch(e){n.call(this,e);break}}try{s=Eae.call(this,u)}catch(e){return Promise.reject(e)}for(d=0,h=i.length;d<h;)s=s.then(i[d++],i[d++]);return s}getUri(e){return Cne(Jne((e=eae(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}vte.forEach(["delete","get","head","options"],(function(e){Lae.prototype[e]=function(t,n){return this.request(eae(n||{},{method:e,url:t,data:(n||{}).data}))}})),vte.forEach(["post","put","patch"],(function(e){function t(t){return function(n,a,r){return this.request(eae(r||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:a}))}}Lae.prototype[e]=t(),Lae.prototype[e+"Form"]=t(!0)}));class xae{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const n=this;this.promise.then((e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null})),this.promise.then=e=>{let t;const a=new Promise((e=>{n.subscribe(e),t=e})).then(e);return a.cancel=function(){n.unsubscribe(t)},a},e((function(e,a,r){n.reason||(n.reason=new $ne(e,a,r),t(n.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new xae((function(t){e=t})),cancel:e}}}const Sae={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Sae).forEach((([e,t])=>{Sae[t]=e}));const kae=function e(t){const n=new Lae(t),a=Cee(Lae.prototype.request,n);return vte.extend(a,Lae.prototype,n,{allOwnKeys:!0}),vte.extend(a,n,null,{allOwnKeys:!0}),a.create=function(n){return e(eae(t,n))},a}(_ne);kae.Axios=Lae,kae.CanceledError=$ne,kae.CancelToken=xae,kae.isCancel=Wne,kae.VERSION="1.7.9",kae.toFormData=Mne,kae.AxiosError=mne,kae.Cancel=kae.CanceledError,kae.all=function(e){return Promise.all(e)},kae.spread=function(e){return function(t){return e.apply(null,t)}},kae.isAxiosError=function(e){return vte.isObject(e)&&!0===e.isAxiosError},kae.mergeConfig=eae,kae.AxiosHeaders=Bne,kae.formToJSON=e=>Nne(vte.isHTMLForm(e)?new FormData(e):e),kae.getAdapter=yae,kae.HttpStatusCode=Sae,kae.default=kae;var wae=function(){function e(){}return e.convertJsonToQueryParamsString=function(e){return Object.keys(e).map((function(t){return t+"="+e[t]})).join("&")},e}(),Tae=function(){function e(e){var t=this;this._backendBaseUrl="",this.updatePdf=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.put("".concat(this.getPdfApisEndPointRoute()),e)];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.fetchOnlyPdfData=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfApisEndPointRoute(),"/get"),e)];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.fetchOnlyPdfPagesData=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfPagesApisEndPointRoute(),"?").concat(wae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.createCommentThread=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfApisEndPointRoute(),"/commentThreads"),e)];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.deleteCommentThread=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfApisEndPointRoute(),"/commentThreads/delete"),e)];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.getCommentThreadById=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfApisEndPointRoute(),"/commentThreads/").concat(e.commentThreadId))];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.fetchCommentThreads=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfApisEndPointRoute(),"/commentThreads?").concat(wae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.createComment=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfApisEndPointRoute(),"/commentThreads/comments"),e)];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.fetchUsersOfPdf=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfApisEndPointRoute(),"/getUsers?").concat(wae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.createPageAnnotation=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:if(Object.keys(e.annotation||{}).length>1)throw new Error("invalid request payload");return[4,null===(n=this.api)||void 0===n?void 0:n.post(this.getPdfPagesAnnotationApisEndPointRoute(),e)];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.fetchAnnotation=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfPagesAnnotationApisEndPointRoute(),"?").concat(wae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.fetchAllAnnotationsOfThePage=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfPagesAnnotationApisEndPointRoute(),"?").concat(wae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.updatePageAnnotation=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.put(this.getPdfPagesAnnotationApisEndPointRoute(),e)];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.deletePageAnnotation=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.delete("".concat(this.getPdfPagesAnnotationApisEndPointRoute(),"?").concat(wae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.fetchPdfScales=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfScalesApisEndPointRoute(),"/get"),e)];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.createPdfScale=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfScalesApisEndPointRoute()),e)];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.deletePdfScale=function(e){return Q7(t,void 0,void 0,(function(){var t;return J7(this,(function(n){switch(n.label){case 0:return[4,null===(t=this.api)||void 0===t?void 0:t.post("".concat(this.getPdfScalesApisEndPointRoute(),"/delete"),e)];case 1:return n.sent(),[2]}}))}))},this.updatePdfScale=function(e){return Q7(t,void 0,void 0,(function(){var t,n;return J7(this,(function(a){switch(a.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.put("".concat(this.getPdfScalesApisEndPointRoute(),"/update"),e)];case 1:return[2,null==(t=a.sent())?void 0:t.data]}}))}))},this.convertImageToPdf=function(e){var n=e.imageDownloadUrl,a=e.imageWidth,r=e.imageHeight;return Q7(t,void 0,void 0,(function(){var e,t,o,c,l;return J7(this,(function(i){switch(i.label){case 0:return e={pdfFileName:"image.pdf",imageDetails:{imageDownloadUrl:n,imageWidth:a,imageHeight:r}},[4,null===(o=this.api)||void 0===o?void 0:o.post("".concat(this.getPdfApisEndPointRoute()),e)];case 1:if(t=i.sent(),!(null===(c=null==t?void 0:t.data)||void 0===c?void 0:c._id))throw new Error("pdfId not found");return[4,null===(l=this.api)||void 0===l?void 0:l.post("".concat(this.getPdfApisEndPointRoute(),"/pdf-pages-as-images"),{pdfId:null==t?void 0:t.data._id})];case 2:return i.sent(),[2,{_id:null==t?void 0:t.data._id}]}}))}))},this.backendBaseUrl=e.backendBaseUrl,this.api=kae.create({baseURL:this.backendBaseUrl,headers:{"Content-type":"application/json; charset=utf-8"},withCredentials:!0})}return Object.defineProperty(e.prototype,"backendBaseUrl",{get:function(){return this._backendBaseUrl},set:function(e){this._backendBaseUrl=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"api",{get:function(){return this._api},set:function(e){this._api=e},enumerable:!1,configurable:!0}),e.prototype.getPdfApisEndPointRoute=function(){return"".concat(this.backendBaseUrl,"/pdfs")},e.prototype.getPdfPagesApisEndPointRoute=function(){return"".concat(this.getPdfApisEndPointRoute(),"/pages")},e.prototype.getPdfScalesApisEndPointRoute=function(){return"".concat(this.getPdfApisEndPointRoute(),"/scales")},e.prototype.getPdfPagesAnnotationApisEndPointRoute=function(){return"".concat(this.getPdfPagesApisEndPointRoute(),"/annotation")},e.calculateDistanceBetweenTwoCoordinatesInPdfPagePoints=function(e){var t=e.normalisedCoordinates2.x-e.normalisedCoordinates1.x,n=e.normalisedCoordinates2.y-e.normalisedCoordinates1.y;return Math.sqrt(t*t+n*n)/(e.pdfPageImageOriginalWidth/e.pdfPageOriginalWidthInPoints)},e.convertPdfPagePointsDistanceToInches=function(e){return e.pdfPagePointsDistance/72},e.convertInchesToCentimeters=function(e){return 2.54*e.inches},e.convertInchesToMeters=function(e){return e.inches/39.37},e.convertInchesToFeet=function(e){return e.inches/12},e.convertInchesDistanceToPdfPagePoints=function(e){return 72*e.inchesDistance},e.isUserMoreNearToHorizontalAxisOrVerticalAxis=function(e){var t=e.firstCoordinate,n=e.secondCoordinate,a=n.x-t.x,r=n.y-t.y;return Math.abs(a)>Math.abs(r)?"horizontal":"vertical"},e.prototype.insertPdfAndItsPagesInDb=function(e){var t,n,a;return Q7(this,void 0,void 0,(function(){var r,o,c;return J7(this,(function(l){switch(l.label){case 0:return(r=new FormData).append("pdfDownloadUrl",e.pdfSourceUrl),e.pdfFileName&&r.append("pdfFileName",e.pdfFileName),[4,null===(t=this.api)||void 0===t?void 0:t.post("".concat(this.getPdfApisEndPointRoute()),r,{headers:{"Content-Type":"multipart/form-data"}})];case 1:if(o=l.sent(),!(null===(n=null==o?void 0:o.data)||void 0===n?void 0:n._id))throw new Error("pdfId not found");return c=null===(a=this.api)||void 0===a?void 0:a.post("".concat(this.getPdfApisEndPointRoute(),"/pdf-pages-as-images"),{pdfId:null==o?void 0:o.data._id}),e.shouldWaitForPdfPagesCreation?[4,c]:[3,3];case 2:l.sent(),l.label=3;case 3:return[2,{_id:null==o?void 0:o.data._id}]}}))}))},e.convertNormalisedCoordinatesToUnNormalisedCoordinates=function(t){for(var n=t.normalisedCoordinates,a=t.normalisedXDimension,r=t.normalisedYDimension,o=t.unNormalisedXDimension,c=t.unNormalisedYDimension,l=[],i=0,s=n;i<s.length;i++){var h=s[i],d=h.x,u=h.y,m=e.convertNormalisedValueToUnNormalisedForShowingInUI({normalisedValue:d,normalisedDimension:a,unNormalisedDimension:o}),p=e.convertNormalisedValueToUnNormalisedForShowingInUI({normalisedValue:u,normalisedDimension:r,unNormalisedDimension:c});l.push({x:m,y:p})}return l},e.doNotMakeCoordinatesGoOutOfBoundary=function(e){for(var t=e.coordinates,n=e.coordinateBoundaries,a=0,r=t;a<r.length;a++){var o=r[a];o.x<n.xMin?o.x=n.xMin:o.x>n.xMax&&(o.x=n.xMax),o.y<n.yMin?o.y=n.yMin:o.y>n.yMax&&(o.y=n.yMax)}return t},e.prototype.insertPdfAndItsPagesInDBViaHTML=function(e){var t,n,a;return Q7(this,void 0,void 0,(function(){var r,o,c,l,i,s,h;return J7(this,(function(d){switch(d.label){case 0:if(!(r=document.getElementById(e.htmlElementId)))throw new Error("htmlELement corresponding to the id not found");return o=r.outerHTML,e.cssClassNamesWhichShouldBeRemovedBeforeHtmlToPdfConversion.forEach((function(e){o=o.replaceAll(e,"")})),c=Array.from(document.querySelectorAll("style")).map((function(e){return e.outerHTML})).join("\n"),l='\n <html>\n <head>\n <meta charset="UTF-8">\n '.concat(c,"\n </head>\n <body>\n ").concat(o,"\n </body>\n </html>\n "),i={pdfFileName:"react-html.pdf",htmlDocument:{document:l,width:r.clientWidth}},[4,null===(t=this.api)||void 0===t?void 0:t.post("".concat(this.getPdfApisEndPointRoute()),i)];case 1:if(s=d.sent(),!(null===(n=null==s?void 0:s.data)||void 0===n?void 0:n._id))throw new Error("pdfId not found");return h=null===(a=this.api)||void 0===a?void 0:a.post("".concat(this.getPdfApisEndPointRoute(),"/pdf-pages-as-images"),{pdfId:null==s?void 0:s.data._id}),e.shouldWaitForPdfPagesCreation?[4,h]:[3,3];case 2:d.sent(),d.label=3;case 3:return[2,{_id:null==s?void 0:s.data._id}]}}))}))},e.convertValueFromOneUnitToAnotherUnit=function(e){var t=e.valueToConvert,n=e.fromUnit,a=e.toUnit;if(n===a)return t;var r=0;if("cm"===n)if("m"===a)r=t/100;else if("inch"===a)r=t/2.54;else{if("ft"!==a)throw new Error("Invalid toUnit");r=t/30.48}else if("m"===n)if("cm"===a)r=100*t;else if("inch"===a)r=39.37*t;else{if("ft"!==a)throw new Error("Invalid toUnit");r=3.281*t}else if("inch"===n)if("cm"===a)r=2.54*t;else if("m"===a)r=t/39.37;else{if("ft"!==a)throw new Error("Invalid toUnit");r=t/12}else{if("ft"!==n)throw new Error("Invalid fromUnit");if("cm"===a)r=30.48*t;else if("m"===a)r=t/3.281;else{if("inch"!==a)throw new Error("Invalid toUnit");r=12*t}}return r},e.convertNormalisedValueToUnNormalisedForShowingInUI=function(e){var t=e.normalisedValue,n=e.normalisedDimension;return t*(e.unNormalisedDimension/n)},e.convertUnNormalisedValueToNormalised=function(e){var t=e.unNormalisedValue,n=e.normalisedDimension;return t/(e.unNormalisedDimension/n)},e.convertCoordinatesArrayToNumberArray=function(e){for(var t=e.coordinates,n=[],a=0;a<t.length;a++)n.push(t[a].x),n.push(t[a].y);return n},e}(),Oae=function(){function e(){}return e.getImageWidthHeightFromURL=function(e){return Q7(this,void 0,void 0,(function(){var t;return J7(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,new Promise((function(t,n){try{var a=new Image;a.onload=function(){return t({width:a.width,height:a.height})},a.src=e}catch(e){n(new Error(e.message))}}))];case 1:return[2,n.sent()];case 2:throw t=n.sent(),new Error(t.message);case 3:return[2]}}))}))},e.getImageHeight=function(e,t){return e/t},e.getImageWidth=function(e,t){return e*t},e.downloadImage=function(e){return new Promise((function(t,n){var a=new Image;a.onload=function(){return t(a)},a.onerror=function(){return n(new Error("Image loading having url ".concat(e," got failed")))},a.src=e}))},e}(),Aae={d:(e,t)=>{for(var n in t)Aae.o(t,n)&&!Aae.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},Rae=globalThis.pdfjsLib={};Aae.d(Rae,{AbortException:()=>ire,AnnotationEditorLayer:()=>Ile,AnnotationEditorParamsType:()=>jae,AnnotationEditorType:()=>Iae,AnnotationEditorUIManager:()=>Gre,AnnotationLayer:()=>Ele,AnnotationMode:()=>Fae,ColorPicker:()=>Tle,DOMSVGFactory:()=>Uce,DrawLayer:()=>jle,FeatureTest:()=>ure,GlobalWorkerOptions:()=>Uoe,ImageKind:()=>Uae,InvalidPDFException:()=>rre,MissingPDFException:()=>ore,OPS:()=>$ae,OutputScale:()=>Pre,PDFDataRangeTransport:()=>xce,PDFDateString:()=>Ore,PDFWorker:()=>Tce,PasswordResponses:()=>qae,PermissionFlag:()=>Bae,PixelsPerInch:()=>Mre,RenderingCancelledException:()=>Hre,TextLayer:()=>zce,TouchManager:()=>Kre,UnexpectedResponseException:()=>cre,Util:()=>pre,VerbosityLevel:()=>Wae,XfaLayer:()=>Wce,build:()=>Pce,createValidAbsoluteUrl:()=>Zae,fetchData:()=>Ere,getDocument:()=>Vce,getFilenameFromUrl:()=>Lre,getPdfFilenameFromUrl:()=>xre,getXfaPageViewport:()=>Are,isDataScheme:()=>Vre,isPdfFile:()=>Cre,noContextMenu:()=>wre,normalizeUnicode:()=>zre,setLayerDimensions:()=>Dre,shadow:()=>ere,stopEvent:()=>Tre,version:()=>Dce});const Nae=!("object"!=typeof yt||yt+""!="[object process]"||yt.versions.nw||yt.versions.electron&&yt.type&&"browser"!==yt.type),_ae=[1,0,0,1,0,0],Dae=[.001,0,0,.001,0,0],Pae=1.35,Fae={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Iae={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},jae={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},Bae={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Uae={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Wae={ERRORS:0,WARNINGS:1,INFOS:5},$ae={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93},qae={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Gae=Wae.WARNINGS;function Yae(){return Gae}function Kae(e){Gae>=Wae.INFOS&&console.log(`Info: ${e}`)}function Xae(e){Gae>=Wae.WARNINGS&&console.log(`Warning: ${e}`)}function Qae(e){throw new Error(e)}function Jae(e,t){e||Qae(t)}function Zae(e,t=null,n=null){if(!e)return null;try{if(n&&"string"==typeof e){if(n.addDefaultProtocol&&e.startsWith("www.")){const t=e.match(/\./g);t?.length>=2&&(e=`http://${e}`)}if(n.tryConvertEncoding)try{e=decodeURIComponent(escape(e))}catch{}}const a=t?new URL(e,t):new URL(e);if(function(e){switch(e?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(a))return a}catch{}return null}function ere(e,t,n,a=!1){return Object.defineProperty(e,t,{value:n,enumerable:!a,configurable:!0,writable:!1}),n}const tre=function(){function e(e,t){this.message=e,this.name=t}return e.prototype=new Error,e.constructor=e,e}();class nre extends tre{constructor(e,t){super(e,"PasswordException"),this.code=t}}class are extends tre{constructor(e,t){super(e,"UnknownErrorException"),this.details=t}}class rre extends tre{constructor(e){super(e,"InvalidPDFException")}}class ore extends tre{constructor(e){super(e,"MissingPDFException")}}class cre extends tre{constructor(e,t){super(e,"UnexpectedResponseException"),this.status=t}}class lre extends tre{constructor(e){super(e,"FormatError")}}class ire extends tre{constructor(e){super(e,"AbortException")}}function sre(e){"object"==typeof e&&void 0!==e?.length||Qae("Invalid argument for bytesToString");const t=e.length,n=8192;if(t<n)return String.fromCharCode.apply(null,e);const a=[];for(let r=0;r<t;r+=n){const o=Math.min(r+n,t),c=e.subarray(r,o);a.push(String.fromCharCode.apply(null,c))}return a.join("")}function hre(e){"string"!=typeof e&&Qae("Invalid argument for stringToBytes");const t=e.length,n=new Uint8Array(t);for(let a=0;a<t;++a)n[a]=255&e.charCodeAt(a);return n}function dre(e){const t=Object.create(null);for(const[n,a]of e)t[n]=a;return t}class ure{static get isLittleEndian(){return ere(this,"isLittleEndian",function(){const e=new Uint8Array(4);return e[0]=1,1===new Uint32Array(e.buffer,0,1)[0]}())}static get isEvalSupported(){return ere(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return ere(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return ere(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){return"undefined"!=typeof navigator&&"string"==typeof navigator?.platform?ere(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:"string"==typeof navigator?.userAgent&&navigator.userAgent.includes("Firefox")}):ere(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return ere(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const mre=Array.from(Array(256).keys(),(e=>e.toString(16).padStart(2,"0")));class pre{static makeHexColor(e,t,n){return`#${mre[e]}${mre[t]}${mre[n]}`}static scaleMinMax(e,t){let n;e[0]?(e[0]<0&&(n=t[0],t[0]=t[2],t[2]=n),t[0]*=e[0],t[2]*=e[0],e[3]<0&&(n=t[1],t[1]=t[3],t[3]=n),t[1]*=e[3],t[3]*=e[3]):(n=t[0],t[0]=t[1],t[1]=n,n=t[2],t[2]=t[3],t[3]=n,e[1]<0&&(n=t[1],t[1]=t[3],t[3]=n),t[1]*=e[1],t[3]*=e[1],e[2]<0&&(n=t[0],t[0]=t[2],t[2]=n),t[0]*=e[2],t[2]*=e[2]),t[0]+=e[4],t[1]+=e[5],t[2]+=e[4],t[3]+=e[5]}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static applyTransform(e,t){return[e[0]*t[0]+e[1]*t[2]+t[4],e[0]*t[1]+e[1]*t[3]+t[5]]}static applyInverseTransform(e,t){const n=t[0]*t[3]-t[1]*t[2];return[(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/n,(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/n]}static getAxialAlignedBoundingBox(e,t){const n=this.applyTransform(e,t),a=this.applyTransform(e.slice(2,4),t),r=this.applyTransform([e[0],e[3]],t),o=this.applyTransform([e[2],e[1]],t);return[Math.min(n[0],a[0],r[0],o[0]),Math.min(n[1],a[1],r[1],o[1]),Math.max(n[0],a[0],r[0],o[0]),Math.max(n[1],a[1],r[1],o[1])]}static inverseTransform(e){const t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e){const t=[e[0],e[2],e[1],e[3]],n=e[0]*t[0]+e[1]*t[2],a=e[0]*t[1]+e[1]*t[3],r=e[2]*t[0]+e[3]*t[2],o=e[2]*t[1]+e[3]*t[3],c=(n+o)/2,l=Math.sqrt((n+o)**2-4*(n*o-r*a))/2,i=c+l||1,s=c-l||1;return[Math.sqrt(i),Math.sqrt(s)]}static normalizeRect(e){const t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){const n=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),a=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(n>a)return null;const r=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),o=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return r>o?null:[n,r,a,o]}static#e(e,t,n,a,r,o,c,l,i,s){if(i<=0||i>=1)return;const h=1-i,d=i*i,u=d*i,m=h*(h*(h*e+3*i*t)+3*d*n)+u*a,p=h*(h*(h*r+3*i*o)+3*d*c)+u*l;s[0]=Math.min(s[0],m),s[1]=Math.min(s[1],p),s[2]=Math.max(s[2],m),s[3]=Math.max(s[3],p)}static#t(e,t,n,a,r,o,c,l,i,s,h,d){if(Math.abs(i)<1e-12)return void(Math.abs(s)>=1e-12&&this.#e(e,t,n,a,r,o,c,l,-h/s,d));const u=s**2-4*h*i;if(u<0)return;const m=Math.sqrt(u),p=2*i;this.#e(e,t,n,a,r,o,c,l,(-s+m)/p,d),this.#e(e,t,n,a,r,o,c,l,(-s-m)/p,d)}static bezierBoundingBox(e,t,n,a,r,o,c,l,i){return i?(i[0]=Math.min(i[0],e,c),i[1]=Math.min(i[1],t,l),i[2]=Math.max(i[2],e,c),i[3]=Math.max(i[3],t,l)):i=[Math.min(e,c),Math.min(t,l),Math.max(e,c),Math.max(t,l)],this.#t(e,n,r,c,t,a,o,l,3*(3*(n-r)-e+c),6*(e-2*n+r),3*(n-e),i),this.#t(e,n,r,c,t,a,o,l,3*(3*(a-o)-t+l),6*(t-2*a+o),3*(a-t),i),i}}let vre=null,fre=null;function zre(e){return vre||(vre=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,fre=new Map([["ſt","ſt"]])),e.replaceAll(vre,((e,t,n)=>t?t.normalize("NFKC"):fre.get(n)))}const gre="pdfjs_internal_id_";"function"!=typeof Promise.try&&(Promise.try=function(e,...t){return new Promise((n=>{n(e(...t))}))});const yre="http://www.w3.org/2000/svg";class Mre{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function Ere(e,t="text"){if(kre(e,document.baseURI)){const n=await fetch(e);if(!n.ok)throw new Error(n.statusText);switch(t){case"arraybuffer":return n.arrayBuffer();case"blob":return n.blob();case"json":return n.json()}return n.text()}return new Promise(((n,a)=>{const r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType=t,r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE)if(200!==r.status&&0!==r.status)a(new Error(r.statusText));else{switch(t){case"arraybuffer":case"blob":case"json":return void n(r.response)}n(r.responseText)}},r.send(null)}))}class bre{constructor({viewBox:e,userUnit:t,scale:n,rotation:a,offsetX:r=0,offsetY:o=0,dontFlip:c=!1}){this.viewBox=e,this.userUnit=t,this.scale=n,this.rotation=a,this.offsetX=r,this.offsetY=o,n*=t;const l=(e[2]+e[0])/2,i=(e[3]+e[1])/2;let s,h,d,u,m,p,v,f;switch((a%=360)<0&&(a+=360),a){case 180:s=-1,h=0,d=0,u=1;break;case 90:s=0,h=1,d=1,u=0;break;case 270:s=0,h=-1,d=-1,u=0;break;case 0:s=1,h=0,d=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}c&&(d=-d,u=-u),0===s?(m=Math.abs(i-e[1])*n+r,p=Math.abs(l-e[0])*n+o,v=(e[3]-e[1])*n,f=(e[2]-e[0])*n):(m=Math.abs(l-e[0])*n+r,p=Math.abs(i-e[1])*n+o,v=(e[2]-e[0])*n,f=(e[3]-e[1])*n),this.transform=[s*n,h*n,d*n,u*n,m-s*n*l-d*n*i,p-h*n*l-u*n*i],this.width=v,this.height=f}get rawDims(){const{userUnit:e,viewBox:t}=this,n=t.map((t=>t*e));return ere(this,"rawDims",{pageWidth:n[2]-n[0],pageHeight:n[3]-n[1],pageX:n[0],pageY:n[1]})}clone({scale:e=this.scale,rotation:t=this.rotation,offsetX:n=this.offsetX,offsetY:a=this.offsetY,dontFlip:r=!1}={}){return new bre({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:e,rotation:t,offsetX:n,offsetY:a,dontFlip:r})}convertToViewportPoint(e,t){return pre.applyTransform([e,t],this.transform)}convertToViewportRectangle(e){const t=pre.applyTransform([e[0],e[1]],this.transform),n=pre.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],n[0],n[1]]}convertToPdfPoint(e,t){return pre.applyInverseTransform([e,t],this.transform)}}class Hre extends tre{constructor(e,t=0){super(e,"RenderingCancelledException"),this.extraDelay=t}}function Vre(e){const t=e.length;let n=0;for(;n<t&&""===e[n].trim();)n++;return"data:"===e.substring(n,n+5).toLowerCase()}function Cre(e){return"string"==typeof e&&/\.pdf$/i.test(e)}function Lre(e){return[e]=e.split(/[#?]/,1),e.substring(e.lastIndexOf("/")+1)}function xre(e,t="document.pdf"){if("string"!=typeof e)return t;if(Vre(e))return Xae('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const n=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,a=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(e);let r=n.exec(a[1])||n.exec(a[2])||n.exec(a[3]);if(r&&(r=r[0],r.includes("%")))try{r=n.exec(decodeURIComponent(r))[0]}catch{}return r||t}class Sre{started=Object.create(null);times=[];time(e){e in this.started&&Xae(`Timer is already running for ${e}`),this.started[e]=Date.now()}timeEnd(e){e in this.started||Xae(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.started[e],end:Date.now()}),delete this.started[e]}toString(){const e=[];let t=0;for(const{name:e}of this.times)t=Math.max(e.length,t);for(const{name:n,start:a,end:r}of this.times)e.push(`${n.padEnd(t)} ${r-a}ms\n`);return e.join("")}}function kre(e,t){try{const{protocol:n}=t?new URL(e,t):new URL(e);return"http:"===n||"https:"===n}catch{return!1}}function wre(e){e.preventDefault()}function Tre(e){e.preventDefault(),e.stopPropagation()}class Ore{static#n;static toDateObject(e){if(!e||"string"!=typeof e)return null;this.#n||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const t=this.#n.exec(e);if(!t)return null;const n=parseInt(t[1],10);let a=parseInt(t[2],10);a=a>=1&&a<=12?a-1:0;let r=parseInt(t[3],10);r=r>=1&&r<=31?r:1;let o=parseInt(t[4],10);o=o>=0&&o<=23?o:0;let c=parseInt(t[5],10);c=c>=0&&c<=59?c:0;let l=parseInt(t[6],10);l=l>=0&&l<=59?l:0;const i=t[7]||"Z";let s=parseInt(t[8],10);s=s>=0&&s<=23?s:0;let h=parseInt(t[9],10)||0;return h=h>=0&&h<=59?h:0,"-"===i?(o+=s,c+=h):"+"===i&&(o-=s,c-=h),new Date(Date.UTC(n,a,r,o,c,l))}}function Are(e,{scale:t=1,rotation:n=0}){const{width:a,height:r}=e.attributes.style,o=[0,0,parseInt(a),parseInt(r)];return new bre({viewBox:o,userUnit:1,scale:t,rotation:n})}function Rre(e){if(e.startsWith("#")){const t=parseInt(e.slice(1),16);return[(16711680&t)>>16,(65280&t)>>8,255&t]}return e.startsWith("rgb(")?e.slice(4,-1).split(",").map((e=>parseInt(e))):e.startsWith("rgba(")?e.slice(5,-1).split(",").map((e=>parseInt(e))).slice(0,3):(Xae(`Not a valid color format: "${e}"`),[0,0,0])}function Nre(e){const{a:t,b:n,c:a,d:r,e:o,f:c}=e.getTransform();return[t,n,a,r,o,c]}function _re(e){const{a:t,b:n,c:a,d:r,e:o,f:c}=e.getTransform().invertSelf();return[t,n,a,r,o,c]}function Dre(e,t,n=!1,a=!0){if(t instanceof bre){const{pageWidth:a,pageHeight:r}=t.rawDims,{style:o}=e,c=ure.isCSSRoundSupported,l=`var(--scale-factor) * ${a}px`,i=`var(--scale-factor) * ${r}px`,s=c?`round(down, ${l}, var(--scale-round-x, 1px))`:`calc(${l})`,h=c?`round(down, ${i}, var(--scale-round-y, 1px))`:`calc(${i})`;n&&t.rotation%180!=0?(o.width=h,o.height=s):(o.width=s,o.height=h)}a&&e.setAttribute("data-main-rotation",t.rotation)}class Pre{constructor(){const e=window.devicePixelRatio||1;this.sx=e,this.sy=e}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}}class Fre{#a=null;#r=null;#o;#c=null;#l=null;static#i=null;constructor(e){this.#o=e,Fre.#i||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"})}render(){const e=this.#a=document.createElement("div");e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");const t=this.#o._uiManager._signal;e.addEventListener("contextmenu",wre,{signal:t}),e.addEventListener("pointerdown",Fre.#s,{signal:t});const n=this.#c=document.createElement("div");n.className="buttons",e.append(n);const a=this.#o.toolbarPosition;if(a){const{style:t}=e,n="ltr"===this.#o._uiManager.direction?1-a[0]:a[0];t.insetInlineEnd=100*n+"%",t.top=`calc(${100*a[1]}% + var(--editor-toolbar-vert-offset))`}return this.#h(),e}get div(){return this.#a}static#s(e){e.stopPropagation()}#d(e){this.#o._focusEventsAllowed=!1,Tre(e)}#u(e){this.#o._focusEventsAllowed=!0,Tre(e)}#m(e){const t=this.#o._uiManager._signal;e.addEventListener("focusin",this.#d.bind(this),{capture:!0,signal:t}),e.addEventListener("focusout",this.#u.bind(this),{capture:!0,signal:t}),e.addEventListener("contextmenu",wre,{signal:t})}hide(){this.#a.classList.add("hidden"),this.#r?.hideDropdown()}show(){this.#a.classList.remove("hidden"),this.#l?.shown()}#h(){const{editorType:e,_uiManager:t}=this.#o,n=document.createElement("button");n.className="delete",n.tabIndex=0,n.setAttribute("data-l10n-id",Fre.#i[e]),this.#m(n),n.addEventListener("click",(e=>{t.delete()}),{signal:t._signal}),this.#c.append(n)}get#p(){const e=document.createElement("div");return e.className="divider",e}async addAltText(e){const t=await e.render();this.#m(t),this.#c.prepend(t,this.#p),this.#l=e}addColorPicker(e){this.#r=e;const t=e.renderButton();this.#m(t),this.#c.prepend(t,this.#p)}remove(){this.#a.remove(),this.#r?.destroy(),this.#r=null}}class Ire{#c=null;#a=null;#v;constructor(e){this.#v=e}#f(){const e=this.#a=document.createElement("div");e.className="editToolbar",e.setAttribute("role","toolbar"),e.addEventListener("contextmenu",wre,{signal:this.#v._signal});const t=this.#c=document.createElement("div");return t.className="buttons",e.append(t),this.#z(),e}#g(e,t){let n=0,a=0;for(const r of e){const e=r.y+r.height;if(e<n)continue;const o=r.x+(t?r.width:0);e>n?(a=o,n=e):t?o>a&&(a=o):o<a&&(a=o)}return[t?1-a:a,n]}show(e,t,n){const[a,r]=this.#g(t,n),{style:o}=this.#a||=this.#f();e.append(this.#a),o.insetInlineEnd=100*a+"%",o.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){this.#a.remove()}#z(){const e=document.createElement("button");e.className="highlightButton",e.tabIndex=0,e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const t=document.createElement("span");e.append(t),t.className="visuallyHidden",t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const n=this.#v._signal;e.addEventListener("contextmenu",wre,{signal:n}),e.addEventListener("click",(()=>{this.#v.highlightSelection("floating_button")}),{signal:n}),this.#c.append(e)}}function jre(e,t,n){for(const a of n)t.addEventListener(a,e[a].bind(e))}class Bre{#y=0;get id(){return"pdfjs_internal_editor_"+this.#y++}}class Ure{#M=function(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const e=new Uint8Array(32);return crypto.getRandomValues(e),sre(e)}();#y=0;#E=null;static get _isSVGFittingCanvas(){const e=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),t=new Image;return t.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',ere(this,"_isSVGFittingCanvas",t.decode().then((()=>(e.drawImage(t,0,0,1,1,0,0,1,3),0===new Uint32Array(e.getImageData(0,0,1,1).data.buffer)[0]))))}async#b(e,t){this.#E||=new Map;let n=this.#E.get(e);if(null===n)return null;if(n?.bitmap)return n.refCounter+=1,n;try{let e;if(n||={bitmap:null,id:`image_${this.#M}_${this.#y++}`,refCounter:0,isSvg:!1},"string"==typeof t?(n.url=t,e=await Ere(t,"blob")):t instanceof File?e=n.file=t:t instanceof Blob&&(e=t),"image/svg+xml"===e.type){const t=Ure._isSVGFittingCanvas,a=new FileReader,r=new Image,o=new Promise(((e,o)=>{r.onload=()=>{n.bitmap=r,n.isSvg=!0,e()},a.onload=async()=>{const e=n.svgUrl=a.result;r.src=await t?`${e}#svgView(preserveAspectRatio(none))`:e},r.onerror=a.onerror=o}));a.readAsDataURL(e),await o}else n.bitmap=await createImageBitmap(e);n.refCounter=1}catch(e){Xae(e),n=null}return this.#E.set(e,n),n&&this.#E.set(n.id,n),n}async getFromFile(e){const{lastModified:t,name:n,size:a,type:r}=e;return this.#b(`${t}_${n}_${a}_${r}`,e)}async getFromUrl(e){return this.#b(e,e)}async getFromBlob(e,t){const n=await t;return this.#b(e,n)}async getFromId(e){this.#E||=new Map;const t=this.#E.get(e);if(!t)return null;if(t.bitmap)return t.refCounter+=1,t;if(t.file)return this.getFromFile(t.file);if(t.blobPromise){const{blobPromise:e}=t;return delete t.blobPromise,this.getFromBlob(t.id,e)}return this.getFromUrl(t.url)}getFromCanvas(e,t){this.#E||=new Map;let n=this.#E.get(e);if(n?.bitmap)return n.refCounter+=1,n;const a=new OffscreenCanvas(t.width,t.height);return a.getContext("2d").drawImage(t,0,0),n={bitmap:a.transferToImageBitmap(),id:`image_${this.#M}_${this.#y++}`,refCounter:1,isSvg:!1},this.#E.set(e,n),this.#E.set(n.id,n),n}getSvgUrl(e){const t=this.#E.get(e);return t?.isSvg?t.svgUrl:null}deleteId(e){this.#E||=new Map;const t=this.#E.get(e);if(!t)return;if(t.refCounter-=1,0!==t.refCounter)return;const{bitmap:n}=t;if(!t.url&&!t.file){const e=new OffscreenCanvas(n.width,n.height);e.getContext("bitmaprenderer").transferFromImageBitmap(n),t.blobPromise=e.convertToBlob()}n.close?.(),t.bitmap=null}isValidId(e){return e.startsWith(`image_${this.#M}_`)}}class Wre{#H=[];#V=!1;#C;#L=-1;constructor(e=128){this.#C=e}add({cmd:e,undo:t,post:n,mustExec:a,type:r=NaN,overwriteIfSameType:o=!1,keepUndo:c=!1}){if(a&&e(),this.#V)return;const l={cmd:e,undo:t,post:n,type:r};if(-1===this.#L)return this.#H.length>0&&(this.#H.length=0),this.#L=0,void this.#H.push(l);if(o&&this.#H[this.#L].type===r)return c&&(l.undo=this.#H[this.#L].undo),void(this.#H[this.#L]=l);const i=this.#L+1;i===this.#C?this.#H.splice(0,1):(this.#L=i,i<this.#H.length&&this.#H.splice(i)),this.#H.push(l)}undo(){if(-1===this.#L)return;this.#V=!0;const{undo:e,post:t}=this.#H[this.#L];e(),t?.(),this.#V=!1,this.#L-=1}redo(){if(this.#L<this.#H.length-1){this.#L+=1,this.#V=!0;const{cmd:e,post:t}=this.#H[this.#L];e(),t?.(),this.#V=!1}}hasSomethingToUndo(){return-1!==this.#L}hasSomethingToRedo(){return this.#L<this.#H.length-1}cleanType(e){if(-1!==this.#L){for(let t=this.#L;t>=0;t--)if(this.#H[t].type!==e)return this.#H.splice(t+1,this.#L-t),void(this.#L=t);this.#H.length=0,this.#L=-1}}destroy(){this.#H=null}}class $re{constructor(e){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:t}=ure.platform;for(const[n,a,r={}]of e)for(const e of n){const n=e.startsWith("mac+");t&&n?(this.callbacks.set(e.slice(4),{callback:a,options:r}),this.allKeys.add(e.split("+").at(-1))):t||n||(this.callbacks.set(e,{callback:a,options:r}),this.allKeys.add(e.split("+").at(-1)))}}#x(e){e.altKey&&this.buffer.push("alt"),e.ctrlKey&&this.buffer.push("ctrl"),e.metaKey&&this.buffer.push("meta"),e.shiftKey&&this.buffer.push("shift"),this.buffer.push(e.key);const t=this.buffer.join("+");return this.buffer.length=0,t}exec(e,t){if(!this.allKeys.has(t.key))return;const n=this.callbacks.get(this.#x(t));if(!n)return;const{callback:a,options:{bubbles:r=!1,args:o=[],checker:c=null}}=n;c&&!c(e,t)||(a.bind(e,...o,t)(),r||Tre(t))}}class qre{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const e=new Map([["CanvasText",null],["Canvas",null]]);return function(e){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const n of e.keys()){t.style.color=n;const a=window.getComputedStyle(t).color;e.set(n,Rre(a))}t.remove()}(e),ere(this,"_colors",e)}convert(e){const t=Rre(e);if(!window.matchMedia("(forced-colors: active)").matches)return t;for(const[e,n]of this._colors)if(n.every(((e,n)=>e===t[n])))return qre._colorsMapping.get(e);return t}getHexCode(e){const t=this._colors.get(e);return t?pre.makeHexColor(...t):e}}class Gre{#S=new AbortController;#k=null;#w=new Map;#T=new Map;#O=null;#A=null;#R=null;#N=new Wre;#_=null;#D=null;#P=0;#F=new Set;#I=null;#j=null;#B=new Set;_editorUndoBar=null;#U=!1;#W=!1;#$=!1;#q=null;#G=null;#Y=null;#K=null;#X=!1;#Q=null;#J=new Bre;#Z=!1;#ee=!1;#te=null;#ne=null;#ae=null;#re=null;#oe=Iae.NONE;#ce=new Set;#le=null;#ie=null;#se=null;#he={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#de=[0,0];#ue=null;#me=null;#pe=null;#ve=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const e=Gre.prototype,t=e=>e.#me.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&e.hasSomethingToControl(),n=(e,{target:t})=>{if(t instanceof HTMLInputElement){const{type:e}=t;return"text"!==e&&"number"!==e}return!0},a=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return ere(this,"_keyboardManager",new $re([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:n}],[["ctrl+z","mac+meta+z"],e.undo,{checker:n}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:n}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:n}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#me.contains(t)&&!e.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#me.contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-a,0],checker:t}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-r,0],checker:t}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[a,0],checker:t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[r,0],checker:t}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-a],checker:t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-r],checker:t}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,a],checker:t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,r],checker:t}]]))}constructor(e,t,n,a,r,o,c,l,i,s,h,d,u){const m=this._signal=this.#S.signal;this.#me=e,this.#pe=t,this.#O=n,this._eventBus=a,a._on("editingaction",this.onEditingAction.bind(this),{signal:m}),a._on("pagechanging",this.onPageChanging.bind(this),{signal:m}),a._on("scalechanging",this.onScaleChanging.bind(this),{signal:m}),a._on("rotationchanging",this.onRotationChanging.bind(this),{signal:m}),a._on("setpreference",this.onSetPreference.bind(this),{signal:m}),a._on("switchannotationeditorparams",(e=>this.updateParams(e.type,e.value)),{signal:m}),this.#fe(),this.#ze(),this.#ge(),this.#A=r.annotationStorage,this.#q=r.filterFactory,this.#ie=o,this.#K=c||null,this.#U=l,this.#W=i,this.#$=s,this.#re=h||null,this.viewParameters={realScale:Mre.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=d||null,this._supportsPinchToZoom=!1!==u}destroy(){this.#ve?.resolve(),this.#ve=null,this.#S?.abort(),this.#S=null,this._signal=null;for(const e of this.#T.values())e.destroy();this.#T.clear(),this.#w.clear(),this.#B.clear(),this.#k=null,this.#ce.clear(),this.#N.destroy(),this.#O?.destroy(),this.#Q?.hide(),this.#Q=null,this.#G&&(clearTimeout(this.#G),this.#G=null),this.#ue&&(clearTimeout(this.#ue),this.#ue=null),this._editorUndoBar?.destroy()}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return this.#re}get useNewAltTextFlow(){return this.#W}get useNewAltTextWhenAddingImage(){return this.#$}get hcmFilter(){return ere(this,"hcmFilter",this.#ie?this.#q.addHCMFilter(this.#ie.foreground,this.#ie.background):"none")}get direction(){return ere(this,"direction",getComputedStyle(this.#me).direction)}get highlightColors(){return ere(this,"highlightColors",this.#K?new Map(this.#K.split(",").map((e=>e.split("=").map((e=>e.trim()))))):null)}get highlightColorNames(){return ere(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(e=>e.reverse()))):null)}setCurrentDrawingSession(e){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#D=e}setMainHighlightColorPicker(e){this.#ae=e}editAltText(e,t=!1){this.#O?.editAltText(this,e,t)}switchToMode(e,t){this._eventBus.on("annotationeditormodechanged",t,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:e})}setPreference(e,t){this._eventBus.dispatch("setpreference",{source:this,name:e,value:t})}onSetPreference({name:e,value:t}){"enableNewAltTextWhenAddingImage"===e&&(this.#$=t)}onPageChanging({pageNumber:e}){this.#P=e-1}focusMainContainer(){this.#me.focus()}findParent(e,t){for(const n of this.#T.values()){const{x:a,y:r,width:o,height:c}=n.div.getBoundingClientRect();if(e>=a&&e<=a+o&&t>=r&&t<=r+c)return n}return null}disableUserSelect(e=!1){this.#pe.classList.toggle("noUserSelect",e)}addShouldRescale(e){this.#B.add(e)}removeShouldRescale(e){this.#B.delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*Mre.PDF_TO_CSS_UNITS;for(const e of this.#B)e.onScaleChanging();this.#D?.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}#ye({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e}#Me(e){const{currentLayer:t}=this;if(t.hasTextLayer(e))return t;for(const t of this.#T.values())if(t.hasTextLayer(e))return t;return null}highlightSelection(e=""){const t=document.getSelection();if(!t||t.isCollapsed)return;const{anchorNode:n,anchorOffset:a,focusNode:r,focusOffset:o}=t,c=t.toString(),l=this.#ye(t).closest(".textLayer"),i=this.getSelectionBoxes(l);if(!i)return;t.empty();const s=this.#Me(l),h=this.#oe===Iae.NONE,d=()=>{s?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:i,anchorNode:n,anchorOffset:a,focusNode:r,focusOffset:o,text:c}),h&&this.showAllEditors("highlight",!0,!0)};h?this.switchToMode(Iae.HIGHLIGHT,d):d()}#Ee(){const e=document.getSelection();if(!e||e.isCollapsed)return;const t=this.#ye(e).closest(".textLayer"),n=this.getSelectionBoxes(t);n&&(this.#Q||=new Ire(this),this.#Q.show(t,n,"ltr"===this.direction))}addToAnnotationStorage(e){e.isEmpty()||!this.#A||this.#A.has(e.id)||this.#A.setValue(e.id,e)}#be(){const e=document.getSelection();if(!e||e.isCollapsed)return void(this.#le&&(this.#Q?.hide(),this.#le=null,this.#He({hasSelectedText:!1})));const{anchorNode:t}=e;if(t===this.#le)return;const n=this.#ye(e).closest(".textLayer");if(n){if(this.#Q?.hide(),this.#le=t,this.#He({hasSelectedText:!0}),(this.#oe===Iae.HIGHLIGHT||this.#oe===Iae.NONE)&&(this.#oe===Iae.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#X=this.isShiftKeyDown,!this.isShiftKeyDown)){const e=this.#oe===Iae.HIGHLIGHT?this.#Me(n):null;e?.toggleDrawing();const t=new AbortController,a=this.combinedSignal(t),r=n=>{"pointerup"===n.type&&0!==n.button||(t.abort(),e?.toggleDrawing(!0),"pointerup"===n.type&&this.#Ve("main_toolbar"))};window.addEventListener("pointerup",r,{signal:a}),window.addEventListener("blur",r,{signal:a})}}else this.#le&&(this.#Q?.hide(),this.#le=null,this.#He({hasSelectedText:!1}))}#Ve(e=""){this.#oe===Iae.HIGHLIGHT?this.highlightSelection(e):this.#U&&this.#Ee()}#fe(){document.addEventListener("selectionchange",this.#be.bind(this),{signal:this._signal})}#Ce(){if(this.#Y)return;this.#Y=new AbortController;const e=this.combinedSignal(this.#Y);window.addEventListener("focus",this.focus.bind(this),{signal:e}),window.addEventListener("blur",this.blur.bind(this),{signal:e})}#Le(){this.#Y?.abort(),this.#Y=null}blur(){if(this.isShiftKeyDown=!1,this.#X&&(this.#X=!1,this.#Ve("main_toolbar")),!this.hasSelection)return;const{activeElement:e}=document;for(const t of this.#ce)if(t.div.contains(e)){this.#ne=[t,e],t._focusEventsAllowed=!1;break}}focus(){if(!this.#ne)return;const[e,t]=this.#ne;this.#ne=null,t.addEventListener("focusin",(()=>{e._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),t.focus()}#ge(){if(this.#te)return;this.#te=new AbortController;const e=this.combinedSignal(this.#te);window.addEventListener("keydown",this.keydown.bind(this),{signal:e}),window.addEventListener("keyup",this.keyup.bind(this),{signal:e})}#xe(){this.#te?.abort(),this.#te=null}#Se(){if(this.#_)return;this.#_=new AbortController;const e=this.combinedSignal(this.#_);document.addEventListener("copy",this.copy.bind(this),{signal:e}),document.addEventListener("cut",this.cut.bind(this),{signal:e}),document.addEventListener("paste",this.paste.bind(this),{signal:e})}#ke(){this.#_?.abort(),this.#_=null}#ze(){const e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e}),document.addEventListener("drop",this.drop.bind(this),{signal:e})}addEditListeners(){this.#ge(),this.#Se()}removeEditListeners(){this.#xe(),this.#ke()}dragOver(e){for(const{type:t}of e.dataTransfer.items)for(const n of this.#j)if(n.isHandlingMimeForPasting(t))return e.dataTransfer.dropEffect="copy",void e.preventDefault()}drop(e){for(const t of e.dataTransfer.items)for(const n of this.#j)if(n.isHandlingMimeForPasting(t.type))return n.paste(t,this.currentLayer),void e.preventDefault()}copy(e){if(e.preventDefault(),this.#k?.commitOrRemove(),!this.hasSelection)return;const t=[];for(const e of this.#ce){const n=e.serialize(!0);n&&t.push(n)}0!==t.length&&e.clipboardData.setData("application/pdfjs",JSON.stringify(t))}cut(e){this.copy(e),this.delete()}async paste(e){e.preventDefault();const{clipboardData:t}=e;for(const e of t.items)for(const t of this.#j)if(t.isHandlingMimeForPasting(e.type))return void t.paste(e,this.currentLayer);let n=t.getData("application/pdfjs");if(!n)return;try{n=JSON.parse(n)}catch(e){return void Xae(`paste: "${e.message}".`)}if(!Array.isArray(n))return;this.unselectAll();const a=this.currentLayer;try{const e=[];for(const t of n){const n=await a.deserialize(t);if(!n)return;e.push(n)}const t=()=>{for(const t of e)this.#we(t);this.#Te(e)},r=()=>{for(const t of e)t.remove()};this.addCommands({cmd:t,undo:r,mustExec:!0})}catch(e){Xae(`paste: "${e.message}".`)}}keydown(e){this.isShiftKeyDown||"Shift"!==e.key||(this.isShiftKeyDown=!0),this.#oe===Iae.NONE||this.isEditorHandlingKeyboard||Gre._keyboardManager.exec(this,e)}keyup(e){this.isShiftKeyDown&&"Shift"===e.key&&(this.isShiftKeyDown=!1,this.#X&&(this.#X=!1,this.#Ve("main_toolbar")))}onEditingAction({name:e}){switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#He(e){Object.entries(e).some((([e,t])=>this.#he[e]!==t))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#he,e)}),this.#oe===Iae.HIGHLIGHT&&!1===e.hasSelectedEditor&&this.#Oe([[jae.HIGHLIGHT_FREE,!0]]))}#Oe(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})}setEditingState(e){e?(this.#Ce(),this.#Se(),this.#He({isEditing:this.#oe!==Iae.NONE,isEmpty:this.#Ae(),hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:this.#N.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Le(),this.#ke(),this.#He({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!this.#j){this.#j=e;for(const e of this.#j)this.#Oe(e.defaultPropertiesToUpdate)}}getId(){return this.#J.id}get currentLayer(){return this.#T.get(this.#P)}getLayer(e){return this.#T.get(e)}get currentPageIndex(){return this.#P}addLayer(e){this.#T.set(e.pageIndex,e),this.#Z?e.enable():e.disable()}removeLayer(e){this.#T.delete(e.pageIndex)}async updateMode(e,t=null,n=!1){if(this.#oe!==e&&(!this.#ve||(await this.#ve.promise,this.#ve))){if(this.#ve=Promise.withResolvers(),this.#oe=e,e===Iae.NONE)return this.setEditingState(!1),this.#Re(),this._editorUndoBar?.hide(),void this.#ve.resolve();this.setEditingState(!0),await this.#Ne(),this.unselectAll();for(const t of this.#T.values())t.updateMode(e);if(!t)return n&&this.addNewEditorFromKeyboard(),void this.#ve.resolve();for(const e of this.#w.values())e.annotationElementId===t?(this.setSelected(e),e.enterInEditMode()):e.unselect();this.#ve.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e!==this.#oe&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:e})}updateParams(e,t){if(this.#j){switch(e){case jae.CREATE:return void this.currentLayer.addNewEditor();case jae.HIGHLIGHT_DEFAULT_COLOR:this.#ae?.updateColor(t);break;case jae.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#se||=new Map).set(e,t),this.showAllEditors("highlight",t)}for(const n of this.#ce)n.updateParams(e,t);for(const n of this.#j)n.updateDefaultParams(e,t)}}showAllEditors(e,t,n=!1){for(const n of this.#w.values())n.editorType===e&&n.show(t);(this.#se?.get(jae.HIGHLIGHT_SHOW_ALL)??!0)!==t&&this.#Oe([[jae.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(this.#ee!==e){this.#ee=e;for(const t of this.#T.values())e?t.disableClick():t.enableClick(),t.div.classList.toggle("waiting",e)}}async#Ne(){if(!this.#Z){this.#Z=!0;const e=[];for(const t of this.#T.values())e.push(t.enable());await Promise.all(e);for(const e of this.#w.values())e.enable()}}#Re(){if(this.unselectAll(),this.#Z){this.#Z=!1;for(const e of this.#T.values())e.disable();for(const e of this.#w.values())e.disable()}}getEditors(e){const t=[];for(const n of this.#w.values())n.pageIndex===e&&t.push(n);return t}getEditor(e){return this.#w.get(e)}addEditor(e){this.#w.set(e.id,e)}removeEditor(e){e.div.contains(document.activeElement)&&(this.#G&&clearTimeout(this.#G),this.#G=setTimeout((()=>{this.focusMainContainer(),this.#G=null}),0)),this.#w.delete(e.id),this.unselect(e),e.annotationElementId&&this.#F.has(e.annotationElementId)||this.#A?.remove(e.id)}addDeletedAnnotationElement(e){this.#F.add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return this.#F.has(e)}removeDeletedAnnotationElement(e){this.#F.delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}#we(e){const t=this.#T.get(e.pageIndex);t?t.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))}setActiveEditor(e){this.#k!==e&&(this.#k=e,e&&this.#Oe(e.propertiesToUpdate))}get#_e(){let e=null;for(e of this.#ce);return e}updateUI(e){this.#_e===e&&this.#Oe(e.propertiesToUpdate)}updateUIForDefaultProperties(e){this.#Oe(e.defaultPropertiesToUpdate)}toggleSelected(e){if(this.#ce.has(e))return this.#ce.delete(e),e.unselect(),void this.#He({hasSelectedEditor:this.hasSelection});this.#ce.add(e),e.select(),this.#Oe(e.propertiesToUpdate),this.#He({hasSelectedEditor:!0})}setSelected(e){this.#D?.commitOrRemove();for(const t of this.#ce)t!==e&&t.unselect();this.#ce.clear(),this.#ce.add(e),e.select(),this.#Oe(e.propertiesToUpdate),this.#He({hasSelectedEditor:!0})}isSelected(e){return this.#ce.has(e)}get firstSelectedEditor(){return this.#ce.values().next().value}unselect(e){e.unselect(),this.#ce.delete(e),this.#He({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#ce.size}get isEnterHandled(){return 1===this.#ce.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#N.undo(),this.#He({hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Ae()}),this._editorUndoBar?.hide()}redo(){this.#N.redo(),this.#He({hasSomethingToUndo:!0,hasSomethingToRedo:this.#N.hasSomethingToRedo(),isEmpty:this.#Ae()})}addCommands(e){this.#N.add(e),this.#He({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Ae()})}cleanUndoStack(e){this.#N.cleanType(e)}#Ae(){if(0===this.#w.size)return!0;if(1===this.#w.size)for(const e of this.#w.values())return e.isEmpty();return!1}delete(){this.commitOrRemove();const e=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!e)return;const t=e?[e]:[...this.#ce],n=()=>{for(const e of t)this.#we(e)};this.addCommands({cmd:()=>{this._editorUndoBar?.show(n,1===t.length?t[0].editorType:t.length);for(const e of t)e.remove()},undo:n,mustExec:!0})}commitOrRemove(){this.#k?.commitOrRemove()}hasSomethingToControl(){return this.#k||this.hasSelection}#Te(e){for(const e of this.#ce)e.unselect();this.#ce.clear();for(const t of e)t.isEmpty()||(this.#ce.add(t),t.select());this.#He({hasSelectedEditor:this.hasSelection})}selectAll(){for(const e of this.#ce)e.commit();this.#Te(this.#w.values())}unselectAll(){if((!this.#k||(this.#k.commitOrRemove(),this.#oe===Iae.NONE))&&!this.#D?.commitOrRemove()&&this.hasSelection){for(const e of this.#ce)e.unselect();this.#ce.clear(),this.#He({hasSelectedEditor:!1})}}translateSelectedEditors(e,t,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;this.#de[0]+=e,this.#de[1]+=t;const[a,r]=this.#de,o=[...this.#ce];this.#ue&&clearTimeout(this.#ue),this.#ue=setTimeout((()=>{this.#ue=null,this.#de[0]=this.#de[1]=0,this.addCommands({cmd:()=>{for(const e of o)this.#w.has(e.id)&&e.translateInPage(a,r)},undo:()=>{for(const e of o)this.#w.has(e.id)&&e.translateInPage(-a,-r)},mustExec:!1})}),1e3);for(const n of o)n.translateInPage(e,t)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#I=new Map;for(const e of this.#ce)this.#I.set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#I)return!1;this.disableUserSelect(!1);const e=this.#I;this.#I=null;let t=!1;for(const[{x:n,y:a,pageIndex:r},o]of e)o.newX=n,o.newY=a,o.newPageIndex=r,t||=n!==o.savedX||a!==o.savedY||r!==o.savedPageIndex;if(!t)return!1;const n=(e,t,n,a)=>{if(this.#w.has(e.id)){const r=this.#T.get(a);r?e._setParentAndPosition(r,t,n):(e.pageIndex=a,e.x=t,e.y=n)}};return this.addCommands({cmd:()=>{for(const[t,{newX:a,newY:r,newPageIndex:o}]of e)n(t,a,r,o)},undo:()=>{for(const[t,{savedX:a,savedY:r,savedPageIndex:o}]of e)n(t,a,r,o)},mustExec:!0}),!0}dragSelectedEditors(e,t){if(this.#I)for(const n of this.#I.keys())n.drag(e,t)}rebuild(e){if(null===e.parent){const t=this.getLayer(e.pageIndex);t?(t.changeParent(e),t.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#ce.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return this.#k===e}getActive(){return this.#k}getMode(){return this.#oe}get imageManager(){return ere(this,"imageManager",new Ure)}getSelectionBoxes(e){if(!e)return null;const t=document.getSelection();for(let n=0,a=t.rangeCount;n<a;n++)if(!e.contains(t.getRangeAt(n).commonAncestorContainer))return null;const{x:n,y:a,width:r,height:o}=e.getBoundingClientRect();let c;switch(e.getAttribute("data-main-rotation")){case"90":c=(e,t,c,l)=>({x:(t-a)/o,y:1-(e+c-n)/r,width:l/o,height:c/r});break;case"180":c=(e,t,c,l)=>({x:1-(e+c-n)/r,y:1-(t+l-a)/o,width:c/r,height:l/o});break;case"270":c=(e,t,c,l)=>({x:1-(t+l-a)/o,y:(e-n)/r,width:l/o,height:c/r});break;default:c=(e,t,c,l)=>({x:(e-n)/r,y:(t-a)/o,width:c/r,height:l/o})}const l=[];for(let e=0,n=t.rangeCount;e<n;e++){const n=t.getRangeAt(e);if(!n.collapsed)for(const{x:e,y:t,width:a,height:r}of n.getClientRects())0!==a&&0!==r&&l.push(c(e,t,a,r))}return 0===l.length?null:l}addChangedExistingAnnotation({annotationElementId:e,id:t}){(this.#R||=new Map).set(e,t)}removeChangedExistingAnnotation({annotationElementId:e}){this.#R?.delete(e)}renderAnnotationElement(e){const t=this.#R?.get(e.data.id);if(!t)return;const n=this.#A.getRawValue(t);n&&(this.#oe!==Iae.NONE||n.hasBeenModified)&&n.renderAnnotationElement(e)}}class Yre{#l=null;#De=!1;#Pe=null;#Fe=null;#Ie=null;#je=null;#Be=!1;#Ue=null;#o=null;#We=null;#$e=null;#qe=!1;static#Ge=null;static _l10n=null;constructor(e){this.#o=e,this.#qe=e._uiManager.useNewAltTextFlow,Yre.#Ge||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(e){Yre._l10n??=e}async render(){const e=this.#Pe=document.createElement("button");e.className="altText",e.tabIndex="0";const t=this.#Fe=document.createElement("span");e.append(t),this.#qe?(e.classList.add("new"),e.setAttribute("data-l10n-id",Yre.#Ge.missing),t.setAttribute("data-l10n-id",Yre.#Ge["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const n=this.#o._uiManager._signal;e.addEventListener("contextmenu",wre,{signal:n}),e.addEventListener("pointerdown",(e=>e.stopPropagation()),{signal:n});const a=e=>{e.preventDefault(),this.#o._uiManager.editAltText(this.#o),this.#qe&&this.#o._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#Ye}})};return e.addEventListener("click",a,{capture:!0,signal:n}),e.addEventListener("keydown",(t=>{t.target===e&&"Enter"===t.key&&(this.#Be=!0,a(t))}),{signal:n}),await this.#Ke(),e}get#Ye(){return(this.#l?"added":null===this.#l&&this.guessedText&&"review")||"missing"}finish(){this.#Pe&&(this.#Pe.focus({focusVisible:this.#Be}),this.#Be=!1)}isEmpty(){return this.#qe?null===this.#l:!this.#l&&!this.#De}hasData(){return this.#qe?null!==this.#l||!!this.#We:this.isEmpty()}get guessedText(){return this.#We}async setGuessedText(e){null===this.#l&&(this.#We=e,this.#$e=await Yre._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e}),this.#Ke())}toggleAltTextBadge(e=!1){if(!this.#qe||this.#l)return this.#Ue?.remove(),void(this.#Ue=null);if(!this.#Ue){const e=this.#Ue=document.createElement("div");e.className="noAltTextBadge",this.#o.div.append(e)}this.#Ue.classList.toggle("hidden",!e)}serialize(e){let t=this.#l;return e||this.#We!==t||(t=this.#$e),{altText:t,decorative:this.#De,guessedText:this.#We,textWithDisclaimer:this.#$e}}get data(){return{altText:this.#l,decorative:this.#De}}set data({altText:e,decorative:t,guessedText:n,textWithDisclaimer:a,cancel:r=!1}){n&&(this.#We=n,this.#$e=a),this.#l===e&&this.#De===t||(r||(this.#l=e,this.#De=t),this.#Ke())}toggle(e=!1){this.#Pe&&(!e&&this.#je&&(clearTimeout(this.#je),this.#je=null),this.#Pe.disabled=!e)}shown(){this.#o._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#Ye}})}destroy(){this.#Pe?.remove(),this.#Pe=null,this.#Fe=null,this.#Ie=null,this.#Ue?.remove(),this.#Ue=null}async#Ke(){const e=this.#Pe;if(!e)return;if(this.#qe){if(e.classList.toggle("done",!!this.#l),e.setAttribute("data-l10n-id",Yre.#Ge[this.#Ye]),this.#Fe?.setAttribute("data-l10n-id",Yre.#Ge[`${this.#Ye}-label`]),!this.#l)return void this.#Ie?.remove()}else{if(!this.#l&&!this.#De)return e.classList.remove("done"),void this.#Ie?.remove();e.classList.add("done"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let t=this.#Ie;if(!t){this.#Ie=t=document.createElement("span"),t.className="tooltip",t.setAttribute("role","tooltip"),t.id=`alt-text-tooltip-${this.#o.id}`;const n=100,a=this.#o._uiManager._signal;a.addEventListener("abort",(()=>{clearTimeout(this.#je),this.#je=null}),{once:!0}),e.addEventListener("mouseenter",(()=>{this.#je=setTimeout((()=>{this.#je=null,this.#Ie.classList.add("show"),this.#o._reportTelemetry({action:"alt_text_tooltip"})}),n)}),{signal:a}),e.addEventListener("mouseleave",(()=>{this.#je&&(clearTimeout(this.#je),this.#je=null),this.#Ie?.classList.remove("show")}),{signal:a})}this.#De?t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(t.removeAttribute("data-l10n-id"),t.textContent=this.#l),t.parentNode||e.append(t);const n=this.#o.getImageForAltText();n?.setAttribute("aria-describedby",t.id)}}class Kre{#me;#Xe=!1;#Qe=null;#Je;#Ze;#et;#tt;#nt;#at=null;#rt;#ot=null;constructor({container:e,isPinchingDisabled:t=null,isPinchingStopped:n=null,onPinchStart:a=null,onPinching:r=null,onPinchEnd:o=null,signal:c}){this.#me=e,this.#Qe=n,this.#Je=t,this.#Ze=a,this.#et=r,this.#tt=o,this.#rt=new AbortController,this.#nt=AbortSignal.any([c,this.#rt.signal]),e.addEventListener("touchstart",this.#ct.bind(this),{passive:!1,signal:this.#nt})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return ere(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#ct(e){if(this.#Je?.()||e.touches.length<2)return;if(!this.#ot){this.#ot=new AbortController;const e=AbortSignal.any([this.#nt,this.#ot.signal]),t=this.#me,n={signal:e,passive:!1};t.addEventListener("touchmove",this.#lt.bind(this),n),t.addEventListener("touchend",this.#it.bind(this),n),t.addEventListener("touchcancel",this.#it.bind(this),n),this.#Ze?.()}if(Tre(e),2!==e.touches.length||this.#Qe?.())return void(this.#at=null);let[t,n]=e.touches;t.identifier>n.identifier&&([t,n]=[n,t]),this.#at={touch0X:t.screenX,touch0Y:t.screenY,touch1X:n.screenX,touch1Y:n.screenY}}#lt(e){if(!this.#at||2!==e.touches.length)return;let[t,n]=e.touches;t.identifier>n.identifier&&([t,n]=[n,t]);const{screenX:a,screenY:r}=t,{screenX:o,screenY:c}=n,l=this.#at,{touch0X:i,touch0Y:s,touch1X:h,touch1Y:d}=l,u=h-i,m=d-s,p=o-a,v=c-r,f=Math.hypot(p,v)||1,z=Math.hypot(u,m)||1;if(!this.#Xe&&Math.abs(z-f)<=Kre.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=a,l.touch0Y=r,l.touch1X=o,l.touch1Y=c,e.preventDefault(),!this.#Xe)return void(this.#Xe=!0);const g=[(a+o)/2,(r+c)/2];this.#et?.(g,z,f)}#it(e){this.#ot.abort(),this.#ot=null,this.#tt?.(),this.#at&&(e.preventDefault(),this.#at=null,this.#Xe=!1)}destroy(){this.#rt?.abort(),this.#rt=null}}class Xre{#st=null;#ht=null;#l=null;#dt=!1;#ut=null;#mt="";#pt=!1;#vt=null;#ft=null;#zt=null;#gt=null;#yt="";#Mt=!1;#Et=null;#bt=!1;#Ht=!1;#Vt=!1;#Ct=null;#Lt=0;#xt=0;#St=null;#kt=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#wt=!1;#Tt=Xre._zIndex++;static _borderLineWidth=-1;static _colorManager=new qre;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const e=Xre.prototype._resizeWithKeyboard,t=Gre.TRANSLATE_SMALL,n=Gre.TRANSLATE_BIG;return ere(this,"_resizerKeyboardManager",new $re([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-t,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-n,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[t,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[n,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-t]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-n]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,t]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,n]}],[["Escape","mac+Escape"],Xre.prototype._stopResizingWithKeyboard]]))}constructor(e){this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null;const{rotation:t,rawDims:{pageWidth:n,pageHeight:a,pageX:r,pageY:o}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,a],this.pageTranslation=[r,o];const[c,l]=this.parentDimensions;this.x=e.x/c,this.y=e.y/l,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return ere(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){const t=new Qre({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}static initialize(e,t){if(Xre._l10n??=e,Xre._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),-1!==Xre._borderLineWidth)return;const n=getComputedStyle(document.documentElement);Xre._borderLineWidth=parseFloat(n.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){Qae("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#wt}set _isDraggable(e){this.#wt=e,this.div?.classList.toggle("draggable",e)}get isEnterHandled(){return!0}center(){const[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(2*e),this.y+=this.width*e/(2*t);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*t/(2*e),this.y-=this.width*e/(2*t);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#Tt}setParent(e){null!==e?(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions):this.#Ot(),this.parent=e}focusin(e){this._focusEventsAllowed&&(this.#Mt?this.#Mt=!1:this.parent.setSelected(this))}focusout(e){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const t=e.relatedTarget;t?.closest(`#${this.id}`)||(e.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,n,a){const[r,o]=this.parentDimensions;[n,a]=this.screenToPageTranslation(n,a),this.x=(e+n)/r,this.y=(t+a)/o,this.fixAndSetPosition()}#At([e,t],n,a){[n,a]=this.screenToPageTranslation(n,a),this.x+=n/e,this.y+=a/t,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(e,t){this.#At(this.parentDimensions,e,t)}translateInPage(e,t){this.#Et||=[this.x,this.y,this.width,this.height],this.#At(this.pageDimensions,e,t),this.div.scrollIntoView({block:"nearest"})}drag(e,t){this.#Et||=[this.x,this.y,this.width,this.height];const{div:n,parentDimensions:[a,r]}=this;if(this.x+=e/a,this.y+=t/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:e,y:t}=this.div.getBoundingClientRect();this.parent.findNewParent(this,e,t)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:o,y:c}=this;const[l,i]=this.getBaseTranslation();o+=l,c+=i;const{style:s}=n;s.left=`${(100*o).toFixed(2)}%`,s.top=`${(100*c).toFixed(2)}%`,this._onTranslating(o,c),n.scrollIntoView({block:"nearest"})}_onTranslating(e,t){}_onTranslated(e,t){}get _hasBeenMoved(){return!!this.#Et&&(this.#Et[0]!==this.x||this.#Et[1]!==this.y)}get _hasBeenResized(){return!!this.#Et&&(this.#Et[2]!==this.width||this.#Et[3]!==this.height)}getBaseTranslation(){const[e,t]=this.parentDimensions,{_borderLineWidth:n}=Xre,a=n/e,r=n/t;switch(this.rotation){case 90:return[-a,r];case 180:return[a,r];case 270:return[a,-r];default:return[-a,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){const{div:{style:t},pageDimensions:[n,a]}=this;let{x:r,y:o,width:c,height:l}=this;if(c*=n,l*=a,r*=n,o*=a,this._mustFixPosition)switch(e){case 0:r=Math.max(0,Math.min(n-c,r)),o=Math.max(0,Math.min(a-l,o));break;case 90:r=Math.max(0,Math.min(n-l,r)),o=Math.min(a,Math.max(c,o));break;case 180:r=Math.min(n,Math.max(c,r)),o=Math.min(a,Math.max(l,o));break;case 270:r=Math.min(n,Math.max(l,r)),o=Math.max(0,Math.min(a-c,o))}this.x=r/=n,this.y=o/=a;const[i,s]=this.getBaseTranslation();r+=i,o+=s,t.left=`${(100*r).toFixed(2)}%`,t.top=`${(100*o).toFixed(2)}%`,this.moveInDOM()}static#Rt(e,t,n){switch(n){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}screenToPageTranslation(e,t){return Xre.#Rt(e,t,this.parentRotation)}pageTranslationToScreen(e,t){return Xre.#Rt(e,t,360-this.parentRotation)}#Nt(e){switch(e){case 90:{const[e,t]=this.pageDimensions;return[0,-e/t,t/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,t]=this.pageDimensions;return[0,e/t,-t/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:e,pageDimensions:[t,n]}=this;return[t*e,n*e]}setDims(e,t){const[n,a]=this.parentDimensions,{style:r}=this.div;r.width=`${(100*e/n).toFixed(2)}%`,this.#pt||(r.height=`${(100*t/a).toFixed(2)}%`)}fixDims(){const{style:e}=this.div,{height:t,width:n}=e,a=n.endsWith("%"),r=!this.#pt&&t.endsWith("%");if(a&&r)return;const[o,c]=this.parentDimensions;a||(e.width=`${(100*parseFloat(n)/o).toFixed(2)}%`),this.#pt||r||(e.height=`${(100*parseFloat(t)/c).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#_t(){if(this.#vt)return;this.#vt=document.createElement("div"),this.#vt.classList.add("resizers");const e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],t=this._uiManager._signal;for(const n of e){const e=document.createElement("div");this.#vt.append(e),e.classList.add("resizer",n),e.setAttribute("data-resizer-name",n),e.addEventListener("pointerdown",this.#Dt.bind(this,n),{signal:t}),e.addEventListener("contextmenu",wre,{signal:t}),e.tabIndex=-1}this.div.prepend(this.#vt)}#Dt(e,t){t.preventDefault();const{isMac:n}=ure.platform;if(0!==t.button||t.ctrlKey&&n)return;this.#l?.toggle(!1);const a=this._isDraggable;this._isDraggable=!1,this.#ft=[t.screenX,t.screenY];const r=new AbortController,o=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#Pt.bind(this,e),{passive:!0,capture:!0,signal:o}),window.addEventListener("touchmove",Tre,{passive:!1,signal:o}),window.addEventListener("contextmenu",wre,{signal:o}),this.#zt={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const c=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;const i=()=>{r.abort(),this.parent.togglePointerEvents(!0),this.#l?.toggle(!0),this._isDraggable=a,this.parent.div.style.cursor=c,this.div.style.cursor=l,this.#Ft()};window.addEventListener("pointerup",i,{signal:o}),window.addEventListener("blur",i,{signal:o})}#It(e,t,n,a){this.width=n,this.height=a,this.x=e,this.y=t;const[r,o]=this.parentDimensions;this.setDims(r*n,o*a),this.fixAndSetPosition(),this._onResized()}_onResized(){}#Ft(){if(!this.#zt)return;const{savedX:e,savedY:t,savedWidth:n,savedHeight:a}=this.#zt;this.#zt=null;const r=this.x,o=this.y,c=this.width,l=this.height;r===e&&o===t&&c===n&&l===a||this.addCommands({cmd:this.#It.bind(this,r,o,c,l),undo:this.#It.bind(this,e,t,n,a),mustExec:!0})}static _round(e){return Math.round(1e4*e)/1e4}#Pt(e,t){const[n,a]=this.parentDimensions,r=this.x,o=this.y,c=this.width,l=this.height,i=Xre.MIN_SIZE/n,s=Xre.MIN_SIZE/a,h=this.#Nt(this.rotation),d=(e,t)=>[h[0]*e+h[2]*t,h[1]*e+h[3]*t],u=this.#Nt(360-this.rotation);let m,p,v=!1,f=!1;switch(e){case"topLeft":v=!0,m=(e,t)=>[0,0],p=(e,t)=>[e,t];break;case"topMiddle":m=(e,t)=>[e/2,0],p=(e,t)=>[e/2,t];break;case"topRight":v=!0,m=(e,t)=>[e,0],p=(e,t)=>[0,t];break;case"middleRight":f=!0,m=(e,t)=>[e,t/2],p=(e,t)=>[0,t/2];break;case"bottomRight":v=!0,m=(e,t)=>[e,t],p=(e,t)=>[0,0];break;case"bottomMiddle":m=(e,t)=>[e/2,t],p=(e,t)=>[e/2,0];break;case"bottomLeft":v=!0,m=(e,t)=>[0,t],p=(e,t)=>[e,0];break;case"middleLeft":f=!0,m=(e,t)=>[0,t/2],p=(e,t)=>[e,t/2]}const z=m(c,l),g=p(c,l);let y=d(...g);const M=Xre._round(r+y[0]),E=Xre._round(o+y[1]);let b,H,V=1,C=1;if(t.fromKeyboard)({deltaX:b,deltaY:H}=t);else{const{screenX:e,screenY:n}=t,[a,r]=this.#ft;[b,H]=this.screenToPageTranslation(e-a,n-r),this.#ft[0]=e,this.#ft[1]=n}var L,x;if([b,H]=(L=b/n,x=H/a,[u[0]*L+u[2]*x,u[1]*L+u[3]*x]),v){const e=Math.hypot(c,l);V=C=Math.max(Math.min(Math.hypot(g[0]-z[0]-b,g[1]-z[1]-H)/e,1/c,1/l),i/c,s/l)}else f?V=Math.max(i,Math.min(1,Math.abs(g[0]-z[0]-b)))/c:C=Math.max(s,Math.min(1,Math.abs(g[1]-z[1]-H)))/l;const S=Xre._round(c*V),k=Xre._round(l*C);y=d(...p(S,k));const w=M-y[0],T=E-y[1];this.#Et||=[this.x,this.y,this.width,this.height],this.width=S,this.height=k,this.x=w,this.y=T,this.setDims(n*S,a*k),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#l?.finish()}async addEditToolbar(){return this._editToolbar||this.#Ht||(this._editToolbar=new Fre(this),this.div.append(this._editToolbar.render()),this.#l&&await this._editToolbar.addAltText(this.#l)),this._editToolbar}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#l?.destroy())}addContainer(e){const t=this._editToolbar?.div;t?t.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#l||(Yre.initialize(Xre._l10n),this.#l=new Yre(this),this.#st&&(this.#l.data=this.#st,this.#st=null),await this.addEditToolbar())}get altTextData(){return this.#l?.data}set altTextData(e){this.#l&&(this.#l.data=e)}get guessedAltText(){return this.#l?.guessedText}async setGuessedAltText(e){await(this.#l?.setGuessedText(e))}serializeAltText(e){return this.#l?.serialize(e)}hasAltText(){return!!this.#l&&!this.#l.isEmpty()}hasAltTextData(){return this.#l?.hasData()??!1}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#dt?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#jt();const[e,t]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*t/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/t).toFixed(2)}%`);const[n,a]=this.getInitialTranslation();return this.translate(n,a),jre(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#kt||=new Kre({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#Bt.bind(this),onPinching:this.#Ut.bind(this),onPinchEnd:this.#Wt.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#Bt(){this.#zt={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#l?.toggle(!1),this.parent.togglePointerEvents(!1)}#Ut(e,t,n){let a=n/t*.7+1-.7;if(1===a)return;const r=this.#Nt(this.rotation),o=(e,t)=>[r[0]*e+r[2]*t,r[1]*e+r[3]*t],[c,l]=this.parentDimensions,i=this.x,s=this.y,h=this.width,d=this.height,u=Xre.MIN_SIZE/c,m=Xre.MIN_SIZE/l;a=Math.max(Math.min(a,1/h,1/d),u/h,m/d);const p=Xre._round(h*a),v=Xre._round(d*a);if(p===h&&v===d)return;this.#Et||=[i,s,h,d];const f=o(h/2,d/2),z=Xre._round(i+f[0]),g=Xre._round(s+f[1]),y=o(p/2,v/2);this.x=z-y[0],this.y=g-y[1],this.width=p,this.height=v,this.setDims(c*p,l*v),this.fixAndSetPosition(),this._onResizing()}#Wt(){this.#l?.toggle(!0),this.parent.togglePointerEvents(!0),this.#Ft()}pointerdown(e){const{isMac:t}=ure.platform;0!==e.button||e.ctrlKey&&t?e.preventDefault():(this.#Mt=!0,this._isDraggable?this.#$t(e):this.#qt(e))}get isSelected(){return this._uiManager.isSelected(this)}#qt(e){const{isMac:t}=ure.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)}#$t(e){const{isSelected:t}=this;this._uiManager.setUpDragSession();let n=!1;const a=new AbortController,r=this._uiManager.combinedSignal(a),o={capture:!0,passive:!1,signal:r},c=e=>{a.abort(),this.#ut=null,this.#Mt=!1,this._uiManager.endDragSession()||this.#qt(e),n&&this._onStopDragging()};t&&(this.#Lt=e.clientX,this.#xt=e.clientY,this.#ut=e.pointerId,this.#mt=e.pointerType,window.addEventListener("pointermove",(e=>{n||(n=!0,this._onStartDragging());const{clientX:t,clientY:a,pointerId:r}=e;if(r!==this.#ut)return void Tre(e);const[o,c]=this.screenToPageTranslation(t-this.#Lt,a-this.#xt);this.#Lt=t,this.#xt=a,this._uiManager.dragSelectedEditors(o,c)}),o),window.addEventListener("touchmove",Tre,o),window.addEventListener("pointerdown",(e=>{e.pointerType===this.#mt&&(this.#kt||e.isPrimary)&&c(e),Tre(e)}),o));const l=e=>{this.#ut&&this.#ut!==e.pointerId?Tre(e):c(e)};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#Ct&&clearTimeout(this.#Ct),this.#Ct=setTimeout((()=>{this.#Ct=null,this.parent?.moveEditorInDOM(this)}),0)}_setParentAndPosition(e,t,n){e.changeParent(this),this.x=t,this.y=n,this.fixAndSetPosition(),this._onTranslated()}getRect(e,t,n=this.rotation){const a=this.parentScale,[r,o]=this.pageDimensions,[c,l]=this.pageTranslation,i=e/a,s=t/a,h=this.x*r,d=this.y*o,u=this.width*r,m=this.height*o;switch(n){case 0:return[h+i+c,o-d-s-m+l,h+i+u+c,o-d-s+l];case 90:return[h+s+c,o-d+i+l,h+s+m+c,o-d+i+u+l];case 180:return[h-i-u+c,o-d+s+l,h-i+c,o-d+s+m+l];case 270:return[h-s-m+c,o-d-i-u+l,h-s+c,o-d-i+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,t){const[n,a,r,o]=e,c=r-n,l=o-a;switch(this.rotation){case 0:return[n,t-o,c,l];case 90:return[n,t-a,l,c];case 180:return[r,t-a,c,l];case 270:return[r,t-o,l,c];default:throw new Error("Invalid rotation")}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){this.#Ht=!0}disableEditMode(){this.#Ht=!1}isInEditMode(){return this.#Ht}shouldGetKeyboardEvents(){return this.#Vt}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:e,left:t,bottom:n,right:a}=this.getClientDimensions(),{innerHeight:r,innerWidth:o}=window;return t<o&&a>0&&e<r&&n>0}#jt(){if(this.#gt||!this.div)return;this.#gt=new AbortController;const e=this._uiManager.combinedSignal(this.#gt);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:e}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:e})}rebuild(){this.#jt()}rotate(e){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(e=!1,t=null){Qae("An editor must be serializable")}static async deserialize(e,t,n){const a=new this.prototype.constructor({parent:t,id:t.getNextId(),uiManager:n});a.rotation=e.rotation,a.#st=e.accessibilityData;const[r,o]=a.pageDimensions,[c,l,i,s]=a.getRectInCurrentCoords(e.rect,o);return a.x=c/r,a.y=l/o,a.width=i/r,a.height=s/o,a}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#gt?.abort(),this.#gt=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#Ct&&(clearTimeout(this.#Ct),this.#Ct=null),this.#Ot(),this.removeEditToolbar(),this.#St){for(const e of this.#St.values())clearTimeout(e);this.#St=null}this.parent=null,this.#kt?.destroy(),this.#kt=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#_t(),this.#vt.classList.remove("hidden"),jre(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(e){if(!this.isResizable||e.target!==this.div||"Enter"!==e.key)return;this._uiManager.setSelected(this),this.#zt={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const t=this.#vt.children;if(!this.#ht){this.#ht=Array.from(t);const e=this.#Gt.bind(this),n=this.#Yt.bind(this),a=this._uiManager._signal;for(const t of this.#ht){const r=t.getAttribute("data-resizer-name");t.setAttribute("role","spinbutton"),t.addEventListener("keydown",e,{signal:a}),t.addEventListener("blur",n,{signal:a}),t.addEventListener("focus",this.#Kt.bind(this,r),{signal:a}),t.setAttribute("data-l10n-id",Xre._l10nResizer[r])}}const n=this.#ht[0];let a=0;for(const e of t){if(e===n)break;a++}const r=(360-this.rotation+this.parentRotation)%360/90*(this.#ht.length/4);if(r!==a){if(r<a)for(let e=0;e<a-r;e++)this.#vt.append(this.#vt.firstChild);else if(r>a)for(let e=0;e<r-a;e++)this.#vt.firstChild.before(this.#vt.lastChild);let e=0;for(const n of t){const t=this.#ht[e++].getAttribute("data-resizer-name");n.setAttribute("data-l10n-id",Xre._l10nResizer[t])}}this.#Xt(0),this.#Vt=!0,this.#vt.firstChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}#Gt(e){Xre._resizerKeyboardManager.exec(this,e)}#Yt(e){this.#Vt&&e.relatedTarget?.parentNode!==this.#vt&&this.#Ot()}#Kt(e){this.#yt=this.#Vt?e:""}#Xt(e){if(this.#ht)for(const t of this.#ht)t.tabIndex=e}_resizeWithKeyboard(e,t){this.#Vt&&this.#Pt(this.#yt,{deltaX:e,deltaY:t,fromKeyboard:!0})}#Ot(){this.#Vt=!1,this.#Xt(-1),this.#Ft()}_stopResizingWithKeyboard(){this.#Ot(),this.div.focus()}select(){this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar?(this._editToolbar?.show(),this.#l?.toggleAltTextBadge(!1)):this.addEditToolbar().then((()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()}))}unselect(){this.#vt?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#l?.toggleAltTextBadge(!0)}updateParams(e,t){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#bt}set isEditing(e){this.#bt=e,this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(e,t){this.#pt=!0;const n=e/t,{style:a}=this.div;a.aspectRatio=n,a.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,t=!1){if(t){this.#St||=new Map;const{action:t}=e;let n=this.#St.get(t);return n&&clearTimeout(n),n=setTimeout((()=>{this._reportTelemetry(e),this.#St.delete(t),0===this.#St.size&&(this.#St=null)}),Xre._telemetryTimeout),void this.#St.set(t,n)}e.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(e=this._isVisible){this.div.classList.toggle("hidden",!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),this.#dt=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#dt=!0}renderAnnotationElement(e){let t=e.container.querySelector(".annotationContent");if(t){if("CANVAS"===t.nodeName){const e=t;t=document.createElement("div"),t.classList.add("annotationContent",this.editorType),e.before(t)}}else t=document.createElement("div"),t.classList.add("annotationContent",this.editorType),e.container.prepend(t);return t}resetAnnotationElement(e){const{firstChild:t}=e.container;"DIV"===t?.nodeName&&t.classList.contains("annotationContent")&&t.remove()}}class Qre extends Xre{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Jre=3285377520,Zre=4294901760,eoe=65535;class toe{constructor(e){this.h1=e?4294967295&e:Jre,this.h2=e?4294967295&e:Jre}update(e){let t,n;if("string"==typeof e){t=new Uint8Array(2*e.length),n=0;for(let a=0,r=e.length;a<r;a++){const r=e.charCodeAt(a);r<=255?t[n++]=r:(t[n++]=r>>>8,t[n++]=255&r)}}else{if(!ArrayBuffer.isView(e))throw new Error("Invalid data format, must be a string or TypedArray.");t=e.slice(),n=t.byteLength}const a=n>>2,r=n-4*a,o=new Uint32Array(t.buffer,0,a);let c=0,l=0,i=this.h1,s=this.h2;const h=3432918353,d=461845907,u=11601,m=13715;for(let e=0;e<a;e++)1&e?(c=o[e],c=c*h&Zre|c*u&eoe,c=c<<15|c>>>17,c=c*d&Zre|c*m&eoe,i^=c,i=i<<13|i>>>19,i=5*i+3864292196):(l=o[e],l=l*h&Zre|l*u&eoe,l=l<<15|l>>>17,l=l*d&Zre|l*m&eoe,s^=l,s=s<<13|s>>>19,s=5*s+3864292196);switch(c=0,r){case 3:c^=t[4*a+2]<<16;case 2:c^=t[4*a+1]<<8;case 1:c^=t[4*a],c=c*h&Zre|c*u&eoe,c=c<<15|c>>>17,c=c*d&Zre|c*m&eoe,1&a?i^=c:s^=c}this.h1=i,this.h2=s}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=3981806797*e&Zre|36045*e&eoe,t=4283543511*t&Zre|(2950163797*(t<<16|e>>>16)&Zre)>>>16,e^=t>>>1,e=444984403*e&Zre|60499*e&eoe,t=3301882366*t&Zre|(3120437893*(t<<16|e>>>16)&Zre)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,"0")+(t>>>0).toString(16).padStart(8,"0")}}const noe=Object.freeze({map:null,hash:"",transfer:void 0});class aoe{#Qt=!1;#Jt=null;#Zt=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,t){const n=this.#Zt.get(e);return void 0===n?t:Object.assign(t,n)}getRawValue(e){return this.#Zt.get(e)}remove(e){if(this.#Zt.delete(e),0===this.#Zt.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const e of this.#Zt.values())if(e instanceof Xre)return;this.onAnnotationEditor(null)}}setValue(e,t){const n=this.#Zt.get(e);let a=!1;if(void 0!==n)for(const[e,r]of Object.entries(t))n[e]!==r&&(a=!0,n[e]=r);else a=!0,this.#Zt.set(e,t);a&&this.#en(),t instanceof Xre&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(t.constructor._type)}has(e){return this.#Zt.has(e)}getAll(){return this.#Zt.size>0?dre(this.#Zt):null}setAll(e){for(const[t,n]of Object.entries(e))this.setValue(t,n)}get size(){return this.#Zt.size}#en(){this.#Qt||(this.#Qt=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#Qt&&(this.#Qt=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new roe(this)}get serializable(){if(0===this.#Zt.size)return noe;const e=new Map,t=new toe,n=[],a=Object.create(null);let r=!1;for(const[n,o]of this.#Zt){const c=o instanceof Xre?o.serialize(!1,a):o;c&&(e.set(n,c),t.update(`${n}:${JSON.stringify(c)}`),r||=!!c.bitmap)}if(r)for(const t of e.values())t.bitmap&&n.push(t.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:n}:noe}get editorStats(){let e=null;const t=new Map;for(const n of this.#Zt.values()){if(!(n instanceof Xre))continue;const a=n.telemetryFinalData;if(!a)continue;const{type:r}=a;t.has(r)||t.set(r,Object.getPrototypeOf(n).constructor),e||=Object.create(null);const o=e[r]||=new Map;for(const[e,t]of Object.entries(a)){if("type"===e)continue;let n=o.get(e);n||(n=new Map,o.set(e,n));const a=n.get(t)??0;n.set(t,a+1)}}for(const[n,a]of t)e[n]=a.computeTelemetryFinalData(e[n]);return e}resetModifiedIds(){this.#Jt=null}get modifiedIds(){if(this.#Jt)return this.#Jt;const e=[];for(const t of this.#Zt.values())t instanceof Xre&&t.annotationElementId&&t.serialize()&&e.push(t.annotationElementId);return this.#Jt={ids:new Set(e),hash:e.join(",")}}}class roe extends aoe{#tn;constructor(e){super();const{map:t,hash:n,transfer:a}=e.serializable,r=structuredClone(t,a?{transfer:a}:null);this.#tn={map:r,hash:n,transfer:a}}get print(){Qae("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#tn}get modifiedIds(){return ere(this,"modifiedIds",{ids:new Set,hash:""})}}class ooe{#nn=new Set;constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const t=this.styleElement.sheet;t.insertRule(e,t.cssRules.length)}clear(){for(const e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),this.#nn.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:e,_inspectFont:t}){if(e&&!this.#nn.has(e.loadedName))if(Jae(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:n,src:a,style:r}=e,o=new FontFace(n,a,r);this.addNativeFontFace(o);try{await o.load(),this.#nn.add(n),t?.(e)}catch{Xae(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}}else Qae("Not implemented: loadSystemFont without the Font Loading API.")}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo)return void await this.loadSystemFont(e);if(this.isFontLoadingAPISupported){const t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{await t.loaded}catch(n){throw Xae(`Failed to load font '${t.family}': '${n}'.`),e.disableFontFace=!0,n}}return}const t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;await new Promise((t=>{const n=this._queueLoadingCallback(t);this._prepareFontLoadEvent(e,n)}))}}get isFontLoadingAPISupported(){return ere(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){let e=!1;return(Nae||"undefined"!=typeof navigator&&"string"==typeof navigator?.userAgent&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(e=!0),ere(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(e){const{loadingRequests:t}=this,n={done:!1,complete:function(){for(Jae(!n.done,"completeRequest() cannot be called twice."),n.done=!0;t.length>0&&t[0].done;){const e=t.shift();setTimeout(e.callback,0)}},callback:e};return t.push(n),n}get _loadTestFont(){return ere(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(e,t){function n(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|255&e.charCodeAt(t+3)}function a(e,t,n,a){return e.substring(0,t)+a+e.substring(t+n)}let r,o;const c=this._document.createElement("canvas");c.width=1,c.height=1;const l=c.getContext("2d");let i=0;const s=`lt${Date.now()}${this.loadTestFontId++}`;let h=this._loadTestFont;h=a(h,976,s.length,s);const d=1482184792;let u=n(h,16);for(r=0,o=s.length-3;r<o;r+=4)u=u-d+n(s,r)|0;r<s.length&&(u=u-d+n(s+"XXX",r)|0),h=a(h,16,4,function(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)}(u));const m=`@font-face {font-family:"${s}";src:url(data:font/opentype;base64,${btoa(h)});}`;this.insertRule(m);const p=this._document.createElement("div");p.style.visibility="hidden",p.style.width=p.style.height="10px",p.style.position="absolute",p.style.top=p.style.left="0px";for(const t of[e.loadedName,s]){const e=this._document.createElement("span");e.textContent="Hi",e.style.fontFamily=t,p.append(e)}this._document.body.append(p),function e(t,n){if(++i>30)return Xae("Load test font never loaded."),void n();l.font="30px "+t,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0?n():setTimeout(e.bind(null,t,n))}(s,(()=>{p.remove(),t.complete()}))}}class coe{constructor(e,{disableFontFace:t=!1,fontExtraProperties:n=!1,inspectFont:a=null}){this.compiledGlyphs=Object.create(null);for(const t in e)this[t]=e[t];this.disableFontFace=!0===t,this.fontExtraProperties=!0===n,this._inspectFont=a}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let e;if(this.cssFontInfo){const t={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(t.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,t)}else e=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),e}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${t=this.data,Uint8Array.prototype.toBase64?t.toBase64():btoa(sre(t))});`;var t;let n;if(this.cssFontInfo){let t=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(t+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),n=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${t}src:${e}}`}else n=`@font-face {font-family:"${this.loadedName}";src:${e}}`;return this._inspectFont?.(this,e),n}getPathGenerator(e,t){if(void 0!==this.compiledGlyphs[t])return this.compiledGlyphs[t];const n=this.loadedName+"_path_"+t;let a;try{a=e.get(n)}catch(e){Xae(`getPathGenerator - ignoring character: "${e}".`)}const r=new Path2D(a||"");return this.fontExtraProperties||e.delete(n),this.compiledGlyphs[t]=r}}function loe(){}function ioe(e){if(e instanceof ire||e instanceof rre||e instanceof ore||e instanceof nre||e instanceof cre||e instanceof are)return e;switch(e instanceof Error||"object"==typeof e&&null!==e||Qae('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),e.name){case"AbortException":return new ire(e.message);case"InvalidPDFException":return new rre(e.message);case"MissingPDFException":return new ore(e.message);case"PasswordException":return new nre(e.message,e.code);case"UnexpectedResponseException":return new cre(e.message,e.status);case"UnknownErrorException":return new are(e.message,e.details)}return new are(e.message,e.toString())}class soe{#an=new AbortController;constructor(e,t,n){this.sourceName=e,this.targetName=t,this.comObj=n,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),n.addEventListener("message",this.#rn.bind(this),{signal:this.#an.signal})}#rn({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream)return void this.#on(e);if(e.callback){const t=e.callbackId,n=this.callbackCapabilities[t];if(!n)throw new Error(`Cannot resolve callback ${t}`);if(delete this.callbackCapabilities[t],1===e.callback)n.resolve(e.data);else{if(2!==e.callback)throw new Error("Unexpected callback case");n.reject(ioe(e.reason))}return}const t=this.actionHandler[e.action];if(!t)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const n=this.sourceName,a=e.sourceName,r=this.comObj;Promise.try(t,e.data).then((function(t){r.postMessage({sourceName:n,targetName:a,callback:1,callbackId:e.callbackId,data:t})}),(function(t){r.postMessage({sourceName:n,targetName:a,callback:2,callbackId:e.callbackId,reason:ioe(t)})}))}else e.streamId?this.#cn(e):t(e.data)}on(e,t){const n=this.actionHandler;if(n[e])throw new Error(`There is already an actionName called "${e}"`);n[e]=t}send(e,t,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},n)}sendWithPromise(e,t,n){const a=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[a]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:a,data:t},n)}catch(e){r.reject(e)}return r.promise}sendWithStream(e,t,n,a){const r=this.streamId++,o=this.sourceName,c=this.targetName,l=this.comObj;return new ReadableStream({start:n=>{const i=Promise.withResolvers();return this.streamControllers[r]={controller:n,startCall:i,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:o,targetName:c,action:e,streamId:r,data:t,desiredSize:n.desiredSize},a),i.promise},pull:e=>{const t=Promise.withResolvers();return this.streamControllers[r].pullCall=t,l.postMessage({sourceName:o,targetName:c,stream:6,streamId:r,desiredSize:e.desiredSize}),t.promise},cancel:e=>{Jae(e instanceof Error,"cancel must have a valid reason");const t=Promise.withResolvers();return this.streamControllers[r].cancelCall=t,this.streamControllers[r].isClosed=!0,l.postMessage({sourceName:o,targetName:c,stream:1,streamId:r,reason:ioe(e)}),t.promise}},n)}#cn(e){const t=e.streamId,n=this.sourceName,a=e.sourceName,r=this.comObj,o=this,c=this.actionHandler[e.action],l={enqueue(e,o=1,c){if(this.isCancelled)return;const l=this.desiredSize;this.desiredSize-=o,l>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:n,targetName:a,stream:4,streamId:t,chunk:e},c)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:n,targetName:a,stream:3,streamId:t}),delete o.streamSinks[t])},error(e){Jae(e instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:n,targetName:a,stream:5,streamId:t,reason:ioe(e)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[t]=l,Promise.try(c,e.data,l).then((function(){r.postMessage({sourceName:n,targetName:a,stream:8,streamId:t,success:!0})}),(function(e){r.postMessage({sourceName:n,targetName:a,stream:8,streamId:t,reason:ioe(e)})}))}#on(e){const t=e.streamId,n=this.sourceName,a=e.sourceName,r=this.comObj,o=this.streamControllers[t],c=this.streamSinks[t];switch(e.stream){case 8:e.success?o.startCall.resolve():o.startCall.reject(ioe(e.reason));break;case 7:e.success?o.pullCall.resolve():o.pullCall.reject(ioe(e.reason));break;case 6:if(!c){r.postMessage({sourceName:n,targetName:a,stream:7,streamId:t,success:!0});break}c.desiredSize<=0&&e.desiredSize>0&&c.sinkCapability.resolve(),c.desiredSize=e.desiredSize,Promise.try(c.onPull||loe).then((function(){r.postMessage({sourceName:n,targetName:a,stream:7,streamId:t,success:!0})}),(function(e){r.postMessage({sourceName:n,targetName:a,stream:7,streamId:t,reason:ioe(e)})}));break;case 4:if(Jae(o,"enqueue should have stream controller"),o.isClosed)break;o.controller.enqueue(e.chunk);break;case 3:if(Jae(o,"close should have stream controller"),o.isClosed)break;o.isClosed=!0,o.controller.close(),this.#ln(o,t);break;case 5:Jae(o,"error should have stream controller"),o.controller.error(ioe(e.reason)),this.#ln(o,t);break;case 2:e.success?o.cancelCall.resolve():o.cancelCall.reject(ioe(e.reason)),this.#ln(o,t);break;case 1:if(!c)break;const l=ioe(e.reason);Promise.try(c.onCancel||loe,l).then((function(){r.postMessage({sourceName:n,targetName:a,stream:2,streamId:t,success:!0})}),(function(e){r.postMessage({sourceName:n,targetName:a,stream:2,streamId:t,reason:ioe(e)})})),c.sinkCapability.reject(l),c.isCancelled=!0,delete this.streamSinks[t];break;default:throw new Error("Unexpected stream case")}}async#ln(e,t){await Promise.allSettled([e.startCall?.promise,e.pullCall?.promise,e.cancelCall?.promise]),delete this.streamControllers[t]}destroy(){this.#an?.abort(),this.#an=null}}class hoe{#in=!1;constructor({enableHWA:e=!1}){this.#in=e}create(e,t){if(e<=0||t<=0)throw new Error("Invalid canvas size");const n=this._createCanvas(e,t);return{canvas:n,context:n.getContext("2d",{willReadFrequently:!this.#in})}}reset(e,t,n){if(!e.canvas)throw new Error("Canvas is not specified");if(t<=0||n<=0)throw new Error("Invalid canvas size");e.canvas.width=t,e.canvas.height=n}destroy(e){if(!e.canvas)throw new Error("Canvas is not specified");e.canvas.width=0,e.canvas.height=0,e.canvas=null,e.context=null}_createCanvas(e,t){Qae("Abstract method `_createCanvas` called.")}}class doe{constructor({baseUrl:e=null,isCompressed:t=!0}){this.baseUrl=e,this.isCompressed=t}async fetch({name:e}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!e)throw new Error("CMap name must be specified.");const t=this.baseUrl+e+(this.isCompressed?".bcmap":"");return this._fetch(t).then((e=>({cMapData:e,isCompressed:this.isCompressed}))).catch((e=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${t}`)}))}async _fetch(e){Qae("Abstract method `_fetch` called.")}}class uoe extends doe{async _fetch(e){const t=await Ere(e,this.isCompressed?"arraybuffer":"text");return t instanceof ArrayBuffer?new Uint8Array(t):hre(t)}}class moe{addFilter(e){return"none"}addHCMFilter(e,t){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addHighlightHCMFilter(e,t,n,a,r){return"none"}destroy(e=!1){}}class poe{constructor({baseUrl:e=null}){this.baseUrl=e}async fetch({filename:e}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!e)throw new Error("Font filename must be specified.");const t=`${this.baseUrl}${e}`;return this._fetch(t).catch((e=>{throw new Error(`Unable to load font data at: ${t}`)}))}async _fetch(e){Qae("Abstract method `_fetch` called.")}}class voe extends poe{async _fetch(e){const t=await Ere(e,"arraybuffer");return new Uint8Array(t)}}async function foe(e){const t=yt.getBuiltinModule("fs"),n=await t.promises.readFile(e);return new Uint8Array(n)}Nae&&Xae("Please use the `legacy` build in Node.js environments.");const zoe="Fill",goe="Stroke",yoe="Shading";function Moe(e,t){if(!t)return;const n=t[2]-t[0],a=t[3]-t[1],r=new Path2D;r.rect(t[0],t[1],n,a),e.clip(r)}class Eoe{getPattern(){Qae("Abstract method `getPattern` called.")}}class boe extends Eoe{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}_createGradient(e){let t;"axial"===this._type?t=e.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(t=e.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const e of this._colorStops)t.addColorStop(e[0],e[1]);return t}getPattern(e,t,n,a){let r;if(a===goe||a===zoe){const o=t.current.getClippedPathBoundingBox(a,Nre(e))||[0,0,0,0],c=Math.ceil(o[2]-o[0])||1,l=Math.ceil(o[3]-o[1])||1,i=t.cachedCanvases.getCanvas("pattern",c,l),s=i.context;s.clearRect(0,0,s.canvas.width,s.canvas.height),s.beginPath(),s.rect(0,0,s.canvas.width,s.canvas.height),s.translate(-o[0],-o[1]),n=pre.transform(n,[1,0,0,1,o[0],o[1]]),s.transform(...t.baseTransform),this.matrix&&s.transform(...this.matrix),Moe(s,this._bbox),s.fillStyle=this._createGradient(s),s.fill(),r=e.createPattern(i.canvas,"no-repeat");const h=new DOMMatrix(n);r.setTransform(h)}else Moe(e,this._bbox),r=this._createGradient(e);return r}}function Hoe(e,t,n,a,r,o,c,l){const i=t.coords,s=t.colors,h=e.data,d=4*e.width;let u;i[n+1]>i[a+1]&&(u=n,n=a,a=u,u=o,o=c,c=u),i[a+1]>i[r+1]&&(u=a,a=r,r=u,u=c,c=l,l=u),i[n+1]>i[a+1]&&(u=n,n=a,a=u,u=o,o=c,c=u);const m=(i[n]+t.offsetX)*t.scaleX,p=(i[n+1]+t.offsetY)*t.scaleY,v=(i[a]+t.offsetX)*t.scaleX,f=(i[a+1]+t.offsetY)*t.scaleY,z=(i[r]+t.offsetX)*t.scaleX,g=(i[r+1]+t.offsetY)*t.scaleY;if(p>=g)return;const y=s[o],M=s[o+1],E=s[o+2],b=s[c],H=s[c+1],V=s[c+2],C=s[l],L=s[l+1],x=s[l+2],S=Math.round(p),k=Math.round(g);let w,T,O,A,R,N,_,D;for(let e=S;e<=k;e++){if(e<f){const t=e<p?0:(p-e)/(p-f);w=m-(m-v)*t,T=y-(y-b)*t,O=M-(M-H)*t,A=E-(E-V)*t}else{let t;t=e>g?1:f===g?0:(f-e)/(f-g),w=v-(v-z)*t,T=b-(b-C)*t,O=H-(H-L)*t,A=V-(V-x)*t}let t;t=e<p?0:e>g?1:(p-e)/(p-g),R=m-(m-z)*t,N=y-(y-C)*t,_=M-(M-L)*t,D=E-(E-x)*t;const n=Math.round(Math.min(w,R)),a=Math.round(Math.max(w,R));let r=d*e+4*n;for(let e=n;e<=a;e++)t=(w-e)/(w-R),t<0?t=0:t>1&&(t=1),h[r++]=T-(T-N)*t|0,h[r++]=O-(O-_)*t|0,h[r++]=A-(A-D)*t|0,h[r++]=255}}function Voe(e,t,n){const a=t.coords,r=t.colors;let o,c;switch(t.type){case"lattice":const l=t.verticesPerRow,i=Math.floor(a.length/l)-1,s=l-1;for(o=0;o<i;o++){let t=o*l;for(let o=0;o<s;o++,t++)Hoe(e,n,a[t],a[t+1],a[t+l],r[t],r[t+1],r[t+l]),Hoe(e,n,a[t+l+1],a[t+1],a[t+l],r[t+l+1],r[t+1],r[t+l])}break;case"triangles":for(o=0,c=a.length;o<c;o+=3)Hoe(e,n,a[o],a[o+1],a[o+2],r[o],r[o+1],r[o+2]);break;default:throw new Error("illegal figure")}}class Coe extends Eoe{constructor(e){super(),this._coords=e[2],this._colors=e[3],this._figures=e[4],this._bounds=e[5],this._bbox=e[7],this._background=e[8],this.matrix=null}_createMeshCanvas(e,t,n){const a=Math.floor(this._bounds[0]),r=Math.floor(this._bounds[1]),o=Math.ceil(this._bounds[2])-a,c=Math.ceil(this._bounds[3])-r,l=Math.min(Math.ceil(Math.abs(o*e[0]*1.1)),3e3),i=Math.min(Math.ceil(Math.abs(c*e[1]*1.1)),3e3),s=o/l,h=c/i,d={coords:this._coords,colors:this._colors,offsetX:-a,offsetY:-r,scaleX:1/s,scaleY:1/h},u=l+4,m=i+4,p=n.getCanvas("mesh",u,m),v=p.context,f=v.createImageData(l,i);if(t){const e=f.data;for(let n=0,a=e.length;n<a;n+=4)e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=255}for(const e of this._figures)Voe(f,e,d);return v.putImageData(f,2,2),{canvas:p.canvas,offsetX:a-2*s,offsetY:r-2*h,scaleX:s,scaleY:h}}getPattern(e,t,n,a){let r;if(Moe(e,this._bbox),a===yoe)r=pre.singularValueDecompose2dScale(Nre(e));else if(r=pre.singularValueDecompose2dScale(t.baseTransform),this.matrix){const e=pre.singularValueDecompose2dScale(this.matrix);r=[r[0]*e[0],r[1]*e[1]]}const o=this._createMeshCanvas(r,a===yoe?null:this._background,t.cachedCanvases);return a!==yoe&&(e.setTransform(...t.baseTransform),this.matrix&&e.transform(...this.matrix)),e.translate(o.offsetX,o.offsetY),e.scale(o.scaleX,o.scaleY),e.createPattern(o.canvas,"no-repeat")}}class Loe extends Eoe{getPattern(){return"hotpink"}}class xoe{static MAX_PATTERN_SIZE=3e3;constructor(e,t,n,a,r){this.operatorList=e[2],this.matrix=e[3],this.bbox=e[4],this.xstep=e[5],this.ystep=e[6],this.paintType=e[7],this.tilingType=e[8],this.color=t,this.ctx=n,this.canvasGraphicsFactory=a,this.baseTransform=r}createPatternCanvas(e){const{bbox:t,operatorList:n,paintType:a,tilingType:r,color:o,canvasGraphicsFactory:c}=this;let{xstep:l,ystep:i}=this;l=Math.abs(l),i=Math.abs(i),Kae("TilingType: "+r);const s=t[0],h=t[1],d=t[2],u=t[3],m=d-s,p=u-h,v=pre.singularValueDecompose2dScale(this.matrix),f=pre.singularValueDecompose2dScale(this.baseTransform),z=v[0]*f[0],g=v[1]*f[1];let y=m,M=p,E=!1,b=!1;const H=Math.ceil(l*z),V=Math.ceil(i*g);H>=Math.ceil(m*z)?y=l:E=!0,V>=Math.ceil(p*g)?M=i:b=!0;const C=this.getSizeAndScale(y,this.ctx.canvas.width,z),L=this.getSizeAndScale(M,this.ctx.canvas.height,g),x=e.cachedCanvases.getCanvas("pattern",C.size,L.size),S=x.context,k=c.createCanvasGraphics(S);if(k.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(k,a,o),S.translate(-C.scale*s,-L.scale*h),k.transform(C.scale,0,0,L.scale,0,0),S.save(),this.clipBbox(k,s,h,d,u),k.baseTransform=Nre(k.ctx),k.executeOperatorList(n),k.endDrawing(),S.restore(),E||b){const t=x.canvas;E&&(y=l),b&&(M=i);const n=this.getSizeAndScale(y,this.ctx.canvas.width,z),a=this.getSizeAndScale(M,this.ctx.canvas.height,g),r=n.size,o=a.size,c=e.cachedCanvases.getCanvas("pattern-workaround",r,o),d=c.context,u=E?Math.floor(m/l):0,v=b?Math.floor(p/i):0;for(let e=0;e<=u;e++)for(let n=0;n<=v;n++)d.drawImage(t,r*e,o*n,r,o,0,0,r,o);return{canvas:c.canvas,scaleX:n.scale,scaleY:a.scale,offsetX:s,offsetY:h}}return{canvas:x.canvas,scaleX:C.scale,scaleY:L.scale,offsetX:s,offsetY:h}}getSizeAndScale(e,t,n){const a=Math.max(xoe.MAX_PATTERN_SIZE,t);let r=Math.ceil(e*n);return r>=a?r=a:n=r/e,{scale:n,size:r}}clipBbox(e,t,n,a,r){const o=a-t,c=r-n;e.ctx.rect(t,n,o,c),e.current.updateRectMinMax(Nre(e.ctx),[t,n,a,r]),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,t,n){const a=e.ctx,r=e.current;switch(t){case 1:const e=this.ctx;a.fillStyle=e.fillStyle,a.strokeStyle=e.strokeStyle,r.fillColor=e.fillStyle,r.strokeColor=e.strokeStyle;break;case 2:const o=pre.makeHexColor(n[0],n[1],n[2]);a.fillStyle=o,a.strokeStyle=o,r.fillColor=o,r.strokeColor=o;break;default:throw new lre(`Unsupported paint type: ${t}`)}}getPattern(e,t,n,a){let r=n;a!==yoe&&(r=pre.transform(r,t.baseTransform),this.matrix&&(r=pre.transform(r,this.matrix)));const o=this.createPatternCanvas(t);let c=new DOMMatrix(r);c=c.translate(o.offsetX,o.offsetY),c=c.scale(1/o.scaleX,1/o.scaleY);const l=e.createPattern(o.canvas,"repeat");return l.setTransform(c),l}}function Soe({src:e,srcPos:t=0,dest:n,width:a,height:r,nonBlackColor:o=4294967295,inverseDecode:c=!1}){const l=ure.isLittleEndian?4278190080:255,[i,s]=c?[o,l]:[l,o],h=a>>3,d=7&a,u=e.length;n=new Uint32Array(n.buffer);let m=0;for(let a=0;a<r;a++){for(const a=t+h;t<a;t++){const a=t<u?e[t]:255;n[m++]=128&a?s:i,n[m++]=64&a?s:i,n[m++]=32&a?s:i,n[m++]=16&a?s:i,n[m++]=8&a?s:i,n[m++]=4&a?s:i,n[m++]=2&a?s:i,n[m++]=1&a?s:i}if(0===d)continue;const a=t<u?e[t++]:255;for(let e=0;e<d;e++)n[m++]=a&1<<7-e?s:i}return{srcPos:t,destPos:m}}const koe=16;class woe{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,t,n){let a;return void 0!==this.cache[e]?(a=this.cache[e],this.canvasFactory.reset(a,t,n)):(a=this.canvasFactory.create(t,n),this.cache[e]=a),a}delete(e){delete this.cache[e]}clear(){for(const e in this.cache){const t=this.cache[e];this.canvasFactory.destroy(t),delete this.cache[e]}}}function Toe(e,t,n,a,r,o,c,l,i,s){const[h,d,u,m,p,v]=Nre(e);if(0===d&&0===u){const f=c*h+p,z=Math.round(f),g=l*m+v,y=Math.round(g),M=(c+i)*h+p,E=Math.abs(Math.round(M)-z)||1,b=(l+s)*m+v,H=Math.abs(Math.round(b)-y)||1;return e.setTransform(Math.sign(h),0,0,Math.sign(m),z,y),e.drawImage(t,n,a,r,o,0,0,E,H),e.setTransform(h,d,u,m,p,v),[E,H]}if(0===h&&0===m){const f=l*u+p,z=Math.round(f),g=c*d+v,y=Math.round(g),M=(l+s)*u+p,E=Math.abs(Math.round(M)-z)||1,b=(c+i)*d+v,H=Math.abs(Math.round(b)-y)||1;return e.setTransform(0,Math.sign(d),Math.sign(u),0,z,y),e.drawImage(t,n,a,r,o,0,0,H,E),e.setTransform(h,d,u,m,p,v),[H,E]}return e.drawImage(t,n,a,r,o,c,l,i,s),[Math.hypot(h,d)*i,Math.hypot(u,m)*s]}class Ooe{constructor(e,t){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=_ae,this.textMatrixScale=1,this.fontMatrix=Dae,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=0,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,e,t])}clone(){const e=Object.create(this);return e.clipBox=this.clipBox.slice(),e}setCurrentPoint(e,t){this.x=e,this.y=t}updatePathMinMax(e,t,n){[t,n]=pre.applyTransform([t,n],e),this.minX=Math.min(this.minX,t),this.minY=Math.min(this.minY,n),this.maxX=Math.max(this.maxX,t),this.maxY=Math.max(this.maxY,n)}updateRectMinMax(e,t){const n=pre.applyTransform(t,e),a=pre.applyTransform(t.slice(2),e),r=pre.applyTransform([t[0],t[3]],e),o=pre.applyTransform([t[2],t[1]],e);this.minX=Math.min(this.minX,n[0],a[0],r[0],o[0]),this.minY=Math.min(this.minY,n[1],a[1],r[1],o[1]),this.maxX=Math.max(this.maxX,n[0],a[0],r[0],o[0]),this.maxY=Math.max(this.maxY,n[1],a[1],r[1],o[1])}updateScalingPathMinMax(e,t){pre.scaleMinMax(e,t),this.minX=Math.min(this.minX,t[0]),this.minY=Math.min(this.minY,t[1]),this.maxX=Math.max(this.maxX,t[2]),this.maxY=Math.max(this.maxY,t[3])}updateCurvePathMinMax(e,t,n,a,r,o,c,l,i,s){const h=pre.bezierBoundingBox(t,n,a,r,o,c,l,i,s);s||this.updateRectMinMax(e,h)}getPathBoundingBox(e=zoe,t=null){const n=[this.minX,this.minY,this.maxX,this.maxY];if(e===goe){t||Qae("Stroke bounding box must include transform.");const e=pre.singularValueDecompose2dScale(t),a=e[0]*this.lineWidth/2,r=e[1]*this.lineWidth/2;n[0]-=a,n[1]-=r,n[2]+=a,n[3]+=r}return n}updateClipFromPath(){const e=pre.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(e){this.clipBox=e,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(e=zoe,t=null){return pre.intersect(this.clipBox,this.getPathBoundingBox(e,t))}}function Aoe(e,t){if(t instanceof ImageData)return void e.putImageData(t,0,0);const n=t.height,a=t.width,r=n%koe,o=(n-r)/koe,c=0===r?o:o+1,l=e.createImageData(a,koe);let i,s=0;const h=t.data,d=l.data;let u,m,p,v;if(t.kind===Uae.GRAYSCALE_1BPP){const t=h.byteLength,n=new Uint32Array(d.buffer,0,d.byteLength>>2),v=n.length,f=a+7>>3,z=4294967295,g=ure.isLittleEndian?4278190080:255;for(u=0;u<c;u++){for(p=u<o?koe:r,i=0,m=0;m<p;m++){const e=t-s;let r=0;const o=e>f?a:8*e-7,c=-8&o;let l=0,d=0;for(;r<c;r+=8)d=h[s++],n[i++]=128&d?z:g,n[i++]=64&d?z:g,n[i++]=32&d?z:g,n[i++]=16&d?z:g,n[i++]=8&d?z:g,n[i++]=4&d?z:g,n[i++]=2&d?z:g,n[i++]=1&d?z:g;for(;r<o;r++)0===l&&(d=h[s++],l=128),n[i++]=d&l?z:g,l>>=1}for(;i<v;)n[i++]=0;e.putImageData(l,0,u*koe)}}else if(t.kind===Uae.RGBA_32BPP){for(m=0,v=a*koe*4,u=0;u<o;u++)d.set(h.subarray(s,s+v)),s+=v,e.putImageData(l,0,m),m+=koe;u<c&&(v=a*r*4,d.set(h.subarray(s,s+v)),e.putImageData(l,0,m))}else{if(t.kind!==Uae.RGB_24BPP)throw new Error(`bad image kind: ${t.kind}`);for(p=koe,v=a*p,u=0;u<c;u++){for(u>=o&&(p=r,v=a*p),i=0,m=v;m--;)d[i++]=h[s++],d[i++]=h[s++],d[i++]=h[s++],d[i++]=255;e.putImageData(l,0,u*koe)}}}function Roe(e,t){if(t.bitmap)return void e.drawImage(t.bitmap,0,0);const n=t.height,a=t.width,r=n%koe,o=(n-r)/koe,c=0===r?o:o+1,l=e.createImageData(a,koe);let i=0;const s=t.data,h=l.data;for(let t=0;t<c;t++){const n=t<o?koe:r;({srcPos:i}=Soe({src:s,srcPos:i,dest:h,width:a,height:n,nonBlackColor:0})),e.putImageData(l,0,t*koe)}}function Noe(e,t){const n=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const a of n)void 0!==e[a]&&(t[a]=e[a]);void 0!==e.setLineDash&&(t.setLineDash(e.getLineDash()),t.lineDashOffset=e.lineDashOffset)}function _oe(e){if(e.strokeStyle=e.fillStyle="#000000",e.fillRule="nonzero",e.globalAlpha=1,e.lineWidth=1,e.lineCap="butt",e.lineJoin="miter",e.miterLimit=10,e.globalCompositeOperation="source-over",e.font="10px sans-serif",void 0!==e.setLineDash&&(e.setLineDash([]),e.lineDashOffset=0),!Nae){const{filter:t}=e;"none"!==t&&""!==t&&(e.filter="none")}}function Doe(e,t){if(t)return!0;const n=pre.singularValueDecompose2dScale(e);n[0]=Math.fround(n[0]),n[1]=Math.fround(n[1]);const a=Math.fround((globalThis.devicePixelRatio||1)*Mre.PDF_TO_CSS_UNITS);return n[0]<=a&&n[1]<=a}const Poe=["butt","round","square"],Foe=["miter","round","bevel"],Ioe={},joe={};class Boe{constructor(e,t,n,a,r,{optionalContentConfig:o,markedContentStack:c=null},l,i){this.ctx=e,this.current=new Ooe(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=t,this.objs=n,this.canvasFactory=a,this.filterFactory=r,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=c||[],this.optionalContentConfig=o,this.cachedCanvases=new woe(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=i,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(e,t=null){return"string"==typeof e?e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e):t}beginDrawing({transform:e,viewport:t,transparency:n=!1,background:a=null}){const r=this.ctx.canvas.width,o=this.ctx.canvas.height,c=this.ctx.fillStyle;if(this.ctx.fillStyle=a||"#ffffff",this.ctx.fillRect(0,0,r,o),this.ctx.fillStyle=c,n){const e=this.cachedCanvases.getCanvas("transparent",r,o);this.compositeCtx=this.ctx,this.transparentCanvas=e.canvas,this.ctx=e.context,this.ctx.save(),this.ctx.transform(...Nre(this.compositeCtx))}this.ctx.save(),_oe(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...t.transform),this.viewportScale=t.scale,this.baseTransform=Nre(this.ctx)}executeOperatorList(e,t,n,a){const r=e.argsArray,o=e.fnArray;let c=t||0;const l=r.length;if(l===c)return c;const i=l-c>10&&"function"==typeof n,s=i?Date.now()+15:0;let h=0;const d=this.commonObjs,u=this.objs;let m;for(;;){if(void 0!==a&&c===a.nextBreakPoint)return a.breakIt(c,n),c;if(m=o[c],m!==$ae.dependency)this[m].apply(this,r[c]);else for(const e of r[c]){const t=e.startsWith("g_")?d:u;if(!t.has(e))return t.get(e,n),c}if(c++,c===l)return c;if(i&&++h>10){if(Date.now()>s)return n(),c;h=0}}}#sn(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#sn(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const e of this._cachedBitmapsMap.values()){for(const t of e.values())"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear(),this.#hn()}#hn(){if(this.pageColors){const e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==e){const t=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=t}}}_scaleImage(e,t){const n=e.width??e.displayWidth,a=e.height??e.displayHeight;let r,o,c=Math.max(Math.hypot(t[0],t[1]),1),l=Math.max(Math.hypot(t[2],t[3]),1),i=n,s=a,h="prescale1";for(;c>2&&i>1||l>2&&s>1;){let t=i,n=s;c>2&&i>1&&(t=i>=16384?Math.floor(i/2)-1||1:Math.ceil(i/2),c/=i/t),l>2&&s>1&&(n=s>=16384?Math.floor(s/2)-1||1:Math.ceil(s)/2,l/=s/n),r=this.cachedCanvases.getCanvas(h,t,n),o=r.context,o.clearRect(0,0,t,n),o.drawImage(e,0,0,i,s,0,0,t,n),e=r.canvas,i=t,s=n,h="prescale1"===h?"prescale2":"prescale1"}return{img:e,paintWidth:i,paintHeight:s}}_createMaskCanvas(e){const t=this.ctx,{width:n,height:a}=e,r=this.current.fillColor,o=this.current.patternFill,c=Nre(t);let l,i,s,h;if((e.bitmap||e.data)&&e.count>1){const t=e.bitmap||e.data.buffer;i=JSON.stringify(o?c:[c.slice(0,4),r]),l=this._cachedBitmapsMap.get(t),l||(l=new Map,this._cachedBitmapsMap.set(t,l));const n=l.get(i);if(n&&!o)return{canvas:n,offsetX:Math.round(Math.min(c[0],c[2])+c[4]),offsetY:Math.round(Math.min(c[1],c[3])+c[5])};s=n}s||(h=this.cachedCanvases.getCanvas("maskCanvas",n,a),Roe(h.context,e));let d=pre.transform(c,[1/n,0,0,-1/a,0,0]);d=pre.transform(d,[1,0,0,1,0,-a]);const[u,m,p,v]=pre.getAxialAlignedBoundingBox([0,0,n,a],d),f=Math.round(p-u)||1,z=Math.round(v-m)||1,g=this.cachedCanvases.getCanvas("fillCanvas",f,z),y=g.context,M=u,E=m;y.translate(-M,-E),y.transform(...d),s||(s=this._scaleImage(h.canvas,_re(y)),s=s.img,l&&o&&l.set(i,s)),y.imageSmoothingEnabled=Doe(Nre(y),e.interpolate),Toe(y,s,0,0,s.width,s.height,0,0,n,a),y.globalCompositeOperation="source-in";const b=pre.transform(_re(y),[1,0,0,1,-M,-E]);return y.fillStyle=o?r.getPattern(t,this,b,zoe):r,y.fillRect(0,0,n,a),l&&!o&&(this.cachedCanvases.delete("fillCanvas"),l.set(i,g.canvas)),{canvas:g.canvas,offsetX:Math.round(M),offsetY:Math.round(E)}}setLineWidth(e){e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(e){this.ctx.lineCap=Poe[e]}setLineJoin(e){this.ctx.lineJoin=Foe[e]}setMiterLimit(e){this.ctx.miterLimit=e}setDash(e,t){const n=this.ctx;void 0!==n.setLineDash&&(n.setLineDash(e),n.lineDashOffset=t)}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(const[t,n]of e)switch(t){case"LW":this.setLineWidth(n);break;case"LC":this.setLineCap(n);break;case"LJ":this.setLineJoin(n);break;case"ML":this.setMiterLimit(n);break;case"D":this.setDash(n[0],n[1]);break;case"RI":this.setRenderingIntent(n);break;case"FL":this.setFlatness(n);break;case"Font":this.setFont(n[0],n[1]);break;case"CA":this.current.strokeAlpha=n;break;case"ca":this.current.fillAlpha=n,this.ctx.globalAlpha=n;break;case"BM":this.ctx.globalCompositeOperation=n;break;case"SMask":this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode():!this.current.activeSMask&&e&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const e=this.ctx.canvas.width,t=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,a=this.cachedCanvases.getCanvas(n,e,t);this.suspendedCtx=this.ctx,this.ctx=a.context;const r=this.ctx;r.setTransform(...Nre(this.suspendedCtx)),Noe(this.suspendedCtx,r),function(e,t){if(e._removeMirroring)throw new Error("Context is already forwarding operations.");e.__originalSave=e.save,e.__originalRestore=e.restore,e.__originalRotate=e.rotate,e.__originalScale=e.scale,e.__originalTranslate=e.translate,e.__originalTransform=e.transform,e.__originalSetTransform=e.setTransform,e.__originalResetTransform=e.resetTransform,e.__originalClip=e.clip,e.__originalMoveTo=e.moveTo,e.__originalLineTo=e.lineTo,e.__originalBezierCurveTo=e.bezierCurveTo,e.__originalRect=e.rect,e.__originalClosePath=e.closePath,e.__originalBeginPath=e.beginPath,e._removeMirroring=()=>{e.save=e.__originalSave,e.restore=e.__originalRestore,e.rotate=e.__originalRotate,e.scale=e.__originalScale,e.translate=e.__originalTranslate,e.transform=e.__originalTransform,e.setTransform=e.__originalSetTransform,e.resetTransform=e.__originalResetTransform,e.clip=e.__originalClip,e.moveTo=e.__originalMoveTo,e.lineTo=e.__originalLineTo,e.bezierCurveTo=e.__originalBezierCurveTo,e.rect=e.__originalRect,e.closePath=e.__originalClosePath,e.beginPath=e.__originalBeginPath,delete e._removeMirroring},e.save=function(){t.save(),this.__originalSave()},e.restore=function(){t.restore(),this.__originalRestore()},e.translate=function(e,n){t.translate(e,n),this.__originalTranslate(e,n)},e.scale=function(e,n){t.scale(e,n),this.__originalScale(e,n)},e.transform=function(e,n,a,r,o,c){t.transform(e,n,a,r,o,c),this.__originalTransform(e,n,a,r,o,c)},e.setTransform=function(e,n,a,r,o,c){t.setTransform(e,n,a,r,o,c),this.__originalSetTransform(e,n,a,r,o,c)},e.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},e.rotate=function(e){t.rotate(e),this.__originalRotate(e)},e.clip=function(e){t.clip(e),this.__originalClip(e)},e.moveTo=function(e,n){t.moveTo(e,n),this.__originalMoveTo(e,n)},e.lineTo=function(e,n){t.lineTo(e,n),this.__originalLineTo(e,n)},e.bezierCurveTo=function(e,n,a,r,o,c){t.bezierCurveTo(e,n,a,r,o,c),this.__originalBezierCurveTo(e,n,a,r,o,c)},e.rect=function(e,n,a,r){t.rect(e,n,a,r),this.__originalRect(e,n,a,r)},e.closePath=function(){t.closePath(),this.__originalClosePath()},e.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}(r,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Noe(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(e){if(!this.current.activeSMask)return;e?(e[0]=Math.floor(e[0]),e[1]=Math.floor(e[1]),e[2]=Math.ceil(e[2]),e[3]=Math.ceil(e[3])):e=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const t=this.current.activeSMask,n=this.suspendedCtx;this.composeSMask(n,t,this.ctx,e),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(e,t,n,a){const r=a[0],o=a[1],c=a[2]-r,l=a[3]-o;0!==c&&0!==l&&(this.genericComposeSMask(t.context,n,c,l,t.subtype,t.backdrop,t.transferMap,r,o,t.offsetX,t.offsetY),e.save(),e.globalAlpha=1,e.globalCompositeOperation="source-over",e.setTransform(1,0,0,1,0,0),e.drawImage(n.canvas,0,0),e.restore())}genericComposeSMask(e,t,n,a,r,o,c,l,i,s,h){let d=e.canvas,u=l-s,m=i-h;if(o){const t=pre.makeHexColor(...o);if(u<0||m<0||u+n>d.width||m+a>d.height){const e=this.cachedCanvases.getCanvas("maskExtension",n,a),r=e.context;r.drawImage(d,-u,-m),r.globalCompositeOperation="destination-atop",r.fillStyle=t,r.fillRect(0,0,n,a),r.globalCompositeOperation="source-over",d=e.canvas,u=m=0}else{e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const r=new Path2D;r.rect(u,m,n,a),e.clip(r),e.globalCompositeOperation="destination-atop",e.fillStyle=t,e.fillRect(u,m,n,a),e.restore()}}t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0),"Alpha"===r&&c?t.filter=this.filterFactory.addAlphaFilter(c):"Luminosity"===r&&(t.filter=this.filterFactory.addLuminosityFilter(c));const p=new Path2D;p.rect(l,i,n,a),t.clip(p),t.globalCompositeOperation="destination-in",t.drawImage(d,u,m,n,a,l,i,n,a),t.restore()}save(){this.inSMaskMode?(Noe(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),Noe(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(e,t,n,a,r,o){this.ctx.transform(e,t,n,a,r,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,n){const a=this.ctx,r=this.current;let o,c,l=r.x,i=r.y;const s=Nre(a),h=0===s[0]&&0===s[3]||0===s[1]&&0===s[2],d=h?n.slice(0):null;for(let n=0,u=0,m=e.length;n<m;n++)switch(0|e[n]){case $ae.rectangle:l=t[u++],i=t[u++];const e=t[u++],n=t[u++],m=l+e,p=i+n;a.moveTo(l,i),0===e||0===n?a.lineTo(m,p):(a.lineTo(m,i),a.lineTo(m,p),a.lineTo(l,p)),h||r.updateRectMinMax(s,[l,i,m,p]),a.closePath();break;case $ae.moveTo:l=t[u++],i=t[u++],a.moveTo(l,i),h||r.updatePathMinMax(s,l,i);break;case $ae.lineTo:l=t[u++],i=t[u++],a.lineTo(l,i),h||r.updatePathMinMax(s,l,i);break;case $ae.curveTo:o=l,c=i,l=t[u+4],i=t[u+5],a.bezierCurveTo(t[u],t[u+1],t[u+2],t[u+3],l,i),r.updateCurvePathMinMax(s,o,c,t[u],t[u+1],t[u+2],t[u+3],l,i,d),u+=6;break;case $ae.curveTo2:o=l,c=i,a.bezierCurveTo(l,i,t[u],t[u+1],t[u+2],t[u+3]),r.updateCurvePathMinMax(s,o,c,l,i,t[u],t[u+1],t[u+2],t[u+3],d),l=t[u+2],i=t[u+3],u+=4;break;case $ae.curveTo3:o=l,c=i,l=t[u+2],i=t[u+3],a.bezierCurveTo(t[u],t[u+1],l,i,l,i),r.updateCurvePathMinMax(s,o,c,t[u],t[u+1],l,i,l,i,d),u+=4;break;case $ae.closePath:a.closePath()}h&&r.updateScalingPathMinMax(s,d),r.setCurrentPoint(l,i)}closePath(){this.ctx.closePath()}stroke(e=!0){const t=this.ctx,n=this.current.strokeColor;t.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof n&&n?.getPattern?(t.save(),t.strokeStyle=n.getPattern(t,this,_re(t),goe),this.rescaleAndStroke(!1),t.restore()):this.rescaleAndStroke(!0)),e&&this.consumePath(this.current.getClippedPathBoundingBox()),t.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(e=!0){const t=this.ctx,n=this.current.fillColor;let a=!1;this.current.patternFill&&(t.save(),t.fillStyle=n.getPattern(t,this,_re(t),zoe),a=!0);const r=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==r&&(this.pendingEOFill?(t.fill("evenodd"),this.pendingEOFill=!1):t.fill()),a&&t.restore(),e&&this.consumePath(r)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Ioe}eoClip(){this.pendingClip=joe}beginText(){this.current.textMatrix=_ae,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const e=this.pendingTextPaths,t=this.ctx;if(void 0===e)return void t.beginPath();const n=new Path2D,a=t.getTransform().invertSelf();for(const{transform:t,x:r,y:o,fontSize:c,path:l}of e)n.addPath(l,new DOMMatrix(t).preMultiplySelf(a).translate(r,o).scale(c,-c));t.clip(n),t.beginPath(),delete this.pendingTextPaths}setCharSpacing(e){this.current.charSpacing=e}setWordSpacing(e){this.current.wordSpacing=e}setHScale(e){this.current.textHScale=e/100}setLeading(e){this.current.leading=-e}setFont(e,t){const n=this.commonObjs.get(e),a=this.current;if(!n)throw new Error(`Can't find font for ${e}`);if(a.fontMatrix=n.fontMatrix||Dae,0!==a.fontMatrix[0]&&0!==a.fontMatrix[3]||Xae("Invalid font matrix for font "+e),t<0?(t=-t,a.fontDirection=-1):a.fontDirection=1,this.current.font=n,this.current.fontSize=t,n.isType3Font)return;const r=n.loadedName||"sans-serif",o=n.systemFontInfo?.css||`"${r}", ${n.fallbackName}`;let c="normal";n.black?c="900":n.bold&&(c="bold");const l=n.italic?"italic":"normal";let i=t;t<16?i=16:t>100&&(i=100),this.current.fontSizeScale=t/i,this.ctx.font=`${l} ${c} ${i}px ${o}`}setTextRenderingMode(e){this.current.textRenderingMode=e}setTextRise(e){this.current.textRise=e}moveText(e,t){this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=t}setLeadingMoveText(e,t){this.setLeading(-t),this.moveText(e,t)}setTextMatrix(e,t,n,a,r,o){this.current.textMatrix=[e,t,n,a,r,o],this.current.textMatrixScale=Math.hypot(e,t),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#dn(e,t,n){const a=new Path2D;return a.addPath(e,new DOMMatrix(n).invertSelf().multiplySelf(t)),a}paintChar(e,t,n,a,r){const o=this.ctx,c=this.current,l=c.font,i=c.textRenderingMode,s=c.fontSize/c.fontSizeScale,h=3&i,d=!!(4&i),u=c.patternFill&&!l.missingFile,m=c.patternStroke&&!l.missingFile;let p;if((l.disableFontFace||d||u||m)&&(p=l.getPathGenerator(this.commonObjs,e)),l.disableFontFace||u||m){if(o.save(),o.translate(t,n),o.scale(s,-s),0===h||2===h)if(a){const e=o.getTransform();o.setTransform(...a),o.fill(this.#dn(p,e,a))}else o.fill(p);if(1===h||2===h)if(r){const e=o.getTransform();o.setTransform(...r),o.stroke(this.#dn(p,e,r))}else o.lineWidth/=s,o.stroke(p);o.restore()}else 0!==h&&2!==h||o.fillText(e,t,n),1!==h&&2!==h||o.strokeText(e,t,n);d&&(this.pendingTextPaths||=[]).push({transform:Nre(o),x:t,y:n,fontSize:s,path:p})}get isFontSubpixelAAEnabled(){const{context:e}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);e.scale(1.5,1),e.fillText("I",0,10);const t=e.getImageData(0,0,10,10).data;let n=!1;for(let e=3;e<t.length;e+=4)if(t[e]>0&&t[e]<255){n=!0;break}return ere(this,"isFontSubpixelAAEnabled",n)}showText(e){const t=this.current,n=t.font;if(n.isType3Font)return this.showType3Text(e);const a=t.fontSize;if(0===a)return;const r=this.ctx,o=t.fontSizeScale,c=t.charSpacing,l=t.wordSpacing,i=t.fontDirection,s=t.textHScale*i,h=e.length,d=n.vertical,u=d?1:-1,m=n.defaultVMetrics,p=a*t.fontMatrix[0],v=0===t.textRenderingMode&&!n.disableFontFace&&!t.patternFill;let f,z;if(r.save(),r.transform(...t.textMatrix),r.translate(t.x,t.y+t.textRise),i>0?r.scale(s,-1):r.scale(s,1),t.patternFill){r.save();const e=t.fillColor.getPattern(r,this,_re(r),zoe);f=Nre(r),r.restore(),r.fillStyle=e}if(t.patternStroke){r.save();const e=t.strokeColor.getPattern(r,this,_re(r),goe);z=Nre(r),r.restore(),r.strokeStyle=e}let g=t.lineWidth;const y=t.textMatrixScale;if(0===y||0===g){const e=3&t.textRenderingMode;1!==e&&2!==e||(g=this.getSinglePixelWidth())}else g/=y;if(1!==o&&(r.scale(o,o),g/=o),r.lineWidth=g,n.isInvalidPDFjsFont){const n=[];let a=0;for(const t of e)n.push(t.unicode),a+=t.width;return r.fillText(n.join(""),0,0),t.x+=a*p*s,r.restore(),void this.compose()}let M,E=0;for(M=0;M<h;++M){const t=e[M];if("number"==typeof t){E+=u*t*a/1e3;continue}let s=!1;const h=(t.isSpace?l:0)+c,g=t.fontChar,y=t.accent;let b,H,V=t.width;if(d){const e=t.vmetric||m,n=-(t.vmetric?e[1]:.5*V)*p,a=e[2]*p;V=e?-e[0]:V,b=n/o,H=(E+a)/o}else b=E/o,H=0;if(n.remeasure&&V>0){const e=1e3*r.measureText(g).width/a*o;if(V<e&&this.isFontSubpixelAAEnabled){const t=V/e;s=!0,r.save(),r.scale(t,1),b/=t}else V!==e&&(b+=(V-e)/2e3*a/o)}if(this.contentVisible&&(t.isInFont||n.missingFile))if(v&&!y)r.fillText(g,b,H);else if(this.paintChar(g,b,H,f,z),y){const e=b+a*y.offset.x/o,t=H-a*y.offset.y/o;this.paintChar(y.fontChar,e,t,f,z)}E+=d?V*p-h*i:V*p+h*i,s&&r.restore()}d?t.y-=E:t.x+=E*s,r.restore(),this.compose()}showType3Text(e){const t=this.ctx,n=this.current,a=n.font,r=n.fontSize,o=n.fontDirection,c=a.vertical?1:-1,l=n.charSpacing,i=n.wordSpacing,s=n.textHScale*o,h=n.fontMatrix||Dae,d=e.length;let u,m,p,v;if(3!==n.textRenderingMode&&0!==r){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,t.save(),t.transform(...n.textMatrix),t.translate(n.x,n.y),t.scale(s,o),u=0;u<d;++u){if(m=e[u],"number"==typeof m){v=c*m*r/1e3,this.ctx.translate(v,0),n.x+=v*s;continue}const o=(m.isSpace?i:0)+l,d=a.charProcOperatorList[m.operatorListId];d?(this.contentVisible&&(this.processingType3=m,this.save(),t.scale(r,r),t.transform(...h),this.executeOperatorList(d),this.restore()),p=pre.applyTransform([m.width,0],h)[0]*r+o,t.translate(p,0),n.x+=p*s):Xae(`Type3 character "${m.operatorListId}" is not available.`)}t.restore(),this.processingType3=null}}setCharWidth(e,t){}setCharWidthAndBounds(e,t,n,a,r,o){this.ctx.rect(n,a,r-n,o-a),this.ctx.clip(),this.endPath()}getColorN_Pattern(e){let t;if("TilingPattern"===e[0]){const n=e[1],a=this.baseTransform||Nre(this.ctx),r={createCanvasGraphics:e=>new Boe(e,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};t=new xoe(e,n,this.ctx,r,a)}else t=this._getPattern(e[1],e[2]);return t}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(e,t,n){this.ctx.strokeStyle=this.current.strokeColor=pre.makeHexColor(e,t,n),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(e,t,n){this.ctx.fillStyle=this.current.fillColor=pre.makeHexColor(e,t,n),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(e,t=null){let n;return this.cachedPatterns.has(e)?n=this.cachedPatterns.get(e):(n=function(e){switch(e[0]){case"RadialAxial":return new boe(e);case"Mesh":return new Coe(e);case"Dummy":return new Loe}throw new Error(`Unknown IR type: ${e[0]}`)}(this.getObject(e)),this.cachedPatterns.set(e,n)),t&&(n.matrix=t),n}shadingFill(e){if(!this.contentVisible)return;const t=this.ctx;this.save();const n=this._getPattern(e);t.fillStyle=n.getPattern(t,this,_re(t),yoe);const a=_re(t);if(a){const{width:e,height:n}=t.canvas,[r,o,c,l]=pre.getAxialAlignedBoundingBox([0,0,e,n],a);this.ctx.fillRect(r,o,c-r,l-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){Qae("Should not call beginInlineImage")}beginImageData(){Qae("Should not call beginImageData")}paintFormXObjectBegin(e,t){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),e&&this.transform(...e),this.baseTransform=Nre(this.ctx),t)){const e=t[2]-t[0],n=t[3]-t[1];this.ctx.rect(t[0],t[1],e,n),this.current.updateRectMinMax(Nre(this.ctx),t),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const t=this.ctx;e.isolated||Kae("TODO: Support non-isolated groups."),e.knockout&&Xae("Knockout groups not supported.");const n=Nre(t);if(e.matrix&&t.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let a=pre.getAxialAlignedBoundingBox(e.bbox,Nre(t));const r=[0,0,t.canvas.width,t.canvas.height];a=pre.intersect(a,r)||[0,0,0,0];const o=Math.floor(a[0]),c=Math.floor(a[1]),l=Math.max(Math.ceil(a[2])-o,1),i=Math.max(Math.ceil(a[3])-c,1);this.current.startNewPathAndClipBox([0,0,l,i]);let s="groupAt"+this.groupLevel;e.smask&&(s+="_smask_"+this.smaskCounter++%2);const h=this.cachedCanvases.getCanvas(s,l,i),d=h.context;d.translate(-o,-c),d.transform(...n),e.smask?this.smaskStack.push({canvas:h.canvas,context:d,offsetX:o,offsetY:c,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}):(t.setTransform(1,0,0,1,0,0),t.translate(o,c),t.save()),Noe(t,d),this.ctx=d,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(t),this.groupLevel++}endGroup(e){if(!this.contentVisible)return;this.groupLevel--;const t=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,e.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const e=Nre(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...e);const n=pre.getAxialAlignedBoundingBox([0,0,t.canvas.width,t.canvas.height],e);this.ctx.drawImage(t.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(e,t,n,a,r){if(this.#sn(),_oe(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),t){const a=t[2]-t[0],o=t[3]-t[1];if(r&&this.annotationCanvasMap){(n=n.slice())[4]-=t[0],n[5]-=t[1],(t=t.slice())[0]=t[1]=0,t[2]=a,t[3]=o;const[r,c]=pre.singularValueDecompose2dScale(Nre(this.ctx)),{viewportScale:l}=this,i=Math.ceil(a*this.outputScaleX*l),s=Math.ceil(o*this.outputScaleY*l);this.annotationCanvas=this.canvasFactory.create(i,s);const{canvas:h,context:d}=this.annotationCanvas;this.annotationCanvasMap.set(e,h),this.annotationCanvas.savedCtx=this.ctx,this.ctx=d,this.ctx.save(),this.ctx.setTransform(r,0,0,-c,0,o*c),_oe(this.ctx)}else _oe(this.ctx),this.endPath(),this.ctx.rect(t[0],t[1],a,o),this.ctx.clip(),this.ctx.beginPath()}this.current=new Ooe(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...a)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#hn(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e){if(!this.contentVisible)return;const t=e.count;(e=this.getObject(e.data,e)).count=t;const n=this.ctx,a=this.processingType3;if(a&&(void 0===a.compiled&&(a.compiled=function(e){const{width:t,height:n}=e;if(t>1e3||n>1e3)return null;const a=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),r=t+1;let o,c,l,i=new Uint8Array(r*(n+1));const s=t+7&-8;let h=new Uint8Array(s*n),d=0;for(const t of e.data){let e=128;for(;e>0;)h[d++]=t&e?0:255,e>>=1}let u=0;for(d=0,0!==h[d]&&(i[0]=1,++u),c=1;c<t;c++)h[d]!==h[d+1]&&(i[c]=h[d]?2:1,++u),d++;for(0!==h[d]&&(i[c]=2,++u),o=1;o<n;o++){d=o*s,l=o*r,h[d-s]!==h[d]&&(i[l]=h[d]?1:8,++u);let e=(h[d]?4:0)+(h[d-s]?8:0);for(c=1;c<t;c++)e=(e>>2)+(h[d+1]?4:0)+(h[d-s+1]?8:0),a[e]&&(i[l+c]=a[e],++u),d++;if(h[d-s]!==h[d]&&(i[l+c]=h[d]?2:4,++u),u>1e3)return null}for(d=s*(n-1),l=o*r,0!==h[d]&&(i[l]=8,++u),c=1;c<t;c++)h[d]!==h[d+1]&&(i[l+c]=h[d]?4:8,++u),d++;if(0!==h[d]&&(i[l+c]=4,++u),u>1e3)return null;const m=new Int32Array([0,r,-1,0,-r,0,0,0,1]),p=new Path2D;for(o=0;u&&o<=n;o++){let e=o*r;const n=e+t;for(;e<n&&!i[e];)e++;if(e===n)continue;p.moveTo(e%r,o);const a=e;let c=i[e];do{const t=m[c];do{e+=t}while(!i[e]);const n=i[e];5!==n&&10!==n?(c=n,i[e]=0):(c=n&51*c>>4,i[e]&=c>>2|c<<2),p.lineTo(e%r,e/r|0),i[e]||--u}while(a!==e);--o}return h=null,i=null,function(e){e.save(),e.scale(1/t,-1/n),e.translate(0,-n),e.fill(p),e.beginPath(),e.restore()}}(e)),a.compiled))return void a.compiled(n);const r=this._createMaskCanvas(e),o=r.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(o,r.offsetX,r.offsetY),n.restore(),this.compose()}paintImageMaskXObjectRepeat(e,t,n=0,a=0,r,o){if(!this.contentVisible)return;e=this.getObject(e.data,e);const c=this.ctx;c.save();const l=Nre(c);c.transform(t,n,a,r,0,0);const i=this._createMaskCanvas(e);c.setTransform(1,0,0,1,i.offsetX-l[4],i.offsetY-l[5]);for(let e=0,s=o.length;e<s;e+=2){const s=pre.transform(l,[t,n,a,r,o[e],o[e+1]]),[h,d]=pre.applyTransform([0,0],s);c.drawImage(i.canvas,h,d)}c.restore(),this.compose()}paintImageMaskXObjectGroup(e){if(!this.contentVisible)return;const t=this.ctx,n=this.current.fillColor,a=this.current.patternFill;for(const r of e){const{data:e,width:o,height:c,transform:l}=r,i=this.cachedCanvases.getCanvas("maskCanvas",o,c),s=i.context;s.save(),Roe(s,this.getObject(e,r)),s.globalCompositeOperation="source-in",s.fillStyle=a?n.getPattern(s,this,_re(t),zoe):n,s.fillRect(0,0,o,c),s.restore(),t.save(),t.transform(...l),t.scale(1,-1),Toe(t,i.canvas,0,0,o,c,0,-1,1,1),t.restore()}this.compose()}paintImageXObject(e){if(!this.contentVisible)return;const t=this.getObject(e);t?this.paintInlineImageXObject(t):Xae("Dependent image isn't ready yet")}paintImageXObjectRepeat(e,t,n,a){if(!this.contentVisible)return;const r=this.getObject(e);if(!r)return void Xae("Dependent image isn't ready yet");const o=r.width,c=r.height,l=[];for(let e=0,r=a.length;e<r;e+=2)l.push({transform:[t,0,0,n,a[e],a[e+1]],x:0,y:0,w:o,h:c});this.paintInlineImageXObjectGroup(r,l)}applyTransferMapsToCanvas(e){return"none"!==this.current.transferMaps&&(e.filter=this.current.transferMaps,e.drawImage(e.canvas,0,0),e.filter="none"),e.canvas}applyTransferMapsToBitmap(e){if("none"===this.current.transferMaps)return e.bitmap;const{bitmap:t,width:n,height:a}=e,r=this.cachedCanvases.getCanvas("inlineImage",n,a),o=r.context;return o.filter=this.current.transferMaps,o.drawImage(t,0,0),o.filter="none",r.canvas}paintInlineImageXObject(e){if(!this.contentVisible)return;const t=e.width,n=e.height,a=this.ctx;if(this.save(),!Nae){const{filter:e}=a;"none"!==e&&""!==e&&(a.filter="none")}let r;if(a.scale(1/t,-1/n),e.bitmap)r=this.applyTransferMapsToBitmap(e);else if("function"==typeof HTMLElement&&e instanceof HTMLElement||!e.data)r=e;else{const a=this.cachedCanvases.getCanvas("inlineImage",t,n).context;Aoe(a,e),r=this.applyTransferMapsToCanvas(a)}const o=this._scaleImage(r,_re(a));a.imageSmoothingEnabled=Doe(Nre(a),e.interpolate),Toe(a,o.img,0,0,o.paintWidth,o.paintHeight,0,-n,t,n),this.compose(),this.restore()}paintInlineImageXObjectGroup(e,t){if(!this.contentVisible)return;const n=this.ctx;let a;if(e.bitmap)a=e.bitmap;else{const t=e.width,n=e.height,r=this.cachedCanvases.getCanvas("inlineImage",t,n).context;Aoe(r,e),a=this.applyTransferMapsToCanvas(r)}for(const e of t)n.save(),n.transform(...e.transform),n.scale(1,-1),Toe(n,a,e.x,e.y,e.w,e.h,0,-1,1,1),n.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(e){}markPointProps(e,t){}beginMarkedContent(e){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t){"OC"===e?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(t)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(e){const t=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(e);const n=this.ctx;this.pendingClip&&(t||(this.pendingClip===joe?n.clip("evenodd"):n.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),n.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const e=Nre(this.ctx);if(0===e[1]&&0===e[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{const t=Math.abs(e[0]*e[3]-e[2]*e[1]),n=Math.hypot(e[0],e[2]),a=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(n,a)/t}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:e}=this.current,{a:t,b:n,c:a,d:r}=this.ctx.getTransform();let o,c;if(0===n&&0===a){const n=Math.abs(t),a=Math.abs(r);if(n===a)if(0===e)o=c=1/n;else{const t=n*e;o=c=t<1?1/t:1}else if(0===e)o=1/n,c=1/a;else{const t=n*e,r=a*e;o=t<1?1/t:1,c=r<1?1/r:1}}else{const l=Math.abs(t*r-n*a),i=Math.hypot(t,n),s=Math.hypot(a,r);if(0===e)o=s/l,c=i/l;else{const t=e*l;o=s>t?s/t:1,c=i>t?i/t:1}}this._cachedScaleForStroking[0]=o,this._cachedScaleForStroking[1]=c}return this._cachedScaleForStroking}rescaleAndStroke(e){const{ctx:t}=this,{lineWidth:n}=this.current,[a,r]=this.getScaleForStroking();if(t.lineWidth=n||1,1===a&&1===r)return void t.stroke();const o=t.getLineDash();if(e&&t.save(),t.scale(a,r),o.length>0){const e=Math.max(a,r);t.setLineDash(o.map((t=>t/e))),t.lineDashOffset/=e}t.stroke(),e&&t.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}}for(const e in $ae)void 0!==Boe.prototype[e]&&(Boe.prototype[$ae[e]]=Boe.prototype[e]);class Uoe{static#un=null;static#mn="";static get workerPort(){return this.#un}static set workerPort(e){if(!("undefined"!=typeof Worker&&e instanceof Worker)&&null!==e)throw new Error("Invalid `workerPort` type.");this.#un=e}static get workerSrc(){return this.#mn}static set workerSrc(e){if("string"!=typeof e)throw new Error("Invalid `workerSrc` type.");this.#mn=e}}class Woe{#pn;#vn;constructor({parsedData:e,rawData:t}){this.#pn=e,this.#vn=t}getRaw(){return this.#vn}get(e){return this.#pn.get(e)??null}getAll(){return dre(this.#pn)}has(e){return this.#pn.has(e)}}const $oe=Symbol("INTERNAL");class qoe{#fn=!1;#zn=!1;#gn=!1;#yn=!0;constructor(e,{name:t,intent:n,usage:a,rbGroups:r}){this.#fn=!!(2&e),this.#zn=!!(4&e),this.name=t,this.intent=n,this.usage=a,this.rbGroups=r}get visible(){if(this.#gn)return this.#yn;if(!this.#yn)return!1;const{print:e,view:t}=this.usage;return this.#fn?"OFF"!==t?.viewState:!this.#zn||"OFF"!==e?.printState}_setVisible(e,t,n=!1){e!==$oe&&Qae("Internal method `_setVisible` called."),this.#gn=n,this.#yn=t}}class Goe{#Mn=null;#En=new Map;#bn=null;#Hn=null;constructor(e,t=2){if(this.renderingIntent=t,this.name=null,this.creator=null,null!==e){this.name=e.name,this.creator=e.creator,this.#Hn=e.order;for(const n of e.groups)this.#En.set(n.id,new qoe(t,n));if("OFF"===e.baseState)for(const e of this.#En.values())e._setVisible($oe,!1);for(const t of e.on)this.#En.get(t)._setVisible($oe,!0);for(const t of e.off)this.#En.get(t)._setVisible($oe,!1);this.#bn=this.getHash()}}#Vn(e){const t=e.length;if(t<2)return!0;const n=e[0];for(let a=1;a<t;a++){const t=e[a];let r;if(Array.isArray(t))r=this.#Vn(t);else{if(!this.#En.has(t))return Xae(`Optional content group not found: ${t}`),!0;r=this.#En.get(t).visible}switch(n){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return"And"===n}isVisible(e){if(0===this.#En.size)return!0;if(!e)return Kae("Optional content group not defined."),!0;if("OCG"===e.type)return this.#En.has(e.id)?this.#En.get(e.id).visible:(Xae(`Optional content group not found: ${e.id}`),!0);if("OCMD"===e.type){if(e.expression)return this.#Vn(e.expression);if(!e.policy||"AnyOn"===e.policy){for(const t of e.ids){if(!this.#En.has(t))return Xae(`Optional content group not found: ${t}`),!0;if(this.#En.get(t).visible)return!0}return!1}if("AllOn"===e.policy){for(const t of e.ids){if(!this.#En.has(t))return Xae(`Optional content group not found: ${t}`),!0;if(!this.#En.get(t).visible)return!1}return!0}if("AnyOff"===e.policy){for(const t of e.ids){if(!this.#En.has(t))return Xae(`Optional content group not found: ${t}`),!0;if(!this.#En.get(t).visible)return!0}return!1}if("AllOff"===e.policy){for(const t of e.ids){if(!this.#En.has(t))return Xae(`Optional content group not found: ${t}`),!0;if(this.#En.get(t).visible)return!1}return!0}return Xae(`Unknown optional content policy ${e.policy}.`),!0}return Xae(`Unknown group type ${e.type}.`),!0}setVisibility(e,t=!0,n=!0){const a=this.#En.get(e);if(a){if(n&&t&&a.rbGroups.length)for(const t of a.rbGroups)for(const n of t)n!==e&&this.#En.get(n)?._setVisible($oe,!1,!0);a._setVisible($oe,!!t,!0),this.#Mn=null}else Xae(`Optional content group not found: ${e}`)}setOCGState({state:e,preserveRB:t}){let n;for(const a of e){switch(a){case"ON":case"OFF":case"Toggle":n=a;continue}const e=this.#En.get(a);if(e)switch(n){case"ON":this.setVisibility(a,!0,t);break;case"OFF":this.setVisibility(a,!1,t);break;case"Toggle":this.setVisibility(a,!e.visible,t)}}this.#Mn=null}get hasInitialVisibility(){return null===this.#bn||this.getHash()===this.#bn}getOrder(){return this.#En.size?this.#Hn?this.#Hn.slice():[...this.#En.keys()]:null}getGroups(){return this.#En.size>0?dre(this.#En):null}getGroup(e){return this.#En.get(e)||null}getHash(){if(null!==this.#Mn)return this.#Mn;const e=new toe;for(const[t,n]of this.#En)e.update(`${t}:${n.visible}`);return this.#Mn=e.hexdigest()}}class Yoe{constructor(e,{disableRange:t=!1,disableStream:n=!1}){Jae(e,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:a,initialData:r,progressiveDone:o,contentDispositionFilename:c}=e;if(this._queuedChunks=[],this._progressiveDone=o,this._contentDispositionFilename=c,r?.length>0){const e=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;this._queuedChunks.push(e)}this._pdfDataRangeTransport=e,this._isStreamingSupported=!n,this._isRangeSupported=!t,this._contentLength=a,this._fullRequestReader=null,this._rangeReaders=[],e.addRangeListener(((e,t)=>{this._onReceiveData({begin:e,chunk:t})})),e.addProgressListener(((e,t)=>{this._onProgress({loaded:e,total:t})})),e.addProgressiveReadListener((e=>{this._onReceiveData({chunk:e})})),e.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),e.transportReady()}_onReceiveData({begin:e,chunk:t}){const n=t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer;void 0===e?this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n):Jae(this._rangeReaders.some((function(t){return t._begin===e&&(t._enqueue(n),!0)})),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(e){void 0===e.total?this._rangeReaders[0]?.onProgress?.({loaded:e.loaded}):this._fullRequestReader?.onProgress?.({loaded:e.loaded,total:e.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(e){const t=this._rangeReaders.indexOf(e);t>=0&&this._rangeReaders.splice(t,1)}getFullReader(){Jae(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const e=this._queuedChunks;return this._queuedChunks=null,new Koe(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const n=new Xoe(this,e,t);return this._pdfDataRangeTransport.requestDataRange(e,t),this._rangeReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeReaders.slice(0))t.cancel(e);this._pdfDataRangeTransport.abort()}}class Koe{constructor(e,t,n=!1,a=null){this._stream=e,this._done=n||!1,this._filename=Cre(a)?a:null,this._queuedChunks=t||[],this._loaded=0;for(const e of this._queuedChunks)this._loaded+=e.byteLength;this._requests=[],this._headersReady=Promise.resolve(),e._fullRequestReader=this,this.onProgress=null}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Xoe{constructor(e,t,n){this._stream=e,this._begin=t,this._end=n,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(e){if(!this._done){if(0===this._requests.length)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Qoe(e,t){const n=new Headers;if(!e||!t||"object"!=typeof t)return n;for(const e in t){const a=t[e];void 0!==a&&n.append(e,a)}return n}function Joe(e){try{return new URL(e).origin}catch{}return null}function Zoe({responseHeaders:e,isHttp:t,rangeChunkSize:n,disableRange:a}){const r={allowRangeRequests:!1,suggestedLength:void 0},o=parseInt(e.get("Content-Length"),10);return Number.isInteger(o)?(r.suggestedLength=o,o<=2*n||a||!t||"bytes"!==e.get("Accept-Ranges")||"identity"!==(e.get("Content-Encoding")||"identity")||(r.allowRangeRequests=!0),r):r}function ece(e){const t=e.get("Content-Disposition");if(t){let e=function(e){let t=!0,n=a("filename\\*","i").exec(e);if(n){n=n[1];let e=c(n);return e=unescape(e),e=l(e),e=i(e),o(e)}if(n=function(e){const t=[];let n;const r=a("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(n=r.exec(e));){let[,e,a,r]=n;if(e=parseInt(e,10),e in t){if(0===e)break}else t[e]=[a,r]}const o=[];for(let e=0;e<t.length&&e in t;++e){let[n,a]=t[e];a=c(a),n&&(a=unescape(a),0===e&&(a=l(a))),o.push(a)}return o.join("")}(e),n)return o(i(n));if(n=a("filename","i").exec(e),n){n=n[1];let e=c(n);return e=i(e),o(e)}function a(e,t){return new RegExp("(?:^|;)\\s*"+e+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',t)}function r(e,n){if(e){if(!/^[\x00-\xFF]+$/.test(n))return n;try{const a=new TextDecoder(e,{fatal:!0}),r=hre(n);n=a.decode(r),t=!1}catch{}}return n}function o(e){return t&&/[\x80-\xff]/.test(e)&&(e=r("utf-8",e),t&&(e=r("iso-8859-1",e))),e}function c(e){if(e.startsWith('"')){const t=e.slice(1).split('\\"');for(let e=0;e<t.length;++e){const n=t[e].indexOf('"');-1!==n&&(t[e]=t[e].slice(0,n),t.length=e+1),t[e]=t[e].replaceAll(/\\(.)/g,"$1")}e=t.join('"')}return e}function l(e){const t=e.indexOf("'");return-1===t?e:r(e.slice(0,t),e.slice(t+1).replace(/^[^']*'/,""))}function i(e){return!e.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(e)?e:e.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(e,t,n,a){if("q"===n||"Q"===n)return r(t,a=(a=a.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(e,t){return String.fromCharCode(parseInt(t,16))})));try{a=atob(a)}catch{}return r(t,a)}))}return""}(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Cre(e))return e}return null}function tce(e,t){return 404===e||0===e&&t.startsWith("file:")?new ore('Missing PDF "'+t+'".'):new cre(`Unexpected server response (${e}) while retrieving PDF "${t}".`,e)}function nce(e){return 200===e||206===e}function ace(e,t,n){return{method:"GET",headers:e,signal:n.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function rce(e){return e instanceof Uint8Array?e.buffer:e instanceof ArrayBuffer?e:(Xae(`getArrayBuffer - unexpected data format: ${e}`),new Uint8Array(e).buffer)}class oce{_responseOrigin=null;constructor(e){this.source=e,this.isHttp=/^https?:/i.test(e.url),this.headers=Qoe(this.isHttp,e.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return Jae(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new cce(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const n=new lce(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeRequestReaders.slice(0))t.cancel(e)}}class cce{constructor(e){this._stream=e,this._reader=null,this._loaded=0,this._filename=null;const t=e.source;this._withCredentials=t.withCredentials||!1,this._contentLength=t.length,this._headersCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange;const n=new Headers(e.headers),a=t.url;fetch(a,ace(n,this._withCredentials,this._abortController)).then((t=>{if(e._responseOrigin=Joe(t.url),!nce(t.status))throw tce(t.status,a);this._reader=t.body.getReader(),this._headersCapability.resolve();const n=t.headers,{allowRangeRequests:r,suggestedLength:o}=Zoe({responseHeaders:n,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=r,this._contentLength=o||this._contentLength,this._filename=ece(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new ire("Streaming is disabled."))})).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:rce(e),done:!1})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}}class lce{constructor(e,t,n){this._stream=e,this._reader=null,this._loaded=0;const a=e.source;this._withCredentials=a.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!a.disableStream,this._abortController=new AbortController;const r=new Headers(e.headers);r.append("Range",`bytes=${t}-${n-1}`);const o=a.url;fetch(o,ace(r,this._withCredentials,this._abortController)).then((t=>{const n=Joe(t.url);if(n!==e._responseOrigin)throw new Error(`Expected range response-origin "${n}" to match "${e._responseOrigin}".`);if(!nce(t.status))throw tce(t.status,o);this._readCapability.resolve(),this._reader=t.body.getReader()})).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded}),{value:rce(e),done:!1})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}}class ice{_responseOrigin=null;constructor({url:e,httpHeaders:t,withCredentials:n}){this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=Qoe(this.isHttp,t),this.withCredentials=n||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(e){const t=new XMLHttpRequest,n=this.currXhrId++,a=this.pendingRequests[n]={xhr:t};t.open("GET",this.url),t.withCredentials=this.withCredentials;for(const[e,n]of this.headers)t.setRequestHeader(e,n);return this.isHttp&&"begin"in e&&"end"in e?(t.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),a.expectedStatus=206):a.expectedStatus=200,t.responseType="arraybuffer",Jae(e.onError,"Expected `onError` callback to be provided."),t.onerror=()=>{e.onError(t.status)},t.onreadystatechange=this.onStateChange.bind(this,n),t.onprogress=this.onProgress.bind(this,n),a.onHeadersReceived=e.onHeadersReceived,a.onDone=e.onDone,a.onError=e.onError,a.onProgress=e.onProgress,t.send(null),n}onProgress(e,t){const n=this.pendingRequests[e];n&&n.onProgress?.(t)}onStateChange(e,t){const n=this.pendingRequests[e];if(!n)return;const a=n.xhr;if(a.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),4!==a.readyState)return;if(!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],0===a.status&&this.isHttp)return void n.onError(a.status);const r=a.status||200;if((200!==r||206!==n.expectedStatus)&&r!==n.expectedStatus)return void n.onError(a.status);const o=function(e){const t=e.response;return"string"!=typeof t?t:hre(t).buffer}(a);if(206===r){const e=a.getResponseHeader("Content-Range"),t=/bytes (\d+)-(\d+)\/(\d+)/.exec(e);t?n.onDone({begin:parseInt(t[1],10),chunk:o}):(Xae('Missing or invalid "Content-Range" header.'),n.onError(0))}else o?n.onDone({begin:0,chunk:o}):n.onError(a.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){const t=this.pendingRequests[e].xhr;delete this.pendingRequests[e],t.abort()}}class sce{constructor(e){this._source=e,this._manager=new ice(e),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){const t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)}getFullReader(){return Jae(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new hce(this._manager,this._source),this._fullRequestReader}getRangeReader(e,t){const n=new dce(this._manager,e,t);return n.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeRequestReaders.slice(0))t.cancel(e)}}class hce{constructor(e,t){this._manager=e,this._url=t.url,this._fullRequestId=e.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._contentLength=t.length,this._rangeChunkSize=t.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const e=this._fullRequestId,t=this._manager.getRequestXhr(e);this._manager._responseOrigin=Joe(t.responseURL);const n=t.getAllResponseHeaders(),a=new Headers(n?n.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((e=>{const[t,...n]=e.split(": ");return[t,n.join(": ")]})):[]),{allowRangeRequests:r,suggestedLength:o}=Zoe({responseHeaders:a,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});r&&(this._isRangeSupported=!0),this._contentLength=o||this._contentLength,this._filename=ece(a),this._isRangeSupported&&this._manager.abortRequest(e),this._headersCapability.resolve()}_onDone(e){if(e&&(this._requests.length>0?this._requests.shift().resolve({value:e.chunk,done:!1}):this._cachedChunks.push(e.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){this._storedError=tce(e,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(e){this.onProgress?.({loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._headersCapability.reject(e);for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class dce{constructor(e,t,n){this._manager=e,this._url=e.url,this._requestId=e.request({begin:t,end:n,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){const e=Joe(this._manager.getRequestXhr(this._requestId)?.responseURL);e!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${e}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(e){const t=e.chunk;this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(e){this._storedError??=tce(e,this._url);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(e){this.isStreamingSupported||this.onProgress?.({loaded:e.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const uce=/^[a-z][a-z0-9\-+.]+:/i;class mce{constructor(e){this.source=e,this.url=function(e){if(uce.test(e))return new URL(e);const t=yt.getBuiltinModule("url");return new URL(t.pathToFileURL(e))}(e.url),Jae("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return Jae(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new pce(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const n=new vce(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeRequestReaders.slice(0))t.cancel(e)}}class pce{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;const t=e.source;this._contentLength=t.length,this._loaded=0,this._filename=null,this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const n=yt.getBuiltinModule("fs");n.promises.lstat(this._url).then((e=>{this._contentLength=e.size,this._setReadableStream(n.createReadStream(this._url)),this._headersCapability.resolve()}),(e=>{"ENOENT"===e.code&&(e=new ore(`Missing PDF "${this._url}".`)),this._storedError=e,this._headersCapability.reject(e)}))}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return null===e?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){this._readableStream?this._readableStream.destroy(e):this._error(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",(()=>{this._readCapability.resolve()})),e.on("end",(()=>{e.destroy(),this._done=!0,this._readCapability.resolve()})),e.on("error",(e=>{this._error(e)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new ire("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class vce{constructor(e,t,n){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const a=e.source;this._isStreamingSupported=!a.disableStream;const r=yt.getBuiltinModule("fs");this._setReadableStream(r.createReadStream(this._url,{start:t,end:n-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return null===e?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){this._readableStream?this._readableStream.destroy(e):this._error(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",(()=>{this._readCapability.resolve()})),e.on("end",(()=>{e.destroy(),this._done=!0,this._readCapability.resolve()})),e.on("error",(e=>{this._error(e)})),this._storedError&&this._readableStream.destroy(this._storedError)}}const fce=30;class zce{#Cn=Promise.withResolvers();#me=null;#Ln=!1;#xn=!!globalThis.FontInspector?.enabled;#Sn=null;#kn=null;#wn=0;#Tn=0;#On=null;#An=null;#Rn=0;#Nn=0;#_n=Object.create(null);#Dn=[];#Pn=null;#Fn=[];#In=new WeakMap;#jn=null;static#Bn=new Map;static#Un=new Map;static#Wn=new WeakMap;static#$n=null;static#qn=new Set;constructor({textContentSource:e,container:t,viewport:n}){if(e instanceof ReadableStream)this.#Pn=e;else{if("object"!=typeof e)throw new Error('No "textContentSource" parameter specified.');this.#Pn=new ReadableStream({start(t){t.enqueue(e),t.close()}})}this.#me=this.#An=t,this.#Nn=n.scale*(globalThis.devicePixelRatio||1),this.#Rn=n.rotation,this.#kn={div:null,properties:null,ctx:null};const{pageWidth:a,pageHeight:r,pageX:o,pageY:c}=n.rawDims;this.#jn=[1,0,0,-1,-o,c+r],this.#Tn=a,this.#wn=r,zce.#Gn(),Dre(t,n),this.#Cn.promise.finally((()=>{zce.#qn.delete(this),this.#kn=null,this.#_n=null})).catch((()=>{}))}static get fontFamilyMap(){const{isWindows:e,isFirefox:t}=ure.platform;return ere(this,"fontFamilyMap",new Map([["sans-serif",(e&&t?"Calibri, ":"")+"sans-serif"],["monospace",(e&&t?"Lucida Console, ":"")+"monospace"]]))}render(){const e=()=>{this.#On.read().then((({value:t,done:n})=>{n?this.#Cn.resolve():(this.#Sn??=t.lang,Object.assign(this.#_n,t.styles),this.#Yn(t.items),e())}),this.#Cn.reject)};return this.#On=this.#Pn.getReader(),zce.#qn.add(this),e(),this.#Cn.promise}update({viewport:e,onBefore:t=null}){const n=e.scale*(globalThis.devicePixelRatio||1),a=e.rotation;if(a!==this.#Rn&&(t?.(),this.#Rn=a,Dre(this.#An,{rotation:a})),n!==this.#Nn){t?.(),this.#Nn=n;const e={div:null,properties:null,ctx:zce.#Kn(this.#Sn)};for(const t of this.#Fn)e.properties=this.#In.get(t),e.div=t,this.#Xn(e)}}cancel(){const e=new ire("TextLayer task cancelled.");this.#On?.cancel(e).catch((()=>{})),this.#On=null,this.#Cn.reject(e)}get textDivs(){return this.#Fn}get textContentItemsStr(){return this.#Dn}#Yn(e){if(this.#Ln)return;this.#kn.ctx??=zce.#Kn(this.#Sn);const t=this.#Fn,n=this.#Dn;for(const a of e){if(t.length>1e5)return Xae("Ignoring additional textDivs for performance reasons."),void(this.#Ln=!0);if(void 0!==a.str)n.push(a.str),this.#Qn(a);else if("beginMarkedContentProps"===a.type||"beginMarkedContent"===a.type){const e=this.#me;this.#me=document.createElement("span"),this.#me.classList.add("markedContent"),null!==a.id&&this.#me.setAttribute("id",`${a.id}`),e.append(this.#me)}else"endMarkedContent"===a.type&&(this.#me=this.#me.parentNode)}}#Qn(e){const t=document.createElement("span"),n={angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL,fontSize:0};this.#Fn.push(t);const a=pre.transform(this.#jn,e.transform);let r=Math.atan2(a[1],a[0]);const o=this.#_n[e.fontName];o.vertical&&(r+=Math.PI/2);let c=this.#xn&&o.fontSubstitution||o.fontFamily;c=zce.fontFamilyMap.get(c)||c;const l=Math.hypot(a[2],a[3]),i=l*zce.#Jn(c,this.#Sn);let s,h;0===r?(s=a[4],h=a[5]-i):(s=a[4]+i*Math.sin(r),h=a[5]-i*Math.cos(r));const d="calc(var(--scale-factor)*",u=t.style;this.#me===this.#An?(u.left=`${(100*s/this.#Tn).toFixed(2)}%`,u.top=`${(100*h/this.#wn).toFixed(2)}%`):(u.left=`${d}${s.toFixed(2)}px)`,u.top=`${d}${h.toFixed(2)}px)`),u.fontSize=`${d}${(zce.#$n*l).toFixed(2)}px)`,u.fontFamily=c,n.fontSize=l,t.setAttribute("role","presentation"),t.textContent=e.str,t.dir=e.dir,this.#xn&&(t.dataset.fontName=o.fontSubstitutionLoadedName||e.fontName),0!==r&&(n.angle=r*(180/Math.PI));let m=!1;if(e.str.length>1)m=!0;else if(" "!==e.str&&e.transform[0]!==e.transform[3]){const t=Math.abs(e.transform[0]),n=Math.abs(e.transform[3]);t!==n&&Math.max(t,n)/Math.min(t,n)>1.5&&(m=!0)}if(m&&(n.canvasWidth=o.vertical?e.height:e.width),this.#In.set(t,n),this.#kn.div=t,this.#kn.properties=n,this.#Xn(this.#kn),n.hasText&&this.#me.append(t),n.hasEOL){const e=document.createElement("br");e.setAttribute("role","presentation"),this.#me.append(e)}}#Xn(e){const{div:t,properties:n,ctx:a}=e,{style:r}=t;let o="";if(zce.#$n>1&&(o=`scale(${1/zce.#$n})`),0!==n.canvasWidth&&n.hasText){const{fontFamily:e}=r,{canvasWidth:c,fontSize:l}=n;zce.#Zn(a,l*this.#Nn,e);const{width:i}=a.measureText(t.textContent);i>0&&(o=`scaleX(${c*this.#Nn/i}) ${o}`)}0!==n.angle&&(o=`rotate(${n.angle}deg) ${o}`),o.length>0&&(r.transform=o)}static cleanup(){if(!(this.#qn.size>0)){this.#Bn.clear();for(const{canvas:e}of this.#Un.values())e.remove();this.#Un.clear()}}static#Kn(e=null){let t=this.#Un.get(e||="");if(!t){const n=document.createElement("canvas");n.className="hiddenCanvasElement",n.lang=e,document.body.append(n),t=n.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#Un.set(e,t),this.#Wn.set(t,{size:0,family:""})}return t}static#Zn(e,t,n){const a=this.#Wn.get(e);t===a.size&&n===a.family||(e.font=`${t}px ${n}`,a.size=t,a.family=n)}static#Gn(){if(null!==this.#$n)return;const e=document.createElement("div");e.style.opacity=0,e.style.lineHeight=1,e.style.fontSize="1px",e.style.position="absolute",e.textContent="X",document.body.append(e),this.#$n=e.getBoundingClientRect().height,e.remove()}static#Jn(e,t){const n=this.#Bn.get(e);if(n)return n;const a=this.#Kn(t);a.canvas.width=a.canvas.height=fce,this.#Zn(a,fce,e);const r=a.measureText("");let o=r.fontBoundingBoxAscent,c=Math.abs(r.fontBoundingBoxDescent);if(o){const t=o/(o+c);return this.#Bn.set(e,t),a.canvas.width=a.canvas.height=0,t}a.strokeStyle="red",a.clearRect(0,0,fce,fce),a.strokeText("g",0,0);let l=a.getImageData(0,0,fce,fce).data;c=0;for(let e=l.length-1-3;e>=0;e-=4)if(l[e]>0){c=Math.ceil(e/4/fce);break}a.clearRect(0,0,fce,fce),a.strokeText("A",0,fce),l=a.getImageData(0,0,fce,fce).data,o=0;for(let e=0,t=l.length;e<t;e+=4)if(l[e]>0){o=fce-Math.floor(e/4/fce);break}a.canvas.width=a.canvas.height=0;const i=o?o/(o+c):.8;return this.#Bn.set(e,i),i}}class gce{static textContent(e){const t=[],n={items:t,styles:Object.create(null)};return function e(n){if(!n)return;let a=null;const r=n.name;if("#text"===r)a=n.value;else{if(!gce.shouldBuildText(r))return;n?.attributes?.textContent?a=n.attributes.textContent:n.value&&(a=n.value)}if(null!==a&&t.push({str:a}),n.children)for(const t of n.children)e(t)}(e),n}static shouldBuildText(e){return!("textarea"===e||"input"===e||"option"===e||"select"===e)}}const yce=65536,Mce=Nae?class extends hoe{_createCanvas(e,t){return yt.getBuiltinModule("module").createRequire("undefined"==typeof document&&"undefined"==typeof location?new(require("url").URL)("file:"+__filename).href:"undefined"==typeof document?location.href:document.currentScript&&"SCRIPT"===document.currentScript.tagName.toUpperCase()&&document.currentScript.src||new URL("index.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(e,t)}}:class extends hoe{constructor({ownerDocument:e=globalThis.document,enableHWA:t=!1}){super({enableHWA:t}),this._document=e}_createCanvas(e,t){const n=this._document.createElement("canvas");return n.width=e,n.height=t,n}},Ece=Nae?class extends doe{async _fetch(e){return foe(e)}}:uoe,bce=Nae?class extends moe{}:class extends moe{#ea;#ta;#na;#aa;#ra;#oa;#y=0;constructor({docId:e,ownerDocument:t=globalThis.document}){super(),this.#aa=e,this.#ra=t}get#E(){return this.#ta||=new Map}get#ca(){return this.#oa||=new Map}get#la(){if(!this.#na){const e=this.#ra.createElement("div"),{style:t}=e;t.visibility="hidden",t.contain="strict",t.width=t.height=0,t.position="absolute",t.top=t.left=0,t.zIndex=-1;const n=this.#ra.createElementNS(yre,"svg");n.setAttribute("width",0),n.setAttribute("height",0),this.#na=this.#ra.createElementNS(yre,"defs"),e.append(n),n.append(this.#na),this.#ra.body.append(e)}return this.#na}#ia(e){if(1===e.length){const t=e[0],n=new Array(256);for(let e=0;e<256;e++)n[e]=t[e]/255;const a=n.join(",");return[a,a,a]}const[t,n,a]=e,r=new Array(256),o=new Array(256),c=new Array(256);for(let e=0;e<256;e++)r[e]=t[e]/255,o[e]=n[e]/255,c[e]=a[e]/255;return[r.join(","),o.join(","),c.join(",")]}#sa(e){if(void 0===this.#ea){this.#ea="";const e=this.#ra.URL;e!==this.#ra.baseURI&&(Vre(e)?Xae('#createUrl: ignore "data:"-URL for performance reasons.'):this.#ea=e.split("#",1)[0])}return`url(${this.#ea}#${e})`}addFilter(e){if(!e)return"none";let t=this.#E.get(e);if(t)return t;const[n,a,r]=this.#ia(e),o=1===e.length?n:`${n}${a}${r}`;if(t=this.#E.get(o),t)return this.#E.set(e,t),t;const c=`g_${this.#aa}_transfer_map_${this.#y++}`,l=this.#sa(c);this.#E.set(e,l),this.#E.set(o,l);const i=this.#ha(c);return this.#da(n,a,r,i),l}addHCMFilter(e,t){const n=`${e}-${t}`,a="base";let r=this.#ca.get(a);if(r?.key===n)return r.url;if(r?(r.filter?.remove(),r.key=n,r.url="none",r.filter=null):(r={key:n,url:"none",filter:null},this.#ca.set(a,r)),!e||!t)return r.url;const o=this.#ua(e);e=pre.makeHexColor(...o);const c=this.#ua(t);if(t=pre.makeHexColor(...c),this.#la.style.color="","#000000"===e&&"#ffffff"===t||e===t)return r.url;const l=new Array(256);for(let e=0;e<=255;e++){const t=e/255;l[e]=t<=.03928?t/12.92:((t+.055)/1.055)**2.4}const i=l.join(","),s=`g_${this.#aa}_hcm_filter`,h=r.filter=this.#ha(s);this.#da(i,i,i,h),this.#ma(h);const d=(e,t)=>{const n=o[e]/255,a=c[e]/255,r=new Array(t+1);for(let e=0;e<=t;e++)r[e]=n+e/t*(a-n);return r.join(",")};return this.#da(d(0,5),d(1,5),d(2,5),h),r.url=this.#sa(s),r.url}addAlphaFilter(e){let t=this.#E.get(e);if(t)return t;const[n]=this.#ia([e]),a=`alpha_${n}`;if(t=this.#E.get(a),t)return this.#E.set(e,t),t;const r=`g_${this.#aa}_alpha_map_${this.#y++}`,o=this.#sa(r);this.#E.set(e,o),this.#E.set(a,o);const c=this.#ha(r);return this.#pa(n,c),o}addLuminosityFilter(e){let t,n,a=this.#E.get(e||"luminosity");if(a)return a;if(e?([t]=this.#ia([e]),n=`luminosity_${t}`):n="luminosity",a=this.#E.get(n),a)return this.#E.set(e,a),a;const r=`g_${this.#aa}_luminosity_map_${this.#y++}`,o=this.#sa(r);this.#E.set(e,o),this.#E.set(n,o);const c=this.#ha(r);return this.#va(c),e&&this.#pa(t,c),o}addHighlightHCMFilter(e,t,n,a,r){const o=`${t}-${n}-${a}-${r}`;let c=this.#ca.get(e);if(c?.key===o)return c.url;if(c?(c.filter?.remove(),c.key=o,c.url="none",c.filter=null):(c={key:o,url:"none",filter:null},this.#ca.set(e,c)),!t||!n)return c.url;const[l,i]=[t,n].map(this.#ua.bind(this));let s=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),h=Math.round(.2126*i[0]+.7152*i[1]+.0722*i[2]),[d,u]=[a,r].map(this.#ua.bind(this));h<s&&([s,h,d,u]=[h,s,u,d]),this.#la.style.color="";const m=(e,t,n)=>{const a=new Array(256),r=(h-s)/n,o=e/255,c=(t-e)/(255*n);let l=0;for(let e=0;e<=n;e++){const t=Math.round(s+e*r),n=o+e*c;for(let e=l;e<=t;e++)a[e]=n;l=t+1}for(let e=l;e<256;e++)a[e]=a[l-1];return a.join(",")},p=`g_${this.#aa}_hcm_${e}_filter`,v=c.filter=this.#ha(p);return this.#ma(v),this.#da(m(d[0],u[0],5),m(d[1],u[1],5),m(d[2],u[2],5),v),c.url=this.#sa(p),c.url}destroy(e=!1){e&&this.#oa?.size||(this.#na?.parentNode.parentNode.remove(),this.#na=null,this.#ta?.clear(),this.#ta=null,this.#oa?.clear(),this.#oa=null,this.#y=0)}#va(e){const t=this.#ra.createElementNS(yre,"feColorMatrix");t.setAttribute("type","matrix"),t.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),e.append(t)}#ma(e){const t=this.#ra.createElementNS(yre,"feColorMatrix");t.setAttribute("type","matrix"),t.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(t)}#ha(e){const t=this.#ra.createElementNS(yre,"filter");return t.setAttribute("color-interpolation-filters","sRGB"),t.setAttribute("id",e),this.#la.append(t),t}#fa(e,t,n){const a=this.#ra.createElementNS(yre,t);a.setAttribute("type","discrete"),a.setAttribute("tableValues",n),e.append(a)}#da(e,t,n,a){const r=this.#ra.createElementNS(yre,"feComponentTransfer");a.append(r),this.#fa(r,"feFuncR",e),this.#fa(r,"feFuncG",t),this.#fa(r,"feFuncB",n)}#pa(e,t){const n=this.#ra.createElementNS(yre,"feComponentTransfer");t.append(n),this.#fa(n,"feFuncA",e)}#ua(e){return this.#la.style.color=e,Rre(getComputedStyle(this.#la).getPropertyValue("color"))}},Hce=Nae?class extends poe{async _fetch(e){return foe(e)}}:voe;function Vce(e={}){"string"==typeof e||e instanceof URL?e={url:e}:(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const t=new Lce,{docId:n}=t,a=e.url?function(e){if(e instanceof URL)return e.href;try{return new URL(e,window.location).href}catch{if(Nae&&"string"==typeof e)return e}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(e.url):null,r=e.data?function(e){if(Nae&&void 0!==gL&&e instanceof gL)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if("string"==typeof e)return hre(e);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)||"object"==typeof e&&!isNaN(e?.length))return new Uint8Array(e);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(e.data):null,o=e.httpHeaders||null,c=!0===e.withCredentials,l=e.password??null,i=e.range instanceof xce?e.range:null,s=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:yce;let h=e.worker instanceof Tce?e.worker:null;const d=e.verbosity,u="string"!=typeof e.docBaseUrl||Vre(e.docBaseUrl)?null:e.docBaseUrl,m="string"==typeof e.cMapUrl?e.cMapUrl:null,p=!1!==e.cMapPacked,v=e.CMapReaderFactory||Ece,f="string"==typeof e.standardFontDataUrl?e.standardFontDataUrl:null,z=e.StandardFontDataFactory||Hce,g=!0!==e.stopAtErrors,y=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,M=!1!==e.isEvalSupported,E="boolean"==typeof e.isOffscreenCanvasSupported?e.isOffscreenCanvasSupported:!Nae,b="boolean"==typeof e.isImageDecoderSupported?e.isImageDecoderSupported:!Nae&&(ure.platform.isFirefox||!globalThis.chrome),H=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,V="boolean"==typeof e.disableFontFace?e.disableFontFace:Nae,C=!0===e.fontExtraProperties,L=!0===e.enableXfa,x=e.ownerDocument||globalThis.document,S=!0===e.disableRange,k=!0===e.disableStream,w=!0===e.disableAutoFetch,T=!0===e.pdfBug,O=e.CanvasFactory||Mce,A=e.FilterFactory||bce,R=!0===e.enableHWA,N=i?i.length:e.length??NaN,_="boolean"==typeof e.useSystemFonts?e.useSystemFonts:!Nae&&!V,D="boolean"==typeof e.useWorkerFetch?e.useWorkerFetch:v===uoe&&z===voe&&m&&f&&kre(m,document.baseURI)&&kre(f,document.baseURI);!function(e){Number.isInteger(e)&&(Gae=e)}(d);const P={canvasFactory:new O({ownerDocument:x,enableHWA:R}),filterFactory:new A({docId:n,ownerDocument:x}),cMapReaderFactory:D?null:new v({baseUrl:m,isCompressed:p}),standardFontDataFactory:D?null:new z({baseUrl:f})};if(!h){const e={verbosity:d,port:Uoe.workerPort};h=e.port?Tce.fromPort(e):new Tce(e),t._worker=h}const F={docId:n,apiVersion:"4.10.38",data:r,password:l,disableAutoFetch:w,rangeChunkSize:s,length:N,docBaseUrl:u,enableXfa:L,evaluatorOptions:{maxImageSize:y,disableFontFace:V,ignoreErrors:g,isEvalSupported:M,isOffscreenCanvasSupported:E,isImageDecoderSupported:b,canvasMaxAreaInBytes:H,fontExtraProperties:C,useSystemFonts:_,cMapUrl:D?m:null,standardFontDataUrl:D?f:null}},I={disableFontFace:V,fontExtraProperties:C,ownerDocument:x,pdfBug:T,styleElement:null,loadingParams:{disableAutoFetch:w,enableXfa:L}};return h.promise.then((function(){if(t.destroyed)throw new Error("Loading aborted");if(h.destroyed)throw new Error("Worker was destroyed");const e=h.messageHandler.sendWithPromise("GetDocRequest",F,r?[r.buffer]:null);let l;if(i)l=new Yoe(i,{disableRange:S,disableStream:k});else if(!r){if(!a)throw new Error("getDocument - no `url` parameter provided.");let e;if(Nae)if(kre(a)){if("undefined"==typeof fetch||"undefined"==typeof Response||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");e=oce}else e=mce;else e=kre(a)?oce:sce;l=new e({url:a,length:N,httpHeaders:o,withCredentials:c,rangeChunkSize:s,disableRange:S,disableStream:k})}return e.then((e=>{if(t.destroyed)throw new Error("Loading aborted");if(h.destroyed)throw new Error("Worker was destroyed");const a=new soe(n,e,h.port),r=new Oce(a,t,l,I,P);t._transport=r,a.send("Ready",null)}))})).catch(t._capability.reject),t}function Cce(e){return"object"==typeof e&&Number.isInteger(e?.num)&&e.num>=0&&Number.isInteger(e?.gen)&&e.gen>=0}class Lce{static#aa=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+Lce.#aa++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await(this._transport?.destroy())}catch(e){throw this._worker?.port&&delete this._worker._pendingDestroy,e}this._transport=null,this._worker?.destroy(),this._worker=null}}class xce{constructor(e,t,n=!1,a=null){this.length=e,this.initialData=t,this.progressiveDone=n,this.contentDispositionFilename=a,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(e){this._rangeListeners.push(e)}addProgressListener(e){this._progressListeners.push(e)}addProgressiveReadListener(e){this._progressiveReadListeners.push(e)}addProgressiveDoneListener(e){this._progressiveDoneListeners.push(e)}onDataRange(e,t){for(const n of this._rangeListeners)n(e,t)}onDataProgress(e,t){this._readyCapability.promise.then((()=>{for(const n of this._progressListeners)n(e,t)}))}onDataProgressiveRead(e){this._readyCapability.promise.then((()=>{for(const t of this._progressiveReadListeners)t(e)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(const e of this._progressiveDoneListeners)e()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(e,t){Qae("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class Sce{constructor(e,t){this._pdfInfo=e,this._transport=t}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return ere(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:e="display"}={}){const{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(t)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class kce{#za=null;#ga=!1;constructor(e,t,n,a=!1){this._pageIndex=e,this._pageInfo=t,this._transport=n,this._stats=a?new Sre:null,this._pdfBug=a,this.commonObjs=n.commonObjs,this.objs=new Rce,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:t=this.rotate,offsetX:n=0,offsetY:a=0,dontFlip:r=!1}={}){return new bre({viewBox:this.view,userUnit:this.userUnit,scale:e,rotation:t,offsetX:n,offsetY:a,dontFlip:r})}getAnnotations({intent:e="display"}={}){const{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return ere(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:e,viewport:t,intent:n="display",annotationMode:a=Fae.ENABLE,transform:r=null,background:o=null,optionalContentConfigPromise:c=null,annotationCanvasMap:l=null,pageColors:i=null,printAnnotationStorage:s=null,isEditing:h=!1}){this._stats?.time("Overall");const d=this._transport.getRenderingIntent(n,a,s,h),{renderingIntent:u,cacheKey:m}=d;this.#ga=!1,this.#ya(),c||=this._transport.getOptionalContentConfig(u);let p=this._intentStates.get(m);p||(p=Object.create(null),this._intentStates.set(m,p)),p.streamReaderCancelTimeout&&(clearTimeout(p.streamReaderCancelTimeout),p.streamReaderCancelTimeout=null);const v=!!(4&u);p.displayReadyCapability||(p.displayReadyCapability=Promise.withResolvers(),p.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(d));const f=e=>{p.renderTasks.delete(z),(this._maybeCleanupAfterRender||v)&&(this.#ga=!0),this.#Ma(!v),e?(z.capability.reject(e),this._abortOperatorList({intentState:p,reason:e instanceof Error?e:new Error(e)})):z.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},z=new _ce({callback:f,params:{canvasContext:e,viewport:t,transform:r,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:p.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!v,pdfBug:this._pdfBug,pageColors:i});(p.renderTasks||=new Set).add(z);const g=z.task;return Promise.all([p.displayReadyCapability.promise,c]).then((([e,t])=>{if(this.destroyed)f();else{if(this._stats?.time("Rendering"),!(t.renderingIntent&u))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");z.initializeGraphics({transparency:e,optionalContentConfig:t}),z.operatorListChanged()}})).catch(f),g}getOperatorList({intent:e="display",annotationMode:t=Fae.ENABLE,printAnnotationStorage:n=null,isEditing:a=!1}={}){const r=this._transport.getRenderingIntent(e,t,n,a,!0);let o,c=this._intentStates.get(r.cacheKey);return c||(c=Object.create(null),this._intentStates.set(r.cacheKey,c)),c.opListReadCapability||(o=Object.create(null),o.operatorListChanged=function(){c.operatorList.lastChunk&&(c.opListReadCapability.resolve(c.operatorList),c.renderTasks.delete(o))},c.opListReadCapability=Promise.withResolvers(),(c.renderTasks||=new Set).add(o),c.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(r)),c.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===e,disableNormalization:!0===t},{highWaterMark:100,size:e=>e.items.length})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then((e=>gce.textContent(e)));const t=this.streamTextContent(e);return new Promise((function(e,n){const a=t.getReader(),r={items:[],styles:Object.create(null),lang:null};!function t(){a.read().then((function({value:n,done:a}){a?e(r):(r.lang??=n.lang,Object.assign(r.styles,n.styles),r.items.push(...n.items),t())}),n)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const e=[];for(const t of this._intentStates.values())if(this._abortOperatorList({intentState:t,reason:new Error("Page was destroyed."),force:!0}),!t.opListReadCapability)for(const n of t.renderTasks)e.push(n.completed),n.cancel();return this.objs.clear(),this.#ga=!1,this.#ya(),Promise.all(e)}cleanup(e=!1){this.#ga=!0;const t=this.#Ma(!1);return e&&t&&(this._stats&&=new Sre),t}#Ma(e=!1){if(this.#ya(),!this.#ga||this.destroyed)return!1;if(e)return this.#za=setTimeout((()=>{this.#za=null,this.#Ma(!1)}),5e3),!1;for(const{renderTasks:e,operatorList:t}of this._intentStates.values())if(e.size>0||!t.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#ga=!1,!0}#ya(){this.#za&&(clearTimeout(this.#za),this.#za=null)}_startRenderPage(e,t){const n=this._intentStates.get(t);n&&(this._stats?.timeEnd("Page Request"),n.displayReadyCapability?.resolve(e))}_renderPageChunk(e,t){for(let n=0,a=e.length;n<a;n++)t.operatorList.fnArray.push(e.fnArray[n]),t.operatorList.argsArray.push(e.argsArray[n]);t.operatorList.lastChunk=e.lastChunk,t.operatorList.separateAnnots=e.separateAnnots;for(const e of t.renderTasks)e.operatorListChanged();e.lastChunk&&this.#Ma(!0)}_pumpOperatorList({renderingIntent:e,cacheKey:t,annotationStorageSerializable:n,modifiedIds:a}){const{map:r,transfer:o}=n,c=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:t,annotationStorage:r,modifiedIds:a},o).getReader(),l=this._intentStates.get(t);l.streamReader=c;const i=()=>{c.read().then((({value:e,done:t})=>{t?l.streamReader=null:this._transport.destroyed||(this._renderPageChunk(e,l),i())}),(e=>{if(l.streamReader=null,!this._transport.destroyed){if(l.operatorList){l.operatorList.lastChunk=!0;for(const e of l.renderTasks)e.operatorListChanged();this.#Ma(!0)}if(l.displayReadyCapability)l.displayReadyCapability.reject(e);else{if(!l.opListReadCapability)throw e;l.opListReadCapability.reject(e)}}}))};i()}_abortOperatorList({intentState:e,reason:t,force:n=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!n){if(e.renderTasks.size>0)return;if(t instanceof Hre){let n=100;return t.extraDelay>0&&t.extraDelay<1e3&&(n+=t.extraDelay),void(e.streamReaderCancelTimeout=setTimeout((()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})}),n))}}if(e.streamReader.cancel(new ire(t.message)).catch((()=>{})),e.streamReader=null,!this._transport.destroyed){for(const[t,n]of this._intentStates)if(n===e){this._intentStates.delete(t);break}this.cleanup()}}}get stats(){return this._stats}}class wce{#Ea=new Map;#ba=Promise.resolve();postMessage(e,t){const n={data:structuredClone(e,t?{transfer:t}:null)};this.#ba.then((()=>{for(const[e]of this.#Ea)e.call(this,n)}))}addEventListener(e,t,n=null){let a=null;if(n?.signal instanceof AbortSignal){const{signal:r}=n;if(r.aborted)return void Xae("LoopbackPort - cannot use an `aborted` signal.");const o=()=>this.removeEventListener(e,t);a=()=>r.removeEventListener("abort",o),r.addEventListener("abort",o)}this.#Ea.set(t,a)}removeEventListener(e,t){const n=this.#Ea.get(t);n?.(),this.#Ea.delete(t)}terminate(){for(const[,e]of this.#Ea)e?.();this.#Ea.clear()}}class Tce{static#Ha=0;static#Va=!1;static#Ca;static{Nae&&(this.#Va=!0,Uoe.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(e,t)=>{let n;try{if(n=new URL(e),!n.origin||"null"===n.origin)return!1}catch{return!1}const a=new URL(t,n);return n.origin===a.origin},this._createCDNWrapper=e=>{const t=`await import("${e}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))}}constructor({name:e=null,port:t=null,verbosity:n=Yae()}={}){if(this.name=e,this.destroyed=!1,this.verbosity=n,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,t){if(Tce.#Ca?.has(t))throw new Error("Cannot use more than one PDFWorker per port.");return(Tce.#Ca||=new WeakMap).set(t,this),void this._initializeFromPort(t)}this._initialize()}get promise(){return this._readyCapability.promise}#La(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(e){this._port=e,this._messageHandler=new soe("main","worker",e),this._messageHandler.on("ready",(function(){})),this.#La()}_initialize(){if(Tce.#Va||Tce.#xa)return void this._setupFakeWorker();let{workerSrc:e}=Tce;try{Tce._isSameOrigin(window.location.href,e)||(e=Tce._createCDNWrapper(new URL(e,window.location).href));const t=new Worker(e,{type:"module"}),n=new soe("main","worker",t),a=()=>{r.abort(),n.destroy(),t.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},r=new AbortController;t.addEventListener("error",(()=>{this._webWorker||a()}),{signal:r.signal}),n.on("test",(e=>{r.abort(),!this.destroyed&&e?(this._messageHandler=n,this._port=t,this._webWorker=t,this.#La()):a()})),n.on("ready",(e=>{if(r.abort(),this.destroyed)a();else try{o()}catch{this._setupFakeWorker()}}));const o=()=>{const e=new Uint8Array;n.send("test",e,[e.buffer])};return void o()}catch{Kae("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){Tce.#Va||(Xae("Setting up fake worker."),Tce.#Va=!0),Tce._setupFakeWorkerGlobal.then((e=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const t=new wce;this._port=t;const n="fake"+Tce.#Ha++,a=new soe(n+"_worker",n,t);e.setup(a,t),this._messageHandler=new soe(n,n+"_worker",t),this.#La()})).catch((e=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${e.message}".`))}))}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,Tce.#Ca?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(e){if(!e?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const t=this.#Ca?.get(e.port);if(t){if(t._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return t}return new Tce(e)}static get workerSrc(){if(Uoe.workerSrc)return Uoe.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#xa(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return ere(this,"_setupFakeWorkerGlobal",(async()=>this.#xa?this.#xa:(await import(this.workerSrc)).WorkerMessageHandler)())}}class Oce{#Sa=new Map;#ka=new Map;#wa=new Map;#Ta=new Map;#Oa=null;constructor(e,t,n,a,r){this.messageHandler=e,this.loadingTask=t,this.commonObjs=new Rce,this.fontLoader=new ooe({ownerDocument:a.ownerDocument,styleElement:a.styleElement}),this.loadingParams=a.loadingParams,this._params=a,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.cMapReaderFactory=r.cMapReaderFactory,this.standardFontDataFactory=r.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=n,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#Aa(e,t=null){const n=this.#Sa.get(e);if(n)return n;const a=this.messageHandler.sendWithPromise(e,t);return this.#Sa.set(e,a),a}get annotationStorage(){return ere(this,"annotationStorage",new aoe)}getRenderingIntent(e,t=Fae.ENABLE,n=null,a=!1,r=!1){let o=2,c=noe;switch(e){case"any":o=1;break;case"display":break;case"print":o=4;break;default:Xae(`getRenderingIntent - invalid intent: ${e}`)}const l=4&o&&n instanceof roe?n:this.annotationStorage;switch(t){case Fae.DISABLE:o+=64;break;case Fae.ENABLE:break;case Fae.ENABLE_FORMS:o+=16;break;case Fae.ENABLE_STORAGE:o+=32,c=l.serializable;break;default:Xae(`getRenderingIntent - invalid annotationMode: ${t}`)}a&&(o+=128),r&&(o+=256);const{ids:i,hash:s}=l.modifiedIds;return{renderingIntent:o,cacheKey:[o,c.hash,s].join("_"),annotationStorageSerializable:c,modifiedIds:i}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#Oa?.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const t of this.#ka.values())e.push(t._destroy());this.#ka.clear(),this.#wa.clear(),this.#Ta.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const t=this.messageHandler.sendWithPromise("Terminate",null);return e.push(t),Promise.all(e).then((()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#Sa.clear(),this.filterFactory.destroy(),zce.cleanup(),this._networkStream?.cancelAllRequests(new ire("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:e,loadingTask:t}=this;e.on("GetReader",((e,t)=>{Jae(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=e=>{this._lastProgress={loaded:e.loaded,total:e.total}},t.onPull=()=>{this._fullReader.read().then((function({value:e,done:n}){n?t.close():(Jae(e instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),t.enqueue(new Uint8Array(e),1,[e]))})).catch((e=>{t.error(e)}))},t.onCancel=e=>{this._fullReader.cancel(e),t.ready.catch((e=>{if(!this.destroyed)throw e}))}})),e.on("ReaderHeadersReady",(async e=>{await this._fullReader.headersReady;const{isStreamingSupported:n,isRangeSupported:a,contentLength:r}=this._fullReader;return n&&a||(this._lastProgress&&t.onProgress?.(this._lastProgress),this._fullReader.onProgress=e=>{t.onProgress?.({loaded:e.loaded,total:e.total})}),{isStreamingSupported:n,isRangeSupported:a,contentLength:r}})),e.on("GetRangeReader",((e,t)=>{Jae(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const n=this._networkStream.getRangeReader(e.begin,e.end);n?(t.onPull=()=>{n.read().then((function({value:e,done:n}){n?t.close():(Jae(e instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),t.enqueue(new Uint8Array(e),1,[e]))})).catch((e=>{t.error(e)}))},t.onCancel=e=>{n.cancel(e),t.ready.catch((e=>{if(!this.destroyed)throw e}))}):t.close()})),e.on("GetDoc",(({pdfInfo:e})=>{this._numPages=e.numPages,this._htmlForXfa=e.htmlForXfa,delete e.htmlForXfa,t._capability.resolve(new Sce(e,this))})),e.on("DocException",(e=>{t._capability.reject(ioe(e))})),e.on("PasswordRequest",(e=>{this.#Oa=Promise.withResolvers();try{if(!t.onPassword)throw ioe(e);const n=e=>{e instanceof Error?this.#Oa.reject(e):this.#Oa.resolve({password:e})};t.onPassword(n,e.code)}catch(e){this.#Oa.reject(e)}return this.#Oa.promise})),e.on("DataLoaded",(e=>{t.onProgress?.({loaded:e.length,total:e.length}),this.downloadInfoCapability.resolve(e)})),e.on("StartRenderPage",(e=>{this.destroyed||this.#ka.get(e.pageIndex)._startRenderPage(e.transparency,e.cacheKey)})),e.on("commonobj",(([t,n,a])=>{if(this.destroyed)return null;if(this.commonObjs.has(t))return null;switch(n){case"Font":const{disableFontFace:r,fontExtraProperties:o,pdfBug:c}=this._params;if("error"in a){const e=a.error;Xae(`Error during font loading: ${e}`),this.commonObjs.resolve(t,e);break}const l=c&&globalThis.FontInspector?.enabled?(e,t)=>globalThis.FontInspector.fontAdded(e,t):null,i=new coe(a,{disableFontFace:r,fontExtraProperties:o,inspectFont:l});this.fontLoader.bind(i).catch((()=>e.sendWithPromise("FontFallback",{id:t}))).finally((()=>{!o&&i.data&&(i.data=null),this.commonObjs.resolve(t,i)}));break;case"CopyLocalImage":const{imageRef:s}=a;Jae(s,"The imageRef must be defined.");for(const e of this.#ka.values())for(const[,n]of e.objs)if(n?.ref===s)return n.dataLen?(this.commonObjs.resolve(t,structuredClone(n)),n.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(t,a);break;default:throw new Error(`Got unknown common object type ${n}`)}return null})),e.on("obj",(([e,t,n,a])=>{if(this.destroyed)return;const r=this.#ka.get(t);if(!r.objs.has(e))if(0!==r._intentStates.size)switch(n){case"Image":r.objs.resolve(e,a),a?.dataLen>1e7&&(r._maybeCleanupAfterRender=!0);break;case"Pattern":r.objs.resolve(e,a);break;default:throw new Error(`Got unknown object type ${n}`)}else a?.bitmap?.close()})),e.on("DocProgress",(e=>{this.destroyed||t.onProgress?.({loaded:e.loaded,total:e.total})})),e.on("FetchBuiltInCMap",(async e=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(e)})),e.on("FetchStandardFontData",(async e=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(e)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&Xae("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:e,transfer:t}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:this._fullReader?.filename??null},t).finally((()=>{this.annotationStorage.resetModified()}))}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(new Error("Invalid page request."));const t=e-1,n=this.#wa.get(t);if(n)return n;const a=this.messageHandler.sendWithPromise("GetPage",{pageIndex:t}).then((n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&this.#Ta.set(n.refStr,e);const a=new kce(t,n,this,this._params.pdfBug);return this.#ka.set(t,a),a}));return this.#wa.set(t,a),a}getPageIndex(e){return Cce(e)?this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:t})}getFieldObjects(){return this.#Aa("GetFieldObjects")}hasJSActions(){return this.#Aa("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return"string"!=typeof e?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#Aa("GetDocJSActions")}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:e})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:e})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(e){return this.#Aa("GetOptionalContentConfig").then((t=>new Goe(t,e)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const e="GetMetadata",t=this.#Sa.get(e);if(t)return t;const n=this.messageHandler.sendWithPromise(e,null).then((e=>({info:e[0],metadata:e[1]?new Woe(e[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));return this.#Sa.set(e,n),n}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(e=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of this.#ka.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),this.#Sa.clear(),this.filterFactory.destroy(!0),zce.cleanup()}}cachedPageNumber(e){if(!Cce(e))return null;const t=0===e.gen?`${e.num}R`:`${e.num}R${e.gen}`;return this.#Ta.get(t)??null}}const Ace=Symbol("INITIAL_DATA");class Rce{#Ra=Object.create(null);#Na(e){return this.#Ra[e]||={...Promise.withResolvers(),data:Ace}}get(e,t=null){if(t){const n=this.#Na(e);return n.promise.then((()=>t(n.data))),null}const n=this.#Ra[e];if(!n||n.data===Ace)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return n.data}has(e){const t=this.#Ra[e];return!!t&&t.data!==Ace}delete(e){const t=this.#Ra[e];return!(!t||t.data===Ace||(delete this.#Ra[e],0))}resolve(e,t=null){const n=this.#Na(e);n.data=t,n.resolve()}clear(){for(const e in this.#Ra){const{data:t}=this.#Ra[e];t?.bitmap?.close()}this.#Ra=Object.create(null)}*[Symbol.iterator](){for(const e in this.#Ra){const{data:t}=this.#Ra[e];t!==Ace&&(yield[e,t])}}}class Nce{#_a=null;constructor(e){this.#_a=e,this.onContinue=null}get promise(){return this.#_a.capability.promise}cancel(e=0){this.#_a.cancel(null,e)}get separateAnnots(){const{separateAnnots:e}=this.#_a.operatorList;if(!e)return!1;const{annotationCanvasMap:t}=this.#_a;return e.form||e.canvas&&t?.size>0}}class _ce{#Da=null;static#Pa=new WeakSet;constructor({callback:e,params:t,objs:n,commonObjs:a,annotationCanvasMap:r,operatorList:o,pageIndex:c,canvasFactory:l,filterFactory:i,useRequestAnimationFrame:s=!1,pdfBug:h=!1,pageColors:d=null}){this.callback=e,this.params=t,this.objs=n,this.commonObjs=a,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=o,this._pageIndex=c,this.canvasFactory=l,this.filterFactory=i,this._pdfBug=h,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===s&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Nce(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=t.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:e=!1,optionalContentConfig:t}){if(this.cancelled)return;if(this._canvas){if(_ce.#Pa.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");_ce.#Pa.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:n,viewport:a,transform:r,background:o}=this.params;this.gfx=new Boe(n,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:t},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:r,viewport:a,transparency:e,background:o}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(e=null,t=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#Da&&(window.cancelAnimationFrame(this.#Da),this.#Da=null),_ce.#Pa.delete(this._canvas),this.callback(e||new Hre(`Rendering cancelled, page ${this._pageIndex+1}`,t))}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#Da=window.requestAnimationFrame((()=>{this.#Da=null,this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),_ce.#Pa.delete(this._canvas),this.callback())))}}const Dce="4.10.38",Pce="f9bea397f";function Fce(e){return Math.floor(255*Math.max(0,Math.min(1,e))).toString(16).padStart(2,"0")}function Ice(e){return Math.max(0,Math.min(255,255*e))}class jce{static CMYK_G([e,t,n,a]){return["G",1-Math.min(1,.3*e+.59*n+.11*t+a)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_rgb([e]){return[e=Ice(e),e,e]}static G_HTML([e]){const t=Fce(e);return`#${t}${t}${t}`}static RGB_G([e,t,n]){return["G",.3*e+.59*t+.11*n]}static RGB_rgb(e){return e.map(Ice)}static RGB_HTML(e){return`#${e.map(Fce).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([e,t,n,a]){return["RGB",1-Math.min(1,e+a),1-Math.min(1,n+a),1-Math.min(1,t+a)]}static CMYK_rgb([e,t,n,a]){return[Ice(1-Math.min(1,e+a)),Ice(1-Math.min(1,n+a)),Ice(1-Math.min(1,t+a))]}static CMYK_HTML(e){const t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,n]){const a=1-e,r=1-t,o=1-n;return["CMYK",a,r,o,Math.min(a,r,o)]}}class Bce{create(e,t,n=!1){if(e<=0||t<=0)throw new Error("Invalid SVG dimensions");const a=this._createSVG("svg:svg");return a.setAttribute("version","1.1"),n||(a.setAttribute("width",`${e}px`),a.setAttribute("height",`${t}px`)),a.setAttribute("preserveAspectRatio","none"),a.setAttribute("viewBox",`0 0 ${e} ${t}`),a}createElement(e){if("string"!=typeof e)throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){Qae("Abstract method `_createSVG` called.")}}class Uce extends Bce{_createSVG(e){return document.createElementNS(yre,e)}}class Wce{static setupStorage(e,t,n,a,r){const o=a.getValue(t,{value:null});switch(n.name){case"textarea":if(null!==o.value&&(e.textContent=o.value),"print"===r)break;e.addEventListener("input",(e=>{a.setValue(t,{value:e.target.value})}));break;case"input":if("radio"===n.attributes.type||"checkbox"===n.attributes.type){if(o.value===n.attributes.xfaOn?e.setAttribute("checked",!0):o.value===n.attributes.xfaOff&&e.removeAttribute("checked"),"print"===r)break;e.addEventListener("change",(e=>{a.setValue(t,{value:e.target.checked?e.target.getAttribute("xfaOn"):e.target.getAttribute("xfaOff")})}))}else{if(null!==o.value&&e.setAttribute("value",o.value),"print"===r)break;e.addEventListener("input",(e=>{a.setValue(t,{value:e.target.value})}))}break;case"select":if(null!==o.value){e.setAttribute("value",o.value);for(const e of n.children)e.attributes.value===o.value?e.attributes.selected=!0:e.attributes.hasOwnProperty("selected")&&delete e.attributes.selected}e.addEventListener("input",(e=>{const n=e.target.options,r=-1===n.selectedIndex?"":n[n.selectedIndex].value;a.setValue(t,{value:r})}))}}static setAttributes({html:e,element:t,storage:n=null,intent:a,linkService:r}){const{attributes:o}=t,c=e instanceof HTMLAnchorElement;"radio"===o.type&&(o.name=`${o.name}-${a}`);for(const[t,n]of Object.entries(o))if(null!=n)switch(t){case"class":n.length&&e.setAttribute(t,n.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",n);break;case"style":Object.assign(e.style,n);break;case"textContent":e.textContent=n;break;default:(!c||"href"!==t&&"newWindow"!==t)&&e.setAttribute(t,n)}c&&r.addLinkAttributes(e,o.href,o.newWindow),n&&o.dataId&&this.setupStorage(e,o.dataId,t,n)}static render(e){const t=e.annotationStorage,n=e.linkService,a=e.xfaHtml,r=e.intent||"display",o=document.createElement(a.name);a.attributes&&this.setAttributes({html:o,element:a,intent:r,linkService:n});const c="richText"!==r,l=e.div;if(l.append(o),e.viewport){const t=`matrix(${e.viewport.transform.join(",")})`;l.style.transform=t}c&&l.setAttribute("class","xfaLayer xfaFont");const i=[];if(0===a.children.length){if(a.value){const e=document.createTextNode(a.value);o.append(e),c&&gce.shouldBuildText(a.name)&&i.push(e)}return{textDivs:i}}const s=[[a,-1,o]];for(;s.length>0;){const[e,a,o]=s.at(-1);if(a+1===e.children.length){s.pop();continue}const l=e.children[++s.at(-1)[1]];if(null===l)continue;const{name:h}=l;if("#text"===h){const e=document.createTextNode(l.value);i.push(e),o.append(e);continue}const d=l?.attributes?.xmlns?document.createElementNS(l.attributes.xmlns,h):document.createElement(h);if(o.append(d),l.attributes&&this.setAttributes({html:d,element:l,storage:t,intent:r,linkService:n}),l.children?.length>0)s.push([l,-1,d]);else if(l.value){const e=document.createTextNode(l.value);c&&gce.shouldBuildText(h)&&i.push(e),d.append(e)}}for(const e of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))e.setAttribute("readOnly",!0);return{textDivs:i}}static update(e){const t=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=t,e.div.hidden=!1}}const $ce=1e3,qce=new WeakSet;function Gce(e){return{width:e[2]-e[0],height:e[3]-e[1]}}class Yce{static create(e){switch(e.data.annotationType){case 2:return new Xce(e);case 1:return new Qce(e);case 20:switch(e.data.fieldType){case"Tx":return new Zce(e);case"Btn":return e.data.radioButton?new nle(e):e.data.checkBox?new tle(e):new ale(e);case"Ch":return new rle(e);case"Sig":return new ele(e)}return new Jce(e);case 16:return new ole(e);case 3:return new lle(e);case 4:return new ile(e);case 5:return new sle(e);case 6:return new hle(e);case 8:return new dle(e);case 14:return new mle(e);case 15:return new ple(e);case 7:return new ule(e);case 9:return new vle(e);case 10:return new fle(e);case 11:return new zle(e);case 12:return new gle(e);case 13:return new yle(e);case 17:return new Mle(e);default:return new Kce(e)}}}class Kce{#Fa=null;#Ia=!1;#ja=null;constructor(e,{isRenderable:t=!1,ignoreBorder:n=!1,createQuadrilaterals:a=!1}={}){this.isRenderable=t,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,t&&(this.container=this._createContainer(n)),a&&this._createQuadrilaterals()}static _hasPopupData({titleObj:e,contentsObj:t,richText:n}){return!!(e?.str||t?.str||n?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Kce._hasPopupData(this.data)}updateEdited(e){if(!this.container)return;this.#Fa||={rect:this.data.rect.slice(0)};const{rect:t}=e;t&&this.#Ba(t),this.#ja?.popup.updateEdited(e)}resetEdited(){this.#Fa&&(this.#Ba(this.#Fa.rect),this.#ja?.popup.resetEdited(),this.#Fa=null)}#Ba(e){const{container:{style:t},data:{rect:n,rotation:a},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:o,pageX:c,pageY:l}}}}=this;n?.splice(0,4,...e);const{width:i,height:s}=Gce(e);t.left=100*(e[0]-c)/r+"%",t.top=100*(o-e[3]+l)/o+"%",0===a?(t.width=100*i/r+"%",t.height=100*s/o+"%"):this.setRotation(a)}_createContainer(e){const{data:t,parent:{page:n,viewport:a}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",t.id),this instanceof Jce||(r.tabIndex=$ce);const{style:o}=r;if(o.zIndex=this.parent.zIndex++,t.alternativeText&&(r.title=t.alternativeText),t.noRotate&&r.classList.add("norotate"),!t.rect||this instanceof ole){const{rotation:e}=t;return t.hasOwnCanvas||0===e||this.setRotation(e,r),r}const{width:c,height:l}=Gce(t.rect);if(!e&&t.borderStyle.width>0){o.borderWidth=`${t.borderStyle.width}px`;const e=t.borderStyle.horizontalCornerRadius,n=t.borderStyle.verticalCornerRadius;if(e>0||n>0){const t=`calc(${e}px * var(--scale-factor)) / calc(${n}px * var(--scale-factor))`;o.borderRadius=t}else if(this instanceof nle){const e=`calc(${c}px * var(--scale-factor)) / calc(${l}px * var(--scale-factor))`;o.borderRadius=e}switch(t.borderStyle.style){case 1:o.borderStyle="solid";break;case 2:o.borderStyle="dashed";break;case 3:Xae("Unimplemented border style: beveled");break;case 4:Xae("Unimplemented border style: inset");break;case 5:o.borderBottomStyle="solid"}const a=t.borderColor||null;a?(this.#Ia=!0,o.borderColor=pre.makeHexColor(0|a[0],0|a[1],0|a[2])):o.borderWidth=0}const i=pre.normalizeRect([t.rect[0],n.view[3]-t.rect[1]+n.view[1],t.rect[2],n.view[3]-t.rect[3]+n.view[1]]),{pageWidth:s,pageHeight:h,pageX:d,pageY:u}=a.rawDims;o.left=100*(i[0]-d)/s+"%",o.top=100*(i[1]-u)/h+"%";const{rotation:m}=t;return t.hasOwnCanvas||0===m?(o.width=100*c/s+"%",o.height=100*l/h+"%"):this.setRotation(m,r),r}setRotation(e,t=this.container){if(!this.data.rect)return;const{pageWidth:n,pageHeight:a}=this.parent.viewport.rawDims,{width:r,height:o}=Gce(this.data.rect);let c,l;e%180==0?(c=100*r/n,l=100*o/a):(c=100*o/n,l=100*r/a),t.style.width=`${c}%`,t.style.height=`${l}%`,t.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){const e=(e,t,n)=>{const a=n.detail[e],r=a[0],o=a.slice(1);n.target.style[t]=jce[`${r}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[t]:jce[`${r}_rgb`](o)})};return ere(this,"_commonActions",{display:e=>{const{display:t}=e.detail,n=t%2==1;this.container.style.visibility=n?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:n,noPrint:1===t||2===t})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:t}=e.detail;this.container.style.visibility=t?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:t,noView:t})},focus:e=>{setTimeout((()=>e.target.focus({preventScroll:!1})),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:t=>{e("bgColor","backgroundColor",t)},fillColor:t=>{e("fillColor","backgroundColor",t)},fgColor:t=>{e("fgColor","color",t)},textColor:t=>{e("textColor","color",t)},borderColor:t=>{e("borderColor","borderColor",t)},strokeColor:t=>{e("strokeColor","borderColor",t)},rotation:e=>{const t=e.detail.rotation;this.setRotation(t),this.annotationStorage.setValue(this.data.id,{rotation:t})}})}_dispatchEventFromSandbox(e,t){const n=this._commonActions;for(const a of Object.keys(t.detail)){const r=e[a]||n[a];r?.(t)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;const t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;const n=this._commonActions;for(const[a,r]of Object.entries(t)){const o=n[a];o&&(o({detail:{[a]:r},target:e}),delete t[a])}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:e}=this.data;if(!e)return;const[t,n,a,r]=this.data.rect.map((e=>Math.fround(e)));if(8===e.length){const[o,c,l,i]=e.subarray(2,6);if(a===o&&r===c&&t===l&&n===i)return}const{style:o}=this.container;let c;if(this.#Ia){const{borderColor:e,borderWidth:t}=o;o.borderWidth=0,c=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${e}" stroke-width="${t}">`],this.container.classList.add("hasBorder")}const l=a-t,i=r-n,{svgFactory:s}=this,h=s.createElement("svg");h.classList.add("quadrilateralsContainer"),h.setAttribute("width",0),h.setAttribute("height",0);const d=s.createElement("defs");h.append(d);const u=s.createElement("clipPath"),m=`clippath_${this.data.id}`;u.setAttribute("id",m),u.setAttribute("clipPathUnits","objectBoundingBox"),d.append(u);for(let n=2,a=e.length;n<a;n+=8){const a=e[n],o=e[n+1],h=e[n+2],d=e[n+3],m=s.createElement("rect"),p=(h-t)/l,v=(r-o)/i,f=(a-h)/l,z=(o-d)/i;m.setAttribute("x",p),m.setAttribute("y",v),m.setAttribute("width",f),m.setAttribute("height",z),u.append(m),c?.push(`<rect vector-effect="non-scaling-stroke" x="${p}" y="${v}" width="${f}" height="${z}"/>`)}this.#Ia&&(c.push("</g></svg>')"),o.backgroundImage=c.join("")),this.container.append(h),this.container.style.clipPath=`url(#${m})`}_createPopup(){const{data:e}=this,t=this.#ja=new ole({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]});this.parent.div.append(t.render())}render(){Qae("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){const n=[];if(this._fieldObjects){const a=this._fieldObjects[e];if(a)for(const{page:e,id:r,exportValues:o}of a){if(-1===e)continue;if(r===t)continue;const a="string"==typeof o?o:null,c=document.querySelector(`[data-element-id="${r}"]`);!c||qce.has(c)?n.push({id:r,exportValue:a,domElement:c}):Xae(`_getElementsByName - element not allowed: ${r}`)}return n}for(const a of document.getElementsByName(e)){const{exportValue:e}=a,r=a.getAttribute("data-element-id");r!==t&&qce.has(a)&&n.push({id:r,exportValue:e,domElement:a})}return n}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(const t of e)t.classList.add("highlightArea");else e.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:e,data:{id:t}}=this;this.container.addEventListener("dblclick",(()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:e,editId:t})}))}}class Xce extends Kce{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!!t?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:t}=this,n=document.createElement("a");n.setAttribute("data-element-id",e.id);let a=!1;return e.url?(t.addLinkAttributes(n,e.url,e.newWindow),a=!0):e.action?(this._bindNamedAction(n,e.action),a=!0):e.attachment?(this.#Ua(n,e.attachment,e.attachmentDest),a=!0):e.setOCGState?(this.#Wa(n,e.setOCGState),a=!0):e.dest?(this._bindLink(n,e.dest),a=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,e),a=!0),e.resetForm?(this._bindResetFormAction(n,e.resetForm),a=!0):this.isTooltipOnly&&!a&&(this._bindLink(n,""),a=!0)),this.container.classList.add("linkAnnotation"),a&&this.container.append(n),this.container}#$a(){this.container.setAttribute("data-internal-link","")}_bindLink(e,t){e.href=this.linkService.getDestinationHash(t),e.onclick=()=>(t&&this.linkService.goToDestination(t),!1),(t||""===t)&&this.#$a()}_bindNamedAction(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),this.#$a()}#Ua(e,t,n=null){e.href=this.linkService.getAnchorUrl(""),t.description&&(e.title=t.description),e.onclick=()=>(this.downloadManager?.openOrDownloadData(t.content,t.filename,n),!1),this.#$a()}#Wa(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(t),!1),this.#$a()}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl("");const n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const a of Object.keys(t.actions)){const r=n.get(a);r&&(e[r]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t.id,name:a}}),!1))}e.onclick||(e.onclick=()=>!1),this.#$a()}_bindResetFormAction(e,t){const n=e.onclick;if(n||(e.href=this.linkService.getAnchorUrl("")),this.#$a(),!this._fieldObjects)return Xae('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(n||(e.onclick=()=>!1));e.onclick=()=>{n?.();const{fields:e,refs:a,include:r}=t,o=[];if(0!==e.length||0!==a.length){const t=new Set(a);for(const n of e){const e=this._fieldObjects[n]||[];for(const{id:n}of e)t.add(n)}for(const e of Object.values(this._fieldObjects))for(const n of e)t.has(n.id)===r&&o.push(n)}else for(const e of Object.values(this._fieldObjects))o.push(...e);const c=this.annotationStorage,l=[];for(const e of o){const{id:t}=e;switch(l.push(t),e.type){case"text":{const n=e.defaultValue||"";c.setValue(t,{value:n});break}case"checkbox":case"radiobutton":{const n=e.defaultValue===e.exportValues;c.setValue(t,{value:n});break}case"combobox":case"listbox":{const n=e.defaultValue||"";c.setValue(t,{value:n});break}default:continue}const n=document.querySelector(`[data-element-id="${t}"]`);n&&(qce.has(n)?n.dispatchEvent(new Event("resetform")):Xae(`_bindResetFormAction - element not allowed: ${t}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:l,name:"ResetForm"}}),!1}}}class Qce extends Kce{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const e=document.createElement("img");return e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",e.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),e.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(e),this.container}}class Jce extends Kce{render(){return this.container}showElementAndHideCanvas(e){this.data.hasOwnCanvas&&("CANVAS"===e.previousSibling?.nodeName&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){return ure.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,n,a,r){n.includes("mouse")?e.addEventListener(n,(e=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:a,value:r(e),shift:e.shiftKey,modifier:this._getKeyModifier(e)}})})):e.addEventListener(n,(e=>{if("blur"===n){if(!t.focused||!e.relatedTarget)return;t.focused=!1}else if("focus"===n){if(t.focused)return;t.focused=!0}r&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:a,value:r(e)}})}))}_setEventListeners(e,t,n,a){for(const[r,o]of n)("Action"===o||this.data.actions?.[o])&&("Focus"!==o&&"Blur"!==o||(t||={focused:!1}),this._setEventListener(e,t,r,o,a),"Focus"!==o||this.data.actions?.Blur?"Blur"!==o||this.data.actions?.Focus||this._setEventListener(e,t,"focus","Focus",null):this._setEventListener(e,t,"blur","Blur",null))}_setBackgroundColor(e){const t=this.data.backgroundColor||null;e.style.backgroundColor=null===t?"transparent":pre.makeHexColor(t[0],t[1],t[2])}_setTextStyle(e){const{fontColor:t}=this.data.defaultAppearanceData,n=this.data.defaultAppearanceData.fontSize||9,a=e.style;let r;const o=e=>Math.round(10*e)/10;if(this.data.multiLine){const e=Math.abs(this.data.rect[3]-this.data.rect[1]-2),t=e/(Math.round(e/(Pae*n))||1);r=Math.min(n,o(t/Pae))}else{const e=Math.abs(this.data.rect[3]-this.data.rect[1]-2);r=Math.min(n,o(e/Pae))}a.fontSize=`calc(${r}px * var(--scale-factor))`,a.color=pre.makeHexColor(t[0],t[1],t[2]),null!==this.data.textAlignment&&(a.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute("required",!0):e.removeAttribute("required"),e.setAttribute("aria-required",t)}}class Zce extends Jce{constructor(e){super(e,{isRenderable:e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue})}setPropertyOnSiblings(e,t,n,a){const r=this.annotationStorage;for(const o of this._getElementsByName(e.name,e.id))o.domElement&&(o.domElement[t]=n),r.setValue(o.id,{[a]:n})}render(){const e=this.annotationStorage,t=this.data.id;this.container.classList.add("textWidgetAnnotation");let n=null;if(this.renderForms){const a=e.getValue(t,{value:this.data.fieldValue});let r=a.value||"";const o=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;o&&r.length>o&&(r=r.slice(0,o));let c=a.formattedValue||this.data.textContent?.join("\n")||null;c&&this.data.comb&&(c=c.replaceAll(/\s+/g,""));const l={userValue:r,formattedValue:c,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(n=document.createElement("textarea"),n.textContent=c??r,this.data.doNotScroll&&(n.style.overflowY="hidden")):(n=document.createElement("input"),n.type="text",n.setAttribute("value",c??r),this.data.doNotScroll&&(n.style.overflowX="hidden")),this.data.hasOwnCanvas&&(n.hidden=!0),qce.add(n),n.setAttribute("data-element-id",t),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=$ce,this._setRequired(n,this.data.required),o&&(n.maxLength=o),n.addEventListener("input",(a=>{e.setValue(t,{value:a.target.value}),this.setPropertyOnSiblings(n,"value",a.target.value,"value"),l.formattedValue=null})),n.addEventListener("resetform",(e=>{const t=this.data.defaultFieldValue??"";n.value=l.userValue=t,l.formattedValue=null}));let i=e=>{const{formattedValue:t}=l;null!=t&&(e.target.value=t),e.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){n.addEventListener("focus",(e=>{if(l.focused)return;const{target:t}=e;l.userValue&&(t.value=l.userValue),l.lastCommittedValue=t.value,l.commitKey=1,this.data.actions?.Focus||(l.focused=!0)})),n.addEventListener("updatefromsandbox",(n=>{this.showElementAndHideCanvas(n.target);const a={value(n){l.userValue=n.detail.value??"",e.setValue(t,{value:l.userValue.toString()}),n.target.value=l.userValue},formattedValue(n){const{formattedValue:a}=n.detail;l.formattedValue=a,null!=a&&n.target!==document.activeElement&&(n.target.value=a),e.setValue(t,{formattedValue:a})},selRange(e){e.target.setSelectionRange(...e.detail.selRange)},charLimit:n=>{const{charLimit:a}=n.detail,{target:r}=n;if(0===a)return void r.removeAttribute("maxLength");r.setAttribute("maxLength",a);let o=l.userValue;!o||o.length<=a||(o=o.slice(0,a),r.value=l.userValue=o,e.setValue(t,{value:o}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:o,willCommit:!0,commitKey:1,selStart:r.selectionStart,selEnd:r.selectionEnd}}))}};this._dispatchEventFromSandbox(a,n)})),n.addEventListener("keydown",(e=>{l.commitKey=1;let n=-1;if("Escape"===e.key?n=0:"Enter"!==e.key||this.data.multiLine?"Tab"===e.key&&(l.commitKey=3):n=2,-1===n)return;const{value:a}=e.target;l.lastCommittedValue!==a&&(l.lastCommittedValue=a,l.userValue=a,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:a,willCommit:!0,commitKey:n,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}))}));const a=i;i=null,n.addEventListener("blur",(e=>{if(!l.focused||!e.relatedTarget)return;this.data.actions?.Blur||(l.focused=!1);const{value:n}=e.target;l.userValue=n,l.lastCommittedValue!==n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:n,willCommit:!0,commitKey:l.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}),a(e)})),this.data.actions?.Keystroke&&n.addEventListener("beforeinput",(e=>{l.lastCommittedValue=null;const{data:n,target:a}=e,{value:r,selectionStart:o,selectionEnd:c}=a;let i=o,s=c;switch(e.inputType){case"deleteWordBackward":{const e=r.substring(0,o).match(/\w*[^\w]*$/);e&&(i-=e[0].length);break}case"deleteWordForward":{const e=r.substring(o).match(/^[^\w]*\w*/);e&&(s+=e[0].length);break}case"deleteContentBackward":o===c&&(i-=1);break;case"deleteContentForward":o===c&&(s+=1)}e.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:r,change:n||"",willCommit:!1,selStart:i,selEnd:s}})})),this._setEventListeners(n,l,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.value))}if(i&&n.addEventListener("blur",i),this.data.comb){const e=(this.data.rect[2]-this.data.rect[0])/o;n.classList.add("comb"),n.style.letterSpacing=`calc(${e}px * var(--scale-factor) - 1ch)`}}else n=document.createElement("div"),n.textContent=this.data.fieldValue,n.style.verticalAlign="middle",n.style.display="table-cell",this.data.hasOwnCanvas&&(n.hidden=!0);return this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class ele extends Jce{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class tle extends Jce{constructor(e){super(e,{isRenderable:e.renderForms})}render(){const e=this.annotationStorage,t=this.data,n=t.id;let a=e.getValue(n,{value:t.exportValue===t.fieldValue}).value;"string"==typeof a&&(a="Off"!==a,e.setValue(n,{value:a})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const r=document.createElement("input");return qce.add(r),r.setAttribute("data-element-id",n),r.disabled=t.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=t.fieldName,a&&r.setAttribute("checked",!0),r.setAttribute("exportValue",t.exportValue),r.tabIndex=$ce,r.addEventListener("change",(a=>{const{name:r,checked:o}=a.target;for(const a of this._getElementsByName(r,n)){const n=o&&a.exportValue===t.exportValue;a.domElement&&(a.domElement.checked=n),e.setValue(a.id,{value:n})}e.setValue(n,{value:o})})),r.addEventListener("resetform",(e=>{const n=t.defaultFieldValue||"Off";e.target.checked=n===t.exportValue})),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",(t=>{const a={value(t){t.target.checked="Off"!==t.detail.value,e.setValue(n,{value:t.target.checked})}};this._dispatchEventFromSandbox(a,t)})),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.checked))),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class nle extends Jce{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const e=this.annotationStorage,t=this.data,n=t.id;let a=e.getValue(n,{value:t.fieldValue===t.buttonValue}).value;if("string"==typeof a&&(a=a!==t.buttonValue,e.setValue(n,{value:a})),a)for(const a of this._getElementsByName(t.fieldName,n))e.setValue(a.id,{value:!1});const r=document.createElement("input");if(qce.add(r),r.setAttribute("data-element-id",n),r.disabled=t.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=t.fieldName,a&&r.setAttribute("checked",!0),r.tabIndex=$ce,r.addEventListener("change",(t=>{const{name:a,checked:r}=t.target;for(const t of this._getElementsByName(a,n))e.setValue(t.id,{value:!1});e.setValue(n,{value:r})})),r.addEventListener("resetform",(e=>{const n=t.defaultFieldValue;e.target.checked=null!=n&&n===t.buttonValue})),this.enableScripting&&this.hasJSActions){const a=t.buttonValue;r.addEventListener("updatefromsandbox",(t=>{const r={value:t=>{const r=a===t.detail.value;for(const a of this._getElementsByName(t.target.name)){const t=r&&a.id===n;a.domElement&&(a.domElement.checked=t),e.setValue(a.id,{value:t})}}};this._dispatchEventFromSandbox(r,t)})),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.checked))}return this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class ale extends Xce{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){const e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton");const t=e.lastChild;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener("updatefromsandbox",(e=>{this._dispatchEventFromSandbox({},e)}))),e}}class rle extends Jce{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const e=this.annotationStorage,t=this.data.id,n=e.getValue(t,{value:this.data.fieldValue}),a=document.createElement("select");qce.add(a),a.setAttribute("data-element-id",t),a.disabled=this.data.readOnly,this._setRequired(a,this.data.required),a.name=this.data.fieldName,a.tabIndex=$ce;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(a.size=this.data.options.length,this.data.multiSelect&&(a.multiple=!0)),a.addEventListener("resetform",(e=>{const t=this.data.defaultFieldValue;for(const e of a.options)e.selected=e.value===t}));for(const e of this.data.options){const t=document.createElement("option");t.textContent=e.displayValue,t.value=e.exportValue,n.value.includes(e.exportValue)&&(t.setAttribute("selected",!0),r=!1),a.append(t)}let o=null;if(r){const e=document.createElement("option");e.value=" ",e.setAttribute("hidden",!0),e.setAttribute("selected",!0),a.prepend(e),o=()=>{e.remove(),a.removeEventListener("input",o),o=null},a.addEventListener("input",o)}const c=e=>{const t=e?"value":"textContent",{options:n,multiple:r}=a;return r?Array.prototype.filter.call(n,(e=>e.selected)).map((e=>e[t])):-1===n.selectedIndex?null:n[n.selectedIndex][t]};let l=c(!1);const i=e=>{const t=e.target.options;return Array.prototype.map.call(t,(e=>({displayValue:e.textContent,exportValue:e.value})))};return this.enableScripting&&this.hasJSActions?(a.addEventListener("updatefromsandbox",(n=>{const r={value(n){o?.();const r=n.detail.value,i=new Set(Array.isArray(r)?r:[r]);for(const e of a.options)e.selected=i.has(e.value);e.setValue(t,{value:c(!0)}),l=c(!1)},multipleSelection(e){a.multiple=!0},remove(n){const r=a.options,o=n.detail.remove;r[o].selected=!1,a.remove(o),r.length>0&&-1===Array.prototype.findIndex.call(r,(e=>e.selected))&&(r[0].selected=!0),e.setValue(t,{value:c(!0),items:i(n)}),l=c(!1)},clear(n){for(;0!==a.length;)a.remove(0);e.setValue(t,{value:null,items:[]}),l=c(!1)},insert(n){const{index:r,displayValue:o,exportValue:s}=n.detail.insert,h=a.children[r],d=document.createElement("option");d.textContent=o,d.value=s,h?h.before(d):a.append(d),e.setValue(t,{value:c(!0),items:i(n)}),l=c(!1)},items(n){const{items:r}=n.detail;for(;0!==a.length;)a.remove(0);for(const e of r){const{displayValue:t,exportValue:n}=e,r=document.createElement("option");r.textContent=t,r.value=n,a.append(r)}a.options.length>0&&(a.options[0].selected=!0),e.setValue(t,{value:c(!0),items:i(n)}),l=c(!1)},indices(n){const a=new Set(n.detail.indices);for(const e of n.target.options)e.selected=a.has(e.index);e.setValue(t,{value:c(!0)}),l=c(!1)},editable(e){e.target.disabled=!e.detail.editable}};this._dispatchEventFromSandbox(r,n)})),a.addEventListener("input",(n=>{const a=c(!0),r=c(!1);e.setValue(t,{value:a}),n.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:l,change:r,changeEx:a,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(a,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(e=>e.target.value))):a.addEventListener("input",(function(n){e.setValue(t,{value:c(!0)})})),this.data.combo&&this._setTextStyle(a),this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class ole extends Kce{constructor(e){const{data:t,elements:n}=e;super(e,{isRenderable:Kce._hasPopupData(t)}),this.elements=n,this.popup=null}render(){this.container.classList.add("popupAnnotation");const e=this.popup=new cle({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),t=[];for(const n of this.elements)n.popup=e,n.container.ariaHasPopup="dialog",t.push(n.data.id),n.addHighlightArea();return this.container.setAttribute("aria-controls",t.map((e=>`${gre}${e}`)).join(",")),this.container}}class cle{#qa=this.#Ga.bind(this);#Ya=this.#Ka.bind(this);#Xa=this.#Qa.bind(this);#Ja=this.#Za.bind(this);#er=null;#me=null;#tr=null;#nr=null;#ar=null;#rr=null;#or=null;#cr=!1;#lr=null;#L=null;#ir=null;#sr=null;#hr=null;#Fa=null;#dr=!1;constructor({container:e,color:t,elements:n,titleObj:a,modificationDate:r,contentsObj:o,richText:c,parent:l,rect:i,parentRect:s,open:h}){this.#me=e,this.#hr=a,this.#tr=o,this.#sr=c,this.#rr=l,this.#er=t,this.#ir=i,this.#or=s,this.#ar=n,this.#nr=Ore.toDateObject(r),this.trigger=n.flatMap((e=>e.getElementsToTriggerPopup()));for(const e of this.trigger)e.addEventListener("click",this.#Ja),e.addEventListener("mouseenter",this.#Xa),e.addEventListener("mouseleave",this.#Ya),e.classList.add("popupTriggerArea");for(const e of n)e.container?.addEventListener("keydown",this.#qa);this.#me.hidden=!0,h&&this.#Za()}render(){if(this.#lr)return;const e=this.#lr=document.createElement("div");if(e.className="popup",this.#er){const t=e.style.outlineColor=pre.makeHexColor(...this.#er);if(CSS.supports("background-color","color-mix(in srgb, red 30%, white)"))e.style.backgroundColor=`color-mix(in srgb, ${t} 30%, white)`;else{const t=.7;e.style.backgroundColor=pre.makeHexColor(...this.#er.map((e=>Math.floor(t*(255-e)+e))))}}const t=document.createElement("span");t.className="header";const n=document.createElement("h1");if(t.append(n),({dir:n.dir,str:n.textContent}=this.#hr),e.append(t),this.#nr){const e=document.createElement("span");e.classList.add("popupDate"),e.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),e.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#nr.valueOf()})),t.append(e)}const a=this.#ur;if(a)Wce.render({xfaHtml:a,intent:"richText",div:e}),e.lastChild.classList.add("richText","popupContent");else{const t=this._formatContents(this.#tr);e.append(t)}this.#me.append(e)}get#ur(){const e=this.#sr,t=this.#tr;return!e?.str||t?.str&&t.str!==e.str?null:this.#sr.html||null}get#mr(){return this.#ur?.attributes?.style?.fontSize||0}get#pr(){return this.#ur?.attributes?.style?.color||null}#vr(e){const t=[],n={str:e,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:t}]}},a={style:{color:this.#pr,fontSize:this.#mr?`calc(${this.#mr}px * var(--scale-factor))`:""}};for(const n of e.split("\n"))t.push({name:"span",value:n,attributes:a});return n}_formatContents({str:e,dir:t}){const n=document.createElement("p");n.classList.add("popupContent"),n.dir=t;const a=e.split(/(?:\r\n?|\n)/);for(let e=0,t=a.length;e<t;++e){const r=a[e];n.append(document.createTextNode(r)),e<t-1&&n.append(document.createElement("br"))}return n}#Ga(e){e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||("Enter"===e.key||"Escape"===e.key&&this.#cr)&&this.#Za()}updateEdited({rect:e,popupContent:t}){this.#Fa||={contentsObj:this.#tr,richText:this.#sr},e&&(this.#L=null),t&&(this.#sr=this.#vr(t),this.#tr=null),this.#lr?.remove(),this.#lr=null}resetEdited(){this.#Fa&&(({contentsObj:this.#tr,richText:this.#sr}=this.#Fa),this.#Fa=null,this.#lr?.remove(),this.#lr=null,this.#L=null)}#fr(){if(null!==this.#L)return;const{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:n,pageX:a,pageY:r}}}=this.#rr;let o=!!this.#or,c=o?this.#or:this.#ir;for(const e of this.#ar)if(!c||null!==pre.intersect(e.data.rect,c)){c=e.data.rect,o=!0;break}const l=pre.normalizeRect([c[0],e[3]-c[1]+e[1],c[2],e[3]-c[3]+e[1]]),i=o?c[2]-c[0]+5:0,s=l[0]+i,h=l[1];this.#L=[100*(s-a)/t,100*(h-r)/n];const{style:d}=this.#me;d.left=`${this.#L[0]}%`,d.top=`${this.#L[1]}%`}#Za(){this.#cr=!this.#cr,this.#cr?(this.#Qa(),this.#me.addEventListener("click",this.#Ja),this.#me.addEventListener("keydown",this.#qa)):(this.#Ka(),this.#me.removeEventListener("click",this.#Ja),this.#me.removeEventListener("keydown",this.#qa))}#Qa(){this.#lr||this.render(),this.isVisible?this.#cr&&this.#me.classList.add("focused"):(this.#fr(),this.#me.hidden=!1,this.#me.style.zIndex=parseInt(this.#me.style.zIndex)+1e3)}#Ka(){this.#me.classList.remove("focused"),!this.#cr&&this.isVisible&&(this.#me.hidden=!0,this.#me.style.zIndex=parseInt(this.#me.style.zIndex)-1e3)}forceHide(){this.#dr=this.isVisible,this.#dr&&(this.#me.hidden=!0)}maybeShow(){this.#dr&&(this.#lr||this.#Qa(),this.#dr=!1,this.#me.hidden=!1)}get isVisible(){return!1===this.#me.hidden}}class lle extends Kce{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.textContent=e.data.textContent,this.textPosition=e.data.textPosition,this.annotationEditorType=Iae.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const e=document.createElement("div");e.classList.add("annotationTextContent"),e.setAttribute("role","comment");for(const t of this.textContent){const n=document.createElement("span");n.textContent=t,e.append(n)}this.container.append(e)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class ile extends Kce{#zr=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const e=this.data,{width:t,height:n}=Gce(e.rect),a=this.svgFactory.create(t,n,!0),r=this.#zr=this.svgFactory.createElement("svg:line");return r.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),r.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),r.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),r.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),r.setAttribute("stroke-width",e.borderStyle.width||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),a.append(r),this.container.append(a),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#zr}addHighlightArea(){this.container.classList.add("highlightArea")}}class sle extends Kce{#gr=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const e=this.data,{width:t,height:n}=Gce(e.rect),a=this.svgFactory.create(t,n,!0),r=e.borderStyle.width,o=this.#gr=this.svgFactory.createElement("svg:rect");return o.setAttribute("x",r/2),o.setAttribute("y",r/2),o.setAttribute("width",t-r),o.setAttribute("height",n-r),o.setAttribute("stroke-width",r||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),a.append(o),this.container.append(a),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#gr}addHighlightArea(){this.container.classList.add("highlightArea")}}class hle extends Kce{#yr=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const e=this.data,{width:t,height:n}=Gce(e.rect),a=this.svgFactory.create(t,n,!0),r=e.borderStyle.width,o=this.#yr=this.svgFactory.createElement("svg:ellipse");return o.setAttribute("cx",t/2),o.setAttribute("cy",n/2),o.setAttribute("rx",t/2-r/2),o.setAttribute("ry",n/2-r/2),o.setAttribute("stroke-width",r||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),a.append(o),this.container.append(a),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#yr}addHighlightArea(){this.container.classList.add("highlightArea")}}class dle extends Kce{#Mr=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:t,borderStyle:n,popupRef:a}}=this;if(!t)return this.container;const{width:r,height:o}=Gce(e),c=this.svgFactory.create(r,o,!0);let l=[];for(let n=0,a=t.length;n<a;n+=2){const a=t[n]-e[0],r=e[3]-t[n+1];l.push(`${a},${r}`)}l=l.join(" ");const i=this.#Mr=this.svgFactory.createElement(this.svgElementName);return i.setAttribute("points",l),i.setAttribute("stroke-width",n.width||1),i.setAttribute("stroke","transparent"),i.setAttribute("fill","transparent"),c.append(i),this.container.append(c),!a&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Mr}addHighlightArea(){this.container.classList.add("highlightArea")}}class ule extends dle{constructor(e){super(e),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class mle extends Kce{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class ple extends Kce{#Er=null;#br=[];constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?Iae.HIGHLIGHT:Iae.INK}#Hr(e,t){switch(e){case 90:return{transform:`rotate(90) translate(${-t[0]},${t[1]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};case 180:return{transform:`rotate(180) translate(${-t[2]},${t[1]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]};case 270:return{transform:`rotate(270) translate(${-t[2]},${t[3]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};default:return{transform:`translate(${-t[0]},${t[3]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]}}}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,rotation:t,inkLists:n,borderStyle:a,popupRef:r}}=this,{transform:o,width:c,height:l}=this.#Hr(t,e),i=this.svgFactory.create(c,l,!0),s=this.#Er=this.svgFactory.createElement("svg:g");i.append(s),s.setAttribute("stroke-width",a.width||1),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),s.setAttribute("stroke-miterlimit",10),s.setAttribute("stroke","transparent"),s.setAttribute("fill","transparent"),s.setAttribute("transform",o);for(let e=0,t=n.length;e<t;e++){const t=this.svgFactory.createElement(this.svgElementName);this.#br.push(t),t.setAttribute("points",n[e].join(",")),s.append(t)}return!r&&this.hasPopupData&&this._createPopup(),this.container.append(i),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);const{thickness:t,points:n,rect:a}=e,r=this.#Er;if(t>=0&&r.setAttribute("stroke-width",t||1),n)for(let e=0,t=this.#br.length;e<t;e++)this.#br[e].setAttribute("points",n[e].join(","));if(a){const{transform:e,width:t,height:n}=this.#Hr(this.data.rotation,a);r.parentElement.setAttribute("viewBox",`0 0 ${t} ${n}`),r.setAttribute("transform",e)}}getElementsToTriggerPopup(){return this.#br}addHighlightArea(){this.container.classList.add("highlightArea")}}class vle extends Kce{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=Iae.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class fle extends Kce{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class zle extends Kce{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class gle extends Kce{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class yle extends Kce{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=Iae.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class Mle extends Kce{#Vr=null;constructor(e){super(e,{isRenderable:!0});const{file:t}=this.data;this.filename=t.filename,this.content=t.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...t})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:t}=this;let n;t.hasAppearance||0===t.fillAlpha?n=document.createElement("div"):(n=document.createElement("img"),n.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(t.name)?"paperclip":"pushpin"}.svg`,t.fillAlpha&&t.fillAlpha<1&&(n.style=`filter: opacity(${Math.round(100*t.fillAlpha)}%);`)),n.addEventListener("dblclick",this.#Cr.bind(this)),this.#Vr=n;const{isMac:a}=ure.platform;return e.addEventListener("keydown",(e=>{"Enter"===e.key&&(a?e.metaKey:e.ctrlKey)&&this.#Cr()})),!t.popupRef&&this.hasPopupData?this._createPopup():n.classList.add("popupTriggerArea"),e.append(n),e}getElementsToTriggerPopup(){return this.#Vr}addHighlightArea(){this.container.classList.add("highlightArea")}#Cr(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class Ele{#Lr=null;#xr=null;#Sr=new Map;#kr=null;constructor({div:e,accessibilityManager:t,annotationCanvasMap:n,annotationEditorUIManager:a,page:r,viewport:o,structTreeLayer:c}){this.div=e,this.#Lr=t,this.#xr=n,this.#kr=c||null,this.page=r,this.viewport=o,this.zIndex=0,this._annotationEditorUIManager=a}hasEditableAnnotations(){return this.#Sr.size>0}async#wr(e,t){const n=e.firstChild||e,a=n.id=`${gre}${t}`,r=await(this.#kr?.getAriaAttributes(a));if(r)for(const[e,t]of r)n.setAttribute(e,t);this.div.append(e),this.#Lr?.moveElementInDOM(this.div,e,n,!1)}async render(e){const{annotations:t}=e,n=this.div;Dre(n,this.viewport);const a=new Map,r={data:null,layer:n,linkService:e.linkService,downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:!1!==e.renderForms,svgFactory:new Uce,annotationStorage:e.annotationStorage||new aoe,enableScripting:!0===e.enableScripting,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(const e of t){if(e.noHTML)continue;const t=16===e.annotationType;if(t){const t=a.get(e.id);if(!t)continue;r.elements=t}else{const{width:t,height:n}=Gce(e.rect);if(t<=0||n<=0)continue}r.data=e;const n=Yce.create(r);if(!n.isRenderable)continue;if(!t&&e.popupRef){const t=a.get(e.popupRef);t?t.push(n):a.set(e.popupRef,[n])}const o=n.render();e.hidden&&(o.style.visibility="hidden"),await this.#wr(o,e.id),n._isEditable&&(this.#Sr.set(n.data.id,n),this._annotationEditorUIManager?.renderAnnotationElement(n))}this.#Tr()}update({viewport:e}){const t=this.div;this.viewport=e,Dre(t,{rotation:e.rotation}),this.#Tr(),t.hidden=!1}#Tr(){if(!this.#xr)return;const e=this.div;for(const[t,n]of this.#xr){const a=e.querySelector(`[data-annotation-id="${t}"]`);if(!a)continue;n.className="annotationContent";const{firstChild:r}=a;r?"CANVAS"===r.nodeName?r.replaceWith(n):r.classList.contains("annotationContent")?r.after(n):r.before(n):a.append(n)}this.#xr.clear()}getEditableAnnotations(){return Array.from(this.#Sr.values())}getEditableAnnotation(e){return this.#Sr.get(e)}}const ble=/\r\n?|\n/g;class Hle extends Xre{#er;#Or="";#Ar=`${this.id}-editor`;#Rr=null;#mr;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const e=Hle.prototype,t=e=>e.isEmpty(),n=Gre.TRANSLATE_SMALL,a=Gre.TRANSLATE_BIG;return ere(this,"_keyboardManager",new $re([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],e.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],e._translateEmpty,{args:[-n,0],checker:t}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-a,0],checker:t}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[n,0],checker:t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[a,0],checker:t}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-n],checker:t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-a],checker:t}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,n],checker:t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,a],checker:t}]]))}static _type="freetext";static _editorType=Iae.FREETEXT;constructor(e){super({...e,name:"freeTextEditor"}),this.#er=e.color||Hle._defaultColor||Xre._defaultLineColor,this.#mr=e.fontSize||Hle._defaultFontSize}static initialize(e,t){Xre.initialize(e,t);const n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,t){switch(e){case jae.FREETEXT_SIZE:Hle._defaultFontSize=t;break;case jae.FREETEXT_COLOR:Hle._defaultColor=t}}updateParams(e,t){switch(e){case jae.FREETEXT_SIZE:this.#Nr(t);break;case jae.FREETEXT_COLOR:this.#_r(t)}}static get defaultPropertiesToUpdate(){return[[jae.FREETEXT_SIZE,Hle._defaultFontSize],[jae.FREETEXT_COLOR,Hle._defaultColor||Xre._defaultLineColor]]}get propertiesToUpdate(){return[[jae.FREETEXT_SIZE,this.#mr],[jae.FREETEXT_COLOR,this.#er]]}#Nr(e){const t=e=>{this.editorDiv.style.fontSize=`calc(${e}px * var(--scale-factor))`,this.translate(0,-(e-this.#mr)*this.parentScale),this.#mr=e,this.#Dr()},n=this.#mr;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:jae.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#_r(e){const t=e=>{this.#er=this.editorDiv.style.color=e},n=this.#er;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:jae.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(e,t){this._uiManager.translateSelectedEditors(e,t,!0)}getInitialTranslation(){const e=this.parentScale;return[-Hle._internalPadding*e,-(Hle._internalPadding+this.#mr)*e]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(Iae.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#Rr=new AbortController;const e=this._uiManager.combinedSignal(this.#Rr);this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#Ar),this._isDraggable=!0,this.#Rr?.abort(),this.#Rr=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#Pr(){const e=[];this.editorDiv.normalize();let t=null;for(const n of this.editorDiv.childNodes)t?.nodeType===Node.TEXT_NODE&&"BR"===n.nodeName||(e.push(Hle.#Fr(n)),t=n);return e.join("\n")}#Dr(){const[e,t]=this.parentDimensions;let n;if(this.isAttachedToDOM)n=this.div.getBoundingClientRect();else{const{currentLayer:e,div:t}=this,a=t.style.display,r=t.classList.contains("hidden");t.classList.remove("hidden"),t.style.display="hidden",e.div.append(this.div),n=t.getBoundingClientRect(),t.remove(),t.style.display=a,t.classList.toggle("hidden",r)}this.rotation%180==this.parentRotation%180?(this.width=n.width/e,this.height=n.height/t):(this.width=n.height/e,this.height=n.width/t),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=this.#Or,t=this.#Or=this.#Pr().trimEnd();if(e===t)return;const n=e=>{this.#Or=e,e?(this.#Ir(),this._uiManager.rebuild(this),this.#Dr()):this.remove()};this.addCommands({cmd:()=>{n(t)},undo:()=>{n(e)},mustExec:!1}),this.#Dr()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(e){this.enterInEditMode()}keydown(e){e.target===this.div&&"Enter"===e.key&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){Hle._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let e,t;this.width&&(e=this.x,t=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#Ar),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:n}=this.editorDiv;if(n.fontSize=`calc(${this.#mr}px * var(--scale-factor))`,n.color=this.#er,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),jre(this,this.div,["dblclick","keydown"]),this.width){const[n,a]=this.parentDimensions;if(this.annotationElementId){const{position:r}=this._initialData;let[o,c]=this.getInitialTranslation();[o,c]=this.pageTranslationToScreen(o,c);const[l,i]=this.pageDimensions,[s,h]=this.pageTranslation;let d,u;switch(this.rotation){case 0:d=e+(r[0]-s)/l,u=t+this.height-(r[1]-h)/i;break;case 90:d=e+(r[0]-s)/l,u=t-(r[1]-h)/i,[o,c]=[c,-o];break;case 180:d=e-this.width+(r[0]-s)/l,u=t-(r[1]-h)/i,[o,c]=[-o,-c];break;case 270:d=e+(r[0]-s-this.height*i)/l,u=t+(r[1]-h-this.width*l)/i,[o,c]=[-c,o]}this.setAt(d*n,u*a,o,c)}else this.setAt(e*n,t*a,this.width*n,this.height*a);this.#Ir(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#Fr(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(ble,"")}editorDivPaste(e){const t=e.clipboardData||window.clipboardData,{types:n}=t;if(1===n.length&&"text/plain"===n[0])return;e.preventDefault();const a=Hle.#jr(t.getData("text")||"").replaceAll(ble,"\n");if(!a)return;const r=window.getSelection();if(!r.rangeCount)return;this.editorDiv.normalize(),r.deleteFromDocument();const o=r.getRangeAt(0);if(!a.includes("\n"))return o.insertNode(document.createTextNode(a)),this.editorDiv.normalize(),void r.collapseToStart();const{startContainer:c,startOffset:l}=o,i=[],s=[];if(c.nodeType===Node.TEXT_NODE){const e=c.parentElement;if(s.push(c.nodeValue.slice(l).replaceAll(ble,"")),e!==this.editorDiv){let t=i;for(const n of this.editorDiv.childNodes)n!==e?t.push(Hle.#Fr(n)):t=s}i.push(c.nodeValue.slice(0,l).replaceAll(ble,""))}else if(c===this.editorDiv){let e=i,t=0;for(const n of this.editorDiv.childNodes)t++===l&&(e=s),e.push(Hle.#Fr(n))}this.#Or=`${i.join("\n")}${a}${s.join("\n")}`,this.#Ir();const h=new Range;let d=i.reduce(((e,t)=>e+t.length),0);for(const{firstChild:e}of this.editorDiv.childNodes)if(e.nodeType===Node.TEXT_NODE){const t=e.nodeValue.length;if(d<=t){h.setStart(e,d),h.setEnd(e,d);break}d-=t}r.removeAllRanges(),r.addRange(h)}#Ir(){if(this.editorDiv.replaceChildren(),this.#Or)for(const e of this.#Or.split("\n")){const t=document.createElement("div");t.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(t)}}#Br(){return this.#Or.replaceAll(" "," ")}static#jr(e){return e.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static async deserialize(e,t,n){let a=null;if(e instanceof lle){const{data:{defaultAppearanceData:{fontSize:t,fontColor:n},rect:r,rotation:o,id:c,popupRef:l},textContent:i,textPosition:s,parent:{page:{pageNumber:h}}}=e;if(!i||0===i.length)return null;a=e={annotationType:Iae.FREETEXT,color:Array.from(n),fontSize:t,value:i.join("\n"),position:s,pageIndex:h-1,rect:r.slice(0),rotation:o,id:c,deleted:!1,popupRef:l}}const r=await super.deserialize(e,t,n);return r.#mr=e.fontSize,r.#er=pre.makeHexColor(...e.color),r.#Or=Hle.#jr(e.value),r.annotationElementId=e.id||null,r._initialData=a,r}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const t=Hle._internalPadding*this.parentScale,n=this.getRect(t,t),a=Xre._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#er),r={annotationType:Iae.FREETEXT,color:a,fontSize:this.#mr,value:this.#Br(),pageIndex:this.pageIndex,rect:n,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?r:this.annotationElementId&&!this.#Ur(r)?null:(r.id=this.annotationElementId,r)}#Ur(e){const{value:t,fontSize:n,color:a,pageIndex:r}=this._initialData;return this._hasBeenMoved||e.value!==t||e.fontSize!==n||e.color.some(((e,t)=>e!==a[t]))||e.pageIndex!==r}renderAnnotationElement(e){const t=super.renderAnnotationElement(e);if(this.deleted)return t;const{style:n}=t;n.fontSize=`calc(${this.#mr}px * var(--scale-factor))`,n.color=this.#er,t.replaceChildren();for(const e of this.#Or.split("\n")){const n=document.createElement("div");n.append(e?document.createTextNode(e):document.createElement("br")),t.append(n)}const a=Hle._internalPadding*this.parentScale;return e.updateEdited({rect:this.getRect(a,a),popupContent:this.#Or}),t}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}}class Vle{static PRECISION=1e-4;toSVGPath(){Qae("Abstract method `toSVGPath` must be implemented.")}get box(){Qae("Abstract getter `box` must be implemented.")}serialize(e,t){Qae("Abstract method `serialize` must be implemented.")}static _rescale(e,t,n,a,r,o){o||=new Float32Array(e.length);for(let c=0,l=e.length;c<l;c+=2)o[c]=t+e[c]*a,o[c+1]=n+e[c+1]*r;return o}static _rescaleAndSwap(e,t,n,a,r,o){o||=new Float32Array(e.length);for(let c=0,l=e.length;c<l;c+=2)o[c]=t+e[c+1]*a,o[c+1]=n+e[c]*r;return o}static _translate(e,t,n,a){a||=new Float32Array(e.length);for(let r=0,o=e.length;r<o;r+=2)a[r]=t+e[r],a[r+1]=n+e[r+1];return a}static svgRound(e){return Math.round(1e4*e)}static _normalizePoint(e,t,n,a,r){switch(r){case 90:return[1-t/n,e/a];case 180:return[1-e/n,1-t/a];case 270:return[t/n,1-e/a];default:return[e/n,t/a]}}static _normalizePagePoint(e,t,n){switch(n){case 90:return[1-t,e];case 180:return[1-e,1-t];case 270:return[t,1-e];default:return[e,t]}}static createBezierPoints(e,t,n,a,r,o){return[(e+5*n)/6,(t+5*a)/6,(5*n+r)/6,(5*a+o)/6,(n+r)/2,(a+o)/2]}}class Cle{#Wr;#$r=[];#qr;#Gr;#Yr=[];#Kr=new Float32Array(18);#Xr;#Qr;#Jr;#Zr;#eo;#to;#no=[];static#ao=8;static#ro=2;static#oo=Cle.#ao+Cle.#ro;constructor({x:e,y:t},n,a,r,o,c=0){this.#Wr=n,this.#to=r*a,this.#Gr=o,this.#Kr.set([NaN,NaN,NaN,NaN,e,t],6),this.#qr=c,this.#Zr=Cle.#ao*a,this.#Jr=Cle.#oo*a,this.#eo=a,this.#no.push(e,t)}isEmpty(){return isNaN(this.#Kr[8])}#co(){const e=this.#Kr.subarray(4,6),t=this.#Kr.subarray(16,18),[n,a,r,o]=this.#Wr;return[(this.#Xr+(e[0]-t[0])/2-n)/r,(this.#Qr+(e[1]-t[1])/2-a)/o,(this.#Xr+(t[0]-e[0])/2-n)/r,(this.#Qr+(t[1]-e[1])/2-a)/o]}add({x:e,y:t}){this.#Xr=e,this.#Qr=t;const[n,a,r,o]=this.#Wr;let[c,l,i,s]=this.#Kr.subarray(8,12);const h=e-i,d=t-s,u=Math.hypot(h,d);if(u<this.#Jr)return!1;const m=u-this.#Zr,p=m/u,v=p*h,f=p*d;let z=c,g=l;c=i,l=s,i+=v,s+=f,this.#no?.push(e,t);const y=v/m,M=-f/m*this.#to,E=y*this.#to;return this.#Kr.set(this.#Kr.subarray(2,8),0),this.#Kr.set([i+M,s+E],4),this.#Kr.set(this.#Kr.subarray(14,18),12),this.#Kr.set([i-M,s-E],16),isNaN(this.#Kr[6])?(0===this.#Yr.length&&(this.#Kr.set([c+M,l+E],2),this.#Yr.push(NaN,NaN,NaN,NaN,(c+M-n)/r,(l+E-a)/o),this.#Kr.set([c-M,l-E],14),this.#$r.push(NaN,NaN,NaN,NaN,(c-M-n)/r,(l-E-a)/o)),this.#Kr.set([z,g,c,l,i,s],6),!this.isEmpty()):(this.#Kr.set([z,g,c,l,i,s],6),Math.abs(Math.atan2(g-l,z-c)-Math.atan2(f,v))<Math.PI/2?([c,l,i,s]=this.#Kr.subarray(2,6),this.#Yr.push(NaN,NaN,NaN,NaN,((c+i)/2-n)/r,((l+s)/2-a)/o),[c,l,z,g]=this.#Kr.subarray(14,18),this.#$r.push(NaN,NaN,NaN,NaN,((z+c)/2-n)/r,((g+l)/2-a)/o),!0):([z,g,c,l,i,s]=this.#Kr.subarray(0,6),this.#Yr.push(((z+5*c)/6-n)/r,((g+5*l)/6-a)/o,((5*c+i)/6-n)/r,((5*l+s)/6-a)/o,((c+i)/2-n)/r,((l+s)/2-a)/o),[i,s,c,l,z,g]=this.#Kr.subarray(12,18),this.#$r.push(((z+5*c)/6-n)/r,((g+5*l)/6-a)/o,((5*c+i)/6-n)/r,((5*l+s)/6-a)/o,((c+i)/2-n)/r,((l+s)/2-a)/o),!0))}toSVGPath(){if(this.isEmpty())return"";const e=this.#Yr,t=this.#$r;if(isNaN(this.#Kr[6])&&!this.isEmpty())return this.#lo();const n=[];n.push(`M${e[4]} ${e[5]}`);for(let t=6;t<e.length;t+=6)isNaN(e[t])?n.push(`L${e[t+4]} ${e[t+5]}`):n.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);this.#io(n);for(let e=t.length-6;e>=6;e-=6)isNaN(t[e])?n.push(`L${t[e+4]} ${t[e+5]}`):n.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);return this.#so(n),n.join(" ")}#lo(){const[e,t,n,a]=this.#Wr,[r,o,c,l]=this.#co();return`M${(this.#Kr[2]-e)/n} ${(this.#Kr[3]-t)/a} L${(this.#Kr[4]-e)/n} ${(this.#Kr[5]-t)/a} L${r} ${o} L${c} ${l} L${(this.#Kr[16]-e)/n} ${(this.#Kr[17]-t)/a} L${(this.#Kr[14]-e)/n} ${(this.#Kr[15]-t)/a} Z`}#so(e){const t=this.#$r;e.push(`L${t[4]} ${t[5]} Z`)}#io(e){const[t,n,a,r]=this.#Wr,o=this.#Kr.subarray(4,6),c=this.#Kr.subarray(16,18),[l,i,s,h]=this.#co();e.push(`L${(o[0]-t)/a} ${(o[1]-n)/r} L${l} ${i} L${s} ${h} L${(c[0]-t)/a} ${(c[1]-n)/r}`)}newFreeDrawOutline(e,t,n,a,r,o){return new Lle(e,t,n,a,r,o)}getOutlines(){const e=this.#Yr,t=this.#$r,n=this.#Kr,[a,r,o,c]=this.#Wr,l=new Float32Array((this.#no?.length??0)+2);for(let e=0,t=l.length-2;e<t;e+=2)l[e]=(this.#no[e]-a)/o,l[e+1]=(this.#no[e+1]-r)/c;if(l[l.length-2]=(this.#Xr-a)/o,l[l.length-1]=(this.#Qr-r)/c,isNaN(n[6])&&!this.isEmpty())return this.#ho(l);const i=new Float32Array(this.#Yr.length+24+this.#$r.length);let s=e.length;for(let t=0;t<s;t+=2)isNaN(e[t])?i[t]=i[t+1]=NaN:(i[t]=e[t],i[t+1]=e[t+1]);s=this.#do(i,s);for(let e=t.length-6;e>=6;e-=6)for(let n=0;n<6;n+=2)isNaN(t[e+n])?(i[s]=i[s+1]=NaN,s+=2):(i[s]=t[e+n],i[s+1]=t[e+n+1],s+=2);return this.#uo(i,s),this.newFreeDrawOutline(i,l,this.#Wr,this.#eo,this.#qr,this.#Gr)}#ho(e){const t=this.#Kr,[n,a,r,o]=this.#Wr,[c,l,i,s]=this.#co(),h=new Float32Array(36);return h.set([NaN,NaN,NaN,NaN,(t[2]-n)/r,(t[3]-a)/o,NaN,NaN,NaN,NaN,(t[4]-n)/r,(t[5]-a)/o,NaN,NaN,NaN,NaN,c,l,NaN,NaN,NaN,NaN,i,s,NaN,NaN,NaN,NaN,(t[16]-n)/r,(t[17]-a)/o,NaN,NaN,NaN,NaN,(t[14]-n)/r,(t[15]-a)/o],0),this.newFreeDrawOutline(h,e,this.#Wr,this.#eo,this.#qr,this.#Gr)}#uo(e,t){const n=this.#$r;return e.set([NaN,NaN,NaN,NaN,n[4],n[5]],t),t+6}#do(e,t){const n=this.#Kr.subarray(4,6),a=this.#Kr.subarray(16,18),[r,o,c,l]=this.#Wr,[i,s,h,d]=this.#co();return e.set([NaN,NaN,NaN,NaN,(n[0]-r)/c,(n[1]-o)/l,NaN,NaN,NaN,NaN,i,s,NaN,NaN,NaN,NaN,h,d,NaN,NaN,NaN,NaN,(a[0]-r)/c,(a[1]-o)/l],t),t+24}}class Lle extends Vle{#Wr;#mo=new Float32Array(4);#qr;#Gr;#no;#eo;#po;constructor(e,t,n,a,r,o){super(),this.#po=e,this.#no=t,this.#Wr=n,this.#eo=a,this.#qr=r,this.#Gr=o,this.lastPoint=[NaN,NaN],this.#vo(o);const[c,l,i,s]=this.#mo;for(let t=0,n=e.length;t<n;t+=2)e[t]=(e[t]-c)/i,e[t+1]=(e[t+1]-l)/s;for(let e=0,n=t.length;e<n;e+=2)t[e]=(t[e]-c)/i,t[e+1]=(t[e+1]-l)/s}toSVGPath(){const e=[`M${this.#po[4]} ${this.#po[5]}`];for(let t=6,n=this.#po.length;t<n;t+=6)isNaN(this.#po[t])?e.push(`L${this.#po[t+4]} ${this.#po[t+5]}`):e.push(`C${this.#po[t]} ${this.#po[t+1]} ${this.#po[t+2]} ${this.#po[t+3]} ${this.#po[t+4]} ${this.#po[t+5]}`);return e.push("Z"),e.join(" ")}serialize([e,t,n,a],r){const o=n-e,c=a-t;let l,i;switch(r){case 0:l=Vle._rescale(this.#po,e,a,o,-c),i=Vle._rescale(this.#no,e,a,o,-c);break;case 90:l=Vle._rescaleAndSwap(this.#po,e,t,o,c),i=Vle._rescaleAndSwap(this.#no,e,t,o,c);break;case 180:l=Vle._rescale(this.#po,n,t,-o,c),i=Vle._rescale(this.#no,n,t,-o,c);break;case 270:l=Vle._rescaleAndSwap(this.#po,n,a,-o,-c),i=Vle._rescaleAndSwap(this.#no,n,a,-o,-c)}return{outline:Array.from(l),points:[Array.from(i)]}}#vo(e){const t=this.#po;let n=t[4],a=t[5],r=n,o=a,c=n,l=a,i=n,s=a;const h=e?Math.max:Math.min;for(let e=6,d=t.length;e<d;e+=6){if(isNaN(t[e]))r=Math.min(r,t[e+4]),o=Math.min(o,t[e+5]),c=Math.max(c,t[e+4]),l=Math.max(l,t[e+5]),s<t[e+5]?(i=t[e+4],s=t[e+5]):s===t[e+5]&&(i=h(i,t[e+4]));else{const d=pre.bezierBoundingBox(n,a,...t.slice(e,e+6));r=Math.min(r,d[0]),o=Math.min(o,d[1]),c=Math.max(c,d[2]),l=Math.max(l,d[3]),s<d[3]?(i=d[2],s=d[3]):s===d[3]&&(i=h(i,d[2]))}n=t[e+4],a=t[e+5]}const d=this.#mo;d[0]=r-this.#qr,d[1]=o-this.#qr,d[2]=c-r+2*this.#qr,d[3]=l-o+2*this.#qr,this.lastPoint=[i,s]}get box(){return this.#mo}newOutliner(e,t,n,a,r,o=0){return new Cle(e,t,n,a,r,o)}getNewOutline(e,t){const[n,a,r,o]=this.#mo,[c,l,i,s]=this.#Wr,h=r*i,d=o*s,u=n*i+c,m=a*s+l,p=this.newOutliner({x:this.#no[0]*h+u,y:this.#no[1]*d+m},this.#Wr,this.#eo,e,this.#Gr,t??this.#qr);for(let e=2;e<this.#no.length;e+=2)p.add({x:this.#no[e]*h+u,y:this.#no[e+1]*d+m});return p.getOutlines()}}class xle{#Wr;#fo;#zo=[];#go=[];constructor(e,t=0,n=0,a=!0){let r=1/0,o=-1/0,c=1/0,l=-1/0;const i=10**-4;for(const{x:n,y:a,width:s,height:h}of e){const e=Math.floor((n-t)/i)*i,d=Math.ceil((n+s+t)/i)*i,u=Math.floor((a-t)/i)*i,m=Math.ceil((a+h+t)/i)*i,p=[e,u,m,!0],v=[d,u,m,!1];this.#zo.push(p,v),r=Math.min(r,e),o=Math.max(o,d),c=Math.min(c,u),l=Math.max(l,m)}const s=o-r+2*n,h=l-c+2*n,d=r-n,u=c-n,m=this.#zo.at(a?-1:-2),p=[m[0],m[2]];for(const e of this.#zo){const[t,n,a]=e;e[0]=(t-d)/s,e[1]=(n-u)/h,e[2]=(a-u)/h}this.#Wr=new Float32Array([d,u,s,h]),this.#fo=p}getOutlines(){this.#zo.sort(((e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2]));const e=[];for(const t of this.#zo)t[3]?(e.push(...this.#yo(t)),this.#Mo(t)):(this.#Eo(t),e.push(...this.#yo(t)));return this.#bo(e)}#bo(e){const t=[],n=new Set;for(const n of e){const[e,a,r]=n;t.push([e,a,n],[e,r,n])}t.sort(((e,t)=>e[1]-t[1]||e[0]-t[0]));for(let e=0,a=t.length;e<a;e+=2){const a=t[e][2],r=t[e+1][2];a.push(r),r.push(a),n.add(a),n.add(r)}const a=[];let r;for(;n.size>0;){const e=n.values().next().value;let[t,o,c,l,i]=e;n.delete(e);let s=t,h=o;for(r=[t,c],a.push(r);;){let e;if(n.has(l))e=l;else{if(!n.has(i))break;e=i}n.delete(e),[t,o,c,l,i]=e,s!==t&&(r.push(s,h,t,h===o?o:c),s=t),h=h===o?c:o}r.push(s,h)}return new Sle(a,this.#Wr,this.#fo)}#Ho(e){const t=this.#go;let n=0,a=t.length-1;for(;n<=a;){const r=n+a>>1,o=t[r][0];if(o===e)return r;o<e?n=r+1:a=r-1}return a+1}#Mo([,e,t]){const n=this.#Ho(e);this.#go.splice(n,0,[e,t])}#Eo([,e,t]){const n=this.#Ho(e);for(let a=n;a<this.#go.length;a++){const[n,r]=this.#go[a];if(n!==e)break;if(n===e&&r===t)return void this.#go.splice(a,1)}for(let a=n-1;a>=0;a--){const[n,r]=this.#go[a];if(n!==e)break;if(n===e&&r===t)return void this.#go.splice(a,1)}}#yo(e){const[t,n,a]=e,r=[[t,n,a]],o=this.#Ho(a);for(let e=0;e<o;e++){const[n,a]=this.#go[e];for(let e=0,o=r.length;e<o;e++){const[,c,l]=r[e];if(!(a<=c||l<=n))if(c>=n)if(l>a)r[e][1]=a;else{if(1===o)return[];r.splice(e,1),e--,o--}else r[e][2]=n,l>a&&r.push([t,a,l])}}return r}}class Sle extends Vle{#Wr;#Vo;constructor(e,t,n){super(),this.#Vo=e,this.#Wr=t,this.lastPoint=n}toSVGPath(){const e=[];for(const t of this.#Vo){let[n,a]=t;e.push(`M${n} ${a}`);for(let r=2;r<t.length;r+=2){const o=t[r],c=t[r+1];o===n?(e.push(`V${c}`),a=c):c===a&&(e.push(`H${o}`),n=o)}e.push("Z")}return e.join(" ")}serialize([e,t,n,a],r){const o=[],c=n-e,l=a-t;for(const t of this.#Vo){const n=new Array(t.length);for(let r=0;r<t.length;r+=2)n[r]=e+t[r]*c,n[r+1]=a-t[r+1]*l;o.push(n)}return o}get box(){return this.#Wr}get classNamesForOutlining(){return["highlightOutline"]}}class kle extends Cle{newFreeDrawOutline(e,t,n,a,r,o){return new wle(e,t,n,a,r,o)}}class wle extends Lle{newOutliner(e,t,n,a,r,o=0){return new kle(e,t,n,a,r,o)}}class Tle{#Co=null;#Lo=null;#xo;#So=null;#ko=!1;#wo=!1;#o=null;#To;#Oo=null;#v=null;#Ao;static#Ro=null;static get _keyboardManager(){return ere(this,"_keyboardManager",new $re([[["Escape","mac+Escape"],Tle.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Tle.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Tle.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Tle.prototype._moveToPrevious],[["Home","mac+Home"],Tle.prototype._moveToBeginning],[["End","mac+End"],Tle.prototype._moveToEnd]]))}constructor({editor:e=null,uiManager:t=null}){e?(this.#wo=!1,this.#Ao=jae.HIGHLIGHT_COLOR,this.#o=e):(this.#wo=!0,this.#Ao=jae.HIGHLIGHT_DEFAULT_COLOR),this.#v=e?._uiManager||t,this.#To=this.#v._eventBus,this.#xo=e?.color||this.#v?.highlightColors.values().next().value||"#FFFF98",Tle.#Ro||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){const e=this.#Co=document.createElement("button");e.className="colorPicker",e.tabIndex="0",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),e.setAttribute("aria-haspopup",!0);const t=this.#v._signal;e.addEventListener("click",this.#No.bind(this),{signal:t}),e.addEventListener("keydown",this.#Ga.bind(this),{signal:t});const n=this.#Lo=document.createElement("span");return n.className="swatch",n.setAttribute("aria-hidden",!0),n.style.backgroundColor=this.#xo,e.append(n),e}renderMainDropdown(){const e=this.#So=this.#_o();return e.setAttribute("aria-orientation","horizontal"),e.setAttribute("aria-labelledby","highlightColorPickerLabel"),e}#_o(){const e=document.createElement("div"),t=this.#v._signal;e.addEventListener("contextmenu",wre,{signal:t}),e.className="dropdown",e.role="listbox",e.setAttribute("aria-multiselectable",!1),e.setAttribute("aria-orientation","vertical"),e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[n,a]of this.#v.highlightColors){const r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",a),r.title=n,r.setAttribute("data-l10n-id",Tle.#Ro[n]);const o=document.createElement("span");r.append(o),o.className="swatch",o.style.backgroundColor=a,r.setAttribute("aria-selected",a===this.#xo),r.addEventListener("click",this.#Do.bind(this,a),{signal:t}),e.append(r)}return e.addEventListener("keydown",this.#Ga.bind(this),{signal:t}),e}#Do(e,t){t.stopPropagation(),this.#To.dispatch("switchannotationeditorparams",{source:this,type:this.#Ao,value:e})}_colorSelectFromKeyboard(e){if(e.target===this.#Co)return void this.#No(e);const t=e.target.getAttribute("data-color");t&&this.#Do(t,e)}_moveToNext(e){this.#Po?e.target!==this.#Co?e.target.nextSibling?.focus():this.#So.firstChild?.focus():this.#No(e)}_moveToPrevious(e){e.target!==this.#So?.firstChild&&e.target!==this.#Co?(this.#Po||this.#No(e),e.target.previousSibling?.focus()):this.#Po&&this._hideDropdownFromKeyboard()}_moveToBeginning(e){this.#Po?this.#So.firstChild?.focus():this.#No(e)}_moveToEnd(e){this.#Po?this.#So.lastChild?.focus():this.#No(e)}#Ga(e){Tle._keyboardManager.exec(this,e)}#No(e){if(this.#Po)return void this.hideDropdown();if(this.#ko=0===e.detail,this.#Oo||(this.#Oo=new AbortController,window.addEventListener("pointerdown",this.#s.bind(this),{signal:this.#v.combinedSignal(this.#Oo)})),this.#So)return void this.#So.classList.remove("hidden");const t=this.#So=this.#_o();this.#Co.append(t)}#s(e){this.#So?.contains(e.target)||this.hideDropdown()}hideDropdown(){this.#So?.classList.add("hidden"),this.#Oo?.abort(),this.#Oo=null}get#Po(){return this.#So&&!this.#So.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#wo||(this.#Po?(this.hideDropdown(),this.#Co.focus({preventScroll:!0,focusVisible:this.#ko})):this.#o?.unselect())}updateColor(e){if(this.#Lo&&(this.#Lo.style.backgroundColor=e),!this.#So)return;const t=this.#v.highlightColors.values();for(const n of this.#So.children)n.setAttribute("aria-selected",t.next().value===e)}destroy(){this.#Co?.remove(),this.#Co=null,this.#Lo=null,this.#So?.remove(),this.#So=null}}class Ole extends Xre{#Fo=null;#Io=0;#jo;#Bo=null;#r=null;#Uo=null;#Wo=null;#$o=0;#qo=null;#Go=null;#y=null;#Yo=!1;#fo=null;#Ko;#Xo=null;#Qo="";#to;#Jo="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=Iae.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const e=Ole.prototype;return ere(this,"_keyboardManager",new $re([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}constructor(e){super({...e,name:"highlightEditor"}),this.color=e.color||Ole._defaultColor,this.#to=e.thickness||Ole._defaultThickness,this.#Ko=e.opacity||Ole._defaultOpacity,this.#jo=e.boxes||null,this.#Jo=e.methodOfCreation||"",this.#Qo=e.text||"",this._isDraggable=!1,e.highlightId>-1?(this.#Yo=!0,this.#Zo(e),this.#ec()):this.#jo&&(this.#Fo=e.anchorNode,this.#Io=e.anchorOffset,this.#Wo=e.focusNode,this.#$o=e.focusOffset,this.#tc(),this.#ec(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#Yo?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#to,methodOfCreation:this.#Jo}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}#tc(){const e=new xle(this.#jo,.001);this.#Go=e.getOutlines(),[this.x,this.y,this.width,this.height]=this.#Go.box;const t=new xle(this.#jo,.0025,.001,"ltr"===this._uiManager.direction);this.#Uo=t.getOutlines();const{lastPoint:n}=this.#Uo;this.#fo=[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]}#Zo({highlightOutlines:e,highlightId:t,clipPathId:n}){if(this.#Go=e,this.#Uo=e.getNewOutline(this.#to/2+1.5,.0025),t>=0)this.#y=t,this.#Bo=n,this.parent.drawLayer.finalizeDraw(t,{bbox:e.box,path:{d:e.toSVGPath()}}),this.#Xo=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#Uo.box,path:{d:this.#Uo.toSVGPath()}},!0);else if(this.parent){const t=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#y,{bbox:Ole.#nc(this.#Go.box,(t-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#Xo,{bbox:Ole.#nc(this.#Uo.box,t),path:{d:this.#Uo.toSVGPath()}})}const[a,r,o,c]=e.box;switch(this.rotation){case 0:this.x=a,this.y=r,this.width=o,this.height=c;break;case 90:{const[e,t]=this.parentDimensions;this.x=r,this.y=1-a,this.width=o*t/e,this.height=c*e/t;break}case 180:this.x=1-a,this.y=1-r,this.width=o,this.height=c;break;case 270:{const[e,t]=this.parentDimensions;this.x=1-r,this.y=a,this.width=o*t/e,this.height=c*e/t;break}}const{lastPoint:l}=this.#Uo;this.#fo=[(l[0]-a)/o,(l[1]-r)/c]}static initialize(e,t){Xre.initialize(e,t),Ole._defaultColor||=t.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(e,t){switch(e){case jae.HIGHLIGHT_DEFAULT_COLOR:Ole._defaultColor=t;break;case jae.HIGHLIGHT_THICKNESS:Ole._defaultThickness=t}}translateInPage(e,t){}get toolbarPosition(){return this.#fo}updateParams(e,t){switch(e){case jae.HIGHLIGHT_COLOR:this.#_r(t);break;case jae.HIGHLIGHT_THICKNESS:this.#ac(t)}}static get defaultPropertiesToUpdate(){return[[jae.HIGHLIGHT_DEFAULT_COLOR,Ole._defaultColor],[jae.HIGHLIGHT_THICKNESS,Ole._defaultThickness]]}get propertiesToUpdate(){return[[jae.HIGHLIGHT_COLOR,this.color||Ole._defaultColor],[jae.HIGHLIGHT_THICKNESS,this.#to||Ole._defaultThickness],[jae.HIGHLIGHT_FREE,this.#Yo]]}#_r(e){const t=(e,t)=>{this.color=e,this.#Ko=t,this.parent?.drawLayer.updateProperties(this.#y,{root:{fill:e,"fill-opacity":t}}),this.#r?.updateColor(e)},n=this.color,a=this.#Ko;this.addCommands({cmd:t.bind(this,e,Ole._defaultOpacity),undo:t.bind(this,n,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:jae.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(e)},!0)}#ac(e){const t=this.#to,n=e=>{this.#to=e,this.#rc(e)};this.addCommands({cmd:n.bind(this,e),undo:n.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:jae.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)}async addEditToolbar(){const e=await super.addEditToolbar();return e?(this._uiManager.highlightColors&&(this.#r=new Tle({editor:this}),e.addColorPicker(this.#r)),e):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#oc())}getBaseTranslation(){return[0,0]}getRect(e,t){return super.getRect(e,t,this.#oc())}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){this.#cc(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#ec(),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let t=!1;this.parent&&!e?this.#cc():e&&(this.#ec(e),t=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(e),this.show(this._isVisible),t&&this.select()}#rc(e){if(!this.#Yo)return;this.#Zo({highlightOutlines:this.#Go.getNewOutline(e/2)}),this.fixAndSetPosition();const[t,n]=this.parentDimensions;this.setDims(this.width*t,this.height*n)}#cc(){null!==this.#y&&this.parent&&(this.parent.drawLayer.remove(this.#y),this.#y=null,this.parent.drawLayer.remove(this.#Xo),this.#Xo=null)}#ec(e=this.parent){null===this.#y&&(({id:this.#y,clipPathId:this.#Bo}=e.drawLayer.draw({bbox:this.#Go.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#Ko},rootClass:{highlight:!0,free:this.#Yo},path:{d:this.#Go.toSVGPath()}},!1,!0)),this.#Xo=e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#Yo},bbox:this.#Uo.box,path:{d:this.#Uo.toSVGPath()}},this.#Yo),this.#qo&&(this.#qo.style.clipPath=this.#Bo))}static#nc([e,t,n,a],r){switch(r){case 90:return[1-t-a,e,a,n];case 180:return[1-e-n,1-t-a,n,a];case 270:return[t,1-e-n,a,n]}return[e,t,n,a]}rotate(e){const{drawLayer:t}=this.parent;let n;this.#Yo?(e=(e-this.rotation+360)%360,n=Ole.#nc(this.#Go.box,e)):n=Ole.#nc([this.x,this.y,this.width,this.height],e),t.updateProperties(this.#y,{bbox:n,root:{"data-main-rotation":e}}),t.updateProperties(this.#Xo,{bbox:Ole.#nc(this.#Uo.box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();this.#Qo&&(e.setAttribute("aria-label",this.#Qo),e.setAttribute("role","mark")),this.#Yo?e.classList.add("free"):this.div.addEventListener("keydown",this.#lc.bind(this),{signal:this._uiManager._signal});const t=this.#qo=document.createElement("div");e.append(t),t.setAttribute("aria-hidden","true"),t.className="internal",t.style.clipPath=this.#Bo;const[n,a]=this.parentDimensions;return this.setDims(this.width*n,this.height*a),jre(this,this.#qo,["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Xo,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Xo,{rootClass:{hovered:!1}})}#lc(e){Ole._keyboardManager.exec(this,e)}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:this.#ic(!0);break;case 1:case 3:this.#ic(!1)}}#ic(e){if(!this.#Fo)return;const t=window.getSelection();e?t.setPosition(this.#Fo,this.#Io):t.setPosition(this.#Wo,this.#$o)}select(){super.select(),this.#Xo&&this.parent?.drawLayer.updateProperties(this.#Xo,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#Xo&&(this.parent?.drawLayer.updateProperties(this.#Xo,{rootClass:{selected:!1}}),this.#Yo||this.#ic(!1))}get _mustFixPosition(){return!this.#Yo}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(this.#y,{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(this.#Xo,{rootClass:{hidden:!e}}))}#oc(){return this.#Yo?this.rotation:0}#sc(){if(this.#Yo)return null;const[e,t]=this.pageDimensions,[n,a]=this.pageTranslation,r=this.#jo,o=new Float32Array(8*r.length);let c=0;for(const{x:l,y:i,width:s,height:h}of r){const r=l*e+n,d=(1-i)*t+a;o[c]=o[c+4]=r,o[c+1]=o[c+3]=d,o[c+2]=o[c+6]=r+s*e,o[c+5]=o[c+7]=d-h*t,c+=8}return o}#hc(e){return this.#Go.serialize(e,this.#oc())}static startHighlighting(e,t,{target:n,x:a,y:r}){const{x:o,y:c,width:l,height:i}=n.getBoundingClientRect(),s=new AbortController,h=e.combinedSignal(s),d=t=>{s.abort(),this.#dc(e,t)};window.addEventListener("blur",d,{signal:h}),window.addEventListener("pointerup",d,{signal:h}),window.addEventListener("pointerdown",Tre,{capture:!0,passive:!1,signal:h}),window.addEventListener("contextmenu",wre,{signal:h}),n.addEventListener("pointermove",this.#uc.bind(this,e),{signal:h}),this._freeHighlight=new kle({x:a,y:r},[o,c,l,i],e.scale,this._defaultThickness/2,t,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static#uc(e,t){this._freeHighlight.add(t)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#dc(e,t){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(t,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(e,t,n){let a=null;if(e instanceof vle){const{data:{quadPoints:t,rect:n,rotation:r,id:o,color:c,opacity:l,popupRef:i},parent:{page:{pageNumber:s}}}=e;a=e={annotationType:Iae.HIGHLIGHT,color:Array.from(c),opacity:l,quadPoints:t,boxes:null,pageIndex:s-1,rect:n.slice(0),rotation:r,id:o,deleted:!1,popupRef:i}}else if(e instanceof ple){const{data:{inkLists:t,rect:n,rotation:r,id:o,color:c,borderStyle:{rawWidth:l},popupRef:i},parent:{page:{pageNumber:s}}}=e;a=e={annotationType:Iae.HIGHLIGHT,color:Array.from(c),thickness:l,inkLists:t,boxes:null,pageIndex:s-1,rect:n.slice(0),rotation:r,id:o,deleted:!1,popupRef:i}}const{color:r,quadPoints:o,inkLists:c,opacity:l}=e,i=await super.deserialize(e,t,n);i.color=pre.makeHexColor(...r),i.#Ko=l||1,c&&(i.#to=e.thickness),i.annotationElementId=e.id||null,i._initialData=a;const[s,h]=i.pageDimensions,[d,u]=i.pageTranslation;if(o){const e=i.#jo=[];for(let t=0;t<o.length;t+=8)e.push({x:(o[t]-d)/s,y:1-(o[t+1]-u)/h,width:(o[t+2]-o[t])/s,height:(o[t+1]-o[t+5])/h});i.#tc(),i.#ec(),i.rotate(i.rotation)}else if(c){i.#Yo=!0;const e=c[0],n={x:e[0]-d,y:h-(e[1]-u)},a=new kle(n,[0,0,s,h],1,i.#to/2,!0,.001);for(let t=0,r=e.length;t<r;t+=2)n.x=e[t]-d,n.y=h-(e[t+1]-u),a.add(n);const{id:r,clipPathId:o}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:i.color,"fill-opacity":i._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:a.toSVGPath()}},!0,!0);i.#Zo({highlightOutlines:a.getOutlines(),highlightId:r,clipPathId:o}),i.#ec()}return i}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const t=this.getRect(0,0),n=Xre._colorManager.convert(this.color),a={annotationType:Iae.HIGHLIGHT,color:n,opacity:this.#Ko,thickness:this.#to,quadPoints:this.#sc(),outlines:this.#hc(t),pageIndex:this.pageIndex,rect:t,rotation:this.#oc(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#Ur(a)?null:(a.id=this.annotationElementId,a)}#Ur(e){const{color:t}=this._initialData;return e.color.some(((e,n)=>e!==t[n]))}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class Ale{#mc=Object.create(null);updateProperty(e,t){this[e]=t,this.updateSVGProperty(e,t)}updateProperties(e){if(e)for(const[t,n]of Object.entries(e))this.updateProperty(t,n)}updateSVGProperty(e,t){this.#mc[e]=t}toSVGProperties(){const e=this.#mc;return this.#mc=Object.create(null),{root:e}}reset(){this.#mc=Object.create(null)}updateAll(e=this){this.updateProperties(e)}clone(){Qae("Not implemented")}}class Rle extends Xre{#pc=null;#vc;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#fc=null;static#zc=null;static#gc=null;static#yc=NaN;static#Mc=null;static#Ec=null;static#bc=NaN;static _INNER_MARGIN=3;constructor(e){super(e),this.#vc=e.mustBeCommitted||!1,e.drawOutlines&&(this.#Hc(e),this.#ec())}#Hc({drawOutlines:e,drawId:t,drawingOptions:n}){this.#pc=e,this._drawingOptions||=n,t>=0?(this._drawId=t,this.parent.drawLayer.finalizeDraw(t,e.defaultProperties)):this._drawId=this.#Vc(e,this.parent),this.#Cc(e.box)}#Vc(e,t){const{id:n}=t.drawLayer.draw(Rle._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return n}static _mergeSVGProperties(e,t){const n=new Set(Object.keys(e));for(const[a,r]of Object.entries(t))n.has(a)?Object.assign(e[a],r):e[a]=r;return e}static getDefaultDrawingOptions(e){Qae("Not implemented")}static get typesMap(){Qae("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,t){const n=this.typesMap.get(e);n&&this._defaultDrawingOptions.updateProperty(n,t),this._currentParent&&(Rle.#fc.updateProperty(n,t),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,t){const n=this.constructor.typesMap.get(e);n&&this._updateProperty(e,n,t)}static get defaultPropertiesToUpdate(){const e=[],t=this._defaultDrawingOptions;for(const[n,a]of this.typesMap)e.push([n,t[a]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:t}=this;for(const[n,a]of this.constructor.typesMap)e.push([n,t[a]]);return e}_updateProperty(e,t,n){const a=this._drawingOptions,r=a[t],o=e=>{a.updateProperty(t,e);const n=this.#pc.updateProperty(t,e);n&&this.#Cc(n),this.parent?.drawLayer.updateProperties(this._drawId,a.toSVGProperties())};this.addCommands({cmd:o.bind(this,n),undo:o.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,Rle._mergeSVGProperties(this.#pc.getPathResizingSVGProperties(this.#Lc()),{bbox:this.#xc()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,Rle._mergeSVGProperties(this.#pc.getPathResizedSVGProperties(this.#Lc()),{bbox:this.#xc()}))}_onTranslating(e,t){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#xc(e,t)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,Rle._mergeSVGProperties(this.#pc.getPathTranslatedSVGProperties(this.#Lc(),this.parentDimensions),{bbox:this.#xc()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#vc&&(this.#vc=!1,this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){this.#cc(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#ec(),this.#Cc(this.#pc.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let t=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),this.#cc()):e&&(this._uiManager.addShouldRescale(this),this.#ec(e),t=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(e),t&&this.select()}#cc(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#ec(e=this.parent){null!==this._drawId&&this.parent===e||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#Vc(this.#pc,e)):this.parent.drawLayer.updateParent(this._drawId,e.drawLayer))}#Sc([e,t,n,a]){const{parentDimensions:[r,o],rotation:c}=this;switch(c){case 90:return[t,1-e,n*(o/r),a*(r/o)];case 180:return[1-e,1-t,n,a];case 270:return[1-t,e,n*(o/r),a*(r/o)];default:return[e,t,n,a]}}#Lc(){const{x:e,y:t,width:n,height:a,parentDimensions:[r,o],rotation:c}=this;switch(c){case 90:return[1-t,e,n*(r/o),a*(o/r)];case 180:return[1-e,1-t,n,a];case 270:return[t,1-e,n*(r/o),a*(o/r)];default:return[e,t,n,a]}}#Cc(e){if([this.x,this.y,this.width,this.height]=this.#Sc(e),this.div){this.fixAndSetPosition();const[e,t]=this.parentDimensions;this.setDims(this.width*e,this.height*t)}this._onResized()}#xc(){const{x:e,y:t,width:n,height:a,rotation:r,parentRotation:o,parentDimensions:[c,l]}=this;switch((4*r+o)/90){case 1:return[1-t-a,e,a,n];case 2:return[1-e-n,1-t-a,n,a];case 3:return[t,1-e-n,a,n];case 4:return[e,t-n*(c/l),a*(l/c),n*(c/l)];case 5:return[1-t,e,n*(c/l),a*(l/c)];case 6:return[1-e-a*(l/c),1-t,a*(l/c),n*(c/l)];case 7:return[t-n*(c/l),1-e-a*(l/c),n*(c/l),a*(l/c)];case 8:return[e-n,t-a,n,a];case 9:return[1-t,e-n,a,n];case 10:return[1-e,1-t,n,a];case 11:return[t-a,1-e,a,n];case 12:return[e-a*(l/c),t,a*(l/c),n*(c/l)];case 13:return[1-t-n*(c/l),e-a*(l/c),n*(c/l),a*(l/c)];case 14:return[1-e,1-t-n*(c/l),a*(l/c),n*(c/l)];case 15:return[t,1-e,n*(c/l),a*(l/c)];default:return[e,t,n,a]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,Rle._mergeSVGProperties({bbox:this.#xc()},this.#pc.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#Cc(this.#pc.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;const e=super.render();e.classList.add("draw");const t=document.createElement("div");e.append(t),t.setAttribute("aria-hidden","true"),t.className="internal";const[n,a]=this.parentDimensions;return this.setDims(this.width*n,this.height*a),this._uiManager.addShouldRescale(this),this.disableEditing(),e}static createDrawerInstance(e,t,n,a,r){Qae("Not implemented")}static startDrawing(e,t,n,a){const{target:r,offsetX:o,offsetY:c,pointerId:l,pointerType:i}=a;if(Rle.#Mc&&Rle.#Mc!==i)return;const{viewport:{rotation:s}}=e,{width:h,height:d}=r.getBoundingClientRect(),u=Rle.#zc=new AbortController,m=e.combinedSignal(u);Rle.#yc||=l,Rle.#Mc??=i,window.addEventListener("pointerup",(e=>{Rle.#yc===e.pointerId?this._endDraw(e):Rle.#Ec?.delete(e.pointerId)}),{signal:m}),window.addEventListener("pointercancel",(e=>{Rle.#yc===e.pointerId?this._currentParent.endDrawingSession():Rle.#Ec?.delete(e.pointerId)}),{signal:m}),window.addEventListener("pointerdown",(e=>{Rle.#Mc===e.pointerType&&((Rle.#Ec||=new Set).add(e.pointerId),Rle.#fc.isCancellable()&&(Rle.#fc.removeLastElement(),Rle.#fc.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:m}),window.addEventListener("contextmenu",wre,{signal:m}),r.addEventListener("pointermove",this._drawMove.bind(this),{signal:m}),r.addEventListener("touchmove",(e=>{e.timeStamp===Rle.#bc&&Tre(e)}),{signal:m}),e.toggleDrawing(),t._editorUndoBar?.hide(),Rle.#fc?e.drawLayer.updateProperties(this._currentDrawId,Rle.#fc.startNew(o,c,h,d,s)):(t.updateUIForDefaultProperties(this),Rle.#fc=this.createDrawerInstance(o,c,h,d,s),Rle.#gc=this.getDefaultDrawingOptions(),this._currentParent=e,({id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(Rle.#gc.toSVGProperties(),Rle.#fc.defaultSVGProperties),!0,!1)))}static _drawMove(e){if(Rle.#bc=-1,!Rle.#fc)return;const{offsetX:t,offsetY:n,pointerId:a}=e;Rle.#yc===a&&(Rle.#Ec?.size>=1?this._endDraw(e):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,Rle.#fc.add(t,n)),Rle.#bc=e.timeStamp,Tre(e)))}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,Rle.#fc=null,Rle.#gc=null,Rle.#Mc=null,Rle.#bc=NaN),Rle.#zc&&(Rle.#zc.abort(),Rle.#zc=null,Rle.#yc=NaN,Rle.#Ec=null)}static _endDraw(e){const t=this._currentParent;if(t)if(t.toggleDrawing(!0),this._cleanup(!1),e&&t.drawLayer.updateProperties(this._currentDrawId,Rle.#fc.end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const e=Rle.#fc,n=this._currentDrawId,a=e.getLastElement();t.addCommands({cmd:()=>{t.drawLayer.updateProperties(n,e.setLastElement(a))},undo:()=>{t.drawLayer.updateProperties(n,e.removeLastElement())},mustExec:!1,type:jae.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(e){const t=this._currentParent;if(!t)return null;if(t.toggleDrawing(!0),t.cleanUndoStack(jae.DRAW_STEP),!Rle.#fc.isEmpty()){const{pageDimensions:[n,a],scale:r}=t,o=t.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:Rle.#fc.getOutlines(n*r,a*r,r,this._INNER_MARGIN),drawingOptions:Rle.#gc,mustBeCommitted:!e});return this._cleanup(!0),o}return t.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,t,n,a,r,o){Qae("Not implemented")}static async deserialize(e,t,n){const{rawDims:{pageWidth:a,pageHeight:r,pageX:o,pageY:c}}=t.viewport,l=this.deserializeDraw(o,c,a,r,this._INNER_MARGIN,e),i=await super.deserialize(e,t,n);return i.createDrawingOptions(e),i.#Hc({drawOutlines:l}),i.#ec(),i.onScaleChanging(),i.rotate(),i}serializeDraw(e){const[t,n]=this.pageTranslation,[a,r]=this.pageDimensions;return this.#pc.serialize([t,n,a,r],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class Nle{#Kr=new Float64Array(6);#zr;#kc;#Rn;#to;#no;#wc="";#Tc=0;#Vo=new _le;#Oc;#Ac;constructor(e,t,n,a,r,o){this.#Oc=n,this.#Ac=a,this.#Rn=r,this.#to=o,[e,t]=this.#Rc(e,t);const c=this.#zr=[NaN,NaN,NaN,NaN,e,t];this.#no=[e,t],this.#kc=[{line:c,points:this.#no}],this.#Kr.set(c,0)}updateProperty(e,t){"stroke-width"===e&&(this.#to=t)}#Rc(e,t){return Vle._normalizePoint(e,t,this.#Oc,this.#Ac,this.#Rn)}isEmpty(){return!this.#kc||0===this.#kc.length}isCancellable(){return this.#no.length<=10}add(e,t){[e,t]=this.#Rc(e,t);const[n,a,r,o]=this.#Kr.subarray(2,6),c=e-r,l=t-o;return Math.hypot(this.#Oc*c,this.#Ac*l)<=2?null:(this.#no.push(e,t),isNaN(n)?(this.#Kr.set([r,o,e,t],2),this.#zr.push(NaN,NaN,NaN,NaN,e,t),{path:{d:this.toSVGPath()}}):(isNaN(this.#Kr[0])&&this.#zr.splice(6,6),this.#Kr.set([n,a,r,o,e,t],0),this.#zr.push(...Vle.createBezierPoints(n,a,r,o,e,t)),{path:{d:this.toSVGPath()}}))}end(e,t){return this.add(e,t)||(2===this.#no.length?{path:{d:this.toSVGPath()}}:null)}startNew(e,t,n,a,r){this.#Oc=n,this.#Ac=a,this.#Rn=r,[e,t]=this.#Rc(e,t);const o=this.#zr=[NaN,NaN,NaN,NaN,e,t];this.#no=[e,t];const c=this.#kc.at(-1);return c&&(c.line=new Float32Array(c.line),c.points=new Float32Array(c.points)),this.#kc.push({line:o,points:this.#no}),this.#Kr.set(o,0),this.#Tc=0,this.toSVGPath(),null}getLastElement(){return this.#kc.at(-1)}setLastElement(e){return this.#kc?(this.#kc.push(e),this.#zr=e.line,this.#no=e.points,this.#Tc=0,{path:{d:this.toSVGPath()}}):this.#Vo.setLastElement(e)}removeLastElement(){if(!this.#kc)return this.#Vo.removeLastElement();this.#kc.pop(),this.#wc="";for(let e=0,t=this.#kc.length;e<t;e++){const{line:t,points:n}=this.#kc[e];this.#zr=t,this.#no=n,this.#Tc=0,this.toSVGPath()}return{path:{d:this.#wc}}}toSVGPath(){const e=Vle.svgRound(this.#zr[4]),t=Vle.svgRound(this.#zr[5]);if(2===this.#no.length)return this.#wc=`${this.#wc} M ${e} ${t} Z`,this.#wc;if(this.#no.length<=6){const n=this.#wc.lastIndexOf("M");this.#wc=`${this.#wc.slice(0,n)} M ${e} ${t}`,this.#Tc=6}if(4===this.#no.length){const e=Vle.svgRound(this.#zr[10]),t=Vle.svgRound(this.#zr[11]);return this.#wc=`${this.#wc} L ${e} ${t}`,this.#Tc=12,this.#wc}const n=[];0===this.#Tc&&(n.push(`M ${e} ${t}`),this.#Tc=6);for(let e=this.#Tc,t=this.#zr.length;e<t;e+=6){const[t,a,r,o,c,l]=this.#zr.slice(e,e+6).map(Vle.svgRound);n.push(`C${t} ${a} ${r} ${o} ${c} ${l}`)}return this.#wc+=n.join(" "),this.#Tc=this.#zr.length,this.#wc}getOutlines(e,t,n,a){const r=this.#kc.at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),this.#Vo.build(this.#kc,e,t,n,this.#Rn,this.#to,a),this.#Kr=null,this.#zr=null,this.#kc=null,this.#wc=null,this.#Vo}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class _le extends Vle{#mo;#Nc=0;#qr;#kc;#Oc;#Ac;#_c;#Rn;#to;build(e,t,n,a,r,o,c){this.#Oc=t,this.#Ac=n,this.#_c=a,this.#Rn=r,this.#to=o,this.#qr=c??0,this.#kc=e,this.#Dc()}setLastElement(e){return this.#kc.push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#kc.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:t}of this.#kc)if(e.push(`M${Vle.svgRound(t[4])} ${Vle.svgRound(t[5])}`),6!==t.length)if(12!==t.length)for(let n=6,a=t.length;n<a;n+=6){const[a,r,o,c,l,i]=t.subarray(n,n+6).map(Vle.svgRound);e.push(`C${a} ${r} ${o} ${c} ${l} ${i}`)}else e.push(`L${Vle.svgRound(t[10])} ${Vle.svgRound(t[11])}`);else e.push("Z");return e.join("")}serialize([e,t,n,a],r){const o=[],c=[],[l,i,s,h]=this.#Pc();let d,u,m,p,v,f,z,g,y;switch(this.#Rn){case 0:y=Vle._rescale,d=e,u=t+a,m=n,p=-a,v=e+l*n,f=t+(1-i-h)*a,z=e+(l+s)*n,g=t+(1-i)*a;break;case 90:y=Vle._rescaleAndSwap,d=e,u=t,m=n,p=a,v=e+i*n,f=t+l*a,z=e+(i+h)*n,g=t+(l+s)*a;break;case 180:y=Vle._rescale,d=e+n,u=t,m=-n,p=a,v=e+(1-l-s)*n,f=t+i*a,z=e+(1-l)*n,g=t+(i+h)*a;break;case 270:y=Vle._rescaleAndSwap,d=e+n,u=t+a,m=-n,p=-a,v=e+(1-i-h)*n,f=t+(1-l-s)*a,z=e+(1-i)*n,g=t+(1-l)*a}for(const{line:e,points:t}of this.#kc)o.push(y(e,d,u,m,p,r?new Array(e.length):null)),c.push(y(t,d,u,m,p,r?new Array(t.length):null));return{lines:o,points:c,rect:[v,f,z,g]}}static deserialize(e,t,n,a,r,{paths:{lines:o,points:c},rotation:l,thickness:i}){const s=[];let h,d,u,m,p;switch(l){case 0:p=Vle._rescale,h=-e/n,d=t/a+1,u=1/n,m=-1/a;break;case 90:p=Vle._rescaleAndSwap,h=-t/a,d=-e/n,u=1/a,m=1/n;break;case 180:p=Vle._rescale,h=e/n+1,d=-t/a,u=-1/n,m=1/a;break;case 270:p=Vle._rescaleAndSwap,h=t/a+1,d=e/n+1,u=-1/a,m=-1/n}if(!o){o=[];for(const e of c){const t=e.length;if(2===t){o.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1]]));continue}if(4===t){o.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1],NaN,NaN,NaN,NaN,e[2],e[3]]));continue}const n=new Float32Array(3*(t-2));o.push(n);let[a,r,c,l]=e.subarray(0,4);n.set([NaN,NaN,NaN,NaN,a,r],0);for(let o=4;o<t;o+=2){const t=e[o],i=e[o+1];n.set(Vle.createBezierPoints(a,r,c,l,t,i),3*(o-2)),[a,r,c,l]=[c,l,t,i]}}}for(let e=0,t=o.length;e<t;e++)s.push({line:p(o[e].map((e=>e??NaN)),h,d,u,m),points:p(c[e].map((e=>e??NaN)),h,d,u,m)});const v=new _le;return v.build(s,n,a,1,l,i,r),v}#Fc(e=this.#to){const t=this.#qr+e/2*this.#_c;return this.#Rn%180==0?[t/this.#Oc,t/this.#Ac]:[t/this.#Ac,t/this.#Oc]}#Pc(){const[e,t,n,a]=this.#mo,[r,o]=this.#Fc(0);return[e+r,t+o,n-2*r,a-2*o]}#Dc(){const e=this.#mo=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:t}of this.#kc){if(t.length<=12){for(let n=4,a=t.length;n<a;n+=6){const[a,r]=t.subarray(n,n+2);e[0]=Math.min(e[0],a),e[1]=Math.min(e[1],r),e[2]=Math.max(e[2],a),e[3]=Math.max(e[3],r)}continue}let n=t[4],a=t[5];for(let r=6,o=t.length;r<o;r+=6){const[o,c,l,i,s,h]=t.subarray(r,r+6);pre.bezierBoundingBox(n,a,o,c,l,i,s,h,e),n=s,a=h}}const[t,n]=this.#Fc();e[0]=Math.min(1,Math.max(0,e[0]-t)),e[1]=Math.min(1,Math.max(0,e[1]-n)),e[2]=Math.min(1,Math.max(0,e[2]+t)),e[3]=Math.min(1,Math.max(0,e[3]+n)),e[2]-=e[0],e[3]-=e[1]}get box(){return this.#mo}updateProperty(e,t){return"stroke-width"===e?this.#ac(t):null}#ac(e){const[t,n]=this.#Fc();this.#to=e;const[a,r]=this.#Fc(),[o,c]=[a-t,r-n],l=this.#mo;return l[0]-=o,l[1]-=c,l[2]+=2*o,l[3]+=2*c,l}updateParentDimensions([e,t],n){const[a,r]=this.#Fc();this.#Oc=e,this.#Ac=t,this.#_c=n;const[o,c]=this.#Fc(),l=o-a,i=c-r,s=this.#mo;return s[0]-=l,s[1]-=i,s[2]+=2*l,s[3]+=2*i,s}updateRotation(e){return this.#Nc=e,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#mo.map(Vle.svgRound).join(" ")}get defaultProperties(){const[e,t]=this.#mo;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Vle.svgRound(e)} ${Vle.svgRound(t)}`}}}get rotationTransform(){const[,,e,t]=this.#mo;let n=0,a=0,r=0,o=0,c=0,l=0;switch(this.#Nc){case 90:a=t/e,r=-e/t,c=e;break;case 180:n=-1,o=-1,c=e,l=t;break;case 270:a=-t/e,r=e/t,l=t;break;default:return""}return`matrix(${n} ${a} ${r} ${o} ${Vle.svgRound(c)} ${Vle.svgRound(l)})`}getPathResizingSVGProperties([e,t,n,a]){const[r,o]=this.#Fc(),[c,l,i,s]=this.#mo;if(Math.abs(i-r)<=Vle.PRECISION||Math.abs(s-o)<=Vle.PRECISION){const r=e+n/2-(c+i/2),o=t+a/2-(l+s/2);return{path:{"transform-origin":`${Vle.svgRound(e)} ${Vle.svgRound(t)}`,transform:`${this.rotationTransform} translate(${r} ${o})`}}}const h=(n-2*r)/(i-2*r),d=(a-2*o)/(s-2*o),u=i/n,m=s/a;return{path:{"transform-origin":`${Vle.svgRound(c)} ${Vle.svgRound(l)}`,transform:`${this.rotationTransform} scale(${u} ${m}) translate(${Vle.svgRound(r)} ${Vle.svgRound(o)}) scale(${h} ${d}) translate(${Vle.svgRound(-r)} ${Vle.svgRound(-o)})`}}}getPathResizedSVGProperties([e,t,n,a]){const[r,o]=this.#Fc(),c=this.#mo,[l,i,s,h]=c;if(c[0]=e,c[1]=t,c[2]=n,c[3]=a,Math.abs(s-r)<=Vle.PRECISION||Math.abs(h-o)<=Vle.PRECISION){const r=e+n/2-(l+s/2),o=t+a/2-(i+h/2);for(const{line:e,points:t}of this.#kc)Vle._translate(e,r,o,e),Vle._translate(t,r,o,t);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Vle.svgRound(e)} ${Vle.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const d=(n-2*r)/(s-2*r),u=(a-2*o)/(h-2*o),m=-d*(l+r)+e+r,p=-u*(i+o)+t+o;if(1!==d||1!==u||0!==m||0!==p)for(const{line:e,points:t}of this.#kc)Vle._rescale(e,m,p,d,u,e),Vle._rescale(t,m,p,d,u,t);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Vle.svgRound(e)} ${Vle.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,t],n){const[a,r]=n,o=this.#mo,c=e-o[0],l=t-o[1];if(this.#Oc===a&&this.#Ac===r)for(const{line:e,points:t}of this.#kc)Vle._translate(e,c,l,e),Vle._translate(t,c,l,t);else{const e=this.#Oc/a,t=this.#Ac/r;this.#Oc=a,this.#Ac=r;for(const{line:n,points:a}of this.#kc)Vle._rescale(n,c,l,e,t,n),Vle._rescale(a,c,l,e,t,a);o[2]*=e,o[3]*=t}return o[0]=e,o[1]=t,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Vle.svgRound(e)} ${Vle.svgRound(t)}`}}}get defaultSVGProperties(){const e=this.#mo;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Vle.svgRound(e[0])} ${Vle.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}class Dle extends Ale{#Ic;constructor(e){super(),this.#Ic=e,super.updateProperties({fill:"none",stroke:Xre._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(e,t){"stroke-width"===e&&(t??=this["stroke-width"],t*=this.#Ic.realScale),super.updateSVGProperty(e,t)}clone(){const e=new Dle(this.#Ic);return e.updateAll(this),e}}class Ple extends Rle{static _type="ink";static _editorType=Iae.INK;static _defaultDrawingOptions=null;constructor(e){super({...e,name:"inkEditor"}),this._willKeepAspectRatio=!0}static initialize(e,t){Xre.initialize(e,t),this._defaultDrawingOptions=new Dle(t.viewParameters)}static getDefaultDrawingOptions(e){const t=this._defaultDrawingOptions.clone();return t.updateProperties(e),t}static get supportMultipleDrawings(){return!0}static get typesMap(){return ere(this,"typesMap",new Map([[jae.INK_THICKNESS,"stroke-width"],[jae.INK_COLOR,"stroke"],[jae.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,t,n,a,r){return new Nle(e,t,n,a,r,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,t,n,a,r,o){return _le.deserialize(e,t,n,a,r,o)}static async deserialize(e,t,n){let a=null;if(e instanceof ple){const{data:{inkLists:t,rect:n,rotation:r,id:o,color:c,opacity:l,borderStyle:{rawWidth:i},popupRef:s},parent:{page:{pageNumber:h}}}=e;a=e={annotationType:Iae.INK,color:Array.from(c),thickness:i,opacity:l,paths:{points:t},boxes:null,pageIndex:h-1,rect:n.slice(0),rotation:r,id:o,deleted:!1,popupRef:s}}const r=await super.deserialize(e,t,n);return r.annotationElementId=e.id||null,r._initialData=a,r}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:e,_drawingOptions:t,parent:n}=this;t.updateSVGProperty("stroke-width"),n.drawLayer.updateProperties(e,t.toSVGProperties())}static onScaleChangingWhenDrawing(){const e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:t,opacity:n}){this._drawingOptions=Ple.getDefaultDrawingOptions({stroke:pre.makeHexColor(...e),"stroke-width":t,"stroke-opacity":n})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:t,points:n,rect:a}=this.serializeDraw(e),{_drawingOptions:{stroke:r,"stroke-opacity":o,"stroke-width":c}}=this,l={annotationType:Iae.INK,color:Xre._colorManager.convert(r),opacity:o,thickness:c,paths:{lines:t,points:n},pageIndex:this.pageIndex,rect:a,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?l:this.annotationElementId&&!this.#Ur(l)?null:(l.id=this.annotationElementId,l)}#Ur(e){const{color:t,thickness:n,opacity:a,pageIndex:r}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||e.color.some(((e,n)=>e!==t[n]))||e.thickness!==n||e.opacity!==a||e.pageIndex!==r}renderAnnotationElement(e){const{points:t,rect:n}=this.serializeDraw(!1);return e.updateEdited({rect:n,thickness:this._drawingOptions["stroke-width"],points:t}),null}}class Fle extends Xre{#jc=null;#Bc=null;#Uc=null;#Wc=null;#$c=null;#qc="";#Gc=null;#Yc=null;#Kc=!1;#Xc=!1;static _type="stamp";static _editorType=Iae.STAMP;constructor(e){super({...e,name:"stampEditor"}),this.#Wc=e.bitmapUrl,this.#$c=e.bitmapFile}static initialize(e,t){Xre.initialize(e,t)}static get supportedTypes(){return ere(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map((e=>`image/${e}`)))}static get supportedTypesStr(){return ere(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(e){return this.supportedTypes.includes(e)}static paste(e,t){t.pasteEditor(Iae.STAMP,{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(e){const t=e.get("hasAltText");return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}#Qc(e,t=!1){e?(this.#jc=e.bitmap,t||(this.#Bc=e.id,this.#Kc=e.isSvg),e.file&&(this.#qc=e.file.name),this.#Jc()):this.remove()}#Zc(){if(this.#Uc=null,this._uiManager.enableWaiting(!1),this.#Gc){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#jc)return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#jc){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(e=null,t=!0){if(this.hasAltTextData())return null;const{mlManager:n}=this._uiManager;if(!n)throw new Error("No ML.");if(!await n.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:a,width:r,height:o}=e||this.copyCanvas(null,null,!0).imageData,c=await n.guess({name:"altText",request:{data:a,width:r,height:o,channels:a.length/(r*o)}});if(!c)throw new Error("No response from the AI service.");if(c.error)throw new Error("Error from the AI service.");if(c.cancel)return null;if(!c.output)throw new Error("No valid response from the AI service.");const l=c.output;return await this.setGuessedAltText(l),t&&!this.hasAltTextData()&&(this.altTextData={alt:l,decorative:!1}),l}#el(){if(this.#Bc)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#Bc).then((e=>this.#Qc(e,!0))).finally((()=>this.#Zc()));if(this.#Wc){const e=this.#Wc;return this.#Wc=null,this._uiManager.enableWaiting(!0),void(this.#Uc=this._uiManager.imageManager.getFromUrl(e).then((e=>this.#Qc(e))).finally((()=>this.#Zc())))}if(this.#$c){const e=this.#$c;return this.#$c=null,this._uiManager.enableWaiting(!0),void(this.#Uc=this._uiManager.imageManager.getFromFile(e).then((e=>this.#Qc(e))).finally((()=>this.#Zc())))}const e=document.createElement("input");e.type="file",e.accept=Fle.supportedTypesStr;const t=this._uiManager._signal;this.#Uc=new Promise((n=>{e.addEventListener("change",(async()=>{if(e.files&&0!==e.files.length){this._uiManager.enableWaiting(!0);const t=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#Qc(t)}else this.remove();n()}),{signal:t}),e.addEventListener("cancel",(()=>{this.remove(),n()}),{signal:t})})).finally((()=>this.#Zc())),e.click()}remove(){this.#Bc&&(this.#jc=null,this._uiManager.imageManager.deleteId(this.#Bc),this.#Gc?.remove(),this.#Gc=null,this.#Yc&&(clearTimeout(this.#Yc),this.#Yc=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#Bc&&null===this.#Gc&&this.#el(),this.isAttachedToDOM||this.parent.add(this))):this.#Bc&&this.#el()}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(this.#Uc||this.#jc||this.#Wc||this.#$c||this.#Bc)}get isResizable(){return!0}render(){if(this.div)return this.div;let e,t;if(this.width&&(e=this.x,t=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#jc?this.#Jc():this.#el(),this.width&&!this.annotationElementId){const[n,a]=this.parentDimensions;this.setAt(e*n,t*a,this.width*n,this.height*a)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(null!==this.#Yc&&clearTimeout(this.#Yc),this.#Yc=setTimeout((()=>{this.#Yc=null,this.#tl()}),200))}#Jc(){const{div:e}=this;let{width:t,height:n}=this.#jc;const[a,r]=this.pageDimensions,o=.75;if(this.width)t=this.width*a,n=this.height*r;else if(t>o*a||n>o*r){const e=Math.min(o*a/t,o*r/n);t*=e,n*=e}const[c,l]=this.parentDimensions;this.setDims(t*c/a,n*l/r),this._uiManager.enableWaiting(!1);const i=this.#Gc=document.createElement("canvas");i.setAttribute("role","img"),this.addContainer(i),this.width=t/a,this.height=n/r,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(e.hidden=!1),this.#tl(),this.#Xc||(this.parent.addUndoableEditor(this),this.#Xc=!0),this._reportTelemetry({action:"inserted_image"}),this.#qc&&i.setAttribute("aria-label",this.#qc)}copyCanvas(e,t,n=!1){e||(e=224);const{width:a,height:r}=this.#jc,o=new Pre;let c=this.#jc,l=a,i=r,s=null;if(t){if(a>t||r>t){const e=Math.min(t/a,t/r);l=Math.floor(a*e),i=Math.floor(r*e)}s=document.createElement("canvas");const e=s.width=Math.ceil(l*o.sx),n=s.height=Math.ceil(i*o.sy);this.#Kc||(c=this.#nl(e,n));const h=s.getContext("2d");h.filter=this._uiManager.hcmFilter;let d="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(d="#8f8f9d",u="#42414d");const m=15,p=m*o.sx,v=m*o.sy,f=new OffscreenCanvas(2*p,2*v),z=f.getContext("2d");z.fillStyle=d,z.fillRect(0,0,2*p,2*v),z.fillStyle=u,z.fillRect(0,0,p,v),z.fillRect(p,v,p,v),h.fillStyle=h.createPattern(f,"repeat"),h.fillRect(0,0,e,n),h.drawImage(c,0,0,c.width,c.height,0,0,e,n)}let h=null;if(n){let t,n;if(o.symmetric&&c.width<e&&c.height<e)t=c.width,n=c.height;else if(c=this.#jc,a>e||r>e){const o=Math.min(e/a,e/r);t=Math.floor(a*o),n=Math.floor(r*o),this.#Kc||(c=this.#nl(t,n))}const l=new OffscreenCanvas(t,n).getContext("2d",{willReadFrequently:!0});l.drawImage(c,0,0,c.width,c.height,0,0,t,n),h={width:t,height:n,data:l.getImageData(0,0,t,n).data}}return{canvas:s,width:l,height:i,imageData:h}}#nl(e,t){const{width:n,height:a}=this.#jc;let r=n,o=a,c=this.#jc;for(;r>2*e||o>2*t;){const n=r,a=o;r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2)),o>2*t&&(o=o>=16384?Math.floor(o/2)-1:Math.ceil(o/2));const l=new OffscreenCanvas(r,o);l.getContext("2d").drawImage(c,0,0,n,a,0,0,r,o),c=l.transferToImageBitmap()}return c}#tl(){const[e,t]=this.parentDimensions,{width:n,height:a}=this,r=new Pre,o=Math.ceil(n*e*r.sx),c=Math.ceil(a*t*r.sy),l=this.#Gc;if(!l||l.width===o&&l.height===c)return;l.width=o,l.height=c;const i=this.#Kc?this.#jc:this.#nl(o,c),s=l.getContext("2d");s.filter=this._uiManager.hcmFilter,s.drawImage(i,0,0,i.width,i.height,0,0,o,c)}getImageForAltText(){return this.#Gc}#al(e){if(e){if(this.#Kc){const e=this._uiManager.imageManager.getSvgUrl(this.#Bc);if(e)return e}const e=document.createElement("canvas");return({width:e.width,height:e.height}=this.#jc),e.getContext("2d").drawImage(this.#jc,0,0),e.toDataURL()}if(this.#Kc){const[e,t]=this.pageDimensions,n=Math.round(this.width*e*Mre.PDF_TO_CSS_UNITS),a=Math.round(this.height*t*Mre.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(n,a);return r.getContext("2d").drawImage(this.#jc,0,0,this.#jc.width,this.#jc.height,0,0,n,a),r.transferToImageBitmap()}return structuredClone(this.#jc)}static async deserialize(e,t,n){let a=null;if(e instanceof yle){const{data:{rect:r,rotation:o,id:c,structParent:l,popupRef:i},container:s,parent:{page:{pageNumber:h}}}=e,d=s.querySelector("canvas"),u=n.imageManager.getFromCanvas(s.id,d);d.remove();const m=(await t._structTree.getAriaAttributes(`${gre}${c}`))?.get("aria-label")||"";a=e={annotationType:Iae.STAMP,bitmapId:u.id,bitmap:u.bitmap,pageIndex:h-1,rect:r.slice(0),rotation:o,id:c,deleted:!1,accessibilityData:{decorative:!1,altText:m},isSvg:!1,structParent:l,popupRef:i}}const r=await super.deserialize(e,t,n),{rect:o,bitmap:c,bitmapUrl:l,bitmapId:i,isSvg:s,accessibilityData:h}=e;i&&n.imageManager.isValidId(i)?(r.#Bc=i,c&&(r.#jc=c)):r.#Wc=l,r.#Kc=s;const[d,u]=r.pageDimensions;return r.width=(o[2]-o[0])/d,r.height=(o[3]-o[1])/u,r.annotationElementId=e.id||null,h&&(r.altTextData=h),r._initialData=a,r.#Xc=!!a,r}serialize(e=!1,t=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const n={annotationType:Iae.STAMP,bitmapId:this.#Bc,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#Kc,structTreeParentId:this._structTreeParentId};if(e)return n.bitmapUrl=this.#al(!0),n.accessibilityData=this.serializeAltText(!0),n;const{decorative:a,altText:r}=this.serializeAltText(!1);if(!a&&r&&(n.accessibilityData={type:"Figure",alt:r}),this.annotationElementId){const e=this.#Ur(n);if(e.isSame)return null;e.isSameAltText?delete n.accessibilityData:n.accessibilityData.structParent=this._initialData.structParent??-1}if(n.id=this.annotationElementId,null===t)return n;t.stamps||=new Map;const o=this.#Kc?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(t.stamps.has(this.#Bc)){if(this.#Kc){const e=t.stamps.get(this.#Bc);o>e.area&&(e.area=o,e.serialized.bitmap.close(),e.serialized.bitmap=this.#al(!1))}}else t.stamps.set(this.#Bc,{area:o,serialized:n}),n.bitmap=this.#al(!1);return n}#Ur(e){const{pageIndex:t,accessibilityData:{altText:n}}=this._initialData,a=e.pageIndex===t,r=(e.accessibilityData?.alt||"")===n;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&a&&r,isSameAltText:r}}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}}class Ile{#Lr;#rl=!1;#ol=null;#cl=null;#ll=null;#il=new Map;#sl=!1;#hl=!1;#dl=!1;#ul=null;#ml=null;#pl=null;#vl=null;#v;static _initialized=!1;static#j=new Map([Hle,Ple,Fle,Ole].map((e=>[e._editorType,e])));constructor({uiManager:e,pageIndex:t,div:n,structTreeLayer:a,accessibilityManager:r,annotationLayer:o,drawLayer:c,textLayer:l,viewport:i,l10n:s}){const h=[...Ile.#j.values()];if(!Ile._initialized){Ile._initialized=!0;for(const t of h)t.initialize(s,e)}e.registerEditorTypes(h),this.#v=e,this.pageIndex=t,this.div=n,this.#Lr=r,this.#ol=o,this.viewport=i,this.#pl=l,this.drawLayer=c,this._structTree=a,this.#v.addLayer(this)}get isEmpty(){return 0===this.#il.size}get isInvisible(){return this.isEmpty&&this.#v.getMode()===Iae.NONE}updateToolbar(e){this.#v.updateToolbar(e)}updateMode(e=this.#v.getMode()){switch(this.#fl(),e){case Iae.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case Iae.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Iae.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:t}=this.div;for(const n of Ile.#j.values())t.toggle(`${n._type}Editing`,e===n._editorType);this.div.hidden=!1}hasTextLayer(e){return e===this.#pl?.div}setEditingState(e){this.#v.setEditingState(e)}addCommands(e){this.#v.addCommands(e)}cleanUndoStack(e){this.#v.cleanUndoStack(e)}toggleDrawing(e=!1){this.div.classList.toggle("drawing",!e)}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}toggleAnnotationLayerPointerEvents(e=!1){this.#ol?.div.classList.toggle("disabled",!e)}async enable(){this.#dl=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);const e=new Set;for(const t of this.#il.values())t.enableEditing(),t.show(!0),t.annotationElementId&&(this.#v.removeChangedExistingAnnotation(t),e.add(t.annotationElementId));if(!this.#ol)return void(this.#dl=!1);const t=this.#ol.getEditableAnnotations();for(const n of t){if(n.hide(),this.#v.isDeletedAnnotationElement(n.data.id))continue;if(e.has(n.data.id))continue;const t=await this.deserialize(n);t&&(this.addOrRebuild(t),t.enableEditing())}this.#dl=!1}disable(){this.#hl=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,t=new Map;for(const n of this.#il.values())n.disableEditing(),n.annotationElementId&&(null===n.serialize()?(t.set(n.annotationElementId,n),this.getEditableAnnotation(n.annotationElementId)?.show(),n.remove()):e.set(n.annotationElementId,n));if(this.#ol){const n=this.#ol.getEditableAnnotations();for(const a of n){const{id:n}=a.data;if(this.#v.isDeletedAnnotationElement(n))continue;let r=t.get(n);r?(r.resetAnnotationElement(a),r.show(!1),a.show()):(r=e.get(n),r&&(this.#v.addChangedExistingAnnotation(r),r.renderAnnotationElement(a)&&r.show(!1)),a.show())}}this.#fl(),this.isEmpty&&(this.div.hidden=!0);const{classList:n}=this.div;for(const e of Ile.#j.values())n.remove(`${e._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#hl=!1}getEditableAnnotation(e){return this.#ol?.getEditableAnnotation(e)||null}setActiveEditor(e){this.#v.getActive()!==e&&this.#v.setActiveEditor(e)}enableTextSelection(){if(this.div.tabIndex=-1,this.#pl?.div&&!this.#vl){this.#vl=new AbortController;const e=this.#v.combinedSignal(this.#vl);this.#pl.div.addEventListener("pointerdown",this.#zl.bind(this),{signal:e}),this.#pl.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#pl?.div&&this.#vl&&(this.#vl.abort(),this.#vl=null,this.#pl.div.classList.remove("highlighting"))}#zl(e){this.#v.unselectAll();const{target:t}=e;if(t===this.#pl.div||("img"===t.getAttribute("role")||t.classList.contains("endOfContent"))&&this.#pl.div.contains(t)){const{isMac:t}=ure.platform;if(0!==e.button||e.ctrlKey&&t)return;this.#v.showAllEditors("highlight",!0,!0),this.#pl.div.classList.add("free"),this.toggleDrawing(),Ole.startHighlighting(this,"ltr"===this.#v.direction,{target:this.#pl.div,x:e.x,y:e.y}),this.#pl.div.addEventListener("pointerup",(()=>{this.#pl.div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:this.#v._signal}),e.preventDefault()}}enableClick(){if(this.#cl)return;this.#cl=new AbortController;const e=this.#v.combinedSignal(this.#cl);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:e});const t=this.pointerup.bind(this);this.div.addEventListener("pointerup",t,{signal:e}),this.div.addEventListener("pointercancel",t,{signal:e})}disableClick(){this.#cl?.abort(),this.#cl=null}attach(e){this.#il.set(e.id,e);const{annotationElementId:t}=e;t&&this.#v.isDeletedAnnotationElement(t)&&this.#v.removeDeletedAnnotationElement(e)}detach(e){this.#il.delete(e.id),this.#Lr?.removePointerInTextLayer(e.contentDiv),!this.#hl&&e.annotationElementId&&this.#v.addDeletedAnnotationElement(e)}remove(e){this.detach(e),this.#v.removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1}changeParent(e){e.parent!==this&&(e.parent&&e.annotationElementId&&(this.#v.addDeletedAnnotationElement(e.annotationElementId),Xre.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),e.parent?.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))}add(e){if(e.parent!==this||!e.isAttachedToDOM){if(this.changeParent(e),this.#v.addEditor(e),this.attach(e),!e.isAttachedToDOM){const t=e.render();this.div.append(t),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(!this.#dl),this.#v.addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){if(!e.isAttachedToDOM)return;const{activeElement:t}=document;e.div.contains(t)&&!this.#ll&&(e._focusEventsAllowed=!1,this.#ll=setTimeout((()=>{this.#ll=null,e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener("focusin",(()=>{e._focusEventsAllowed=!0}),{once:!0,signal:this.#v._signal}),t.focus())}),0)),e._structTreeParentId=this.#Lr?.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?(e.parent||=this,e.rebuild(),e.show()):this.add(e)}addUndoableEditor(e){this.addCommands({cmd:()=>e._uiManager.rebuild(e),undo:()=>{e.remove()},mustExec:!1})}getNextId(){return this.#v.getId()}get#gl(){return Ile.#j.get(this.#v.getMode())}combinedSignal(e){return this.#v.combinedSignal(e)}#yl(e){const t=this.#gl;return t?new t.prototype.constructor(e):null}canCreateNewEmptyEditor(){return this.#gl?.canCreateNewEmptyEditor()}pasteEditor(e,t){this.#v.updateToolbar(e),this.#v.updateMode(e);const{offsetX:n,offsetY:a}=this.#Ml(),r=this.getNextId(),o=this.#yl({parent:this,id:r,x:n,y:a,uiManager:this.#v,isCentered:!0,...t});o&&this.add(o)}async deserialize(e){return await(Ile.#j.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,this.#v))||null}createAndAddNewEditor(e,t,n={}){const a=this.getNextId(),r=this.#yl({parent:this,id:a,x:e.offsetX,y:e.offsetY,uiManager:this.#v,isCentered:t,...n});return r&&this.add(r),r}#Ml(){const{x:e,y:t,width:n,height:a}=this.div.getBoundingClientRect(),r=Math.max(0,e),o=Math.max(0,t),c=(r+Math.min(window.innerWidth,e+n))/2-e,l=(o+Math.min(window.innerHeight,t+a))/2-t,[i,s]=this.viewport.rotation%180==0?[c,l]:[l,c];return{offsetX:i,offsetY:s}}addNewEditor(){this.createAndAddNewEditor(this.#Ml(),!0)}setSelected(e){this.#v.setSelected(e)}toggleSelected(e){this.#v.toggleSelected(e)}unselect(e){this.#v.unselect(e)}pointerup(e){const{isMac:t}=ure.platform;0!==e.button||e.ctrlKey&&t||e.target===this.div&&this.#sl&&(this.#sl=!1,this.#gl?.isDrawer&&this.#gl.supportMultipleDrawings||(this.#rl?this.#v.getMode()!==Iae.STAMP?this.createAndAddNewEditor(e,!1):this.#v.unselectAll():this.#rl=!0))}pointerdown(e){if(this.#v.getMode()===Iae.HIGHLIGHT&&this.enableTextSelection(),this.#sl)return void(this.#sl=!1);const{isMac:t}=ure.platform;if(0!==e.button||e.ctrlKey&&t)return;if(e.target!==this.div)return;if(this.#sl=!0,this.#gl?.isDrawer)return void this.startDrawingSession(e);const n=this.#v.getActive();this.#rl=!n||n.isEmpty()}startDrawingSession(e){if(this.div.focus(),this.#ul)return void this.#gl.startDrawing(this,this.#v,!1,e);this.#v.setCurrentDrawingSession(this),this.#ul=new AbortController;const t=this.#v.combinedSignal(this.#ul);this.div.addEventListener("blur",(({relatedTarget:e})=>{e&&!this.div.contains(e)&&(this.#ml=null,this.commitOrRemove())}),{signal:t}),this.#gl.startDrawing(this,this.#v,!1,e)}pause(e){if(e){const{activeElement:e}=document;this.div.contains(e)&&(this.#ml=e)}else this.#ml&&setTimeout((()=>{this.#ml?.focus(),this.#ml=null}),0)}endDrawingSession(e=!1){return this.#ul?(this.#v.setCurrentDrawingSession(null),this.#ul.abort(),this.#ul=null,this.#ml=null,this.#gl.endDrawing(e)):null}findNewParent(e,t,n){const a=this.#v.findParent(t,n);return null!==a&&a!==this&&(a.changeParent(e),!0)}commitOrRemove(){return!!this.#ul&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#ul&&this.#gl.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#v.getActive()?.parent===this&&(this.#v.commitOrRemove(),this.#v.setActiveEditor(null)),this.#ll&&(clearTimeout(this.#ll),this.#ll=null);for(const e of this.#il.values())this.#Lr?.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove();this.div=null,this.#il.clear(),this.#v.removeLayer(this)}#fl(){for(const e of this.#il.values())e.isEmpty()&&e.remove()}render({viewport:e}){this.viewport=e,Dre(this.div,e);for(const e of this.#v.getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:e}){this.#v.commitOrRemove(),this.#fl();const t=this.viewport.rotation,n=e.rotation;if(this.viewport=e,Dre(this.div,{rotation:n}),t!==n)for(const e of this.#il.values())e.rotate(n)}get pageDimensions(){const{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return this.#v.viewParameters.realScale}}class jle{#rr=null;#y=0;#El=new Map;#bl=new Map;constructor({pageIndex:e}){this.pageIndex=e}setParent(e){if(this.#rr){if(this.#rr!==e){if(this.#El.size>0)for(const t of this.#El.values())t.remove(),e.append(t);this.#rr=e}}else this.#rr=e}static get _svgFactory(){return ere(this,"_svgFactory",new Uce)}static#Hl(e,[t,n,a,r]){const{style:o}=e;o.top=100*n+"%",o.left=100*t+"%",o.width=100*a+"%",o.height=100*r+"%"}#Vl(){const e=jle._svgFactory.create(1,1,!0);return this.#rr.append(e),e.setAttribute("aria-hidden",!0),e}#Cl(e,t){const n=jle._svgFactory.createElement("clipPath");e.append(n);const a=`clip_${t}`;n.setAttribute("id",a),n.setAttribute("clipPathUnits","objectBoundingBox");const r=jle._svgFactory.createElement("use");return n.append(r),r.setAttribute("href",`#${t}`),r.classList.add("clip"),a}#Ll(e,t){for(const[n,a]of Object.entries(t))null===a?e.removeAttribute(n):e.setAttribute(n,a)}draw(e,t=!1,n=!1){const a=this.#y++,r=this.#Vl(),o=jle._svgFactory.createElement("defs");r.append(o);const c=jle._svgFactory.createElement("path");o.append(c);const l=`path_p${this.pageIndex}_${a}`;c.setAttribute("id",l),c.setAttribute("vector-effect","non-scaling-stroke"),t&&this.#bl.set(a,c);const i=n?this.#Cl(o,l):null,s=jle._svgFactory.createElement("use");return r.append(s),s.setAttribute("href",`#${l}`),this.updateProperties(r,e),this.#El.set(a,r),{id:a,clipPathId:`url(#${i})`}}drawOutline(e,t){const n=this.#y++,a=this.#Vl(),r=jle._svgFactory.createElement("defs");a.append(r);const o=jle._svgFactory.createElement("path");r.append(o);const c=`path_p${this.pageIndex}_${n}`;let l;if(o.setAttribute("id",c),o.setAttribute("vector-effect","non-scaling-stroke"),t){const e=jle._svgFactory.createElement("mask");r.append(e),l=`mask_p${this.pageIndex}_${n}`,e.setAttribute("id",l),e.setAttribute("maskUnits","objectBoundingBox");const t=jle._svgFactory.createElement("rect");e.append(t),t.setAttribute("width","1"),t.setAttribute("height","1"),t.setAttribute("fill","white");const a=jle._svgFactory.createElement("use");e.append(a),a.setAttribute("href",`#${c}`),a.setAttribute("stroke","none"),a.setAttribute("fill","black"),a.setAttribute("fill-rule","nonzero"),a.classList.add("mask")}const i=jle._svgFactory.createElement("use");a.append(i),i.setAttribute("href",`#${c}`),l&&i.setAttribute("mask",`url(#${l})`);const s=i.cloneNode();return a.append(s),i.classList.add("mainOutline"),s.classList.add("secondaryOutline"),this.updateProperties(a,e),this.#El.set(n,a),n}finalizeDraw(e,t){this.#bl.delete(e),this.updateProperties(e,t)}updateProperties(e,t){if(!t)return;const{root:n,bbox:a,rootClass:r,path:o}=t,c="number"==typeof e?this.#El.get(e):e;if(c){if(n&&this.#Ll(c,n),a&&jle.#Hl(c,a),r){const{classList:e}=c;for(const[t,n]of Object.entries(r))e.toggle(t,n)}if(o){const e=c.firstChild.firstChild;this.#Ll(e,o)}}}updateParent(e,t){if(t===this)return;const n=this.#El.get(e);n&&(t.#rr.append(n),this.#El.delete(e),t.#El.set(e,n))}remove(e){this.#bl.delete(e),null!==this.#rr&&(this.#El.get(e).remove(),this.#El.delete(e))}destroy(){this.#rr=null;for(const e of this.#El.values())e.remove();this.#El.clear(),this.#bl.clear()}}globalThis.pdfjsTestingUtils={HighlightOutliner:xle};var Ble=Rae.GlobalWorkerOptions,Ule=Rae.TextLayer,Wle=Rae.getDocument;function $le(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var a=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===n&&a.firstChild?a.insertBefore(r,a.firstChild):a.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}$le('.messageBar{--closing-button-icon:url(images/messageBar_closingButton.svg);--message-bar-close-button-color:var(--text-primary-color);--message-bar-close-button-color-hover:var(--text-primary-color);--message-bar-close-button-border-radius:4px;--message-bar-close-button-border:none;--message-bar-close-button-hover-bg-color:#15141a24;--message-bar-close-button-active-bg-color:#15141a36;--message-bar-close-button-focus-bg-color:#15141a12}@media (prefers-color-scheme:dark){.messageBar{--message-bar-close-button-hover-bg-color:#fbfbfe24;--message-bar-close-button-active-bg-color:#fbfbfe36;--message-bar-close-button-focus-bg-color:#fbfbfe12}}@media screen and (forced-colors:active){.messageBar{--message-bar-close-button-color:ButtonText;--message-bar-close-button-border:1px solid ButtonText;--message-bar-close-button-hover-bg-color:ButtonText;--message-bar-close-button-active-bg-color:ButtonText;--message-bar-close-button-focus-bg-color:ButtonText;--message-bar-close-button-color-hover:HighlightText}}.messageBar{align-items:center;background:var(--message-bar-bg-color);border:1px solid var(--message-bar-border-color);border-radius:4px;color:var(--message-bar-fg-color);display:flex;flex-direction:column;gap:8px;justify-content:center;padding:8px 8px 8px 16px;position:relative;-webkit-user-select:none;-moz-user-select:none;user-select:none}.messageBar>div{align-items:flex-start;align-self:stretch;display:flex;gap:8px}:is(.messageBar>div):before{background-color:var(--message-bar-icon-color);content:"";display:inline-block;flex-shrink:0;height:16px;-webkit-mask-image:var(--message-bar-icon);mask-image:var(--message-bar-icon);-webkit-mask-size:cover;mask-size:cover;width:16px}.messageBar button{cursor:pointer}:is(.messageBar button):focus-visible{outline:var(--focus-ring-outline);outline-offset:2px}.messageBar .closeButton{align-items:center;background:none;border:var(--message-bar-close-button-border);border-radius:var(--message-bar-close-button-border-radius);display:flex;height:32px;justify-content:center;width:32px}:is(.messageBar .closeButton):before{background-color:var(--message-bar-close-button-color);content:"";display:inline-block;height:16px;-webkit-mask-image:var(--closing-button-icon);mask-image:var(--closing-button-icon);-webkit-mask-size:cover;mask-size:cover;width:16px}:is(.messageBar .closeButton):is(:hover,:active,:focus):before{background-color:var(--message-bar-close-button-color-hover)}:is(.messageBar .closeButton):hover{background-color:var(--message-bar-close-button-hover-bg-color)}:is(.messageBar .closeButton):active{background-color:var(--message-bar-close-button-active-bg-color)}:is(.messageBar .closeButton):focus{background-color:var(--message-bar-close-button-focus-bg-color)}:is(.messageBar .closeButton)>span{display:inline-block;height:0;overflow:hidden;width:0}#editorUndoBar{--text-primary-color:#15141a;--message-bar-icon:url(images/secondaryToolbarButton-documentProperties.svg);--message-bar-icon-color:#0060df;--message-bar-bg-color:#deeafc;--message-bar-fg-color:var(--text-primary-color);--message-bar-border-color:#00000014;--undo-button-bg-color:#15141a12;--undo-button-bg-color-hover:#15141a24;--undo-button-bg-color-active:#15141a36;--undo-button-fg-color:var(--message-bar-fg-color);--undo-button-fg-color-hover:var(--undo-button-fg-color);--undo-button-fg-color-active:var(--undo-button-fg-color);--focus-ring-color:#0060df;--focus-ring-outline:2px solid var(--focus-ring-color)}@media (prefers-color-scheme:dark){#editorUndoBar{--text-primary-color:#fbfbfe;--message-bar-icon-color:#73a7f3;--message-bar-bg-color:#003070;--message-bar-border-color:#ffffff14;--undo-button-bg-color:#ffffff14;--undo-button-bg-color-hover:#ffffff24;--undo-button-bg-color-active:#ffffff36}}@media screen and (forced-colors:active){#editorUndoBar{--text-primary-color:CanvasText;--message-bar-icon-color:CanvasText;--message-bar-bg-color:Canvas;--message-bar-border-color:CanvasText;--undo-button-bg-color:ButtonText;--undo-button-bg-color-hover:SelectedItem;--undo-button-bg-color-active:SelectedItem;--undo-button-fg-color:ButtonFace;--undo-button-fg-color-hover:SelectedItemText;--undo-button-fg-color-active:SelectedItemText;--focus-ring-color:CanvasText}}#editorUndoBar{cursor:default;font:menu;font-size:15px;left:50%;padding-block:8px;padding-inline:16px 8px;position:fixed;top:50px;transform:translateX(-50%);z-index:10}#editorUndoBar button{cursor:pointer}#editorUndoBar #editorUndoBarUndoButton{background-color:var(--undo-button-bg-color);border:none;border-radius:4px;color:var(--undo-button-fg-color);font-weight:590;height:32px;line-height:19.5px;margin-inline-start:8px;padding:4px 16px}:is(#editorUndoBar #editorUndoBarUndoButton):hover{background-color:var(--undo-button-bg-color-hover);color:var(--undo-button-fg-color-hover)}:is(#editorUndoBar #editorUndoBarUndoButton):active{background-color:var(--undo-button-bg-color-active);color:var(--undo-button-fg-color-active)}#editorUndoBar>div{align-items:center}.dialog{--dialog-bg-color:#fff;--dialog-border-color:#fff;--dialog-shadow:0 2px 14px 0 #3a394433;--text-primary-color:#15141a;--text-secondary-color:#5b5b66;--hover-filter:brightness(0.9);--focus-ring-color:#0060df;--focus-ring-outline:2px solid var(--focus-ring-color);--link-fg-color:#0060df;--link-hover-fg-color:#0250bb;--separator-color:#f0f0f4;--textarea-border-color:#8f8f9d;--textarea-bg-color:#fff;--textarea-fg-color:var(--text-secondary-color);--radio-bg-color:#f0f0f4;--radio-checked-bg-color:#fbfbfe;--radio-border-color:#8f8f9d;--radio-checked-border-color:#0060df;--button-secondary-bg-color:#f0f0f4;--button-secondary-fg-color:var(--text-primary-color);--button-secondary-border-color:var(--button-secondary-bg-color);--button-secondary-hover-bg-color:var(--button-secondary-bg-color);--button-secondary-hover-fg-color:var(--button-secondary-fg-color);--button-secondary-hover-border-color:var(--button-secondary-hover-bg-color);--button-primary-bg-color:#0060df;--button-primary-fg-color:#fbfbfe;--button-primary-border-color:var(--button-primary-bg-color);--button-primary-hover-bg-color:var(--button-primary-bg-color);--button-primary-hover-fg-color:var(--button-primary-fg-color);--button-primary-hover-border-color:var(--button-primary-hover-bg-color)}@media (prefers-color-scheme:dark){.dialog{--dialog-bg-color:#1c1b22;--dialog-border-color:#1c1b22;--dialog-shadow:0 2px 14px 0 #15141a;--text-primary-color:#fbfbfe;--text-secondary-color:#cfcfd8;--focus-ring-color:#0df;--hover-filter:brightness(1.4);--link-fg-color:#0df;--link-hover-fg-color:#80ebff;--separator-color:#52525e;--textarea-bg-color:#42414d;--radio-bg-color:#2b2a33;--radio-checked-bg-color:#15141a;--radio-checked-border-color:#0df;--button-secondary-bg-color:#2b2a33;--button-primary-bg-color:#0df;--button-primary-fg-color:#15141a}}@media screen and (forced-colors:active){.dialog{--dialog-bg-color:Canvas;--dialog-border-color:CanvasText;--dialog-shadow:none;--text-primary-color:CanvasText;--text-secondary-color:CanvasText;--hover-filter:none;--focus-ring-color:ButtonBorder;--link-fg-color:LinkText;--link-hover-fg-color:LinkText;--separator-color:CanvasText;--textarea-border-color:ButtonBorder;--textarea-bg-color:Field;--textarea-fg-color:ButtonText;--radio-bg-color:ButtonFace;--radio-checked-bg-color:ButtonFace;--radio-border-color:ButtonText;--radio-checked-border-color:ButtonText;--button-secondary-bg-color:ButtonFace;--button-secondary-fg-color:ButtonText;--button-secondary-border-color:ButtonText;--button-secondary-hover-bg-color:AccentColor;--button-secondary-hover-fg-color:AccentColorText;--button-primary-bg-color:ButtonText;--button-primary-fg-color:ButtonFace;--button-primary-hover-bg-color:AccentColor;--button-primary-hover-fg-color:AccentColorText}}.dialog{background:var(--dialog-bg-color);border:1px solid var(--dialog-border-color);border-radius:4px;box-shadow:var(--dialog-shadow);color:var(--text-primary-color);font:message-box;font-size:13px;font-weight:400;line-height:150%;padding:12px 16px}:is(.dialog .mainContainer) :focus-visible{outline:var(--focus-ring-outline);outline-offset:2px}:is(.dialog .mainContainer) .title{align-items:flex-start;display:flex;flex-direction:column;gap:12px;justify-content:flex-end;width:auto}:is(:is(.dialog .mainContainer) .title)>span{font-size:13px;font-style:normal;font-weight:590;line-height:150%}:is(.dialog .mainContainer) .dialogSeparator{border-bottom:none;border-top:1px solid var(--separator-color);height:0;margin-block:4px;width:100%}:is(.dialog .mainContainer) .dialogButtonsGroup{align-self:flex-end;display:flex;gap:12px}:is(.dialog .mainContainer) .radio{align-items:flex-start;display:flex;flex-direction:column;gap:4px}:is(:is(.dialog .mainContainer) .radio)>.radioButton{align-items:center;align-self:stretch;display:flex;gap:8px}:is(:is(:is(.dialog .mainContainer) .radio)>.radioButton) input{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:var(--radio-bg-color);border:1px solid var(--radio-border-color);border-radius:50%;box-sizing:border-box;height:16px;width:16px}:is(:is(:is(:is(.dialog .mainContainer) .radio)>.radioButton) input):hover{filter:var(--hover-filter)}:is(:is(:is(:is(.dialog .mainContainer) .radio)>.radioButton) input):checked{background-color:var(--radio-checked-bg-color);border:4px solid var(--radio-checked-border-color)}:is(:is(.dialog .mainContainer) .radio)>.radioLabel{align-items:flex-start;align-self:stretch;display:flex;gap:10px;padding-inline-start:24px}:is(:is(:is(.dialog .mainContainer) .radio)>.radioLabel)>span{color:var(--text-secondary-color);flex:1 0 0;font-size:11px}:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton)){border:1px solid;border-radius:4px;font:menu;font-weight:600;height:32px;padding:4px 16px;width:auto}:is(:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton))):hover{cursor:pointer;filter:var(--hover-filter)}.secondaryButton:is(:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton))){background-color:var(--button-secondary-bg-color);border-color:var(--button-secondary-border-color);color:var(--button-secondary-fg-color)}.secondaryButton:is(:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton))):hover{background-color:var(--button-secondary-hover-bg-color);border-color:var(--button-secondary-hover-border-color);color:var(--button-secondary-hover-fg-color)}.primaryButton:is(:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton))){background-color:var(--button-primary-bg-color);border-color:var(--button-primary-border-color);color:var(--button-primary-fg-color);opacity:1}.primaryButton:is(:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton))):hover{background-color:var(--button-primary-hover-bg-color);border-color:var(--button-primary-hover-border-color);color:var(--button-primary-hover-fg-color)}:is(.dialog .mainContainer) a{color:var(--link-fg-color)}:is(:is(.dialog .mainContainer) a):hover{color:var(--link-hover-fg-color)}:is(.dialog .mainContainer) textarea{background:var(--textarea-bg-color);border:1px solid var(--textarea-border-color);border-radius:4px;box-sizing:border-box;color:var(--textarea-fg-color);font:inherit;margin:0;padding:8px;resize:none}:is(:is(.dialog .mainContainer) textarea):focus{border-color:#0000;outline-offset:0}:is(:is(.dialog .mainContainer) textarea):disabled{opacity:.4;pointer-events:none}:is(.dialog .mainContainer) .messageBar{--message-bar-bg-color:#ffebcd;--message-bar-fg-color:#15141a;--message-bar-border-color:#00000014;--message-bar-icon:url(images/messageBar_warning.svg);--message-bar-icon-color:#cd411e}@media (prefers-color-scheme:dark){:is(.dialog .mainContainer) .messageBar{--message-bar-bg-color:#5a3100;--message-bar-fg-color:#fbfbfe;--message-bar-border-color:#ffffff14;--message-bar-icon-color:#e49c49}}@media screen and (forced-colors:active){:is(.dialog .mainContainer) .messageBar{--message-bar-bg-color:HighlightText;--message-bar-fg-color:CanvasText;--message-bar-border-color:CanvasText;--message-bar-icon-color:CanvasText}}:is(.dialog .mainContainer) .messageBar{align-self:stretch}:is(:is(:is(.dialog .mainContainer) .messageBar)>div):before,:is(:is(:is(.dialog .mainContainer) .messageBar)>div)>div{margin-block:4px}:is(:is(:is(.dialog .mainContainer) .messageBar)>div)>div{align-items:flex-start;display:flex;flex:1 0 0;flex-direction:column;gap:8px}:is(:is(:is(:is(.dialog .mainContainer) .messageBar)>div)>div) .title{font-size:13px;font-weight:590}:is(:is(:is(:is(.dialog .mainContainer) .messageBar)>div)>div) .description{font-size:13px}:is(.dialog .mainContainer) .toggler{align-items:center;align-self:stretch;display:flex;gap:8px}:is(:is(.dialog .mainContainer) .toggler)>.togglerLabel{-webkit-user-select:none;-moz-user-select:none;user-select:none}.textLayer{-webkit-text-size-adjust:none;-moz-text-size-adjust:none;text-size-adjust:none;caret-color:CanvasText;forced-color-adjust:none;inset:0;line-height:1;opacity:1;overflow:clip;position:absolute;text-align:initial;transform-origin:0 0;z-index:0}.textLayer.highlighting{touch-action:none}.textLayer :is(span,br){color:#0000;cursor:text;position:absolute;transform-origin:0 0;white-space:pre}.textLayer .markedContent span:not(.markedContent),.textLayer>:not(.markedContent){z-index:1}.textLayer span.markedContent{height:0;top:0}.textLayer span[role=img]{cursor:default;-webkit-user-select:none;-moz-user-select:none;user-select:none}.textLayer .highlight{--highlight-bg-color:#b400aa40;--highlight-selected-bg-color:#00640040;--highlight-backdrop-filter:none;--highlight-selected-backdrop-filter:none}@media screen and (forced-colors:active){.textLayer .highlight{--highlight-bg-color:#0000;--highlight-selected-bg-color:#0000;--highlight-backdrop-filter:var(--hcm-highlight-filter);--highlight-selected-backdrop-filter:var(\n --hcm-highlight-selected-filter\n )}}.textLayer .highlight{-webkit-backdrop-filter:var(--highlight-backdrop-filter);backdrop-filter:var(--highlight-backdrop-filter);background-color:var(--highlight-bg-color);border-radius:4px;margin:-1px;padding:1px}.appended:is(.textLayer .highlight){position:static}.begin:is(.textLayer .highlight){border-radius:4px 0 0 4px}.end:is(.textLayer .highlight){border-radius:0 4px 4px 0}.middle:is(.textLayer .highlight){border-radius:0}.selected:is(.textLayer .highlight){-webkit-backdrop-filter:var(--highlight-selected-backdrop-filter);backdrop-filter:var(--highlight-selected-backdrop-filter);background-color:var(--highlight-selected-bg-color)}.textLayer ::-moz-selection{background:#0000ff40;background:color-mix(in srgb,AccentColor,#0000 75%)}.textLayer ::selection{background:#0000ff40;background:color-mix(in srgb,AccentColor,#0000 75%)}.textLayer br::-moz-selection{background:#0000}.textLayer br::selection{background:#0000}.textLayer .endOfContent{cursor:default;display:block;inset:100% 0 0;position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:0}.textLayer.selecting .endOfContent{top:0}.annotationLayer{--annotation-unfocused-field-background:url(\'data:image/svg+xml;charset=utf-8,<svg width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%" style="fill:rgba(0,54,255,.13)"/></svg>\');--input-focus-border-color:Highlight;--input-focus-outline:1px solid Canvas;--input-unfocused-border-color:#0000;--input-disabled-border-color:#0000;--input-hover-border-color:#000;--link-outline:none}@media screen and (forced-colors:active){.annotationLayer{--input-focus-border-color:CanvasText;--input-unfocused-border-color:ActiveText;--input-disabled-border-color:GrayText;--input-hover-border-color:Highlight;--link-outline:1.5px solid LinkText}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input:required,.annotationLayer .choiceWidgetAnnotation select:required,.annotationLayer .textWidgetAnnotation :is(input,textarea):required{outline:1.5px solid selectedItem}.annotationLayer .linkAnnotation{outline:var(--link-outline)}:is(.annotationLayer .linkAnnotation):hover{-webkit-backdrop-filter:var(--hcm-highlight-filter);backdrop-filter:var(--hcm-highlight-filter)}:is(.annotationLayer .linkAnnotation)>a:hover{background:none!important;box-shadow:none;opacity:0!important}.annotationLayer .popupAnnotation .popup{background-color:ButtonFace!important;color:ButtonText!important;outline:calc(1.5px*var(--scale-factor)) solid CanvasText!important}.annotationLayer .highlightArea:hover:after{-webkit-backdrop-filter:var(--hcm-highlight-filter);backdrop-filter:var(--hcm-highlight-filter);content:"";height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%}.annotationLayer .popupAnnotation.focused .popup{outline:calc(3px*var(--scale-factor)) solid Highlight!important}}.annotationLayer{left:0;pointer-events:none;position:absolute;top:0;transform-origin:0 0}.annotationLayer[data-main-rotation="90"] .norotate{transform:rotate(270deg) translateX(-100%)}.annotationLayer[data-main-rotation="180"] .norotate{transform:rotate(180deg) translate(-100%,-100%)}.annotationLayer[data-main-rotation="270"] .norotate{transform:rotate(90deg) translateY(-100%)}.annotationLayer.disabled .popup,.annotationLayer.disabled section{pointer-events:none}.annotationLayer .annotationContent{height:100%;pointer-events:none;position:absolute;width:100%}.freetext:is(.annotationLayer .annotationContent){background:#0000;border:none;font:10px sans-serif;inset:0;line-height:1.35;overflow:visible;-webkit-user-select:none;-moz-user-select:none;user-select:none;white-space:nowrap}.annotationLayer section{box-sizing:border-box;pointer-events:auto;position:absolute;text-align:initial;transform-origin:0 0}:is(.annotationLayer section):has(div.annotationContent) canvas.annotationContent{display:none}.textLayer.selecting~.annotationLayer section{pointer-events:none}.annotationLayer :is(.linkAnnotation,.buttonWidgetAnnotation.pushButton)>a{font-size:1em;height:100%;left:0;position:absolute;top:0;width:100%}.annotationLayer :is(.linkAnnotation,.buttonWidgetAnnotation.pushButton):not(.hasBorder)>a:hover{background-color:#ff0;box-shadow:0 2px 10px #ff0;opacity:.2}.annotationLayer .linkAnnotation.hasBorder:hover{background-color:#ff03}.annotationLayer .hasBorder{background-size:100% 100%}.annotationLayer .textAnnotation img{cursor:pointer;height:100%;left:0;position:absolute;top:0;width:100%}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input,.annotationLayer .choiceWidgetAnnotation select,.annotationLayer .textWidgetAnnotation :is(input,textarea){background-image:var(--annotation-unfocused-field-background);border:2px solid var(--input-unfocused-border-color);box-sizing:border-box;font:calc(9px*var(--scale-factor)) sans-serif;height:100%;margin:0;vertical-align:top;width:100%}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input:required,.annotationLayer .choiceWidgetAnnotation select:required,.annotationLayer .textWidgetAnnotation :is(input,textarea):required{outline:1.5px solid red}.annotationLayer .choiceWidgetAnnotation select option{padding:0}.annotationLayer .buttonWidgetAnnotation.radioButton input{border-radius:50%}.annotationLayer .textWidgetAnnotation textarea{resize:none}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input[disabled],.annotationLayer .choiceWidgetAnnotation select[disabled],.annotationLayer .textWidgetAnnotation [disabled]:is(input,textarea){background:none;border:2px solid var(--input-disabled-border-color);cursor:not-allowed}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input:hover,.annotationLayer .choiceWidgetAnnotation select:hover,.annotationLayer .textWidgetAnnotation :is(input,textarea):hover{border:2px solid var(--input-hover-border-color)}.annotationLayer .buttonWidgetAnnotation.checkBox input:hover,.annotationLayer .choiceWidgetAnnotation select:hover,.annotationLayer .textWidgetAnnotation :is(input,textarea):hover{border-radius:2px}.annotationLayer .choiceWidgetAnnotation select:focus,.annotationLayer .textWidgetAnnotation :is(input,textarea):focus{background:none;border:2px solid var(--input-focus-border-color);border-radius:2px;outline:var(--input-focus-outline)}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) :focus{background-color:initial;background-image:none}.annotationLayer .buttonWidgetAnnotation.checkBox :focus{border:2px solid var(--input-focus-border-color);border-radius:2px;outline:var(--input-focus-outline)}.annotationLayer .buttonWidgetAnnotation.radioButton :focus{border:2px solid var(--input-focus-border-color);outline:var(--input-focus-outline)}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after,.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before,.annotationLayer .buttonWidgetAnnotation.radioButton input:checked:before{background-color:CanvasText;content:"";display:block;position:absolute}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after,.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before{height:80%;left:45%;width:1px}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before{transform:rotate(45deg)}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after{transform:rotate(-45deg)}.annotationLayer .buttonWidgetAnnotation.radioButton input:checked:before{border-radius:50%;height:50%;left:25%;top:25%;width:50%}.annotationLayer .textWidgetAnnotation input.comb{font-family:monospace;padding-left:2px;padding-right:0}.annotationLayer .textWidgetAnnotation input.comb:focus{width:103%}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input{-webkit-appearance:none;-moz-appearance:none;appearance:none}.annotationLayer .fileAttachmentAnnotation .popupTriggerArea{height:100%;width:100%}.annotationLayer .popupAnnotation{font-size:calc(9px*var(--scale-factor));height:auto;max-width:45%;pointer-events:none;position:absolute;width:-moz-max-content;width:max-content}.annotationLayer .popup{word-wrap:break-word;background-color:#ff9;border-radius:calc(2px*var(--scale-factor));box-shadow:0 calc(2px*var(--scale-factor)) calc(5px*var(--scale-factor)) #888;cursor:pointer;font:message-box;outline:1.5px solid #ffff4a;padding:calc(6px*var(--scale-factor));pointer-events:auto;white-space:normal}.annotationLayer .popupAnnotation.focused .popup{outline-width:3px}.annotationLayer .popup *{font-size:calc(9px*var(--scale-factor))}.annotationLayer .popup>.header{display:inline-block}.annotationLayer .popup>.header h1{display:inline}.annotationLayer .popup>.header .popupDate{display:inline-block;margin-left:calc(5px*var(--scale-factor));width:-moz-fit-content;width:fit-content}.annotationLayer .popupContent{border-top:1px solid #333;margin-top:calc(2px*var(--scale-factor));padding-top:calc(2px*var(--scale-factor))}.annotationLayer .richText>*{font-size:calc(9px*var(--scale-factor));white-space:pre-wrap}.annotationLayer .popupTriggerArea{cursor:pointer}.annotationLayer section svg{height:100%;left:0;position:absolute;top:0;width:100%}.annotationLayer .annotationTextContent{color:#0000;height:100%;opacity:0;pointer-events:none;position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100%}:is(.annotationLayer .annotationTextContent) span{display:inline-block;width:100%}.annotationLayer svg.quadrilateralsContainer{contain:strict;height:0;left:0;position:absolute;top:0;width:0;z-index:-1}:root{--xfa-unfocused-field-background:url(\'data:image/svg+xml;charset=utf-8,<svg width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%" style="fill:rgba(0,54,255,.13)"/></svg>\');--xfa-focus-outline:auto}@media screen and (forced-colors:active){:root{--xfa-focus-outline:2px solid CanvasText}.xfaLayer :required{outline:1.5px solid selectedItem}}.xfaLayer{background-color:initial}.xfaLayer .highlight{background-color:#efcbed;border-radius:4px;margin:-1px;padding:1px}.xfaLayer .highlight.appended{position:static}.xfaLayer .highlight.begin{border-radius:4px 0 0 4px}.xfaLayer .highlight.end{border-radius:0 4px 4px 0}.xfaLayer .highlight.middle{border-radius:0}.xfaLayer .highlight.selected{background-color:#cbdfcb}.xfaPage{overflow:hidden;position:relative}.xfaContentarea{position:absolute}.xfaPrintOnly{display:none}.xfaLayer{left:0;line-height:1.2;position:absolute;text-align:initial;top:0;transform-origin:0 0}.xfaLayer *{background-color:initial;box-sizing:border-box;color:inherit;font:inherit;font-kerning:inherit;font-style:inherit;font-weight:inherit;letter-spacing:-.01px;line-height:inherit;margin:0;padding:0;pointer-events:auto;text-align:inherit;text-decoration:inherit}.xfaLayer :required{outline:1.5px solid red}.xfaLayer div,.xfaLayer svg,.xfaLayer svg *{pointer-events:none}.xfaLayer a{color:blue}.xfaRich li{margin-left:3em}.xfaFont{color:#000;font-kerning:none;font-size:10px;font-style:normal;font-weight:400;letter-spacing:0;text-decoration:none;vertical-align:0}.xfaCaption{flex:0 0 auto;overflow:hidden}.xfaCaptionForCheckButton{flex:1 1 auto;overflow:hidden}.xfaLabel{height:100%;width:100%}.xfaLeft{flex-direction:row}.xfaLeft,.xfaRight{align-items:center;display:flex}.xfaRight{flex-direction:row-reverse}:is(.xfaLeft,.xfaRight)>:is(.xfaCaption,.xfaCaptionForCheckButton){max-height:100%}.xfaTop{flex-direction:column}.xfaBottom,.xfaTop{align-items:flex-start;display:flex}.xfaBottom{flex-direction:column-reverse}:is(.xfaTop,.xfaBottom)>:is(.xfaCaption,.xfaCaptionForCheckButton){width:100%}.xfaBorder{background-color:initial;pointer-events:none;position:absolute}.xfaWrapped{height:100%;width:100%}:is(.xfaTextfield,.xfaSelect):focus{background-color:initial;background-image:none;outline:var(--xfa-focus-outline);outline-offset:-1px}:is(.xfaCheckbox,.xfaRadio):focus{outline:var(--xfa-focus-outline)}.xfaSelect,.xfaTextfield{background-image:var(--xfa-unfocused-field-background);border:none;flex:1 1 auto;height:100%;resize:none;width:100%}.xfaSelect{padding-inline:2px}:is(.xfaTop,.xfaBottom)>:is(.xfaTextfield,.xfaSelect){flex:0 1 auto}.xfaButton{border:none;cursor:pointer;text-align:center}.xfaButton,.xfaLink{height:100%;width:100%}.xfaLink{left:0;position:absolute;top:0}.xfaCheckbox,.xfaRadio{border:none;flex:0 0 auto;height:100%;width:100%}.xfaRich{white-space:pre-wrap}.xfaImage,.xfaRich{height:100%;width:100%}.xfaImage{-o-object-fit:contain;object-fit:contain;-o-object-position:left top;object-position:left top}.xfaLrTb,.xfaRlTb,.xfaTb{flex-direction:column}.xfaLr,.xfaLrTb,.xfaRlTb,.xfaTb{align-items:stretch;display:flex}.xfaLr{flex-direction:row}.xfaRl{align-items:stretch;display:flex;flex-direction:row-reverse}.xfaTb>div{justify-content:left}.xfaArea,.xfaPosition{position:relative}.xfaValignMiddle{align-items:center;display:flex}.xfaTable{flex-direction:column}.xfaTable,.xfaTable .xfaRow{align-items:stretch;display:flex}.xfaTable .xfaRow{flex-direction:row}.xfaTable .xfaRlRow{align-items:stretch;display:flex;flex:1;flex-direction:row-reverse}.xfaTable .xfaRlRow>div{flex:1}:is(.xfaNonInteractive,.xfaDisabled,.xfaReadOnly) :is(input,textarea){background:initial}@media print{.xfaSelect,.xfaTextfield{background:#0000}.xfaSelect{-webkit-appearance:none;-moz-appearance:none;appearance:none;text-indent:1px;text-overflow:""}}.canvasWrapper svg{transform:none}.moving:is(.canvasWrapper svg){z-index:100000}[data-main-rotation="90"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) mask,[data-main-rotation="90"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) use:not(.clip,.mask){transform:matrix(0,1,-1,0,1,0)}[data-main-rotation="180"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) mask,[data-main-rotation="180"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) use:not(.clip,.mask){transform:matrix(-1,0,0,-1,1,1)}[data-main-rotation="270"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) mask,[data-main-rotation="270"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) use:not(.clip,.mask){transform:matrix(0,-1,1,0,0,1)}.draw:is(.canvasWrapper svg){mix-blend-mode:normal;position:absolute}.draw[data-draw-rotation="90"]:is(.canvasWrapper svg){transform:rotate(90deg)}.draw[data-draw-rotation="180"]:is(.canvasWrapper svg){transform:rotate(180deg)}.draw[data-draw-rotation="270"]:is(.canvasWrapper svg){transform:rotate(270deg)}.highlight:is(.canvasWrapper svg){--blend-mode:multiply}@media screen and (forced-colors:active){.highlight:is(.canvasWrapper svg){--blend-mode:difference}}.highlight:is(.canvasWrapper svg){mix-blend-mode:var(--blend-mode);position:absolute}.highlight:is(.canvasWrapper svg):not(.free){fill-rule:evenodd}.highlightOutline:is(.canvasWrapper svg){fill-rule:evenodd;fill:none;mix-blend-mode:normal;position:absolute}.highlightOutline.hovered:is(.canvasWrapper svg):not(.free):not(.selected){stroke:var(--hover-outline-color);stroke-width:var(--outline-width)}.highlightOutline.selected:is(.canvasWrapper svg):not(.free) .mainOutline{stroke:var(--outline-around-color);stroke-width:calc(var(--outline-width) + var(--outline-around-width)*2)}.highlightOutline.selected:is(.canvasWrapper svg):not(.free) .secondaryOutline{stroke:var(--outline-color);stroke-width:var(--outline-width)}.highlightOutline.free.hovered:is(.canvasWrapper svg):not(.selected){stroke:var(--hover-outline-color);stroke-width:calc(var(--outline-width)*2)}.highlightOutline.free.selected:is(.canvasWrapper svg) .mainOutline{stroke:var(--outline-around-color);stroke-width:calc((var(--outline-width) + var(--outline-around-width))*2)}.highlightOutline.free.selected:is(.canvasWrapper svg) .secondaryOutline{stroke:var(--outline-color);stroke-width:calc(var(--outline-width)*2)}.toggle-button{--button-background-color:#f0f0f4;--button-background-color-hover:#e0e0e6;--button-background-color-active:#cfcfd8;--color-accent-primary:#0060df;--color-accent-primary-hover:#0250bb;--color-accent-primary-active:#054096;--border-interactive-color:#8f8f9d;--border-radius-circle:9999px;--border-width:1px;--size-item-small:16px;--size-item-large:32px;--color-canvas:#fff}@media (prefers-color-scheme:dark){.toggle-button{--button-background-color:color-mix(in srgb,currentColor 7%,#0000);--button-background-color-hover:color-mix(in srgb,currentColor 14%,#0000);--button-background-color-active:color-mix(in srgb,currentColor 21%,#0000);--color-accent-primary:#0df;--color-accent-primary-hover:#80ebff;--color-accent-primary-active:#aaf2ff;--border-interactive-color:#bfbfc9;--color-canvas:#1c1b22}}@media (forced-colors:active){.toggle-button{--color-accent-primary:ButtonText;--color-accent-primary-hover:SelectedItem;--color-accent-primary-active:SelectedItem;--border-interactive-color:ButtonText;--button-background-color:ButtonFace;--border-interactive-color-hover:SelectedItem;--border-interactive-color-active:SelectedItem;--border-interactive-color-disabled:GrayText;--color-canvas:ButtonText}}.toggle-button{--toggle-background-color:var(--button-background-color);--toggle-background-color-hover:var(--button-background-color-hover);--toggle-background-color-active:var(--button-background-color-active);--toggle-background-color-pressed:var(--color-accent-primary);--toggle-background-color-pressed-hover:var(--color-accent-primary-hover);--toggle-background-color-pressed-active:var(--color-accent-primary-active);--toggle-border-color:var(--border-interactive-color);--toggle-border-color-hover:var(--toggle-border-color);--toggle-border-color-active:var(--toggle-border-color);--toggle-border-radius:var(--border-radius-circle);--toggle-border-width:var(--border-width);--toggle-height:var(--size-item-small);--toggle-width:var(--size-item-large);--toggle-dot-background-color:var(--toggle-border-color);--toggle-dot-background-color-hover:var(--toggle-dot-background-color);--toggle-dot-background-color-active:var(--toggle-dot-background-color);--toggle-dot-background-color-on-pressed:var(--color-canvas);--toggle-dot-margin:1px;--toggle-dot-height:calc(var(--toggle-height) - var(--toggle-dot-margin)*2 - var(--toggle-border-width)*2);--toggle-dot-width:var(--toggle-dot-height);--toggle-dot-transform-x:calc(var(--toggle-width) - var(--toggle-dot-margin)*4 - var(--toggle-dot-width));-webkit-appearance:none;-moz-appearance:none;appearance:none;background:var(--toggle-background-color);border:var(--toggle-border-width) solid var(--toggle-border-color);border-radius:var(--toggle-border-radius);box-sizing:border-box;flex-shrink:0;height:var(--toggle-height);margin:0;padding:0;width:var(--toggle-width)}.toggle-button:focus-visible{outline:var(--focus-outline);outline-offset:var(--focus-outline-offset)}.toggle-button:enabled:hover{background:var(--toggle-background-color-hover);border-color:var(--toggle-border-color)}.toggle-button:enabled:active{background:var(--toggle-background-color-active);border-color:var(--toggle-border-color)}.toggle-button[aria-pressed=true]{background:var(--toggle-background-color-pressed);border-color:#0000}.toggle-button[aria-pressed=true]:enabled:hover{background:var(--toggle-background-color-pressed-hover);border-color:#0000}.toggle-button[aria-pressed=true]:enabled:active{background:var(--toggle-background-color-pressed-active);border-color:#0000}.toggle-button:before{background-color:var(--toggle-dot-background-color);border-radius:var(--toggle-border-radius);content:"";display:block;height:var(--toggle-dot-height);margin:var(--toggle-dot-margin);translate:0;width:var(--toggle-dot-width)}.toggle-button[aria-pressed=true]:before{translate:var(--toggle-dot-transform-x)}.toggle-button[aria-pressed=true]:before,.toggle-button[aria-pressed=true]:enabled:active:before,.toggle-button[aria-pressed=true]:enabled:hover:before{background-color:var(--toggle-dot-background-color-on-pressed)}[dir=rtl] .toggle-button[aria-pressed=true]:before{translate:calc(var(--toggle-dot-transform-x)*-1)}@media (prefers-reduced-motion:no-preference){.toggle-button:before{transition:translate .1s}}@media (prefers-contrast){.toggle-button:enabled:hover{border-color:var(--toggle-border-color-hover)}.toggle-button:enabled:active{border-color:var(--toggle-border-color-active)}.toggle-button[aria-pressed=true]:enabled{border-color:var(--toggle-border-color);position:relative}.toggle-button[aria-pressed=true]:enabled:hover,.toggle-button[aria-pressed=true]:enabled:hover:active{border-color:var(--toggle-border-color-hover)}.toggle-button[aria-pressed=true]:enabled:active{background-color:var(--toggle-dot-background-color-active);border-color:var(--toggle-dot-background-color-hover)}.toggle-button:active:before,.toggle-button:hover:before{background-color:var(--toggle-dot-background-color-hover)}}@media (forced-colors){.toggle-button{--toggle-dot-background-color:var(--color-accent-primary);--toggle-dot-background-color-hover:var(--color-accent-primary-hover);--toggle-dot-background-color-active:var(--color-accent-primary-active);--toggle-dot-background-color-on-pressed:var(--button-background-color);--toggle-background-color-disabled:var(--button-background-color-disabled);--toggle-border-color-hover:var(--border-interactive-color-hover);--toggle-border-color-active:var(--border-interactive-color-active);--toggle-border-color-disabled:var(--border-interactive-color-disabled)}.toggle-button[aria-pressed=true]:enabled:after{border:1px solid var(--button-background-color);border-radius:var(--toggle-border-radius);content:"";display:block;height:var(--toggle-height);inset:-2px;position:absolute;width:var(--toggle-width)}.toggle-button[aria-pressed=true]:enabled:active:after{border-color:var(--toggle-border-color-active)}}:root{--outline-width:2px;--outline-color:#0060df;--outline-around-width:1px;--outline-around-color:#f0f0f4;--hover-outline-around-color:var(--outline-around-color);--focus-outline:solid var(--outline-width) var(--outline-color);--unfocus-outline:solid var(--outline-width) #0000;--focus-outline-around:solid var(--outline-around-width) var(--outline-around-color);--hover-outline-color:#8f8f9d;--hover-outline:solid var(--outline-width) var(--hover-outline-color);--hover-outline-around:solid var(--outline-around-width) var(--hover-outline-around-color);--freetext-line-height:1.35;--freetext-padding:2px;--resizer-bg-color:var(--outline-color);--resizer-size:6px;--resizer-shift:calc(0px - (var(--outline-width) + var(--resizer-size))/2 - var(--outline-around-width));--editorFreeText-editing-cursor:text;--editorInk-editing-cursor:url(images/cursor-editorInk.svg) 0 16,pointer;--editorHighlight-editing-cursor:url(images/cursor-editorTextHighlight.svg) 24 24,text;--editorFreeHighlight-editing-cursor:url(images/cursor-editorFreeHighlight.svg) 1 18,pointer;--new-alt-text-warning-image:url(images/altText_warning.svg)}.visuallyHidden{border:0;font-size:0;height:0;left:0;margin:0;overflow:hidden;padding:0;position:absolute;top:0;white-space:nowrap;width:0}.textLayer.highlighting{cursor:var(--editorFreeHighlight-editing-cursor)}.textLayer.highlighting:not(.free) span{cursor:var(--editorHighlight-editing-cursor)}.textLayer.highlighting.free span,[role=img]:is(.textLayer.highlighting:not(.free) span){cursor:var(--editorFreeHighlight-editing-cursor)}:is(#viewerContainer.pdfPresentationMode:fullscreen,.annotationEditorLayer.disabled) .noAltTextBadge{display:none!important}@media (min-resolution:1.1dppx){:root{--editorFreeText-editing-cursor:url(images/cursor-editorFreeText.svg) 0 16,text}}@media screen and (forced-colors:active){:root{--outline-color:CanvasText;--outline-around-color:ButtonFace;--resizer-bg-color:ButtonText;--hover-outline-color:Highlight;--hover-outline-around-color:SelectedItemText}}[data-editor-rotation="90"]{transform:rotate(90deg)}[data-editor-rotation="180"]{transform:rotate(180deg)}[data-editor-rotation="270"]{transform:rotate(270deg)}.annotationEditorLayer{background:#0000;cursor:auto;font-size:calc(100px*var(--scale-factor));inset:0;position:absolute;transform-origin:0 0}.annotationEditorLayer .selectedEditor{z-index:100000!important}.annotationEditorLayer.drawing *{pointer-events:none!important}.annotationEditorLayer.waiting{content:"";cursor:wait;height:100%;inset:0;position:absolute;width:100%}.annotationEditorLayer.disabled{pointer-events:none}.annotationEditorLayer.freetextEditing{cursor:var(--editorFreeText-editing-cursor)}.annotationEditorLayer.inkEditing{cursor:var(--editorInk-editing-cursor)}.annotationEditorLayer .draw{box-sizing:border-box}.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor){background:#0000;border:var(--unfocus-outline);cursor:auto;max-height:100%;max-width:100%;position:absolute;transform-origin:0 0;z-index:1}.draggable.selectedEditor:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor)){cursor:move}.selectedEditor:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor)){border:var(--focus-outline);outline:var(--focus-outline-around)}.selectedEditor:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor)):before{border:var(--focus-outline-around);content:"";inset:0;pointer-events:none;position:absolute}:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor)):hover:not(.selectedEditor){border:var(--hover-outline);outline:var(--hover-outline-around)}:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor)):hover:not(.selectedEditor):before{border:var(--focus-outline-around);content:"";inset:0;position:absolute}:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar{--editor-toolbar-delete-image:url(images/editor-toolbar-delete.svg);--editor-toolbar-bg-color:#f0f0f4;--editor-toolbar-highlight-image:url(images/toolbarButton-editorHighlight.svg);--editor-toolbar-fg-color:#2e2e56;--editor-toolbar-border-color:#8f8f9d;--editor-toolbar-hover-border-color:var(--editor-toolbar-border-color);--editor-toolbar-hover-bg-color:#e0e0e6;--editor-toolbar-hover-fg-color:var(--editor-toolbar-fg-color);--editor-toolbar-hover-outline:none;--editor-toolbar-focus-outline-color:#0060df;--editor-toolbar-shadow:0 2px 6px 0 #3a394433;--editor-toolbar-vert-offset:6px;--editor-toolbar-height:28px;--editor-toolbar-padding:2px;--alt-text-done-color:#2ac3a2;--alt-text-warning-color:#0090ed;--alt-text-hover-done-color:var(--alt-text-done-color);--alt-text-hover-warning-color:var(--alt-text-warning-color)}@media (prefers-color-scheme:dark){:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar{--editor-toolbar-bg-color:#2b2a33;--editor-toolbar-fg-color:#fbfbfe;--editor-toolbar-hover-bg-color:#52525e;--editor-toolbar-focus-outline-color:#0df;--alt-text-done-color:#54ffbd;--alt-text-warning-color:#80ebff}}@media screen and (forced-colors:active){:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar{--editor-toolbar-bg-color:ButtonFace;--editor-toolbar-fg-color:ButtonText;--editor-toolbar-border-color:ButtonText;--editor-toolbar-hover-border-color:AccentColor;--editor-toolbar-hover-bg-color:ButtonFace;--editor-toolbar-hover-fg-color:AccentColor;--editor-toolbar-hover-outline:2px solid var(--editor-toolbar-hover-border-color);--editor-toolbar-focus-outline-color:ButtonBorder;--editor-toolbar-shadow:none;--alt-text-done-color:var(--editor-toolbar-fg-color);--alt-text-warning-color:var(--editor-toolbar-fg-color);--alt-text-hover-done-color:var(--editor-toolbar-hover-fg-color);--alt-text-hover-warning-color:var(--editor-toolbar-hover-fg-color)}}:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar{align-items:center;background-color:var(--editor-toolbar-bg-color);border:1px solid var(--editor-toolbar-border-color);border-radius:6px;box-shadow:var(--editor-toolbar-shadow);box-sizing:initial;cursor:default;display:flex;flex-direction:column;height:var(--editor-toolbar-height);inset-block-start:calc(100% + var(--editor-toolbar-vert-offset));inset-inline-end:0;justify-content:center;padding:var(--editor-toolbar-padding);pointer-events:auto;position:absolute;width:-moz-fit-content;width:fit-content}.hidden:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar){display:none}:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar):has(:focus-visible){border-color:#0000}[dir=ltr] :is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar){transform-origin:100% 0}[dir=rtl] :is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar){transform-origin:0 0}:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons{align-items:center;display:flex;gap:0;height:100%;justify-content:center}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) button{padding:0}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .divider{border-left:1px solid var(--editor-toolbar-border-color);border-right:none;display:inline-block;height:calc(var(--editor-toolbar-padding)*2 + var(--editor-toolbar-height));margin-inline:2px;width:0}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .highlightButton{width:var(--editor-toolbar-height)}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .highlightButton):before{background-color:var(--editor-toolbar-fg-color);content:"";display:inline-block;height:100%;-webkit-mask-image:var(--editor-toolbar-highlight-image);mask-image:var(--editor-toolbar-highlight-image);-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;width:100%}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .highlightButton):hover:before{background-color:var(--editor-toolbar-hover-fg-color)}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .delete{width:var(--editor-toolbar-height)}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .delete):before{background-color:var(--editor-toolbar-fg-color);content:"";display:inline-block;height:100%;-webkit-mask-image:var(--editor-toolbar-delete-image);mask-image:var(--editor-toolbar-delete-image);-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;width:100%}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .delete):hover:before{background-color:var(--editor-toolbar-hover-fg-color)}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons)>*{height:var(--editor-toolbar-height)}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons)>:not(.divider){background-color:initial;border:none;cursor:pointer}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons)>:not(.divider)):hover{background-color:var(--editor-toolbar-hover-bg-color);border-radius:2px;color:var(--editor-toolbar-hover-fg-color);outline:var(--editor-toolbar-hover-outline);outline-offset:1px}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons)>:not(.divider)):hover:active{outline:none}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons)>:not(.divider)):focus-visible{border-radius:2px;outline:2px solid var(--editor-toolbar-focus-outline-color)}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText{--alt-text-add-image:url(images/altText_add.svg);--alt-text-done-image:url(images/altText_done.svg);align-items:center;color:var(--editor-toolbar-fg-color);display:flex;font:menu;font-size:12px;font-weight:590;justify-content:center;padding-inline:8px;pointer-events:all;width:-moz-max-content;width:max-content}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):disabled{pointer-events:none}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):before{background-color:var(--editor-toolbar-fg-color);content:"";display:inline-block;height:13px;margin-inline-end:4px;-webkit-mask-image:var(--alt-text-add-image);mask-image:var(--alt-text-add-image);-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;width:12px}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):hover:before{background-color:var(--editor-toolbar-hover-fg-color)}.done:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):before{-webkit-mask-image:var(--alt-text-done-image);mask-image:var(--alt-text-done-image)}.new:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):before{background-color:var(--alt-text-warning-color);height:16px;-webkit-mask-image:var(--new-alt-text-warning-image);mask-image:var(--new-alt-text-warning-image);-webkit-mask-size:cover;mask-size:cover;width:16px}.new:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):hover:before{background-color:var(--alt-text-hover-warning-color)}.new.done:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):before{background-color:var(--alt-text-done-color);-webkit-mask-image:var(--alt-text-done-image);mask-image:var(--alt-text-done-image)}.new.done:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):hover:before{background-color:var(--alt-text-hover-done-color)}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText) .tooltip{word-wrap:anywhere;display:none}.show:is(:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText) .tooltip){--alt-text-tooltip-bg:#f0f0f4;--alt-text-tooltip-fg:#15141a;--alt-text-tooltip-border:#8f8f9d;--alt-text-tooltip-shadow:0px 2px 6px 0px #3a394433}@media (prefers-color-scheme:dark){.show:is(:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText) .tooltip){--alt-text-tooltip-bg:#1c1b22;--alt-text-tooltip-fg:#fbfbfe;--alt-text-tooltip-shadow:0px 2px 6px 0px #15141a}}@media screen and (forced-colors:active){.show:is(:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText) .tooltip){--alt-text-tooltip-bg:Canvas;--alt-text-tooltip-fg:CanvasText;--alt-text-tooltip-border:CanvasText;--alt-text-tooltip-shadow:none}}.show:is(:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText) .tooltip){align-items:center;background:var(--alt-text-tooltip-bg);border:.5px solid var(--alt-text-tooltip-border);box-shadow:var(--alt-text-tooltip-shadow);color:var(--alt-text-tooltip-fg);display:inline-flex;flex-direction:column;font-size:12px;height:auto;inset-inline-start:0;justify-content:center;max-width:300px;padding-block:2px 3px;padding-inline:3px;pointer-events:none;position:absolute;top:calc(100% + 2px);width:-moz-max-content;width:max-content}.annotationEditorLayer .freeTextEditor{height:auto;padding:calc(var(--freetext-padding)*var(--scale-factor));touch-action:none;width:auto}.annotationEditorLayer .freeTextEditor .internal{background:#0000;border:none;font:10px sans-serif;inset:0;line-height:var(--freetext-line-height);overflow:visible;-webkit-user-select:none;-moz-user-select:none;user-select:none;white-space:nowrap}.annotationEditorLayer .freeTextEditor .overlay{background:#0000;display:none;height:100%;inset:0;position:absolute;width:100%}.annotationEditorLayer freeTextEditor .overlay.enabled{display:block}.annotationEditorLayer .freeTextEditor .internal:empty:before{color:gray;content:attr(default-content)}.annotationEditorLayer .freeTextEditor .internal:focus{outline:none;-webkit-user-select:auto;-moz-user-select:auto;user-select:auto}.annotationEditorLayer .inkEditor{height:100%;width:100%}.annotationEditorLayer .inkEditor.editing{cursor:inherit}.annotationEditorLayer .inkEditor .inkEditorCanvas{height:100%;inset:0;position:absolute;touch-action:none;width:100%}.annotationEditorLayer .stampEditor{height:auto;width:auto}:is(.annotationEditorLayer .stampEditor) canvas{height:100%;left:0;margin:0;position:absolute;top:0;width:100%}:is(.annotationEditorLayer .stampEditor) .noAltTextBadge{--no-alt-text-badge-border-color:#f0f0f4;--no-alt-text-badge-bg-color:#cfcfd8;--no-alt-text-badge-fg-color:#5b5b66}@media (prefers-color-scheme:dark){:is(.annotationEditorLayer .stampEditor) .noAltTextBadge{--no-alt-text-badge-border-color:#52525e;--no-alt-text-badge-bg-color:#fbfbfe;--no-alt-text-badge-fg-color:#15141a}}@media screen and (forced-colors:active){:is(.annotationEditorLayer .stampEditor) .noAltTextBadge{--no-alt-text-badge-border-color:ButtonText;--no-alt-text-badge-bg-color:ButtonFace;--no-alt-text-badge-fg-color:ButtonText}}:is(.annotationEditorLayer .stampEditor) .noAltTextBadge{align-items:center;background:var(--no-alt-text-badge-bg-color);border:1px solid var(--no-alt-text-badge-border-color);border-radius:2px;display:inline-flex;height:32px;inset-block-end:5px;inset-inline-end:5px;justify-content:center;padding:3px;pointer-events:none;position:absolute;width:32px;z-index:1}:is(:is(.annotationEditorLayer .stampEditor) .noAltTextBadge):before{background-color:var(--no-alt-text-badge-fg-color);content:"";display:inline-block;height:16px;-webkit-mask-image:var(--new-alt-text-warning-image);mask-image:var(--new-alt-text-warning-image);-webkit-mask-size:cover;mask-size:cover;width:16px}:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers{inset:0;position:absolute}.hidden:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers){display:none}:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer{background:content-box var(--resizer-bg-color);border:var(--focus-outline-around);border-radius:2px;height:var(--resizer-size);position:absolute;width:var(--resizer-size)}.topLeft:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){left:var(--resizer-shift);top:var(--resizer-shift)}.topMiddle:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){left:calc(50% + var(--resizer-shift));top:var(--resizer-shift)}.topRight:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){right:var(--resizer-shift);top:var(--resizer-shift)}.middleRight:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){right:var(--resizer-shift);top:calc(50% + var(--resizer-shift))}.bottomRight:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){bottom:var(--resizer-shift);right:var(--resizer-shift)}.bottomMiddle:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){bottom:var(--resizer-shift);left:calc(50% + var(--resizer-shift))}.bottomLeft:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){bottom:var(--resizer-shift);left:var(--resizer-shift)}.middleLeft:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){left:var(--resizer-shift);top:calc(50% + var(--resizer-shift))}.bottomRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer),.topLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer){cursor:nwse-resize}.bottomMiddle:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer),.topMiddle:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer){cursor:ns-resize}.bottomLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer),.topRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer){cursor:nesw-resize}.middleLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer),.middleRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer){cursor:ew-resize}.bottomRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer),.topLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer){cursor:nesw-resize}.bottomMiddle:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer),.topMiddle:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer){cursor:ew-resize}.bottomLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer),.topRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer){cursor:nwse-resize}.middleLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer),.middleRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer){cursor:ns-resize}:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="90"],[data-main-rotation="90"] [data-editor-rotation="0"],[data-main-rotation="180"] [data-editor-rotation="270"],[data-main-rotation="270"] [data-editor-rotation="180"])) .editToolbar{rotate:270deg}[dir=ltr] :is(:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="90"],[data-main-rotation="90"] [data-editor-rotation="0"],[data-main-rotation="180"] [data-editor-rotation="270"],[data-main-rotation="270"] [data-editor-rotation="180"])) .editToolbar){inset-block-start:0;inset-inline-end:calc(0px - var(--editor-toolbar-vert-offset))}[dir=rtl] :is(:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="90"],[data-main-rotation="90"] [data-editor-rotation="0"],[data-main-rotation="180"] [data-editor-rotation="270"],[data-main-rotation="270"] [data-editor-rotation="180"])) .editToolbar){inset-block-start:0;inset-inline-end:calc(100% + var(--editor-toolbar-vert-offset))}:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="180"],[data-main-rotation="90"] [data-editor-rotation="90"],[data-main-rotation="180"] [data-editor-rotation="0"],[data-main-rotation="270"] [data-editor-rotation="270"])) .editToolbar{inset-block-start:calc(0pc - var(--editor-toolbar-vert-offset));inset-inline-end:100%;rotate:180deg}:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="270"],[data-main-rotation="90"] [data-editor-rotation="180"],[data-main-rotation="180"] [data-editor-rotation="90"],[data-main-rotation="270"] [data-editor-rotation="0"])) .editToolbar{rotate:90deg}[dir=ltr] :is(:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="270"],[data-main-rotation="90"] [data-editor-rotation="180"],[data-main-rotation="180"] [data-editor-rotation="90"],[data-main-rotation="270"] [data-editor-rotation="0"])) .editToolbar){inset-block-start:100%;inset-inline-end:calc(100% + var(--editor-toolbar-vert-offset))}[dir=rtl] :is(:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="270"],[data-main-rotation="90"] [data-editor-rotation="180"],[data-main-rotation="180"] [data-editor-rotation="90"],[data-main-rotation="270"] [data-editor-rotation="0"])) .editToolbar){inset-block-start:0;inset-inline-start:calc(0px - var(--editor-toolbar-vert-offset))}.dialog.altText::backdrop{-webkit-mask:url(#alttext-manager-mask);mask:url(#alttext-manager-mask)}.dialog.altText.positioned{margin:0}.dialog.altText #altTextContainer{align-items:flex-start;display:inline-flex;flex-direction:column;gap:16px;height:-moz-fit-content;height:fit-content;width:300px}:is(.dialog.altText #altTextContainer) #overallDescription{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:4px}:is(:is(.dialog.altText #altTextContainer) #overallDescription) span{align-self:stretch}:is(:is(.dialog.altText #altTextContainer) #overallDescription) .title{font-size:13px;font-style:normal;font-weight:590}:is(.dialog.altText #altTextContainer) #addDescription{align-items:stretch;display:flex;flex-direction:column;gap:8px}:is(:is(.dialog.altText #altTextContainer) #addDescription) .descriptionArea{flex:1;padding-inline:24px 10px}:is(:is(:is(.dialog.altText #altTextContainer) #addDescription) .descriptionArea) textarea{min-height:75px;width:100%}:is(.dialog.altText #altTextContainer) #buttons{align-items:flex-start;align-self:stretch;display:flex;gap:8px;justify-content:flex-end}.dialog.newAltText{--new-alt-text-ai-disclaimer-icon:url(images/altText_disclaimer.svg);--new-alt-text-spinner-icon:url(images/altText_spinner.svg);--preview-image-bg-color:#f0f0f4;--preview-image-border:none}@media (prefers-color-scheme:dark){.dialog.newAltText{--preview-image-bg-color:#2b2a33}}@media screen and (forced-colors:active){.dialog.newAltText{--preview-image-bg-color:ButtonFace;--preview-image-border:1px solid ButtonText}}.dialog.newAltText{max-width:570px;min-width:300px;padding:0;width:80%}.dialog.newAltText.aiInstalling #newAltTextCreateAutomatically,.dialog.newAltText.noAi #newAltTextCreateAutomatically,.dialog.newAltText.noAi #newAltTextDisclaimer{display:none!important}.dialog.newAltText.aiInstalling #newAltTextDownloadModel{display:flex!important}.dialog.newAltText.error #newAltTextNotNow{display:none!important}.dialog.newAltText.error #newAltTextCancel{display:inline-block!important}.dialog.newAltText:not(.error) #newAltTextError{display:none!important}.dialog.newAltText #newAltTextContainer{align-items:flex-start;display:flex;flex:0 1 auto;flex-direction:column;gap:12px;justify-content:flex-end;line-height:normal;padding:16px;width:auto}:is(.dialog.newAltText #newAltTextContainer) #mainContent{align-items:flex-start;align-self:stretch;display:flex;flex:1 1 auto;gap:12px;justify-content:flex-end}:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionAndSettings{align-items:flex-start;align-self:stretch;display:flex;flex:1 0 0;flex-direction:column;gap:16px}:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction{align-items:flex-start;align-self:stretch;display:flex;flex:1 1 auto;flex-direction:column;gap:8px}:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer{height:70px;position:relative;width:100%}:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) textarea{height:100%;padding:8px;width:100%}:is(:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) textarea)::-moz-placeholder{color:var(--text-secondary-color)}:is(:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) textarea)::placeholder{color:var(--text-secondary-color)}:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) .altTextSpinner{background-color:var(--text-secondary-color);display:none;height:16px;inset-block-start:8px;inset-inline-start:8px;-webkit-mask-size:cover;mask-size:cover;pointer-events:none;position:absolute;width:16px}.loading:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) textarea::-moz-placeholder{color:#0000}.loading:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) textarea::placeholder{color:#0000}.loading:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) .altTextSpinner{display:inline-block;-webkit-mask-image:var(--new-alt-text-spinner-icon);mask-image:var(--new-alt-text-spinner-icon)}:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescription{font-size:11px}:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDisclaimer{align-items:flex-start;display:flex;flex-direction:row;font-size:11px;gap:4px}:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDisclaimer):before{background-color:var(--text-secondary-color);content:"";display:inline-block;flex:1 0 auto;height:16px;-webkit-mask-image:var(--new-alt-text-ai-disclaimer-icon);mask-image:var(--new-alt-text-ai-disclaimer-icon);-webkit-mask-size:cover;mask-size:cover;width:17px}:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #newAltTextDownloadModel{align-items:center;align-self:stretch;display:flex;gap:4px}:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #newAltTextDownloadModel):before{background-color:var(--text-secondary-color);content:"";display:inline-block;height:16px;-webkit-mask-image:var(--new-alt-text-spinner-icon);mask-image:var(--new-alt-text-spinner-icon);-webkit-mask-size:cover;mask-size:cover;width:16px}:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #newAltTextImagePreview{align-items:center;aspect-ratio:1;background-color:var(--preview-image-bg-color);border:var(--preview-image-border);display:flex;flex:0 0 auto;justify-content:center;width:180px}:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #newAltTextImagePreview)>canvas{max-height:100%;max-width:100%}.colorPicker{--hover-outline-color:#0250bb;--selected-outline-color:#0060df;--swatch-border-color:#cfcfd8}@media (prefers-color-scheme:dark){.colorPicker{--hover-outline-color:#80ebff;--selected-outline-color:#aaf2ff;--swatch-border-color:#52525e}}@media screen and (forced-colors:active){.colorPicker{--hover-outline-color:Highlight;--selected-outline-color:var(--hover-outline-color);--swatch-border-color:ButtonText}}.colorPicker .swatch{border:1px solid var(--swatch-border-color);border-radius:100%;box-sizing:border-box;forced-color-adjust:none;height:16px;outline-offset:2px;width:16px}.colorPicker button:is(:hover,.selected)>.swatch{border:none}.annotationEditorLayer[data-main-rotation="0"] .highlightEditor:not(.free)>.editToolbar{rotate:0deg}.annotationEditorLayer[data-main-rotation="90"] .highlightEditor:not(.free)>.editToolbar{rotate:270deg}.annotationEditorLayer[data-main-rotation="180"] .highlightEditor:not(.free)>.editToolbar{rotate:180deg}.annotationEditorLayer[data-main-rotation="270"] .highlightEditor:not(.free)>.editToolbar{rotate:90deg}.annotationEditorLayer .highlightEditor{background:#0000;border:none;cursor:auto;max-height:100%;max-width:100%;outline:none;pointer-events:none;position:absolute;transform-origin:0 0;z-index:1}:is(.annotationEditorLayer .highlightEditor):not(.free){transform:none}:is(.annotationEditorLayer .highlightEditor) .internal{height:100%;left:0;pointer-events:auto;position:absolute;top:0;width:100%}.disabled:is(.annotationEditorLayer .highlightEditor) .internal{pointer-events:none}.selectedEditor:is(.annotationEditorLayer .highlightEditor) .internal{cursor:pointer}:is(.annotationEditorLayer .highlightEditor) .editToolbar{--editor-toolbar-colorpicker-arrow-image:url(images/toolbarButton-menuArrow.svg);transform-origin:center!important}:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker{align-items:center;display:flex;gap:4px;justify-content:center;padding:4px;position:relative;width:auto}:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker):after{background-color:var(--editor-toolbar-fg-color);content:"";display:inline-block;height:12px;-webkit-mask-image:var(--editor-toolbar-colorpicker-arrow-image);mask-image:var(--editor-toolbar-colorpicker-arrow-image);-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;width:12px}:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker):hover:after{background-color:var(--editor-toolbar-hover-fg-color)}:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker):has(.dropdown:not(.hidden)){background-color:var(--editor-toolbar-hover-bg-color)}:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker):has(.dropdown:not(.hidden)):after{scale:-1}:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown{align-items:center;background-color:var(--editor-toolbar-bg-color);border:1px solid var(--editor-toolbar-border-color);border-radius:6px;box-shadow:var(--editor-toolbar-shadow);display:flex;flex-direction:column;gap:11px;inset-block-start:calc(100% + 4px);justify-content:center;padding-block:8px;position:absolute;width:calc(100% + var(--editor-toolbar-padding)*2)}:is(:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown) button{align-items:center;background:none;border:none;cursor:pointer;display:flex;height:auto;justify-content:center;width:100%}:is(:is(:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown) button):is(:active,:focus-visible){outline:none}:is(:is(:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown) button)>.swatch{outline-offset:2px}[aria-selected=true]:is(:is(:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown) button)>.swatch{outline:2px solid var(--selected-outline-color)}:is(:is(:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown) button):is(:hover,:active,:focus-visible)>.swatch{outline:2px solid var(--hover-outline-color)}.editorParamsToolbar:has(#highlightParamsToolbarContainer){padding:unset}#highlightParamsToolbarContainer{gap:16px;padding-block-end:12px;padding-inline:10px}#highlightParamsToolbarContainer .colorPicker{display:flex;flex-direction:column;gap:8px}:is(#highlightParamsToolbarContainer .colorPicker) .dropdown{align-items:center;display:flex;flex-direction:row;height:auto;justify-content:space-between}:is(:is(#highlightParamsToolbarContainer .colorPicker) .dropdown) button{align-items:center;background:none;border:none;cursor:pointer;display:flex;flex:0 0 auto;height:auto;justify-content:center;padding:0;width:auto}:is(:is(:is(#highlightParamsToolbarContainer .colorPicker) .dropdown) button) .swatch{height:24px;width:24px}:is(:is(:is(#highlightParamsToolbarContainer .colorPicker) .dropdown) button):is(:active,:focus-visible){outline:none}[aria-selected=true]:is(:is(:is(#highlightParamsToolbarContainer .colorPicker) .dropdown) button)>.swatch{outline:2px solid var(--selected-outline-color)}:is(:is(:is(#highlightParamsToolbarContainer .colorPicker) .dropdown) button):is(:hover,:active,:focus-visible)>.swatch{outline:2px solid var(--hover-outline-color)}#highlightParamsToolbarContainer #editorHighlightThickness{align-items:center;align-self:stretch;display:flex;flex-direction:column;gap:4px}:is(#highlightParamsToolbarContainer #editorHighlightThickness) .editorParamsLabel{align-self:stretch;height:auto}:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker{--example-color:#bfbfc9;align-items:center;align-self:stretch;display:flex;justify-content:space-between}@media (prefers-color-scheme:dark){:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker{--example-color:#80808e}}@media screen and (forced-colors:active){:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker{--example-color:CanvasText}}:is(:is(:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker)>.editorParamsSlider[disabled]){opacity:.4}:is(:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker):after,:is(:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker):before{aspect-ratio:1;background-color:var(--example-color);border-radius:100%;content:"";display:block;width:8px}:is(:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker):after{width:24px}:is(:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker) .editorParamsSlider{height:14px;width:unset}#highlightParamsToolbarContainer #editorHighlightVisibility{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:8px}:is(#highlightParamsToolbarContainer #editorHighlightVisibility) .divider{--divider-color:#d7d7db}@media (prefers-color-scheme:dark){:is(#highlightParamsToolbarContainer #editorHighlightVisibility) .divider{--divider-color:#8f8f9d}}@media screen and (forced-colors:active){:is(#highlightParamsToolbarContainer #editorHighlightVisibility) .divider{--divider-color:CanvasText}}:is(#highlightParamsToolbarContainer #editorHighlightVisibility) .divider{background-color:var(--divider-color);height:1px;margin-block:4px;width:100%}:is(#highlightParamsToolbarContainer #editorHighlightVisibility) .toggler{align-items:center;align-self:stretch;display:flex;justify-content:space-between}#altTextSettingsDialog{padding:16px}#altTextSettingsDialog #altTextSettingsContainer{display:flex;flex-direction:column;gap:16px;width:573px}:is(#altTextSettingsDialog #altTextSettingsContainer) .mainContainer{gap:16px}:is(#altTextSettingsDialog #altTextSettingsContainer) .description{color:var(--text-secondary-color)}:is(#altTextSettingsDialog #altTextSettingsContainer) #aiModelSettings{display:flex;flex-direction:column;gap:12px}:is(:is(#altTextSettingsDialog #altTextSettingsContainer) #aiModelSettings) button{width:-moz-fit-content;width:fit-content}.download:is(:is(#altTextSettingsDialog #altTextSettingsContainer) #aiModelSettings) #deleteModelButton,:is(:is(#altTextSettingsDialog #altTextSettingsContainer) #aiModelSettings):not(.download) #downloadModelButton{display:none}:is(#altTextSettingsDialog #altTextSettingsContainer) #altTextEditor,:is(#altTextSettingsDialog #altTextSettingsContainer) #automaticAltText{display:flex;flex-direction:column;gap:8px}:is(#altTextSettingsDialog #altTextSettingsContainer) #aiModelSettings,:is(#altTextSettingsDialog #altTextSettingsContainer) #createModelDescription,:is(#altTextSettingsDialog #altTextSettingsContainer) #showAltTextDialogDescription{padding-inline-start:40px}:is(#altTextSettingsDialog #altTextSettingsContainer) #automaticSettings{display:flex;flex-direction:column;gap:16px}:root{--viewer-container-height:0;--pdfViewer-padding-bottom:0;--page-margin:1px auto -8px;--page-border:9px solid #0000;--spreadHorizontalWrapped-margin-LR:-3.5px;--loading-icon-delay:400ms}@media screen and (forced-colors:active){:root{--pdfViewer-padding-bottom:9px;--page-margin:8px auto -1px;--page-border:1px solid CanvasText;--spreadHorizontalWrapped-margin-LR:3.5px}}[data-main-rotation="90"]{transform:rotate(90deg) translateY(-100%)}[data-main-rotation="180"]{transform:rotate(180deg) translate(-100%,-100%)}[data-main-rotation="270"]{transform:rotate(270deg) translateX(-100%)}#hiddenCopyElement,.hiddenCanvasElement{display:none;height:0;left:0;position:absolute;top:0;width:0}.pdfViewer{--scale-factor:1;--page-bg-color:unset;--hcm-highlight-filter:none;--hcm-highlight-selected-filter:none;padding-bottom:var(--pdfViewer-padding-bottom)}@media screen and (forced-colors:active){.pdfViewer{--hcm-highlight-filter:invert(100%)}}.pdfViewer.copyAll{cursor:wait}.pdfViewer .canvasWrapper{height:100%;overflow:hidden;width:100%}:is(.pdfViewer .canvasWrapper) canvas{contain:content;display:block;height:100%;left:0;margin:0;position:absolute;top:0;width:100%}:is(:is(.pdfViewer .canvasWrapper) canvas) .structTree{contain:strict}.pdfViewer .page{--scale-round-x:1px;--scale-round-y:1px;background-clip:content-box;background-color:var(--page-bg-color,#fff);border:var(--page-border);direction:ltr;height:1056px;margin:var(--page-margin);overflow:visible;position:relative;width:816px}.pdfViewer .dummyPage{height:var(--viewer-container-height);position:relative;width:0}.pdfViewer.noUserSelect{-webkit-user-select:none;-moz-user-select:none;user-select:none}.pdfViewer.removePageBorders .page{border:none;margin:0 auto 10px}.pdfViewer.singlePageView{display:inline-block}.pdfViewer.singlePageView .page{border:none;margin:0}.pdfViewer:is(.scrollHorizontal,.scrollWrapped),.spread{margin-inline:3.5px;text-align:center}.pdfViewer.scrollHorizontal,.spread{white-space:nowrap}.pdfViewer.removePageBorders,.pdfViewer:is(.scrollHorizontal,.scrollWrapped) .spread{margin-inline:0}.pdfViewer:is(.scrollHorizontal,.scrollWrapped) :is(.page,.spread),.spread :is(.page,.dummyPage){display:inline-block;vertical-align:middle}.pdfViewer:is(.scrollHorizontal,.scrollWrapped) .page,.spread .page{margin-inline:var(--spreadHorizontalWrapped-margin-LR)}.pdfViewer.removePageBorders .spread .page,.pdfViewer.removePageBorders:is(.scrollHorizontal,.scrollWrapped) .page{margin-inline:5px}.pdfViewer .page.loadingIcon:after{background:url(images/loading-icon.gif) 50% no-repeat;contain:strict;content:"";display:none;height:100%;left:0;position:absolute;top:0;transition-delay:var(--loading-icon-delay);transition-property:display;width:100%;z-index:5}.pdfViewer .page.loading:after{display:block}.pdfViewer .page:not(.loading):after{display:none;transition-property:none}.pdfPresentationMode .pdfViewer{padding-bottom:0}.pdfPresentationMode .spread{margin:0}.pdfPresentationMode .pdfViewer .page{border:2px solid #0000;margin:0 auto}');var qle=function(){function e(){}return e.generateUniqueId=function(){var e=Date.now().toString(36),t=Math.random().toString(36).substring(2,8);return"".concat(e,"-").concat(t)},e}(),Gle=Symbol.for("immer-nothing"),Yle=Symbol.for("immer-draftable"),Kle=Symbol.for("immer-state"),Xle="production"!==yt.env.NODE_ENV?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function Qle(e,...t){if("production"!==yt.env.NODE_ENV){const n=Xle[e],a="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${a}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Jle=Object.getPrototypeOf;function Zle(e){return!!e&&!!e[Kle]}function eie(e){return!!e&&(nie(e)||Array.isArray(e)||!!e[Yle]||!!e.constructor?.[Yle]||lie(e)||iie(e))}var tie=Object.prototype.constructor.toString();function nie(e){if(!e||"object"!=typeof e)return!1;const t=Jle(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===tie}function aie(e,t){0===rie(e)?Reflect.ownKeys(e).forEach((n=>{t(n,e[n],e)})):e.forEach(((n,a)=>t(a,n,e)))}function rie(e){const t=e[Kle];return t?t.type_:Array.isArray(e)?1:lie(e)?2:iie(e)?3:0}function oie(e,t){return 2===rie(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function cie(e,t,n){const a=rie(e);2===a?e.set(t,n):3===a?e.add(n):e[t]=n}function lie(e){return e instanceof Map}function iie(e){return e instanceof Set}function sie(e){return e.copy_||e.base_}function hie(e,t){if(lie(e))return new Map(e);if(iie(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=nie(e);if(!0===t||"class_only"===t&&!n){const t=Object.getOwnPropertyDescriptors(e);delete t[Kle];let n=Reflect.ownKeys(t);for(let a=0;a<n.length;a++){const r=n[a],o=t[r];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(t[r]={configurable:!0,writable:!0,enumerable:o.enumerable,value:e[r]})}return Object.create(Jle(e),t)}{const t=Jle(e);if(null!==t&&n)return{...e};const a=Object.create(t);return Object.assign(a,e)}}function die(e,t=!1){return mie(e)||Zle(e)||!eie(e)||(rie(e)>1&&(e.set=e.add=e.clear=e.delete=uie),Object.freeze(e),t&&Object.entries(e).forEach((([e,t])=>die(t,!0)))),e}function uie(){Qle(2)}function mie(e){return Object.isFrozen(e)}var pie,vie={};function fie(e){const t=vie[e];return t||Qle(0,e),t}function zie(){return pie}function gie(e,t){t&&(fie("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function yie(e){Mie(e),e.drafts_.forEach(bie),e.drafts_=null}function Mie(e){e===pie&&(pie=e.parent_)}function Eie(e){return pie={drafts_:[],parent_:pie,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function bie(e){const t=e[Kle];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Hie(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Kle].modified_&&(yie(t),Qle(4)),eie(e)&&(e=Vie(t,e),t.parent_||Lie(t,e)),t.patches_&&fie("Patches").generateReplacementPatches_(n[Kle].base_,e,t.patches_,t.inversePatches_)):e=Vie(t,n,[]),yie(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Gle?e:void 0}function Vie(e,t,n){if(mie(t))return t;const a=t[Kle];if(!a)return aie(t,((r,o)=>Cie(e,a,t,r,o,n))),t;if(a.scope_!==e)return t;if(!a.modified_)return Lie(e,a.base_,!0),a.base_;if(!a.finalized_){a.finalized_=!0,a.scope_.unfinalizedDrafts_--;const t=a.copy_;let r=t,o=!1;3===a.type_&&(r=new Set(t),t.clear(),o=!0),aie(r,((r,c)=>Cie(e,a,t,r,c,n,o))),Lie(e,t,!1),n&&e.patches_&&fie("Patches").generatePatches_(a,n,e.patches_,e.inversePatches_)}return a.copy_}function Cie(e,t,n,a,r,o,c){if("production"!==yt.env.NODE_ENV&&r===n&&Qle(5),Zle(r)){const c=Vie(e,r,o&&t&&3!==t.type_&&!oie(t.assigned_,a)?o.concat(a):void 0);if(cie(n,a,c),!Zle(c))return;e.canAutoFreeze_=!1}else c&&n.add(r);if(eie(r)&&!mie(r)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Vie(e,r),t&&t.scope_.parent_||"symbol"==typeof a||!Object.prototype.propertyIsEnumerable.call(n,a)||Lie(e,r)}}function Lie(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&die(t,n)}var xie={get(e,t){if(t===Kle)return e;const n=sie(e);if(!oie(n,t))return function(e,t,n){const a=wie(t,n);return a?"value"in a?a.value:a.get?.call(e.draft_):void 0}(e,n,t);const a=n[t];return e.finalized_||!eie(a)?a:a===kie(e.base_,t)?(Oie(e),e.copy_[t]=Aie(a,e)):a},has:(e,t)=>t in sie(e),ownKeys:e=>Reflect.ownKeys(sie(e)),set(e,t,n){const a=wie(sie(e),t);if(a?.set)return a.set.call(e.draft_,n),!0;if(!e.modified_){const a=kie(sie(e),t),c=a?.[Kle];if(c&&c.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(((r=n)===(o=a)?0!==r||1/r==1/o:r!=r&&o!=o)&&(void 0!==n||oie(e.base_,t)))return!0;Oie(e),Tie(e)}var r,o;return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==kie(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,Oie(e),Tie(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=sie(e),a=Reflect.getOwnPropertyDescriptor(n,t);return a?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:a.enumerable,value:n[t]}:a},defineProperty(){Qle(11)},getPrototypeOf:e=>Jle(e.base_),setPrototypeOf(){Qle(12)}},Sie={};function kie(e,t){const n=e[Kle];return(n?sie(n):e)[t]}function wie(e,t){if(!(t in e))return;let n=Jle(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Jle(n)}}function Tie(e){e.modified_||(e.modified_=!0,e.parent_&&Tie(e.parent_))}function Oie(e){e.copy_||(e.copy_=hie(e.base_,e.scope_.immer_.useStrictShallowCopy_))}function Aie(e,t){const n=lie(e)?fie("MapSet").proxyMap_(e,t):iie(e)?fie("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),a={type_:n?1:0,scope_:t?t.scope_:zie(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let r=a,o=xie;n&&(r=[a],o=Sie);const{revoke:c,proxy:l}=Proxy.revocable(r,o);return a.draft_=l,a.revoke_=c,l}(e,t);return(t?t.scope_:zie()).drafts_.push(n),n}function Rie(e){if(!eie(e)||mie(e))return e;const t=e[Kle];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=hie(e,t.scope_.immer_.useStrictShallowCopy_)}else n=hie(e,!0);return aie(n,((e,t)=>{cie(n,e,Rie(t))})),t&&(t.finalized_=!1),n}aie(xie,((e,t)=>{Sie[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),Sie.deleteProperty=function(e,t){return"production"!==yt.env.NODE_ENV&&isNaN(parseInt(t))&&Qle(13),Sie.set.call(this,e,t,void 0)},Sie.set=function(e,t,n){return"production"!==yt.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&Qle(14),xie.set.call(this,e[0],t,n,e[0])};var Nie=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const a=this;return function(e=n,...r){return a.produce(e,(e=>t.call(this,e,...r)))}}let a;if("function"!=typeof t&&Qle(6),void 0!==n&&"function"!=typeof n&&Qle(7),eie(e)){const r=Eie(this),o=Aie(e,void 0);let c=!0;try{a=t(o),c=!1}finally{c?yie(r):Mie(r)}return gie(r,n),Hie(a,r)}if(!e||"object"!=typeof e){if(a=t(e),void 0===a&&(a=e),a===Gle&&(a=void 0),this.autoFreeze_&&die(a,!0),n){const t=[],r=[];fie("Patches").generateReplacementPatches_(e,a,t,r),n(t,r)}return a}Qle(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,a;return[this.produce(e,t,((e,t)=>{n=e,a=t})),n,a]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){eie(e)||Qle(8),Zle(e)&&(e=function(e){return Zle(e)||Qle(10,e),Rie(e)}(e));const t=Eie(this),n=Aie(e,void 0);return n[Kle].isManual_=!0,Mie(t),n}finishDraft(e,t){const n=e&&e[Kle];n&&n.isManual_||Qle(9);const{scope_:a}=n;return gie(a,t),Hie(void 0,a)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const a=t[n];if(0===a.path.length&&"replace"===a.op){e=a.value;break}}n>-1&&(t=t.slice(n+1));const a=fie("Patches").applyPatches_;return Zle(e)?a(e,t):this.produce(e,(e=>a(e,t)))}},_ie=Nie.produce;Nie.produceWithPatches.bind(Nie);var Die=Nie.setAutoFreeze.bind(Nie);Nie.setUseStrictShallowCopy.bind(Nie),Nie.applyPatches.bind(Nie),Nie.createDraft.bind(Nie),Nie.finishDraft.bind(Nie);var Pie={isScaleSaveHappening:!1,isAddNewScaleFormPopupOpen:!1,scaleName:"",paperDimension:{unitOfMeasurement:"inch",scalarQuantity:1},displayDimension:{unitOfMeasurement:"inch",scalarQuantity:1},precision:.1,userCalibratingScaleOnPdfPageDetails:{isHappening:!1,coordinates:[]},isCalibrationScaleFormPopupOpen:!1,pdfPageId:""},Fie={scaleId:"",popup:{isOpen:!1},paperDimension:{unitOfMeasurement:"inch",scalarQuantity:0},displayDimension:{unitOfMeasurement:"inch",scalarQuantity:0},scaleName:"",precision:.1,isScaleSaveHappening:!1},Iie=function(){function e(){}return e.getEnvValue=function(e){var t,n=null===(t=null===window||void 0===window?void 0:window._env_)||void 0===t?void 0:t[e];return n&&"default"!==n?n:""},e}(),jie=function(){function e(){}return e.BACKEND_BASE_URL=Iie.getEnvValue("BACKEND_BASE_URL"),e.scalePrecisionOptions=[.1,.01,.001],e.annotationAvalaibleColors=[{color:"#E34234"},{color:"#FF8D02"},{color:"#FFCD44"},{color:"#5BC96D"},{color:"#26D2D2"},{color:"#587CE2"},{color:"#C544CE"},{color:"#7D2E25"},{color:"#A84F1C"},{color:"#E99E38"},{color:"#347842"},{color:"#167E7D"},{color:"#354A87"},{color:"#76287B"},{color:"#000"},{color:"#CDCDCD"},{color:"#9C9C9C"},{color:"#696969"},{color:"#272727"},{color:"#FFFFFF"}],e.pdfPagesElementId="pdf-pages-container",e}(),Bie={isOpen:!1,sections:{color:{collapsedStatus:"collapsed",currentlySelectedColor:jie.annotationAvalaibleColors[0].color},coordinates:{collapsedStatus:"collapsed",shouldHighlightFirstCoordinate:!1,shouldHighlightSecondCoordinate:!1,x1:0,x2:0,y1:0,y2:0}}};Ble.workerSrc="https://unpkg.com/pdfjs-dist@4.10.38/build/pdf.worker.min.mjs",Die(!1);var Uie={options:{showDividerBetweenToolSections:!0,alignmentOfFirstRowToolSections:"space-between"},sections:[[{name:"fullScreen"},{name:"zoomTool"}],[{name:"Annotation",children:[{name:"highlight"},{name:"callout"}]},{name:"Shapes",children:[{name:"rectangle"}]},{name:"Measure",children:[{name:"measureDistance"}]}],[{name:"toggleTextSelectionTool"},{name:"eyeTool"},{name:"comment"}]]};function Wie(e){var a=this,r=n.useState([]),o=r[0],c=r[1],l=n.useState(""),i=l[0],s=l[1],h=n.useState(""),d=h[0],u=h[1],m=n.useState({pdfEditorToolsToShow:e.toolsToShow||Uie,toolsRelatedData:{},measureToolRelatedData:{scaleIdSelected:"",addNewScaleDetails:Pie,editScaleDetails:Fie,distanceAnnotation:{configurationsDrawer:Bie,isFirstPointSelected:!1,isSecondPointSelected:!1}},textHighlightToolRelatedData:{isTextSelectionEnabled:!0,selectedTextToolBoxDetails:{pdfPageId:"",x:0,y:0}}}),p=m[0],v=m[1],f=n.useState(e.currentUserId),z=f[0],g=f[1],y=n.useState([]),M=y[0],E=y[1],b=n.useState([]),H=b[0],V=b[1],C=n.useState(!1),L=C[0],x=C[1],S=n.useState(0),k=S[0],w=S[1],T=n.useState(!1),O=T[0],A=T[1],R=n.useState(!1),N=R[0],_=R[1],D=n.useState(e.areAnnotationsVisibleByDefault),P=D[0],F=D[1],I=n.useState(""),j=I[0],B=I[1],U=n.useState(""),W=U[0],$=U[1],q=e.rectangleAnnotationToolOptions,G=e.backendBaseUrl,Y=e.rlefEventServiceBaseUrl,K=n.useRef(new Tae({backendBaseUrl:G})),X=n.useState(qle.generateUniqueId()),Q=X[0];X[1];var J=n.useState([]),Z=J[0],ee=J[1],te=n.useCallback((function(e){ee((function(t){return Z7(Z7([],t,!0),[e],!1)}))}),[ee]),ne=n.useCallback((function(e,t){return Q7(a,void 0,void 0,(function(){var n,a;return J7(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,3,4]),x(!0),[4,K.current.fetchUsersOfPdf({pdfId:t,userNameSearchKey:e,limit:10,offset:1})];case 1:return(n=r.sent())&&V(n),[3,4];case 2:return a=r.sent(),console.error("Error fetching suggested users: ",a),[3,4];case 3:return x(!1),[7];case 4:return[2]}}))}))}),[]),ae=n.useCallback((function(e){ee((function(t){return Z7([],t.filter((function(t){return t!==e})),!0)}))}),[ee]),re=n.useCallback((function(){return Q7(a,void 0,void 0,(function(){var t,n,a,r,c;return J7(this,(function(l){switch(l.label){case 0:if(!(t=(null===(c=o[0])||void 0===c?void 0:c._id)||""))return[2];l.label=1;case 1:return l.trys.push([1,5,,6]),_(!0),[4,K.current.fetchUsersOfPdf({pdfId:t})];case 2:return(n=l.sent())?-1!==n.findIndex((function(t){return t._id===e.currentUserId}))?[3,4]:[4,K.current.fetchUsersOfPdf({pdfId:t,userIds:[e.currentUserId]})]:[2];case 3:(a=l.sent())&&a.length>0&&n.push(a[0]),l.label=4;case 4:return E(n),[3,6];case 5:return r=l.sent(),console.error("Error fetching users: ",r),[3,6];case 6:return[2]}}))}))}),[o]);n.useEffect((function(){N||re()}),[re,N]);var oe=n.useState([]);oe[0];var ce=oe[1],le=n.useState({isEditingText:!1,annotationId:"",pdfId:"",pdfPageId:"",color:"",points:[],text:""}),ie=le[0],se=le[1],he=n.useCallback((function(e,t){return Q7(a,void 0,void 0,(function(){var n,a,r,o,l,i,s,h,d,u,m,f,z;return J7(this,(function(g){switch(g.label){case 0:return n=(t||{}).pdfSourceUrl,e&&te(e),a={},e&&(a.pdfId=e),n&&(a.pdfSourceUrl=n),r=K.current.fetchOnlyPdfData(X7(X7({},a),{getPdfDownloadUrl:"true"})),o={pdfs:[]},n?[4,r]:[3,6];case 1:return(o=g.sent()).pdfs.length>0?(e=o.pdfs[0]._id,[3,5]):[3,2];case 2:return ce((function(e){return Z7(Z7([],e,!0),[n],!1)})),[4,K.current.insertPdfAndItsPagesInDb({pdfSourceUrl:n,pdfFileName:"sourceUrl.pdf"})];case 3:return l=g.sent(),e=l._id,[4,K.current.fetchOnlyPdfData(X7(X7({},a),{getPdfDownloadUrl:"true"}))];case 4:o=g.sent(),ce((function(e){return Z7([],e.filter((function(e){return e!==n})),!0)})),g.label=5;case 5:return[3,8];case 6:return[4,r];case 7:o=g.sent(),g.label=8;case 8:return i=K.current.fetchOnlyPdfPagesData({pdfId:e,getPdfPageImageDownloadUrl:"true",pdfPageImageUploaded:"true"}),s=K.current.fetchPdfScales({pdfId:e}),[4,i];case 9:return h=g.sent(),[4,s];case 10:return d=g.sent(),!p.measureToolRelatedData.scaleIdSelected&&d.scales.length>0&&v(_ie((function(e){var t;e.measureToolRelatedData.scaleIdSelected=(null===(t=d.scales[0])||void 0===t?void 0:t._id)||""}))),(u=null===(z=null==o?void 0:o.pdfs[0])||void 0===z?void 0:z.pdfDownloadUrl)?[4,Wle(u).promise]:[3,12];case 11:return f=g.sent(),[3,13];case 12:f=null,g.label=13;case 13:return(m=f)&&c((function(t){var a,r,c=Z7([],t,!0),l=c.length>0?c.findIndex((function(t){return t._id===e})):-1,i=-1!==l,s={_id:null===(r=null===(a=null==o?void 0:o.pdfs)||void 0===a?void 0:a[0])||void 0===r?void 0:r._id,sourcePdfUrl:n||"",pdfPagesImageGenerationStatus:o.pdfs[0].pdfPagesImageGenerationStatus,pdfDownloadUrl:o.pdfs[0].pdfDownloadUrl,pdfDocument:m,pages:h.pages.map((function(e){return{_id:null==e?void 0:e._id,pdfId:e.pdfId,annotations:[],commentThreads:[],pageImageUrl:e.pageAsImageDetails.pageImageDownloadUrl||"",pageNumber:e.pageNumber,pdfPageWidthInPoints:e.pdfPageWidthInPoints,pdfPageHeightInPoints:e.pdfPageHeightInPoints,pageAsImageDetails:e.pageAsImageDetails}})),scales:d.scales.map((function(e){return X7({},e)}))};return i?c[l]=X7({},s):c.push(s),c})),ae(e),[2]}}))}))}),[te,K,ae,c]),de=n.useCallback((function(e){v((function(t){var n=X7({},t);return n.toolsRelatedData=X7(X7({},n.toolsRelatedData),{comment:X7(X7({},n.toolsRelatedData.comment),{selectedThreadId:e})}),n}))}),[v]),ue=p.measureToolRelatedData.addNewScaleDetails,me=p.measureToolRelatedData.editScaleDetails,pe=n.useCallback((function(){return Q7(a,void 0,void 0,(function(){return J7(this,(function(e){return v((function(e){var t,n;return X7(X7({},e),{measureToolRelatedData:X7(X7({},e.measureToolRelatedData),{addNewScaleDetails:X7(X7({},e.measureToolRelatedData.addNewScaleDetails),{isAddNewScaleFormPopupOpen:!0,pdfPageId:null===(n=null===(t=null==o?void 0:o[0])||void 0===t?void 0:t.pages[0])||void 0===n?void 0:n._id})})})})),[2]}))}))}),[o]),ve=n.useState([]),fe=ve[0],ze=ve[1],ge=n.useCallback((function(e){return Q7(a,void 0,void 0,(function(){var t,n,a;return J7(this,(function(r){switch(r.label){case 0:return(t=o.find((function(t){return t._id===e.pdfIdOfPage})))&&(n=t.pages.find((function(t){return t._id===e.pdfPageId})))?n.pageImageElement||fe.includes(n._id)?[2]:(ze((function(e){return Z7(Z7([],e,!0),[n._id],!1)})),[4,Oae.downloadImage(n.pageImageUrl)]):[2];case 1:return a=r.sent(),c((function(t){var n=t.map((function(e){return X7(X7({},e),{pages:e.pages.map((function(e){return X7({},e)}))})})),r=n.findIndex((function(t){return t._id===e.pdfIdOfPage})),o=n[r].pages.findIndex((function(t){return t._id===e.pdfPageId}));return n[r].pages[o].pageImageElement=a,n})),ze((function(e){return Z7([],e.filter((function(e){return e!==n._id})),!0)})),[2]}}))}))}),[fe,o]),ye=n.useCallback((function(e){return Q7(a,void 0,void 0,(function(){var t,n,a,r;return J7(this,(function(l){switch(l.label){case 0:return t=e.pdfId,(n=o.find((function(e){return e._id===t})))?(a=n.pages.map((function(e){return e._id})),[4,K.current.fetchOnlyPdfPagesData({excludePdfPageIds:a,pdfId:t,getPdfPageImageDownloadUrl:"true",pdfPageImageUploaded:"true"})]):[2];case 1:return r=l.sent(),c((function(e){var n=e.findIndex((function(e){return e._id===t}));return-1===n?e:(e[n].pages=Z7(Z7([],e[n].pages,!0),r.pages.map((function(e){return{_id:e._id,pdfId:e.pdfId,pageNumber:e.pageNumber,annotations:[],commentThreads:[],pageAsImageDetails:e.pageAsImageDetails,pageImageUrl:e.pageAsImageDetails.pageImageDownloadUrl||"",pdfPageWidthInPoints:e.pdfPageWidthInPoints,pdfPageHeightInPoints:e.pdfPageHeightInPoints}})),!0),Z7([],e,!0))})),[2]}}))}))}),[o,K]),Me=n.useCallback((function(e){var t=e.pdfId,n=e.pdfPageId,r=e.annotationIds;return Q7(a,void 0,void 0,(function(){return J7(this,(function(e){return c((function(e){return e.map((function(e){return e._id===t?X7(X7({},e),{pages:e.pages.map((function(e){return e._id===n?X7(X7({},e),{annotations:e.annotations.filter((function(e){return!r.includes(e._id)||(K.current.deletePageAnnotation({annotationId:e._id}),!1)}))}):X7({},e)}))}):X7({},e)}))})),[2]}))}))}),[K]),Ee=n.useCallback((function(e){var t=e.pdfId,n=e.pdfPageId,a=e.annotations;c((function(e){return e.map((function(e){return e._id===t?X7(X7({},e),{pages:e.pages.map((function(e){return e._id===n?X7(X7({},e),{annotations:Z7(Z7([],e.annotations,!0),a,!0)}):X7({pdfPageId:e._id},e)}))}):X7({},e)}))}))}),[]),be=n.useState({rectangleAnnotationOptions:q,rectangleAnnotationData:{_id:"",color:"",height:0,width:0,pdfId:"",pdfPageId:"",rotationAngle:0,x:0,y:0},rectangleAnnotationConfigurationDrawer:{isOpen:!1,sections:{color:{collapsedStatus:"collapsed",currentlySelectedColor:""}}}}),He=be[0],Ve=be[1],Ce=n.useMemo((function(){for(var e=null,t=0,n=o||[];t<n.length;t++)for(var a=0,r=n[t].pages||[];a<r.length;a++)for(var c=0,l=r[a].annotations||[];c<l.length;c++){var s=l[c];if(s._id===i)return s}return e}),[i]);n.useEffect((function(){(null==Ce?void 0:Ce.rectangleAnnotation)?Ve(_ie((function(e){var t;e.rectangleAnnotationConfigurationDrawer.sections.color.currentlySelectedColor=(null===(t=Ce.rectangleAnnotation)||void 0===t?void 0:t.color)||""}))):(v(_ie((function(e){e.measureToolRelatedData.distanceAnnotation.configurationsDrawer.isOpen=!1}))),Ve(_ie((function(e){e.rectangleAnnotationConfigurationDrawer.isOpen=!1}))))}),[Ce]);var Le=n.useMemo((function(){return{pdfs:o,setPdfs:c,annotationSelectedId:i,setAnnotationSelectedId:s,toolSelected:d,setToolSelected:u,tools:p,setTools:v,currentUserId:z,setCurrentUserId:g,users:M,setUsers:E,isLeftBarOpen:O,setIsLeftBarOpen:A,isAnnotationsVisible:P,setIsAnnotationsVisible:F,backendBaseUrl:G,fetchPdfRelatedData:he,removeAnnotationsFromPdfPageAndDb:Me,addAnnotationsToPdfPage:Ee,addPdfPageImageElementIfNotPresentAlready:ge,setSelectedCommentThreadId:de,pageZoomPercentage:k,setPageZoomPercentage:w,rlefEventServiceBaseUrl:Y,addNewScaleDetails:ue,addScaleButtonClickedFromToolbar:pe,pdfEditorServiceRef:K,fetchAndSetPdfPagesInPdfWhichAreCreatedInDB:ye,pdfPageIdsForWhichPageImageElementIsBeingFetched:fe,callOutToolRelatedDataWhenSelected:ie,setCallOutToolRelatedDataWhenSelected:se,pdfEditorElementId:Q,selectedToolGroup:j,setSelectedToolGroup:B,pdfIdsWhoseDataBeingFetched:Z,annotationSelected:Ce,editScaleDetails:me,suggestedUsersForMention:H,fetchAndSetSuggestedUsersForMention:ne,isFetchingSuggestedUsersForMention:L,customCursorToShow:W,setCustomCursorToShow:$,rectangleRelatedData:He,setRectangleRelatedData:Ve}}),[o,i,d,p,z,M,O,P,G,he,ge,de,k,w,Y,ue,pe,ye,fe,ie,Q,j,Z,Ce,me,H,ne,L,W,He]);return t.jsx($ie.Provider,X7({value:Le},{children:e.children}))}var $ie=c.default.createContext({}),qie=function(){var e=c.default.useContext($ie);if(!e)throw new Error("usePdfAnnotationContext must be used within a PdfEditorContextProvider");return e};$le(".ContentArea-module_content-area-container__otXm-{align-items:center;background-color:#e3e6e8;display:flex;flex:1;justify-content:center;overflow:auto;position:relative}");$le(".PdfPage-module_pageContainer__-Q0sD{display:flex;flex-grow:1;height:100%;width:100%}.PdfPage-module_pageContainerWhenHorizontallyOverflowingAndIsVisibleInViewport__8onR1{align-self:flex-start}.PdfPage-module_justifyContentCenter__-7ATB{justify-content:center}.PdfPage-module_selectedText__m7jFl span::selection{background-color:#ffff0045!important}.PdfPage-module_selectedText__m7jFl span::-moz-selection{background-color:#ffff0045!important}.PdfPage-module_displayNone__cHRJo{display:none}.PdfPage-module_handCursor__vsE7b{cursor:grab!important}.PdfPage-module_handCursor__vsE7b:active{cursor:grabbing!important}");var Gie=Math.PI/180;const Yie=void 0!==eee?eee:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},Kie={_global:Yie,version:"8.4.3",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(e){}.toString()),dblClickWindow:400,getAngle:e=>Kie.angleDeg?e*Gie:e,enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>Kie.DD.isDragging,isDragReady:()=>!!Kie.DD.node,releaseCanvasOnDestroy:!0,document:Yie.document,_injectGlobal(e){Yie.Konva=e}},Xie=e=>{Kie[e.prototype.getClassName()]=e};Kie._injectGlobal(Kie);class Qie{constructor(e=[1,0,0,1,0,0]){this.dirty=!1,this.m=e&&e.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new Qie(this.m)}copyInto(e){e.m[0]=this.m[0],e.m[1]=this.m[1],e.m[2]=this.m[2],e.m[3]=this.m[3],e.m[4]=this.m[4],e.m[5]=this.m[5]}point(e){var t=this.m;return{x:t[0]*e.x+t[2]*e.y+t[4],y:t[1]*e.x+t[3]*e.y+t[5]}}translate(e,t){return this.m[4]+=this.m[0]*e+this.m[2]*t,this.m[5]+=this.m[1]*e+this.m[3]*t,this}scale(e,t){return this.m[0]*=e,this.m[1]*=e,this.m[2]*=t,this.m[3]*=t,this}rotate(e){var t=Math.cos(e),n=Math.sin(e),a=this.m[0]*t+this.m[2]*n,r=this.m[1]*t+this.m[3]*n,o=this.m[0]*-n+this.m[2]*t,c=this.m[1]*-n+this.m[3]*t;return this.m[0]=a,this.m[1]=r,this.m[2]=o,this.m[3]=c,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(e,t){var n=this.m[0]+this.m[2]*t,a=this.m[1]+this.m[3]*t,r=this.m[2]+this.m[0]*e,o=this.m[3]+this.m[1]*e;return this.m[0]=n,this.m[1]=a,this.m[2]=r,this.m[3]=o,this}multiply(e){var t=this.m[0]*e.m[0]+this.m[2]*e.m[1],n=this.m[1]*e.m[0]+this.m[3]*e.m[1],a=this.m[0]*e.m[2]+this.m[2]*e.m[3],r=this.m[1]*e.m[2]+this.m[3]*e.m[3],o=this.m[0]*e.m[4]+this.m[2]*e.m[5]+this.m[4],c=this.m[1]*e.m[4]+this.m[3]*e.m[5]+this.m[5];return this.m[0]=t,this.m[1]=n,this.m[2]=a,this.m[3]=r,this.m[4]=o,this.m[5]=c,this}invert(){var e=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),t=this.m[3]*e,n=-this.m[1]*e,a=-this.m[2]*e,r=this.m[0]*e,o=e*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),c=e*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=t,this.m[1]=n,this.m[2]=a,this.m[3]=r,this.m[4]=o,this.m[5]=c,this}getMatrix(){return this.m}decompose(){var e=this.m[0],t=this.m[1],n=this.m[2],a=this.m[3],r=e*a-t*n;let o={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=e||0!=t){var c=Math.sqrt(e*e+t*t);o.rotation=t>0?Math.acos(e/c):-Math.acos(e/c),o.scaleX=c,o.scaleY=r/c,o.skewX=(e*n+t*a)/r,o.skewY=0}else if(0!=n||0!=a){var l=Math.sqrt(n*n+a*a);o.rotation=Math.PI/2-(a>0?Math.acos(-n/l):-Math.acos(n/l)),o.scaleX=r/l,o.scaleY=l,o.skewX=0,o.skewY=(e*n+t*a)/r}return o.rotation=ose._getRotation(o.rotation),o}}var Jie=Math.PI/180,Zie=180/Math.PI,ese="Konva error: ",tse={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},nse=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,ase=[];const rse="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(e){setTimeout(e,60)},ose={_isElement:e=>!(!e||1!=e.nodeType),_isFunction:e=>!!(e&&e.constructor&&e.call&&e.apply),_isPlainObject:e=>!!e&&e.constructor===Object,_isArray:e=>"[object Array]"===Object.prototype.toString.call(e),_isNumber:e=>"[object Number]"===Object.prototype.toString.call(e)&&!isNaN(e)&&isFinite(e),_isString:e=>"[object String]"===Object.prototype.toString.call(e),_isBoolean:e=>"[object Boolean]"===Object.prototype.toString.call(e),isObject:e=>e instanceof Object,isValidSelector(e){if("string"!=typeof e)return!1;var t=e[0];return"#"===t||"."===t||t===t.toUpperCase()},_sign:e=>0===e||e>0?1:-1,requestAnimFrame(e){ase.push(e),1===ase.length&&rse((function(){const e=ase;ase=[],e.forEach((function(e){e()}))}))},createCanvasElement(){var e=document.createElement("canvas");try{e.style=e.style||{}}catch(e){}return e},createImageElement:()=>document.createElement("img"),_isInDocument(e){for(;e=e.parentNode;)if(e==document)return!0;return!1},_urlToImage(e,t){var n=ose.createImageElement();n.onload=function(){t(n)},n.src=e},_rgbToHex:(e,t,n)=>((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1),_hexToRgb(e){e=e.replace("#","");var t=parseInt(e,16);return{r:t>>16&255,g:t>>8&255,b:255&t}},getRandomColor(){for(var e=(16777215*Math.random()|0).toString(16);e.length<6;)e="0"+e;return"#"+e},getRGB(e){var t;return e in tse?{r:(t=tse[e])[0],g:t[1],b:t[2]}:"#"===e[0]?this._hexToRgb(e.substring(1)):"rgb("===e.substr(0,4)?(t=nse.exec(e.replace(/ /g,"")),{r:parseInt(t[1],10),g:parseInt(t[2],10),b:parseInt(t[3],10)}):{r:0,g:0,b:0}},colorToRGBA:e=>(e=e||"black",ose._namedColorToRBA(e)||ose._hex3ColorToRGBA(e)||ose._hex4ColorToRGBA(e)||ose._hex6ColorToRGBA(e)||ose._hex8ColorToRGBA(e)||ose._rgbColorToRGBA(e)||ose._rgbaColorToRGBA(e)||ose._hslColorToRGBA(e)),_namedColorToRBA(e){var t=tse[e.toLowerCase()];return t?{r:t[0],g:t[1],b:t[2],a:1}:null},_rgbColorToRGBA(e){if(0===e.indexOf("rgb(")){var t=(e=e.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:t[0],g:t[1],b:t[2],a:1}}},_rgbaColorToRGBA(e){if(0===e.indexOf("rgba(")){var t=(e=e.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map(((e,t)=>"%"===e.slice(-1)?3===t?parseInt(e)/100:parseInt(e)/100*255:Number(e)));return{r:t[0],g:t[1],b:t[2],a:t[3]}}},_hex8ColorToRGBA(e){if("#"===e[0]&&9===e.length)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:parseInt(e.slice(7,9),16)/255}},_hex6ColorToRGBA(e){if("#"===e[0]&&7===e.length)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:1}},_hex4ColorToRGBA(e){if("#"===e[0]&&5===e.length)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:parseInt(e[4]+e[4],16)/255}},_hex3ColorToRGBA(e){if("#"===e[0]&&4===e.length)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:1}},_hslColorToRGBA(e){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(e)){const[t,...n]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e),a=Number(n[0])/360,r=Number(n[1])/100,o=Number(n[2])/100;let c,l,i;if(0===r)return i=255*o,{r:Math.round(i),g:Math.round(i),b:Math.round(i),a:1};c=o<.5?o*(1+r):o+r-o*r;const s=2*o-c,h=[0,0,0];for(let e=0;e<3;e++)l=a+1/3*-(e-1),l<0&&l++,l>1&&l--,i=6*l<1?s+6*(c-s)*l:2*l<1?c:3*l<2?s+(c-s)*(2/3-l)*6:s,h[e]=255*i;return{r:Math.round(h[0]),g:Math.round(h[1]),b:Math.round(h[2]),a:1}}},haveIntersection:(e,t)=>!(t.x>e.x+e.width||t.x+t.width<e.x||t.y>e.y+e.height||t.y+t.height<e.y),cloneObject(e){var t={};for(var n in e)this._isPlainObject(e[n])?t[n]=this.cloneObject(e[n]):this._isArray(e[n])?t[n]=this.cloneArray(e[n]):t[n]=e[n];return t},cloneArray:e=>e.slice(0),degToRad:e=>e*Jie,radToDeg:e=>e*Zie,_degToRad:e=>(ose.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),ose.degToRad(e)),_radToDeg:e=>(ose.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),ose.radToDeg(e)),_getRotation:e=>Kie.angleDeg?ose.radToDeg(e):e,_capitalize:e=>e.charAt(0).toUpperCase()+e.slice(1),throw(e){throw new Error(ese+e)},error(e){console.error(ese+e)},warn(e){Kie.showWarnings&&console.warn("Konva warning: "+e)},each(e,t){for(var n in e)t(n,e[n])},_inRange:(e,t,n)=>t<=e&&e<n,_getProjectionToSegment(e,t,n,a,r,o){var c,l,i,s=(e-n)*(e-n)+(t-a)*(t-a);if(0==s)c=e,l=t,i=(r-n)*(r-n)+(o-a)*(o-a);else{var h=((r-e)*(n-e)+(o-t)*(a-t))/s;h<0?(c=e,l=t,i=(e-r)*(e-r)+(t-o)*(t-o)):h>1?(c=n,l=a,i=(n-r)*(n-r)+(a-o)*(a-o)):i=((c=e+h*(n-e))-r)*(c-r)+((l=t+h*(a-t))-o)*(l-o)}return[c,l,i]},_getProjectionToLine(e,t,n){var a=ose.cloneObject(e),r=Number.MAX_VALUE;return t.forEach((function(o,c){if(n||c!==t.length-1){var l=t[(c+1)%t.length],i=ose._getProjectionToSegment(o.x,o.y,l.x,l.y,e.x,e.y),s=i[0],h=i[1],d=i[2];d<r&&(a.x=s,a.y=h,r=d)}})),a},_prepareArrayForTween(e,t,n){var a,r=[],o=[];if(e.length>t.length){var c=t;t=e,e=c}for(a=0;a<e.length;a+=2)r.push({x:e[a],y:e[a+1]});for(a=0;a<t.length;a+=2)o.push({x:t[a],y:t[a+1]});var l=[];return o.forEach((function(e){var t=ose._getProjectionToLine(e,r,n);l.push(t.x),l.push(t.y)})),l},_prepareToStringify(e){var t;for(var n in e.visitedByCircularReferenceRemoval=!0,e)if(e.hasOwnProperty(n)&&e[n]&&"object"==typeof e[n])if(t=Object.getOwnPropertyDescriptor(e,n),e[n].visitedByCircularReferenceRemoval||ose._isElement(e[n])){if(!t.configurable)return null;delete e[n]}else if(null===ose._prepareToStringify(e[n])){if(!t.configurable)return null;delete e[n]}return delete e.visitedByCircularReferenceRemoval,e},_assign(e,t){for(var n in t)e[n]=t[n];return e},_getFirstPointerId:e=>e.touches?e.changedTouches[0].identifier:e.pointerId||999,releaseCanvas(...e){Kie.releaseCanvasOnDestroy&&e.forEach((e=>{e.width=0,e.height=0}))},drawRoundedRectPath(e,t,n,a){let r=0,o=0,c=0,l=0;"number"==typeof a?r=o=c=l=Math.min(a,t/2,n/2):(r=Math.min(a[0]||0,t/2,n/2),o=Math.min(a[1]||0,t/2,n/2),l=Math.min(a[2]||0,t/2,n/2),c=Math.min(a[3]||0,t/2,n/2)),e.moveTo(r,0),e.lineTo(t-o,0),e.arc(t-o,o,o,3*Math.PI/2,0,!1),e.lineTo(t,n-l),e.arc(t-l,n-l,l,0,Math.PI/2,!1),e.lineTo(c,n),e.arc(c,n-c,c,Math.PI/2,Math.PI,!1),e.lineTo(0,r),e.arc(r,r,r,Math.PI,3*Math.PI/2,!1)}};function cse(e){return ose._isString(e)?'"'+e+'"':"[object Number]"===Object.prototype.toString.call(e)||ose._isBoolean(e)?e:Object.prototype.toString.call(e)}function lse(e){return e>255?255:e<0?0:Math.round(e)}function ise(){if(Kie.isUnminified)return function(e,t){return ose._isNumber(e)||ose.warn(cse(e)+' is a not valid value for "'+t+'" attribute. The value should be a number.'),e}}function sse(e){if(Kie.isUnminified)return function(t,n){let a=ose._isNumber(t),r=ose._isArray(t)&&t.length==e;return a||r||ose.warn(cse(t)+' is a not valid value for "'+n+'" attribute. The value should be a number or Array<number>('+e+")"),t}}function hse(){if(Kie.isUnminified)return function(e,t){return ose._isNumber(e)||"auto"===e||ose.warn(cse(e)+' is a not valid value for "'+t+'" attribute. The value should be a number or "auto".'),e}}function dse(){if(Kie.isUnminified)return function(e,t){return ose._isString(e)||ose.warn(cse(e)+' is a not valid value for "'+t+'" attribute. The value should be a string.'),e}}function use(){if(Kie.isUnminified)return function(e,t){const n=ose._isString(e),a="[object CanvasGradient]"===Object.prototype.toString.call(e)||e&&e.addColorStop;return n||a||ose.warn(cse(e)+' is a not valid value for "'+t+'" attribute. The value should be a string or a native gradient.'),e}}function mse(){if(Kie.isUnminified)return function(e,t){return!0===e||!1===e||ose.warn(cse(e)+' is a not valid value for "'+t+'" attribute. The value should be a boolean.'),e}}var pse="get",vse="set";const fse={addGetterSetter(e,t,n,a,r){fse.addGetter(e,t,n),fse.addSetter(e,t,a,r),fse.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){var a=pse+ose._capitalize(t);e.prototype[a]=e.prototype[a]||function(){var e=this.attrs[t];return void 0===e?n:e}},addSetter(e,t,n,a){var r=vse+ose._capitalize(t);e.prototype[r]||fse.overWriteSetter(e,t,n,a)},overWriteSetter(e,t,n,a){var r=vse+ose._capitalize(t);e.prototype[r]=function(e){return n&&null!=e&&(e=n.call(this,e,t)),this._setAttr(t,e),a&&a.call(this),this}},addComponentsGetterSetter(e,t,n,a,r){var o,c,l=n.length,i=ose._capitalize,s=pse+i(t),h=vse+i(t);e.prototype[s]=function(){var e={};for(o=0;o<l;o++)e[c=n[o]]=this.getAttr(t+i(c));return e};var d=function(e){if(Kie.isUnminified)return function(t,n){return null==t||ose.isObject(t)||ose.warn(cse(t)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+e),t}}(n);e.prototype[h]=function(e){var o,c=this.attrs[t];for(o in a&&(e=a.call(this,e)),d&&d.call(this,e,t),e)e.hasOwnProperty(o)&&this._setAttr(t+i(o),e[o]);return e||n.forEach((e=>{this._setAttr(t+i(e),void 0)})),this._fireChangeEvent(t,c,e),r&&r.call(this),this},fse.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){var n=ose._capitalize(t),a=vse+n,r=pse+n;e.prototype[t]=function(){return arguments.length?(this[a](arguments[0]),this):this[r]()}},addDeprecatedGetterSetter(e,t,n,a){ose.error("Adding deprecated "+t);var r=pse+ose._capitalize(t),o=t+" property is deprecated and will be removed soon. Look at Konva change log for more information.";e.prototype[r]=function(){ose.error(o);var e=this.attrs[t];return void 0===e?n:e},fse.addSetter(e,t,a,(function(){ose.error(o)})),fse.addOverloadedGetterSetter(e,t)},backCompat(e,t){ose.each(t,(function(t,n){var a=e.prototype[n],r=pse+ose._capitalize(t),o=vse+ose._capitalize(t);function c(){a.apply(this,arguments),ose.error('"'+t+'" method is deprecated and will be removed soon. Use ""'+n+'" instead.')}e.prototype[t]=c,e.prototype[r]=c,e.prototype[o]=c}))},afterSetFilter(){this._filterUpToDate=!1}};var zse,gse=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];class yse{constructor(e){this.canvas=e,Kie.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(e){e.fillEnabled()&&this._fill(e)}_fill(e){}strokeShape(e){e.hasStroke()&&this._stroke(e)}_stroke(e){}fillStrokeShape(e){e.attrs.fillAfterStrokeEnabled?(this.strokeShape(e),this.fillShape(e)):(this.fillShape(e),this.strokeShape(e))}getTrace(e,t){var n,a,r,o,c=this.traceArr,l=c.length,i="";for(n=0;n<l;n++)(r=(a=c[n]).method)?(o=a.args,i+=r,e?i+="()":ose._isArray(o[0])?i+="(["+o.join(",")+"])":(t&&(o=o.map((e=>"number"==typeof e?Math.floor(e):e))),i+="("+o.join(",")+")")):(i+=a.property,e||(i+="="+a.val)),i+=";";return i}clearTrace(){this.traceArr=[]}_trace(e){var t=this.traceArr;t.push(e),t.length>=100&&t.shift()}reset(){var e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){var t=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,t.getWidth()/t.pixelRatio,t.getHeight()/t.pixelRatio)}_applyLineCap(e){const t=e.attrs.lineCap;t&&this.setAttr("lineCap",t)}_applyOpacity(e){var t=e.getAbsoluteOpacity();1!==t&&this.setAttr("globalAlpha",t)}_applyLineJoin(e){const t=e.attrs.lineJoin;t&&this.setAttr("lineJoin",t)}setAttr(e,t){this._context[e]=t}arc(e,t,n,a,r,o){this._context.arc(e,t,n,a,r,o)}arcTo(e,t,n,a,r){this._context.arcTo(e,t,n,a,r)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,n,a,r,o){this._context.bezierCurveTo(e,t,n,a,r,o)}clearRect(e,t,n,a){this._context.clearRect(e,t,n,a)}clip(){this._context.clip()}closePath(){this._context.closePath()}createImageData(e,t){var n=arguments;return 2===n.length?this._context.createImageData(e,t):1===n.length?this._context.createImageData(e):void 0}createLinearGradient(e,t,n,a){return this._context.createLinearGradient(e,t,n,a)}createPattern(e,t){return this._context.createPattern(e,t)}createRadialGradient(e,t,n,a,r,o){return this._context.createRadialGradient(e,t,n,a,r,o)}drawImage(e,t,n,a,r,o,c,l,i){var s=arguments,h=this._context;3===s.length?h.drawImage(e,t,n):5===s.length?h.drawImage(e,t,n,a,r):9===s.length&&h.drawImage(e,t,n,a,r,o,c,l,i)}ellipse(e,t,n,a,r,o,c,l){this._context.ellipse(e,t,n,a,r,o,c,l)}isPointInPath(e,t,n,a){return n?this._context.isPointInPath(n,e,t,a):this._context.isPointInPath(e,t,a)}fill(e){e?this._context.fill(e):this._context.fill()}fillRect(e,t,n,a){this._context.fillRect(e,t,n,a)}strokeRect(e,t,n,a){this._context.strokeRect(e,t,n,a)}fillText(e,t,n,a){a?this._context.fillText(e,t,n,a):this._context.fillText(e,t,n)}measureText(e){return this._context.measureText(e)}getImageData(e,t,n,a){return this._context.getImageData(e,t,n,a)}lineTo(e,t){this._context.lineTo(e,t)}moveTo(e,t){this._context.moveTo(e,t)}rect(e,t,n,a){this._context.rect(e,t,n,a)}putImageData(e,t,n){this._context.putImageData(e,t,n)}quadraticCurveTo(e,t,n,a){this._context.quadraticCurveTo(e,t,n,a)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,t){this._context.scale(e,t)}setLineDash(e){this._context.setLineDash?this._context.setLineDash(e):"mozDash"in this._context?this._context.mozDash=e:"webkitLineDash"in this._context&&(this._context.webkitLineDash=e)}getLineDash(){return this._context.getLineDash()}setTransform(e,t,n,a,r,o){this._context.setTransform(e,t,n,a,r,o)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,t,n,a){this._context.strokeText(e,t,n,a)}transform(e,t,n,a,r,o){this._context.transform(e,t,n,a,r,o)}translate(e,t){this._context.translate(e,t)}_enableTrace(){var e,t,n=this,a=gse.length,r=this.setAttr,o=function(e){var a,r=n[e];n[e]=function(){return t=function(e){var t,n,a=[],r=e.length,o=ose;for(t=0;t<r;t++)n=e[t],o._isNumber(n)?n=Math.round(1e3*n)/1e3:o._isString(n)||(n+=""),a.push(n);return a}(Array.prototype.slice.call(arguments,0)),a=r.apply(n,arguments),n._trace({method:e,args:t}),a}};for(e=0;e<a;e++)o(gse[e]);n.setAttr=function(){r.apply(n,arguments);var e=arguments[0],t=arguments[1];"shadowOffsetX"!==e&&"shadowOffsetY"!==e&&"shadowBlur"!==e||(t/=this.canvas.getPixelRatio()),n._trace({property:e,val:t})}}_applyGlobalCompositeOperation(e){const t=e.attrs.globalCompositeOperation;!t||"source-over"===t||this.setAttr("globalCompositeOperation",t)}}["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach((function(e){Object.defineProperty(yse.prototype,e,{get(){return this._context[e]},set(t){this._context[e]=t}})}));class Mse extends yse{constructor(e){super(e),this._context=e._canvas.getContext("2d")}_fillColor(e){var t=e.fill();this.setAttr("fillStyle",t),e._fillFunc(this)}_fillPattern(e){this.setAttr("fillStyle",e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){var t=e._getLinearGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fillRadialGradient(e){const t=e._getRadialGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fill(e){const t=e.fill(),n=e.getFillPriority();if(t&&"color"===n)return void this._fillColor(e);const a=e.getFillPatternImage();if(a&&"pattern"===n)return void this._fillPattern(e);const r=e.getFillLinearGradientColorStops();if(r&&"linear-gradient"===n)return void this._fillLinearGradient(e);const o=e.getFillRadialGradientColorStops();o&&"radial-gradient"===n?this._fillRadialGradient(e):t?this._fillColor(e):a?this._fillPattern(e):r?this._fillLinearGradient(e):o&&this._fillRadialGradient(e)}_strokeLinearGradient(e){const t=e.getStrokeLinearGradientStartPoint(),n=e.getStrokeLinearGradientEndPoint(),a=e.getStrokeLinearGradientColorStops(),r=this.createLinearGradient(t.x,t.y,n.x,n.y);if(a){for(var o=0;o<a.length;o+=2)r.addColorStop(a[o],a[o+1]);this.setAttr("strokeStyle",r)}}_stroke(e){var t=e.dash(),n=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!n){this.save();var a=this.getCanvas().getPixelRatio();this.setTransform(a,0,0,a,0,0)}this._applyLineCap(e),t&&e.dashEnabled()&&(this.setLineDash(t),this.setAttr("lineDashOffset",e.dashOffset())),this.setAttr("lineWidth",e.strokeWidth()),e.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)"),e.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(e):this.setAttr("strokeStyle",e.stroke()),e._strokeFunc(this),n||this.restore()}}_applyShadow(e){var t,n,a,r=null!==(t=e.getShadowRGBA())&&void 0!==t?t:"black",o=null!==(n=e.getShadowBlur())&&void 0!==n?n:5,c=null!==(a=e.getShadowOffset())&&void 0!==a?a:{x:0,y:0},l=e.getAbsoluteScale(),i=this.canvas.getPixelRatio(),s=l.x*i,h=l.y*i;this.setAttr("shadowColor",r),this.setAttr("shadowBlur",o*Math.min(Math.abs(s),Math.abs(h))),this.setAttr("shadowOffsetX",c.x*s),this.setAttr("shadowOffsetY",c.y*h)}}class Ese extends yse{constructor(e){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:!0})}_fill(e){this.save(),this.setAttr("fillStyle",e.colorKey),e._fillFuncHit(this),this.restore()}strokeShape(e){e.hasHitStroke()&&this._stroke(e)}_stroke(e){if(e.hasHitStroke()){const r=e.getStrokeScaleEnabled();if(!r){this.save();var t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(e);var n=e.hitStrokeWidth(),a="auto"===n?e.strokeWidth():n;this.setAttr("lineWidth",a),this.setAttr("strokeStyle",e.colorKey),e._strokeFuncHit(this),r||this.restore()}}}class bse{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var t=(e||{}).pixelRatio||Kie.pixelRatio||function(){if(zse)return zse;var e=ose.createCanvasElement(),t=e.getContext("2d");return zse=(Kie._global.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1),ose.releaseCanvas(e),zse}();this.pixelRatio=t,this._canvas=ose.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(e){var t=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/t,this.getHeight()/t)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+"px";var t=this.pixelRatio;this.getContext()._context.scale(t,t)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+"px";var t=this.pixelRatio;this.getContext()._context.scale(t,t)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,t){this.setWidth(e||0),this.setHeight(t||0)}toDataURL(e,t){try{return this._canvas.toDataURL(e,t)}catch(e){try{return this._canvas.toDataURL()}catch(e){return ose.error("Unable to get data URL. "+e.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}fse.addGetterSetter(bse,"pixelRatio",void 0,ise());class Hse extends bse{constructor(e={width:0,height:0}){super(e),this.context=new Mse(this),this.setSize(e.width,e.height)}}class Vse extends bse{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new Ese(this),this.setSize(e.width,e.height)}}const Cse={get isDragging(){var e=!1;return Cse._dragElements.forEach((t=>{"dragging"===t.dragStatus&&(e=!0)})),e},justDragged:!1,get node(){var e;return Cse._dragElements.forEach((t=>{e=t.node})),e},_dragElements:new Map,_drag(e){const t=[];Cse._dragElements.forEach(((n,a)=>{const{node:r}=n,o=r.getStage();o.setPointersPositions(e),void 0===n.pointerId&&(n.pointerId=ose._getFirstPointerId(e));const c=o._changedPointerPositions.find((e=>e.id===n.pointerId));if(c){if("dragging"!==n.dragStatus){var l=r.dragDistance();if(Math.max(Math.abs(c.x-n.startPointerPos.x),Math.abs(c.y-n.startPointerPos.y))<l)return;if(r.startDrag({evt:e}),!r.isDragging())return}r._setDragPosition(e,n),t.push(r)}})),t.forEach((t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:e},!0)}))},_endDragBefore(e){const t=[];Cse._dragElements.forEach((n=>{const{node:a}=n,r=a.getStage();if(e&&r.setPointersPositions(e),!r._changedPointerPositions.find((e=>e.id===n.pointerId)))return;"dragging"!==n.dragStatus&&"stopped"!==n.dragStatus||(Cse.justDragged=!0,Kie._mouseListenClick=!1,Kie._touchListenClick=!1,Kie._pointerListenClick=!1,n.dragStatus="stopped");const o=n.node.getLayer()||n.node instanceof Kie.Stage&&n.node;o&&-1===t.indexOf(o)&&t.push(o)})),t.forEach((e=>{e.draw()}))},_endDragAfter(e){Cse._dragElements.forEach(((t,n)=>{"stopped"===t.dragStatus&&t.node.fire("dragend",{type:"dragend",target:t.node,evt:e},!0),"dragging"!==t.dragStatus&&Cse._dragElements.delete(n)}))}};Kie.isBrowser&&(window.addEventListener("mouseup",Cse._endDragBefore,!0),window.addEventListener("touchend",Cse._endDragBefore,!0),window.addEventListener("mousemove",Cse._drag),window.addEventListener("touchmove",Cse._drag),window.addEventListener("mouseup",Cse._endDragAfter,!1),window.addEventListener("touchend",Cse._endDragAfter,!1));var Lse="absoluteOpacity",xse="allEventListeners",Sse="absoluteTransform",kse="absoluteScale",wse="canvas",Tse="listening",Ose="mouseenter",Ase="mouseleave",Rse="Shape",Nse=" ",_se="stage",Dse="transform",Pse="visible",Fse=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(Nse);let Ise=1;class jse{constructor(e){this._id=Ise++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(e),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(e){e!==Dse&&e!==Sse||!this._cache.get(e)?e?this._cache.delete(e):this._cache.clear():this._cache.get(e).dirty=!0}_getCache(e,t){var n=this._cache.get(e);return(void 0===n||(e===Dse||e===Sse)&&!0===n.dirty)&&(n=t.call(this),this._cache.set(e,n)),n}_calculate(e,t,n){if(!this._attachedDepsListeners.get(e)){const n=t.map((e=>e+"Change.konva")).join(Nse);this.on(n,(()=>{this._clearCache(e)})),this._attachedDepsListeners.set(e,!0)}return this._getCache(e,n)}_getCanvasCache(){return this._cache.get(wse)}_clearSelfAndDescendantCache(e){this._clearCache(e),e===Sse&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(wse)){const{scene:e,filter:t,hit:n}=this._cache.get(wse);ose.releaseCanvas(e,t,n),this._cache.delete(wse)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){var t=e||{},n={};void 0!==t.x&&void 0!==t.y&&void 0!==t.width&&void 0!==t.height||(n=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()}));var a=Math.ceil(t.width||n.width),r=Math.ceil(t.height||n.height),o=t.pixelRatio,c=void 0===t.x?Math.floor(n.x):t.x,l=void 0===t.y?Math.floor(n.y):t.y,i=t.offset||0,s=t.drawBorder||!1,h=t.hitCanvasPixelRatio||1;if(a&&r){c-=i,l-=i;var d=new Hse({pixelRatio:o,width:a+=2*i+1,height:r+=2*i+1}),u=new Hse({pixelRatio:o,width:0,height:0}),m=new Vse({pixelRatio:h,width:a,height:r}),p=d.getContext(),v=m.getContext();return m.isCache=!0,d.isCache=!0,this._cache.delete(wse),this._filterUpToDate=!1,!1===t.imageSmoothingEnabled&&(d.getContext()._context.imageSmoothingEnabled=!1,u.getContext()._context.imageSmoothingEnabled=!1),p.save(),v.save(),p.translate(-c,-l),v.translate(-c,-l),this._isUnderCache=!0,this._clearSelfAndDescendantCache(Lse),this._clearSelfAndDescendantCache(kse),this.drawScene(d,this),this.drawHit(m,this),this._isUnderCache=!1,p.restore(),v.restore(),s&&(p.save(),p.beginPath(),p.rect(0,0,a,r),p.closePath(),p.setAttr("strokeStyle","red"),p.setAttr("lineWidth",5),p.stroke(),p.restore()),this._cache.set(wse,{scene:d,filter:u,hit:m,x:c,y:l}),this._requestDraw(),this}ose.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.")}isCached(){return this._cache.has(wse)}getClientRect(e){throw new Error('abstract "getClientRect" method call')}_transformedRect(e,t){var n,a,r,o,c=[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}],l=this.getAbsoluteTransform(t);return c.forEach((function(e){var t=l.point(e);void 0===n&&(n=r=t.x,a=o=t.y),n=Math.min(n,t.x),a=Math.min(a,t.y),r=Math.max(r,t.x),o=Math.max(o,t.y)})),{x:n,y:a,width:r-n,height:o-a}}_drawCachedSceneCanvas(e){e.save(),e._applyOpacity(this),e._applyGlobalCompositeOperation(this);const t=this._getCanvasCache();e.translate(t.x,t.y);var n=this._getCachedSceneCanvas(),a=n.pixelRatio;e.drawImage(n._canvas,0,0,n.width/a,n.height/a),e.restore()}_drawCachedHitCanvas(e){var t=this._getCanvasCache(),n=t.hit;e.save(),e.translate(t.x,t.y),e.drawImage(n._canvas,0,0,n.width/n.pixelRatio,n.height/n.pixelRatio),e.restore()}_getCachedSceneCanvas(){var e,t,n,a,r=this.filters(),o=this._getCanvasCache(),c=o.scene,l=o.filter,i=l.getContext();if(r){if(!this._filterUpToDate){var s=c.pixelRatio;l.setSize(c.width/c.pixelRatio,c.height/c.pixelRatio);try{for(e=r.length,i.clear(),i.drawImage(c._canvas,0,0,c.getWidth()/s,c.getHeight()/s),t=i.getImageData(0,0,l.getWidth(),l.getHeight()),n=0;n<e;n++)"function"==typeof(a=r[n])?(a.call(this,t),i.putImageData(t,0,0)):ose.error("Filter should be type of function, but got "+typeof a+" instead. Please check correct filters")}catch(e){ose.error("Unable to apply filter. "+e.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return l}return c}on(e,t){if(this._cache&&this._cache.delete(xse),3===arguments.length)return this._delegate.apply(this,arguments);var n,a,r,o,c=e.split(Nse),l=c.length;for(n=0;n<l;n++)r=(a=c[n].split("."))[0],o=a[1]||"",this.eventListeners[r]||(this.eventListeners[r]=[]),this.eventListeners[r].push({name:o,handler:t});return this}off(e,t){var n,a,r,o,c,l=(e||"").split(Nse),i=l.length;if(this._cache&&this._cache.delete(xse),!e)for(a in this.eventListeners)this._off(a);for(n=0;n<i;n++)if(o=(r=l[n].split("."))[0],c=r[1],o)this.eventListeners[o]&&this._off(o,c,t);else for(a in this.eventListeners)this._off(a,c,t);return this}dispatchEvent(e){var t={target:this,type:e.type,evt:e};return this.fire(e.type,t),this}addEventListener(e,t){return this.on(e,(function(e){t.call(this,e.evt)})),this}removeEventListener(e){return this.off(e),this}_delegate(e,t,n){var a=this;this.on(e,(function(e){for(var r=e.target.findAncestors(t,!0,a),o=0;o<r.length;o++)(e=ose.cloneObject(e)).currentTarget=r[o],n.call(r[o],e)}))}remove(){return this.isDragging()&&this.stopDrag(),Cse._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(Sse),this._clearSelfAndDescendantCache(Lse),this._clearSelfAndDescendantCache(kse),this._clearSelfAndDescendantCache(_se),this._clearSelfAndDescendantCache(Pse),this._clearSelfAndDescendantCache(Tse)}_remove(){this._clearCaches();var e=this.getParent();e&&e.children&&(e.children.splice(this.index,1),e._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(e){var t="get"+ose._capitalize(e);return ose._isFunction(this[t])?this[t]():this.attrs[e]}getAncestors(){for(var e=this.getParent(),t=[];e;)t.push(e),e=e.getParent();return t}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges((()=>{var t,n;if(!e)return this;for(t in e)"children"!==t&&(n="set"+ose._capitalize(t),ose._isFunction(this[n])?this[n](e[t]):this._setAttr(t,e[t]))})),this}isListening(){return this._getCache(Tse,this._isListening)}_isListening(e){if(!this.listening())return!1;const t=this.getParent();return!t||t===e||this===e||t._isListening(e)}isVisible(){return this._getCache(Pse,this._isVisible)}_isVisible(e){if(!this.visible())return!1;const t=this.getParent();return!t||t===e||this===e||t._isVisible(e)}shouldDrawHit(e,t=!1){if(e)return this._isVisible(e)&&this._isListening(e);var n=this.getLayer(),a=!1;Cse._dragElements.forEach((e=>{"dragging"===e.dragStatus&&("Stage"===e.node.nodeType||e.node.getLayer()===n)&&(a=!0)}));var r=!t&&!Kie.hitOnDragEnabled&&a;return this.isListening()&&this.isVisible()&&!r}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){var e,t,n,a,r=this.getDepth(),o=this,c=0;return"Stage"!==o.nodeType&&function l(i){for(e=[],t=i.length,n=0;n<t;n++)a=i[n],c++,a.nodeType!==Rse&&(e=e.concat(a.getChildren().slice())),a._id===o._id&&(n=t);e.length>0&&e[0].getDepth()<=r&&l(e)}(o.getStage().getChildren()),c}getDepth(){for(var e=0,t=this.parent;t;)e++,t=t.parent;return e}_batchTransformChanges(e){this._batchingTransformChange=!0,e(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(Dse),this._clearSelfAndDescendantCache(Sse)),this._needClearTransformCache=!1}setPosition(e){return this._batchTransformChanges((()=>{this.x(e.x),this.y(e.y)})),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){if(!this.getStage())return null;var e=this.getStage().getPointerPosition();if(!e)return null;var t=this.getAbsoluteTransform().copy();return t.invert(),t.point(e)}getAbsolutePosition(e){let t=!1,n=this.parent;for(;n;){if(n.isCached()){t=!0;break}n=n.parent}t&&!e&&(e=!0);var a=this.getAbsoluteTransform(e).getMatrix(),r=new Qie,o=this.offset();return r.m=a.slice(),r.translate(o.x,o.y),r.getTranslation()}setAbsolutePosition(e){var t=this._clearTransform();this.attrs.x=t.x,this.attrs.y=t.y,delete t.x,delete t.y,this._clearCache(Dse);var n=this._getAbsoluteTransform().copy();return n.invert(),n.translate(e.x,e.y),e={x:this.attrs.x+n.getTranslation().x,y:this.attrs.y+n.getTranslation().y},this._setTransform(t),this.setPosition({x:e.x,y:e.y}),this._clearCache(Dse),this._clearSelfAndDescendantCache(Sse),this}_setTransform(e){var t;for(t in e)this.attrs[t]=e[t]}_clearTransform(){var e={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,e}move(e){var t=e.x,n=e.y,a=this.x(),r=this.y();return void 0!==t&&(a+=t),void 0!==n&&(r+=n),this.setPosition({x:a,y:r}),this}_eachAncestorReverse(e,t){var n,a,r=[],o=this.getParent();if(!t||t._id!==this._id){for(r.unshift(this);o&&(!t||o._id!==t._id);)r.unshift(o),o=o.parent;for(n=r.length,a=0;a<n;a++)e(r[a])}}rotate(e){return this.rotation(this.rotation()+e),this}moveToTop(){if(!this.parent)return ose.warn("Node has no parent. moveToTop function is ignored."),!1;var e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return ose.warn("Node has no parent. moveUp function is ignored."),!1;var e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return ose.warn("Node has no parent. moveDown function is ignored."),!1;var e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return ose.warn("Node has no parent. moveToBottom function is ignored."),!1;var e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(e){if(!this.parent)return ose.warn("Node has no parent. zIndex parameter is ignored."),this;(e<0||e>=this.parent.children.length)&&ose.warn("Unexpected value "+e+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");var t=this.index;return this.parent.children.splice(t,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(Lse,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){var e=this.opacity(),t=this.getParent();return t&&!t._isUnderCache&&(e*=t.getAbsoluteOpacity()),e}moveTo(e){return this.getParent()!==e&&(this._remove(),e.add(this)),this}toObject(){var e,t,n,a,r={},o=this.getAttrs();for(e in r.attrs={},o)t=o[e],ose.isObject(t)&&!ose._isPlainObject(t)&&!ose._isArray(t)||(n="function"==typeof this[e]&&this[e],delete o[e],a=n?n.call(this):null,o[e]=t,a!==t&&(r.attrs[e]=t));return r.className=this.getClassName(),ose._prepareToStringify(r)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,t,n){var a=[];t&&this._isMatch(e)&&a.push(this);for(var r=this.parent;r;){if(r===n)return a;r._isMatch(e)&&a.push(r),r=r.parent}return a}isAncestorOf(e){return!1}findAncestor(e,t,n){return this.findAncestors(e,t,n)[0]}_isMatch(e){if(!e)return!1;if("function"==typeof e)return e(this);var t,n,a=e.replace(/ /g,"").split(","),r=a.length;for(t=0;t<r;t++)if(n=a[t],ose.isValidSelector(n)||(ose.warn('Selector "'+n+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),ose.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),ose.warn("Konva is awesome, right?")),"#"===n.charAt(0)){if(this.id()===n.slice(1))return!0}else if("."===n.charAt(0)){if(this.hasName(n.slice(1)))return!0}else if(this.className===n||this.nodeType===n)return!0;return!1}getLayer(){var e=this.getParent();return e?e.getLayer():null}getStage(){return this._getCache(_se,this._getStage)}_getStage(){var e=this.getParent();return e?e.getStage():void 0}fire(e,t={},n){return t.target=t.target||this,n?this._fireAndBubble(e,t):this._fire(e,t),this}getAbsoluteTransform(e){return e?this._getAbsoluteTransform(e):this._getCache(Sse,this._getAbsoluteTransform)}_getAbsoluteTransform(e){var t;if(e)return t=new Qie,this._eachAncestorReverse((function(e){var n=e.transformsEnabled();"all"===n?t.multiply(e.getTransform()):"position"===n&&t.translate(e.x()-e.offsetX(),e.y()-e.offsetY())}),e),t;t=this._cache.get(Sse)||new Qie,this.parent?this.parent.getAbsoluteTransform().copyInto(t):t.reset();var n=this.transformsEnabled();if("all"===n)t.multiply(this.getTransform());else if("position"===n){const e=this.attrs.x||0,n=this.attrs.y||0,a=this.attrs.offsetX||0,r=this.attrs.offsetY||0;t.translate(e-a,n-r)}return t.dirty=!1,t}getAbsoluteScale(e){for(var t=this;t;)t._isUnderCache&&(e=t),t=t.getParent();const n=this.getAbsoluteTransform(e).decompose();return{x:n.scaleX,y:n.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(Dse,this._getTransform)}_getTransform(){var e,t,n=this._cache.get(Dse)||new Qie;n.reset();var a=this.x(),r=this.y(),o=Kie.getAngle(this.rotation()),c=null!==(e=this.attrs.scaleX)&&void 0!==e?e:1,l=null!==(t=this.attrs.scaleY)&&void 0!==t?t:1,i=this.attrs.skewX||0,s=this.attrs.skewY||0,h=this.attrs.offsetX||0,d=this.attrs.offsetY||0;return 0===a&&0===r||n.translate(a,r),0!==o&&n.rotate(o),0===i&&0===s||n.skew(i,s),1===c&&1===l||n.scale(c,l),0===h&&0===d||n.translate(-1*h,-1*d),n.dirty=!1,n}clone(e){var t,n,a,r,o,c=ose.cloneObject(this.attrs);for(t in e)c[t]=e[t];var l=new this.constructor(c);for(t in this.eventListeners)for(a=(n=this.eventListeners[t]).length,r=0;r<a;r++)(o=n[r]).name.indexOf("konva")<0&&(l.eventListeners[t]||(l.eventListeners[t]=[]),l.eventListeners[t].push(o));return l}_toKonvaCanvas(e){e=e||{};var t=this.getClientRect(),n=this.getStage(),a=void 0!==e.x?e.x:Math.floor(t.x),r=void 0!==e.y?e.y:Math.floor(t.y),o=e.pixelRatio||1,c=new Hse({width:e.width||Math.ceil(t.width)||(n?n.width():0),height:e.height||Math.ceil(t.height)||(n?n.height():0),pixelRatio:o}),l=c.getContext();return!1===e.imageSmoothingEnabled&&(l._context.imageSmoothingEnabled=!1),l.save(),(a||r)&&l.translate(-1*a,-1*r),this.drawScene(c),l.restore(),c}toCanvas(e){return this._toKonvaCanvas(e)._canvas}toDataURL(e){var t=(e=e||{}).mimeType||null,n=e.quality||null,a=this._toKonvaCanvas(e).toDataURL(t,n);return e.callback&&e.callback(a),a}toImage(e){return new Promise(((t,n)=>{try{const n=null==e?void 0:e.callback;n&&delete e.callback,ose._urlToImage(this.toDataURL(e),(function(e){t(e),null==n||n(e)}))}catch(e){n(e)}}))}toBlob(e){return new Promise(((t,n)=>{try{const n=null==e?void 0:e.callback;n&&delete e.callback,this.toCanvas(e).toBlob((e=>{t(e),null==n||n(e)}))}catch(e){n(e)}}))}setSize(e){return this.width(e.width),this.height(e.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():Kie.dragDistance}_off(e,t,n){var a,r,o,c=this.eventListeners[e];for(a=0;a<c.length;a++)if(r=c[a].name,o=c[a].handler,!("konva"===r&&"konva"!==t||t&&r!==t||n&&n!==o)){if(c.splice(a,1),0===c.length){delete this.eventListeners[e];break}a--}}_fireChangeEvent(e,t,n){this._fire(e+"Change",{oldVal:t,newVal:n})}addName(e){if(!this.hasName(e)){var t=this.name(),n=t?t+" "+e:e;this.name(n)}return this}hasName(e){if(!e)return!1;const t=this.name();return!!t&&-1!==(t||"").split(/\s/g).indexOf(e)}removeName(e){var t=(this.name()||"").split(/\s/g),n=t.indexOf(e);return-1!==n&&(t.splice(n,1),this.name(t.join(" "))),this}setAttr(e,t){var n=this["set"+ose._capitalize(e)];return ose._isFunction(n)?n.call(this,t):this._setAttr(e,t),this}_requestDraw(){if(Kie.autoDrawEnabled){const e=this.getLayer()||this.getStage();null==e||e.batchDraw()}}_setAttr(e,t){var n=this.attrs[e];(n!==t||ose.isObject(t))&&(null==t?delete this.attrs[e]:this.attrs[e]=t,this._shouldFireChangeEvents&&this._fireChangeEvent(e,n,t),this._requestDraw())}_setComponentAttr(e,t,n){var a;void 0!==n&&((a=this.attrs[e])||(this.attrs[e]=this.getAttr(e)),this.attrs[e][t]=n,this._fireChangeEvent(e,a,n))}_fireAndBubble(e,t,n){if(t&&this.nodeType===Rse&&(t.target=this),e!==Ose&&e!==Ase||!(n&&(this===n||this.isAncestorOf&&this.isAncestorOf(n))||"Stage"===this.nodeType&&!n)){this._fire(e,t);var a=(e===Ose||e===Ase)&&n&&n.isAncestorOf&&n.isAncestorOf(this)&&!n.isAncestorOf(this.parent);(t&&!t.cancelBubble||!t)&&this.parent&&this.parent.isListening()&&!a&&(n&&n.parent?this._fireAndBubble.call(this.parent,e,t,n):this._fireAndBubble.call(this.parent,e,t))}}_getProtoListeners(e){let t=this._cache.get(xse);if(!t){t={};let e=Object.getPrototypeOf(this);for(;e;)if(e.eventListeners){for(var n in e.eventListeners){const a=e.eventListeners[n],r=t[n]||[];t[n]=a.concat(r)}e=Object.getPrototypeOf(e)}else e=Object.getPrototypeOf(e);this._cache.set(xse,t)}return t[e]}_fire(e,t){(t=t||{}).currentTarget=this,t.type=e;const n=this._getProtoListeners(e);if(n)for(var a=0;a<n.length;a++)n[a].handler.call(this,t);const r=this.eventListeners[e];if(r)for(a=0;a<r.length;a++)r[a].handler.call(this,t)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(e){var t=e?e.pointerId:void 0,n=this.getStage(),a=this.getAbsolutePosition(),r=n._getPointerById(t)||n._changedPointerPositions[0]||a;Cse._dragElements.set(this._id,{node:this,startPointerPos:r,offset:{x:r.x-a.x,y:r.y-a.y},dragStatus:"ready",pointerId:t})}startDrag(e,t=!0){Cse._dragElements.has(this._id)||this._createDragElement(e),Cse._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:e&&e.evt},t)}_setDragPosition(e,t){const n=this.getStage()._getPointerById(t.pointerId);if(n){var a={x:n.x-t.offset.x,y:n.y-t.offset.y},r=this.dragBoundFunc();if(void 0!==r){const t=r.call(this,a,e);t?a=t:ose.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===a.x&&this._lastPos.y===a.y||(this.setAbsolutePosition(a),this._requestDraw()),this._lastPos=a}}stopDrag(e){const t=Cse._dragElements.get(this._id);t&&(t.dragStatus="stopped"),Cse._endDragBefore(e),Cse._endDragAfter(e)}setDraggable(e){this._setAttr("draggable",e),this._dragChange()}isDragging(){const e=Cse._dragElements.get(this._id);return!!e&&"dragging"===e.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",(function(e){if((void 0===e.evt.button||Kie.dragButtons.indexOf(e.evt.button)>=0)&&!this.isDragging()){var t=!1;Cse._dragElements.forEach((e=>{this.isAncestorOf(e.node)&&(t=!0)})),t||this._createDragElement(e)}}))}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;const e=Cse._dragElements.get(this._id),t=e&&"dragging"===e.dragStatus,n=e&&"ready"===e.dragStatus;t?this.stopDrag():n&&Cse._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(e={x:0,y:0}){const t=this.getStage();if(!t)return!1;const n={x:-e.x,y:-e.y,width:t.width()+2*e.x,height:t.height()+2*e.y};return ose.haveIntersection(n,this.getClientRect())}static create(e,t){return ose._isString(e)&&(e=JSON.parse(e)),this._createNode(e,t)}static _createNode(e,t){var n,a,r,o=jse.prototype.getClassName.call(e),c=e.children;if(t&&(e.attrs.container=t),Kie[o]||(ose.warn('Can not find a node with class name "'+o+'". Fallback to "Shape".'),o="Shape"),n=new Kie[o](e.attrs),c)for(a=c.length,r=0;r<a;r++)n.add(jse._createNode(c[r]));return n}}jse.prototype.nodeType="Node",jse.prototype._attrsAffectingSize=[],jse.prototype.eventListeners={},jse.prototype.on.call(jse.prototype,Fse,(function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(Dse),this._clearSelfAndDescendantCache(Sse))})),jse.prototype.on.call(jse.prototype,"visibleChange.konva",(function(){this._clearSelfAndDescendantCache(Pse)})),jse.prototype.on.call(jse.prototype,"listeningChange.konva",(function(){this._clearSelfAndDescendantCache(Tse)})),jse.prototype.on.call(jse.prototype,"opacityChange.konva",(function(){this._clearSelfAndDescendantCache(Lse)}));const Bse=fse.addGetterSetter;Bse(jse,"zIndex"),Bse(jse,"absolutePosition"),Bse(jse,"position"),Bse(jse,"x",0,ise()),Bse(jse,"y",0,ise()),Bse(jse,"globalCompositeOperation","source-over",dse()),Bse(jse,"opacity",1,ise()),Bse(jse,"name","",dse()),Bse(jse,"id","",dse()),Bse(jse,"rotation",0,ise()),fse.addComponentsGetterSetter(jse,"scale",["x","y"]),Bse(jse,"scaleX",1,ise()),Bse(jse,"scaleY",1,ise()),fse.addComponentsGetterSetter(jse,"skew",["x","y"]),Bse(jse,"skewX",0,ise()),Bse(jse,"skewY",0,ise()),fse.addComponentsGetterSetter(jse,"offset",["x","y"]),Bse(jse,"offsetX",0,ise()),Bse(jse,"offsetY",0,ise()),Bse(jse,"dragDistance",null,ise()),Bse(jse,"width",0,ise()),Bse(jse,"height",0,ise()),Bse(jse,"listening",!0,mse()),Bse(jse,"preventDefault",!0,mse()),Bse(jse,"filters",null,(function(e){return this._filterUpToDate=!1,e})),Bse(jse,"visible",!0,mse()),Bse(jse,"transformsEnabled","all",dse()),Bse(jse,"size"),Bse(jse,"dragBoundFunc"),Bse(jse,"draggable",!1,mse()),fse.backCompat(jse,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});class Use extends jse{constructor(){super(...arguments),this.children=[]}getChildren(e){if(!e)return this.children||[];const t=this.children||[];var n=[];return t.forEach((function(t){e(t)&&n.push(t)})),n}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach((e=>{e.parent=null,e.index=0,e.remove()})),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach((e=>{e.parent=null,e.index=0,e.destroy()})),this.children=[],this._requestDraw(),this}add(...e){if(0===e.length)return this;if(e.length>1){for(var t=0;t<e.length;t++)this.add(e[t]);return this}const n=e[0];return n.getParent()?(n.moveTo(this),this):(this._validateAdd(n),n.index=this.getChildren().length,n.parent=this,n._clearCaches(),this.getChildren().push(n),this._fire("add",{child:n}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(e){return this._generalFind(e,!1)}findOne(e){var t=this._generalFind(e,!0);return t.length>0?t[0]:void 0}_generalFind(e,t){var n=[];return this._descendants((a=>{const r=a._isMatch(e);return r&&n.push(a),!(!r||!t)})),n}_descendants(e){let t=!1;const n=this.getChildren();for(const a of n){if(t=e(a),t)return!0;if(a.hasChildren()&&(t=a._descendants(e),t))return!0}return!1}toObject(){var e=jse.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach((t=>{e.children.push(t.toObject())})),e}isAncestorOf(e){for(var t=e.getParent();t;){if(t._id===this._id)return!0;t=t.getParent()}return!1}clone(e){var t=jse.prototype.clone.call(this,e);return this.getChildren().forEach((function(e){t.add(e.clone())})),t}getAllIntersections(e){var t=[];return this.find("Shape").forEach((function(n){n.isVisible()&&n.intersects(e)&&t.push(n)})),t}_clearSelfAndDescendantCache(e){var t;super._clearSelfAndDescendantCache(e),this.isCached()||null===(t=this.children)||void 0===t||t.forEach((function(t){t._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;null===(e=this.children)||void 0===e||e.forEach((function(e,t){e.index=t})),this._requestDraw()}drawScene(e,t){var n=this.getLayer(),a=e||n&&n.getCanvas(),r=a&&a.getContext(),o=this._getCanvasCache(),c=o&&o.scene,l=a&&a.isCache;if(!this.isVisible()&&!l)return this;if(c){r.save();var i=this.getAbsoluteTransform(t).getMatrix();r.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this._drawCachedSceneCanvas(r),r.restore()}else this._drawChildren("drawScene",a,t);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;var n=this.getLayer(),a=e||n&&n.hitCanvas,r=a&&a.getContext(),o=this._getCanvasCache();if(o&&o.hit){r.save();var c=this.getAbsoluteTransform(t).getMatrix();r.transform(c[0],c[1],c[2],c[3],c[4],c[5]),this._drawCachedHitCanvas(r),r.restore()}else this._drawChildren("drawHit",a,t);return this}_drawChildren(e,t,n){var a,r=t&&t.getContext(),o=this.clipWidth(),c=this.clipHeight(),l=this.clipFunc(),i=o&&c||l;const s=n===this;if(i){r.save();var h=this.getAbsoluteTransform(n),d=h.getMatrix();if(r.transform(d[0],d[1],d[2],d[3],d[4],d[5]),r.beginPath(),l)l.call(this,r,this);else{var u=this.clipX(),m=this.clipY();r.rect(u,m,o,c)}r.clip(),d=h.copy().invert().getMatrix(),r.transform(d[0],d[1],d[2],d[3],d[4],d[5])}var p=!s&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===e;p&&(r.save(),r._applyGlobalCompositeOperation(this)),null===(a=this.children)||void 0===a||a.forEach((function(a){a[e](t,n)})),p&&r.restore(),i&&r.restore()}getClientRect(e){var t,n,a,r,o,c,l=(e=e||{}).skipTransform,i=e.relativeTo,s=this;null===(t=this.children)||void 0===t||t.forEach((function(t){if(t.visible()){var c=t.getClientRect({relativeTo:s,skipShadow:e.skipShadow,skipStroke:e.skipStroke});0===c.width&&0===c.height||(void 0===n?(n=c.x,a=c.y,r=c.x+c.width,o=c.y+c.height):(n=Math.min(n,c.x),a=Math.min(a,c.y),r=Math.max(r,c.x+c.width),o=Math.max(o,c.y+c.height)))}}));for(var h=this.find("Shape"),d=!1,u=0;u<h.length;u++)if(h[u]._isVisible(this)){d=!0;break}return c=d&&void 0!==n?{x:n,y:a,width:r-n,height:o-a}:{x:0,y:0,width:0,height:0},l?c:this._transformedRect(c,i)}}fse.addComponentsGetterSetter(Use,"clip",["x","y","width","height"]),fse.addGetterSetter(Use,"clipX",void 0,ise()),fse.addGetterSetter(Use,"clipY",void 0,ise()),fse.addGetterSetter(Use,"clipWidth",void 0,ise()),fse.addGetterSetter(Use,"clipHeight",void 0,ise()),fse.addGetterSetter(Use,"clipFunc");const Wse=new Map,$se=void 0!==Kie._global.PointerEvent;function qse(e){return Wse.get(e)}function Gse(e){return{evt:e,pointerId:e.pointerId}}function Yse(e,t){return Wse.get(e)===t}function Kse(e,t){Xse(e),t.getStage()&&(Wse.set(e,t),$se&&t._fire("gotpointercapture",Gse(new PointerEvent("gotpointercapture"))))}function Xse(e,t){const n=Wse.get(e);if(!n)return;const a=n.getStage();a&&a.content,Wse.delete(e),$se&&n._fire("lostpointercapture",Gse(new PointerEvent("lostpointercapture")))}var Qse="mouseleave",Jse="mouseover",Zse="mouseenter",ehe="mousemove",the="mousedown",nhe="mouseup",ahe="pointermove",rhe="pointerdown",ohe="pointerup",che="pointercancel",lhe="pointerout",ihe="pointerleave",she="pointerover",hhe="pointerenter",dhe="contextmenu",uhe="touchstart",mhe="touchend",phe="touchmove",vhe="touchcancel",fhe="wheel",zhe=[[Zse,"_pointerenter"],[the,"_pointerdown"],[ehe,"_pointermove"],[nhe,"_pointerup"],[Qse,"_pointerleave"],[uhe,"_pointerdown"],[phe,"_pointermove"],[mhe,"_pointerup"],[vhe,"_pointercancel"],[Jse,"_pointerover"],[fhe,"_wheel"],[dhe,"_contextmenu"],[rhe,"_pointerdown"],[ahe,"_pointermove"],[ohe,"_pointerup"],[che,"_pointercancel"],["lostpointercapture","_lostpointercapture"]];const ghe={mouse:{[lhe]:"mouseout",[ihe]:Qse,[she]:Jse,[hhe]:Zse,[ahe]:ehe,[rhe]:the,[ohe]:nhe,[che]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[lhe]:"touchout",[ihe]:"touchleave",[she]:"touchover",[hhe]:"touchenter",[ahe]:phe,[rhe]:uhe,[ohe]:mhe,[che]:vhe,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[lhe]:lhe,[ihe]:ihe,[she]:she,[hhe]:hhe,[ahe]:ahe,[rhe]:rhe,[ohe]:ohe,[che]:che,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},yhe=e=>e.indexOf("pointer")>=0?"pointer":e.indexOf("touch")>=0?"touch":"mouse",Mhe=e=>{const t=yhe(e);return"pointer"===t?Kie.pointerEventsEnabled&&ghe.pointer:"touch"===t?ghe.touch:"mouse"===t?ghe.mouse:void 0};function Ehe(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&&ose.warn("Stage does not support clipping. Please use clip for Layers or Groups."),e}const bhe=[];class Hhe extends Use{constructor(e){super(Ehe(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),bhe.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",(()=>{Ehe(this.attrs)})),this._checkVisibility()}_validateAdd(e){const t="Layer"===e.getType(),n="FastLayer"===e.getType();t||n||ose.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const e=this.visible()?"":"none";this.content.style.display=e}setContainer(e){if("string"==typeof e){if("."===e.charAt(0)){var t=e.slice(1);e=document.getElementsByClassName(t)[0]}else{var n;n="#"!==e.charAt(0)?e:e.slice(1),e=document.getElementById(n)}if(!e)throw"Can not find container in document with id "+n}return this._setAttr("container",e),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),e.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){var e,t=this.children,n=t.length;for(e=0;e<n;e++)t[e].clear();return this}clone(e){return e||(e={}),e.container="undefined"!=typeof document&&document.createElement("div"),Use.prototype.clone.call(this,e)}destroy(){super.destroy();var e=this.content;e&&ose._isInDocument(e)&&this.container().removeChild(e);var t=bhe.indexOf(this);return t>-1&&bhe.splice(t,1),ose.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(ose.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}_getPointerById(e){return this._pointerPositions.find((t=>t.id===e))}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(e){(e=e||{}).x=e.x||0,e.y=e.y||0,e.width=e.width||this.width(),e.height=e.height||this.height();var t=new Hse({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),n=t.getContext()._context,a=this.children;return(e.x||e.y)&&n.translate(-1*e.x,-1*e.y),a.forEach((function(t){if(t.isVisible()){var a=t._toKonvaCanvas(e);n.drawImage(a._canvas,e.x,e.y,a.getWidth()/a.getPixelRatio(),a.getHeight()/a.getPixelRatio())}})),t}getIntersection(e){if(!e)return null;var t,n=this.children;for(t=n.length-1;t>=0;t--){const a=n[t].getIntersection(e);if(a)return a}return null}_resizeDOM(){var e=this.width(),t=this.height();this.content&&(this.content.style.width=e+"px",this.content.style.height=t+"px"),this.bufferCanvas.setSize(e,t),this.bufferHitCanvas.setSize(e,t),this.children.forEach((n=>{n.setSize({width:e,height:t}),n.draw()}))}add(e,...t){if(arguments.length>1){for(var n=0;n<arguments.length;n++)this.add(arguments[n]);return this}super.add(e);var a=this.children.length;return a>5&&ose.warn("The stage has "+a+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),e.setSize({width:this.width(),height:this.height()}),e.draw(),Kie.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return Yse(e,this)}setPointerCapture(e){Kse(e,this)}releaseCapture(e){Xse(e)}getLayers(){return this.children}_bindContentEvents(){Kie.isBrowser&&zhe.forEach((([e,t])=>{this.content.addEventListener(e,(e=>{this[t](e)}),{passive:!1})}))}_pointerenter(e){this.setPointersPositions(e);const t=Mhe(e.type);this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);const t=Mhe(e.type);this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_getTargetShape(e){let t=this[e+"targetShape"];return t&&!t.getStage()&&(t=null),t}_pointerleave(e){const t=Mhe(e.type),n=yhe(e.type);if(t){this.setPointersPositions(e);var a=this._getTargetShape(n),r=!Cse.isDragging||Kie.hitOnDragEnabled;a&&r?(a._fireAndBubble(t.pointerout,{evt:e}),a._fireAndBubble(t.pointerleave,{evt:e}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this[n+"targetShape"]=null):r&&(this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(t.pointerout,{evt:e,target:this,currentTarget:this})),this.pointerPos=void 0,this._pointerPositions=[]}}_pointerdown(e){const t=Mhe(e.type),n=yhe(e.type);if(t){this.setPointersPositions(e);var a=!1;this._changedPointerPositions.forEach((r=>{var o=this.getIntersection(r);if(Cse.justDragged=!1,Kie["_"+n+"ListenClick"]=!0,!o||!o.isListening())return;Kie.capturePointerEventsEnabled&&o.setPointerCapture(r.id),this[n+"ClickStartShape"]=o,o._fireAndBubble(t.pointerdown,{evt:e,pointerId:r.id}),a=!0;const c=e.type.indexOf("touch")>=0;o.preventDefault()&&e.cancelable&&c&&e.preventDefault()})),a||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}_pointermove(e){const t=Mhe(e.type),n=yhe(e.type);if(!t)return;if(Cse.isDragging&&Cse.node.preventDefault()&&e.cancelable&&e.preventDefault(),this.setPointersPositions(e),Cse.isDragging&&!Kie.hitOnDragEnabled)return;var a={};let r=!1;var o=this._getTargetShape(n);this._changedPointerPositions.forEach((c=>{const l=qse(c.id)||this.getIntersection(c),i=c.id,s={evt:e,pointerId:i};var h=o!==l;if(h&&o&&(o._fireAndBubble(t.pointerout,Object.assign({},s),l),o._fireAndBubble(t.pointerleave,Object.assign({},s),l)),l){if(a[l._id])return;a[l._id]=!0}l&&l.isListening()?(r=!0,h&&(l._fireAndBubble(t.pointerover,Object.assign({},s),o),l._fireAndBubble(t.pointerenter,Object.assign({},s),o),this[n+"targetShape"]=l),l._fireAndBubble(t.pointermove,Object.assign({},s))):o&&(this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:i}),this[n+"targetShape"]=null)})),r||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){const t=Mhe(e.type),n=yhe(e.type);if(!t)return;this.setPointersPositions(e);const a=this[n+"ClickStartShape"],r=this[n+"ClickEndShape"];var o={};let c=!1;this._changedPointerPositions.forEach((l=>{const i=qse(l.id)||this.getIntersection(l);if(i){if(i.releaseCapture(l.id),o[i._id])return;o[i._id]=!0}const s=l.id,h={evt:e,pointerId:s};let d=!1;Kie["_"+n+"InDblClickWindow"]?(d=!0,clearTimeout(this[n+"DblTimeout"])):Cse.justDragged||(Kie["_"+n+"InDblClickWindow"]=!0,clearTimeout(this[n+"DblTimeout"])),this[n+"DblTimeout"]=setTimeout((function(){Kie["_"+n+"InDblClickWindow"]=!1}),Kie.dblClickWindow),i&&i.isListening()?(c=!0,this[n+"ClickEndShape"]=i,i._fireAndBubble(t.pointerup,Object.assign({},h)),Kie["_"+n+"ListenClick"]&&a&&a===i&&(i._fireAndBubble(t.pointerclick,Object.assign({},h)),d&&r&&r===i&&i._fireAndBubble(t.pointerdblclick,Object.assign({},h)))):(this[n+"ClickEndShape"]=null,Kie["_"+n+"ListenClick"]&&this._fire(t.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:s}),d&&this._fire(t.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:s}))})),c||this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),Kie["_"+n+"ListenClick"]=!1,e.cancelable&&"touch"!==n&&e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);var t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(dhe,{evt:e}):this._fire(dhe,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);var t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(fhe,{evt:e}):this._fire(fhe,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);const t=qse(e.pointerId)||this.getIntersection(this.getPointerPosition());t&&t._fireAndBubble(ohe,Gse(e)),Xse(e.pointerId)}_lostpointercapture(e){Xse(e.pointerId)}setPointersPositions(e){var t=this._getContentPosition(),n=null,a=null;void 0!==(e=e||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(e.touches,(e=>{this._pointerPositions.push({id:e.identifier,x:(e.clientX-t.left)/t.scaleX,y:(e.clientY-t.top)/t.scaleY})})),Array.prototype.forEach.call(e.changedTouches||e.touches,(e=>{this._changedPointerPositions.push({id:e.identifier,x:(e.clientX-t.left)/t.scaleX,y:(e.clientY-t.top)/t.scaleY})}))):(n=(e.clientX-t.left)/t.scaleX,a=(e.clientY-t.top)/t.scaleY,this.pointerPos={x:n,y:a},this._pointerPositions=[{x:n,y:a,id:ose._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:a,id:ose._getFirstPointerId(e)}])}_setPointerPosition(e){ose.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(e)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};var e=this.content.getBoundingClientRect();return{top:e.top,left:e.left,scaleX:e.width/this.content.clientWidth||1,scaleY:e.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new Hse({width:this.width(),height:this.height()}),this.bufferHitCanvas=new Vse({pixelRatio:1,width:this.width(),height:this.height()}),Kie.isBrowser){var e=this.container();if(!e)throw"Stage has no container. A container is required.";e.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),e.appendChild(this.content),this._resizeDOM()}}cache(){return ose.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach((function(e){e.batchDraw()})),this}}Hhe.prototype.nodeType="Stage",Xie(Hhe),fse.addGetterSetter(Hhe,"container");var Vhe="hasShadow",Che="shadowRGBA",Lhe="patternImage",xhe="linearGradient",She="radialGradient";let khe;function whe(){return khe||(khe=ose.createCanvasElement().getContext("2d"),khe)}const The={};class Ohe extends jse{constructor(e){let t;for(super(e);t=ose.getRandomColor(),!t||t in The;);this.colorKey=t,The[t]=this}getContext(){return ose.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return ose.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(Vhe,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(Lhe,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const e=whe().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(e&&e.setTransform){const t=new Qie;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(Kie.getAngle(this.fillPatternRotation())),t.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),t.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const n=t.getMatrix(),a="undefined"==typeof DOMMatrix?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);e.setTransform(a)}return e}}_getLinearGradient(){return this._getCache(xhe,this.__getLinearGradient)}__getLinearGradient(){var e=this.fillLinearGradientColorStops();if(e){for(var t=whe(),n=this.fillLinearGradientStartPoint(),a=this.fillLinearGradientEndPoint(),r=t.createLinearGradient(n.x,n.y,a.x,a.y),o=0;o<e.length;o+=2)r.addColorStop(e[o],e[o+1]);return r}}_getRadialGradient(){return this._getCache(She,this.__getRadialGradient)}__getRadialGradient(){var e=this.fillRadialGradientColorStops();if(e){for(var t=whe(),n=this.fillRadialGradientStartPoint(),a=this.fillRadialGradientEndPoint(),r=t.createRadialGradient(n.x,n.y,this.fillRadialGradientStartRadius(),a.x,a.y,this.fillRadialGradientEndRadius()),o=0;o<e.length;o+=2)r.addColorStop(e[o],e[o+1]);return r}}getShadowRGBA(){return this._getCache(Che,this._getShadowRGBA)}_getShadowRGBA(){if(this.hasShadow()){var e=ose.colorToRGBA(this.shadowColor());return e?"rgba("+e.r+","+e.g+","+e.b+","+e.a*(this.shadowOpacity()||1)+")":void 0}}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],(()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops())))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],(()=>this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops())))}hasHitStroke(){const e=this.hitStrokeWidth();return"auto"===e?this.hasStroke():this.strokeEnabled()&&!!e}intersects(e){var t=this.getStage().bufferHitCanvas;return t.getContext().clear(),this.drawHit(t,null,!0),t.context.getImageData(Math.round(e.x),Math.round(e.y),1,1).data[3]>0}destroy(){return jse.prototype.destroy.call(this),delete The[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e){var t;if(!this.getStage())return!1;if(null!==(t=this.attrs.perfectDrawEnabled)&&void 0!==t&&!t)return!1;const n=e||this.hasFill(),a=this.hasStroke(),r=1!==this.getAbsoluteOpacity();if(n&&a&&r)return!0;const o=this.hasShadow(),c=this.shadowForStrokeEnabled();return!!(n&&a&&o&&c)}setStrokeHitEnabled(e){ose.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),e?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){var e=this.size();return{x:this._centroid?-e.width/2:0,y:this._centroid?-e.height/2:0,width:e.width,height:e.height}}getClientRect(e={}){const t=e.skipTransform,n=e.relativeTo,a=this.getSelfRect(),r=!e.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=a.width+r,c=a.height+r,l=!e.skipShadow&&this.hasShadow(),i=l?this.shadowOffsetX():0,s=l?this.shadowOffsetY():0,h=o+Math.abs(i),d=c+Math.abs(s),u=l&&this.shadowBlur()||0,m={width:h+2*u,height:d+2*u,x:-(r/2+u)+Math.min(i,0)+a.x,y:-(r/2+u)+Math.min(s,0)+a.y};return t?m:this._transformedRect(m,n)}drawScene(e,t){var n,a,r=this.getLayer(),o=e||r.getCanvas(),c=o.getContext(),l=this._getCanvasCache(),i=this.getSceneFunc(),s=this.hasShadow(),h=o.isCache,d=t===this;if(!this.isVisible()&&!d)return this;if(l){c.save();var u=this.getAbsoluteTransform(t).getMatrix();return c.transform(u[0],u[1],u[2],u[3],u[4],u[5]),this._drawCachedSceneCanvas(c),c.restore(),this}if(!i)return this;if(c.save(),this._useBufferCanvas()&&!h){(a=(n=this.getStage().bufferCanvas).getContext()).clear(),a.save(),a._applyLineJoin(this);var m=this.getAbsoluteTransform(t).getMatrix();a.transform(m[0],m[1],m[2],m[3],m[4],m[5]),i.call(this,a,this),a.restore();var p=n.pixelRatio;s&&c._applyShadow(this),c._applyOpacity(this),c._applyGlobalCompositeOperation(this),c.drawImage(n._canvas,0,0,n.width/p,n.height/p)}else c._applyLineJoin(this),d||(m=this.getAbsoluteTransform(t).getMatrix(),c.transform(m[0],m[1],m[2],m[3],m[4],m[5]),c._applyOpacity(this),c._applyGlobalCompositeOperation(this)),s&&c._applyShadow(this),i.call(this,c,this);return c.restore(),this}drawHit(e,t,n=!1){if(!this.shouldDrawHit(t,n))return this;var a=this.getLayer(),r=e||a.hitCanvas,o=r&&r.getContext(),c=this.hitFunc()||this.sceneFunc(),l=this._getCanvasCache(),i=l&&l.hit;if(this.colorKey||ose.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),i){o.save();var s=this.getAbsoluteTransform(t).getMatrix();return o.transform(s[0],s[1],s[2],s[3],s[4],s[5]),this._drawCachedHitCanvas(o),o.restore(),this}if(!c)return this;if(o.save(),o._applyLineJoin(this),this!==t){var h=this.getAbsoluteTransform(t).getMatrix();o.transform(h[0],h[1],h[2],h[3],h[4],h[5])}return c.call(this,o,this),o.restore(),this}drawHitFromCache(e=0){var t,n,a,r,o,c=this._getCanvasCache(),l=this._getCachedSceneCanvas(),i=c.hit,s=i.getContext(),h=i.getWidth(),d=i.getHeight();s.clear(),s.drawImage(l._canvas,0,0,h,d);try{for(a=(n=(t=s.getImageData(0,0,h,d)).data).length,r=ose._hexToRgb(this.colorKey),o=0;o<a;o+=4)n[o+3]>e?(n[o]=r.r,n[o+1]=r.g,n[o+2]=r.b,n[o+3]=255):n[o+3]=0;s.putImageData(t,0,0)}catch(e){ose.error("Unable to draw hit graph from cached scene canvas. "+e.message)}return this}hasPointerCapture(e){return Yse(e,this)}setPointerCapture(e){Kse(e,this)}releaseCapture(e){Xse(e)}}Ohe.prototype._fillFunc=function(e){e.fill()},Ohe.prototype._strokeFunc=function(e){e.stroke()},Ohe.prototype._fillFuncHit=function(e){e.fill()},Ohe.prototype._strokeFuncHit=function(e){e.stroke()},Ohe.prototype._centroid=!1,Ohe.prototype.nodeType="Shape",Xie(Ohe),Ohe.prototype.eventListeners={},Ohe.prototype.on.call(Ohe.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(Vhe)})),Ohe.prototype.on.call(Ohe.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(Che)})),Ohe.prototype.on.call(Ohe.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",(function(){this._clearCache(Lhe)})),Ohe.prototype.on.call(Ohe.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",(function(){this._clearCache(xhe)})),Ohe.prototype.on.call(Ohe.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",(function(){this._clearCache(She)})),fse.addGetterSetter(Ohe,"stroke",void 0,use()),fse.addGetterSetter(Ohe,"strokeWidth",2,ise()),fse.addGetterSetter(Ohe,"fillAfterStrokeEnabled",!1),fse.addGetterSetter(Ohe,"hitStrokeWidth","auto",hse()),fse.addGetterSetter(Ohe,"strokeHitEnabled",!0,mse()),fse.addGetterSetter(Ohe,"perfectDrawEnabled",!0,mse()),fse.addGetterSetter(Ohe,"shadowForStrokeEnabled",!0,mse()),fse.addGetterSetter(Ohe,"lineJoin"),fse.addGetterSetter(Ohe,"lineCap"),fse.addGetterSetter(Ohe,"sceneFunc"),fse.addGetterSetter(Ohe,"hitFunc"),fse.addGetterSetter(Ohe,"dash"),fse.addGetterSetter(Ohe,"dashOffset",0,ise()),fse.addGetterSetter(Ohe,"shadowColor",void 0,dse()),fse.addGetterSetter(Ohe,"shadowBlur",0,ise()),fse.addGetterSetter(Ohe,"shadowOpacity",1,ise()),fse.addComponentsGetterSetter(Ohe,"shadowOffset",["x","y"]),fse.addGetterSetter(Ohe,"shadowOffsetX",0,ise()),fse.addGetterSetter(Ohe,"shadowOffsetY",0,ise()),fse.addGetterSetter(Ohe,"fillPatternImage"),fse.addGetterSetter(Ohe,"fill",void 0,use()),fse.addGetterSetter(Ohe,"fillPatternX",0,ise()),fse.addGetterSetter(Ohe,"fillPatternY",0,ise()),fse.addGetterSetter(Ohe,"fillLinearGradientColorStops"),fse.addGetterSetter(Ohe,"strokeLinearGradientColorStops"),fse.addGetterSetter(Ohe,"fillRadialGradientStartRadius",0),fse.addGetterSetter(Ohe,"fillRadialGradientEndRadius",0),fse.addGetterSetter(Ohe,"fillRadialGradientColorStops"),fse.addGetterSetter(Ohe,"fillPatternRepeat","repeat"),fse.addGetterSetter(Ohe,"fillEnabled",!0),fse.addGetterSetter(Ohe,"strokeEnabled",!0),fse.addGetterSetter(Ohe,"shadowEnabled",!0),fse.addGetterSetter(Ohe,"dashEnabled",!0),fse.addGetterSetter(Ohe,"strokeScaleEnabled",!0),fse.addGetterSetter(Ohe,"fillPriority","color"),fse.addComponentsGetterSetter(Ohe,"fillPatternOffset",["x","y"]),fse.addGetterSetter(Ohe,"fillPatternOffsetX",0,ise()),fse.addGetterSetter(Ohe,"fillPatternOffsetY",0,ise()),fse.addComponentsGetterSetter(Ohe,"fillPatternScale",["x","y"]),fse.addGetterSetter(Ohe,"fillPatternScaleX",1,ise()),fse.addGetterSetter(Ohe,"fillPatternScaleY",1,ise()),fse.addComponentsGetterSetter(Ohe,"fillLinearGradientStartPoint",["x","y"]),fse.addComponentsGetterSetter(Ohe,"strokeLinearGradientStartPoint",["x","y"]),fse.addGetterSetter(Ohe,"fillLinearGradientStartPointX",0),fse.addGetterSetter(Ohe,"strokeLinearGradientStartPointX",0),fse.addGetterSetter(Ohe,"fillLinearGradientStartPointY",0),fse.addGetterSetter(Ohe,"strokeLinearGradientStartPointY",0),fse.addComponentsGetterSetter(Ohe,"fillLinearGradientEndPoint",["x","y"]),fse.addComponentsGetterSetter(Ohe,"strokeLinearGradientEndPoint",["x","y"]),fse.addGetterSetter(Ohe,"fillLinearGradientEndPointX",0),fse.addGetterSetter(Ohe,"strokeLinearGradientEndPointX",0),fse.addGetterSetter(Ohe,"fillLinearGradientEndPointY",0),fse.addGetterSetter(Ohe,"strokeLinearGradientEndPointY",0),fse.addComponentsGetterSetter(Ohe,"fillRadialGradientStartPoint",["x","y"]),fse.addGetterSetter(Ohe,"fillRadialGradientStartPointX",0),fse.addGetterSetter(Ohe,"fillRadialGradientStartPointY",0),fse.addComponentsGetterSetter(Ohe,"fillRadialGradientEndPoint",["x","y"]),fse.addGetterSetter(Ohe,"fillRadialGradientEndPointX",0),fse.addGetterSetter(Ohe,"fillRadialGradientEndPointY",0),fse.addGetterSetter(Ohe,"fillPatternRotation",0),fse.backCompat(Ohe,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});var Ahe=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],Rhe=Ahe.length;class Nhe extends Use{constructor(e){super(e),this.canvas=new Hse,this.hitCanvas=new Vse({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);var t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),e<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[e+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){jse.prototype.moveToTop.call(this);var e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!jse.prototype.moveUp.call(this))return!1;var e=this.getStage();return!(!e||!e.content||(e.content.removeChild(this.getNativeCanvasElement()),this.index<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[this.index+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement()),0))}moveDown(){if(jse.prototype.moveDown.call(this)){var e=this.getStage();if(e){var t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(jse.prototype.moveToBottom.call(this)){var e=this.getStage();if(e){var t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){var e=this.getNativeCanvasElement();return jse.prototype.remove.call(this),e&&e.parentNode&&ose._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:e,height:t}){return this.canvas.setSize(e,t),this.hitCanvas.setSize(e,t),this._setSmoothEnabled(),this}_validateAdd(e){var t=e.getType();"Group"!==t&&"Shape"!==t&&ose.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(e){return(e=e||{}).width=e.width||this.getWidth(),e.height=e.height||this.getHeight(),e.x=void 0!==e.x?e.x:this.x(),e.y=void 0!==e.y?e.y:this.y(),jse.prototype._toKonvaCanvas.call(this,e)}_checkVisibility(){const e=this.visible();this.canvas._canvas.style.display=e?"block":"none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){ose.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){ose.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,ose.requestAnimFrame((()=>{this.draw(),this._waitingForDraw=!1}))),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;for(var t=1,n=!1;;){for(let a=0;a<Rhe;a++){const r=Ahe[a],o=this._getIntersection({x:e.x+r.x*t,y:e.y+r.y*t}),c=o.shape;if(c)return c;if(n=!!o.antialiased,!o.antialiased)break}if(!n)return null;t+=1}}_getIntersection(e){const t=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.round(e.x*t),Math.round(e.y*t),1,1).data,a=n[3];if(255===a){const e=ose._rgbToHex(n[0],n[1],n[2]),t=The["#"+e];return t?{shape:t}:{antialiased:!0}}return a>0?{antialiased:!0}:{}}drawScene(e,t){var n=this.getLayer(),a=e||n&&n.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&a.getContext().clear(),Use.prototype.drawScene.call(this,a,t),this._fire("draw",{node:this}),this}drawHit(e,t){var n=this.getLayer(),a=e||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),Use.prototype.drawHit.call(this,a,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){ose.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return ose.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(this.parent&&this.parent.content){var e=this.parent;this.hitCanvas._canvas.parentNode?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}}destroy(){return ose.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}Nhe.prototype.nodeType="Layer",Xie(Nhe),fse.addGetterSetter(Nhe,"imageSmoothingEnabled",!0),fse.addGetterSetter(Nhe,"clearBeforeDraw",!0),fse.addGetterSetter(Nhe,"hitGraphEnabled",!0,mse());class _he extends Nhe{constructor(e){super(e),this.listening(!1),ose.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}_he.prototype.nodeType="FastLayer",Xie(_he);class Dhe extends Use{_validateAdd(e){var t=e.getType();"Group"!==t&&"Shape"!==t&&ose.throw("You may only add groups and shapes to groups.")}}Dhe.prototype.nodeType="Group",Xie(Dhe);var Phe=Yie.performance&&Yie.performance.now?function(){return Yie.performance.now()}:function(){return(new Date).getTime()};class Fhe{constructor(e,t){this.id=Fhe.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:Phe(),frameRate:0},this.func=e,this.setLayers(t)}setLayers(e){var t;return t=e?e.length>0?e:[e]:[],this.layers=t,this}getLayers(){return this.layers}addLayer(e){var t,n=this.layers,a=n.length;for(t=0;t<a;t++)if(n[t]._id===e._id)return!1;return this.layers.push(e),!0}isRunning(){var e,t=Fhe.animations,n=t.length;for(e=0;e<n;e++)if(t[e].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=Phe(),Fhe._addAnimation(this),this}stop(){return Fhe._removeAnimation(this),this}_updateFrameObject(e){this.frame.timeDiff=e-this.frame.lastTime,this.frame.lastTime=e,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(e){this.animations.push(e),this._handleAnimation()}static _removeAnimation(e){var t,n=e.id,a=this.animations,r=a.length;for(t=0;t<r;t++)if(a[t].id===n){this.animations.splice(t,1);break}}static _runFrames(){var e,t,n,a,r,o,c,l,i={},s=this.animations;for(a=0;a<s.length;a++)if(t=(e=s[a]).layers,n=e.func,e._updateFrameObject(Phe()),o=t.length,!n||!1!==n.call(e,e.frame))for(r=0;r<o;r++)void 0!==(c=t[r])._id&&(i[c._id]=c);for(l in i)i.hasOwnProperty(l)&&i[l].batchDraw()}static _animationLoop(){var e=Fhe;e.animations.length?(e._runFrames(),ose.requestAnimFrame(e._animationLoop)):e.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,ose.requestAnimFrame(this._animationLoop))}}Fhe.animations=[],Fhe.animIdCounter=0,Fhe.animRunning=!1;var Ihe={node:1,duration:1,easing:1,onFinish:1,yoyo:1},jhe=0,Bhe=["fill","stroke","shadowColor"];class Uhe{constructor(e,t,n,a,r,o,c){this.prop=e,this.propFunc=t,this.begin=a,this._pos=a,this.duration=o,this._change=0,this.prevPos=0,this.yoyo=c,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=r-this.begin,this.pause()}fire(e){var t=this[e];t&&t()}setTime(e){e>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():e<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=e,this.update())}getTime(){return this._time}setPosition(e){this.prevPos=this._pos,this.propFunc(e),this._pos=e}getPosition(e){return void 0===e&&(e=this._time),this.func(e,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(e){this.pause(),this._time=e,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){var e=this.getTimer()-this._startTime;2===this.state?this.setTime(e):3===this.state&&this.setTime(this.duration-e)}pause(){this.state=1,this.fire("onPause")}getTimer(){return(new Date).getTime()}}class Whe{constructor(e){var t,n,a=this,r=e.node,o=r._id,c=e.easing||$he.Linear,l=!!e.yoyo;t=void 0===e.duration?.3:0===e.duration?.001:e.duration,this.node=r,this._id=jhe++;var i=r.getLayer()||(r instanceof Kie.Stage?r.getLayers():null);for(n in i||ose.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new Fhe((function(){a.tween.onEnterFrame()}),i),this.tween=new Uhe(n,(function(e){a._tweenFunc(e)}),c,0,1,1e3*t,l),this._addListeners(),Whe.attrs[o]||(Whe.attrs[o]={}),Whe.attrs[o][this._id]||(Whe.attrs[o][this._id]={}),Whe.tweens[o]||(Whe.tweens[o]={}),e)void 0===Ihe[n]&&this._addAttr(n,e[n]);this.reset(),this.onFinish=e.onFinish,this.onReset=e.onReset,this.onUpdate=e.onUpdate}_addAttr(e,t){var n,a,r,o,c,l,i,s,h=this.node,d=h._id;if((r=Whe.tweens[d][e])&&delete Whe.attrs[d][r][e],n=h.getAttr(e),ose._isArray(t))if(a=[],c=Math.max(t.length,n.length),"points"===e&&t.length!==n.length&&(t.length>n.length?(i=n,n=ose._prepareArrayForTween(n,t,h.closed())):(l=t,t=ose._prepareArrayForTween(t,n,h.closed()))),0===e.indexOf("fill"))for(o=0;o<c;o++)if(o%2==0)a.push(t[o]-n[o]);else{var u=ose.colorToRGBA(n[o]);s=ose.colorToRGBA(t[o]),n[o]=u,a.push({r:s.r-u.r,g:s.g-u.g,b:s.b-u.b,a:s.a-u.a})}else for(o=0;o<c;o++)a.push(t[o]-n[o]);else-1!==Bhe.indexOf(e)?(n=ose.colorToRGBA(n),a={r:(s=ose.colorToRGBA(t)).r-n.r,g:s.g-n.g,b:s.b-n.b,a:s.a-n.a}):a=t-n;Whe.attrs[d][this._id][e]={start:n,diff:a,end:t,trueEnd:l,trueStart:i},Whe.tweens[d][e]=this._id}_tweenFunc(e){var t,n,a,r,o,c,l,i,s=this.node,h=Whe.attrs[s._id][this._id];for(t in h){if(a=(n=h[t]).start,r=n.diff,i=n.end,ose._isArray(a))if(o=[],l=Math.max(a.length,i.length),0===t.indexOf("fill"))for(c=0;c<l;c++)c%2==0?o.push((a[c]||0)+r[c]*e):o.push("rgba("+Math.round(a[c].r+r[c].r*e)+","+Math.round(a[c].g+r[c].g*e)+","+Math.round(a[c].b+r[c].b*e)+","+(a[c].a+r[c].a*e)+")");else for(c=0;c<l;c++)o.push((a[c]||0)+r[c]*e);else o=-1!==Bhe.indexOf(t)?"rgba("+Math.round(a.r+r.r*e)+","+Math.round(a.g+r.g*e)+","+Math.round(a.b+r.b*e)+","+(a.a+r.a*e)+")":a+r*e;s.setAttr(t,o)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{var e=this.node,t=Whe.attrs[e._id][this._id];t.points&&t.points.trueEnd&&e.setAttr("points",t.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{var e=this.node,t=Whe.attrs[e._id][this._id];t.points&&t.points.trueStart&&e.points(t.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(e){return this.tween.seek(1e3*e),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){var e,t=this.node._id,n=this._id,a=Whe.tweens[t];for(e in this.pause(),a)delete Whe.tweens[t][e];delete Whe.attrs[t][n]}}Whe.attrs={},Whe.tweens={},jse.prototype.to=function(e){var t=e.onFinish;e.node=this,e.onFinish=function(){this.destroy(),t&&t()},new Whe(e).play()};const $he={BackEaseIn(e,t,n,a){var r=1.70158;return n*(e/=a)*e*((r+1)*e-r)+t},BackEaseOut(e,t,n,a){var r=1.70158;return n*((e=e/a-1)*e*((r+1)*e+r)+1)+t},BackEaseInOut(e,t,n,a){var r=1.70158;return(e/=a/2)<1?n/2*(e*e*((1+(r*=1.525))*e-r))+t:n/2*((e-=2)*e*((1+(r*=1.525))*e+r)+2)+t},ElasticEaseIn(e,t,n,a,r,o){var c=0;return 0===e?t:1==(e/=a)?t+n:(o||(o=.3*a),!r||r<Math.abs(n)?(r=n,c=o/4):c=o/(2*Math.PI)*Math.asin(n/r),-r*Math.pow(2,10*(e-=1))*Math.sin((e*a-c)*(2*Math.PI)/o)+t)},ElasticEaseOut(e,t,n,a,r,o){var c=0;return 0===e?t:1==(e/=a)?t+n:(o||(o=.3*a),!r||r<Math.abs(n)?(r=n,c=o/4):c=o/(2*Math.PI)*Math.asin(n/r),r*Math.pow(2,-10*e)*Math.sin((e*a-c)*(2*Math.PI)/o)+n+t)},ElasticEaseInOut(e,t,n,a,r,o){var c=0;return 0===e?t:2==(e/=a/2)?t+n:(o||(o=a*(.3*1.5)),!r||r<Math.abs(n)?(r=n,c=o/4):c=o/(2*Math.PI)*Math.asin(n/r),e<1?r*Math.pow(2,10*(e-=1))*Math.sin((e*a-c)*(2*Math.PI)/o)*-.5+t:r*Math.pow(2,-10*(e-=1))*Math.sin((e*a-c)*(2*Math.PI)/o)*.5+n+t)},BounceEaseOut:(e,t,n,a)=>(e/=a)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t,BounceEaseIn:(e,t,n,a)=>n-$he.BounceEaseOut(a-e,0,n,a)+t,BounceEaseInOut:(e,t,n,a)=>e<a/2?.5*$he.BounceEaseIn(2*e,0,n,a)+t:.5*$he.BounceEaseOut(2*e-a,0,n,a)+.5*n+t,EaseIn:(e,t,n,a)=>n*(e/=a)*e+t,EaseOut:(e,t,n,a)=>-n*(e/=a)*(e-2)+t,EaseInOut:(e,t,n,a)=>(e/=a/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t,StrongEaseIn:(e,t,n,a)=>n*(e/=a)*e*e*e*e+t,StrongEaseOut:(e,t,n,a)=>n*((e=e/a-1)*e*e*e*e+1)+t,StrongEaseInOut:(e,t,n,a)=>(e/=a/2)<1?n/2*e*e*e*e*e+t:n/2*((e-=2)*e*e*e*e+2)+t,Linear:(e,t,n,a)=>n*e/a+t},qhe=ose._assign(Kie,{Util:ose,Transform:Qie,Node:jse,Container:Use,Stage:Hhe,stages:bhe,Layer:Nhe,FastLayer:_he,Group:Dhe,DD:Cse,Shape:Ohe,shapes:The,Animation:Fhe,Tween:Whe,Easings:$he,Context:yse,Canvas:bse});class Ghe extends Ohe{_sceneFunc(e){var t=Kie.getAngle(this.angle()),n=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,t,n),e.arc(0,0,this.innerRadius(),t,0,!n),e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){const e=this.innerRadius(),t=this.outerRadius(),n=this.clockwise(),a=Kie.getAngle(n?360-this.angle():this.angle()),r=Math.cos(Math.min(a,Math.PI)),o=Math.sin(Math.min(Math.max(Math.PI,a),3*Math.PI/2)),c=Math.sin(Math.min(a,Math.PI/2)),l=r*(r>0?e:t),i=o*(o>0?e:t),s=c*(c>0?t:e);return{x:l,y:n?-1*s:i,width:1*t-l,height:s-i}}}function Yhe(e,t,n,a,r,o,c){var l=Math.sqrt(Math.pow(n-e,2)+Math.pow(a-t,2)),i=Math.sqrt(Math.pow(r-n,2)+Math.pow(o-a,2)),s=c*l/(l+i),h=c*i/(l+i);return[n-s*(r-e),a-s*(o-t),n+h*(r-e),a+h*(o-t)]}function Khe(e,t){var n,a,r=e.length,o=[];for(n=2;n<r-2;n+=2)a=Yhe(e[n-2],e[n-1],e[n],e[n+1],e[n+2],e[n+3],t),isNaN(a[0])||(o.push(a[0]),o.push(a[1]),o.push(e[n]),o.push(e[n+1]),o.push(a[2]),o.push(a[3]));return o}Ghe.prototype._centroid=!0,Ghe.prototype.className="Arc",Ghe.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Xie(Ghe),fse.addGetterSetter(Ghe,"innerRadius",0,ise()),fse.addGetterSetter(Ghe,"outerRadius",0,ise()),fse.addGetterSetter(Ghe,"angle",0,ise()),fse.addGetterSetter(Ghe,"clockwise",!1,mse());class Xhe extends Ohe{constructor(e){super(e),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",(function(){this._clearCache("tensionPoints")}))}_sceneFunc(e){var t,n,a,r=this.points(),o=r.length,c=this.tension(),l=this.closed(),i=this.bezier();if(o){if(e.beginPath(),e.moveTo(r[0],r[1]),0!==c&&o>4){for(n=(t=this.getTensionPoints()).length,a=l?0:4,l||e.quadraticCurveTo(t[0],t[1],t[2],t[3]);a<n-2;)e.bezierCurveTo(t[a++],t[a++],t[a++],t[a++],t[a++],t[a++]);l||e.quadraticCurveTo(t[n-2],t[n-1],r[o-2],r[o-1])}else if(i)for(a=2;a<o;)e.bezierCurveTo(r[a++],r[a++],r[a++],r[a++],r[a++],r[a++]);else for(a=2;a<o;a+=2)e.lineTo(r[a],r[a+1]);l?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():Khe(this.points(),this.tension())}_getTensionPointsClosed(){var e=this.points(),t=e.length,n=this.tension(),a=Yhe(e[t-2],e[t-1],e[0],e[1],e[2],e[3],n),r=Yhe(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],n),o=Khe(e,n);return[a[2],a[3]].concat(o).concat([r[0],r[1],e[t-2],e[t-1],r[2],r[3],a[0],a[1],e[0],e[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){var e=this.points();if(e.length<4)return{x:e[0]||0,y:e[1]||0,width:0,height:0};for(var t,n,a=(e=0!==this.tension()?[e[0],e[1],...this._getTensionPoints(),e[e.length-2],e[e.length-1]]:this.points())[0],r=e[0],o=e[1],c=e[1],l=0;l<e.length/2;l++)t=e[2*l],n=e[2*l+1],a=Math.min(a,t),r=Math.max(r,t),o=Math.min(o,n),c=Math.max(c,n);return{x:a,y:o,width:r-a,height:c-o}}}Xhe.prototype.className="Line",Xhe.prototype._attrsAffectingSize=["points","bezier","tension"],Xie(Xhe),fse.addGetterSetter(Xhe,"closed",!1),fse.addGetterSetter(Xhe,"bezier",!1),fse.addGetterSetter(Xhe,"tension",0,ise()),fse.addGetterSetter(Xhe,"points",[],function(){if(Kie.isUnminified)return function(e,t){const n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&e instanceof n||(ose._isArray(e)?e.forEach((function(e){ose._isNumber(e)||ose.warn('"'+t+'" attribute has non numeric element '+e+". Make sure that all elements are numbers.")})):ose.warn(cse(e)+' is a not valid value for "'+t+'" attribute. The value should be a array of numbers.')),e}}());class Qhe extends Ohe{constructor(e){super(e),this.dataArray=[],this.pathLength=0,this.dataArray=Qhe.parsePathData(this.data()),this.pathLength=0;for(var t=0;t<this.dataArray.length;++t)this.pathLength+=this.dataArray[t].pathLength;this.on("dataChange.konva",(function(){this.dataArray=Qhe.parsePathData(this.data()),this.pathLength=0;for(var e=0;e<this.dataArray.length;++e)this.pathLength+=this.dataArray[e].pathLength}))}_sceneFunc(e){var t=this.dataArray;e.beginPath();for(var n=!1,a=0;a<t.length;a++){var r=t[a].command,o=t[a].points;switch(r){case"L":e.lineTo(o[0],o[1]);break;case"M":e.moveTo(o[0],o[1]);break;case"C":e.bezierCurveTo(o[0],o[1],o[2],o[3],o[4],o[5]);break;case"Q":e.quadraticCurveTo(o[0],o[1],o[2],o[3]);break;case"A":var c=o[0],l=o[1],i=o[2],s=o[3],h=o[4],d=o[5],u=o[6],m=o[7],p=i>s?i:s,v=i>s?1:i/s,f=i>s?s/i:1;e.translate(c,l),e.rotate(u),e.scale(v,f),e.arc(0,0,p,h,h+d,1-m),e.scale(1/v,1/f),e.rotate(-u),e.translate(-c,-l);break;case"z":n=!0,e.closePath()}}n||this.hasFill()?e.fillStrokeShape(this):e.strokeShape(this)}getSelfRect(){var e=[];this.dataArray.forEach((function(t){if("A"===t.command){var n=t.points[4],a=t.points[5],r=t.points[4]+a,o=Math.PI/180;if(Math.abs(n-r)<o&&(o=Math.abs(n-r)),a<0)for(let a=n-o;a>r;a-=o){const n=Qhe.getPointOnEllipticalArc(t.points[0],t.points[1],t.points[2],t.points[3],a,0);e.push(n.x,n.y)}else for(let a=n+o;a<r;a+=o){const n=Qhe.getPointOnEllipticalArc(t.points[0],t.points[1],t.points[2],t.points[3],a,0);e.push(n.x,n.y)}}else if("C"===t.command)for(let n=0;n<=1;n+=.01){const a=Qhe.getPointOnCubicBezier(n,t.start.x,t.start.y,t.points[0],t.points[1],t.points[2],t.points[3],t.points[4],t.points[5]);e.push(a.x,a.y)}else e=e.concat(t.points)}));for(var t,n,a=e[0],r=e[0],o=e[1],c=e[1],l=0;l<e.length/2;l++)t=e[2*l],n=e[2*l+1],isNaN(t)||(a=Math.min(a,t),r=Math.max(r,t)),isNaN(n)||(o=Math.min(o,n),c=Math.max(c,n));return{x:a,y:o,width:r-a,height:c-o}}getLength(){return this.pathLength}getPointAtLength(e){var t,n=0,a=this.dataArray.length;if(!a)return null;for(;n<a&&e>this.dataArray[n].pathLength;)e-=this.dataArray[n].pathLength,++n;if(n===a)return{x:(t=this.dataArray[n-1].points.slice(-2))[0],y:t[1]};if(e<.01)return{x:(t=this.dataArray[n].points.slice(0,2))[0],y:t[1]};var r=this.dataArray[n],o=r.points;switch(r.command){case"L":return Qhe.getPointOnLine(e,r.start.x,r.start.y,o[0],o[1]);case"C":return Qhe.getPointOnCubicBezier(e/r.pathLength,r.start.x,r.start.y,o[0],o[1],o[2],o[3],o[4],o[5]);case"Q":return Qhe.getPointOnQuadraticBezier(e/r.pathLength,r.start.x,r.start.y,o[0],o[1],o[2],o[3]);case"A":var c=o[0],l=o[1],i=o[2],s=o[3],h=o[4],d=o[5],u=o[6];return h+=d*e/r.pathLength,Qhe.getPointOnEllipticalArc(c,l,i,s,h,u)}return null}static getLineLength(e,t,n,a){return Math.sqrt((n-e)*(n-e)+(a-t)*(a-t))}static getPointOnLine(e,t,n,a,r,o,c){void 0===o&&(o=t),void 0===c&&(c=n);var l=(r-n)/(a-t+1e-8),i=Math.sqrt(e*e/(1+l*l));a<t&&(i*=-1);var s,h=l*i;if(a===t)s={x:o,y:c+h};else if((c-n)/(o-t+1e-8)===l)s={x:o+i,y:c+h};else{var d,u,m=this.getLineLength(t,n,a,r),p=(o-t)*(a-t)+(c-n)*(r-n);d=t+(p/=m*m)*(a-t),u=n+p*(r-n);var v=this.getLineLength(o,c,d,u),f=Math.sqrt(e*e-v*v);i=Math.sqrt(f*f/(1+l*l)),a<t&&(i*=-1),s={x:d+i,y:u+(h=l*i)}}return s}static getPointOnCubicBezier(e,t,n,a,r,o,c,l,i){function s(e){return e*e*e}function h(e){return 3*e*e*(1-e)}function d(e){return 3*e*(1-e)*(1-e)}function u(e){return(1-e)*(1-e)*(1-e)}return{x:l*s(e)+o*h(e)+a*d(e)+t*u(e),y:i*s(e)+c*h(e)+r*d(e)+n*u(e)}}static getPointOnQuadraticBezier(e,t,n,a,r,o,c){function l(e){return e*e}function i(e){return 2*e*(1-e)}function s(e){return(1-e)*(1-e)}return{x:o*l(e)+a*i(e)+t*s(e),y:c*l(e)+r*i(e)+n*s(e)}}static getPointOnEllipticalArc(e,t,n,a,r,o){var c=Math.cos(o),l=Math.sin(o),i=n*Math.cos(r),s=a*Math.sin(r);return{x:e+(i*c-s*l),y:t+(i*l+s*c)}}static parsePathData(e){if(!e)return[];var t=e,n=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];t=t.replace(new RegExp(" ","g"),",");for(var a=0;a<n.length;a++)t=t.replace(new RegExp(n[a],"g"),"|"+n[a]);var r,o=t.split("|"),c=[],l=[],i=0,s=0,h=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;for(a=1;a<o.length;a++){var d=o[a],u=d.charAt(0);for(d=d.slice(1),l.length=0;r=h.exec(d);)l.push(r[0]);for(var m=[],p=0,v=l.length;p<v;p++)if("00"!==l[p]){var f=parseFloat(l[p]);isNaN(f)?m.push(0):m.push(f)}else m.push(0,0);for(;m.length>0&&!isNaN(m[0]);){var z,g,y,M,E,b,H,V,C,L,x=null,S=[],k=i,w=s;switch(u){case"l":i+=m.shift(),s+=m.shift(),x="L",S.push(i,s);break;case"L":i=m.shift(),s=m.shift(),S.push(i,s);break;case"m":var T=m.shift(),O=m.shift();if(i+=T,s+=O,x="M",c.length>2&&"z"===c[c.length-1].command)for(var A=c.length-2;A>=0;A--)if("M"===c[A].command){i=c[A].points[0]+T,s=c[A].points[1]+O;break}S.push(i,s),u="l";break;case"M":i=m.shift(),s=m.shift(),x="M",S.push(i,s),u="L";break;case"h":i+=m.shift(),x="L",S.push(i,s);break;case"H":i=m.shift(),x="L",S.push(i,s);break;case"v":s+=m.shift(),x="L",S.push(i,s);break;case"V":s=m.shift(),x="L",S.push(i,s);break;case"C":S.push(m.shift(),m.shift(),m.shift(),m.shift()),i=m.shift(),s=m.shift(),S.push(i,s);break;case"c":S.push(i+m.shift(),s+m.shift(),i+m.shift(),s+m.shift()),i+=m.shift(),s+=m.shift(),x="C",S.push(i,s);break;case"S":g=i,y=s,"C"===(z=c[c.length-1]).command&&(g=i+(i-z.points[2]),y=s+(s-z.points[3])),S.push(g,y,m.shift(),m.shift()),i=m.shift(),s=m.shift(),x="C",S.push(i,s);break;case"s":g=i,y=s,"C"===(z=c[c.length-1]).command&&(g=i+(i-z.points[2]),y=s+(s-z.points[3])),S.push(g,y,i+m.shift(),s+m.shift()),i+=m.shift(),s+=m.shift(),x="C",S.push(i,s);break;case"Q":S.push(m.shift(),m.shift()),i=m.shift(),s=m.shift(),S.push(i,s);break;case"q":S.push(i+m.shift(),s+m.shift()),i+=m.shift(),s+=m.shift(),x="Q",S.push(i,s);break;case"T":g=i,y=s,"Q"===(z=c[c.length-1]).command&&(g=i+(i-z.points[0]),y=s+(s-z.points[1])),i=m.shift(),s=m.shift(),x="Q",S.push(g,y,i,s);break;case"t":g=i,y=s,"Q"===(z=c[c.length-1]).command&&(g=i+(i-z.points[0]),y=s+(s-z.points[1])),i+=m.shift(),s+=m.shift(),x="Q",S.push(g,y,i,s);break;case"A":M=m.shift(),E=m.shift(),b=m.shift(),H=m.shift(),V=m.shift(),C=i,L=s,i=m.shift(),s=m.shift(),x="A",S=this.convertEndpointToCenterParameterization(C,L,i,s,H,V,M,E,b);break;case"a":M=m.shift(),E=m.shift(),b=m.shift(),H=m.shift(),V=m.shift(),C=i,L=s,i+=m.shift(),s+=m.shift(),x="A",S=this.convertEndpointToCenterParameterization(C,L,i,s,H,V,M,E,b)}c.push({command:x||u,points:S,start:{x:k,y:w},pathLength:this.calcLength(k,w,x||u,S)})}"z"!==u&&"Z"!==u||c.push({command:"z",points:[],start:void 0,pathLength:0})}return c}static calcLength(e,t,n,a){var r,o,c,l,i=Qhe;switch(n){case"L":return i.getLineLength(e,t,a[0],a[1]);case"C":for(r=0,o=i.getPointOnCubicBezier(0,e,t,a[0],a[1],a[2],a[3],a[4],a[5]),l=.01;l<=1;l+=.01)c=i.getPointOnCubicBezier(l,e,t,a[0],a[1],a[2],a[3],a[4],a[5]),r+=i.getLineLength(o.x,o.y,c.x,c.y),o=c;return r;case"Q":for(r=0,o=i.getPointOnQuadraticBezier(0,e,t,a[0],a[1],a[2],a[3]),l=.01;l<=1;l+=.01)c=i.getPointOnQuadraticBezier(l,e,t,a[0],a[1],a[2],a[3]),r+=i.getLineLength(o.x,o.y,c.x,c.y),o=c;return r;case"A":r=0;var s=a[4],h=a[5],d=a[4]+h,u=Math.PI/180;if(Math.abs(s-d)<u&&(u=Math.abs(s-d)),o=i.getPointOnEllipticalArc(a[0],a[1],a[2],a[3],s,0),h<0)for(l=s-u;l>d;l-=u)c=i.getPointOnEllipticalArc(a[0],a[1],a[2],a[3],l,0),r+=i.getLineLength(o.x,o.y,c.x,c.y),o=c;else for(l=s+u;l<d;l+=u)c=i.getPointOnEllipticalArc(a[0],a[1],a[2],a[3],l,0),r+=i.getLineLength(o.x,o.y,c.x,c.y),o=c;return c=i.getPointOnEllipticalArc(a[0],a[1],a[2],a[3],d,0),r+i.getLineLength(o.x,o.y,c.x,c.y)}return 0}static convertEndpointToCenterParameterization(e,t,n,a,r,o,c,l,i){var s=i*(Math.PI/180),h=Math.cos(s)*(e-n)/2+Math.sin(s)*(t-a)/2,d=-1*Math.sin(s)*(e-n)/2+Math.cos(s)*(t-a)/2,u=h*h/(c*c)+d*d/(l*l);u>1&&(c*=Math.sqrt(u),l*=Math.sqrt(u));var m=Math.sqrt((c*c*(l*l)-c*c*(d*d)-l*l*(h*h))/(c*c*(d*d)+l*l*(h*h)));r===o&&(m*=-1),isNaN(m)&&(m=0);var p=m*c*d/l,v=m*-l*h/c,f=(e+n)/2+Math.cos(s)*p-Math.sin(s)*v,z=(t+a)/2+Math.sin(s)*p+Math.cos(s)*v,g=function(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])},y=function(e,t){return(e[0]*t[0]+e[1]*t[1])/(g(e)*g(t))},M=function(e,t){return(e[0]*t[1]<e[1]*t[0]?-1:1)*Math.acos(y(e,t))},E=M([1,0],[(h-p)/c,(d-v)/l]),b=[(h-p)/c,(d-v)/l],H=[(-1*h-p)/c,(-1*d-v)/l],V=M(b,H);return y(b,H)<=-1&&(V=Math.PI),y(b,H)>=1&&(V=0),0===o&&V>0&&(V-=2*Math.PI),1===o&&V<0&&(V+=2*Math.PI),[f,z,c,l,E,V,s,o]}}Qhe.prototype.className="Path",Qhe.prototype._attrsAffectingSize=["data"],Xie(Qhe),fse.addGetterSetter(Qhe,"data");class Jhe extends Xhe{_sceneFunc(e){super._sceneFunc(e);var t=2*Math.PI,n=this.points(),a=n,r=0!==this.tension()&&n.length>4;r&&(a=this.getTensionPoints());var o,c,l=this.pointerLength(),i=n.length;if(r){const e=[a[a.length-4],a[a.length-3],a[a.length-2],a[a.length-1],n[i-2],n[i-1]],t=Qhe.calcLength(a[a.length-4],a[a.length-3],"C",e),r=Qhe.getPointOnQuadraticBezier(Math.min(1,1-l/t),e[0],e[1],e[2],e[3],e[4],e[5]);o=n[i-2]-r.x,c=n[i-1]-r.y}else o=n[i-2]-n[i-4],c=n[i-1]-n[i-3];var s=(Math.atan2(c,o)+t)%t,h=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(n[i-2],n[i-1]),e.rotate(s),e.moveTo(0,0),e.lineTo(-l,h/2),e.lineTo(-l,-h/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(n[0],n[1]),r?(o=(a[0]+a[2])/2-n[0],c=(a[1]+a[3])/2-n[1]):(o=n[2]-n[0],c=n[3]-n[1]),e.rotate((Math.atan2(-c,-o)+t)%t),e.moveTo(0,0),e.lineTo(-l,h/2),e.lineTo(-l,-h/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){var t=this.dashEnabled();t&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),t&&(this.attrs.dashEnabled=!0)}getSelfRect(){const e=super.getSelfRect(),t=this.pointerWidth()/2;return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}}Jhe.prototype.className="Arrow",Xie(Jhe),fse.addGetterSetter(Jhe,"pointerLength",10,ise()),fse.addGetterSetter(Jhe,"pointerWidth",10,ise()),fse.addGetterSetter(Jhe,"pointerAtBeginning",!1),fse.addGetterSetter(Jhe,"pointerAtEnding",!0);class Zhe extends Ohe{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(e){this.radius()!==e/2&&this.radius(e/2)}setHeight(e){this.radius()!==e/2&&this.radius(e/2)}}Zhe.prototype._centroid=!0,Zhe.prototype.className="Circle",Zhe.prototype._attrsAffectingSize=["radius"],Xie(Zhe),fse.addGetterSetter(Zhe,"radius",0,ise());class ede extends Ohe{_sceneFunc(e){var t=this.radiusX(),n=this.radiusY();e.beginPath(),e.save(),t!==n&&e.scale(1,n/t),e.arc(0,0,t,0,2*Math.PI,!1),e.restore(),e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.radiusX()}getHeight(){return 2*this.radiusY()}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}}ede.prototype.className="Ellipse",ede.prototype._centroid=!0,ede.prototype._attrsAffectingSize=["radiusX","radiusY"],Xie(ede),fse.addComponentsGetterSetter(ede,"radius",["x","y"]),fse.addGetterSetter(ede,"radiusX",0,ise()),fse.addGetterSetter(ede,"radiusY",0,ise());class tde extends Ohe{constructor(e){super(e),this.on("imageChange.konva",(()=>{this._setImageLoad()})),this._setImageLoad()}_setImageLoad(){const e=this.image();e&&e.complete||e&&4===e.readyState||e&&e.addEventListener&&e.addEventListener("load",(()=>{this._requestDraw()}))}_useBufferCanvas(){return super._useBufferCanvas(!0)}_sceneFunc(e){const t=this.getWidth(),n=this.getHeight(),a=this.cornerRadius(),r=this.attrs.image;let o;if(r){const e=this.attrs.cropWidth,a=this.attrs.cropHeight;o=e&&a?[r,this.cropX(),this.cropY(),e,a,0,0,t,n]:[r,0,0,t,n]}(this.hasFill()||this.hasStroke()||a)&&(e.beginPath(),a?ose.drawRoundedRectPath(e,t,n,a):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)),r&&(a&&e.clip(),e.drawImage.apply(e,o))}_hitFunc(e){var t=this.width(),n=this.height(),a=this.cornerRadius();e.beginPath(),a?ose.drawRoundedRectPath(e,t,n,a):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}getWidth(){var e,t;return null!==(e=this.attrs.width)&&void 0!==e?e:null===(t=this.image())||void 0===t?void 0:t.width}getHeight(){var e,t;return null!==(e=this.attrs.height)&&void 0!==e?e:null===(t=this.image())||void 0===t?void 0:t.height}static fromURL(e,t,n=null){var a=ose.createImageElement();a.onload=function(){var e=new tde({image:a});t(e)},a.onerror=n,a.crossOrigin="Anonymous",a.src=e}}tde.prototype.className="Image",Xie(tde),fse.addGetterSetter(tde,"cornerRadius",0,sse(4)),fse.addGetterSetter(tde,"image"),fse.addComponentsGetterSetter(tde,"crop",["x","y","width","height"]),fse.addGetterSetter(tde,"cropX",0,ise()),fse.addGetterSetter(tde,"cropY",0,ise()),fse.addGetterSetter(tde,"cropWidth",0,ise()),fse.addGetterSetter(tde,"cropHeight",0,ise());var nde=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],ade="up",rde="right",ode="down",cde="left",lde=nde.length;class ide extends Dhe{constructor(e){super(e),this.on("add.konva",(function(e){this._addListeners(e.child),this._sync()}))}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(e){var t,n=this,a=function(){n._sync()};for(t=0;t<lde;t++)e.on(nde[t]+"Change.konva",a)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){var e,t,n,a,r,o,c,l=this.getText(),i=this.getTag();if(l&&i){switch(e=l.width(),t=l.height(),n=i.pointerDirection(),a=i.pointerWidth(),c=i.pointerHeight(),r=0,o=0,n){case ade:r=e/2,o=-1*c;break;case rde:r=e+a,o=t/2;break;case ode:r=e/2,o=t+c;break;case cde:r=-1*a,o=t/2}i.setAttrs({x:-1*r,y:-1*o,width:e,height:t}),l.setAttrs({x:-1*r,y:-1*o})}}}ide.prototype.className="Label",Xie(ide);class sde extends Ohe{_sceneFunc(e){var t=this.width(),n=this.height(),a=this.pointerDirection(),r=this.pointerWidth(),o=this.pointerHeight(),c=this.cornerRadius();let l=0,i=0,s=0,h=0;"number"==typeof c?l=i=s=h=Math.min(c,t/2,n/2):(l=Math.min(c[0]||0,t/2,n/2),i=Math.min(c[1]||0,t/2,n/2),h=Math.min(c[2]||0,t/2,n/2),s=Math.min(c[3]||0,t/2,n/2)),e.beginPath(),e.moveTo(l,0),a===ade&&(e.lineTo((t-r)/2,0),e.lineTo(t/2,-1*o),e.lineTo((t+r)/2,0)),e.lineTo(t-i,0),e.arc(t-i,i,i,3*Math.PI/2,0,!1),a===rde&&(e.lineTo(t,(n-o)/2),e.lineTo(t+r,n/2),e.lineTo(t,(n+o)/2)),e.lineTo(t,n-h),e.arc(t-h,n-h,h,0,Math.PI/2,!1),a===ode&&(e.lineTo((t+r)/2,n),e.lineTo(t/2,n+o),e.lineTo((t-r)/2,n)),e.lineTo(s,n),e.arc(s,n-s,s,Math.PI/2,Math.PI,!1),a===cde&&(e.lineTo(0,(n+o)/2),e.lineTo(-1*r,n/2),e.lineTo(0,(n-o)/2)),e.lineTo(0,l),e.arc(l,l,l,Math.PI,3*Math.PI/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){var e=0,t=0,n=this.pointerWidth(),a=this.pointerHeight(),r=this.pointerDirection(),o=this.width(),c=this.height();return r===ade?(t-=a,c+=a):r===ode?c+=a:r===cde?(e-=1.5*n,o+=n):r===rde&&(o+=1.5*n),{x:e,y:t,width:o,height:c}}}sde.prototype.className="Tag",Xie(sde),fse.addGetterSetter(sde,"pointerDirection","none"),fse.addGetterSetter(sde,"pointerWidth",0,ise()),fse.addGetterSetter(sde,"pointerHeight",0,ise()),fse.addGetterSetter(sde,"cornerRadius",0,sse(4));class hde extends Ohe{_sceneFunc(e){var t=this.cornerRadius(),n=this.width(),a=this.height();e.beginPath(),t?ose.drawRoundedRectPath(e,n,a,t):e.rect(0,0,n,a),e.closePath(),e.fillStrokeShape(this)}}hde.prototype.className="Rect",Xie(hde),fse.addGetterSetter(hde,"cornerRadius",0,sse(4));class dde extends Ohe{_sceneFunc(e){const t=this._getPoints();e.beginPath(),e.moveTo(t[0].x,t[0].y);for(var n=1;n<t.length;n++)e.lineTo(t[n].x,t[n].y);e.closePath(),e.fillStrokeShape(this)}_getPoints(){const e=this.attrs.sides,t=this.attrs.radius||0,n=[];for(var a=0;a<e;a++)n.push({x:t*Math.sin(2*a*Math.PI/e),y:-1*t*Math.cos(2*a*Math.PI/e)});return n}getSelfRect(){const e=this._getPoints();var t=e[0].x,n=e[0].y,a=e[0].x,r=e[0].y;return e.forEach((e=>{t=Math.min(t,e.x),n=Math.max(n,e.x),a=Math.min(a,e.y),r=Math.max(r,e.y)})),{x:t,y:a,width:n-t,height:r-a}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}dde.prototype.className="RegularPolygon",dde.prototype._centroid=!0,dde.prototype._attrsAffectingSize=["radius"],Xie(dde),fse.addGetterSetter(dde,"radius",0,ise()),fse.addGetterSetter(dde,"sides",0,ise());var ude=2*Math.PI;class mde extends Ohe{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,ude,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),ude,0,!0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}mde.prototype.className="Ring",mde.prototype._centroid=!0,mde.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Xie(mde),fse.addGetterSetter(mde,"innerRadius",0,ise()),fse.addGetterSetter(mde,"outerRadius",0,ise());class pde extends Ohe{constructor(e){super(e),this._updated=!0,this.anim=new Fhe((()=>{var e=this._updated;return this._updated=!1,e})),this.on("animationChange.konva",(function(){this.frameIndex(0)})),this.on("frameIndexChange.konva",(function(){this._updated=!0})),this.on("frameRateChange.konva",(function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())}))}_sceneFunc(e){var t=this.animation(),n=this.frameIndex(),a=4*n,r=this.animations()[t],o=this.frameOffsets(),c=r[a+0],l=r[a+1],i=r[a+2],s=r[a+3],h=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,i,s),e.closePath(),e.fillStrokeShape(this)),h)if(o){var d=o[t],u=2*n;e.drawImage(h,c,l,i,s,d[u+0],d[u+1],i,s)}else e.drawImage(h,c,l,i,s,0,0,i,s)}_hitFunc(e){var t=this.animation(),n=this.frameIndex(),a=4*n,r=this.animations()[t],o=this.frameOffsets(),c=r[a+2],l=r[a+3];if(e.beginPath(),o){var i=o[t],s=2*n;e.rect(i[s+0],i[s+1],c,l)}else e.rect(0,0,c,l);e.closePath(),e.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){var e=this;this.interval=setInterval((function(){e._updateIndex()}),1e3/this.frameRate())}start(){if(!this.isRunning()){var e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){var e=this.frameIndex(),t=this.animation();e<this.animations()[t].length/4-1?this.frameIndex(e+1):this.frameIndex(0)}}pde.prototype.className="Sprite",Xie(pde),fse.addGetterSetter(pde,"animation"),fse.addGetterSetter(pde,"animations"),fse.addGetterSetter(pde,"frameOffsets"),fse.addGetterSetter(pde,"image"),fse.addGetterSetter(pde,"frameIndex",0,ise()),fse.addGetterSetter(pde,"frameRate",17,ise()),fse.backCompat(pde,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});class vde extends Ohe{_sceneFunc(e){var t=this.innerRadius(),n=this.outerRadius(),a=this.numPoints();e.beginPath(),e.moveTo(0,0-n);for(var r=1;r<2*a;r++){var o=r%2==0?n:t,c=o*Math.sin(r*Math.PI/a),l=-1*o*Math.cos(r*Math.PI/a);e.lineTo(c,l)}e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}function fde(e){return Array.from(e)}vde.prototype.className="Star",vde.prototype._centroid=!0,vde.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Xie(vde),fse.addGetterSetter(vde,"numPoints",5,ise()),fse.addGetterSetter(vde,"innerRadius",0,ise()),fse.addGetterSetter(vde,"outerRadius",0,ise());var zde,gde="auto",yde="justify",Mde="left",Ede="middle",bde="normal",Hde=" ",Vde="none",Cde=["fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],Lde=Cde.length;function xde(){return zde||(zde=ose.createCanvasElement().getContext("2d"))}class Sde extends Ohe{constructor(e){super(function(e){return(e=e||{}).fillLinearGradientColorStops||e.fillRadialGradientColorStops||e.fillPatternImage||(e.fill=e.fill||"black"),e}(e)),this._partialTextX=0,this._partialTextY=0;for(var t=0;t<Lde;t++)this.on(Cde[t]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(e){var t=this.textArr,n=t.length;if(this.text()){var a,r=this.padding(),o=this.fontSize(),c=this.lineHeight()*o,l=this.verticalAlign(),i=0,s=this.align(),h=this.getWidth(),d=this.letterSpacing(),u=this.fill(),m=this.textDecoration(),p=-1!==m.indexOf("underline"),v=-1!==m.indexOf("line-through"),f=0,z=(f=c/2,0),g=0;for(e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",Ede),e.setAttr("textAlign",Mde),l===Ede?i=(this.getHeight()-n*c-2*r)/2:"bottom"===l&&(i=this.getHeight()-n*c-2*r),e.translate(r,i+r),a=0;a<n;a++){z=0,g=0;var y,M,E,b=t[a],H=b.text,V=b.width,C=b.lastInParagraph;if(e.save(),"right"===s?z+=h-V-2*r:"center"===s&&(z+=(h-V-2*r)/2),p){e.save(),e.beginPath(),e.moveTo(z,f+g+Math.round(o/2)),M=0==(y=H.split(" ").length-1),E=s!==yde||C?V:h-2*r,e.lineTo(z+Math.round(E),f+g+Math.round(o/2)),e.lineWidth=o/15;const t=this._getLinearGradient();e.strokeStyle=t||u,e.stroke(),e.restore()}if(v){e.save(),e.beginPath(),e.moveTo(z,f+g),M=0==(y=H.split(" ").length-1),E=s===yde&&C&&!M?h-2*r:V,e.lineTo(z+Math.round(E),f+g),e.lineWidth=o/15;const t=this._getLinearGradient();e.strokeStyle=t||u,e.stroke(),e.restore()}if(0!==d||s===yde){y=H.split(" ").length-1;for(var L=fde(H),x=0;x<L.length;x++){var S=L[x];" "!==S||C||s!==yde||(z+=(h-2*r-V)/y),this._partialTextX=z,this._partialTextY=f+g,this._partialText=S,e.fillStrokeShape(this),z+=this.measureSize(S).width+d}}else this._partialTextX=z,this._partialTextY=f+g,this._partialText=H,e.fillStrokeShape(this);e.restore(),n>1&&(f+=c)}}}_hitFunc(e){var t=this.getWidth(),n=this.getHeight();e.beginPath(),e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}setText(e){var t=ose._isString(e)?e:null==e?"":e+"";return this._setAttr("text",t),this}getWidth(){return this.attrs.width===gde||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===gde||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return ose.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(e){var t,n=xde(),a=this.fontSize();return n.save(),n.font=this._getContextFont(),t=n.measureText(e),n.restore(),{width:t.width,height:a}}_getContextFont(){return this.fontStyle()+Hde+this.fontVariant()+Hde+(this.fontSize()+"px ")+function(e){return e.split(",").map((e=>{const t=(e=e.trim()).indexOf(" ")>=0,n=e.indexOf('"')>=0||e.indexOf("'")>=0;return t&&!n&&(e=`"${e}"`),e})).join(", ")}(this.fontFamily())}_addTextLine(e){this.align()===yde&&(e=e.trim());var t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e){var t=this.letterSpacing(),n=e.length;return xde().measureText(e).width+(n?t*(n-1):0)}_setTextData(){var e=this.text().split("\n"),t=+this.fontSize(),n=0,a=this.lineHeight()*t,r=this.attrs.width,o=this.attrs.height,c=r!==gde&&void 0!==r,l=o!==gde&&void 0!==o,i=this.padding(),s=r-2*i,h=o-2*i,d=0,u=this.wrap(),m="char"!==u&&u!==Vde,p=this.ellipsis();this.textArr=[],xde().font=this._getContextFont();for(var v=p?this._getTextWidth("…"):0,f=0,z=e.length;f<z;++f){var g=e[f],y=this._getTextWidth(g);if(c&&y>s)for(;g.length>0;){for(var M=0,E=g.length,b="",H=0;M<E;){var V=M+E>>>1,C=g.slice(0,V+1),L=this._getTextWidth(C)+v;L<=s?(M=V+1,b=C,H=L):E=V}if(!b)break;if(m){var x,S=g[b.length];(x=(S===Hde||"-"===S)&&H<=s?b.length:Math.max(b.lastIndexOf(Hde),b.lastIndexOf("-"))+1)>0&&(M=x,b=b.slice(0,M),H=this._getTextWidth(b))}if(b=b.trimRight(),this._addTextLine(b),n=Math.max(n,H),d+=a,this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if((g=(g=g.slice(M)).trimLeft()).length>0&&(y=this._getTextWidth(g))<=s){this._addTextLine(g),d+=a,n=Math.max(n,y);break}}else this._addTextLine(g),d+=a,n=Math.max(n,y),this._shouldHandleEllipsis(d)&&f<z-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),l&&d+a>h)break}this.textHeight=t,this.textWidth=n}_shouldHandleEllipsis(e){var t=+this.fontSize(),n=this.lineHeight()*t,a=this.attrs.height,r=a!==gde&&void 0!==a,o=a-2*this.padding();return!(this.wrap()!==Vde)||r&&e+n>o}_tryToAddEllipsisToLastLine(){var e=this.attrs.width,t=e!==gde&&void 0!==e,n=e-2*this.padding(),a=this.ellipsis(),r=this.textArr[this.textArr.length-1];r&&a&&(t&&(this._getTextWidth(r.text+"…")<n||(r.text=r.text.slice(0,r.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(r.text+"…"))}getStrokeScaleEnabled(){return!0}}Sde.prototype._fillFunc=function(e){e.fillText(this._partialText,this._partialTextX,this._partialTextY)},Sde.prototype._strokeFunc=function(e){e.strokeText(this._partialText,this._partialTextX,this._partialTextY)},Sde.prototype.className="Text",Sde.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],Xie(Sde),fse.overWriteSetter(Sde,"width",hse()),fse.overWriteSetter(Sde,"height",hse()),fse.addGetterSetter(Sde,"fontFamily","Arial"),fse.addGetterSetter(Sde,"fontSize",12,ise()),fse.addGetterSetter(Sde,"fontStyle",bde),fse.addGetterSetter(Sde,"fontVariant",bde),fse.addGetterSetter(Sde,"padding",0,ise()),fse.addGetterSetter(Sde,"align",Mde),fse.addGetterSetter(Sde,"verticalAlign","top"),fse.addGetterSetter(Sde,"lineHeight",1,ise()),fse.addGetterSetter(Sde,"wrap","word"),fse.addGetterSetter(Sde,"ellipsis",!1,mse()),fse.addGetterSetter(Sde,"letterSpacing",0,ise()),fse.addGetterSetter(Sde,"text","",dse()),fse.addGetterSetter(Sde,"textDecoration","");var kde="normal";function wde(e){e.fillText(this.partialText,0,0)}function Tde(e){e.strokeText(this.partialText,0,0)}class Ode extends Ohe{constructor(e){super(e),this.dummyCanvas=ose.createCanvasElement(),this.dataArray=[],this.dataArray=Qhe.parsePathData(this.attrs.data),this.on("dataChange.konva",(function(){this.dataArray=Qhe.parsePathData(this.attrs.data),this._setTextData()})),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_sceneFunc(e){e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",this.textBaseline()),e.setAttr("textAlign","left"),e.save();var t=this.textDecoration(),n=this.fill(),a=this.fontSize(),r=this.glyphInfo;"underline"===t&&e.beginPath();for(var o=0;o<r.length;o++){e.save();var c=r[o].p0;e.translate(c.x,c.y),e.rotate(r[o].rotation),this.partialText=r[o].text,e.fillStrokeShape(this),"underline"===t&&(0===o&&e.moveTo(0,a/2+1),e.lineTo(a,a/2+1)),e.restore()}"underline"===t&&(e.strokeStyle=n,e.lineWidth=a/20,e.stroke()),e.restore()}_hitFunc(e){e.beginPath();var t=this.glyphInfo;if(t.length>=1){var n=t[0].p0;e.moveTo(n.x,n.y)}for(var a=0;a<t.length;a++){var r=t[a].p1;e.lineTo(r.x,r.y)}e.setAttr("lineWidth",this.fontSize()),e.setAttr("strokeStyle",this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return ose.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return Sde.prototype.setText.call(this,e)}_getContextFont(){return Sde.prototype._getContextFont.call(this)}_getTextSize(e){var t=this.dummyCanvas.getContext("2d");t.save(),t.font=this._getContextFont();var n=t.measureText(e);return t.restore(),{width:n.width,height:parseInt(this.attrs.fontSize,10)}}_setTextData(){var e=this,t=this._getTextSize(this.attrs.text),n=this.letterSpacing(),a=this.align(),r=this.kerningFunc();this.textWidth=t.width,this.textHeight=t.height;var o=Math.max(this.textWidth+((this.attrs.text||"").length-1)*n,0);this.glyphInfo=[];for(var c=0,l=0;l<e.dataArray.length;l++)e.dataArray[l].pathLength>0&&(c+=e.dataArray[l].pathLength);var i=0;"center"===a&&(i=Math.max(0,c/2-o/2)),"right"===a&&(i=Math.max(0,c-o));for(var s,h,d,u=fde(this.text()),m=this.text().split(" ").length-1,p=-1,v=0,f=function(){v=0;for(var t=e.dataArray,n=p+1;n<t.length;n++){if(t[n].pathLength>0)return p=n,t[n];"M"===t[n].command&&(s={x:t[n].points[0],y:t[n].points[1]})}return{}},z=function(t){var r=e._getTextSize(t).width+n;" "===t&&"justify"===a&&(r+=(c-o)/m);var l=0,i=0;for(h=void 0;Math.abs(r-l)/r>.01&&i<20;){i++;for(var u=l;void 0===d;)(d=f())&&u+d.pathLength<r&&(u+=d.pathLength,d=void 0);if(0===Object.keys(d).length||void 0===s)return;var p=!1;switch(d.command){case"L":Qhe.getLineLength(s.x,s.y,d.points[0],d.points[1])>r?h=Qhe.getPointOnLine(r,s.x,s.y,d.points[0],d.points[1],s.x,s.y):d=void 0;break;case"A":var z=d.points[4],g=d.points[5],y=d.points[4]+g;0===v?v=z+1e-8:r>l?v+=Math.PI/180*g/Math.abs(g):v-=Math.PI/360*g/Math.abs(g),(g<0&&v<y||g>=0&&v>y)&&(v=y,p=!0),h=Qhe.getPointOnEllipticalArc(d.points[0],d.points[1],d.points[2],d.points[3],v,d.points[6]);break;case"C":0===v?v=r>d.pathLength?1e-8:r/d.pathLength:r>l?v+=(r-l)/d.pathLength/2:v=Math.max(v-(l-r)/d.pathLength/2,0),v>1&&(v=1,p=!0),h=Qhe.getPointOnCubicBezier(v,d.start.x,d.start.y,d.points[0],d.points[1],d.points[2],d.points[3],d.points[4],d.points[5]);break;case"Q":0===v?v=r/d.pathLength:r>l?v+=(r-l)/d.pathLength:v-=(l-r)/d.pathLength,v>1&&(v=1,p=!0),h=Qhe.getPointOnQuadraticBezier(v,d.start.x,d.start.y,d.points[0],d.points[1],d.points[2],d.points[3])}void 0!==h&&(l=Qhe.getLineLength(s.x,s.y,h.x,h.y)),p&&(p=!1,d=void 0)}},g=i/(e._getTextSize("C").width+n)-1,y=0;y<g&&(z("C"),void 0!==s&&void 0!==h);y++)s=h;for(var M=0;M<u.length&&(z(u[M]),void 0!==s&&void 0!==h);M++){var E=Qhe.getLineLength(s.x,s.y,h.x,h.y),b=0;if(r)try{b=r(u[M-1],u[M])*this.fontSize()}catch(e){b=0}s.x+=b,h.x+=b,this.textWidth+=b;var H=Qhe.getPointOnLine(b+E/2,s.x,s.y,h.x,h.y),V=Math.atan2(h.y-s.y,h.x-s.x);this.glyphInfo.push({transposeX:H.x,transposeY:H.y,text:u[M],rotation:V,p0:s,p1:h}),s=h}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};var e=[];this.glyphInfo.forEach((function(t){e.push(t.p0.x),e.push(t.p0.y),e.push(t.p1.x),e.push(t.p1.y)}));for(var t,n,a=e[0]||0,r=e[0]||0,o=e[1]||0,c=e[1]||0,l=0;l<e.length/2;l++)t=e[2*l],n=e[2*l+1],a=Math.min(a,t),r=Math.max(r,t),o=Math.min(o,n),c=Math.max(c,n);var i=this.fontSize();return{x:a-i/2,y:o-i/2,width:r-a+i,height:c-o+i}}destroy(){return ose.releaseCanvas(this.dummyCanvas),super.destroy()}}Ode.prototype._fillFunc=wde,Ode.prototype._strokeFunc=Tde,Ode.prototype._fillFuncHit=wde,Ode.prototype._strokeFuncHit=Tde,Ode.prototype.className="TextPath",Ode.prototype._attrsAffectingSize=["text","fontSize","data"],Xie(Ode),fse.addGetterSetter(Ode,"data"),fse.addGetterSetter(Ode,"fontFamily","Arial"),fse.addGetterSetter(Ode,"fontSize",12,ise()),fse.addGetterSetter(Ode,"fontStyle",kde),fse.addGetterSetter(Ode,"align","left"),fse.addGetterSetter(Ode,"letterSpacing",0,ise()),fse.addGetterSetter(Ode,"textBaseline","middle"),fse.addGetterSetter(Ode,"fontVariant",kde),fse.addGetterSetter(Ode,"text",""),fse.addGetterSetter(Ode,"textDecoration",null),fse.addGetterSetter(Ode,"kerningFunc",null);var Ade="tr-konva",Rde=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange"].map((e=>e+`.${Ade}`)).join(" "),Nde="nodesRect",_de=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],Dde={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135};const Pde="ontouchstart"in Kie._global;var Fde=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function Ide(e,t,n){const a=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),r=n.y+(e.x-n.x)*Math.sin(t)+(e.y-n.y)*Math.cos(t);return Object.assign(Object.assign({},e),{rotation:e.rotation+t,x:a,y:r})}class jde extends Dhe{constructor(e){super(e),this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(Rde,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return ose.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return Ade+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();const t=e.filter((e=>!e.isAncestorOf(this)||(ose.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1)));return this._nodes=e=t,1===e.length&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach((e=>{const t=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()},n=e._attrsAffectingSize.map((e=>e+"Change."+this._getEventNamespace())).join(" ");e.on(n,t),e.on(_de.map((e=>e+`.${this._getEventNamespace()}`)).join(" "),t),e.on(`absoluteTransformChange.${this._getEventNamespace()}`,t),this._proxyDrag(e)})),this._resetTransformCache(),!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,(n=>{t=e.getAbsolutePosition(),this.isDragging()||e===this.findOne(".back")||this.startDrag(n,!1)})),e.on(`dragmove.${this._getEventNamespace()}`,(n=>{if(!t)return;const a=e.getAbsolutePosition(),r=a.x-t.x,o=a.y-t.y;this.nodes().forEach((t=>{if(t===e)return;if(t.isDragging())return;const a=t.getAbsolutePosition();t.setAbsolutePosition({x:a.x+r,y:a.y+o}),t.startDrag(n)})),t=null}))}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach((e=>{e.off("."+this._getEventNamespace())})),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(Nde),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(Nde,this.__getNodeRect)}__getNodeShape(e,t=this.rotation(),n){var a=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=e.getAbsoluteScale(n),o=e.getAbsolutePosition(n),c=a.x*r.x-e.offsetX()*r.x,l=a.y*r.y-e.offsetY()*r.y;const i=(Kie.getAngle(e.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return Ide({x:o.x+c*Math.cos(i)+l*Math.sin(-i),y:o.y+l*Math.cos(i)+c*Math.sin(i),width:a.width*r.x,height:a.height*r.y,rotation:i},-Kie.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const e=[];this.nodes().map((t=>{const n=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()});var a=[{x:n.x,y:n.y},{x:n.x+n.width,y:n.y},{x:n.x+n.width,y:n.y+n.height},{x:n.x,y:n.y+n.height}],r=t.getAbsoluteTransform();a.forEach((function(t){var n=r.point(t);e.push(n)}))}));const t=new Qie;var n,a,r,o;t.rotate(-Kie.getAngle(this.rotation())),e.forEach((function(e){var c=t.point(e);void 0===n&&(n=r=c.x,a=o=c.y),n=Math.min(n,c.x),a=Math.min(a,c.y),r=Math.max(r,c.x),o=Math.max(o,c.y)})),t.invert();const c=t.point({x:n,y:a});return{x:c.x,y:c.y,width:r-n,height:o-a,rotation:Kie.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),Fde.forEach(function(e){this._createAnchor(e)}.bind(this)),this._createAnchor("rotater")}_createAnchor(e){var t=new hde({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:Pde?10:"auto"}),n=this;t.on("mousedown touchstart",(function(e){n._handleMouseDown(e)})),t.on("dragstart",(e=>{t.stopDrag(),e.cancelBubble=!0})),t.on("dragend",(e=>{e.cancelBubble=!0})),t.on("mouseenter",(()=>{var n=Kie.getAngle(this.rotation()),a=function(e,t){if("rotater"===e)return"crosshair";t+=ose.degToRad(Dde[e]||0);var n=(ose.radToDeg(t)%360+360)%360;return ose._inRange(n,337.5,360)||ose._inRange(n,0,22.5)?"ns-resize":ose._inRange(n,22.5,67.5)?"nesw-resize":ose._inRange(n,67.5,112.5)?"ew-resize":ose._inRange(n,112.5,157.5)?"nwse-resize":ose._inRange(n,157.5,202.5)?"ns-resize":ose._inRange(n,202.5,247.5)?"nesw-resize":ose._inRange(n,247.5,292.5)?"ew-resize":ose._inRange(n,292.5,337.5)?"nwse-resize":(ose.error("Transformer has unknown angle for cursor detection: "+n),"pointer")}(e,n);t.getStage().content&&(t.getStage().content.style.cursor=a),this._cursorChange=!0})),t.on("mouseout",(()=>{t.getStage().content&&(t.getStage().content.style.cursor=""),this._cursorChange=!1})),this.add(t)}_createBack(){var e=new Ohe({name:"back",width:0,height:0,draggable:!0,sceneFunc(e){var t=this.getParent(),n=t.padding();e.beginPath(),e.rect(-n,-n,this.width()+2*n,this.height()+2*n),e.moveTo(this.width()/2,-n),t.rotateEnabled()&&e.lineTo(this.width()/2,-t.rotateAnchorOffset()*ose._sign(this.height())-n),e.fillStrokeShape(this)},hitFunc:(e,t)=>{if(this.shouldOverdrawWholeArea()){var n=this.padding();e.beginPath(),e.rect(-n,-n,t.width()+2*n,t.height()+2*n),e.fillStrokeShape(t)}}});this.add(e),this._proxyDrag(e),e.on("dragstart",(e=>{e.cancelBubble=!0})),e.on("dragmove",(e=>{e.cancelBubble=!0})),e.on("dragend",(e=>{e.cancelBubble=!0})),this.on("dragmove",(e=>{this.update()}))}_handleMouseDown(e){this._movingAnchorName=e.target.name().split(" ")[0];var t=this._getNodeRect(),n=t.width,a=t.height,r=Math.sqrt(Math.pow(n,2)+Math.pow(a,2));this.sin=Math.abs(a/r),this.cos=Math.abs(n/r),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;var o=e.target.getAbsolutePosition(),c=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:c.x-o.x,y:c.y-o.y},this._fire("transformstart",{evt:e.evt,target:this.getNode()}),this._nodes.forEach((t=>{t._fire("transformstart",{evt:e.evt,target:t})}))}_handleMouseMove(e){var t,n,a,r=this.findOne("."+this._movingAnchorName),o=r.getStage();o.setPointersPositions(e);const c=o.getPointerPosition();let l={x:c.x-this._anchorDragOffset.x,y:c.y-this._anchorDragOffset.y};const i=r.getAbsolutePosition();this.anchorDragBoundFunc()&&(l=this.anchorDragBoundFunc()(i,l,e)),r.setAbsolutePosition(l);const s=r.getAbsolutePosition();if(i.x!==s.x||i.y!==s.y)if("rotater"!==this._movingAnchorName){var h=this.keepRatio()||e.shiftKey,d=this.centeredScaling()||e.altKey;if("top-left"===this._movingAnchorName){if(h){var u=d?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};a=Math.sqrt(Math.pow(u.x-r.x(),2)+Math.pow(u.y-r.y(),2));var m=this.findOne(".top-left").x()>u.x?-1:1,p=this.findOne(".top-left").y()>u.y?-1:1;t=a*this.cos*m,n=a*this.sin*p,this.findOne(".top-left").x(u.x-t),this.findOne(".top-left").y(u.y-n)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(r.y());else if("top-right"===this._movingAnchorName){h&&(u=d?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()},a=Math.sqrt(Math.pow(r.x()-u.x,2)+Math.pow(u.y-r.y(),2)),m=this.findOne(".top-right").x()<u.x?-1:1,p=this.findOne(".top-right").y()>u.y?-1:1,t=a*this.cos*m,n=a*this.sin*p,this.findOne(".top-right").x(u.x+t),this.findOne(".top-right").y(u.y-n));var v=r.position();this.findOne(".top-left").y(v.y),this.findOne(".bottom-right").x(v.x)}else"middle-left"===this._movingAnchorName?this.findOne(".top-left").x(r.x()):"middle-right"===this._movingAnchorName?this.findOne(".bottom-right").x(r.x()):"bottom-left"===this._movingAnchorName?(h&&(u=d?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()},a=Math.sqrt(Math.pow(u.x-r.x(),2)+Math.pow(r.y()-u.y,2)),m=u.x<r.x()?-1:1,p=r.y()<u.y?-1:1,t=a*this.cos*m,n=a*this.sin*p,r.x(u.x-t),r.y(u.y+n)),v=r.position(),this.findOne(".top-left").x(v.x),this.findOne(".bottom-right").y(v.y)):"bottom-center"===this._movingAnchorName?this.findOne(".bottom-right").y(r.y()):"bottom-right"===this._movingAnchorName?h&&(u=d?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()},a=Math.sqrt(Math.pow(r.x()-u.x,2)+Math.pow(r.y()-u.y,2)),m=this.findOne(".bottom-right").x()<u.x?-1:1,p=this.findOne(".bottom-right").y()<u.y?-1:1,t=a*this.cos*m,n=a*this.sin*p,this.findOne(".bottom-right").x(u.x+t),this.findOne(".bottom-right").y(u.y+n)):console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(d=this.centeredScaling()||e.altKey){var f=this.findOne(".top-left"),z=this.findOne(".bottom-right"),g=f.x(),y=f.y(),M=this.getWidth()-z.x(),E=this.getHeight()-z.y();z.move({x:-g,y:-y}),f.move({x:M,y:E})}var b=this.findOne(".top-left").getAbsolutePosition();t=b.x,n=b.y;var H=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),V=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:t,y:n,width:H,height:V,rotation:Kie.getAngle(this.rotation())},e)}else{var C=this._getNodeRect();t=r.x()-C.width/2,n=-r.y()+C.height/2;let a=Math.atan2(-n,t)+Math.PI/2;C.height<0&&(a-=Math.PI);const o=Kie.getAngle(this.rotation())+a,c=Kie.getAngle(this.rotationSnapTolerance()),l=function(e,t){const n=function(e){return{x:e.x+e.width/2*Math.cos(e.rotation)+e.height/2*Math.sin(-e.rotation),y:e.y+e.height/2*Math.cos(e.rotation)+e.width/2*Math.sin(e.rotation)}}(e);return Ide(e,t,n)}(C,function(e,t,n){let a=t;for(let r=0;r<e.length;r++){const o=Kie.getAngle(e[r]),c=Math.abs(o-t)%(2*Math.PI);Math.min(c,2*Math.PI-c)<n&&(a=o)}return a}(this.rotationSnaps(),o,c)-C.rotation);this._fitNodesInto(l,e)}}_handleMouseUp(e){this._removeEvents(e)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(e){if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));var t=this.getNode();this._fire("transformend",{evt:e,target:t}),t&&this._nodes.forEach((t=>{t._fire("transformend",{evt:e,target:t})})),this._movingAnchorName=null}}_fitNodesInto(e,t){var n=this._getNodeRect();if(ose._inRange(e.width,2*-this.padding()-1,1))return void this.update();if(ose._inRange(e.height,2*-this.padding()-1,1))return void this.update();const a=this.flipEnabled();var r=new Qie;if(r.rotate(Kie.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const t=r.point({x:2*-this.padding(),y:0});if(e.x+=t.x,e.y+=t.y,e.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,!a)return void this.update()}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const t=r.point({x:2*this.padding(),y:0});if(this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.width+=2*this.padding(),!a)return void this.update()}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const t=r.point({x:0,y:2*-this.padding()});if(e.x+=t.x,e.y+=t.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding(),!a)return void this.update()}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const t=r.point({x:0,y:2*this.padding()});if(this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding(),!a)return void this.update()}if(this.boundBoxFunc()){const t=this.boundBoxFunc()(n,e);t?e=t:ose.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const o=1e7,c=new Qie;c.translate(n.x,n.y),c.rotate(n.rotation),c.scale(n.width/o,n.height/o);const l=new Qie;l.translate(e.x,e.y),l.rotate(e.rotation),l.scale(e.width/o,e.height/o);const i=l.multiply(c.invert());this._nodes.forEach((e=>{var n;const a=e.getParent().getAbsoluteTransform(),r=e.getTransform().copy();r.translate(e.offsetX(),e.offsetY());const o=new Qie;o.multiply(a.copy().invert()).multiply(i).multiply(a).multiply(r);const c=o.decompose();e.setAttrs(c),this._fire("transform",{evt:t,target:e}),e._fire("transform",{evt:t,target:e}),null===(n=e.getLayer())||void 0===n||n.batchDraw()})),this.rotation(ose._getRotation(e.rotation)),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,t){this.findOne(e).setAttrs(t)}update(){var e,t=this._getNodeRect();this.rotation(ose._getRotation(t.rotation));var n=t.width,a=t.height,r=this.enabledAnchors(),o=this.resizeEnabled(),c=this.padding(),l=this.anchorSize();this.find("._anchor").forEach((e=>{e.setAttrs({width:l,height:l,offsetX:l/2,offsetY:l/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})})),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:l/2+c,offsetY:l/2+c,visible:o&&r.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:n/2,y:0,offsetY:l/2+c,visible:o&&r.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:n,y:0,offsetX:l/2-c,offsetY:l/2+c,visible:o&&r.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:a/2,offsetX:l/2+c,visible:o&&r.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:n,y:a/2,offsetX:l/2-c,visible:o&&r.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:a,offsetX:l/2+c,offsetY:l/2-c,visible:o&&r.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:n/2,y:a,offsetY:l/2-c,visible:o&&r.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:n,y:a,offsetX:l/2-c,offsetY:l/2-c,visible:o&&r.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:n/2,y:-this.rotateAnchorOffset()*ose._sign(a)-c,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:n,height:a,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0}),null===(e=this.getLayer())||void 0===e||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();var e=this.findOne("."+this._movingAnchorName);e&&e.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),Dhe.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return jse.prototype.toObject.call(this)}clone(e){return jse.prototype.clone.call(this,e)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}jde.prototype.className="Transformer",Xie(jde),fse.addGetterSetter(jde,"enabledAnchors",Fde,(function(e){return e instanceof Array||ose.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach((function(e){-1===Fde.indexOf(e)&&ose.warn("Unknown anchor name: "+e+". Available names are: "+Fde.join(", "))})),e||[]})),fse.addGetterSetter(jde,"flipEnabled",!0,mse()),fse.addGetterSetter(jde,"resizeEnabled",!0),fse.addGetterSetter(jde,"anchorSize",10,ise()),fse.addGetterSetter(jde,"rotateEnabled",!0),fse.addGetterSetter(jde,"rotationSnaps",[]),fse.addGetterSetter(jde,"rotateAnchorOffset",50,ise()),fse.addGetterSetter(jde,"rotationSnapTolerance",5,ise()),fse.addGetterSetter(jde,"borderEnabled",!0),fse.addGetterSetter(jde,"anchorStroke","rgb(0, 161, 255)"),fse.addGetterSetter(jde,"anchorStrokeWidth",1,ise()),fse.addGetterSetter(jde,"anchorFill","white"),fse.addGetterSetter(jde,"anchorCornerRadius",0,ise()),fse.addGetterSetter(jde,"borderStroke","rgb(0, 161, 255)"),fse.addGetterSetter(jde,"borderStrokeWidth",1,ise()),fse.addGetterSetter(jde,"borderDash"),fse.addGetterSetter(jde,"keepRatio",!0),fse.addGetterSetter(jde,"centeredScaling",!1),fse.addGetterSetter(jde,"ignoreStroke",!1),fse.addGetterSetter(jde,"padding",0,ise()),fse.addGetterSetter(jde,"node"),fse.addGetterSetter(jde,"nodes"),fse.addGetterSetter(jde,"boundBoxFunc"),fse.addGetterSetter(jde,"anchorDragBoundFunc"),fse.addGetterSetter(jde,"shouldOverdrawWholeArea",!1),fse.addGetterSetter(jde,"useSingleNodeRotation",!0),fse.backCompat(jde,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});class Bde extends Ohe{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,Kie.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}function Ude(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}Bde.prototype.className="Wedge",Bde.prototype._centroid=!0,Bde.prototype._attrsAffectingSize=["radius"],Xie(Bde),fse.addGetterSetter(Bde,"radius",0,ise()),fse.addGetterSetter(Bde,"angle",0,ise()),fse.addGetterSetter(Bde,"clockwise",!1),fse.backCompat(Bde,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});var Wde=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],$de=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function qde(e,t,n,a,r){var o=n-t,c=r-a;return 0===o?a+c/2:0===c?a:c*((e-t)/o)+a}function Gde(e,t,n){var a=4*(n*e.width+t),r=[];return r.push(e.data[a++],e.data[a++],e.data[a++],e.data[a++]),r}function Yde(e,t){return Math.sqrt(Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)+Math.pow(e[2]-t[2],2))}function Kde(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}fse.addGetterSetter(jse,"blurRadius",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"brightness",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"contrast",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"embossStrength",.5,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"embossWhiteLevel",.5,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"embossDirection","top-left",null,fse.afterSetFilter),fse.addGetterSetter(jse,"embossBlend",!1,null,fse.afterSetFilter),fse.addGetterSetter(jse,"enhance",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"hue",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"saturation",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"luminance",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"hue",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"saturation",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"value",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"kaleidoscopePower",2,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"kaleidoscopeAngle",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"threshold",0,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"noise",.2,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"pixelSize",8,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"levels",.5,ise(),fse.afterSetFilter),fse.addGetterSetter(jse,"red",0,(function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)})),fse.addGetterSetter(jse,"green",0,(function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)})),fse.addGetterSetter(jse,"blue",0,lse,fse.afterSetFilter),fse.addGetterSetter(jse,"red",0,(function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)})),fse.addGetterSetter(jse,"green",0,(function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)})),fse.addGetterSetter(jse,"blue",0,lse,fse.afterSetFilter),fse.addGetterSetter(jse,"alpha",1,(function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e})),fse.addGetterSetter(jse,"threshold",.5,ise(),fse.afterSetFilter),qhe.Util._assign(qhe,{Arc:Ghe,Arrow:Jhe,Circle:Zhe,Ellipse:ede,Image:tde,Label:ide,Tag:sde,Line:Xhe,Path:Qhe,Rect:hde,RegularPolygon:dde,Ring:mde,Sprite:pde,Star:vde,Text:Sde,TextPath:Ode,Transformer:jde,Wedge:Bde,Filters:{Blur:function(e){var t=Math.round(this.blurRadius());t>0&&function(e,t){var n,a,r,o,c,l,i,s,h,d,u,m,p,v,f,z,g,y,M,E,b,H,V,C,L=e.data,x=e.width,S=e.height,k=t+t+1,w=x-1,T=S-1,O=t+1,A=O*(O+1)/2,R=new Ude,N=null,_=R,D=null,P=null,F=Wde[t],I=$de[t];for(r=1;r<k;r++)_=_.next=new Ude,r===O&&(N=_);for(_.next=R,i=l=0,a=0;a<S;a++){for(z=g=y=M=s=h=d=u=0,m=O*(E=L[l]),p=O*(b=L[l+1]),v=O*(H=L[l+2]),f=O*(V=L[l+3]),s+=A*E,h+=A*b,d+=A*H,u+=A*V,_=R,r=0;r<O;r++)_.r=E,_.g=b,_.b=H,_.a=V,_=_.next;for(r=1;r<O;r++)o=l+((w<r?w:r)<<2),s+=(_.r=E=L[o])*(C=O-r),h+=(_.g=b=L[o+1])*C,d+=(_.b=H=L[o+2])*C,u+=(_.a=V=L[o+3])*C,z+=E,g+=b,y+=H,M+=V,_=_.next;for(D=R,P=N,n=0;n<x;n++)L[l+3]=V=u*F>>I,0!==V?(V=255/V,L[l]=(s*F>>I)*V,L[l+1]=(h*F>>I)*V,L[l+2]=(d*F>>I)*V):L[l]=L[l+1]=L[l+2]=0,s-=m,h-=p,d-=v,u-=f,m-=D.r,p-=D.g,v-=D.b,f-=D.a,o=i+((o=n+t+1)<w?o:w)<<2,s+=z+=D.r=L[o],h+=g+=D.g=L[o+1],d+=y+=D.b=L[o+2],u+=M+=D.a=L[o+3],D=D.next,m+=E=P.r,p+=b=P.g,v+=H=P.b,f+=V=P.a,z-=E,g-=b,y-=H,M-=V,P=P.next,l+=4;i+=x}for(n=0;n<x;n++){for(g=y=M=z=h=d=u=s=0,m=O*(E=L[l=n<<2]),p=O*(b=L[l+1]),v=O*(H=L[l+2]),f=O*(V=L[l+3]),s+=A*E,h+=A*b,d+=A*H,u+=A*V,_=R,r=0;r<O;r++)_.r=E,_.g=b,_.b=H,_.a=V,_=_.next;for(c=x,r=1;r<=t;r++)l=c+n<<2,s+=(_.r=E=L[l])*(C=O-r),h+=(_.g=b=L[l+1])*C,d+=(_.b=H=L[l+2])*C,u+=(_.a=V=L[l+3])*C,z+=E,g+=b,y+=H,M+=V,_=_.next,r<T&&(c+=x);for(l=n,D=R,P=N,a=0;a<S;a++)L[3+(o=l<<2)]=V=u*F>>I,V>0?(V=255/V,L[o]=(s*F>>I)*V,L[o+1]=(h*F>>I)*V,L[o+2]=(d*F>>I)*V):L[o]=L[o+1]=L[o+2]=0,s-=m,h-=p,d-=v,u-=f,m-=D.r,p-=D.g,v-=D.b,f-=D.a,o=n+((o=a+O)<T?o:T)*x<<2,s+=z+=D.r=L[o],h+=g+=D.g=L[o+1],d+=y+=D.b=L[o+2],u+=M+=D.a=L[o+3],D=D.next,m+=E=P.r,p+=b=P.g,v+=H=P.b,f+=V=P.a,z-=E,g-=b,y-=H,M-=V,P=P.next,l+=x}}(e,t)},Brighten:function(e){var t,n=255*this.brightness(),a=e.data,r=a.length;for(t=0;t<r;t+=4)a[t]+=n,a[t+1]+=n,a[t+2]+=n},Contrast:function(e){var t,n=Math.pow((this.contrast()+100)/100,2),a=e.data,r=a.length,o=150,c=150,l=150;for(t=0;t<r;t+=4)o=a[t],c=a[t+1],l=a[t+2],o/=255,o-=.5,o*=n,o+=.5,c/=255,c-=.5,c*=n,c+=.5,l/=255,l-=.5,l*=n,l+=.5,o=(o*=255)<0?0:o>255?255:o,c=(c*=255)<0?0:c>255?255:c,l=(l*=255)<0?0:l>255?255:l,a[t]=o,a[t+1]=c,a[t+2]=l},Emboss:function(e){var t=10*this.embossStrength(),n=255*this.embossWhiteLevel(),a=this.embossDirection(),r=this.embossBlend(),o=0,c=0,l=e.data,i=e.width,s=e.height,h=4*i,d=s;switch(a){case"top-left":o=-1,c=-1;break;case"top":o=-1,c=0;break;case"top-right":o=-1,c=1;break;case"right":o=0,c=1;break;case"bottom-right":o=1,c=1;break;case"bottom":o=1,c=0;break;case"bottom-left":o=1,c=-1;break;case"left":o=0,c=-1;break;default:ose.error("Unknown emboss direction: "+a)}do{var u=(d-1)*h,m=o;d+m<1&&(m=0),d+m>s&&(m=0);var p=(d-1+m)*i*4,v=i;do{var f=u+4*(v-1),z=c;v+z<1&&(z=0),v+z>i&&(z=0);var g=p+4*(v-1+z),y=l[f]-l[g],M=l[f+1]-l[g+1],E=l[f+2]-l[g+2],b=y,H=b>0?b:-b;if((M>0?M:-M)>H&&(b=M),(E>0?E:-E)>H&&(b=E),b*=t,r){var V=l[f]+b,C=l[f+1]+b,L=l[f+2]+b;l[f]=V>255?255:V<0?0:V,l[f+1]=C>255?255:C<0?0:C,l[f+2]=L>255?255:L<0?0:L}else{var x=n-b;x<0?x=0:x>255&&(x=255),l[f]=l[f+1]=l[f+2]=x}}while(--v)}while(--d)},Enhance:function(e){var t,n,a,r,o=e.data,c=o.length,l=o[0],i=l,s=o[1],h=s,d=o[2],u=d,m=this.enhance();if(0!==m){for(r=0;r<c;r+=4)(t=o[r+0])<l?l=t:t>i&&(i=t),(n=o[r+1])<s?s=n:n>h&&(h=n),(a=o[r+2])<d?d=a:a>u&&(u=a);var p,v,f,z,g,y,M,E,b;for(i===l&&(i=255,l=0),h===s&&(h=255,s=0),u===d&&(u=255,d=0),m>0?(v=i+m*(255-i),f=l-m*(l-0),g=h+m*(255-h),y=s-m*(s-0),E=u+m*(255-u),b=d-m*(d-0)):(v=i+m*(i-(p=.5*(i+l))),f=l+m*(l-p),g=h+m*(h-(z=.5*(h+s))),y=s+m*(s-z),E=u+m*(u-(M=.5*(u+d))),b=d+m*(d-M)),r=0;r<c;r+=4)o[r+0]=qde(o[r+0],l,i,f,v),o[r+1]=qde(o[r+1],s,h,y,g),o[r+2]=qde(o[r+2],d,u,b,E)}},Grayscale:function(e){var t,n,a=e.data,r=a.length;for(t=0;t<r;t+=4)n=.34*a[t]+.5*a[t+1]+.16*a[t+2],a[t]=n,a[t+1]=n,a[t+2]=n},HSL:function(e){var t,n,a,r,o,c=e.data,l=c.length,i=Math.pow(2,this.saturation()),s=Math.abs(this.hue()+360)%360,h=127*this.luminance(),d=1*i*Math.cos(s*Math.PI/180),u=1*i*Math.sin(s*Math.PI/180),m=.299+.701*d+.167*u,p=.587-.587*d+.33*u,v=.114-.114*d-.497*u,f=.299-.299*d-.328*u,z=.587+.413*d+.035*u,g=.114-.114*d+.293*u,y=.299-.3*d+1.25*u,M=.587-.586*d-1.05*u,E=.114+.886*d-.2*u;for(t=0;t<l;t+=4)n=c[t+0],a=c[t+1],r=c[t+2],o=c[t+3],c[t+0]=m*n+p*a+v*r+h,c[t+1]=f*n+z*a+g*r+h,c[t+2]=y*n+M*a+E*r+h,c[t+3]=o},HSV:function(e){var t,n,a,r,o,c=e.data,l=c.length,i=Math.pow(2,this.value()),s=Math.pow(2,this.saturation()),h=Math.abs(this.hue()+360)%360,d=i*s*Math.cos(h*Math.PI/180),u=i*s*Math.sin(h*Math.PI/180),m=.299*i+.701*d+.167*u,p=.587*i-.587*d+.33*u,v=.114*i-.114*d-.497*u,f=.299*i-.299*d-.328*u,z=.587*i+.413*d+.035*u,g=.114*i-.114*d+.293*u,y=.299*i-.3*d+1.25*u,M=.587*i-.586*d-1.05*u,E=.114*i+.886*d-.2*u;for(t=0;t<l;t+=4)n=c[t+0],a=c[t+1],r=c[t+2],o=c[t+3],c[t+0]=m*n+p*a+v*r,c[t+1]=f*n+z*a+g*r,c[t+2]=y*n+M*a+E*r,c[t+3]=o},Invert:function(e){var t,n=e.data,a=n.length;for(t=0;t<a;t+=4)n[t]=255-n[t],n[t+1]=255-n[t+1],n[t+2]=255-n[t+2]},Kaleidoscope:function(e){var t,n,a,r,o,c,l,i,s,h=e.width,d=e.height,u=Math.round(this.kaleidoscopePower()),m=Math.round(this.kaleidoscopeAngle()),p=Math.floor(h*(m%360)/360);if(!(u<1)){var v=ose.createCanvasElement();v.width=h,v.height=d;var f=v.getContext("2d").getImageData(0,0,h,d);ose.releaseCanvas(v),function(e,t,n){var a,r,o,c,l=e.data,i=t.data,s=e.width,h=e.height,d=n.polarCenterX||s/2,u=n.polarCenterY||h/2,m=0,p=0,v=0,f=0,z=Math.sqrt(d*d+u*u);r=s-d,o=h-u,z=(c=Math.sqrt(r*r+o*o))>z?c:z;var g,y,M,E,b=h,H=s,V=360/H*Math.PI/180;for(y=0;y<H;y+=1)for(M=Math.sin(y*V),E=Math.cos(y*V),g=0;g<b;g+=1)r=Math.floor(d+z*g/b*E),m=l[0+(a=4*((o=Math.floor(u+z*g/b*M))*s+r))],p=l[a+1],v=l[a+2],f=l[a+3],i[0+(a=4*(y+g*s))]=m,i[a+1]=p,i[a+2]=v,i[a+3]=f}(e,f,{polarCenterX:h/2,polarCenterY:d/2});for(var z=h/Math.pow(2,u);z<=8;)z*=2,u-=1;var g=z=Math.ceil(z),y=0,M=g,E=1;for(p+z>h&&(y=g,M=0,E=-1),n=0;n<d;n+=1)for(t=y;t!==M;t+=E)i=4*(h*n+Math.round(t+p)%h),r=f.data[i+0],o=f.data[i+1],c=f.data[i+2],l=f.data[i+3],s=4*(h*n+t),f.data[s+0]=r,f.data[s+1]=o,f.data[s+2]=c,f.data[s+3]=l;for(n=0;n<d;n+=1)for(g=Math.floor(z),a=0;a<u;a+=1){for(t=0;t<g+1;t+=1)i=4*(h*n+t),r=f.data[i+0],o=f.data[i+1],c=f.data[i+2],l=f.data[i+3],s=4*(h*n+2*g-t-1),f.data[s+0]=r,f.data[s+1]=o,f.data[s+2]=c,f.data[s+3]=l;g*=2}!function(e,t,n){var a,r,o,c,l,i,s=e.data,h=t.data,d=e.width,u=e.height,m=n.polarCenterX||d/2,p=n.polarCenterY||u/2,v=0,f=0,z=0,g=0,y=Math.sqrt(m*m+p*p);r=d-m,o=u-p,y=(i=Math.sqrt(r*r+o*o))>y?i:y;var M,E,b,H=u,V=d,C=n.polarRotation||0;for(r=0;r<d;r+=1)for(o=0;o<u;o+=1)c=r-m,l=o-p,M=Math.sqrt(c*c+l*l)*H/y,E=(E=(180*Math.atan2(l,c)/Math.PI+360+C)%360)*V/360,b=Math.floor(E),v=s[0+(a=4*(Math.floor(M)*d+b))],f=s[a+1],z=s[a+2],g=s[a+3],h[0+(a=4*(o*d+r))]=v,h[a+1]=f,h[a+2]=z,h[a+3]=g}(f,e,{polarRotation:0})}},Mask:function(e){var t=function(e,t){var n=Gde(e,0,0),a=Gde(e,e.width-1,0),r=Gde(e,0,e.height-1),o=Gde(e,e.width-1,e.height-1),c=t||10;if(Yde(n,a)<c&&Yde(a,o)<c&&Yde(o,r)<c&&Yde(r,n)<c){for(var l=function(e){for(var t=[0,0,0],n=0;n<e.length;n++)t[0]+=e[n][0],t[1]+=e[n][1],t[2]+=e[n][2];return t[0]/=e.length,t[1]/=e.length,t[2]/=e.length,t}([a,n,o,r]),i=[],s=0;s<e.width*e.height;s++){var h=Yde(l,[e.data[4*s],e.data[4*s+1],e.data[4*s+2]]);i[s]=h<c?0:255}return i}}(e,this.threshold());return t&&function(e,t){for(var n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}(e,t=function(e,t,n){for(var a=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],r=Math.round(Math.sqrt(a.length)),o=Math.floor(r/2),c=[],l=0;l<n;l++)for(var i=0;i<t;i++){for(var s=l*t+i,h=0,d=0;d<r;d++)for(var u=0;u<r;u++){var m=l+d-o,p=i+u-o;if(m>=0&&m<n&&p>=0&&p<t){var v=a[d*r+u];h+=e[m*t+p]*v}}c[s]=h}return c}(t=function(e,t,n){for(var a=[1,1,1,1,1,1,1,1,1],r=Math.round(Math.sqrt(a.length)),o=Math.floor(r/2),c=[],l=0;l<n;l++)for(var i=0;i<t;i++){for(var s=l*t+i,h=0,d=0;d<r;d++)for(var u=0;u<r;u++){var m=l+d-o,p=i+u-o;if(m>=0&&m<n&&p>=0&&p<t){var v=a[d*r+u];h+=e[m*t+p]*v}}c[s]=h>=1020?255:0}return c}(t=function(e,t,n){for(var a=[1,1,1,1,0,1,1,1,1],r=Math.round(Math.sqrt(a.length)),o=Math.floor(r/2),c=[],l=0;l<n;l++)for(var i=0;i<t;i++){for(var s=l*t+i,h=0,d=0;d<r;d++)for(var u=0;u<r;u++){var m=l+d-o,p=i+u-o;if(m>=0&&m<n&&p>=0&&p<t){var v=a[d*r+u];h+=e[m*t+p]*v}}c[s]=2040===h?255:0}return c}(t,e.width,e.height),e.width,e.height),e.width,e.height)),e},Noise:function(e){var t,n=255*this.noise(),a=e.data,r=a.length,o=n/2;for(t=0;t<r;t+=4)a[t+0]+=o-2*o*Math.random(),a[t+1]+=o-2*o*Math.random(),a[t+2]+=o-2*o*Math.random()},Pixelate:function(e){var t,n,a,r,o,c,l,i,s,h,d,u,m,p,v=Math.ceil(this.pixelSize()),f=e.width,z=e.height,g=Math.ceil(f/v),y=Math.ceil(z/v),M=e.data;if(v<=0)ose.error("pixelSize value can not be <= 0");else for(u=0;u<g;u+=1)for(m=0;m<y;m+=1){for(r=0,o=0,c=0,l=0,s=(i=u*v)+v,d=(h=m*v)+v,p=0,t=i;t<s;t+=1)if(!(t>=f))for(n=h;n<d;n+=1)n>=z||(r+=M[0+(a=4*(f*n+t))],o+=M[a+1],c+=M[a+2],l+=M[a+3],p+=1);for(r/=p,o/=p,c/=p,l/=p,t=i;t<s;t+=1)if(!(t>=f))for(n=h;n<d;n+=1)n>=z||(M[0+(a=4*(f*n+t))]=r,M[a+1]=o,M[a+2]=c,M[a+3]=l)}},Posterize:function(e){var t,n=Math.round(254*this.levels())+1,a=e.data,r=a.length,o=255/n;for(t=0;t<r;t+=1)a[t]=Math.floor(a[t]/o)*o},RGB:function(e){var t,n,a=e.data,r=a.length,o=this.red(),c=this.green(),l=this.blue();for(t=0;t<r;t+=4)n=(.34*a[t]+.5*a[t+1]+.16*a[t+2])/255,a[t]=n*o,a[t+1]=n*c,a[t+2]=n*l,a[t+3]=a[t+3]},RGBA:function(e){var t,n,a=e.data,r=a.length,o=this.red(),c=this.green(),l=this.blue(),i=this.alpha();for(t=0;t<r;t+=4)n=1-i,a[t]=o*i+a[t]*n,a[t+1]=c*i+a[t+1]*n,a[t+2]=l*i+a[t+2]*n},Sepia:function(e){var t,n,a,r,o=e.data,c=o.length;for(t=0;t<c;t+=4)n=o[t+0],a=o[t+1],r=o[t+2],o[t+0]=Math.min(255,.393*n+.769*a+.189*r),o[t+1]=Math.min(255,.349*n+.686*a+.168*r),o[t+2]=Math.min(255,.272*n+.534*a+.131*r)},Solarize:function(e){var t=e.data,n=e.width,a=4*n,r=e.height;do{var o=(r-1)*a,c=n;do{var l=o+4*(c-1),i=t[l],s=t[l+1],h=t[l+2];i>127&&(i=255-i),s>127&&(s=255-s),h>127&&(h=255-h),t[l]=i,t[l+1]=s,t[l+2]=h}while(--c)}while(--r)},Threshold:function(e){var t,n=255*this.threshold(),a=e.data,r=a.length;for(t=0;t<r;t+=1)a[t]=a[t]<n?0:255}}});var Xde,Qde,Jde={exports:{}},Zde={exports:{}};function eue(){if(Qde)return Xde;Qde=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;return Xde=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var a={};return"abcdefghijklmnopqrst".split("").forEach((function(e){a[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},a)).join("")}catch(e){return!1}}()?Object.assign:function(a,r){for(var o,c,l=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(a),i=1;i<arguments.length;i++){for(var s in o=Object(arguments[i]))t.call(o,s)&&(l[s]=o[s]);if(e){c=e(o);for(var h=0;h<c.length;h++)n.call(o,c[h])&&(l[c[h]]=o[c[h]])}}return l},Xde}var tue,nue,aue,rue,oue={exports:{}},cue={},lue={};function iue(){return aue||(aue=1,"production"===Vee.env.NODE_ENV?oue.exports=(tue||(tue=1,function(e){var t,n,a,r;if("object"==typeof performance&&"function"==typeof performance.now){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,l=c.now();e.unstable_now=function(){return c.now()-l}}if("undefined"==typeof window||"function"!=typeof MessageChannel){var i=null,s=null,h=function(){if(null!==i)try{var t=e.unstable_now();i(!0,t),i=null}catch(e){throw setTimeout(h,0),e}};t=function(e){null!==i?setTimeout(t,0,e):(i=e,setTimeout(h,0))},n=function(e,t){s=setTimeout(e,t)},a=function(){clearTimeout(s)},e.unstable_shouldYield=function(){return!1},r=e.unstable_forceFrameRate=function(){}}else{var d=window.setTimeout,u=window.clearTimeout;if("undefined"!=typeof console){var m=window.cancelAnimationFrame;"function"!=typeof window.requestAnimationFrame&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"),"function"!=typeof m&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills")}var p=!1,v=null,f=-1,z=5,g=0;e.unstable_shouldYield=function(){return e.unstable_now()>=g},r=function(){},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):z=0<e?Math.floor(1e3/e):5};var y=new MessageChannel,M=y.port2;y.port1.onmessage=function(){if(null!==v){var t=e.unstable_now();g=t+z;try{v(!0,t)?M.postMessage(null):(p=!1,v=null)}catch(e){throw M.postMessage(null),e}}else p=!1},t=function(e){v=e,p||(p=!0,M.postMessage(null))},n=function(t,n){f=d((function(){t(e.unstable_now())}),n)},a=function(){u(f),f=-1}}function E(e,t){var n=e.length;e.push(t);e:for(;;){var a=n-1>>>1,r=e[a];if(!(void 0!==r&&0<V(r,t)))break e;e[a]=t,e[n]=r,n=a}}function b(e){return void 0===(e=e[0])?null:e}function H(e){var t=e[0];if(void 0!==t){var n=e.pop();if(n!==t){e[0]=n;e:for(var a=0,r=e.length;a<r;){var o=2*(a+1)-1,c=e[o],l=o+1,i=e[l];if(void 0!==c&&0>V(c,n))void 0!==i&&0>V(i,c)?(e[a]=i,e[l]=n,a=l):(e[a]=c,e[o]=n,a=o);else{if(!(void 0!==i&&0>V(i,n)))break e;e[a]=i,e[l]=n,a=l}}}return t}return null}function V(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}var C=[],L=[],x=1,S=null,k=3,w=!1,T=!1,O=!1;function A(e){for(var t=b(L);null!==t;){if(null===t.callback)H(L);else{if(!(t.startTime<=e))break;H(L),t.sortIndex=t.expirationTime,E(C,t)}t=b(L)}}function R(e){if(O=!1,A(e),!T)if(null!==b(C))T=!0,t(N);else{var a=b(L);null!==a&&n(R,a.startTime-e)}}function N(t,r){T=!1,O&&(O=!1,a()),w=!0;var o=k;try{for(A(r),S=b(C);null!==S&&(!(S.expirationTime>r)||t&&!e.unstable_shouldYield());){var c=S.callback;if("function"==typeof c){S.callback=null,k=S.priorityLevel;var l=c(S.expirationTime<=r);r=e.unstable_now(),"function"==typeof l?S.callback=l:S===b(C)&&H(C),A(r)}else H(C);S=b(C)}if(null!==S)var i=!0;else{var s=b(L);null!==s&&n(R,s.startTime-r),i=!1}return i}finally{S=null,k=o,w=!1}}var _=r;e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_continueExecution=function(){T||w||(T=!0,t(N))},e.unstable_getCurrentPriorityLevel=function(){return k},e.unstable_getFirstCallbackNode=function(){return b(C)},e.unstable_next=function(e){switch(k){case 1:case 2:case 3:var t=3;break;default:t=k}var n=k;k=t;try{return e()}finally{k=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=_,e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=k;k=e;try{return t()}finally{k=n}},e.unstable_scheduleCallback=function(r,o,c){var l=e.unstable_now();switch(c="object"==typeof c&&null!==c&&"number"==typeof(c=c.delay)&&0<c?l+c:l,r){case 1:var i=-1;break;case 2:i=250;break;case 5:i=1073741823;break;case 4:i=1e4;break;default:i=5e3}return r={id:x++,callback:o,priorityLevel:r,startTime:c,expirationTime:i=c+i,sortIndex:-1},c>l?(r.sortIndex=c,E(L,r),null===b(C)&&r===b(L)&&(O?a():O=!0,n(R,c-l))):(r.sortIndex=i,E(C,r),T||w||(T=!0,t(N))),r},e.unstable_wrapCallback=function(e){var t=k;return function(){var n=k;k=t;try{return e.apply(this,arguments)}finally{k=n}}}}(cue)),cue):oue.exports=function(){return nue||(nue=1,e=lue,"production"!==Vee.env.NODE_ENV&&function(){var t,n,a,r;if("object"==typeof performance&&"function"==typeof performance.now){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,l=c.now();e.unstable_now=function(){return c.now()-l}}if("undefined"==typeof window||"function"!=typeof MessageChannel){var i=null,s=null,h=function(){if(null!==i)try{var t=e.unstable_now();i(!0,t),i=null}catch(e){throw setTimeout(h,0),e}};t=function(e){null!==i?setTimeout(t,0,e):(i=e,setTimeout(h,0))},n=function(e,t){s=setTimeout(e,t)},a=function(){clearTimeout(s)},e.unstable_shouldYield=function(){return!1},r=e.unstable_forceFrameRate=function(){}}else{var d=window.setTimeout,u=window.clearTimeout;if("undefined"!=typeof console){var m=window.requestAnimationFrame,p=window.cancelAnimationFrame;"function"!=typeof m&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"),"function"!=typeof p&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills")}var v=!1,f=null,z=-1,g=5,y=0;e.unstable_shouldYield=function(){return e.unstable_now()>=y},r=function(){},e.unstable_forceFrameRate=function(e){e<0||e>125?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):g=e>0?Math.floor(1e3/e):5};var M=new MessageChannel,E=M.port2;M.port1.onmessage=function(){if(null!==f){var t=e.unstable_now();y=t+g;try{f(!0,t)?E.postMessage(null):(v=!1,f=null)}catch(e){throw E.postMessage(null),e}}else v=!1},t=function(e){f=e,v||(v=!0,E.postMessage(null))},n=function(t,n){z=d((function(){t(e.unstable_now())}),n)},a=function(){u(z),z=-1}}function b(e,t){var n=e.length;e.push(t),function(e,t,n){for(var a=n;;){var r=a-1>>>1,o=e[r];if(!(void 0!==o&&C(o,t)>0))return;e[r]=t,e[a]=o,a=r}}(e,t,n)}function H(e){var t=e[0];return void 0===t?null:t}function V(e){var t=e[0];if(void 0!==t){var n=e.pop();return n!==t&&(e[0]=n,function(e,t){for(var n=0,a=e.length;n<a;){var r=2*(n+1)-1,o=e[r],c=r+1,l=e[c];if(void 0!==o&&C(o,t)<0)void 0!==l&&C(l,o)<0?(e[n]=l,e[c]=t,n=c):(e[n]=o,e[r]=t,n=r);else{if(!(void 0!==l&&C(l,t)<0))return;e[n]=l,e[c]=t,n=c}}}(e,n)),t}return null}function C(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}var L=[],x=[],S=1,k=null,w=3,T=!1,O=!1,A=!1;function R(e){for(var t=H(x);null!==t;){if(null===t.callback)V(x);else{if(!(t.startTime<=e))return;V(x),t.sortIndex=t.expirationTime,b(L,t)}t=H(x)}}function N(e){if(A=!1,R(e),!O)if(null!==H(L))O=!0,t(_);else{var a=H(x);null!==a&&n(N,a.startTime-e)}}function _(t,r){O=!1,A&&(A=!1,a()),T=!0;var o=w;try{return function(t,a){var r=a;for(R(r),k=H(L);null!==k&&(!(k.expirationTime>r)||t&&!e.unstable_shouldYield());){var o=k.callback;if("function"==typeof o){k.callback=null,w=k.priorityLevel;var c=o(k.expirationTime<=r);r=e.unstable_now(),"function"==typeof c?k.callback=c:k===H(L)&&V(L),R(r)}else V(L);k=H(L)}if(null!==k)return!0;var l=H(x);return null!==l&&n(N,l.startTime-r),!1}(t,r)}finally{k=null,w=o,T=!1}}var D=r;e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_continueExecution=function(){O||T||(O=!0,t(_))},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_getFirstCallbackNode=function(){return H(L)},e.unstable_next=function(e){var t;switch(w){case 1:case 2:case 3:t=3;break;default:t=w}var n=w;w=t;try{return e()}finally{w=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=D,e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=w;w=e;try{return t()}finally{w=n}},e.unstable_scheduleCallback=function(r,o,c){var l,i,s=e.unstable_now();if("object"==typeof c&&null!==c){var h=c.delay;l="number"==typeof h&&h>0?s+h:s}else l=s;switch(r){case 1:i=-1;break;case 2:i=250;break;case 5:i=1073741823;break;case 4:i=1e4;break;default:i=5e3}var d=l+i,u={id:S++,callback:o,priorityLevel:r,startTime:l,expirationTime:d,sortIndex:-1};return l>s?(u.sortIndex=l,b(x,u),null===H(L)&&u===H(x)&&(A?a():A=!0,n(N,l-s))):(u.sortIndex=d,b(L,u),O||T||(O=!0,t(_))),u},e.unstable_wrapCallback=function(e){var t=w;return function(){var n=w;w=t;try{return e.apply(this,arguments)}finally{w=n}}}}()),lue;var e}()),oue.exports}
302
302
  /** @license React v0.26.2
303
303
  * react-reconciler.production.min.js
304
304
  *