openlearn-next 0.4.2 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/README.md +26 -21
  2. package/cli-data.mjs +535 -40
  3. package/cli-doctor.mjs +456 -17
  4. package/cli.mjs +214 -12
  5. package/dist/assets/AcademicYearFilter-DUUGpDKt.js +1 -0
  6. package/dist/assets/ActivityWorkspaceWidget-5PzyxF6a.js +1 -0
  7. package/dist/assets/AdminDirectoryView-BCtmQTEK.js +5 -0
  8. package/dist/assets/AssessmentCenter-B43ojHG-.js +1 -0
  9. package/dist/assets/BatchPickerModal-CbmjInp7.js +1 -0
  10. package/dist/assets/ClassesView-DEnMaDOt.js +32 -0
  11. package/dist/assets/ClassroomCountdownWidget-CHq4983w.js +2 -0
  12. package/dist/assets/CloudDriveModal-D2t3Uyzr.js +1 -0
  13. package/dist/assets/ComputerLabView-YtnoT5Rb.js +1 -0
  14. package/dist/assets/CourseManagement-DOXyJ_j-.js +1 -0
  15. package/dist/assets/CourseWizardModal-Dbi6Caw2.js +3 -0
  16. package/dist/assets/CoursewareHubPanel-CyxDIJAF.js +1 -0
  17. package/dist/assets/Dashboard-2rLu_ZBy.js +8 -0
  18. package/dist/assets/ExportWeightModal-BrmAh6VX.js +1 -0
  19. package/dist/assets/GLTFLoader-CZJbo_y1.js +1 -0
  20. package/dist/assets/HelpTour-D_q1z_MI.js +1 -0
  21. package/dist/assets/HelpView-CVBrKDrd.js +204 -0
  22. package/dist/assets/ImportLessonsModal-PhHtX31R.js +1 -0
  23. package/dist/assets/ImportModal-DqjqNeH4.js +2 -0
  24. package/dist/assets/InteractiveCoursewareViewer-Vi6lLz7a.js +1 -0
  25. package/dist/assets/InteractiveWhiteboard-lTzeayX5.js +65 -0
  26. package/dist/assets/LazyCourseware-KIt0rGtW.js +2 -0
  27. package/dist/assets/LazyWhiteboard-CCN3pYcW.js +2 -0
  28. package/dist/assets/LessonEditorView-D_GVhHuM.js +1 -0
  29. package/dist/assets/LiveClassroomView-BRsZ6QEq.js +61 -0
  30. package/dist/assets/NotificationDetailModal-tY5rxYCN.js +1 -0
  31. package/dist/assets/OrbitControls-CQjN_uwS.js +1 -0
  32. package/dist/assets/PluginView-CedpAW6d.js +77 -0
  33. package/dist/assets/ProcessLogsModal-Cfr-T9Gd.js +1 -0
  34. package/dist/assets/QuizGeneratorModal-bUA002kP.js +1 -0
  35. package/dist/assets/StudentAssignmentView-BhAz6Hfk.js +1 -0
  36. package/dist/assets/StudentLessonView-DC1yX4kG.js +1 -0
  37. package/dist/assets/StudentView-PHKxIV9T.js +2 -0
  38. package/dist/assets/SystemResourceLibraryModal-DgXYe6_x.js +1 -0
  39. package/dist/assets/TeacherView-DscJtOJ9.js +2 -0
  40. package/dist/assets/TimetableView-D2ozoj_D.js +6 -0
  41. package/dist/assets/UTIF-FfCsrHhe.js +1 -0
  42. package/dist/assets/__vite-optional-peer-dep_ai_ooxml-ui-BIHI7g3E.js +1 -0
  43. package/dist/assets/browser-DEI0QxZC.js +1 -0
  44. package/dist/assets/html2canvas-pro.esm-Bo50djkB.js +12 -0
  45. package/dist/assets/index-2676X8YB.js +131 -0
  46. package/dist/assets/index-C6hlh8pw.css +1 -0
  47. package/dist/assets/{index.es-C5eWEO4o.js → index.es-DyEF0CZ9.js} +1 -1
  48. package/dist/assets/pluginParsers-e4PSm2Iy.js +1 -0
  49. package/dist/assets/react_pptx-react-viewer-BIHI7g3E.js +1 -0
  50. package/dist/assets/teaching-modes-client-BeVaDdJ-.js +1 -0
  51. package/dist/assets/three.module-iOYB3rD4.js +4228 -0
  52. package/dist/assets/timeline-duration-BgdJCSrW.js +1 -0
  53. package/dist/assets/{vendor-charts-qLbgF1eL.js → vendor-charts-SrpBsvM3.js} +2 -2
  54. package/dist/assets/{vendor-icons-BRmhY6fg.js → vendor-icons-CXrZ3R2V.js} +2 -2
  55. package/dist/assets/{vendor-konva-CEOq4dcl.js → vendor-konva-Dne0Z-WC.js} +1 -1
  56. package/dist/assets/{vendor-pdf-D7rGevI1.js → vendor-pdf-C1Vh2Aqq.js} +56 -56
  57. package/dist/assets/vendor-pptx-Bzn6whfK.js +11311 -0
  58. package/dist/assets/vendor-pptx-DIWdXF1L.css +1 -0
  59. package/dist/assets/{vendor-react-B0t7H3hh.js → vendor-react-Kv_JATwr.js} +1 -1
  60. package/dist/assets/vendor-utils-aM7aYvPP.js +1 -0
  61. package/dist/cli-migrator.cjs +310 -0
  62. package/dist/env-validation.cjs +351 -0
  63. package/dist/index.html +13 -10
  64. package/dist/plugin-net-preload.cjs +263 -0
  65. package/dist/server.cjs +51140 -27229
  66. package/migrations/000_initial_schema.sql +410 -0
  67. package/migrations/001_add_execution_mode.sql +6 -0
  68. package/migrations/002_add_client_session_expiry.sql +6 -0
  69. package/migrations/003_classroom_runtime.sql +33 -0
  70. package/migrations/004_courseware_score_config.sql +26 -0
  71. package/migrations/005_assignment_hub.sql +155 -0
  72. package/migrations/006_classroom_event_bus.sql +28 -0
  73. package/migrations/007_interactive_classroom.sql +119 -0
  74. package/migrations/008_teaching_modes.sql +36 -0
  75. package/migrations/009_classroom_peer_review.sql +159 -0
  76. package/migrations/010_class_groups.sql +33 -0
  77. package/migrations/011_classroom_feed.sql +34 -0
  78. package/migrations/012_auto_record_score.sql +48 -0
  79. package/migrations/013_score_source_strategy.sql +81 -0
  80. package/migrations/014_performance_indexes.sql +21 -0
  81. package/migrations/015_demo_data_registry.sql +26 -0
  82. package/migrations/016_preset_polls_and_passcode_expiry.sql +33 -0
  83. package/migrations/017_pacing_signals_segment.sql +6 -0
  84. package/migrations/018_processes_plugin_owner.sql +26 -0
  85. package/migrations/019_plugins_version.sql +61 -0
  86. package/migrations/020_upload_max_file_mb.sql +14 -0
  87. package/migrations/021_class_owner_and_password_gate.sql +11 -0
  88. package/migrations/022_plugin_public_routes.sql +14 -0
  89. package/migrations/023_encrypt_class_passcodes.sql +18 -0
  90. package/migrations/024_segment_gates.sql +37 -0
  91. package/migrations/025_assignment_lookup_indexes.sql +11 -0
  92. package/migrations/026_plugin_grants.sql +21 -0
  93. package/migrations/027_academic_year.sql +26 -0
  94. package/migrations/028_classroom_indexes.sql +14 -0
  95. package/migrations/029_clean_lesson_think_artifacts.sql +13 -0
  96. package/migrations/030_backfill_academic_year.sql +30 -0
  97. package/migrations/031_assessment_core.sql +158 -0
  98. package/migrations/032_progress_verification.sql +17 -0
  99. package/migrations/033_student_lock_mode.sql +9 -0
  100. package/migrations/034_plugin_orphan_data.sql +27 -0
  101. package/migrations/035_icebreaker_checkins.sql +26 -0
  102. package/migrations/036_student_read_notifications_created_at.sql +19 -0
  103. package/migrations/037_plugin_config_scopes.sql +40 -0
  104. package/migrations/038_assessment_ai_grading_suggestion.sql +10 -0
  105. package/migrations/039_question_bank_sharing_and_papers.sql +14 -0
  106. package/migrations/040_assignment_grade_history.sql +37 -0
  107. package/migrations/041_course_package_idempotency.sql +33 -0
  108. package/migrations/042_assignment_grade_resubmit_audit.sql +12 -0
  109. package/migrations/043_mark_sha256_passwords.sql +31 -0
  110. package/migrations/README.md +61 -0
  111. package/migrations/schema-golden.json +640 -0
  112. package/package.json +54 -28
  113. package/dist/assets/AdminDirectoryView-DY--WM5Z.js +0 -1
  114. package/dist/assets/BatchPickerModal-BpWu0Lil.js +0 -1
  115. package/dist/assets/ClassesView-KbHEqJto.js +0 -22
  116. package/dist/assets/ClassroomCountdownWidget-96WFRO9A.js +0 -2
  117. package/dist/assets/CloudDriveModal-DEQ1nkNk.js +0 -1
  118. package/dist/assets/ComputerLabView-1qWDNRQ2.js +0 -1
  119. package/dist/assets/CourseManagement-D3ZpxY0l.js +0 -1
  120. package/dist/assets/CourseWizardModal-Ck_-M8pk.js +0 -3
  121. package/dist/assets/CoursewareHubPanel-CaEizhxl.js +0 -1
  122. package/dist/assets/Dashboard-CYbpbofV.js +0 -8
  123. package/dist/assets/ExportWeightModal-DW2bu9Zz.js +0 -1
  124. package/dist/assets/HelpTour-CMJbbGne.js +0 -1
  125. package/dist/assets/HelpView-CtzdqhBq.js +0 -204
  126. package/dist/assets/ImportLessonsModal-jBuIK453.js +0 -1
  127. package/dist/assets/ImportModal-D7L-KNhZ.js +0 -1
  128. package/dist/assets/InteractiveCoursewareViewer-Bj7ahXMs.js +0 -1
  129. package/dist/assets/InteractiveWhiteboard-B7JcJvDu.js +0 -77
  130. package/dist/assets/LazyCourseware-CuiPxhDg.js +0 -2
  131. package/dist/assets/LazyWhiteboard-BJwCEZAU.js +0 -2
  132. package/dist/assets/LessonEditorView-DFrOp2qp.js +0 -1
  133. package/dist/assets/LiveClassroomView-BZ5nGee3.js +0 -59
  134. package/dist/assets/NotificationDetailModal-Baqnc5pU.js +0 -1
  135. package/dist/assets/PluginView-CCbIuZ24.js +0 -66
  136. package/dist/assets/ProcessLogsModal-DmFXg9mG.js +0 -1
  137. package/dist/assets/QuizGeneratorModal-BBEDssp7.js +0 -1
  138. package/dist/assets/StudentAssignmentView-DgIjUsXz.js +0 -1
  139. package/dist/assets/StudentLessonView-CBJbI5x6.js +0 -1
  140. package/dist/assets/StudentPreviewModal-Bh8OZs0t.js +0 -1
  141. package/dist/assets/StudentView--uGxc5TJ.js +0 -2
  142. package/dist/assets/SystemResourceLibraryModal-BVCclcqA.js +0 -1
  143. package/dist/assets/TeacherView-D4Zsc0eZ.js +0 -2
  144. package/dist/assets/TimetableView-BQG-rEb5.js +0 -6
  145. package/dist/assets/index-BKBCBKvy.js +0 -217
  146. package/dist/assets/index-CvGu7LSj.css +0 -1
  147. package/dist/assets/purify.es-CYR4BTuT.js +0 -3
  148. package/dist/assets/vendor-pptx-C5-U7ieS.js +0 -39
  149. package/dist/assets/vendor-utils-m0Urvtws.js +0 -1
@@ -0,0 +1,12 @@
1
+ /*!
2
+ * html2canvas-pro 2.5.2 <https://yorickshan.github.io/html2canvas-pro/>
3
+ * Copyright (c) 2024-present yorickshan and html2canvas-pro contributors
4
+ * Released under MIT License
5
+ */var qo=class dr{window;cspNonce;cache;constructor(e={}){const r=e.window||(typeof window<"u"?window:void 0);if(!r)throw new Error("Window object is required but not available");this.window=r,this.cspNonce=e.cspNonce,this.cache=e.cache}static fromElement(e,r={}){const n=e.ownerDocument;if(!n)throw new Error("Element is not attached to a document");const o=n.defaultView;if(!o)throw new Error("Document is not attached to a window");return new dr({window:o,...r})}clone(e={}){return new dr({window:e.window||this.window,cspNonce:e.cspNonce??this.cspNonce,cache:e.cache??this.cache})}},Qo=class{config;constructor(t={}){this.config={maxImageTimeout:3e5,allowDataUrls:!0,...t}}validateUrl(t,e="general"){if(!t||typeof t!="string")return{valid:!1,error:"URL must be a non-empty string"};if(t.startsWith("data:"))return this.config.allowDataUrls?{valid:!0,sanitized:t}:{valid:!1,error:"Data URLs are not allowed"};if(t.startsWith("blob:"))return{valid:!0,sanitized:t};try{const r=new URL(t);if(!["http:","https:"].includes(r.protocol))return{valid:!1,error:`Protocol ${r.protocol} is not allowed. Only http and https are permitted.`};if(e==="proxy"&&this.config.allowedProxyDomains&&this.config.allowedProxyDomains.length>0){const n=r.hostname.toLowerCase();if(!this.config.allowedProxyDomains.some(o=>{const s=o.toLowerCase();return n===s||n.endsWith("."+s)}))return{valid:!1,error:`Proxy domain ${r.hostname} is not in the allowed list`}}if(e==="proxy"){if(!this.config.allowLocalhostProxy){const n=r.hostname.toLowerCase();if(n==="localhost"||n==="127.0.0.1"||n==="::1")return{valid:!1,error:"Localhost is not allowed for proxy URLs"};if(this.isPrivateIP(n))return{valid:!1,error:"Private IP addresses are not allowed for proxy URLs"};if(n.startsWith("169.254.")||n.startsWith("fe80:"))return{valid:!1,error:"Link-local addresses are not allowed for proxy URLs"}}return{valid:!0,sanitized:t}}return{valid:!0,sanitized:t}}catch(r){return{valid:!1,error:`Invalid URL format: ${r instanceof Error?r.message:"Unknown error"}`}}}isPrivateIP(t){return[/^0\./,/^10\./,/^100\.(6[4-9]|[7-9][0-9]|1[0-1][0-9]|12[0-7])\./,/^127\./,/^169\.254\./,/^172\.(1[6-9]|2[0-9]|3[0-1])\./,/^192\.0\.0\./,/^192\.0\.2\./,/^192\.168\./,/^198\.(1[8-9])\./,/^198\.51\.100\./,/^203\.0\.113\./,/^2(2[4-9]|3[0-9])\./,/^24[0-9]\./,/^255\.255\.255\.255$/].some(e=>e.test(t))?!0:t.includes(":")?this.isPrivateIPv6(t):!1}isPrivateIPv6(t){const e=t.toLowerCase().trim().replace(/^\[|\]$/g,""),r=e.split("%")[0]??e;if(/^(0:){7}1$/.test(r)||r==="::1"||/^(0:){7}0$/.test(r)||r==="::")return!0;const n=this.expandIPv6(r);if(!n)return this.isPrivateIPv6Prefix(r);const o=parseInt(n.substring(0,2),16);if(o>=252&&o<=253)return!0;if(o===254){const s=parseInt(n.substring(2,4),16);if(s>=128&&s<=191)return!0}return o===255}expandIPv6(t){try{if(t.includes("::")){const e=t.split("::");if(e.length>2)return null;const r=e[0]?e[0].split(":"):[],n=e[1]?e[1].split(":"):[],o=8-r.length-n.length;if(o<0)return null;const s=Array(o).fill("0000");return[...r,...s,...n].map(i=>i.padStart(4,"0")).join(":")}else{const e=t.split(":");return e.length!==8?null:e.map(r=>r.padStart(4,"0")).join(":")}}catch{return null}}isPrivateIPv6Prefix(t){return!!(/^fc[0-9a-f]{0,2}:?/i.test(t)||/^fd[0-9a-f]{0,2}:?/i.test(t)||/^fe[89ab][0-9a-f]:?/i.test(t)||/^ff[0-9a-f]{0,2}:?/i.test(t))}validateCspNonce(t){return!t||typeof t!="string"?{valid:!1,error:"CSP nonce must be a non-empty string"}:t.length<16?{valid:!1,error:"CSP nonce is too short (minimum 16 characters recommended)"}:/^[A-Za-z0-9+/=_-]+$/.test(t)?{valid:!0,sanitized:t}:{valid:!1,error:"CSP nonce contains invalid characters"}}validateImageTimeout(t){return typeof t!="number"||isNaN(t)?{valid:!1,error:"Image timeout must be a number"}:t<0?{valid:!1,error:"Image timeout cannot be negative"}:this.config.maxImageTimeout&&t>this.config.maxImageTimeout?{valid:!1,error:`Image timeout ${t}ms exceeds maximum allowed ${this.config.maxImageTimeout}ms`}:{valid:!0,sanitized:t}}validateDimensions(t,e){if(typeof t!="number"||typeof e!="number")return{valid:!1,error:"Dimensions must be numbers"};if(isNaN(t)||isNaN(e))return{valid:!1,error:"Dimensions cannot be NaN"};if(t<=0||e<=0)return{valid:!1,error:"Dimensions must be positive"};const r=32767;return t>r||e>r?{valid:!1,error:`Dimensions exceed maximum allowed (${r}px)`}:{valid:!0,sanitized:{width:t,height:e}}}validateScale(t){return typeof t!="number"||isNaN(t)?{valid:!1,error:"Scale must be a number"}:t<=0?{valid:!1,error:"Scale must be positive"}:t>10?{valid:!1,error:"Scale factor too large (maximum 10x)"}:{valid:!0,sanitized:t}}validateElement(t){if(!t)return{valid:!1,error:"Element is required"};if(typeof t!="object")return{valid:!1,error:"Element must be an object"};const e=t;return typeof HTMLElement<"u"&&t instanceof HTMLElement?t.ownerDocument?{valid:!0}:{valid:!1,error:"Element must be attached to a document"}:e.ownerDocument?e.ownerDocument.defaultView?{valid:!0}:{valid:!1,error:"Document must be attached to a window (ownerDocument.defaultView required)"}:{valid:!1,error:"Element must be attached to a document (ownerDocument required)"}}validateOptions(t){const e=[],r=t.proxy;if(r!=null&&typeof r=="string"&&r.length>0){const n=this.validateUrl(r,"proxy");n.valid||e.push(`Proxy: ${n.error}`)}if(t.imageTimeout!==void 0){const n=this.validateImageTimeout(t.imageTimeout);n.valid||e.push(`Image timeout: ${n.error}`)}if(t.width!==void 0||t.height!==void 0){const n=t.width??800,o=t.height??600,s=this.validateDimensions(n,o);s.valid||e.push(`Dimensions: ${s.error}`)}if(t.scale!==void 0){const n=this.validateScale(t.scale);n.valid||e.push(`Scale: ${n.error}`)}if(t.cspNonce!==void 0){const n=this.validateCspNonce(t.cspNonce);n.valid||e.push(`CSP nonce: ${n.error}`)}if(this.config.customValidator){const n=this.config.customValidator(t,"options");n.valid||e.push(`Custom validation: ${n.error}`)}return e.length>0?{valid:!1,error:e.join("; ")}:{valid:!0}}};function Jo(t={}){return new Qo({allowDataUrls:!0,maxImageTimeout:3e5,...t})}var ts=class{context;activeMetrics=new Map;completedMetrics=[];enabled;getTime;constructor(t,e=!0){this.context=t,this.enabled=e,this.getTime=typeof performance<"u"&&typeof performance.now=="function"?()=>performance.now():()=>Date.now()}start(t,e){this.enabled&&(this.activeMetrics.has(t)&&this.context?.logger.warn(`Performance metric '${t}' already started. Overwriting.`),this.activeMetrics.set(t,{name:t,startTime:this.getTime(),metadata:e}))}end(t){if(!this.enabled)return;const e=this.activeMetrics.get(t);if(!e){this.context?.logger.warn(`Performance metric '${t}' not found. Was start() called?`);return}return e.endTime=this.getTime(),e.duration=e.endTime-e.startTime,this.completedMetrics.push(e),this.activeMetrics.delete(t),this.context?.logger.debug(`⏱️ ${t}: ${e.duration.toFixed(2)}ms`,e.metadata),e}measure(t,e,r){this.start(t,r);try{const n=e();return this.end(t),n}catch(n){throw this.end(t),n}}async measureAsync(t,e,r){this.start(t,r);try{const n=await e();return this.end(t),n}catch(n){throw this.end(t),n}}getMetrics(){return[...this.completedMetrics]}getMetric(t){return this.completedMetrics.find(e=>e.name===t)}getSummary(){const t=this.completedMetrics.reduce((r,n)=>r+(n.duration||0),0),e=this.completedMetrics.map(r=>({name:r.name,duration:r.duration||0,percentage:t>0?((r.duration||0)/t*100).toFixed(1)+"%":"0%"}));return{totalDuration:t,metrics:this.getMetrics(),breakdown:e}}logSummary(){if(!this.enabled||this.completedMetrics.length===0||!this.context)return;const t=this.getSummary();this.context.logger.info(`
6
+ 📊 Performance Summary (Total: ${t.totalDuration.toFixed(2)}ms):`),t.breakdown.sort((e,r)=>r.duration-e.duration).forEach(e=>{this.context.logger.info(` ${e.name.padEnd(20)} ${e.duration.toFixed(2).padStart(8)}ms ${e.percentage.padStart(6)}`)})}clear(){this.activeMetrics.clear(),this.completedMetrics.splice(0)}isEnabled(){return this.enabled}getActiveMetrics(){return Array.from(this.activeMetrics.keys())}},W=class Ft{left;top;width;height;constructor(e,r,n,o){this.left=e,this.top=r,this.width=n,this.height=o}add(e,r,n,o){return new Ft(this.left+e,this.top+r,this.width+n,this.height+o)}static fromClientRect(e,r){return new Ft(r.left+e.windowBounds.left,r.top+e.windowBounds.top,r.width,r.height)}static fromDOMRectList(e,r){const n=Array.from(r);let o=n.find(s=>s.width!==0);return o||(o=n.find(s=>s.height!==0)),!o&&n.length>0&&(o=n[0]),o?new Ft(o.left+e.windowBounds.left,o.top+e.windowBounds.top,o.width,o.height):Ft.EMPTY}static EMPTY=new Ft(0,0,0,0)};const le=(t,e)=>W.fromClientRect(t,e.getBoundingClientRect()),es=t=>{const e=t.body,r=t.documentElement;if(!e||!r)throw new Error("Unable to get document size");return new W(0,0,Math.max(Math.max(e.scrollWidth,r.scrollWidth),Math.max(e.offsetWidth,r.offsetWidth),Math.max(e.clientWidth,r.clientWidth)),Math.max(Math.max(e.scrollHeight,r.scrollHeight),Math.max(e.offsetHeight,r.offsetHeight),Math.max(e.clientHeight,r.clientHeight)))},p=(t,e)=>{const r=t[e];if(r===void 0)throw new Error(`Missing element at index ${e}`);return r},Wr=65533,U=t=>t>=48&&t<=57,rs=t=>t>=55296&&t<=57343,kt=t=>U(t)||t>=65&&t<=70||t>=97&&t<=102,ns=t=>t>=97&&t<=122,os=t=>t>=65&&t<=90,ss=t=>ns(t)||os(t),is=t=>t>=128,pe=t=>t===10||t===9||t===32,Be=t=>ss(t)||is(t)||t===95,Vr=t=>Be(t)||U(t)||t===45,as=t=>t>=0&&t<=8||t===11||t>=14&&t<=31||t===127,pt=(t,e)=>t!==92?!1:e!==10,ge=(t,e,r)=>t===45?Be(e)||pt(e,r):Be(t)?!0:!!(t===92&&pt(t,e)),Je=(t,e,r)=>t===43||t===45?U(e)?!0:e===46&&U(r):U(t===46?e:t),ls=t=>{let e=0,r=1;(t[e]===43||t[e]===45)&&(t[e]===45&&(r=-1),e++);const n=[];for(;U(t[e]??NaN);)n.push(p(t,e)),e++;const o=n.length?parseInt(String.fromCodePoint(...n),10):0;t[e]===46&&e++;const s=[];for(;U(t[e]??NaN);)s.push(p(t,e)),e++;const i=s.length,a=i?parseInt(String.fromCodePoint(...s),10):0;(t[e]===69||t[e]===101)&&e++;let l=1;(t[e]===43||t[e]===45)&&(t[e]===45&&(l=-1),e++);const c=[];for(;U(t[e]??NaN);)c.push(p(t,e)),e++;const h=c.length?parseInt(String.fromCodePoint(...c),10):0;return r*(o+a*Math.pow(10,-i))*Math.pow(10,l*h)},cs={type:2},hs={type:3},us={type:4},ds={type:13},fs={type:8},ps={type:21},gs={type:9},ms={type:10},bs={type:11},xs={type:12},ws={type:14},me={type:23},ys={type:1},Cs={type:25},Ss={type:24},Es={type:26},vs={type:27},Rs={type:28},Ts={type:29},Ms={type:31},fr={type:32};var pr=class Wt{static _pool=[];static MAX_POOL_SIZE=40;static get(){return Wt._pool.pop()||new Wt}static release(e){Wt._pool.length<Wt.MAX_POOL_SIZE&&(e._reset(),Wt._pool.push(e))}_value;_cursor;constructor(){this._value=[],this._cursor=0}_reset(){this._value=[],this._cursor=0}write(e){this._cursor>0&&(this._value=this._value.slice(this._cursor),this._cursor=0),this._value=this._value.concat([...e].map(r=>r.codePointAt(0)))}read(){const e=[];let r=this.consumeToken();for(;r!==fr;)e.push(r),r=this.consumeToken();return e}consumeToken(){const e=this.consumeCodePoint();switch(e){case 34:return this.consumeStringToken(34);case 35:{const r=this.peekCodePoint(0),n=this.peekCodePoint(1),o=this.peekCodePoint(2);if(Vr(r)||pt(n,o)){const s=ge(r,n,o)?2:1;return{type:5,value:this.consumeName(),flags:s}}break}case 36:if(this.peekCodePoint(0)===61)return this.consumeCodePoint(),ds;break;case 39:return this.consumeStringToken(39);case 40:return cs;case 41:return hs;case 42:if(this.peekCodePoint(0)===61)return this.consumeCodePoint(),ws;break;case 43:if(Je(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 44:return us;case 45:{const r=e,n=this.peekCodePoint(0),o=this.peekCodePoint(1);if(Je(r,n,o))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(ge(r,n,o))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(n===45&&o===62)return this.consumeCodePoint(),this.consumeCodePoint(),Ss;break}case 46:if(Je(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 47:if(this.peekCodePoint(0)===42)for(this.consumeCodePoint();;){let r=this.consumeCodePoint();if(r===42&&(r=this.consumeCodePoint(),r===47))return this.consumeToken();if(r===-1)return this.consumeToken()}break;case 58:return Es;case 59:return vs;case 60:if(this.peekCodePoint(0)===33&&this.peekCodePoint(1)===45&&this.peekCodePoint(2)===45)return this.consumeCodePoint(),this.consumeCodePoint(),this.consumeCodePoint(),Cs;break;case 64:{const r=this.peekCodePoint(0),n=this.peekCodePoint(1),o=this.peekCodePoint(2);if(ge(r,n,o))return{type:7,value:this.consumeName()};break}case 91:return Rs;case 92:if(pt(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case 93:return Ts;case 94:if(this.peekCodePoint(0)===61)return this.consumeCodePoint(),fs;break;case 123:return bs;case 125:return xs;case 117:case 85:{const r=this.peekCodePoint(0),n=this.peekCodePoint(1);return r===43&&(kt(n)||n===63)?(this.consumeCodePoint(),this.consumeUnicodeRangeToken()):(this.reconsumeCodePoint(e),this.consumeIdentLikeToken())}case 124:if(this.peekCodePoint(0)===61)return this.consumeCodePoint(),gs;if(this.peekCodePoint(0)===124)return this.consumeCodePoint(),ps;break;case 126:if(this.peekCodePoint(0)===61)return this.consumeCodePoint(),ms;break;case-1:return fr}return pe(e)?(this.consumeWhiteSpace(),Ms):U(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):Be(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:String.fromCodePoint(e)}}consumeCodePoint(){const e=this._value[this._cursor];return e===void 0?-1:(this._cursor++,e)}reconsumeCodePoint(e){this._cursor>0&&this._value[this._cursor-1]===e?this._cursor--:this._value.splice(this._cursor,0,e)}peekCodePoint(e){const r=this._value[this._cursor+e];return r!==void 0?r:-1}consumeUnicodeRangeToken(){const e=[];let r=this.consumeCodePoint();for(;kt(r)&&e.length<6;)e.push(r),r=this.consumeCodePoint();let n=!1;for(;r===63&&e.length<6;)e.push(r),r=this.consumeCodePoint(),n=!0;if(n)return{type:30,start:parseInt(String.fromCodePoint(...e.map(s=>s===63?48:s)),16),end:parseInt(String.fromCodePoint(...e.map(s=>s===63?70:s)),16)};const o=parseInt(String.fromCodePoint(...e),16);if(r===45&&kt(this.peekCodePoint(0))){r=this.consumeCodePoint();const s=[];for(;kt(r)&&s.length<6;)s.push(r),r=this.consumeCodePoint();return{type:30,start:o,end:parseInt(String.fromCodePoint(...s),16)}}else return{type:30,start:o,end:o}}consumeIdentLikeToken(){const e=this.consumeName();return e.toLowerCase()==="url"&&this.peekCodePoint(0)===40?(this.consumeCodePoint(),this.consumeUrlToken()):this.peekCodePoint(0)===40?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}}consumeUrlToken(){const e=[];if(this.consumeWhiteSpace(),this.peekCodePoint(0)===-1)return{type:22,value:""};const r=this.peekCodePoint(0);if(r===39||r===34){const n=this.consumeStringToken(this.consumeCodePoint());return n.type===0&&(this.consumeWhiteSpace(),this.peekCodePoint(0)===-1||this.peekCodePoint(0)===41)?(this.consumeCodePoint(),{type:22,value:n.value}):(this.consumeBadUrlRemnants(),me)}for(;;){const n=this.consumeCodePoint();if(n===-1||n===41)return{type:22,value:String.fromCodePoint(...e)};if(pe(n))return this.consumeWhiteSpace(),this.peekCodePoint(0)===-1||this.peekCodePoint(0)===41?(this.consumeCodePoint(),{type:22,value:String.fromCodePoint(...e)}):(this.consumeBadUrlRemnants(),me);if(n===34||n===39||n===40||as(n))return this.consumeBadUrlRemnants(),me;if(n===92)if(pt(n,this.peekCodePoint(0)))e.push(this.consumeEscapedCodePoint());else return this.consumeBadUrlRemnants(),me;else e.push(n)}}consumeWhiteSpace(){for(;pe(this.peekCodePoint(0));)this.consumeCodePoint()}consumeBadUrlRemnants(){for(;;){const e=this.consumeCodePoint();if(e===41||e===-1)return;pt(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}}consumeStringSlice(e){let n="";const o=this._cursor+e;let s=this._cursor;for(;s<o;){const i=Math.min(o,s+5e4);n+=String.fromCodePoint(...this._value.slice(s,i)),s=i}return this._cursor=o+1,n}consumeStringToken(e){let r="",n=0;do{const o=this._value[this._cursor+n];if(o===-1||o===void 0||o===e)return r+=this.consumeStringSlice(n),{type:0,value:r};if(o===10)return this._cursor+=n,ys;if(o===92){const s=this._value[this._cursor+n+1];s!==-1&&s!==void 0&&(s===10?(r+=this.consumeStringSlice(n),n=-1,this._cursor++):pt(o,s)&&(r+=this.consumeStringSlice(n),r+=String.fromCodePoint(this.consumeEscapedCodePoint()),n=-1))}n++}while(!0)}consumeNumber(){const e=[];let r=4,n=this.peekCodePoint(0);for((n===43||n===45)&&e.push(this.consumeCodePoint());U(this.peekCodePoint(0));)e.push(this.consumeCodePoint());n=this.peekCodePoint(0);let o=this.peekCodePoint(1);if(n===46&&U(o))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),r=8;U(this.peekCodePoint(0));)e.push(this.consumeCodePoint());n=this.peekCodePoint(0),o=this.peekCodePoint(1);const s=this.peekCodePoint(2);if((n===69||n===101)&&((o===43||o===45)&&U(s)||U(o)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),r=8;U(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[ls(e),r]}consumeNumericToken(){const[e,r]=this.consumeNumber(),n=this.peekCodePoint(0),o=this.peekCodePoint(1),s=this.peekCodePoint(2);return ge(n,o,s)?{type:15,number:e,flags:r,unit:this.consumeName()}:n===37?(this.consumeCodePoint(),{type:16,number:e,flags:r}):{type:17,number:e,flags:r}}consumeEscapedCodePoint(){const e=this.consumeCodePoint();if(kt(e)){let r=String.fromCodePoint(e);for(;kt(this.peekCodePoint(0))&&r.length<6;)r+=String.fromCodePoint(this.consumeCodePoint());pe(this.peekCodePoint(0))&&this.consumeCodePoint();const n=parseInt(r,16);return n===0||rs(n)||n>1114111?Wr:n}return e===-1?Wr:e}consumeName(){let e="";for(;;){const r=this.consumeCodePoint();if(Vr(r))e+=String.fromCodePoint(r);else if(pt(r,this.peekCodePoint(0)))e+=String.fromCodePoint(this.consumeEscapedCodePoint());else return this.reconsumeCodePoint(r),e}}},kn=class Te{_tokens;constructor(e){this._tokens=e}static create(e){const r=new pr;return r.write(e),new Te(r.read())}static parseValue(e){return Te.create(e).parseComponentValue()}static parseValues(e){return Te.create(e).parseComponentValues()}parseComponentValue(){let e=this.consumeToken();for(;e.type===31;)e=this.consumeToken();if(e.type===32)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(e);const r=this.consumeComponentValue();do e=this.consumeToken();while(e.type===31);if(e.type===32)return r;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")}parseComponentValues(){const e=[];for(;;){const r=this.consumeComponentValue();if(r.type===32)return e;e.push(r)}}consumeComponentValue(){const e=this.consumeToken();switch(e.type){case 11:case 28:case 2:return this.consumeSimpleBlock(e.type);case 19:return this.consumeFunction(e)}return e}consumeSimpleBlock(e){const r={type:e,values:[]};let n=this.consumeToken();for(;;){if(n.type===32||Is(n,e))return r;this.reconsumeToken(n),r.values.push(this.consumeComponentValue()),n=this.consumeToken()}}consumeFunction(e){const r={name:e.value,values:[],type:18};for(;;){const n=this.consumeToken();if(n.type===32||n.type===3)return r;this.reconsumeToken(n),r.values.push(this.consumeComponentValue())}}consumeToken(){const e=this._tokens.shift();return typeof e>"u"?fr:e}reconsumeToken(e){this._tokens.unshift(e)}};const K=t=>t.type===15,D=t=>t.type===17,v=t=>t.type===20,Ls=t=>t.type===0,ce=(t,e)=>v(t)&&t.value===e,Kt=t=>t.type!==31,F=t=>t.type!==31&&t.type!==4,q=t=>{const e=[];let r=[];return t.forEach(n=>{if(n.type===4){r.length&&(e.push(r),r=[]);return}n.type!==31&&r.push(n)}),r.length&&e.push(r),e},Is=(t,e)=>e===11&&t.type===12||e===28&&t.type===29?!0:e===2&&t.type===3,Bs=/(\d+(?:\.\d+)?|[+\-*/()])/g,Pn=t=>{const e=t.match(Bs);if(!e)return NaN;const r=[],n=[],o={"+":1,"-":1,"*":2,"/":2};for(const i of e)if(/^\d+(?:\.\d+)?$/.test(i))r.push(parseFloat(i));else if(i==="(")n.push(i);else if(i===")"){for(;n.length&&n[n.length-1]!=="(";)r.push(n.pop());if(!n.length)return NaN;n.pop()}else{for(;n.length&&(o[p(n,n.length-1)]??0)>=(o[i]??0);)r.push(n.pop());n.push(i)}for(;n.length;){const i=n.pop();if(i==="(")return NaN;r.push(i)}const s=[];for(const i of r)if(typeof i=="number")s.push(i);else{const a=s.pop(),l=s.pop();if(l===void 0||a===void 0)return NaN;switch(i){case"+":s.push(l+a);break;case"-":s.push(l-a);break;case"*":s.push(l*a);break;case"/":s.push(a===0?NaN:l/a);break;default:return NaN}}return s.length===1?s[0]??NaN:NaN},N=(t,e,r)=>Math.min(Math.max(t,e),r),G=(t,e)=>[t[0]*e[0]+t[1]*e[1]+t[2]*e[2],t[3]*e[0]+t[4]*e[1]+t[5]*e[2],t[6]*e[0]+t[7]*e[1]+t[8]*e[2]],ut=t=>G([3.2409699419045226,-1.537383177570094,-.4986107602930034,-.9692436362808796,1.8759675015077202,.04155505740717559,.05563007969699366,-.20397695888897652,1.0569715142428786],t),Br=t=>G([.41239079926595934,.357584339383878,.1804807884018343,.21263900587151027,.715168678767756,.07219231536073371,.01933081871559182,.11919477979462598,.9505321522496607],t),yt=t=>{const[e,r,n]=t,o=s=>{const i=s<0?-1:1,a=Math.abs(s);return a>.0031308?i*(1.055*a**(1/2.4)-.055):12.92*s};return[o(e),o(r),o(n)]},Or=t=>{const[e,r,n]=t,o=s=>{const i=s<0?-1:1,a=Math.abs(s);return a<=.04045?s/12.92:i*((a+.055)/1.055)**2.4};return[o(e),o(r),o(n)]},Os=t=>{const[e,r,n]=yt(ut([t[0],t[1],t[2]]));return[e,r,n,t[3]]},ks=t=>{const[e,r,n]=ut([t[0],t[1],t[2]]);return[N(Math.round(e*255),0,255),N(Math.round(r*255),0,255),N(Math.round(n*255),0,255),t[3]]},xt=t=>t.type===17||t.type===15,I=t=>t.type===16||xt(t)||Dn(t),Dn=t=>t.type===17&&t._calcPercentage!==void 0,Ps=t=>t.type===18&&t.name==="calc",Ds=t=>{const e=zr(t,0);if(!e)return null;const r=zr(t,100);if(!r)return null;const n=e.number,o=r.number-n;return o===0?e:{type:17,number:n,flags:4,_calcPercentage:o,_calcPixelOffset:n}},Nn=t=>Ps(t)?Ds(t):I(t)?t:null,zr=(t,e=0)=>{const r=n=>{let o="";for(const s of n)if(s.type!==31){if(s.type===18)if(s.name==="calc"){const i=r(s.values);if(i===null)return null;o+=`(${i})`}else return null;else if(s.type===17)o+=s.number.toString();else if(s.type===15)s.unit==="px"?o+=s.number.toString():s.unit==="rem"||s.unit==="em"?o+=(s.number*16).toString():o+=s.number.toString();else if(s.type===16)o+=(s.number/100*e).toString();else if(s.type===6){const i=s.value;i==="+"||i==="-"||i==="*"||i==="/"?o+=` ${i} `:i==="("?o+="(":i===")"&&(o+=")")}}return o};try{const n=r(t.values);if(n===null||n.trim()==="")return null;const o=Pn(n);if(typeof o=="number"&&!isNaN(o))return{type:17,number:o,flags:4}}catch{return null}return null},_n=t=>t.length>1?[p(t,0),p(t,1)]:[p(t,0)],k={type:17,number:0,flags:4},Y={type:16,number:50,flags:4},j={type:16,number:100,flags:4},te=(t,e,r)=>{const[n,o]=t;return[S(n,e),S(typeof o<"u"?o:n,r)]},S=(t,e)=>{if(Dn(t))return t._calcPercentage/100*e+t._calcPixelOffset;if(t.type===16)return t.number/100*e;if(K(t))switch(t.unit){case"rem":case"em":return 16*t.number;default:return t.number}return t.number},An="deg",Fn="grad",Wn="rad",Vn="turn",Bt={name:"angle",parse:(t,e)=>{if(e.type===15)switch(e.unit){case An:return Math.PI*e.number/180;case Fn:return Math.PI/200*e.number;case Wn:return e.number;case Vn:return Math.PI*2*e.number}throw new Error("Unsupported angle type")}},zn=t=>t.type===15&&(t.unit===An||t.unit===Fn||t.unit===Wn||t.unit===Vn),Un=t=>{switch(t.filter(v).map(e=>e.value).join(" ")){case"to bottom right":case"to right bottom":case"left top":case"top left":return[k,k];case"to top":case"bottom":return J(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[k,j];case"to right":case"left":return J(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[j,j];case"to bottom":case"top":return J(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[j,k];case"to left":case"right":return J(270)}return 0},J=t=>Math.PI*t/180,ot=t=>(255&t)===0,L=t=>{const e=255&t,r=255&t>>8,n=255&t>>16,o=255&t>>24;return e<255?`rgba(${o},${n},${r},${e/255})`:`rgb(${o},${n},${r})`},lt=(t,e,r,n)=>(t<<24|e<<16|r<<8|Math.round(n*255)<<0)>>>0,Q=(t,e)=>{if(t.type===17)return t.number;if(t.type===16){const r=e===3?1:255;return e===3?t.number/100*r:Math.round(t.number/100*r)}return 0},Ot=t=>{const e=t[0];return(e&&e.type===20?e.value:"unknown")==="from"},Oe=t=>lt(N(Math.round(t[0]*255),0,255),N(Math.round(t[1]*255),0,255),N(Math.round(t[2]*255),0,255),N(t[3],0,1)),Ue=t=>{const[e,r,n,o]=t,s=yt([e,r,n]);return lt(N(Math.round(s[0]*255),0,255),N(Math.round(s[1]*255),0,255),N(Math.round(s[2]*255),0,255),o)},It=t=>{const e=ut([t[0],t[1],t[2]]);return Ue([e[0],e[1],e[2],t[3]])},Ns=(t,e)=>{if(Ot(e.filter(F)))throw new Error("Relative color not supported for lab()");const[r,n,o,s]=$e(e),i=_s(e)?r*100:r,a=yt(ut(Yt([i,n,o])));return lt(N(Math.round(a[0]*255),0,255),N(Math.round(a[1]*255),0,255),N(Math.round(a[2]*255),0,255),s)},_s=t=>{const e=t.filter(F)[0];return e!==void 0&&e.type===16},As=(t,e)=>{if(Ot(e.filter(F)))throw new Error("Relative color not supported for oklab()");const[r,n,o,s]=$e(e),i=yt(ut(Ht([r,n,o])));return lt(N(Math.round(i[0]*255),0,255),N(Math.round(i[1]*255),0,255),N(Math.round(i[2]*255),0,255),s)},Fs=(t,e)=>{if(Ot(e.filter(F)))throw new Error("Relative color not supported for oklch()");const[r,n,o,s]=Hn(e),i=yt(ut(Ht(Gt([r,n,o]))));return lt(N(Math.round(i[0]*255),0,255),N(Math.round(i[1]*255),0,255),N(Math.round(i[2]*255),0,255),s)},Ws=(t,e)=>{if(Ot(e.filter(F)))throw new Error("Relative color not supported for lch()");const[r,n,o,s]=Gn(e),i=yt(ut(Yt(Gt([r,n,o]))));return lt(N(Math.round(i[0]*255),0,255),N(Math.round(i[1]*255),0,255),N(Math.round(i[2]*255),0,255),s)},$n=(t,e)=>{const r=e.filter(F),n=r[0],o=r[1],s=r[2],i=r[3],a=i!==void 0&&i.type===6&&i.value==="/"?r[4]:r[3];return[n?(n.type===17?J(n.number):Bt.parse(t,n))/(Math.PI*2):0,o!==void 0&&I(o)?o.number/100:0,s!==void 0&&I(s)?s.number/100:0,a!==void 0&&I(a)?S(a,1):1]},Ur=(t,e)=>{if(Ot(e))throw new Error("Relative color not supported for hsl()");const[r,n,o,s]=$n(t,e),i=kr([r,n,o]);return lt(i[0]*255,i[1]*255,i[2]*255,s)},Gn=t=>{const e=t.filter(F),r=e[0],n=e[1],o=e[2],s=e[4];return[r!==void 0&&I(r)?r.number:0,n!==void 0&&I(n)?n.number:0,o!==void 0&&(D(o)||K(o))?o.number:0,s!==void 0&&I(s)?S(s,1):1]},$e=t=>{const e=t.filter(F),r=e[0],n=e[1],o=e[2],s=e[4];return[r!==void 0?r.type===16?r.number/100:D(r)?r.number:0:0,n!==void 0?n.type===16?n.number/100:D(n)?n.number:0:0,o!==void 0&&(D(o)||K(o))?o.number:0,s!==void 0&&I(s)?S(s,1):1]},Hn=t=>{const e=t.filter(F),r=e[0],n=e[1],o=e[2],s=e[4];return[r!==void 0?r.type===16?r.number/100:D(r)?r.number:0:0,n!==void 0?n.type===16?n.number/100:D(n)?n.number:0:0,o!==void 0&&(D(o)||K(o))?o.number:0,s!==void 0&&I(s)?S(s,1):1]},Ge=t=>G([1.0479297925449969,.022946870601609652,-.05019226628920524,.02962780877005599,.9904344267538799,-.017073799063418826,-.009243040646204504,.015055191490298152,.7518742814281371],t),He=t=>G([.955473421488075,-.02309845494876471,.06325924320057072,-.0283697093338637,1.0099953980813041,.021041441191917323,.012314014864481998,-.020507649298898964,1.330365926242124],t),tr=(t,e,r)=>(r<0&&(r+=1),r>=1&&(r-=1),r<1/6?(e-t)*r*6+t:r<1/2?e:r<2/3?(e-t)*6*(2/3-r)+t:t),kr=([t,e,r])=>{if(e===0)return[r,r,r];const n=r<=.5?r*(e+1):r+e-r*e,o=r*2-n;return[tr(o,n,t+1/3),tr(o,n,t),tr(o,n,t-1/3)]},Gt=([t,e,r])=>(e<0&&(e=0),isNaN(r)&&(r=0),[t,e*Math.cos(r*Math.PI/180),e*Math.sin(r*Math.PI/180)]),Ht=t=>{const e=G([1,.3963377773761749,.2158037573099136,1,-.1055613458156586,-.0638541728258133,1,-.0894841775298119,-1.2914855480194092],t),r=[e[0]**3,e[1]**3,e[2]**3];return G([1.2268798758459243,-.5578149944602171,.2813910456659647,-.0405757452148008,1.112286803280317,-.0717110580655164,-.0763729366746601,-.4214933324022432,1.5869240198367816],r)},Yt=t=>{const e=(t[0]+16)/116,r=t[1]/500+e,n=e-t[2]/200,o=24389/27,s=24/116,i=[(r>s?r**3:(116*r-16)/o)*.3457/.3585,t[0]>8?e**3:t[0]/o,(n>s?n**3:(116*n-16)/o)*.2958/.3585];return He([i[0],i[1],i[2]])},Vs=(t,e)=>{const r=e.filter(F);if(r.length===3||r.length===4){const n=Q(p(r,0),0),o=Q(p(r,1),1),s=Q(p(r,2),2),i=r.length===4?Q(p(r,3),3):1,a=Or([n/255,o/255,s/255]),[l,c,h]=Br([a[0],a[1],a[2]]);return[l,c,h,i]}return[0,0,0,1]},zs=(t,e)=>{const[r,n,o,s]=$n(t,e),i=Or(kr([r,n,o])),[a,l,c]=Br([i[0],i[1],i[2]]);return[a,l,c,s]},Us=(t,e)=>{const[r,n,o,s]=$e(e),[i,a,l]=Yt([r,n,o]);return[i,a,l,s]},$s=(t,e)=>{const[r,n,o,s]=Gn(e),[i,a,l]=Yt(Gt([r,n,o]));return[i,a,l,s]},Gs=(t,e)=>{const[r,n,o,s]=Hn(e),[i,a,l]=Ht(Gt([r,n,o]));return[i,a,l,s]},Hs=(t,e)=>{const[r,n,o,s]=$e(e),[i,a,l]=Ht([r,n,o]);return[i,a,l,s]},Ys=t=>He([t[0],t[1],t[2]]),$r=t=>t,Xs=t=>{const[e,r,n]=Ge([t[0],t[2],t[3]]);return[e,r,n,t[3]]},Gr=t=>It([t[0],t[1],t[2],t[3]]),Ks=t=>{const e=Ys([t[0],t[1],t[2]]);return It([e[0],e[1],e[2],t[3]])},js=t=>G([.4865709486482162,.26566769316909306,.1982172852343625,.2289745640697488,.6917385218365064,.079286914093745,0,.04511338185890264,1.043944368900976],t),Zs=t=>G([2.493496911941425,-.9313836179191239,-.40271078445071684,-.8294889695615747,1.7626640603183463,.023624685841943577,.03584583024378447,-.07617238926804182,.9568845240076872],t),qs=t=>{const e=r=>{const n=r<0?-1:1;return r*n<=.04045?r/12.92:n*((r+.055)/1.055)**2.4||0};return[e(t[0]),e(t[1]),e(t[2])]},Qs=t=>yt(t),Js=t=>{const e=qs([t[0],t[1],t[2]]);return js([e[0],e[1],e[2]])},ti=t=>{const[e,r,n]=Qs(Zs([t[0],t[1],t[2]]));return[e,r,n,t[3]]},ei=t=>{const e=Js([t[0],t[1],t[2]]);return It([e[0],e[1],e[2],t[3]])},ri=t=>G([2.0415879038107465,-.5650069742788596,-.34473135077832956,-.9692436362808795,1.8759675015077202,.04155505740717557,.013444280632031142,-.11836239223101838,1.0151749943912054],t),ni=t=>G([.5766690429101305,.1855582379065463,.1882286462349947,.29734497525053605,.6273635662554661,.0752914584939978,.02703136138641234,.07068885253582723,.9913375368376388],t),oi=t=>{const e=t.map(r=>(r<0?-1:1)*Math.abs(r)**2.19921875);return[e[0]??0,e[1]??0,e[2]??0]},si=t=>{const e=t.map(r=>(r<0?-1:1)*Math.abs(r)**.4547069271758437);return[e[0]??0,e[1]??0,e[2]??0]},ii=t=>{const[e,r,n]=si(ri([t[0],t[1],t[2]]));return[e,r,n,t[3]]},ai=t=>{const e=ut(ni(oi([t[0],t[1],t[2]])));return Ue([e[0],e[1],e[2],t[3]])},li=t=>G([.7977666449006423,.13518129740053308,.0313477341283922,.2880748288194013,.711835234241873,8993693872564e-17,0,0,.8251046025104602],t),ci=t=>G([1.3457868816471583,-.25557208737979464,-.05110186497554526,-.5446307051249019,1.5082477428451468,.02052744743642139,0,0,1.2119675456389452],t),hi=t=>{const[e,r,n]=t,o=s=>s<16/512?s/16:s**1.8;return[o(e),o(r),o(n)]},ui=t=>{const[e,r,n]=t,o=s=>s>1/512?s**(1/1.8):s*16;return[o(e),o(r),o(n)]},di=t=>{const e=hi([t[0],t[1],t[2]]);return He(li([e[0],e[1],e[2]]))},fi=t=>{const[e,r,n]=ui(ci(Ge([t[0],t[1],t[2]])));return[e,r,n,t[3]]},pi=t=>{const e=di([t[0],t[1],t[2]]);return It([e[0],e[1],e[2],t[3]])},gr=1.09929682680944,Yn=.018053968510807,gi=t=>{const e=r=>r<Yn*4.5?r/4.5:Math.pow((r+gr-1)/gr,2.2222222222222223);return[e(t[0]),e(t[1]),e(t[2])]},mi=t=>{const e=r=>r>=Yn?gr*Math.pow(r,.45)-.09929682680944008:4.5*r;return[e(t[0]),e(t[1]),e(t[2])]},bi=t=>G([.6369580483012914,.14461690358620832,.1688809751641721,.2627002120112671,.6779980715188708,.05930171646986196,0,.028072693049087428,1.060985057710791],t),xi=t=>G([1.716651187971268,-.355670783776392,-.25336628137366,-.666684351832489,1.616481236634939,.0157685458139111,.017639857445311,-.042770613257809,.942103121235474],t),wi=t=>{const e=gi([t[0],t[1],t[2]]);return bi([e[0],e[1],e[2]])},yi=t=>{const[e,r,n]=mi(xi([t[0],t[1],t[2]]));return[e,r,n,t[3]]},Ci=t=>{const e=wi([t[0],t[1],t[2]]);return It([e[0],e[1],e[2],t[3]])},Si={lch:2,oklch:2,hsl:0},Ei=[1.2268798758459243,-.5578149944602171,.2813910456659647,-.0405757452148008,1.112286803280317,-.0717110580655164,-.0763729366746601,-.4214933324022432,1.5869240198367816],vi=[1,.3963377773761749,.2158037573099136,1,-.1055613458156586,-.0638541728258133,1,-.0894841775298119,-1.2914855480194092],Xn=t=>{const e=t[0],r=t[1],n=t[2],o=t[3],s=t[4],i=t[5],a=t[6],l=t[7],c=t[8],h=e*(s*c-i*l)-r*(o*c-i*a)+n*(o*l-s*a);return[(s*c-i*l)/h,(n*l-r*c)/h,(r*i-n*s)/h,(i*a-o*c)/h,(e*c-n*a)/h,(n*o-e*i)/h,(o*l-s*a)/h,(r*a-e*l)/h,(e*s-r*o)/h]},Ri=Xn(Ei),Ti=Xn(vi),er=24389/27,rr=24/116,nr=rr*rr*rr,Mi=.3457/.3585,Li=.2958/.3585,Ii=t=>[(255&t>>24)/255,(255&t>>16)/255,(255&t>>8)/255],Hr=t=>{const[e,r,n]=Ge([t[0],t[1],t[2]]),o=e/Mi,s=r,i=n/Li,a=o>nr?Math.cbrt(o):(er*o+16)/116,l=s>nr?Math.cbrt(s):(er*s+16)/116,c=i>nr?Math.cbrt(i):(er*i+16)/116;return[116*l-16,500*(a-l),200*(l-c)]},Yr=t=>{const e=G(Ri,t),r=[Math.cbrt(e[0]),Math.cbrt(e[1]),Math.cbrt(e[2])];return G(Ti,r)},Xr=t=>{const e=Math.hypot(t[1],t[2]),r=Math.atan2(t[2],t[1])*180/Math.PI;return[t[0],e,(r+360)%360]},or=t=>{const e=t[0],r=t[1],n=t[2],o=Math.max(e,r,n),s=Math.min(e,r,n),i=(o+s)/2;if(o===s)return[0,0,i];const a=o-s,l=i>.5?a/(2-o-s):a/(o+s);let c;return o===e?c=((r-n)/a+(r<n?6:0))/6:o===r?c=((n-e)/a+2)/6:c=((e-r)/a+4)/6,[c,l,i]},Kr=(t,e)=>{const r=(255&t)/255,n=Ii(t),o=Or(n),s=Br(o);let i;switch(e){case"srgb":i=n;break;case"srgb-linear":i=o;break;case"xyz":case"xyz-d65":i=s;break;case"xyz-d50":i=Ge(s);break;case"lab":i=Hr(s);break;case"oklab":i=Yr(s);break;case"lch":i=Xr(Hr(s));break;case"oklch":i=Xr(Yr(s));break;case"hsl":i=[or(n)[0]*360,or(n)[1],or(n)[2]]}return[i[0],i[1],i[2],r]},Bi=(t,e)=>{const r=t[0],n=t[1],o=t[2],s=t[3];switch(e){case"srgb":return Oe([r,n,o,s]);case"srgb-linear":return Ue([r,n,o,s]);case"xyz":case"xyz-d65":return It([r,n,o,s]);case"xyz-d50":return It([...He([r,n,o]),s]);case"lab":return be(Yt([r,n,o]),s);case"oklab":return be(Ht([r,n,o]),s);case"lch":return be(Yt(Gt([r,n,o])),s);case"oklch":return be(Ht(Gt([r,n,o])),s);case"hsl":{const i=kr([r/360,n,o]);return Oe([i[0],i[1],i[2],s])}}},be=(t,e)=>{const r=yt(ut(t));return Oe([r[0],r[1],r[2],e])},Oi=(t,e,r,n,o="shorter")=>{const s=r+n;if(s===0)return t;let i=((e-t)%360+360)%360;switch(o){case"shorter":i>180&&(i-=360);break;case"longer":i<180&&(i-=360);break;case"increasing":break;case"decreasing":i>0&&(i-=360)}return t+i*(n/s)},jr=(t,e)=>{let r,n=null;for(const s of e)if(!(s.type===31||s.type===4))if(s.type===16)n=s.number;else if(v(s)&&s.value==="none")n===null&&(n=0);else if(r===void 0)r=s;else throw new Error("Unexpected token in color-mix() component");if(r===void 0)throw new Error("color-mix() component is missing a color");const o=r;return{color:Z.parse(t,o),percentage:n}},ki=["srgb","srgb-linear","lab","oklab","lch","oklch","hsl","xyz","xyz-d50","xyz-d65"],Pi=(t,e,r,n,o,s)=>{const i=Si[o],a=[t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]],l=[e[0]*e[3],e[1]*e[3],e[2]*e[3],e[3]],c=r*a[3]+n*l[3];if(c<=0)return[0,0,0,0];const h=[0,0,0,c];for(let u=0;u<3;u++)u!==i&&(h[u]=(r*p(a,u)+n*p(l,u))/c);if(i!==void 0){let u=p(t,i),d=p(e,i);t[1]===0&&(u=d),e[1]===0&&(d=u),h[i]=Oi(u,d,r,n,s)}return h},Di=(t,e)=>{const r=[[]];for(const y of e)y.type===4?r.push([]):r[r.length-1].push(y);const n=r.map(y=>y.filter(R=>R.type!==31));if(n.length!==3)throw new Error("color-mix() requires exactly two color components");const o=n[0],s=o?o[0]:void 0,i=s!==void 0&&v(s)&&s.value==="in";if(!o||o.length<2||!i)throw new Error("color-mix() requires an interpolation space after `in`");const a=o[1];if(!a||!v(a))throw new Error("color-mix() space must be an identifier");const l=a.value;if(ki.indexOf(l)===-1)throw new Error(`Unsupported color-mix() interpolation space "${l}"`);let c="shorter";const h=o.slice(2);if(h.length>0){const y=h[0],R=h[1];if(!y||!R||!v(y)||!v(R)||R.value!=="hue")throw new Error("Unsupported color-mix() hue method syntax");if(["shorter","longer","increasing","decreasing"].indexOf(y.value)===-1)throw new Error(`Unsupported color-mix() hue method "${y.value}"`);c=y.value}const u=n[1],d=n[2];if(!u||!d)throw new Error("color-mix() requires exactly two color components");const f=jr(t,u),g=jr(t,d);let m=f.percentage,b=g.percentage;if(m===null&&b===null)m=50,b=50;else if(m===null)m=100-(b??0);else if(b===null)b=100-m;else{const y=m+b;y>0&&(m=m/y*100,b=b/y*100)}const x=(m??0)/100,C=(b??0)/100,w=Pi(Kr(f.color,l),Kr(g.color,l),x,C,l,c);return Bi(w,l)},Ni=(t,e)=>{try{return Di(t,e)}catch(r){return t.logger.warn(`Unsupported color-mix() value: ${r instanceof Error?r.message:r}`),0}},Z={name:"color",parse:(t,e)=>{if(e.type===18){const r=Wi[e.name];if(typeof r>"u")throw new Error(`Attempting to parse an unsupported color function "${e.name}"`);return r(t,e.values)}if(e.type===5){const[r,n,o,s]=Kn(e);return lt(r,n,o,s)}if(e.type===20){const r=jn[e.value.toUpperCase()];if(typeof r<"u")return r}return 0}},Kn=t=>{if(t.value.length===3){const e=t.value.substring(0,1),r=t.value.substring(1,2),n=t.value.substring(2,3);return[parseInt(e+e,16),parseInt(r+r,16),parseInt(n+n,16),1]}if(t.value.length===4){const e=t.value.substring(0,1),r=t.value.substring(1,2),n=t.value.substring(2,3),o=t.value.substring(3,4);return[parseInt(e+e,16),parseInt(r+r,16),parseInt(n+n,16),parseInt(o+o,16)/255]}if(t.value.length===6){const e=t.value.substring(0,2),r=t.value.substring(2,4),n=t.value.substring(4,6);return[parseInt(e,16),parseInt(r,16),parseInt(n,16),1]}if(t.value.length===8){const e=t.value.substring(0,2),r=t.value.substring(2,4),n=t.value.substring(4,6),o=t.value.substring(6,8);return[parseInt(e,16),parseInt(r,16),parseInt(n,16),parseInt(o,16)/255]}return[0,0,0,1]},Zr=(t,e)=>{const r=e.filter(F);if(Ot(r))throw new Error("Relative color not supported for rgb()");if(r.length===3||r.length===4){const n=Q(p(r,0),0),o=Q(p(r,1),1),s=Q(p(r,2),2),i=r.length===4?Q(p(r,3),3):1;return lt(n,o,s,i)}if(r.length===5){const n=p(r,3);if(n.type===6&&n.value==="/"){const o=Q(p(r,0),0),s=Q(p(r,1),1),i=Q(p(r,2),2),a=Q(p(r,4),3);return lt(o,s,i,a)}}return 0},_i=(t,e)=>{const r=e.filter(F),n=r[0],o=n&&n.type===20?n.value:"unknown";if(Ot(r)){const s=(R,M)=>{if(D(M))return M.number;const B=z=>z==="r"||z==="x"?0:z==="g"||z==="y"?1:2;if(v(M)){const z=B(M.value);return p(R,z)}const T=z=>{const dt=z.filter(F);let ft="(";for(const et of dt)ft+=et.type===18&&et.name==="calc"?T(et.values):D(et)?et.number:et.type===6||v(et)?et.value:"";return ft+=")",ft};if(M.type===18){const z=M.values.filter(F);if(M.name==="calc"){const dt=T(z).replace(/r|x/,R[0].toString()).replace(/g|y/,R[1].toString()).replace(/b|z/,R[2].toString());return Pn(dt)}}return null},i=p(r,1),a=i.type===18?i.name:v(i)||i.type===5?"rgb":"unknown",l=p(r,2),c=v(l)?l.value:"unknown";let h=i.type===18?i.values:v(i)?[i]:[];if(v(i)){if(typeof jn[i.value.toUpperCase()]>"u")throw new Error("Attempting to use unknown color in relative color 'from'");{const R=Ut(t,i.value),M=255&R,B=255&R>>8,T=255&R>>16;h=[{type:17,number:255&R>>24,flags:1},{type:17,number:T,flags:1},{type:17,number:B,flags:1},{type:17,number:M>1?M/255:M,flags:1}]}}else if(i.type===5){const[R,M,B,T]=Kn(i);h=[{type:17,number:R,flags:1},{type:17,number:M,flags:1},{type:17,number:B,flags:1},{type:17,number:T>1?T/255:T,flags:1}]}if(h.length===0)throw new Error("Attempting to use unknown color in relative color 'from'");if(c==="unknown")throw new Error("Attempting to use unknown colorspace in relative color 'to'");const u=Ai[a],d=Fi[c],f=qr[c];if(typeof u>"u")throw new Error(`Attempting to parse an unsupported color space "${a}" for color() function`);if(typeof d>"u")throw new Error(`Attempting to parse an unsupported color space "${c}" for color() function`);const g=d(u(t,h)),m=s(g,p(r,3)),b=s(g,p(r,4)),x=s(g,p(r,5)),C=r[6],w=r[7],y=C!==void 0&&C.type===6&&C.value==="/"&&w!==void 0&&D(w)?w.number:1;if(m===null||b===null||x===null)throw new Error("Invalid relative color in color() function");if(typeof f>"u")throw new Error(`Attempting to parse an unsupported color space "${c}" for color() function`);return f([m,b,x,y])}else{const s=o,i=qr[s];if(typeof i>"u")throw new Error(`Attempting to parse an unsupported color space "${s}" for color() function`);const a=p(r,1),l=p(r,2),c=p(r,3),h=r[4],u=r[5];return i([D(a)?a.number:0,D(l)?l.number:0,D(c)?c.number:0,h!==void 0&&h.type===6&&h.value==="/"&&u!==void 0&&D(u)?u.number:1])}},qr={srgb:Oe,"srgb-linear":Ue,"display-p3":ei,"a98-rgb":ai,"prophoto-rgb":pi,xyz:Gr,"xyz-d50":Ks,"xyz-d65":Gr,rec2020:Ci},Ai={rgb:Vs,hsl:zs,lab:Us,lch:$s,oklab:Hs,oklch:Gs},Fi={srgb:Os,"srgb-linear":ks,"display-p3":ti,"a98-rgb":ii,"prophoto-rgb":fi,xyz:$r,"xyz-d50":Xs,"xyz-d65":$r,rec2020:yi},Wi={hsl:Ur,hsla:Ur,rgb:Zr,rgba:Zr,lch:Ws,oklch:Fs,oklab:As,lab:Ns,color:_i,"color-mix":Ni},Ut=(t,e)=>Z.parse(t,kn.create(e).parseComponentValue()),jn={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},Tt=t=>t.nodeType===Node.ELEMENT_NODE,Zn=t=>t.nodeType===Node.TEXT_NODE,it=t=>typeof t.className=="object",he=t=>Tt(t)&&typeof t.style<"u"&&!it(t),Vi=t=>t.tagName==="INPUT",zi=t=>t.tagName==="HTML",qn=t=>t.tagName==="svg",Pr=t=>t.tagName==="BODY",Qn=t=>t.tagName==="CANVAS",Qr=t=>t.tagName==="VIDEO",mr=t=>t.tagName==="IMG",Jn=t=>t.tagName==="IFRAME",to=t=>t.tagName==="STYLE",Ui=t=>t.tagName==="SCRIPT",ke=t=>t.tagName==="TEXTAREA",Pe=t=>t.tagName==="SELECT",ee=t=>t.tagName==="SLOT",$i=t=>t.tagName==="LI",Gi=t=>t.tagName==="OL",Jr=t=>!it(t)&&t.tagName.indexOf("-")>0,Hi=new Set(["IMG","VIDEO","AUDIO","CANVAS","IFRAME","INPUT","TEXTAREA","SELECT","BR","HR","META","LINK","BASE","COL","SOURCE","TRACK","WBR","AREA","PARAM","EMBED","OBJECT"]),Yi=t=>!it(t)&&!Hi.has(t.tagName),br={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:(t,e)=>{switch(e){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":return 22;case"hebrew":return 52;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;default:return-1}}},V=(t,e)=>(t&e)!==0;var Xi=class{counters={};getCounterValue(t){const e=this.counters[t];return e&&e.length?p(e,e.length-1):1}getCounterValues(t){const e=this.counters[t];return e||[]}pop(t){t.forEach(e=>this.counters[e]?.pop())}parse(t){const e=t.counterIncrement,r=t.counterReset;let n=!0;e!==null&&e.forEach(s=>{const i=this.counters[s.counter];if(i&&s.increment!==0){n=!1,i.length||i.push(1);const a=Math.max(0,i.length-1);i[a]=(i[a]??0)+s.increment}});const o=[];return n&&r.forEach(s=>{let i=this.counters[s.counter];o.push(s.counter),i||(i=this.counters[s.counter]=[]),i.push(s.reset)}),o}};const tn={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},en={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["Ք","Փ","Ւ","Ց","Ր","Տ","Վ","Ս","Ռ","Ջ","Պ","Չ","Ո","Շ","Ն","Յ","Մ","Ճ","Ղ","Ձ","Հ","Կ","Ծ","Խ","Լ","Ի","Ժ","Թ","Ը","Է","Զ","Ե","Դ","Գ","Բ","Ա"]},Ki={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["י׳","ט׳","ח׳","ז׳","ו׳","ה׳","ד׳","ג׳","ב׳","א׳","ת","ש","ר","ק","צ","פ","ע","ס","נ","מ","ל","כ","יט","יח","יז","טז","טו","י","ט","ח","ז","ו","ה","ד","ג","ב","א"]},ji={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["ჵ","ჰ","ჯ","ჴ","ხ","ჭ","წ","ძ","ც","ჩ","შ","ყ","ღ","ქ","ფ","ჳ","ტ","ს","რ","ჟ","პ","ო","ჲ","ნ","მ","ლ","კ","ი","თ","ჱ","ზ","ვ","ე","დ","გ","ბ","ა"]},Pt=(t,e,r,n,o,s)=>t<e||t>r?ue(t,o,s.length>0):n.integers.reduce((i,a,l)=>{for(;t>=a;)t-=a,i+=n.values[l];return i},"")+s,eo=(t,e,r,n)=>{let o="";do r||t--,o=n(t)+o,t/=e;while(t*e>=e);return o},_=(t,e,r,n,o)=>{const s=r-e+1;return(t<0?"-":"")+(eo(Math.abs(t),s,n,i=>String.fromCodePoint(Math.floor(i%s)+e))+o)},Ct=(t,e,r=". ")=>{const n=e.length;return eo(Math.abs(t),n,!1,o=>String(e[Math.floor(o%n)]))+r},Zi=1,qi=2,Qi=4,Ji=8,ht=(t,e,r,n,o,s)=>{if(t<-9999||t>9999)return ue(t,4,o.length>0);let i=Math.abs(t),a=o;if(i===0)return e[0]+a;for(let l=0;i>0&&l<=4;l++){const c=i%10;c===0&&V(s,Zi)&&a!==""?a=e[c]+a:c>1||c===1&&l===0||c===1&&l===1&&V(s,qi)||c===1&&l===1&&V(s,Qi)&&t>100||c===1&&l>1&&V(s,Ji)?a=(e[c]??"")+(l>0?r[l-1]??"":"")+a:c===1&&l>0&&(a=(r[l-1]??"")+a),i=Math.floor(i/10)}return(t<0?n:"")+a},rn="十百千萬",nn="拾佰仟萬",on="マイナス",sr="마이너스",ue=(t,e,r)=>{const n=r?". ":"",o=r?"、":"",s=r?", ":"",i=r?" ":"";switch(e){case 0:return"•"+i;case 1:return"◦"+i;case 2:return"◾"+i;case 5:const a=_(t,48,57,!0,n);return a.length<4?`0${a}`:a;case 4:return Ct(t,"〇一二三四五六七八九",o);case 6:return Pt(t,1,3999,tn,3,n).toLowerCase();case 7:return Pt(t,1,3999,tn,3,n);case 8:return _(t,945,969,!1,n);case 9:return _(t,97,122,!1,n);case 10:return _(t,65,90,!1,n);case 11:return _(t,1632,1641,!0,n);case 12:case 49:return Pt(t,1,9999,en,3,n);case 35:return Pt(t,1,9999,en,3,n).toLowerCase();case 13:return _(t,2534,2543,!0,n);case 14:case 30:return _(t,6112,6121,!0,n);case 15:return Ct(t,"子丑寅卯辰巳午未申酉戌亥",o);case 16:return Ct(t,"甲乙丙丁戊己庚辛壬癸",o);case 17:case 48:return ht(t,"零一二三四五六七八九",rn,"負",o,14);case 47:return ht(t,"零壹貳參肆伍陸柒捌玖",nn,"負",o,15);case 42:return ht(t,"零一二三四五六七八九",rn,"负",o,14);case 41:return ht(t,"零壹贰叁肆伍陆柒捌玖",nn,"负",o,15);case 26:return ht(t,"〇一二三四五六七八九","十百千万",on,o,0);case 25:return ht(t,"零壱弐参四伍六七八九","拾百千万",on,o,7);case 31:return ht(t,"영일이삼사오육칠팔구","십백천만",sr,s,7);case 33:return ht(t,"零一二三四五六七八九","十百千萬",sr,s,0);case 32:return ht(t,"零壹貳參四五六七八九","拾百千",sr,s,7);case 18:return _(t,2406,2415,!0,n);case 20:return Pt(t,1,19999,ji,3,n);case 21:return _(t,2790,2799,!0,n);case 22:return _(t,2662,2671,!0,n);case 52:return Pt(t,1,10999,Ki,3,n);case 23:return Ct(t,"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");case 24:return Ct(t,"いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");case 27:return _(t,3302,3311,!0,n);case 28:return Ct(t,"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン",o);case 29:return Ct(t,"イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス",o);case 34:return _(t,3792,3801,!0,n);case 37:return _(t,6160,6169,!0,n);case 38:return _(t,4160,4169,!0,n);case 39:return _(t,2918,2927,!0,n);case 40:return _(t,1776,1785,!0,n);case 43:return _(t,3046,3055,!0,n);case 44:return _(t,3174,3183,!0,n);case 45:return _(t,3664,3673,!0,n);case 46:return _(t,3872,3881,!0,n);default:return _(t,48,57,!0,n)}},ta={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:(t,e)=>e.filter(v).reduce((r,n)=>r|ea(n.value),0)},ea=t=>{switch(t){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},ra={name:"float",initialValue:"none",prefix:!1,type:2,parse:(t,e)=>{switch(e){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},na={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:(t,e)=>e.filter(v).map(r=>{switch(r.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;default:return 0}})},oa={name:"text-decoration-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},sa={name:"text-decoration-line",initialValue:"none",prefix:!1,type:1,parse:(t,e)=>e.filter(v).map(r=>{switch(r.value){case"underline":return 1;case"overline":return 2;case"line-through":return 3;case"none":return 4}return 0}).filter(r=>r!==0)},ia={name:"content",initialValue:"none",type:1,prefix:!1,parse:(t,e)=>{if(e.length===0)return[];const r=e[0];return r&&r.type===20&&r.value==="none"?[]:e}},aa={name:"quotes",initialValue:"none",prefix:!0,type:1,parse:(t,e)=>{if(e.length===0)return null;const r=e[0];if(r&&r.type===20&&r.value==="none")return null;const n=[],o=e.filter(Ls);if(o.length%2!==0)return null;for(let s=0;s<o.length;s+=2){const i=p(o,s).value,a=p(o,s+1).value;n.push({open:i,close:a})}return n}},sn=(t,e,r)=>{if(!t)return"";const n=t[Math.min(e,t.length-1)];return n?r?n.open:n.close:""},ro=(t,e)=>{const r=[],n=t.filter(Kt);for(let o=0;o<n.length;o++){const s=n[o],i=n[o+1];if(s&&s.type===20){const a=i&&D(i)?i.number:e;r.push([s.value,a])}}return r},la={name:"counter-increment",initialValue:"none",prefix:!0,type:1,parse:(t,e)=>{if(e.length===0)return null;const r=e[0];return r&&r.type===20&&r.value==="none"?null:ro(e,1).map(([n,o])=>({counter:n,increment:o}))}},ca={name:"counter-reset",initialValue:"none",prefix:!0,type:1,parse:(t,e)=>e.length===0?[]:ro(e,0).filter(([r])=>r!=="none").map(([r,n])=>({counter:r,reset:n}))},ha={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:(t,e)=>e.map(r=>{if(v(r))switch(r.value){case"padding-box":return 1;case"content-box":return 2;case"text":return 3}return 0})},ua={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},fe=(t,e)=>{const r=Z.parse(t,p(e,0)),n=e[1];return n&&I(n)?{color:r,stop:n}:{color:r,stop:null}},nt=(t,e)=>{const r=t.map(l=>({color:l.color,stop:l.stop})),n=p(r,0),o=p(r,r.length-1);n.stop===null&&(n.stop=k),o.stop===null&&(o.stop=j);const s=[];let i=0;for(let l=0;l<r.length;l++){const c=p(r,l).stop;if(c!==null){const h=S(c,e);h>i?s.push(h):s.push(i),i=h}else s.push(null)}let a=null;for(let l=0;l<s.length;l++){const c=p(s,l);if(c===null)a===null&&(a=l);else if(a!==null){const h=l-a,u=(c-s[a-1])/(h+1);for(let d=1;d<=h;d++)s[a+d-1]=u*d;a=null}}return r.map(({color:l},c)=>({color:l,stop:Math.max(Math.min(1,s[c]/e),0)}))},da=(t,e,r)=>{const n=e/2,o=r/2,s=S(t[0],e)-n,i=o-S(t[1],r);return(Math.atan2(i,s)+Math.PI*2)%(Math.PI*2)},De=(t,e,r)=>{const n=typeof t=="number"?t:da(t,e,r),o=Math.abs(e*Math.sin(n))+Math.abs(r*Math.cos(n)),s=e/2,i=r/2,a=o/2,l=Math.sin(n-Math.PI/2)*a,c=Math.cos(n-Math.PI/2)*a;return[o,s-c,s+c,i-l,i+l]},rt=(t,e)=>Math.sqrt(t*t+e*e),an=(t,e,r,n,o)=>[[0,0],[0,e],[t,0],[t,e]].reduce((s,i)=>{const[a,l]=i,c=rt(r-a,n-l);return(o?c<s.optimumDistance:c>s.optimumDistance)?{optimumCorner:i,optimumDistance:c}:s},{optimumDistance:o?1/0:-1/0,optimumCorner:null}).optimumCorner,Ne=(t,e,r,n,o)=>{let s=0,i=0;switch(t.size){case 0:t.shape===0?s=i=Math.min(Math.abs(e),Math.abs(e-n),Math.abs(r),Math.abs(r-o)):t.shape===1&&(s=Math.min(Math.abs(e),Math.abs(e-n)),i=Math.min(Math.abs(r),Math.abs(r-o)));break;case 2:if(t.shape===0)s=i=Math.min(rt(e,r),rt(e,r-o),rt(e-n,r),rt(e-n,r-o));else if(t.shape===1){const a=Math.min(Math.abs(r),Math.abs(r-o))/Math.min(Math.abs(e),Math.abs(e-n)),[l,c]=an(n,o,e,r,!0);s=rt(l-e,(c-r)/a),i=a*s}break;case 1:t.shape===0?s=i=Math.max(Math.abs(e),Math.abs(e-n),Math.abs(r),Math.abs(r-o)):t.shape===1&&(s=Math.max(Math.abs(e),Math.abs(e-n)),i=Math.max(Math.abs(r),Math.abs(r-o)));break;case 3:if(t.shape===0)s=i=Math.max(rt(e,r),rt(e,r-o),rt(e-n,r),rt(e-n,r-o));else if(t.shape===1){const a=Math.max(Math.abs(r),Math.abs(r-o))/Math.max(Math.abs(e),Math.abs(e-n)),[l,c]=an(n,o,e,r,!1);s=rt(l-e,(c-r)/a),i=a*s}}if(Array.isArray(t.size)){const a=t.size;s=S(p(a,0),n),i=a.length===2?S(p(a,1),o):s}return[s,i]},no=(t,e)=>{let r=J(180);const n=[];return q(e).forEach((o,s)=>{if(s===0){const a=o[0];if(a&&a.type===20&&a.value==="to"){r=Un(o);return}else if(a&&zn(a)){r=Bt.parse(t,a);return}}const i=fe(t,o);n.push(i)}),{angle:r,stops:n,type:1}},xe=(t,e)=>{let r=J(180);const n=[];return q(e).forEach((o,s)=>{if(s===0){const a=o[0];if(a&&a.type===20&&["top","left","right","bottom"].indexOf(a.value)!==-1){r=Un(o);return}else if(a&&zn(a)){r=(Bt.parse(t,a)+J(270))%J(360);return}}const i=fe(t,o);n.push(i)}),{angle:r,stops:n,type:1}},fa=(t,e)=>{const r=J(180),n=[];let o=1;const s=0,i=3,a=[];return q(e).forEach((l,c)=>{const h=l[0];if(h){if(c===0){if(v(h)&&h.value==="linear"){o=1;return}else if(v(h)&&h.value==="radial"){o=2;return}}if(h.type===18){if(h.name==="from"){const u=Z.parse(t,p(h.values,0));n.push({stop:k,color:u})}else if(h.name==="to"){const u=Z.parse(t,p(h.values,0));n.push({stop:j,color:u})}else if(h.name==="color-stop"){const u=h.values.filter(F);if(u.length===2){const d=Z.parse(t,p(u,1)),f=p(u,0);D(f)&&n.push({stop:{type:16,number:f.number*100,flags:f.flags},color:d})}}}}}),o===1?{angle:(r+J(180))%J(360),stops:n,type:o}:{size:i,shape:s,stops:n,position:a,type:o}},oo="closest-side",so="farthest-side",io="closest-corner",ao="farthest-corner",lo="circle",co="ellipse",ho="cover",uo="contain",fo=(t,e)=>{let r=1,n=3;const o=[],s=[];return q(e).forEach((i,a)=>{let l=!0;if(a===0){let c=!1;l=i.reduce((h,u)=>{if(c)if(v(u))switch(u.value){case"center":return s.push(Y),h;case"top":case"left":return s.push(k),h;case"right":case"bottom":return s.push(j),h}else(I(u)||xt(u))&&s.push(u);else if(v(u))switch(u.value){case lo:return r=0,!1;case co:return r=1,!1;case"at":return c=!0,!1;case oo:return n=0,!1;case ho:case so:return n=1,!1;case uo:case io:return n=2,!1;case ao:return n=3,!1}else if(xt(u)||I(u))return Array.isArray(n)||(n=[]),n.push(u),!1;return h},l)}if(l){const c=fe(t,i);o.push(c)}}),{size:n,shape:r,stops:o,position:s,type:2}},we=(t,e)=>{let r=1,n=3;const o=[],s=[];return q(e).forEach((i,a)=>{let l=!0;if(a===0?l=i.reduce((c,h)=>{if(v(h))switch(h.value){case"center":return s.push(Y),!1;case"top":case"left":return s.push(k),!1;case"right":case"bottom":return s.push(j),!1}else if(I(h)||xt(h))return s.push(h),!1;return c},l):a===1&&(l=i.reduce((c,h)=>{if(v(h))switch(h.value){case lo:return r=0,!1;case co:return r=1,!1;case uo:case oo:return n=0,!1;case so:return n=1,!1;case io:return n=2,!1;case ho:case ao:return n=3,!1}else if(xt(h)||I(h))return Array.isArray(n)||(n=[]),n.push(h),!1;return c},l)),l){const c=fe(t,i);o.push(c)}}),{size:n,shape:r,stops:o,position:s,type:2}},qt=(t,e)=>({...no(t,e),type:3}),ir=(t,e)=>({...fo(t,e),type:4}),Me=(t,e)=>{let r=0;const n=[],o=[];return q(e).forEach((s,i)=>{let a=!0;if(i===0){let l=!1,c=!1;a=s.reduce((h,u)=>{if(v(u))switch(u.value){case"from":return l=!0,c=!1,!1;case"at":return l=!1,c=!0,!1;case"center":return n.push(Y),h;case"top":case"left":return n.push(k),h;case"right":case"bottom":return n.push(j),h}return l?(r=Bt.parse(t,u),!1):(c&&I(u)&&n.push(u),h)},!0)}a&&s.length>0&&o.push(fe(t,s))}),{type:5,angle:r,position:n,stops:o}},ar=(t,e)=>({...Me(t,e),type:6}),pa=t=>t&&(K(t)&&(t.unit==="dppx"||t.unit==="x")||D(t))?t.number:1,ln=(t,e)=>{const r=q(e),n=t.config.window.devicePixelRatio||1,o=[];for(const a of r){const l=a.find(h=>h.type===22||h.type===18);if(!l)continue;const c=a.find(h=>K(h)||D(h));o.push({imageToken:l,resolution:pa(c)})}if(o.length===0)throw new Error("image-set() requires at least one image candidate");const s=o.filter(a=>a.resolution>=n).sort((a,l)=>a.resolution-l.resolution),i=p(s.length>0?s:o.slice().sort((a,l)=>l.resolution-a.resolution),0);return jt.parse(t,i.imageToken)},ga=t=>t.type===1,po=t=>t.type===2,ma=t=>t.type===3,Dr=t=>t.type===4,ba=t=>t.type===5,xa=t=>t.type===6,jt={name:"image",parse:(t,e)=>{if(e.type===22){const r={url:e.value,type:0};return t.cache.addImage(e.value),r}if(e.type===18){const r=go[e.name];if(typeof r>"u")throw new Error(`Attempting to parse an unsupported image function "${e.name}"`);return r(t,e.values)}throw new Error(`Unsupported image type ${e.type}`)}};function Ye(t){return!(t.type===20&&t.value==="none")&&(t.type!==18||!!go[t.name])}const go={"linear-gradient":no,"-moz-linear-gradient":xe,"-ms-linear-gradient":xe,"-o-linear-gradient":xe,"-webkit-linear-gradient":xe,"radial-gradient":fo,"-moz-radial-gradient":we,"-ms-radial-gradient":we,"-o-radial-gradient":we,"-webkit-radial-gradient":we,"-webkit-gradient":fa,"repeating-linear-gradient":qt,"-webkit-repeating-linear-gradient":qt,"-moz-repeating-linear-gradient":qt,"-ms-repeating-linear-gradient":qt,"-o-repeating-linear-gradient":qt,"repeating-radial-gradient":ir,"-webkit-repeating-radial-gradient":ir,"-moz-repeating-radial-gradient":ir,"conic-gradient":Me,"-webkit-conic-gradient":Me,"-moz-conic-gradient":Me,"repeating-conic-gradient":ar,"-webkit-repeating-conic-gradient":ar,"-moz-repeating-conic-gradient":ar,"image-set":ln,"-webkit-image-set":ln},mo={name:"background-image",initialValue:"none",type:1,prefix:!1,skipCache:!0,parse:(t,e)=>{if(e.length===0)return[];const r=e[0];return r&&r.type===20&&r.value==="none"?[]:e.filter(n=>F(n)&&Ye(n)).map(n=>jt.parse(t,n))}},wa={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:(t,e)=>e.map(r=>{if(v(r))switch(r.value){case"padding-box":return 1;case"content-box":return 2}return 0})},bo={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:(t,e)=>q(e).map(r=>r.map(Nn).filter(n=>n!==null)).map(_n)},xo={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:(t,e)=>q(e).map(r=>r.filter(v).map(n=>n.value).join(" ")).map(ya)},ya=t=>{switch(t){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;default:return 0}},wo={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:(t,e)=>q(e).map(r=>r.map(n=>Ca(n)?n:Nn(n)).filter(n=>n!==null))},Ca=t=>v(t)||I(t),Xe=t=>({name:`border-${t}-color`,initialValue:"transparent",prefix:!1,type:3,format:"color"}),Sa=Xe("top"),Ea=Xe("right"),va=Xe("bottom"),Ra=Xe("left"),Ke=t=>({name:`border-${t}-radius`,initialValue:"0 0",prefix:!1,type:1,parse:(e,r)=>_n(r.filter(I))}),Ta=Ke("top-left"),Ma=Ke("top-right"),La=Ke("bottom-right"),Ia=Ke("bottom-left"),je=t=>({name:`border-${t}-style`,initialValue:"solid",prefix:!1,type:2,parse:(e,r)=>{switch(r){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}),Ba=je("top"),Oa=je("right"),ka=je("bottom"),Pa=je("left"),Ze=t=>({name:`border-${t}-width`,initialValue:"0",type:0,prefix:!1,parse:(e,r)=>K(r)?r.number:0}),yo=Ze("top"),Da=Ze("right"),Na=Ze("bottom"),_a=Ze("left"),Xt={type:0},xr=t=>{const[e]=t;return e?v(e)?e.value==="farthest-side"?"farthest-side":"closest-side":I(e)?e:"closest-side":"closest-side"},Co=t=>{let e=null,r=null;for(const n of t)if(v(n))switch(n.value){case"left":e=k;break;case"right":e=j;break;case"top":r=k;break;case"bottom":r=j;break;case"center":e===null?e=Y:r===null&&(r=Y)}else I(n)&&(e===null?e=n:r===null&&(r=n));return{cx:e??Y,cy:r??Y}},Aa=t=>{const e=[];for(const o of t)if(o.type!==31){if(v(o)&&o.value==="round")break;I(o)&&e.push(o)}const r=e[0]??k,n=e[1]??r;return{type:1,top:r,right:n,bottom:e[2]??r,left:e[3]??n}},Fa=t=>{const e=t.filter(Kt),r=e.findIndex(s=>ce(s,"at")),n=r===-1?e:e.slice(0,r),o=r===-1?[]:e.slice(r+1);return{type:2,radius:xr(n),...Co(o)}},Wa=t=>{const e=t.filter(Kt),r=e.findIndex(s=>ce(s,"at")),n=r===-1?e:e.slice(0,r),o=r===-1?[]:e.slice(r+1);return{type:3,rx:xr(n.slice(0,1)),ry:xr(n.slice(1,2)),...Co(o)}},Va=t=>{const e=q(t),r=[];for(const n of e){if(n.length===1&&n[0]&&v(n[0]))continue;const o=n.filter(I);o.length>=2&&r.push([p(o,0),p(o,1)])}return{type:4,points:r}},za=t=>{const e=t.find(r=>r.type===0);return e?{type:5,d:e.value}:Xt},Ua=t=>{const e=[];for(const r of t)if(r.type!==31){if(v(r)&&r.value==="round")break;I(r)&&e.push(r)}return e.length<4?Xt:{type:6,x:p(e,0),y:p(e,1),width:p(e,2),height:p(e,3)}},$a=t=>{const e=[];for(const n of t)if(n.type!==31){if(v(n)){if(n.value==="round")break;if(n.value==="auto"){e.push("auto");continue}return Xt}I(n)&&e.push(n)}if(e.length!==4)return Xt;const r=(n,o)=>n!=="auto"?n:o==="top"||o==="left"?k:j;return{type:1,top:r(p(e,0),"top"),right:r(p(e,1),"right"),bottom:r(p(e,2),"bottom"),left:r(p(e,3),"left")}},Ga={name:"clip-path",initialValue:"none",prefix:!1,type:0,parse:(t,e)=>{if(v(e)&&e.value==="none")return Xt;if(e.type===18)switch(e.name){case"inset":return Aa(e.values);case"circle":return Fa(e.values);case"ellipse":return Wa(e.values);case"polygon":return Va(e.values);case"path":return za(e.values);case"xywh":return Ua(e.values);case"rect":return $a(e.values)}return Xt}},Ha={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Ya={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:(t,e)=>{switch(e){case"rtl":return 1;default:return 0}}},Xa={name:"font-family",initialValue:"",prefix:!1,type:1,parse:(t,e)=>{const r=[],n=[],o=[];let s=!1;return e.forEach(i=>{switch(i.type){case 20:r.push(i.value);break;case 0:s=!0,r.push(i.value);break;case 17:r.push(i.number.toString());break;case 4:n.push(r.join(" ")),o.push(s),s=!1,r.length=0}}),r.length&&(n.push(r.join(" ")),o.push(s)),n.map((i,a)=>o[a]||i.indexOf(" ")!==-1?`'${i.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\a ").replace(/\r/g,"\\d ").replace(/\f/g,"\\c ")}'`:i)}},Ka={name:"font-size",initialValue:"0",prefix:!1,type:3,format:"length"},ja={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:(t,e)=>e.type===20&&e.value==="normal"?0:e.type===17||e.type===15?e.number:0},Za={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:(t,e)=>{switch(e){case"strict":return"strict";default:return"normal"}}},qa={name:"line-height",initialValue:"normal",prefix:!1,type:4},Mt=(t,e)=>v(t)&&t.value==="normal"?1.2*e:t.type===17?e*t.number:I(t)?S(t,e):e,Qa={name:"list-style-image",initialValue:"none",type:0,prefix:!1,skipCache:!0,parse:(t,e)=>e.type===20&&e.value==="none"||!Ye(e)?null:jt.parse(t,e)},Ja={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:(t,e)=>{switch(e){case"inside":return 0;default:return 1}}},qe=t=>({name:`margin-${t}`,initialValue:"0",prefix:!1,type:4}),tl=qe("top"),el=qe("right"),rl=qe("bottom"),nl=qe("left"),ol={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:(t,e)=>{switch(e){case"break-word":return"break-word";default:return"normal"}}},Qe=t=>({name:`padding-${t}`,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}),sl=Qe("top"),il=Qe("right"),al=Qe("bottom"),ll=Qe("left"),cl={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:(t,e)=>{switch(e){case"right":return 2;case"center":case"justify":return 1;default:return 0}}},hl={name:"position",initialValue:"static",prefix:!1,type:2,parse:(t,e)=>{switch(e){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},ul={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:(t,e)=>e.length===1&&ce(p(e,0),"none")?[]:q(e).map(r=>{const n={color:0,offsetX:k,offsetY:k,blur:k};let o=0;for(let s=0;s<r.length;s++){const i=r[s];i&&(xt(i)?(o===0?n.offsetX=i:o===1?n.offsetY=i:n.blur=i,o++):n.color=Z.parse(t,i))}return n})},dl={name:"text-transform",initialValue:"none",prefix:!1,type:2,parse:(t,e)=>{switch(e){case"uppercase":return 2;case"lowercase":return 1;case"capitalize":return 3}return 0}},fl={name:"transform",initialValue:"none",prefix:!0,type:0,parse:(t,e)=>{if(e.type===20&&e.value==="none")return null;if(e.type===18){const r=bl[e.name];if(typeof r>"u")throw new Error(`Attempting to parse an unsupported transform function "${e.name}"`);return r(t,e.values)}return null}},pl=(t,e)=>{const r=e.filter(n=>n.type===17).map(n=>n.number);return r.length===6?r:null},gl=(t,e)=>{const r=e.filter(n=>n.type===17).map(n=>n.number);return r.length!==16?null:[p(r,0),p(r,1),p(r,4),p(r,5),p(r,12),p(r,13)]},ml=(t,e)=>{if(e.length!==1)return null;const r=p(e,0);let n=0;if(r.type===17&&r.number===0)n=0;else if(r.type===15)n=Bt.parse(t,r);else return null;const o=Math.cos(n),s=Math.sin(n);return[o,s,-s,o,0,0]},bl={matrix:pl,matrix3d:gl,rotate:ml},cn={type:16,number:50,flags:4},xl=[cn,cn],wl={name:"transform-origin",initialValue:"50% 50%",prefix:!0,type:1,parse:(t,e)=>{const r=e.filter(I);return r.length!==2?xl:[p(r,0),p(r,1)]}},yl={name:"rotate",initialValue:"none",prefix:!1,type:0,parse:(t,e)=>e.type===20&&e.value==="none"?null:e.type===17&&e.number===0?0:e.type===15?Bt.parse(t,e)*180/Math.PI:null},Cl={name:"visibility",initialValue:"none",prefix:!1,type:2,parse:(t,e)=>{switch(e){case"hidden":return 1;case"collapse":return 2;default:return 0}}},Sl={name:"word-break",initialValue:"normal",prefix:!1,type:2,parse:(t,e)=>{switch(e){case"break-all":return"break-all";case"keep-all":return"keep-all";default:return"normal"}}},El={name:"white-space",initialValue:"normal",prefix:!1,type:2,parse:(t,e)=>{switch(e){case"pre":return"pre";case"nowrap":return"nowrap";case"pre-wrap":return"pre-wrap";case"pre-line":return"pre-line";default:return"normal"}}},ie=t=>t!==0,lr=t=>t===3||t===4,vl={name:"writing-mode",initialValue:"horizontal-tb",prefix:!1,type:2,parse:(t,e)=>{switch(e){case"vertical-rl":return 1;case"vertical-lr":return 2;case"sideways-rl":return 3;case"sideways-lr":return 4;default:return 0}}},Rl={name:"z-index",initialValue:"auto",prefix:!1,type:0,parse:(t,e)=>{if(e.type===20)return{auto:!0,order:0};if(D(e))return{auto:!1,order:e.number};throw new Error("Invalid z-index number parsed")}},So={name:"time",parse:(t,e)=>{if(e.type===15)switch(e.unit.toLowerCase()){case"s":return 1e3*e.number;case"ms":return e.number}throw new Error("Unsupported time type")}},Tl={name:"opacity",initialValue:"1",type:0,prefix:!1,parse:(t,e)=>D(e)?e.number:1},Ml={name:"text-decoration-style",initialValue:"solid",prefix:!1,type:2,parse:(t,e)=>{switch(e){case"double":return 1;case"dotted":return 2;case"dashed":return 3;case"wavy":return 4;default:return 0}}},Ll={name:"text-decoration-thickness",initialValue:"auto",prefix:!1,type:0,parse:(t,e)=>{if(v(e))switch(e.value){case"auto":return"auto";case"from-font":return"from-font"}return K(e)?e.number:"auto"}},Il={name:"text-underline-offset",initialValue:"auto",prefix:!1,type:0,parse:(t,e)=>v(e)&&e.value==="auto"?"auto":K(e)?e.number:"auto"},Bl={name:"font-weight",initialValue:"normal",type:0,prefix:!1,parse:(t,e)=>{if(D(e))return e.number;if(v(e))switch(e.value){case"bold":return 700;default:return 400}return 400}},Ol={name:"font-variant",initialValue:"none",type:1,prefix:!1,parse:(t,e)=>e.filter(v).map(r=>r.value)},kl={name:"font-style",initialValue:"normal",prefix:!1,type:2,parse:(t,e)=>{switch(e){case"oblique":return"oblique";case"italic":return"italic";default:return"normal"}}},Pl={name:"duration",initialValue:"0s",prefix:!1,type:1,parse:(t,e)=>e.filter(K).map(r=>So.parse(t,r))},Dl={name:"box-shadow",initialValue:"none",type:1,prefix:!1,parse:(t,e)=>e.length===1&&ce(p(e,0),"none")?[]:q(e).map(r=>{const n={color:255,offsetX:k,offsetY:k,blur:k,spread:k,inset:!1};let o=0;for(let s=0;s<r.length;s++){const i=r[s];i&&(ce(i,"inset")?n.inset=!0:xt(i)?(o===0?n.offsetX=i:o===1?n.offsetY=i:o===2?n.blur=i:n.spread=i,o++):n.color=Z.parse(t,i))}return n})},Nl={name:"paint-order",initialValue:"normal",prefix:!1,type:1,parse:(t,e)=>{const r=[0,1,2],n=[];return e.filter(v).forEach(o=>{switch(o.value){case"stroke":n.push(1);break;case"fill":n.push(0);break;case"markers":n.push(2)}}),r.forEach(o=>{n.indexOf(o)===-1&&n.push(o)}),n}},_l={name:"-webkit-text-stroke-color",initialValue:"currentcolor",prefix:!1,type:3,format:"color"},Al={name:"-webkit-text-stroke-width",initialValue:"0",type:0,prefix:!1,parse:(t,e)=>K(e)?e.number:0},Fl={name:"-webkit-line-clamp",initialValue:"none",prefix:!0,type:0,parse:(t,e)=>e.type===20&&e.value==="none"?0:e.type===17?Math.max(0,Math.floor(e.number)):0},Wl={name:"object-fit",initialValue:"fill",prefix:!1,type:1,parse:(t,e)=>e.filter(v).reduce((r,n)=>r|Vl(n.value),0)},Vl=t=>{switch(t){case"contain":return 2;case"cover":return 4;case"none":return 8;case"scale-down":return 16}return 0},zl={name:"text-overflow",initialValue:"clip",prefix:!1,type:2,parse:(t,e)=>{switch(e){case"ellipsis":return 1;default:return 0}}},Ul={name:"image-rendering",initialValue:"auto",prefix:!1,type:2,parse:(t,e)=>{switch(e.toLowerCase()){case"crisp-edges":case"-webkit-crisp-edges":case"-moz-crisp-edges":return 1;case"pixelated":case"-webkit-optimize-contrast":return 2;case"smooth":case"high-quality":return 3;default:return 0}}},A={NORMAL:"normal",MULTIPLY:"multiply",SCREEN:"screen",OVERLAY:"overlay",DARKEN:"darken",LIGHTEN:"lighten",COLOR_DODGE:"color-dodge",COLOR_BURN:"color-burn",HARD_LIGHT:"hard-light",SOFT_LIGHT:"soft-light",DIFFERENCE:"difference",EXCLUSION:"exclusion",HUE:"hue",SATURATION:"saturation",COLOR:"color",LUMINOSITY:"luminosity"},$l=new Set(Object.values(A)),Gl={name:"mix-blend-mode",initialValue:"normal",type:2,prefix:!1,parse:(t,e)=>$l.has(e)?e:A.NORMAL},Eo={name:"filter",initialValue:"none",prefix:!1,type:1,parse:(t,e)=>{if(e.length===1){const n=p(e,0);if(n.type===20&&n.value==="none")return null}const r=[];for(const n of e){if(n.type===22){r.push(`url("${n.value}")`);continue}if(n.type===18){const o=n,s=vo(o.values);switch(o.name){case"blur":r.push(`blur(${s})`);break;case"brightness":case"contrast":case"invert":case"opacity":case"saturate":case"sepia":r.push(`${o.name}(${s})`);break;case"grayscale":r.push(`grayscale(${s})`);break;case"hue-rotate":r.push(`hue-rotate(${s})`);break;case"drop-shadow":r.push(`drop-shadow(${s})`);break;default:r.push(`${o.name}(${s})`)}}}return r.length>0?r.join(" "):null}},vo=t=>{const e=[];for(const r of t){if(r.type===31){e.push(" ");continue}r.type===18?e.push(`${r.name}(${vo(r.values)})`):r.type===4?e.push(","):r.type===6?e.push(r.value):r.type===15?e.push(`${r.number}${r.unit}`):r.type===17?e.push(`${r.number}`):r.type===16?e.push(`${r.number}%`):r.type===20?e.push(r.value):r.type===5&&e.push(`#${r.value}`)}return e.join("").trim()},Hl={name:"font-variant-ligatures",initialValue:"normal",prefix:!1,type:2,parse:(t,e)=>{switch(e){case"none":return 1;case"common-ligatures":return 2;case"no-common-ligatures":return 3;case"discretionary-ligatures":return 4;case"no-discretionary-ligatures":return 5;case"historical-ligatures":return 6;case"no-historical-ligatures":return 7;case"contextual":return 8;case"no-contextual":return 9;default:return 0}}},Yl={name:"zoom",initialValue:"1",type:0,prefix:!1,parse:(t,e)=>e.type===16?Math.max(0,e.number/100):e.type===17?Math.max(0,e.number):1},Xl={name:"object-position",initialValue:"50% 50%",prefix:!1,type:1,parse:(t,e)=>{const r=[];let n=0;for(;n<e.length&&r.length<2;){const o=e[n];if(!o)break;if(v(o))switch(o.value){case"left":case"top":r.push(k);break;case"center":r.push(Y);break;case"right":case"bottom":r.push(j)}else I(o)&&r.push(o);n++}for(;r.length<2;)r.push(Y);return[p(r,0),p(r,1)]}},Kl=new Set(Object.values({NORMAL:"normal",MULTIPLY:"multiply",SCREEN:"screen",OVERLAY:"overlay",DARKEN:"darken",LIGHTEN:"lighten",COLOR_DODGE:"color-dodge",COLOR_BURN:"color-burn",HARD_LIGHT:"hard-light",SOFT_LIGHT:"soft-light",DIFFERENCE:"difference",EXCLUSION:"exclusion",HUE:"hue",SATURATION:"saturation",COLOR:"color",LUMINOSITY:"luminosity"})),jl={name:"background-blend-mode",initialValue:"normal",prefix:!1,type:1,parse:(t,e)=>{const r=[],n=e.filter(F);for(const o of n)v(o)&&Kl.has(o.value)&&r.push(o.value);return r.length>0?r:["normal"]}},Zl={name:"border-image-source",initialValue:"none",prefix:!1,type:1,skipCache:!0,parse:(t,e)=>{if(e.length===0)return null;const r=e.filter(n=>F(n)&&Ye(n));return r.length===0?null:jt.parse(t,p(r,0))}},ql=t=>{const e=[...t];if(e.length===1){const r=p(e,0);e.push(r,r,r)}else e.length===2?e.push(p(e,0),p(e,1)):e.length===3&&e.push(p(e,1));return[p(e,0),p(e,1),p(e,2),p(e,3)]},Ql={name:"border-image-slice",initialValue:"100%",prefix:!1,type:1,parse:(t,e)=>{const r=e.filter(Kt),n=[];let o=!1,s="percent";for(const h of r){if(v(h)&&h.value==="fill"){o=!0;continue}h.type===17?(n.push(h.number),s="number"):h.type===16&&(n.push(h.number),s="percent")}const[i,a,l,c]=ql(n.length>0?n:[100]);return{top:i,right:a,bottom:l,left:c,fill:o,unit:s}}},Jl=t=>{switch(t){case"repeat":return 1;case"round":return 2;case"space":return 3;default:return 0}},tc={name:"border-image-repeat",initialValue:"stretch",prefix:!1,type:1,parse:(t,e)=>{const r=e.filter(Kt),n=[];for(const s of r)v(s)&&n.push(Jl(s.value));const o=n[0]??0;return{horizontal:o,vertical:n[1]??o}}},ec={name:"box-decoration-break",initialValue:"slice",prefix:!1,type:2,parse:(t,e)=>{switch(e){case"clone":return 1;default:return 0}}},rc={name:"accent-color",initialValue:"auto",prefix:!1,type:0,parse:(t,e)=>v(e)&&e.value==="auto"?null:Z.parse(t,e)},nc={name:"-webkit-text-fill-color",initialValue:"currentcolor",prefix:!0,type:0,parse:(t,e)=>v(e)&&e.value==="currentcolor"?null:Z.parse(t,e)},oc={name:"isolation",initialValue:"auto",prefix:!1,type:2,parse:(t,e)=>e==="isolate"?1:0},sc={name:"outline-style",initialValue:"none",prefix:!1,type:2,parse:(t,e)=>{switch(e){case"solid":return 2;case"dashed":return 3;case"dotted":return 4;case"double":return 5;case"auto":return 1;default:return 0}}},ic={name:"outline-color",initialValue:"currentcolor",prefix:!1,type:0,parse:(t,e)=>v(e)&&(e.value==="currentcolor"||e.value==="invert")?null:Z.parse(t,e)},ac={name:"outline-width",initialValue:"medium",prefix:!1,type:0,parse:yo.parse},lc={name:"outline-offset",initialValue:"0px",prefix:!1,type:0,parse:(t,e)=>K(e)||D(e)?e.number:0},cc={name:"backdrop-filter",initialValue:"none",prefix:!1,type:1,parse:(t,e)=>Eo.parse(t,e)},hc={name:"mask-image",initialValue:"none",prefix:!1,type:1,skipCache:!0,parse:mo.parse},uc={name:"mask-position",initialValue:"0%",prefix:!1,type:1,parse:bo.parse},dc={name:"mask-repeat",initialValue:"repeat",prefix:!1,type:1,parse:xo.parse},fc={name:"mask-size",initialValue:"auto",prefix:!1,type:1,parse:wo.parse},hn=["dot","circle","double-circle","triangle","sesame"],pc={name:"text-emphasis-style",initialValue:"none",prefix:!1,type:1,parse:(t,e)=>{const r=e.filter(Kt);if(r.length===0)return null;const n=p(r,0);if(n.type===0)return n.value;if(v(n)){if(n.value==="none")return null;if(n.value!=="filled"&&n.value!=="open"&&hn.indexOf(n.value)===-1)return n.value}let o=!0,s="circle";for(const i of r)v(i)&&(i.value==="filled"?o=!0:i.value==="open"?o=!1:hn.indexOf(i.value)!==-1&&(s=i.value));return{fill:o,shape:s}}},gc={name:"text-emphasis-color",initialValue:"currentcolor",prefix:!1,type:0,parse:(t,e)=>v(e)&&e.value==="currentcolor"?null:Z.parse(t,e)},mc={name:"text-emphasis-position",initialValue:"over right",prefix:!1,type:1,parse:(t,e)=>{let r=!0,n=!0;for(const o of e)if(v(o))switch(o.value){case"over":r=!0;break;case"under":r=!1;break;case"right":n=!0;break;case"left":n=!1}return{over:r,right:n}}},bc=t=>{const e=[...t];if(e.length===1){const r=p(e,0);e.push(r,r,r)}else e.length===2?e.push(p(e,0),p(e,1)):e.length===3&&e.push(p(e,1));return[p(e,0),p(e,1),p(e,2),p(e,3)]},xc=t=>v(t)&&t.value==="auto"?{kind:"auto"}:t.type===17?{kind:"number",value:t.number}:t.type===15&&t.unit==="px"?{kind:"length",value:t.number}:t.type===16?{kind:"percentage",value:t.number}:null,Ro=t=>{const e=[];for(const r of t){if(r.type===31)continue;const n=xc(r);if(!n)return null;e.push(n)}return e.length===0||e.length>4?null:bc(e)},wc={name:"border-image-width",initialValue:"auto",prefix:!1,type:1,parse:(t,e)=>{const r=Ro(e),n={kind:"auto"};return r?{top:r[0],right:r[1],bottom:r[2],left:r[3]}:{top:n,right:n,bottom:n,left:n}}},yc={name:"border-image-outset",initialValue:"0px",prefix:!1,type:1,parse:(t,e)=>{const r=Ro(e),n={kind:"length",value:0};return r?{top:r[0],right:r[1],bottom:r[2],left:r[3]}:{top:n,right:n,bottom:n,left:n}}},Cc={name:"-webkit-box-reflect",initialValue:"none",prefix:!0,type:1,skipCache:!0,parse:(t,e)=>{let r=null,n=0,o=null;for(const s of e)if(s.type!==31){if(r===null&&v(s)){if(s.value==="below"||s.value==="above"||s.value==="left"||s.value==="right"){r=s.value;continue}if(s.value==="none")return null}if(n===0&&K(s)&&s.unit==="px"){n=s.number;continue}if(o===null&&Ye(s)){o=jt.parse(t,s);continue}}return r===null?null:{direction:r,offset:n,mask:o}}},Sc={name:"translate",initialValue:"none",prefix:!1,type:1,parse:(t,e)=>{const r=[];for(const n of e)I(n)&&r.push(n);return r.length===0?null:[p(r,0),r.length>1?p(r,1):k]}},Ec={name:"scale",initialValue:"none",prefix:!1,type:1,parse:(t,e)=>{const r=[];for(const n of e)D(n)&&r.push(n.number);return r.length===0?null:[p(r,0),r.length>1?p(r,1):p(r,0)]}},vc=1e4,un=3e4,dn=6e4,fn=[["animationDuration",Pl,"animationDuration"],["backgroundClip",ha,"backgroundClip"],["backgroundColor",ua,"backgroundColor"],["backgroundImage",mo,"backgroundImage"],["backgroundOrigin",wa,"backgroundOrigin"],["backgroundPosition",bo,"backgroundPosition"],["backgroundRepeat",xo,"backgroundRepeat"],["backgroundSize",wo,"backgroundSize"],["borderTopColor",Sa,"borderTopColor"],["borderRightColor",Ea,"borderRightColor"],["borderBottomColor",va,"borderBottomColor"],["borderLeftColor",Ra,"borderLeftColor"],["borderTopLeftRadius",Ta,"borderTopLeftRadius"],["borderTopRightRadius",Ma,"borderTopRightRadius"],["borderBottomRightRadius",La,"borderBottomRightRadius"],["borderBottomLeftRadius",Ia,"borderBottomLeftRadius"],["borderTopStyle",Ba,"borderTopStyle"],["borderRightStyle",Oa,"borderRightStyle"],["borderBottomStyle",ka,"borderBottomStyle"],["borderLeftStyle",Pa,"borderLeftStyle"],["borderTopWidth",yo,"borderTopWidth"],["borderRightWidth",Da,"borderRightWidth"],["borderBottomWidth",Na,"borderBottomWidth"],["borderLeftWidth",_a,"borderLeftWidth"],["boxShadow",Dl,"boxShadow"],["clipPath",Ga,"clipPath"],["color",Ha,"color"],["direction",Ya,"direction"],["display",ta,"display"],["fontFamily",Xa,"fontFamily"],["fontSize",Ka,"fontSize"],["fontStyle",kl,"fontStyle"],["fontVariant",Ol,"fontVariant"],["fontWeight",Bl,"fontWeight"],["letterSpacing",ja,"letterSpacing"],["lineBreak",Za,"lineBreak"],["lineHeight",qa,"lineHeight"],["listStyleImage",Qa,"listStyleImage"],["listStylePosition",Ja,"listStylePosition"],["listStyleType",br,"listStyleType"],["marginTop",tl,"marginTop"],["marginRight",el,"marginRight"],["marginBottom",rl,"marginBottom"],["marginLeft",nl,"marginLeft"],["opacity",Tl,"opacity"],["overflowWrap",ol,"overflowWrap"],["paddingTop",sl,"paddingTop"],["paddingRight",il,"paddingRight"],["paddingBottom",al,"paddingBottom"],["paddingLeft",ll,"paddingLeft"],["paintOrder",Nl,"paintOrder"],["position",hl,"position"],["textAlign",cl,"textAlign"],["textDecorationStyle",Ml,"textDecorationStyle"],["textDecorationThickness",Ll,"textDecorationThickness"],["textUnderlineOffset",Il,"textUnderlineOffset"],["textShadow",ul,"textShadow"],["textTransform",dl,"textTransform"],["textOverflow",zl,"textOverflow"],["transform",fl,"transform"],["transformOrigin",wl,"transformOrigin"],["rotate",yl,"rotate"],["translate",Sc,"translate"],["scale",Ec,"scale"],["visibility",Cl,"visibility"],["webkitTextStrokeColor",_l,"webkitTextStrokeColor"],["webkitTextStrokeWidth",Al,"webkitTextStrokeWidth"],["webkitLineClamp",Fl,"webkitLineClamp"],["wordBreak",Sl,"wordBreak"],["whiteSpace",El,"whiteSpace"],["writingMode",vl,"writingMode"],["zIndex",Rl,"zIndex"],["objectFit",Wl,"objectFit"],["imageRendering",Ul,"imageRendering"],["mixBlendMode",Gl,"mixBlendMode"],["filter",Eo,"filter"],["fontVariantLigatures",Hl,"fontVariantLigatures"],["zoom",Yl,"zoom"],["objectPosition",Xl,"objectPosition"],["backgroundBlendMode",jl,"backgroundBlendMode"],["borderImageSource",Zl,"borderImageSource"],["borderImageSlice",Ql,"borderImageSlice"],["borderImageRepeat",tc,"borderImageRepeat"],["boxDecorationBreak",ec,"boxDecorationBreak"],["accentColor",rc,"accentColor"],["webkitTextFillColor",nc,"webkitTextFillColor"],["isolation",oc,"isolation"],["outlineColor",ic,"outlineColor"],["outlineStyle",sc,"outlineStyle"],["outlineWidth",ac,"outlineWidth"],["outlineOffset",lc,"outlineOffset"],["backdropFilter",cc,"backdropFilter"],["maskImage",hc,"maskImage"],["maskPosition",uc,"maskPosition"],["maskRepeat",dc,"maskRepeat"],["maskSize",fc,"maskSize"],["textEmphasisStyle",pc,"textEmphasisStyle"],["textEmphasisColor",gc,"textEmphasisColor"],["textEmphasisPosition",mc,"textEmphasisPosition"],["borderImageWidth",wc,"borderImageWidth"],["borderImageOutset",yc,"borderImageOutset"],["webkitBoxReflect",Cc,"webkitBoxReflect"]],pn=new Map,st=(t,e,r)=>{let n=r!==null&&typeof r<"u"?r.toString():e.initialValue;n.trim()===""&&(n=e.initialValue);let o=pn.get(e);if(o){const l=o.get(n);if(l!==void 0)return o.delete(n),o.set(n,l),l}const s=pr.get();s.write(n);const i=new kn(s.read());pr.release(s);const a=(()=>{switch(e.type){case 2:{const l=i.parseComponentValue();return e.parse(t,v(l)?l.value:e.initialValue)}case 0:return e.parse(t,i.parseComponentValue());case 1:return e.parse(t,i.parseComponentValues());case 4:return i.parseComponentValue();case 3:switch(e.format){case"angle":return Bt.parse(t,i.parseComponentValue());case"color":return Z.parse(t,i.parseComponentValue());case"image":return jt.parse(t,i.parseComponentValue());case"length":{const l=i.parseComponentValue();return xt(l)?l:k}case"length-percentage":{const l=i.parseComponentValue();return I(l)?l:k}case"time":return So.parse(t,i.parseComponentValue())}}})();if(o||(o=new Map,pn.set(e,o)),!(e.skipCache||e.type===3&&e.format==="image")){if(o.size>=200){const l=o.keys().next().value;l!==void 0&&o.delete(l)}o.set(n,a)}return a};var Rc=class{styles;constructor(t){this.styles=t}get topColor(){return this.styles.borderTopColor}get rightColor(){return this.styles.borderRightColor}get bottomColor(){return this.styles.borderBottomColor}get leftColor(){return this.styles.borderLeftColor}get topStyle(){return this.styles.borderTopStyle}get rightStyle(){return this.styles.borderRightStyle}get bottomStyle(){return this.styles.borderBottomStyle}get leftStyle(){return this.styles.borderLeftStyle}get topWidth(){return this.styles.borderTopWidth}get rightWidth(){return this.styles.borderRightWidth}get bottomWidth(){return this.styles.borderBottomWidth}get leftWidth(){return this.styles.borderLeftWidth}get topLeftRadius(){return this.styles.borderTopLeftRadius}get topRightRadius(){return this.styles.borderTopRightRadius}get bottomRightRadius(){return this.styles.borderBottomRightRadius}get bottomLeftRadius(){return this.styles.borderBottomLeftRadius}get imageSource(){return this.styles.borderImageSource}get imageSlice(){return this.styles.borderImageSlice}get imageRepeat(){return this.styles.borderImageRepeat}get boxShadow(){return this.styles.boxShadow}},Tc=class{styles;constructor(t){this.styles=t}get color(){return this.styles.backgroundColor}get image(){return this.styles.backgroundImage}get clip(){return this.styles.backgroundClip}get origin(){return this.styles.backgroundOrigin}get position(){return this.styles.backgroundPosition}get repeat(){return this.styles.backgroundRepeat}get size(){return this.styles.backgroundSize}get blendMode(){return this.styles.backgroundBlendMode}},Mc=class{styles;constructor(t){this.styles=t}get family(){return this.styles.fontFamily}get size(){return this.styles.fontSize}get style(){return this.styles.fontStyle}get variant(){return this.styles.fontVariant}get weight(){return this.styles.fontWeight}get ligatures(){return this.styles.fontVariantLigatures}get color(){return this.styles.color}get letterSpacing(){return this.styles.letterSpacing}get lineHeight(){return this.styles.lineHeight}get textAlign(){return this.styles.textAlign}get textTransform(){return this.styles.textTransform}get textOverflow(){return this.styles.textOverflow}get textShadow(){return this.styles.textShadow}get textDecorationColor(){return this.styles.textDecorationColor}get textDecorationLine(){return this.styles.textDecorationLine}get textDecorationStyle(){return this.styles.textDecorationStyle}get textDecorationThickness(){return this.styles.textDecorationThickness}get textUnderlineOffset(){return this.styles.textUnderlineOffset}get wordBreak(){return this.styles.wordBreak}get lineBreak(){return this.styles.lineBreak}get overflowWrap(){return this.styles.overflowWrap}get writingMode(){return this.styles.writingMode}get direction(){return this.styles.direction}get webkitTextStrokeColor(){return this.styles.webkitTextStrokeColor}get webkitTextStrokeWidth(){return this.styles.webkitTextStrokeWidth}get webkitLineClamp(){return this.styles.webkitLineClamp}get paintOrder(){return this.styles.paintOrder}},Lc=class{styles;constructor(t){this.styles=t}get display(){return this.styles.display}get position(){return this.styles.position}get float(){return this.styles.float}get zIndex(){return this.styles.zIndex}get marginTop(){return this.styles.marginTop}get marginRight(){return this.styles.marginRight}get marginBottom(){return this.styles.marginBottom}get marginLeft(){return this.styles.marginLeft}get paddingTop(){return this.styles.paddingTop}get paddingRight(){return this.styles.paddingRight}get paddingBottom(){return this.styles.paddingBottom}get paddingLeft(){return this.styles.paddingLeft}get overflowX(){return this.styles.overflowX}get overflowY(){return this.styles.overflowY}get opacity(){return this.styles.opacity}get visibility(){return this.styles.visibility}get transform(){return this.styles.transform}get transformOrigin(){return this.styles.transformOrigin}get rotate(){return this.styles.rotate}get zoom(){return this.styles.zoom}get clipPath(){return this.styles.clipPath}get mixBlendMode(){return this.styles.mixBlendMode}get filter(){return this.styles.filter}get imageRendering(){return this.styles.imageRendering}get objectFit(){return this.styles.objectFit}get objectPosition(){return this.styles.objectPosition}get boxDecorationBreak(){return this.styles.boxDecorationBreak}get listStyleImage(){return this.styles.listStyleImage}get listStylePosition(){return this.styles.listStylePosition}get listStyleType(){return this.styles.listStyleType}get animationDuration(){return this.styles.animationDuration}isVisible(){return this.styles.isVisible()}isTransparent(){return this.styles.isTransparent()}isTransformed(){return this.styles.isTransformed()}isPositioned(){return this.styles.isPositioned()}isPositionedWithZIndex(){return this.styles.isPositionedWithZIndex()}isFloating(){return this.styles.isFloating()}isInlineLevel(){return this.styles.isInlineLevel()}},Ic=class{animationDuration;backgroundClip;backgroundColor;backgroundImage;backgroundOrigin;backgroundPosition;backgroundRepeat;backgroundSize;borderTopColor;borderRightColor;borderBottomColor;borderLeftColor;borderTopLeftRadius;borderTopRightRadius;borderBottomRightRadius;borderBottomLeftRadius;borderTopStyle;borderRightStyle;borderBottomStyle;borderLeftStyle;borderTopWidth;borderRightWidth;borderBottomWidth;borderLeftWidth;boxShadow;clipPath;color;direction;display;float;fontFamily;fontSize;fontStyle;fontVariant;fontWeight;letterSpacing;lineBreak;lineHeight;listStyleImage;listStylePosition;listStyleType;marginTop;marginRight;marginBottom;marginLeft;opacity;overflowX;overflowY;overflowWrap;paddingTop;paddingRight;paddingBottom;paddingLeft;paintOrder;position;textAlign;textDecorationColor;textDecorationLine;textDecorationStyle;textDecorationThickness;textUnderlineOffset;textShadow;textTransform;textOverflow;transform;transformOrigin;rotate;translate;scale;visibility;webkitTextStrokeColor;webkitTextStrokeWidth;webkitLineClamp;wordBreak;whiteSpace;writingMode;zIndex;objectFit;imageRendering;mixBlendMode;filter;fontVariantLigatures;zoom;objectPosition;backgroundBlendMode;borderImageSource;borderImageSlice;borderImageRepeat;boxDecorationBreak;accentColor;webkitTextFillColor;isolation;outlineColor;outlineStyle;outlineWidth;outlineOffset;backdropFilter;maskImage;maskPosition;maskRepeat;maskSize;textEmphasisStyle;textEmphasisColor;textEmphasisPosition;borderImageWidth;borderImageOutset;webkitBoxReflect;_border;_background;_font;_layout;get border(){return this._border??(this._border=new Rc(this))}get background(){return this._background??(this._background=new Tc(this))}get font(){return this._font??(this._font=new Mc(this))}get layout(){return this._layout??(this._layout=new Lc(this))}constructor(t,e){if(e.display==="none"){this.display=0;for(const[r,n]of fn)r!=="display"&&(this[r]=st(t,n,void 0));Object.assign(this,gn(t,null));return}for(const[r,n,o]of fn)this[r]=st(t,n,e[o]);Object.assign(this,gn(t,e))}isVisible(){return this.display>0&&this.opacity>0&&this.visibility===0}isTransparent(){return ot(this.backgroundColor)}isTransformed(){return this.transform!==null||this.rotate!==null||this.translate!==null||this.scale!==null}isPositioned(){return this.position!==0}isPositionedWithZIndex(){return this.isPositioned()&&!this.zIndex.auto}isFloating(){return this.float!==0}isInlineLevel(){return V(this.display,4)||V(this.display,33554432)||V(this.display,268435456)||V(this.display,536870912)||V(this.display,67108864)||V(this.display,134217728)}};const gn=(t,e)=>{const r=(o,s)=>{if(e)return e[o]??s},n=st(t,na,r("overflow"));return{float:st(t,ra,r("cssFloat")),textDecorationColor:st(t,oa,r("textDecorationColor",r("color"))),textDecorationLine:st(t,sa,r("textDecorationLine",r("textDecoration"))),overflowX:n[0],overflowY:n[n.length>1?1:0]}};var Bc=class{content;quotes;constructor(t,e){this.content=st(t,ia,e.content),this.quotes=st(t,aa,e.quotes)}},To=class{counterIncrement;counterReset;constructor(t,e){this.counterIncrement=st(t,la,e.counterIncrement),this.counterReset=st(t,ca,e.counterReset)}};const Oc="data-html2canvas-debug",kc=t=>{if(typeof t.getAttribute!="function")return 0;switch(t.getAttribute(Oc)){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}},wr=(t,e)=>{const r=kc(t);return r===1||e===r},Pc=t=>{let e="";for(const r of t)try{const n=r.cssRules;for(let o=0;o<n.length;o++){const s=n[o];s&&typeof s.cssText=="string"&&(e+=s.cssText)}}catch{}return e},Mo=(t,e,r)=>{const n=Pc(e);if(!n)return null;const o=t.createElement("style");return o.textContent=n,r&&(o.nonce=r),o},Dc="data-html2canvas-ignore";var Nc=class{cloneNodeFn;options;context;constructor(t,e,r){this.cloneNodeFn=t,this.options=e,this.context=r}appendChildNode(t,e,r){this.safeAppendClonedChild(t,e,r)}cloneChildNodes(t,e,r){t.shadowRoot&&e.shadowRoot?(this.cloneShadowDOMChildren(t.shadowRoot,e.shadowRoot,r),this.cloneLightDOMChildren(t,e,r)):t.shadowRoot&&!e.shadowRoot?this.cloneShadowDOMAsLightDOM(t.shadowRoot,e,r):this.cloneLightDOMChildren(t,e,r)}shouldCloneChild(t){return!Tt(t)||!Ui(t)&&!t.hasAttribute("data-html2canvas-ignore")&&(typeof this.options.ignoreElements!="function"||!this.options.ignoreElements(t))}shouldCloneStyleElement(t){return!this.options.copyStyles||!Tt(t)||!to(t)}safeAppendClonedChild(t,e,r){this.shouldCloneChild(e)&&this.shouldCloneStyleElement(e)&&t.appendChild(this.cloneNodeFn(e,r))}cloneAssignedNodes(t,e,r){t.forEach(n=>{this.safeAppendClonedChild(e,n,r)})}cloneSlotFallbackContent(t,e,r){for(let n=t.firstChild;n;n=n.nextSibling)this.safeAppendClonedChild(e,n,r)}cloneSlotElement(t,e,r){if(!ee(t))return;const n=t;if(typeof n.assignedNodes!="function"){this.context.logger.warn("HTMLSlotElement.assignedNodes is not available",t),this.cloneSlotFallbackContent(t,e,r);return}const o=n.assignedNodes();if(!o||!Array.isArray(o)){this.context.logger.warn("assignedNodes() did not return a valid array",t),this.cloneSlotFallbackContent(t,e,r);return}o.length>0?this.cloneAssignedNodes(o,e,r):this.cloneSlotFallbackContent(t,e,r)}cloneShadowDOMChildren(t,e,r){for(let n=t.firstChild;n;n=n.nextSibling)Tt(n)&&ee(n)?this.cloneSlotElement(n,e,r):this.safeAppendClonedChild(e,n,r);this.appendAdoptedStyleSheets(t,e,r)}cloneLightDOMChildren(t,e,r){for(let n=t.firstChild;n;n=n.nextSibling)this.appendChildNode(e,n,r)}cloneSlotElementAsLightDOM(t,e,r){if(!ee(t))return;const n=t;if(typeof n.assignedNodes!="function"){for(let s=t.firstChild;s;s=s.nextSibling)this.appendChildNode(e,s,r);return}const o=n.assignedNodes();if(o&&Array.isArray(o)&&o.length>0)o.forEach(s=>this.appendChildNode(e,s,r));else for(let s=t.firstChild;s;s=s.nextSibling)this.appendChildNode(e,s,r)}cloneShadowDOMAsLightDOM(t,e,r){for(let n=t.firstChild;n;n=n.nextSibling)Tt(n)&&ee(n)?this.cloneSlotElementAsLightDOM(n,e,r):this.appendChildNode(e,n,r);this.appendAdoptedStyleSheets(t,e,r)}appendAdoptedStyleSheets(t,e,r){if(r)return;const n=t.adoptedStyleSheets;if(!n||n.length===0)return;const o="host"in e?e.host.ownerDocument:e.ownerDocument;if(!o)return;const s=Mo(o,n,this.options.cspNonce);s&&e.appendChild(s)}};const _c=["all","d","content"],yr=(t,e)=>{const r=[];for(let n=t.length-1;n>=0;n--){const o=t.item(n);if(_c.indexOf(o)===-1&&!o.startsWith("--")){const s=t.getPropertyValue(o);if(s){const i=t.getPropertyPriority(o);r.push(i?`${o}:${s} !${i}`:`${o}:${s}`)}}}return r.length>0&&(e.style.cssText=r.join(";")+";"),e},Ac=":before",Fc=":after",Cr="___html2canvas___pseudoelement_before",Sr="___html2canvas___pseudoelement_after",mn=`{
7
+ content: "" !important;
8
+ display: none !important;
9
+ }`,Wc=(t,e)=>{Vc(t,`.${Cr}${Ac}${mn}
10
+ .${Sr}${Fc}${mn}`,e)},Vc=(t,e,r)=>{const n=t.ownerDocument;if(n){const o=n.createElement("style");o.textContent=e,r&&(o.nonce=r),t.appendChild(o)}};var zc=class{context;counters;quoteDepth=0;constructor(t,e){this.context=t,this.counters=e}resolvePseudoContent(t,e,r,n){if(!r)return;const o=r.content,s=e.ownerDocument;if(!s||!o||o==="none"||o==="-moz-alt-content"||r.display==="none")return;this.counters.parse(new To(this.context,r));const i=new Bc(this.context,r),a=s.createElement("html2canvaspseudoelement");yr(r,a),i.content.forEach(c=>{if(c.type===0)a.appendChild(s.createTextNode(c.value));else if(c.type===22){const h=s.createElement("img");h.src=c.value,h.style.opacity="1",a.appendChild(h)}else if(c.type===18){if(c.name==="attr"){const h=c.values.filter(v);h.length&&h[0]&&a.appendChild(s.createTextNode(t.getAttribute(h[0].value)||""))}else if(c.name==="counter"){const[h,u]=c.values.filter(F);if(h&&v(h)){const d=this.counters.getCounterValue(h.value),f=u&&v(u)?br.parse(this.context,u.value):3;a.appendChild(s.createTextNode(ue(d,f,!1)))}}else if(c.name==="counters"){const[h,u,d]=c.values.filter(F);if(h&&v(h)){const f=this.counters.getCounterValues(h.value),g=d&&v(d)?br.parse(this.context,d.value):3,m=u&&u.type===0?u.value:"",b=f.map(x=>ue(x,g,!1)).join(m);a.appendChild(s.createTextNode(b))}}}else if(c.type===20)switch(c.value){case"open-quote":a.appendChild(s.createTextNode(sn(i.quotes,this.quoteDepth++,!0)));break;case"close-quote":{const h=this.quoteDepth>0;this.quoteDepth=Math.max(0,this.quoteDepth-1),h&&a.appendChild(s.createTextNode(sn(i.quotes,this.quoteDepth,!1)));break}default:a.appendChild(s.createTextNode(c.value))}}),a.className=`${Cr} ${Sr}`;const l=n===0?` ${Cr}`:` ${Sr}`;return it(e)?e.className.baseValue+=l:e.className+=l,a}};const $=t=>{if(t?.aborted)throw new DOMException("The operation was aborted.","AbortError")},cr=new WeakMap,Uc=t=>{const e=t&&t.trustedTypes;if(!e)return null;if(cr.has(e))return cr.get(e)??null;let r=null;try{r=e.getPolicy?.("html2canvas-pro")??e.createPolicy("html2canvas-pro",{createHTML:n=>n})}catch{r=null}return cr.set(e,r),r},$c=(t,e,r)=>{const n=t.createElement("iframe");return n.className="html2canvas-container",n.style.visibility="hidden",n.style.position="fixed",n.style.left="-10000px",n.style.top="0px",n.style.border="0",n.width=e.width.toString(),n.height=e.height.toString(),n.scrolling="no",n.setAttribute(Dc,"true"),(r||t.body).appendChild(n),n},Gc=t=>new Promise(e=>{if(t.complete){e();return}if(!t.src){e();return}t.onload=e,t.onerror=e}),Hc=t=>Promise.all([].slice.call(t.images,0).map(Gc)),Yc=(t,e,r)=>new Promise((n,o)=>{const s=t.contentWindow;if(!s)return o("No window assigned for iframe");const i=s.document;let a;const l=setTimeout(()=>{a&&clearInterval(a),o(new Error(`Cloned iframe did not fire its load event within ${dn}ms`))},dn),c=()=>{a&&clearInterval(a),clearTimeout(l),o(new DOMException("The operation was aborted.","AbortError"))};s.onload=t.onload=()=>{s.onload=t.onload=null;const h=Math.ceil(un/50);let u=0;a=setInterval(()=>{u++,r?.aborted?c():i.body.childNodes.length>0&&i.readyState==="complete"?(clearInterval(a),a=void 0,clearTimeout(l),n(t)):u>=h&&(clearInterval(a),a=void 0,e?.warn(`Cloned iframe did not become ready within ${un/1e3} seconds; continuing with a possibly incomplete document`),n(t))},50)},r&&(r.aborted?c():r.addEventListener("abort",c,{once:!0}))}),Xc=t=>{let e="";return t&&(e+="<!DOCTYPE ",t.name&&(e+=t.name),t.internalSubset&&(e+=" "+t.internalSubset.replace(/"/g,"&quot;").replace(/>/g,"&gt;")),t.publicId?(e+=' PUBLIC "'+t.publicId.replace(/"/g,"&quot;")+'"',t.systemId&&(e+=' "'+t.systemId.replace(/"/g,"&quot;")+'"')):t.systemId&&(e+=' SYSTEM "'+t.systemId.replace(/"/g,"&quot;")+'"'),e+=">"),e},Kc=(t,e,r)=>{t&&t.defaultView&&(e!==t.defaultView.pageXOffset||r!==t.defaultView.pageYOffset)&&t.defaultView.scrollTo(e,r)},jc=([t,e,r])=>{t.scrollLeft=e,t.scrollTop=r},Zc=(t,e)=>{const r=t.ownerDocument.createElement("base");r.href=e;const n=t.getElementsByTagName("head").item(0);n?.insertBefore(r,n?.firstChild??null)},qc=(t,e,r,n)=>{const o=$c(e,r,n.container);if(!o.contentWindow)throw new Error("Unable to find iframe window");const s=e.defaultView.pageXOffset,i=e.defaultView.pageYOffset,a=o.contentWindow,l=a.document,c=Yc(o,t.logger,n.signal).then(async()=>{n.scrolledElements.forEach(jc),a&&a.scrollTo(r.left,r.top);const f=n.onclone,g=n.clonedReferenceElement;if(typeof g>"u")throw new Error(`Error finding the ${n.referenceElementName} in the cloned document`);return $(n.signal),l.fonts&&l.fonts.ready&&await l.fonts.ready,$(n.signal),/(AppleWebKit)/g.test(navigator.userAgent)&&(await Hc(l),$(n.signal)),typeof f=="function"&&await Promise.resolve().then(()=>f(l,g)),a.scrollTo(r.left,r.top),/AppleWebKit/g.test(navigator.userAgent)&&(a.scrollY!==r.top||a.scrollX!==r.left)&&(t.logger.warn("Unable to restore scroll position for cloned document"),t.adjustWindowBounds(a.scrollX-r.left,a.scrollY-r.top)),o}),h=e.baseURI;l.open();const u=Xc(e.doctype)+"<html></html>";try{const f=Uc(e.defaultView),g=f?f.createHTML(u):u;l.write(g)}catch{l.write(u)}Kc(e,s,i),l.close();const d=l.adoptNode(n.documentElement);return Zc(d,h),l.replaceChild(d,l.documentElement),c},Qc=t=>{let e=t;for(;e;){if(e.parentNode&&e.parentNode.host)return e.parentNode;const r=e.getRootNode();if(r&&r!==e.ownerDocument&&r.host)return r;e=e.parentNode}return null};var hr=class{context;options;scrolledElements;referenceElement;clonedReferenceElement;documentElement;counters;pseudoContents;slotCloner;constructor(t,e,r){if(this.context=t,this.options=r,this.scrolledElements=[],this.referenceElement=e,this.counters=new Xi,this.pseudoContents=new zc(t,this.counters),this.slotCloner=new Nc((n,o)=>this.cloneNode(n,o),{ignoreElements:r.ignoreElements,copyStyles:r.copyStyles??!0,cspNonce:r.cspNonce},t),!e.ownerDocument)throw new Error("Cloned element does not have an owner document");if(!this.options.iframeContainer){const n=Qc(e);n&&(this.options.iframeContainer=n)}this.documentElement=this.cloneNode(e.ownerDocument.documentElement,!1),this.appendDocumentAdoptedStyles(e.ownerDocument)}appendDocumentAdoptedStyles(t){if(this.options.copyStyles)return;const e=t.adoptedStyleSheets;if(!e||e.length===0)return;const r=this.documentElement.getElementsByTagName("head").item(0);if(!r)return;const n=Mo(this.documentElement.ownerDocument??t,e,this.options.cspNonce);n&&r.appendChild(n)}toIFrame(t,e){return qc(this.context,t,e,{documentElement:this.documentElement,clonedReferenceElement:this.clonedReferenceElement,referenceElementName:this.referenceElement.nodeName,scrolledElements:this.scrolledElements,onclone:this.options.onclone,container:this.options.iframeContainer,signal:this.options.signal})}createElementClone(t){if(wr(t,2))debugger;if(Qn(t))return this.createCanvasClone(t);if(Qr(t))return this.createVideoClone(t);if(to(t))return this.createStyleClone(t);const e=t.cloneNode(!1);return mr(e)&&(mr(t)&&t.currentSrc&&t.currentSrc!==t.src&&(e.src=t.currentSrc,e.srcset=""),e.loading==="lazy"&&(e.loading="eager")),Jr(e)&&!it(e)?this.createCustomElementClone(t,e):e}createCustomElementClone(t,e){const r=document.createElement("div");r.className=e.className,yr(e.style,r);const n=e.attributes;for(let o=0;o<n.length;o++){const s=n.item(o);s&&s.name!=="class"&&s.name!=="style"&&r.setAttribute(s.name,s.value)}if(t.shadowRoot)try{r.attachShadow({mode:"open"})}catch(o){this.context.logger.error("Failed to attach shadow root to custom element clone:",o)}return r}createStyleClone(t){try{const r=t.sheet;if(r&&r.cssRules){const n=[].slice.call(r.cssRules,0).reduce((s,i)=>i&&typeof i.cssText=="string"?s+i.cssText:s,""),o=t.cloneNode(!1);return o.textContent=n,this.options.cspNonce&&(o.nonce=this.options.cspNonce),o}}catch(r){if(this.context.logger.error("Unable to access cssRules property",r),r.name!=="SecurityError")throw r}const e=t.cloneNode(!1);return this.options.cspNonce&&(e.nonce=this.options.cspNonce),e}createCanvasClone(t){if(this.options.inlineImages&&t.ownerDocument){const r=t.ownerDocument.createElement("img");try{return r.src=t.toDataURL(),r}catch{this.context.logger.info("Unable to inline canvas contents, canvas is tainted",t)}}const e=t.cloneNode(!1);try{e.width=t.width,e.height=t.height;const r=t.getContext("2d"),n=e.getContext("2d",{willReadFrequently:!0});if(n)if(!this.options.allowTaint&&r)n.putImageData(r.getImageData(0,0,t.width,t.height),0,0);else{const o=t.getContext("webgl2")??t.getContext("webgl");o&&o.getContextAttributes()?.preserveDrawingBuffer===!1&&this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false",t),n.drawImage(t,0,0)}return e}catch{this.context.logger.info("Unable to clone canvas as it is tainted",t)}return e}createVideoClone(t){const e=t.ownerDocument.createElement("canvas");e.width=t.offsetWidth,e.height=t.offsetHeight;const r=e.getContext("2d");try{return r&&(r.drawImage(t,0,0,e.width,e.height),this.options.allowTaint||r.getImageData(0,0,e.width,e.height)),e}catch{this.context.logger.info("Unable to clone video as it is tainted",t)}const n=t.ownerDocument.createElement("canvas");return n.width=t.offsetWidth,n.height=t.offsetHeight,n}appendChildNode(t,e,r){this.slotCloner.appendChildNode(t,e,r)}cloneChildNodes(t,e,r){this.slotCloner.cloneChildNodes(t,e,r)}cloneNode(t,e){if(Zn(t))return(t.ownerDocument??document).createTextNode(t.data);if(!t.ownerDocument)return t.cloneNode(!1);const r=t.ownerDocument.defaultView;if(r&&Tt(t)&&(he(t)||it(t))){const n=this.createElementClone(t);n.style.transitionProperty="none";const o=r.getComputedStyle(t),s=Yi(t);this.referenceElement===t&&he(n)&&(this.clonedReferenceElement=n),Pr(n)&&Wc(n,this.options.cspNonce);const i=this.counters.parse(new To(this.context,o));if(s){const a=r.getComputedStyle(t,":before"),l=this.pseudoContents.resolvePseudoContent(t,n,a,0);l&&n.insertBefore(l,n.firstChild)}if(Jr(t)&&(e=!0),Qr(t)||this.cloneChildNodes(t,n,e),s){const a=r.getComputedStyle(t,":after"),l=this.pseudoContents.resolvePseudoContent(t,n,a,1);l&&n.appendChild(l)}return this.counters.pop(i),(o&&(this.options.copyStyles||it(t))&&!Jn(t)||e)&&yr(o,n),(t.scrollTop!==0||t.scrollLeft!==0)&&this.scrolledElements.push([n,t.scrollLeft,t.scrollTop]),(ke(t)||Pe(t))&&(ke(n)||Pe(n))&&(n.value=t.value),n}return t.cloneNode(!1)}static destroy(t){return t.parentNode?(t.parentNode.removeChild(t),!0):!1}},bn=class{static normalizeElement(t,e){const r={};if(!he(t)&&!it(t))return r;e.animationDuration.some(o=>o>0)&&(r.animationDuration=t.style.animationDuration,t.style.animationDuration="0s"),e.transform!==null&&(r.transform=t.style.transform,t.style.transform="translate(0, 0)");let n=!1;return e.rotate!==null&&(r.rotate=t.style.rotate,t.style.rotate="0deg",n=!0),e.translate!==null&&(r.translate=t.style.translate,t.style.translate="0px",n=!0),e.scale!==null&&(r.scale=t.style.scale,t.style.scale="1",n=!0),n&&r.transform===void 0&&(r.transform=t.style.transform,t.style.transform="translate(0, 0)"),r}static restoreElement(t,e){!he(t)&&!it(t)||(e.animationDuration!==void 0&&(t.style.animationDuration=e.animationDuration),e.transform!==void 0&&(t.style.transform=e.transform),e.rotate!==void 0&&(t.style.rotate=e.rotate),e.translate!==void 0&&(t.style.translate=e.translate),e.scale!==void 0&&(t.style.scale=e.scale))}},ct=class{context;styles;textNodes=[];elements=[];bounds;legendBounds;createsStackingContext=!1;createsRealStackingContext=!1;isListOwner=!1;debugRender=!1;originalStyles;originalElement;constructor(t,e,r={}){if(this.context=t,wr(e,3))debugger;if(this.styles=new Ic(t,t.config.window.getComputedStyle(e,null)),r.normalizeDom!==!1&&(he(e)||it(e))&&(this.originalStyles=bn.normalizeElement(e,this.styles),this.originalElement=e),this.bounds=le(this.context,e),e.tagName==="FIELDSET"){const n=e.querySelector(":scope > legend");if(n){const o=le(this.context,n);this.legendBounds=o;const s=o.top+o.height/2-this.styles.borderTopWidth/2;this.bounds=new W(this.bounds.left,s,this.bounds.width,this.bounds.height-(s-this.bounds.top))}}wr(e,4)&&(this.debugRender=!0)}restore(){this.originalStyles&&this.originalElement&&(bn.restoreElement(this.originalElement,this.originalStyles),this.originalStyles=void 0,this.originalElement=void 0)}restoreTree(){this.restore();for(const t of this.elements)t.restoreTree()}};const Jc=t=>{if(t.createRange){const r=t.createRange();if(r.getBoundingClientRect){const n=t.createElement("boundtest");n.style.height="123px",n.style.display="block",t.body.appendChild(n),r.selectNode(n);const o=r.getBoundingClientRect(),s=Math.round(o.height);if(t.body.removeChild(n),s===123)return!0}}return!1},th=()=>typeof new Image().crossOrigin<"u",eh=t=>{const e=new Image,r=t.createElement("canvas"),n=r.getContext("2d");if(!n)return!1;e.src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>";try{n.drawImage(e,0,0),r.toDataURL()}catch{return!1}return!0},rh=(t,e,r,n,o)=>{const s="http://www.w3.org/2000/svg",i=document.createElementNS(s,"svg"),a=document.createElementNS(s,"foreignObject");return i.setAttributeNS(null,"width",t.toString()),i.setAttributeNS(null,"height",e.toString()),a.setAttributeNS(null,"width","100%"),a.setAttributeNS(null,"height","100%"),a.setAttributeNS(null,"x",r.toString()),a.setAttributeNS(null,"y",n.toString()),a.setAttributeNS(null,"externalResourcesRequired","true"),i.appendChild(a),a.appendChild(o),i},nh=t=>new Promise((e,r)=>{const n=new Image;n.onload=()=>e(n),n.onerror=r,n.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(t))}`}),Lt={get SUPPORT_RANGE_BOUNDS(){const t=Jc(document);return Object.defineProperty(Lt,"SUPPORT_RANGE_BOUNDS",{value:t}),t},get SUPPORT_SVG_DRAWING(){const t=eh(document);return Object.defineProperty(Lt,"SUPPORT_SVG_DRAWING",{value:t}),t},get SUPPORT_CORS_IMAGES(){const t=th();return Object.defineProperty(Lt,"SUPPORT_CORS_IMAGES",{value:t}),t}};var mt=class{text;bounds;constructor(t,e){this.text=t,this.bounds=e}};const oh=(t,e,r,n)=>{const o=ah(e,r),s=[];let i=0;return o.forEach(a=>{if(r.textDecorationLine.length||a.trim().length>0)if(Lt.SUPPORT_RANGE_BOUNDS){const l=xn(n,i,a.length).getClientRects();if(l.length>1){const c=gt(a);let h=0;c.forEach(u=>{s.push(new mt(u,W.fromDOMRectList(t,xn(n,h+i,u.length).getClientRects()))),h+=u.length})}else s.push(new mt(a,W.fromDOMRectList(t,l)))}else{const l=n.splitText(a.length);s.push(new mt(a,sh(t,n))),n=l}else Lt.SUPPORT_RANGE_BOUNDS||(n=n.splitText(a.length));i+=a.length}),s},sh=(t,e)=>{const r=e.ownerDocument;if(r){const n=r.createElement("html2canvaswrapper");n.appendChild(e.cloneNode(!0));const o=e.parentNode;if(o){o.replaceChild(n,e);const s=le(t,n);return n.firstChild&&o.replaceChild(n.firstChild,n),s}}return W.EMPTY},xn=(t,e,r)=>{const n=t.ownerDocument;if(!n)throw new Error("Node has no owner document");const o=n.createRange();return o.setStart(t,e),o.setEnd(t,e+r),o},wn=new Map,Lo=t=>{let e=wn.get(t);return e||(e=new Intl.Segmenter(void 0,{granularity:t}),wn.set(t,e)),e},gt=t=>Array.from(Lo("grapheme").segment(t),e=>e.segment),ih=t=>Array.from(Lo("word").segment(t),e=>e.segment),ah=(t,e)=>ie(e.writingMode)||e.letterSpacing!==0?gt(t):ih(t);var lh=class{text;textBounds;constructor(t,e,r){this.text=ch(e.data,r.textTransform),this.text.length!==e.data.length&&(e.data=this.text),this.textBounds=oh(t,this.text,r,e)}};const ch=(t,e)=>{switch(e){case 1:return t.toLowerCase();case 3:return t.replace(hh,uh);case 2:return t.toUpperCase();default:return t}},hh=/(^|\s|:|-|\(|\))([a-z])/g,uh=(t,e,r)=>t.length>0?e+r.toUpperCase():t;var Io=class extends ct{src;intrinsicWidth;intrinsicHeight;constructor(t,e,r={}){super(t,e,r),this.src=e.currentSrc||e.src,this.intrinsicWidth=e.naturalWidth,this.intrinsicHeight=e.naturalHeight,this.context.cache.addImage(this.src)}},Bo=class extends ct{canvas;intrinsicWidth;intrinsicHeight;constructor(t,e,r={}){super(t,e,r),this.canvas=e,this.intrinsicWidth=e.width,this.intrinsicHeight=e.height}};const dh=["position","inset","top","right","bottom","left","inset-inline","inset-inline-start","inset-inline-end","inset-block","inset-block-start","inset-block-end","margin","margin-top","margin-right","margin-bottom","margin-left","margin-inline","margin-inline-start","margin-inline-end","margin-block","margin-block-start","margin-block-end"],fh=(t,e)=>{const r=e.getAttribute("style");dh.forEach(o=>e.style.removeProperty(o));const n=t.serializeToString(e);return r===null?e.removeAttribute("style"):e.setAttribute("style",r),n};var Oo=class extends ct{svg;intrinsicWidth;intrinsicHeight;constructor(t,e,r={}){super(t,e,r);const n=new XMLSerializer,o=le(t,e);e.setAttribute("width",`${o.width}px`),e.setAttribute("height",`${o.height}px`),this.svg=`data:image/svg+xml,${encodeURIComponent(fh(n,e))}`,this.intrinsicWidth=e.width.baseVal.value,this.intrinsicHeight=e.height.baseVal.value,this.context.cache.addImage(this.svg)}},ko=class extends ct{value;constructor(t,e,r={}){super(t,e,r),this.value=e.value}},Er=class extends ct{start;reversed;constructor(t,e,r={}){super(t,e,r),this.start=e.start,this.reversed=typeof e.reversed=="boolean"&&e.reversed===!0}};const ph=[{type:15,flags:0,unit:"px",number:3}],gh=[{type:16,flags:0,number:50}],mh=t=>t.width>t.height?new W(t.left+(t.width-t.height)/2,t.top,t.height,t.height):t.width<t.height?new W(t.left,t.top+(t.height-t.width)/2,t.width,t.width):t,bh=t=>{const e=t.type==="password"?new Array(t.value.length+1).join("•"):t.value;return e.length===0?t.placeholder||"":e},xh=t=>t.value.length===0&&!!t.placeholder,wh="checkbox",yh="radio",Ch=1970632191;var zt=class extends ct{type;checked;value;isPlaceholder;constructor(t,e,r={}){switch(super(t,e,r),this.type=e.type.toLowerCase(),this.checked=e.checked,this.value=bh(e),this.isPlaceholder=xh(e),(this.type==="checkbox"||this.type==="radio")&&(this.styles.backgroundColor=3739148031,this.styles.borderTopColor=this.styles.borderRightColor=this.styles.borderBottomColor=this.styles.borderLeftColor=2779096575,this.styles.borderTopWidth=this.styles.borderRightWidth=this.styles.borderBottomWidth=this.styles.borderLeftWidth=1,this.styles.borderTopStyle=this.styles.borderRightStyle=this.styles.borderBottomStyle=this.styles.borderLeftStyle=1,this.styles.backgroundClip=[0],this.styles.backgroundOrigin=[0],this.bounds=mh(this.bounds)),this.type){case wh:this.styles.borderTopRightRadius=this.styles.borderTopLeftRadius=this.styles.borderBottomRightRadius=this.styles.borderBottomLeftRadius=ph;break;case yh:this.styles.borderTopRightRadius=this.styles.borderTopLeftRadius=this.styles.borderBottomRightRadius=this.styles.borderBottomLeftRadius=gh}}},Po=class extends ct{value;constructor(t,e,r={}){super(t,e,r);const n=e.options[e.selectedIndex||0];this.value=n&&n.text||""}},Do=class extends ct{value;constructor(t,e,r={}){super(t,e,r),this.value=e.value}},No=class extends ct{src;width;height;tree;backgroundColor;parseTreeFn;constructor(t,e,r,n={}){super(t,e,n),this.src=e.src,this.width=parseInt(e.width,10)||0,this.height=parseInt(e.height,10)||0,this.backgroundColor=this.styles.backgroundColor,this.parseTreeFn=r;try{const o=e.contentWindow,s=o?.document;if(o&&s&&s.documentElement&&this.parseTreeFn){this.tree=this.parseTreeFn(t,s.documentElement);const i=Ut(t,o.getComputedStyle(s.documentElement).backgroundColor),a=s.body?Ut(t,o.getComputedStyle(s.body).backgroundColor):0;this.backgroundColor=ot(i)?ot(a)?this.styles.backgroundColor:a:i}}catch(o){const s=o instanceof Error?o:new Error(String(o));this.context.logger.warn(`Unable to render iframe content${this.src?` from ${this.src}`:""}: ${s.message}`),this.context.onError?.(s)}}};const Sh=["OL","UL","MENU"],vr=(t,e,r,n,o=1,s={})=>{for(let i=e.firstChild,a;i;i=a)a=i.nextSibling,_o(t,i,r,n,o,s)},_o=(t,e,r,n,o=1,s={})=>{if(Zn(e)&&e.data.length>0){const i=new lh(t,e,r.styles);if(o!==1){const a=r.bounds.left,l=r.bounds.top;i.textBounds=i.textBounds.map(c=>new mt(c.text,new W(a+(c.bounds.left-a)/o,l+(c.bounds.top-l)/o,c.bounds.width/o,c.bounds.height/o)))}r.textNodes.push(i)}else if(Tt(e))if(ee(e)&&e.assignedNodes)e.assignedNodes().forEach(i=>_o(t,i,r,n,o,s));else{const i=Ao(t,e,s),a=i.styles.zoom||1;if(a!==1&&(i.bounds=new W(i.bounds.left,i.bounds.top,i.bounds.width/a,i.bounds.height/a)),i.styles.isVisible()){Eh(e,i,n)?i.createsRealStackingContext=!0:vh(i.styles)&&(i.createsStackingContext=!0),Sh.indexOf(e.tagName)!==-1&&(i.isListOwner=!0),r.elements.push(i);const l=o*(i.styles.zoom||1);e.shadowRoot?vr(t,e.shadowRoot,i,n,l,s):!ke(e)&&!qn(e)&&!Pe(e)&&vr(t,e,i,n,l,s)}}},Ao=(t,e,r={})=>mr(e)?new Io(t,e,r):Qn(e)?new Bo(t,e,r):qn(e)?new Oo(t,e,r):$i(e)?new ko(t,e,r):Gi(e)?new Er(t,e,r):Vi(e)?new zt(t,e,r):Pe(e)?new Po(t,e,r):ke(e)?new Do(t,e,r):Jn(e)?new No(t,e,(n,o)=>Fo(n,o,r),r):new ct(t,e,r),Fo=(t,e,r={})=>{const n=Ao(t,e,r);return n.createsRealStackingContext=!0,vr(t,e,n,n,1,r),n},Eh=(t,e,r)=>e.styles.isPositionedWithZIndex()||e.styles.opacity<1||!!e.styles.filter||!!e.styles.backdropFilter||e.styles.maskImage.length>0||!!e.styles.webkitBoxReflect||e.styles.isolation===1||e.styles.isTransformed()||Pr(t)&&r.styles.isTransparent(),vh=t=>t.isPositioned()||t.isFloating()||t.mixBlendMode!==A.NORMAL?!0:V(t.display,268435456)||V(t.display,33554432)||V(t.display,536870912)||V(t.display,134217728),yn=(t,e)=>t.length===e.length?t.some((r,n)=>r===e[n]):!1,_e=(t,e,r,n,o)=>t.map((s,i)=>{switch(i){case 0:return s.add(e,r);case 1:return s.add(e+n,r);case 2:return s.add(e+n,r+o);case 3:return s.add(e,r+o)}return s});var E=class Wo{type;x;y;constructor(e,r){this.type=0,this.x=e,this.y=r}add(e,r){return new Wo(this.x+e,this.y+r)}};const Dt=(t,e,r)=>new E(t.x+(e.x-t.x)*r,t.y+(e.y-t.y)*r);var re=class ne{type;start;startControl;endControl;end;constructor(e,r,n,o){this.type=1,this.start=e,this.startControl=r,this.endControl=n,this.end=o}subdivide(e,r){const n=Dt(this.start,this.startControl,e),o=Dt(this.startControl,this.endControl,e),s=Dt(this.endControl,this.end,e),i=Dt(n,o,e),a=Dt(o,s,e),l=Dt(i,a,e);return r?new ne(this.start,n,i,l):new ne(l,a,s,this.end)}add(e,r){return new ne(this.start.add(e,r),this.startControl.add(e,r),this.endControl.add(e,r),this.end.add(e,r))}reverse(){return new ne(this.end,this.endControl,this.startControl,this.start)}};const X=t=>t.type===1;var Rh=class{topLeftBorderDoubleOuterBox;topRightBorderDoubleOuterBox;bottomRightBorderDoubleOuterBox;bottomLeftBorderDoubleOuterBox;topLeftBorderDoubleInnerBox;topRightBorderDoubleInnerBox;bottomRightBorderDoubleInnerBox;bottomLeftBorderDoubleInnerBox;topLeftBorderStroke;topRightBorderStroke;bottomRightBorderStroke;bottomLeftBorderStroke;topLeftBorderBox;topRightBorderBox;bottomRightBorderBox;bottomLeftBorderBox;topLeftPaddingBox;topRightPaddingBox;bottomRightPaddingBox;bottomLeftPaddingBox;topLeftContentBox;topRightContentBox;bottomRightContentBox;bottomLeftContentBox;constructor(t){const e=t.styles,r=t.bounds;let[n,o]=te(e.borderTopLeftRadius,r.width,r.height),[s,i]=te(e.borderTopRightRadius,r.width,r.height),[a,l]=te(e.borderBottomRightRadius,r.width,r.height),[c,h]=te(e.borderBottomLeftRadius,r.width,r.height);const u=[];u.push((n+s)/r.width),u.push((c+a)/r.width),u.push((o+h)/r.height),u.push((i+l)/r.height);const d=Math.max(...u);d>1&&(n/=d,o/=d,s/=d,i/=d,a/=d,l/=d,c/=d,h/=d);const f=r.width-s,g=r.height-l,m=r.width-a,b=r.height-h,x=e.borderTopWidth,C=e.borderRightWidth,w=e.borderBottomWidth,y=e.borderLeftWidth,R=S(e.paddingTop,t.bounds.width),M=S(e.paddingRight,t.bounds.width),B=S(e.paddingBottom,t.bounds.width),T=S(e.paddingLeft,t.bounds.width);this.topLeftBorderDoubleOuterBox=n>0||o>0?O(r.left+y/3,r.top+x/3,n-y/3,o-x/3,0):new E(r.left+y/3,r.top+x/3),this.topRightBorderDoubleOuterBox=s>0||i>0?O(r.left+f,r.top+x/3,s-C/3,i-x/3,1):new E(r.left+r.width-C/3,r.top+x/3),this.bottomRightBorderDoubleOuterBox=a>0||l>0?O(r.left+m,r.top+g,a-C/3,l-w/3,2):new E(r.left+r.width-C/3,r.top+r.height-w/3),this.bottomLeftBorderDoubleOuterBox=c>0||h>0?O(r.left+y/3,r.top+b,c-y/3,h-w/3,3):new E(r.left+y/3,r.top+r.height-w/3),this.topLeftBorderDoubleInnerBox=n>0||o>0?O(r.left+y*2/3,r.top+x*2/3,n-y*2/3,o-x*2/3,0):new E(r.left+y*2/3,r.top+x*2/3),this.topRightBorderDoubleInnerBox=s>0||i>0?O(r.left+f,r.top+x*2/3,s-C*2/3,i-x*2/3,1):new E(r.left+r.width-C*2/3,r.top+x*2/3),this.bottomRightBorderDoubleInnerBox=a>0||l>0?O(r.left+m,r.top+g,a-C*2/3,l-w*2/3,2):new E(r.left+r.width-C*2/3,r.top+r.height-w*2/3),this.bottomLeftBorderDoubleInnerBox=c>0||h>0?O(r.left+y*2/3,r.top+b,c-y*2/3,h-w*2/3,3):new E(r.left+y*2/3,r.top+r.height-w*2/3),this.topLeftBorderStroke=n>0||o>0?O(r.left+y/2,r.top+x/2,n-y/2,o-x/2,0):new E(r.left+y/2,r.top+x/2),this.topRightBorderStroke=s>0||i>0?O(r.left+f,r.top+x/2,s-C/2,i-x/2,1):new E(r.left+r.width-C/2,r.top+x/2),this.bottomRightBorderStroke=a>0||l>0?O(r.left+m,r.top+g,a-C/2,l-w/2,2):new E(r.left+r.width-C/2,r.top+r.height-w/2),this.bottomLeftBorderStroke=c>0||h>0?O(r.left+y/2,r.top+b,c-y/2,h-w/2,3):new E(r.left+y/2,r.top+r.height-w/2),this.topLeftBorderBox=n>0||o>0?O(r.left,r.top,n,o,0):new E(r.left,r.top),this.topRightBorderBox=s>0||i>0?O(r.left+f,r.top,s,i,1):new E(r.left+r.width,r.top),this.bottomRightBorderBox=a>0||l>0?O(r.left+m,r.top+g,a,l,2):new E(r.left+r.width,r.top+r.height),this.bottomLeftBorderBox=c>0||h>0?O(r.left,r.top+b,c,h,3):new E(r.left,r.top+r.height),this.topLeftPaddingBox=n>0||o>0?O(r.left+y,r.top+x,Math.max(0,n-y),Math.max(0,o-x),0):new E(r.left+y,r.top+x),this.topRightPaddingBox=s>0||i>0?O(r.left+Math.min(f,r.width-C),r.top+x,f>r.width+C?0:Math.max(0,s-C),Math.max(0,i-x),1):new E(r.left+r.width-C,r.top+x),this.bottomRightPaddingBox=a>0||l>0?O(r.left+Math.min(m,r.width-y),r.top+Math.min(g,r.height-w),Math.max(0,a-C),Math.max(0,l-w),2):new E(r.left+r.width-C,r.top+r.height-w),this.bottomLeftPaddingBox=c>0||h>0?O(r.left+y,r.top+Math.min(b,r.height-w),Math.max(0,c-y),Math.max(0,h-w),3):new E(r.left+y,r.top+r.height-w),this.topLeftContentBox=n>0||o>0?O(r.left+y+T,r.top+x+R,Math.max(0,n-(y+T)),Math.max(0,o-(x+R)),0):new E(r.left+y+T,r.top+x+R),this.topRightContentBox=s>0||i>0?O(r.left+Math.min(f,r.width+y+T),r.top+x+R,f>r.width+y+T?0:s-y+T,i-(x+R),1):new E(r.left+r.width-(C+M),r.top+x+R),this.bottomRightContentBox=a>0||l>0?O(r.left+Math.min(m,r.width-(y+T)),r.top+Math.min(g,r.height+x+R),Math.max(0,a-(C+M)),l-(w+B),2):new E(r.left+r.width-(C+M),r.top+r.height-(w+B)),this.bottomLeftContentBox=c>0||h>0?O(r.left+y+T,r.top+b,Math.max(0,c-(y+T)),h-(w+B),3):new E(r.left+y+T,r.top+r.height-(w+B))}};const O=(t,e,r,n,o)=>{const s=4*((Math.sqrt(2)-1)/3),i=r*s,a=n*s,l=t+r,c=e+n;switch(o){case 0:return new re(new E(t,c),new E(t,c-a),new E(l-i,e),new E(l,e));case 1:return new re(new E(t,e),new E(t+i,e),new E(l,c-a),new E(l,c));case 2:return new re(new E(l,e),new E(l,e+a),new E(t+i,c),new E(t,c));default:return new re(new E(l,c),new E(l-i,c),new E(t,e+a),new E(t,e))}},at=t=>[t.topLeftBorderBox,t.topRightBorderBox,t.bottomRightBorderBox,t.bottomLeftBorderBox],Th=t=>[t.topLeftContentBox,t.topRightContentBox,t.bottomRightContentBox,t.bottomLeftContentBox],wt=t=>[t.topLeftPaddingBox,t.topRightPaddingBox,t.bottomRightPaddingBox,t.bottomLeftPaddingBox];var Qt=class{offsetX;offsetY;matrix;type=0;target=6;constructor(t,e,r){this.offsetX=t,this.offsetY=e,this.matrix=r}},ye=class{path;target;type=1;constructor(t,e){this.path=t,this.target=e}},Mh=class{opacity;type=2;target=6;constructor(t){this.opacity=t}},Nt=class{applyClip;type=3;target=6;constructor(t){this.applyClip=t}};const Lh={[A.NORMAL]:"source-over",[A.MULTIPLY]:"multiply",[A.SCREEN]:"screen",[A.OVERLAY]:"overlay",[A.DARKEN]:"darken",[A.LIGHTEN]:"lighten",[A.COLOR_DODGE]:"color-dodge",[A.COLOR_BURN]:"color-burn",[A.HARD_LIGHT]:"hard-light",[A.SOFT_LIGHT]:"soft-light",[A.DIFFERENCE]:"difference",[A.EXCLUSION]:"exclusion",[A.HUE]:"hue",[A.SATURATION]:"saturation",[A.COLOR]:"color",[A.LUMINOSITY]:"luminosity"};var Ih=class{mixBlendMode;type=4;target=6;compositeOperation;constructor(t){this.mixBlendMode=t,this.compositeOperation=Lh[t]}},Bh=class Vt{type=5;target=6;safeFilterString;shadow;constructor(e){const r=Vt.parseDropShadow(e);this.shadow=r.shadow,this.safeFilterString=r.safeFilterString}static parseDropShadow(e){if(!e)return{safeFilterString:""};const r=Vt.findDropShadows(e);if(r.length===0)return{safeFilterString:e};const n=Vt.parseDropShadowBody(p(r,0).body);let o="",s=0;for(const i of r)o+=e.slice(s,i.start),s=i.end;return o+=e.slice(s),{shadow:n,safeFilterString:o.replace(/\s+/g," ").trim()}}static findDropShadows(e){const r=[],n=/drop-shadow\(/gi;let o;for(;(o=n.exec(e))!==null;){const s=o.index+12-1,i=o.index;let a=1,l=s+1;for(;l<e.length&&a>0;){const h=e[l]??"";h==="("?a++:h===")"&&a--,l++}if(a!==0)break;const c=e.slice(s+1,l-1);r.push({body:c,start:i,end:l})}return r}static parseDropShadowBody(e){const r=Vt.tokenizeFilterArgs(e.trim()),n=[];let o;for(const s of r)Vt.isCSSLength(s)?n.push(parseFloat(s)):s&&(o=s);if(!(n.length<2||n.length>3))return{offsetX:p(n,0),offsetY:p(n,1),blur:n.length>2?p(n,2):0,color:o??"rgba(0,0,0,1)"}}static tokenizeFilterArgs(e){const r=[];let n="",o=0;for(let s=0;s<e.length;s++){const i=e[s]??"";i==="("?(o++,n+=i):i===")"?(o--,n+=i):/\s/.test(i)?o>0?n+=i:n&&(r.push(n),n=""):n+=i}return n&&r.push(n),r}static isCSSLength(e){return/^-?[\d.]+(px|em|rem|pt|cm|mm|in|pc|ex|ch|vw|vh|vmin|vmax|%)?$/i.test(e)}};const Cn=t=>t.type===0,Ae=t=>t.type===1,Nr=t=>t.type===2,Sn=t=>t.type===3,_r=t=>t.type===4,Ar=t=>t.type===5;var Vo=class{element;negativeZIndex;zeroOrAutoZIndexOrTransformedOrOpacity;positiveZIndex;nonPositionedFloats;nonPositionedInlineLevel;inlineLevel;nonInlineLevel;constructor(t){this.element=t,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}},zo=class{container;parent;effects=[];curves;listValue;plainEffectsCache=null;constructor(t,e){if(this.container=t,this.parent=e,this.curves=new Rh(this.container),this.container.styles.opacity<1&&this.effects.push(new Mh(this.container.styles.opacity)),this.container.styles.translate!==null){const r=this.container.styles.transformOrigin,n=this.container.bounds.left+S(r[0],this.container.bounds.width),o=this.container.bounds.top+S(r[1],this.container.bounds.height),[s,i]=this.container.styles.translate,a=S(s,this.container.bounds.width),l=S(i,this.container.bounds.height);this.effects.push(new Qt(n,o,[1,0,0,1,a,l]))}if(this.container.styles.rotate!==null){const r=this.container.styles.transformOrigin,n=this.container.bounds.left+S(r[0],this.container.bounds.width),o=this.container.bounds.top+S(r[1],this.container.bounds.height),s=this.container.styles.rotate*Math.PI/180,i=Math.cos(s),a=Math.sin(s),l=[i,a,-a,i,0,0];this.effects.push(new Qt(n,o,l))}if(this.container.styles.scale!==null){const r=this.container.styles.transformOrigin,n=this.container.bounds.left+S(r[0],this.container.bounds.width),o=this.container.bounds.top+S(r[1],this.container.bounds.height),[s,i]=this.container.styles.scale;this.effects.push(new Qt(n,o,[s,0,0,i,0,0]))}if(this.container.styles.transform!==null){const r=this.container.styles.transformOrigin,n=this.container.bounds.left+S(r[0],this.container.bounds.width),o=this.container.bounds.top+S(r[1],this.container.bounds.height),s=this.container.styles.transform;this.effects.push(new Qt(n,o,s))}if(En(this.container.styles)){const r=at(this.curves),n=wt(this.curves);yn(r,n)?this.effects.push(new ye(r,6)):(this.effects.push(new ye(r,2)),this.effects.push(new ye(n,4)))}if(this.container.styles.clipPath.type!==0){const r=Oh(this.container.styles.clipPath,this.container.bounds);r&&this.effects.push(r)}if(this.container.styles.mixBlendMode!==A.NORMAL&&this.effects.push(new Ih(this.container.styles.mixBlendMode)),this.container.styles.filter!==null&&this.effects.push(new Bh(this.container.styles.filter)),this.container.styles.zoom!==1){const r=this.container.bounds.left,n=this.container.bounds.top,o=this.container.styles.zoom,s=[o,0,0,o,0,0];this.effects.push(new Qt(r,n,s))}}getEffects(t,e){if(!e){let r=this.plainEffectsCache;r||(r=new Map,this.plainEffectsCache=r);let n=r.get(t);return n||(n=this.computeEffects(t),r.set(t,n)),n}return this.computeEffects(t,e)}computeEffects(t,e){let r=[2,3].indexOf(this.container.styles.position)===-1,n=this===e?null:this.parent;const o=i=>i.effects.filter(a=>i!==e||!Ar(a)&&!Nr(a)&&!_r(a)),s=o(this);for(;n;){const i=o(n).filter(a=>!Ae(a));if(r||n.container.styles.position!==0||!n.parent){if(r=[2,3].indexOf(n.container.styles.position)===-1,En(n.container.styles)){const a=at(n.curves),l=wt(n.curves);yn(a,l)||s.unshift(new ye(l,6))}s.unshift(...i)}else s.unshift(...i);n=n===e?null:n.parent}return s.filter(i=>V(i.target,t))}};const En=t=>t.overflowX!==0||t.overflowY!==0,vn=(t,e,r,n,o)=>t==="closest-side"?Math.min(e-r,n-e):t==="farthest-side"?Math.max(e-r,n-e):S(t,o),Oh=(t,e)=>{const{left:r,top:n,width:o,height:s}=e;switch(t.type){case 1:{const i=S(t.left,o),a=S(t.top,s),l=r+i,c=n+a,h=Math.max(0,o-i-S(t.right,o)),u=Math.max(0,s-a-S(t.bottom,s));return new Nt(d=>{d.beginPath(),d.rect(l,c,h,u),d.clip()})}case 2:{const i=r+S(t.cx,o),a=n+S(t.cy,s);let l;return t.radius==="closest-side"?l=Math.min(i-r,a-n,r+o-i,n+s-a):t.radius==="farthest-side"?l=Math.max(i-r,a-n,r+o-i,n+s-a):l=S(t.radius,Math.sqrt(o*o+s*s)/Math.SQRT2),new Nt(c=>{c.beginPath(),c.arc(i,a,Math.max(0,l),0,Math.PI*2),c.clip()})}case 3:{const i=r+S(t.cx,o),a=n+S(t.cy,s),l=vn(t.rx,i,r,r+o,o),c=vn(t.ry,a,n,n+s,s);return new Nt(h=>{h.beginPath(),h.ellipse(i,a,Math.max(0,l),Math.max(0,c),0,0,Math.PI*2),h.clip()})}case 4:{const i=t.points.map(([a,l])=>[r+S(a,o),n+S(l,s)]);return new Nt(a=>{if(a.beginPath(),i.length>0){a.moveTo(p(p(i,0),0),p(p(i,0),1));for(let l=1;l<i.length;l++)a.lineTo(p(p(i,l),0),p(p(i,l),1));a.closePath()}a.clip()})}case 5:{const{d:i}=t;let a=null;return new Nt(l=>{try{a||(a=new Path2D(i));const c=l.getTransform();l.translate(r,n),l.clip(a),l.setTransform(c)}catch{}})}case 6:{const i=r+S(t.x,o),a=n+S(t.y,s),l=Math.max(0,S(t.width,o)),c=Math.max(0,S(t.height,s));return new Nt(h=>{h.beginPath(),h.rect(i,a,l,c),h.clip()})}case 0:return null;default:return null}},Rr=(t,e,r,n)=>{t.container.elements.forEach(o=>{const s=o.createsRealStackingContext,i=o.createsStackingContext,a=new zo(o,t);V(o.styles.display,2048)&&n.push(a);const l=o.isListOwner?[]:n;if(s||i){const c=s||o.styles.isPositioned()?r:e,h=new Vo(a);if(o.styles.isPositioned()||o.styles.opacity<1||o.styles.isTransformed()){const u=o.styles.zIndex.order;if(u<0){let d=0;c.negativeZIndex.some((f,g)=>u>=f.element.container.styles.zIndex.order?(d=g+1,!1):d>0),c.negativeZIndex.splice(d,0,h)}else if(u>0){let d=0;c.positiveZIndex.some((f,g)=>u>=f.element.container.styles.zIndex.order?(d=g+1,!1):d>0),c.positiveZIndex.splice(d,0,h)}else c.zeroOrAutoZIndexOrTransformedOrOpacity.push(h)}else o.styles.isFloating()?c.nonPositionedFloats.push(h):c.nonPositionedInlineLevel.push(h);Rr(a,h,s?h:r,l)}else o.styles.isInlineLevel()?e.inlineLevel.push(a):e.nonInlineLevel.push(a),Rr(a,e,r,l);o.isListOwner&&Uo(o,l)})},Uo=(t,e)=>{let r=t instanceof Er?t.start:1;const n=t instanceof Er?t.reversed:!1;for(let o=0;o<e.length;o++){const s=p(e,o);s.container instanceof ko&&typeof s.container.value=="number"&&s.container.value!==0&&(r=s.container.value),s.listValue=ue(r,s.container.styles.listStyleType,!0),r+=n?-1:1}},kh=t=>{const e=new zo(t,null),r=new Vo(e),n=[];return Rr(e,r,r,n),Uo(e.container,n),r},$o=t=>Math.min(1,Math.max(0,t)),$t=t=>{const e=p(t,0),r=p(t,t.length-1);if(r.stop-e.stop<1e-6)return null;const n=Math.max(r.stop-e.stop,.01),o=[],s=Math.ceil(1/n);for(let a=0;a<s;a++)for(const l of t){const c=a*n+(l.stop-e.stop);if(c>1)break;o.push({stop:c,color:L(l.color)})}const i=o[o.length-1];return(!i||i.stop<1)&&o.push({stop:1,color:L(r.color)}),o},Fe=t=>t.map(e=>({stop:$o(e.stop),color:L(e.color)})),We=(t,e,r,n,o=!1)=>{const s=nt(n,e),i=p(s,s.length-1),a=L(i.color),l=t.createElement("canvas");l.width=Math.max(1,Math.ceil(e*2)),l.height=Math.max(1,Math.ceil(r*2));const c=l.getContext("2d");if(!c)return null;let h;if(o){const d=$t(s);if(!d)return c.fillStyle=a,c.fillRect(0,0,l.width,l.height),{canvas:l,lastColor:a,rx:e,ry:r};h=d}else h=Fe(s);const u=c.createRadialGradient(e,e,0,e,e,e);return h.forEach(d=>u.addColorStop($o(d.stop),d.color)),c.fillStyle=u,e!==r&&c.scale(1,r/e),c.fillRect(0,0,e*2,e*2),{canvas:l,lastColor:a,rx:e,ry:r}},Zt=t=>{const e=t.bounds,r=t.styles;return e.add(r.borderLeftWidth,r.borderTopWidth,-(r.borderRightWidth+r.borderLeftWidth),-(r.borderTopWidth+r.borderBottomWidth))},de=t=>{const e=t.styles,r=t.bounds,n=S(e.paddingLeft,r.width),o=S(e.paddingRight,r.width),s=S(e.paddingTop,r.width),i=S(e.paddingBottom,r.width);return r.add(n+e.borderLeftWidth,s+e.borderTopWidth,-(e.borderRightWidth+e.borderLeftWidth+n+o),-(e.borderTopWidth+e.borderBottomWidth+s+i))},Ph=(t,e)=>t===0?e.bounds:t===2?de(e):Zt(e),Dh=(t,e)=>t===0?e.bounds:t===2?de(e):Zt(e),St=(t,e,r)=>{const n=Ph(Rt(t.styles.backgroundOrigin,e),t),o=Dh(Rt(t.styles.backgroundClip,e),t),s=Nh(Rt(t.styles.backgroundSize,e),r,n);let[i,a]=s;const l=te(Rt(t.styles.backgroundPosition,e),n.width-i,n.height-a),c=_h(Rt(t.styles.backgroundRepeat,e),l,s,n,o),h=Math.round(n.left+l[0]),u=Math.round(n.top+l[1]);return i=Math.max(1,i),a=Math.max(1,a),[c,h,u,i,a]},_t=t=>v(t)&&t.value==="auto",Ce=t=>typeof t=="number",Nh=(t,[e,r,n],o)=>{const[s,i]=t;if(!s)return[0,0];if(I(s)&&i&&I(i))return[S(s,o.width),S(i,o.height)];const a=Ce(n);if(v(s)&&(s.value==="contain"||s.value==="cover"))return Ce(n)?o.width/o.height<n!=(s.value==="cover")?[o.width,o.width/n]:[o.height*n,o.height]:[o.width,o.height];const l=Ce(e),c=Ce(r),h=l||c;if(_t(s)&&(!i||_t(i)))return l&&c?[e,r]:!a&&!h?[o.width,o.height]:h&&a?[l?e:r*n,c?r:e/n]:[l?e:o.width,c?r:o.height];if(a){let f=0,g=0;return I(s)?f=S(s,o.width):i&&I(i)&&(g=S(i,o.height)),_t(s)?f=g*n:(!i||_t(i))&&(g=f/n),[f,g]}let u=null,d=null;if(I(s)?u=S(s,o.width):i&&I(i)&&(d=S(i,o.height)),u!==null&&(!i||_t(i))&&(d=l&&c?u/e*r:o.height),d!==null&&_t(s)&&(u=l&&c?d/r*e:o.width),u!==null&&d!==null)return[u,d];throw new Error("Unable to calculate background-size for element")},Rt=(t,e)=>{const r=t[e];return typeof r>"u"?p(t,0):r},_h=(t,[e,r],[n,o],s,i)=>{switch(t){case 2:return[new E(Math.round(s.left),Math.round(s.top+r)),new E(Math.round(s.left+s.width),Math.round(s.top+r)),new E(Math.round(s.left+s.width),Math.round(o+s.top+r)),new E(Math.round(s.left),Math.round(o+s.top+r))];case 3:return[new E(Math.round(s.left+e),Math.round(s.top)),new E(Math.round(s.left+e+n),Math.round(s.top)),new E(Math.round(s.left+e+n),Math.round(s.height+s.top)),new E(Math.round(s.left+e),Math.round(s.height+s.top))];case 1:return[new E(Math.round(s.left+e),Math.round(s.top+r)),new E(Math.round(s.left+e+n),Math.round(s.top+r)),new E(Math.round(s.left+e+n),Math.round(s.top+r+o)),new E(Math.round(s.left+e),Math.round(s.top+r+o))];default:return[new E(Math.round(i.left),Math.round(i.top)),new E(Math.round(i.left+i.width),Math.round(i.top)),new E(Math.round(i.left+i.width),Math.round(i.height+i.top)),new E(Math.round(i.left),Math.round(i.height+i.top))]}};var H=class extends Error{};const P=t=>{t.width=t.height=0},Ah=["brightness","contrast","grayscale","hue-rotate","invert","opacity","saturate","sepia"],Fh=256,Et=new Map,Wh={functions:[]};function Le(t){if(!t||t==="none")return Wh;const e=Et.get(t);if(e!==void 0)return Et.delete(t),Et.set(t,e),e;const r=Vh(t);if(Et.size>=Fh){const n=Et.keys().next().value;n!==void 0&&Et.delete(n)}return Et.set(t,r),r}const Vh=t=>{const e=[];let r=0;for(;r<t.length;){const n=t[r];if(n===" "||n===`
11
+ `||n===" "){r++;continue}const o=t.indexOf("(",r);if(o===-1)return null;const s=t.slice(r,o).trim();if(!/^[a-zA-Z-]+$/.test(s))return null;const i=zh(t,o);if(i===-1)return null;const a=Uh(s,t.slice(o+1,i).trim());if(!a)return null;e.push(a),r=i+1}return{functions:e}},zh=(t,e)=>{let r=1;for(let n=e+1;n<t.length;n++){const o=t[n];if(o==="(")r++;else if(o===")"&&(r--,r===0))return n}return-1},Tr=/^-?\d+(?:\.\d+)?px$/,Uh=(t,e)=>{if(t==="blur"){if(e==="0")return{kind:"blur",value:0};if(!Tr.test(e))return null;const r=Number.parseFloat(e);return r<0?null:{kind:"blur",value:r}}if(t==="drop-shadow")return Gh(e);if(Ah.indexOf(t)!==-1){const r=t;if(r==="hue-rotate"){const i=Hh(e);return i===null?null:{kind:"unitless",name:r,value:i}}const n=e.trim(),o=n.endsWith("%"),s=o?n.slice(0,-1):n;return/^-?\d+(?:\.\d+)?$/.test(s)?{kind:"unitless",name:r,value:Number.parseFloat(s)*(o?1/100:1)}:null}return null},$h=t=>{const e=[];let r=0,n="";for(const o of t){if(o==="("?r++:o===")"&&r--,o===" "&&r===0){n&&e.push(n),n="";continue}n+=o}return n&&e.push(n),e},Gh=t=>{const e=$h(t),r=e.filter(o=>Tr.test(o)).map(o=>Number.parseFloat(o));if(r.length<2||r.length>3)return null;const n=e.filter(o=>!Tr.test(o));return e.length-n.length!==r.length?null:{kind:"drop-shadow",x:r[0],y:r[1],blur:r[2]??0,color:n.join(" ")||"rgba(0, 0, 0, 0)"}},Hh=t=>{const e=t.trim();if(e==="0")return 0;const r=Number.parseFloat(e);return Number.isNaN(r)?null:e.endsWith("deg")?r:e.endsWith("grad")?r*.9:e.endsWith("rad")?r*180/Math.PI:e.endsWith("turn")?r*360:null},Yh=(t,e)=>t.functions.map(r=>{switch(r.kind){case"blur":return`blur(${r.value*e}px)`;case"drop-shadow":return`drop-shadow(${r.x*e}px ${r.y*e}px ${r.blur*e}px ${r.color})`;case"unitless":return r.name==="hue-rotate"?`hue-rotate(${r.value}deg)`:`${r.name}(${r.value})`}}).join(" ");function Go(t){let e=0,r=0;for(const n of t.functions)n.kind==="blur"?e+=n.value:n.kind==="drop-shadow"&&(e+=n.blur,r=Math.max(r,Math.abs(n.x),Math.abs(n.y)));return Math.ceil(3*e+r)}function Ve(t){const e=(t.ownerDocument??document).createElement("canvas");return e.width=t.width,e.height=t.height,e}const Xh=(t,e)=>new Promise((r,n)=>{const o=a=>{clearTimeout(i),e?.removeEventListener("abort",s),a?n(a):r()},s=()=>o(new DOMException("The operation was aborted.","AbortError")),i=setTimeout(()=>o(new H("Filter surface image decode timed out")),1e4);e?.addEventListener("abort",s,{once:!0}),e?.aborted?s():t.decode().then(()=>o(),()=>o(new H("Filter surface image decode failed")))}),Rn=new WeakMap;function Kh(t=document){const e=Rn.get(t);if(e!==void 0)return e;const r=t.createElement("canvas"),n=t.createElement("canvas");let o=!1;try{r.width=r.height=n.width=n.height=32;const s=r.getContext("2d"),i=n.getContext("2d");if(s&&i&&"filter"in i){s.fillStyle="#fff",s.fillRect(8,8,8,8),i.filter="blur(2px)",i.drawImage(r,0,0);const a=(i.getImageData(6,12,1,1).data[3]??0)>0;i.clearRect(0,0,32,32),i.filter="drop-shadow(12px 0px 0px rgba(255, 0, 0, 0.5))",i.drawImage(r,0,0);const l=i.getImageData(24,12,1,1).data;o=a&&(l[0]??0)>240&&(l[1]??0)<10&&(l[3]??0)>=126&&(l[3]??0)<=129}}catch{}finally{P(r),P(n)}return Rn.set(t,o),o}function jh(t,e,r,n,o){let s,i,a=!1;try{$(o),s=Ve(t);const l=s.getContext("2d");if(!l||!("filter"in l)||(l.filter=Yh(e,n),l.filter==="none"||l.filter===""))return null;l.drawImage(t,0,0),$(o),i=Ve(t);const c=i.getContext("2d");return c?(c.globalAlpha=r,c.drawImage(s,0,0),$(o),a=!0,i):null}catch{return $(o),null}finally{s&&P(s),i&&!a&&P(i)}}const Zh=t=>{let e=0,r=0;for(const n of t.functions)if(n.kind==="blur")e++;else if(n.kind==="drop-shadow")r++;else return!1;return e>1||r>1?!1:e>0&&r>0?t.functions.findIndex(n=>n.kind==="blur")<t.functions.findIndex(n=>n.kind==="drop-shadow"):!0};async function Ie(t,e,r,n,o){if($(o),e.functions.length>0&&Kh(t.ownerDocument??document)){const s=jh(t,e,r,n,o);if(s)return s}if(!Zh(e))throw new H("Filter chain requires native canvas filters");return qh(t,e,r,n,o)}async function qh(t,e,r,n,o){$(o);const s=e.functions.find(w=>w.kind==="blur"),i=e.functions.find(w=>w.kind==="drop-shadow"),a=s&&s.kind==="blur"?s.value:0,l=i&&i.kind==="drop-shadow"?{x:i.x,y:i.y,blur:i.blur,color:i.color}:void 0;if(!a&&!l){const w=Ve(t),y=w.getContext("2d");if(!y)throw P(w),new H("Filter surface canvas is unavailable");y.globalAlpha=r;try{return y.drawImage(t,0,0),w}catch{throw P(w),new H("Filter surface image cannot be drawn")}}const c="http://www.w3.org/2000/svg",h=t.ownerDocument??document,u=(w,y={})=>{const R=h.createElementNS(c,w);return Object.entries(y).forEach(([M,B])=>R.setAttribute(M,String(B))),R},d=u("svg",{width:t.width,height:t.height,viewBox:`0 0 ${t.width} ${t.height}`}),f=u("defs"),g=u("filter",{id:"composited-filter",filterUnits:"userSpaceOnUse",x:0,y:0,width:t.width,height:t.height,"color-interpolation-filters":"sRGB"});if(a&&g.appendChild(u("feGaussianBlur",{stdDeviation:a*n,result:"blurred-source"})),l){g.appendChild(u("feGaussianBlur",{in:a?"blurred-source":"SourceAlpha",stdDeviation:l.blur*n})),g.appendChild(u("feOffset",{dx:l.x*n,dy:l.y*n,result:"offset-shadow"})),g.appendChild(u("feFlood",{"flood-color":l.color})),g.appendChild(u("feComposite",{in2:"offset-shadow",operator:"in"}));const w=u("feMerge");w.appendChild(u("feMergeNode")),w.appendChild(u("feMergeNode",{in:a?"blurred-source":"SourceGraphic"})),g.appendChild(w)}f.appendChild(g),d.appendChild(f);let m;try{if(m=t.toDataURL("image/png"),m==="data:,")throw new Error("Canvas size is unsupported")}catch{throw new H("Filter surface pixels cannot be serialized")}d.appendChild(u("image",{width:t.width,height:t.height,href:m,filter:"url(#composited-filter)"}));const b=h.defaultView,x=b?.Image?new b.Image:new Image;let C;try{x.src=`data:image/svg+xml,${encodeURIComponent(new XMLSerializer().serializeToString(d))}`,await Xh(x,o),$(o),C=Ve(t);const w=C.getContext("2d");if(!w)throw new H("Filter surface canvas is unavailable");return w.globalAlpha=r,w.drawImage(x,0,0),C}catch(w){throw C&&P(C),o?.aborted&&$(o),w instanceof H?w:new H("Filter surface image cannot be drawn")}finally{x.removeAttribute("src")}}function oe(t,e,r){const n=e*r*4;return!Number.isFinite(n)||e<=0||r<=0||e>8192||r>8192||t.pixels+n>16777216?0:(t.pixels+=n,n)}const se=(t,e)=>t.add(-e,-e,e*2,e*2),Se=(t,e)=>new W(Math.min(t.left,e.left),Math.min(t.top,e.top),Math.max(t.left+t.width,e.left+e.width)-Math.min(t.left,e.left),Math.max(t.top+t.height,e.top+e.height)-Math.min(t.top,e.top));function Ho(t){const e=t.styles;let r=t.bounds;for(const o of e.boxShadow)if(!o.inset){const s=Math.max(0,o.spread.number)+3*o.blur.number;r=Se(r,se(t.bounds.add(o.offsetX.number,o.offsetY.number,0,0),s))}for(const o of t.textNodes)for(const s of o.textBounds){const i=se(s.bounds,2*S(e.fontSize,t.bounds.height)+e.webkitTextStrokeWidth);r=Se(r,i);for(const a of e.textShadow)r=Se(r,se(i.add(a.offsetX.number,a.offsetY.number,0,0),3*a.blur.number))}for(const o of t.elements)o.styles.isVisible()&&(r=Se(r,Ho(o)));const n=Le(e.filter);return se(r,n?Go(n):0)}function Mr(t,e,r,n){const o=se(e,r),s=Math.floor(Math.max(t.left,o.left)*n)/n,i=Math.floor(Math.max(t.top,o.top)*n)/n,a=Math.ceil(Math.min(t.left+t.width,o.left+o.width)*n)/n,l=Math.ceil(Math.min(t.top+t.height,o.top+o.height)*n)/n;return new W(s,i,Math.max(0,a-s),Math.max(0,l-i))}var Qh=class{ctx;constructor(t){this.ctx=t}render(t,e){this.ctx.fillStyle=L(e.textDecorationColor??e.color);let r=1;typeof e.textDecorationThickness=="number"?r=e.textDecorationThickness:e.textDecorationThickness==="from-font"&&(r=Math.max(1,Math.floor(e.fontSize.number*.05)));let n=0;typeof e.textUnderlineOffset=="number"&&(n=e.textUnderlineOffset);const o=e.textDecorationStyle;e.textDecorationLine.forEach(s=>{let i=0;switch(s){case 1:i=t.top+t.height-r+n;break;case 2:i=t.top;break;case 3:i=t.top+(t.height/2-r/2);break;default:return}this.draw(t.left,i,t.width,r,o)})}draw(t,e,r,n,o){switch(o){case 0:this.ctx.fillRect(t,e,r,n);break;case 1:{const s=Math.max(1,n);this.ctx.fillRect(t,e,r,n),this.ctx.fillRect(t,e+n+s,r,n);break}case 2:this.drawPattern(t,e,r,n,[n,n*2]);break;case 3:this.drawPattern(t,e,r,n,[n*3,n*2]);break;case 4:this.drawWavy(t,e,r,n);break;default:this.ctx.fillRect(t,e,r,n)}}drawPattern(t,e,r,n,o){this.ctx.save(),this.ctx.beginPath(),this.ctx.setLineDash(o),this.ctx.lineWidth=n,this.ctx.strokeStyle=this.ctx.fillStyle,this.ctx.moveTo(t,e+n/2),this.ctx.lineTo(t+r,e+n/2),this.ctx.stroke(),this.ctx.restore()}drawWavy(t,e,r,n){this.ctx.save(),this.ctx.beginPath(),this.ctx.lineWidth=n,this.ctx.strokeStyle=this.ctx.fillStyle;const o=n*2,s=n*4;let i=t;for(this.ctx.moveTo(i,e+n/2);i<t+r;){const a=Math.min(i+s/2,t+r);if(this.ctx.quadraticCurveTo(i+s/4,e+n/2-o,a,e+n/2),i=a,i<t+r){const l=Math.min(i+s/2,t+r);this.ctx.quadraticCurveTo(i+s/4,e+n/2+o,l,e+n/2),i=l}}this.ctx.stroke(),this.ctx.restore()}};const Jh="Mg",At=t=>t!==void 0&&!Number.isNaN(t),Yo=(t,e)=>{const r=t.measureText(Jh),n=r;return{baseline:At(n.fontBoundingBoxAscent)?n.fontBoundingBoxAscent:At(r.actualBoundingBoxAscent)?r.actualBoundingBoxAscent:e,height:At(n.fontBoundingBoxAscent)&&At(n.fontBoundingBoxDescent)?n.fontBoundingBoxAscent+n.fontBoundingBoxDescent:At(r.actualBoundingBoxAscent)&&At(r.actualBoundingBoxDescent)?r.actualBoundingBoxAscent+r.actualBoundingBoxDescent:e}},Xo=(t,e)=>Yo(t,e).baseline,tu=1,eu=/[\u2E80-\u2FFF\u3000-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uAC00-\uD7AF\uF900-\uFAFF\uFF01-\uFFEF]/,Ee=t=>eu.test(t),ru=()=>typeof navigator>"u"?!1:navigator.userAgentData!==void 0?!0:(typeof window<"u"?window:void 0)?.chrome!==void 0,Ko=()=>ru()?"miter":"round";var nu=class{ctx;options;decorationRenderer;baselineCache=new Map;glyphWidthCache=null;constructor(t){this.ctx=t.ctx,this.options=t.options,this.decorationRenderer=new Qh(t.ctx)}cachedMeasureText(t,e){let r=this.glyphWidthCache;r||(r=new Map,this.glyphWidthCache=r);const n=t+e;let o=r.get(n);return o===void 0&&(o=this.ctx.measureText(t).width,r.set(n,o)),o}iterateLettersWithLetterSpacing(t,e,r,n,o){if(ie(n)){this.iterateVerticalGlyphs(t,e,r,n,o);return}const s=gt(t.text),i=t.bounds.top+r,a=this.ctx.font;let l=t.bounds.left;for(const c of s)o(c,l,i),l+=this.cachedMeasureText(c,a)+e}iterateVerticalGlyphs(t,e,r,n,o){const s=gt(t.text),i=this.ctx.font,a=n===4?-Math.PI/2:Math.PI/2;let l=t.bounds.top;for(let c=0;c<s.length;){const h=s[c];if(!(lr(n)||!Ee(h)&&h.trim().length>0)){const f=this.ctx.textBaseline;Ee(h)&&(this.ctx.textBaseline="ideographic"),o(h,t.bounds.left,l+r),this.ctx.textBaseline=f,l+=this.cachedMeasureText(h,i)+e,c++;continue}const u=c;for(;c<s.length;){const f=s[c];if(!lr(n)&&!Ee(f)&&f.trim().length===0)break;if(lr(n)||!Ee(f)&&f.trim().length>0)c++;else break}this.ctx.save(),this.ctx.translate(t.bounds.left+r,l),this.ctx.rotate(a);let d=0;for(let f=u;f<c;f++){const g=s[f];o(g,0,d),d+=this.cachedMeasureText(g,i)+e}this.ctx.restore(),l+=d}}renderTextWithLetterSpacing(t,e,r,n=0){this.renderFillText(t,e,r,n)}canRenderWholeText(t,e){return t===0&&!ie(e)}renderFillText(t,e,r,n){this.canRenderWholeText(e,n)?this.ctx.fillText(t.text,t.bounds.left,t.bounds.top+r):this.iterateLettersWithLetterSpacing(t,e,r,n,(o,s,i)=>{this.ctx.fillText(o,s,i)})}renderStrokeText(t,e,r,n){this.canRenderWholeText(e,n)?this.ctx.strokeText(t.text,t.bounds.left,t.bounds.top+r):this.iterateLettersWithLetterSpacing(t,e,r,n,(o,s,i)=>{this.ctx.strokeText(o,s,i)})}renderTextStrokeWithStyle(t,e,r){!e.webkitTextStrokeWidth||!t.text.trim().length||(this.ctx.strokeStyle=L(e.webkitTextStrokeColor),this.ctx.lineWidth=e.webkitTextStrokeWidth,this.ctx.lineJoin=Ko(),this.renderStrokeText(t,e.letterSpacing,r,e.writingMode),this.ctx.strokeStyle="",this.ctx.lineWidth=0,this.ctx.lineJoin="miter")}renderTextFillWithShadows(t,e,r){this.ctx.fillStyle=this.resolveFillColor(e),this.renderTextWithLetterSpacing(t,e.letterSpacing,r,e.writingMode);const n=e.textShadow;n.length&&t.text.trim().length&&(n.slice(0).reverse().forEach(o=>{this.ctx.shadowColor=L(o.color),this.ctx.shadowOffsetX=o.offsetX.number*this.options.scale,this.ctx.shadowOffsetY=o.offsetY.number*this.options.scale,this.ctx.shadowBlur=o.blur.number*this.options.scale,this.renderTextWithLetterSpacing(t,e.letterSpacing,r,e.writingMode)}),this.ctx.shadowColor="",this.ctx.shadowOffsetX=0,this.ctx.shadowOffsetY=0,this.ctx.shadowBlur=0)}renderTextBoundWithPaintOrder(t,e,r,n){r.forEach(o=>{switch(o){case 0:this.ctx.fillStyle=this.resolveFillColor(e),this.renderTextWithLetterSpacing(t,e.letterSpacing,n,e.writingMode);break;case 1:this.renderTextStrokeWithStyle(t,e,n)}})}renderTextDecoration(t,e){this.decorationRenderer.render(t,e)}truncateTextWithEllipsis(t,e,r){const o=this.ctx.measureText("…").width,s=gt(t);if(r===0){const i=c=>this.ctx.measureText(s.slice(0,c).join("")).width+o<=e;let a=0,l=s.length;for(;a<l;){const c=a+l+1>>1;i(c)?a=c:l=c-1}return s.slice(0,a).join("")+"…"}else{const i=this.ctx.font;let a=o;const l=[];for(const c of s){const h=this.cachedMeasureText(c,i);if(a+h>e)break;l.push(c),a+=h+r}return l.join("")+"…"}}createFontStyle(t){const e=t.fontVariant.filter(o=>o==="normal"||o==="small-caps").join(""),r=t.fontFamily.join(", "),n=K(t.fontSize)?`${t.fontSize.number}${t.fontSize.unit}`:`${t.fontSize.number}px`;return[[t.fontStyle,e,t.fontWeight,n,r].join(" "),r,n]}resolveFillColor(t){return L(t.webkitTextFillColor??t.color)}renderLineClampedText(t,e,r,n,o){const s=Mt(e.lineHeight,e.fontSize.number),i=[];let a=[],l=p(t.textBounds,0).bounds.top;t.textBounds.forEach(u=>{Math.abs(u.bounds.top-l)>=s*.5?(a.length>0&&i.push(a),a=[u],l=u.bounds.top):a.push(u)}),a.length>0&&i.push(a);const c=e.webkitLineClamp;if(i.length<=c)return!1;for(let u=0;u<c-1;u++)p(i,u).forEach(d=>this.renderTextBoundWithPaintOrder(d,e,r,n));const h=i[c-1];if(h?.length&&o){const u=h.map(m=>m.text).join(""),d=p(h,0),f=o.width-(d.bounds.left-o.left),g=new mt(this.truncateTextWithEllipsis(u,f,e.letterSpacing),d.bounds);for(const m of r)m===0?(this.ctx.fillStyle=this.resolveFillColor(e),this.renderTextWithLetterSpacing(g,e.letterSpacing,n,e.writingMode)):m===1&&this.renderTextStrokeWithStyle(g,e,n)}return!0}renderEllipsisText(t,e,r,n,o){const s=Mt(e.lineHeight,e.fontSize.number),i=p(t.textBounds,0).bounds.top;if(!t.textBounds.every(c=>Math.abs(c.bounds.top-i)<s*.5))return!1;let a=t.textBounds.map(c=>c.text).join("").replace(/\s+/g," ").trim();if(this.ctx.measureText(a).width<=o.width+tu)return!1;const l=new mt(this.truncateTextWithEllipsis(a,o.width,e.letterSpacing),p(t.textBounds,0).bounds);for(const c of r)c===0?this.renderTextFillWithShadows(l,e,n):c===1&&this.renderTextStrokeWithStyle(l,e,n);return!0}measureBaselineCached(t,e){let r=this.baselineCache.get(t);return r===void 0&&(r=Xo(this.ctx,e),this.baselineCache.size>=64&&this.baselineCache.clear(),this.baselineCache.set(t,r)),r}async renderTextNode(t,e,r){this.glyphWidthCache=null;const[n]=this.createFontStyle(e);this.ctx.font=n??"",this.ctx.direction=e.direction===1?"rtl":"ltr",this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic";const o=e.paintOrder,s=this.measureBaselineCached(n??"",e.fontSize.number);e.webkitLineClamp>0&&(e.display&34)!==0&&e.overflowY===1&&t.textBounds.length>0&&this.renderLineClampedText(t,e,o,s,r)||e.textOverflow===1&&r&&e.overflowX===1&&t.textBounds.length>0&&this.renderEllipsisText(t,e,o,s,r)||(t.textBounds.forEach(i=>{o.forEach(a=>{a===0?(this.renderTextFillWithShadows(i,e,s),e.textDecorationLine.length&&this.renderTextDecoration(i.bounds,e)):a===1&&this.renderTextStrokeWithStyle(i,e,s)})}),e.textEmphasisStyle&&this.renderTextEmphasis(t,e,s))}renderTextEmphasis(t,e,r){if(ie(e.writingMode))return;const n=e.textEmphasisStyle;if(!n)return;const o=e.fontSize.number,s=o*.5,i=L(e.textEmphasisColor??e.color),a=e.textEmphasisPosition,l=(h,u)=>{if(typeof n=="string"){const m=this.ctx.font;this.ctx.font=m.replace(/^\S+/,`${s}px`),this.ctx.textAlign="center",this.ctx.fillText(n,h,u+s/3),this.ctx.font=m,this.ctx.textAlign="left";return}const{fill:d,shape:f}=n,g=s*(f==="dot"?.3:f==="sesame"?.26:.34);this.ctx.beginPath(),f==="sesame"?this.ctx.ellipse(h,u,g*1.3,g*.8,Math.PI/4,0,Math.PI*2):f==="triangle"?(this.ctx.moveTo(h,u-g),this.ctx.lineTo(h+g*1.1,u+g*.8),this.ctx.lineTo(h-g*1.1,u+g*.8),this.ctx.closePath()):this.ctx.arc(h,u,g,0,Math.PI*2),d?f==="double-circle"?(this.ctx.lineWidth=g*.7,this.ctx.stroke(),this.ctx.beginPath(),this.ctx.arc(h,u,g*.4,0,Math.PI*2),this.ctx.lineWidth=g*.35,this.ctx.stroke()):this.ctx.fill():(this.ctx.lineWidth=Math.max(1,g*.35),this.ctx.stroke(),f==="double-circle"&&(this.ctx.beginPath(),this.ctx.arc(h,u,g*.5,0,Math.PI*2),this.ctx.stroke()))},c=this.ctx.font;for(const h of t.textBounds){const u=h.bounds.top+r,d=a.over?u-o-s*.4:u+s*.9;let f=h.bounds.left;for(const g of gt(h.text)){const m=this.cachedMeasureText(g,c);this.ctx.save();try{this.ctx.fillStyle=i,this.ctx.strokeStyle=i,this.ctx.lineWidth=1,l(f+m/2+e.letterSpacing/2,d)}finally{this.ctx.restore()}f+=m+e.letterSpacing}}}};const ze=(t,e)=>{e.forEach((r,n)=>{const o=X(r)?r.start:r;n===0?t.moveTo(o.x,o.y):t.lineTo(o.x,o.y),X(r)&&t.bezierCurveTo(r.startControl.x,r.startControl.y,r.endControl.x,r.endControl.y,r.end.x,r.end.y)})},bt=(t,e)=>{t.beginPath(),ze(t,e),t.closePath()};var ou=class{maxSize;_map;constructor(t){this.maxSize=t,this._map=new Map}get(t){if(!this._map.has(t))return;const e=this._map.get(t);return this._map.delete(t),this._map.set(t,e),e}set(t,e){if(this._map.has(t))this._map.delete(t);else if(this._map.size>=this.maxSize){const r=this._map.keys().next().value;r!==void 0&&this._map.delete(r)}this._map.set(t,e)}get size(){return this._map.size}clear(){this._map.clear()}},jo=class{ctx;context;canvas;patternCache=new ou(50);constructor(t){this.ctx=t.ctx,this.context=t.context,this.canvas=t.canvas}async renderBackgroundImage(t){let e=t.styles.backgroundImage.length-1;const r=t.styles.backgroundBlendMode;let n=0;for(const o of t.styles.backgroundImage.slice(0).reverse()){if(n>0){const s=r[n]??r[0]??"normal";s!=="normal"&&(this.ctx.save(),this.ctx.globalCompositeOperation=s)}o.type===0?await this.renderBackgroundURLImage(t,o,e):ga(o)?this.renderLinearGradient(t,o,e):ma(o)?this.renderRepeatingLinearGradient(t,o,e):po(o)?this.renderRadialGradient(t,o,e):Dr(o)?this.renderRepeatingRadialGradient(t,o,e):ba(o)?this.renderConicGradient(t,o,e):xa(o)&&this.renderRepeatingConicGradient(t,o,e),n>0&&(r[n]??r[0]??"normal")!=="normal"&&this.ctx.restore(),e--,n++}}async renderBackgroundURLImage(t,e,r){let n;const o=e.url;try{n=await this.context.cache.match(o)}catch{this.context.logger.error(`Error loading background-image ${o}`)}if(n){const s=isNaN(n.width)||n.width===0?1:n.width,i=isNaN(n.height)||n.height===0?1:n.height,[a,l,c,h,u]=St(t,r,[s,i,s/i]),d=Rt(t.styles.backgroundRepeat,r),f=d===1?"no-repeat":d===2?"repeat-x":d===3?"repeat-y":"repeat",g=`${o}|${Math.round(h)}x${Math.round(u)}|${t.styles.imageRendering}|${f}`;let m=this.patternCache.get(g);if(!m){const b=this.resizeImage(n,h,u,t.styles.imageRendering);m=this.ctx.createPattern(b,f),this.patternCache.set(g,m)}this.renderRepeat(a,m,l,c)}}renderRepeatingLinearGradient(t,e,r){const[n,o,s,i,a]=St(t,r,[null,null,null]),[l,c,h,u,d]=De(e.angle,i,a),f=o+c,g=o+h,m=s+u,b=s+d,x=nt(e.stops,l||1),C=$t(x),w=this.ctx.createLinearGradient(f,m,g,b);if(C)C.forEach(y=>w.addColorStop(Math.min(1,Math.max(0,y.stop)),y.color));else{const y=L(p(x,x.length-1).color);w.addColorStop(0,y),w.addColorStop(1,y)}this.path(n),this.ctx.fillStyle=w,this.ctx.fill()}renderLinearGradient(t,e,r){const[n,o,s,i,a]=St(t,r,[null,null,null]),[l,c,h,u,d]=De(e.angle,i,a),f=`lg|${e.angle}|${Math.round(i)}x${Math.round(a)}|${JSON.stringify(e.stops)}`;let g=this.patternCache.get(f);if(!g){const m=(this.canvas.ownerDocument??document).createElement("canvas");m.width=i,m.height=a;const b=m.getContext("2d");if(!b)return;const x=b.createLinearGradient(c,u,h,d);nt(e.stops,l||1).forEach(C=>x.addColorStop(C.stop,L(C.color))),b.fillStyle=x,b.fillRect(0,0,i,a),i>0&&a>0&&(g=this.ctx.createPattern(m,"repeat"),this.patternCache.set(f,g))}g&&this.renderRepeat(n,g,o,s)}renderRadialGradient(t,e,r){const[n,o,s,i,a]=St(t,r,[null,null,null]),l=e.position.length===0?[Y]:e.position,c=S(p(l,0),i),h=S(p(l,l.length-1),a);let[u,d]=Ne(e,c,h,i,a);if((u===0||d===0)&&(u=Math.max(u,.01),d=Math.max(d,.01)),u>0&&d>0){const f=`rg|${Math.round(c)}x${Math.round(h)}|${Math.round(u)}x${Math.round(d)}|${JSON.stringify(e.stops)}`,g=nt(e.stops,u),m=L(p(g,g.length-1).color);let b=this.patternCache.get(f);if(!b){const x=this.canvas.ownerDocument??document,C=We(x,u,d,e.stops,!1);if(!C)return;b=this.ctx.createPattern(C.canvas,"no-repeat"),this.patternCache.set(f,b)}this.path(n),this.ctx.save(),this.ctx.clip(),this.ctx.fillStyle=m,this.ctx.fill(),this.ctx.translate(o+c-u,s+h-d),this.ctx.fillStyle=b,this.ctx.fillRect(0,0,u*2,d*2),this.ctx.restore()}}renderRepeatingRadialGradient(t,e,r){const[n,o,s,i,a]=St(t,r,[null,null,null]),l=e.position.length===0?[Y]:e.position,c=S(p(l,0),i),h=S(p(l,l.length-1),a);let[u,d]=Ne(e,c,h,i,a);if((u===0||d===0)&&(u=Math.max(u,.01),d=Math.max(d,.01)),!(u>0&&d>0))return;const f=`rrg|${Math.round(c)}x${Math.round(h)}|${Math.round(u)}x${Math.round(d)}|${JSON.stringify(e.stops)}`;let g=this.patternCache.get(f);if(!g){const m=this.canvas.ownerDocument??document,b=We(m,u,d,e.stops,!0);if(!b)return;g=this.ctx.createPattern(b.canvas,"no-repeat"),this.patternCache.set(f,g)}g&&(this.path(n),this.ctx.save(),this.ctx.clip(),this.ctx.translate(o+c-u,s+h-d),this.ctx.fillStyle=g,this.ctx.fillRect(0,0,u*2,d*2),this.ctx.restore())}renderConicGradient(t,e,r){const[n,o,s,i,a]=St(t,r,[null,null,null]),l=e.position.length===0?[Y]:e.position,c=o+S(p(l,0),i),h=s+S(p(l,l.length-1),a),u=this.ctx.createConicGradient(e.angle-Math.PI/2,c,h);nt(e.stops,1).forEach(d=>{u.addColorStop(Math.min(1,Math.max(0,d.stop)),L(d.color))}),this.path(n),this.ctx.save(),this.ctx.clip(),this.ctx.fillStyle=u,this.ctx.fill(),this.ctx.restore()}renderRepeatingConicGradient(t,e,r){const[n,o,s,i,a]=St(t,r,[null,null,null]),l=e.position.length===0?[Y]:e.position,c=o+S(p(l,0),i),h=s+S(p(l,l.length-1),a),u=nt(e.stops,1),d=p(u,0),f=p(u,u.length-1),g=Math.max(f.stop-d.stop,.01);if(f.stop-d.stop<1e-6){const w=this.ctx.createConicGradient(e.angle-Math.PI/2,c,h);w.addColorStop(0,L(f.color)),w.addColorStop(1,L(f.color)),this.path(n),this.ctx.save(),this.ctx.clip(),this.ctx.fillStyle=w,this.ctx.fill(),this.ctx.restore();return}const m=[],b=Math.ceil(1/g);for(let w=0;w<b;w++)for(const y of u){const R=w*g+(y.stop-d.stop);if(R>1)break;m.push({stop:R,color:L(y.color)})}const x=p(m,m.length-1);x&&x.stop<1&&m.push({stop:1,color:x.color});const C=this.ctx.createConicGradient(e.angle-Math.PI/2,c,h);m.forEach(w=>{C.addColorStop(Math.min(1,Math.max(0,w.stop)),w.color)}),this.path(n),this.ctx.save(),this.ctx.clip(),this.ctx.fillStyle=C,this.ctx.fill(),this.ctx.restore()}renderRepeat(t,e,r,n){this.path(t),this.ctx.fillStyle=e,this.ctx.translate(r,n),this.ctx.fill(),this.ctx.translate(-r,-n)}resizeImage(t,e,r,n){const o=(this.canvas.ownerDocument??document).createElement("canvas");o.width=Math.max(1,e),o.height=Math.max(1,r);const s=o.getContext("2d");return s?(n===2||n===1?(this.context.logger.debug("Disabling image smoothing for background image due to CSS image-rendering"),s.imageSmoothingEnabled=!1):n===3?(this.context.logger.debug("Enabling image smoothing for background image due to CSS image-rendering: smooth"),s.imageSmoothingEnabled=!0):s.imageSmoothingEnabled=this.ctx.imageSmoothingEnabled,this.ctx.imageSmoothingQuality&&(s.imageSmoothingQuality=this.ctx.imageSmoothingQuality),s.drawImage(t,0,0,t.width,t.height,0,0,e,r),o):t}path(t){bt(this.ctx,t)}};const Tn=(t,e)=>{switch(e){case 0:return tt(t.topLeftBorderBox,t.topLeftPaddingBox,t.topRightBorderBox,t.topRightPaddingBox);case 1:return tt(t.topRightBorderBox,t.topRightPaddingBox,t.bottomRightBorderBox,t.bottomRightPaddingBox);case 2:return tt(t.bottomRightBorderBox,t.bottomRightPaddingBox,t.bottomLeftBorderBox,t.bottomLeftPaddingBox);default:return tt(t.bottomLeftBorderBox,t.bottomLeftPaddingBox,t.topLeftBorderBox,t.topLeftPaddingBox)}},su=(t,e)=>{switch(e){case 0:return tt(t.topLeftBorderBox,t.topLeftBorderDoubleOuterBox,t.topRightBorderBox,t.topRightBorderDoubleOuterBox);case 1:return tt(t.topRightBorderBox,t.topRightBorderDoubleOuterBox,t.bottomRightBorderBox,t.bottomRightBorderDoubleOuterBox);case 2:return tt(t.bottomRightBorderBox,t.bottomRightBorderDoubleOuterBox,t.bottomLeftBorderBox,t.bottomLeftBorderDoubleOuterBox);default:return tt(t.bottomLeftBorderBox,t.bottomLeftBorderDoubleOuterBox,t.topLeftBorderBox,t.topLeftBorderDoubleOuterBox)}},iu=(t,e)=>{switch(e){case 0:return tt(t.topLeftBorderDoubleInnerBox,t.topLeftPaddingBox,t.topRightBorderDoubleInnerBox,t.topRightPaddingBox);case 1:return tt(t.topRightBorderDoubleInnerBox,t.topRightPaddingBox,t.bottomRightBorderDoubleInnerBox,t.bottomRightPaddingBox);case 2:return tt(t.bottomRightBorderDoubleInnerBox,t.bottomRightPaddingBox,t.bottomLeftBorderDoubleInnerBox,t.bottomLeftPaddingBox);default:return tt(t.bottomLeftBorderDoubleInnerBox,t.bottomLeftPaddingBox,t.topLeftBorderDoubleInnerBox,t.topLeftPaddingBox)}},au=(t,e)=>{switch(e){case 0:return ve(t.topLeftBorderStroke,t.topRightBorderStroke);case 1:return ve(t.topRightBorderStroke,t.bottomRightBorderStroke);case 2:return ve(t.bottomRightBorderStroke,t.bottomLeftBorderStroke);default:return ve(t.bottomLeftBorderStroke,t.topLeftBorderStroke)}},ve=(t,e)=>{const r=[];return X(t)?r.push(t.subdivide(.5,!1)):r.push(t),X(e)?r.push(e.subdivide(.5,!0)):r.push(e),r},tt=(t,e,r,n)=>{const o=[];return X(t)?o.push(t.subdivide(.5,!1)):o.push(t),X(r)?o.push(r.subdivide(.5,!0)):o.push(r),X(n)?o.push(n.subdivide(.5,!0).reverse()):o.push(n),X(e)?o.push(e.subdivide(.5,!1).reverse()):o.push(e),o};var lu=class{ctx;pathCallbacks;constructor(t,e){this.ctx=t.ctx,this.pathCallbacks=e}async renderSolidBorder(t,e,r){this.pathCallbacks.path(Tn(r,e)),this.ctx.fillStyle=L(t),this.ctx.fill()}async renderDoubleBorder(t,e,r,n){if(e<3){await this.renderSolidBorder(t,r,n);return}const o=su(n,r);this.pathCallbacks.path(o),this.ctx.fillStyle=L(t),this.ctx.fill();const s=iu(n,r);this.pathCallbacks.path(s),this.ctx.fill()}async renderDashedDottedBorder(t,e,r,n,o){this.ctx.save();const s=au(n,r),i=Tn(n,r);o===2&&(this.pathCallbacks.path(i),this.ctx.clip());let a,l,c,h;X(p(i,0))?(a=p(i,0).start.x,l=p(i,0).start.y):(a=p(i,0).x,l=p(i,0).y),X(p(i,1))?(c=p(i,1).end.x,h=p(i,1).end.y):(c=p(i,1).x,h=p(i,1).y);let u;r===0||r===2?u=Math.abs(a-c):u=Math.abs(l-h),this.ctx.beginPath(),o===3?this.pathCallbacks.formatPath(s):this.pathCallbacks.formatPath(i.slice(0,2));let d=e<3?e*3:e*2,f=e<3?e*2:e;o===3&&(d=e,f=e);let g=!0;if(u<=d*2)g=!1;else if(u<=d*2+f){const m=u/(2*d+f);d*=m,f*=m}else{const m=Math.floor((u+f)/(d+f)),b=(u-m*d)/(m-1),x=(u-(m+1)*d)/m;f=x<=0||Math.abs(f-b)<Math.abs(f-x)?b:x}if(g&&(o===3?this.ctx.setLineDash([0,d+f]):this.ctx.setLineDash([d,f])),o===3?(this.ctx.lineCap="round",this.ctx.lineWidth=e):this.ctx.lineWidth=e*2+1.1,this.ctx.strokeStyle=L(t),this.ctx.stroke(),this.ctx.setLineDash([]),o===2){if(X(p(i,0))){const m=p(i,3),b=p(i,0);this.ctx.beginPath(),this.pathCallbacks.formatPath([new E(m.end.x,m.end.y),new E(b.start.x,b.start.y)]),this.ctx.stroke()}if(X(p(i,1))){const m=p(i,1),b=p(i,2);this.ctx.beginPath(),this.pathCallbacks.formatPath([new E(m.end.x,m.end.y),new E(b.start.x,b.start.y)]),this.ctx.stroke()}}this.ctx.restore()}};const cu=(t,e,r)=>{const n=t?[t.top,t.right,t.bottom,t.left]:null;return[0,1,2,3].map(o=>{const s=n?n[o]:null,i=e[o]??0;return!s||s.kind==="auto"?i:s.kind==="number"?i*(s.value??1):s.kind==="length"?s.value??0:(s.value??0)/100*(o===0||o===2?r.height:r.width)})},hu=(t,e)=>{const r=t?[t.top,t.right,t.bottom,t.left]:null,n=o=>{const s=r?r[o]:null;return s?s.kind==="number"?(e[o]??0)*(s.value??0):s.value??0:0};return{top:n(0),right:n(1),bottom:n(2),left:n(3)}};var uu=class{ctx;constructor(t){this.ctx=t}renderBorderImage(t,e,r,n,o,s,i,a,l={top:0,right:0,bottom:0,left:0}){t=t.add(-l.left,-l.top,l.left+l.right,l.top+l.bottom);const c=e.naturalWidth||e.width,h=e.naturalHeight||e.height;if(c<=0||h<=0)return;const u=Math.min(r.unit==="percent"?r.top/100*h:Math.min(r.top,h),h),d=Math.min(r.unit==="percent"?r.right/100*c:Math.min(r.right,c),c),f=Math.min(r.unit==="percent"?r.bottom/100*h:Math.min(r.bottom,h),h),g=Math.min(r.unit==="percent"?r.left/100*c:Math.min(r.left,c),c),{left:m,top:b,width:x,height:C}=t;if(x<=0||C<=0)return;const w=Math.min(o,C),y=Math.min(s,x),R=Math.min(i,C-w),M=Math.min(a,x-y);this.drawRegion(e,0,0,g,u,m,b,M,w),this.drawRegion(e,c-d,0,d,u,m+x-y,b,y,w),this.drawRegion(e,c-d,h-f,d,f,m+x-y,b+C-R,y,R),this.drawRegion(e,0,h-f,g,f,m,b+C-R,M,R);const B=[{sx:g,sy:0,sw:c-g-d,sh:u,dx:m+M,dy:b,dw:x-M-y,dh:w,repeat:n.horizontal,horizontal:!0},{sx:c-d,sy:u,sw:d,sh:h-u-f,dx:m+x-y,dy:b+w,dw:y,dh:C-w-R,repeat:n.vertical,horizontal:!1},{sx:g,sy:h-f,sw:c-g-d,sh:f,dx:m+M,dy:b+C-R,dw:x-M-y,dh:R,repeat:n.horizontal,horizontal:!0},{sx:0,sy:u,sw:g,sh:h-u-f,dx:m,dy:b+w,dw:M,dh:C-w-R,repeat:n.vertical,horizontal:!1}];for(const T of B)T.sw<=0||T.sh<=0||T.dw<=0||T.dh<=0||(T.repeat===0?this.ctx.drawImage(e,T.sx,T.sy,T.sw,T.sh,T.dx,T.dy,T.dw,T.dh):(T.repeat===1||T.repeat===2)&&this.drawRepeatedEdge(e,T,T.horizontal,T.repeat===2));r.fill&&this.drawCenterRegion(e,{sx:g,sy:u,sw:c-g-d,sh:h-u-f},{dx:m+M,dy:b+w,dw:x-M-y,dh:C-w-R},n)}drawRegion(t,e,r,n,o,s,i,a,l){n>0&&o>0&&a>0&&l>0&&this.ctx.drawImage(t,e,r,n,o,s,i,a,l)}drawRepeatedEdge(t,e,r,n){const o=r?e.sw:e.sh,s=r?e.dw:e.dh;if(o<=0||s<=0)return;let i,a;n?(a=Math.max(1,Math.round(s/o)),i=s/a):(i=o,a=Math.ceil(s/i)),this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(e.dx,e.dy,e.dw,e.dh),this.ctx.clip();for(let l=0;l<a;l++){const c=l*i;r?this.ctx.drawImage(t,e.sx,e.sy,e.sw,e.sh,e.dx+c,e.dy,i,e.dh):this.ctx.drawImage(t,e.sx,e.sy,e.sw,e.sh,e.dx,e.dy+c,e.dw,i)}this.ctx.restore()}drawCenterRegion(t,e,r,n){if(e.sw<=0||e.sh<=0||r.dw<=0||r.dh<=0)return;const o=(a,l,c)=>{if(a===0)return{size:c,count:1};if(a===2){const h=Math.max(1,Math.round(c/l));return{size:c/h,count:h}}return{size:l,count:Math.max(1,Math.ceil(c/l))}},s=o(n.horizontal,e.sw,r.dw),i=o(n.vertical,e.sh,r.dh);this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(r.dx,r.dy,r.dw,r.dh),this.ctx.clip();for(let a=0;a<i.count;a++)for(let l=0;l<s.count;l++)this.ctx.drawImage(t,e.sx,e.sy,e.sw,e.sh,r.dx+l*s.size,r.dy+a*i.size,s.size,i.size);this.ctx.restore()}};const du=/blur\((\d+(?:\.\d+)?)px\)/gi,fu=(t,e)=>e===1?t:t.replace(du,(r,n)=>`blur(${parseFloat(n)*e}px)`);var pu=class{ctx;pathCallback;scale;activeEffects=[];didSave=!1;saveAtDepth=-1;constructor(t,e){this.ctx=t.ctx,this.pathCallback=e,this.scale=t.scale??1}applyEffects(t){for(;this.activeEffects.length;)this.popEffect();this.didSave=!1,this.saveAtDepth=-1;const e=n=>Cn(n)||Ae(n)||Sn(n),r=t.reduceRight((n,o,s)=>n!==-1?n:e(o)?s:-1,-1);for(let n=0;n<t.length;n++){const o=p(t,n);e(o)&&(this.didSave||(this.ctx.save(),this.didSave=!0),n===r&&(this.saveAtDepth=this.activeEffects.length)),this.applyEffect(o)}}applyEffect(t){Cn(t)?(this.ctx.translate(t.offsetX,t.offsetY),this.ctx.transform(t.matrix[0],t.matrix[1],t.matrix[2],t.matrix[3],t.matrix[4],t.matrix[5]),this.ctx.translate(-t.offsetX,-t.offsetY)):Ae(t)?(this.pathCallback.path(t.path),this.ctx.clip()):Sn(t)?t.applyClip(this.ctx):Nr(t)?this.ctx.globalAlpha*=t.opacity:_r(t)?this.ctx.globalCompositeOperation=t.compositeOperation:Ar(t)&&(this.ctx.filter=fu(t.safeFilterString,this.scale)||"none",t.shadow&&(this.ctx.shadowOffsetX=t.shadow.offsetX*this.scale,this.ctx.shadowOffsetY=t.shadow.offsetY*this.scale,this.ctx.shadowBlur=t.shadow.blur*this.scale,this.ctx.shadowColor=t.shadow.color)),this.activeEffects.push(t)}popEffect(){this.activeEffects.length!==0&&(this.didSave&&this.activeEffects.length-1===this.saveAtDepth&&(this.ctx.restore(),this.didSave=!1,this.saveAtDepth=-1),this.activeEffects.pop(),!this.didSave&&this.activeEffects.length===0&&(this.ctx.globalAlpha=1,this.ctx.globalCompositeOperation="source-over",this.ctx.filter="none",this.ctx.shadowOffsetX=0,this.ctx.shadowOffsetY=0,this.ctx.shadowBlur=0,this.ctx.shadowColor="rgba(0, 0, 0, 0)"))}getActiveEffectCount(){return this.activeEffects.length}hasActiveEffects(){return this.activeEffects.length>0}};const ur=(t,e)=>t.length===0?void 0:t[e%t.length]??t[0],gu=(t,e,r,n)=>{const o=t?t[0]:void 0,s=t&&t.length>1?p(t,1):void 0,i=u=>u!==void 0&&v(u)?u.value:null,a=(u,d,f)=>u===void 0||v(u)?null:I(u)?S(u,d):f,l=i(o);if(l==="contain"||l==="cover"){const u=l==="contain"?Math.min(e.width/r,e.height/n):Math.max(e.width/r,e.height/n);return{width:r*u,height:n*u}}let c=a(o,e.width,r),h=a(s,e.height,n);return c===null&&h===null?(c=r,h=n):c===null?c=r/n*h:h===null&&(h=n/r*c),{width:c,height:h}},mu=(t,e,r,n,o)=>{const s=e.naturalWidth||e.width||o.width,i=e.naturalHeight||e.height||o.height,{width:a,height:l}=gu(ur(r.maskSize,n),o,s,i),c=ur(r.maskPosition,n)??[],h=o.left+S(p(c,0),o.width-a),u=o.top+S(p(c,c.length-1),o.height-l),d=ur(r.maskRepeat,n)??0,f=d===0||d===2,g=d===0||d===3,m=f?Math.ceil((h-o.left)/a):0,b=g?Math.ceil((u-o.top)/l):0,x=f?Math.ceil((o.left+o.width-h)/a):0,C=g?Math.ceil((o.top+o.height-u)/l):0;for(let w=-b;w<=C;w++)for(let y=-m;y<=x;y++)t.drawImage(e,h+y*a,u+w*l,a,l)},bu=(t,e,r)=>{const{width:n,height:o}=r,s=e.position.length===0?[Y]:e.position,i=S(p(s,0),n),a=S(p(s,s.length-1),o);let[l,c]=Ne(e,i,a,n,o);l=Math.max(l,.01),c=Math.max(c,.01);const h=t.canvas.ownerDocument??document,u=We(h,l,c,e.stops,Dr(e));u&&(t.fillStyle=u.lastColor,t.fillRect(r.left,r.top,r.width,r.height),t.drawImage(u.canvas,r.left+i-l,r.top+a-c,l*2,c*2))},xu=(t,e,r)=>{const{width:n,height:o}=r;if(n<=0||o<=0)return;if(po(e)||Dr(e)){bu(t,e,r);return}let s=null;if(e.type===1||e.type===3){const i=e,[a,l,c,h,u]=De(i.angle||0,n,o),d=nt(i.stops,a||1);if(e.type===3){const f=$t(d);if(!f){t.fillStyle=L(p(d,d.length-1).color),t.fillRect(r.left,r.top,n,o);return}s=t.createLinearGradient(r.left+l,r.top+h,r.left+c,r.top+u),f.forEach(g=>s.addColorStop(Math.min(1,Math.max(0,g.stop)),g.color))}else s=t.createLinearGradient(r.left+l,r.top+h,r.left+c,r.top+u),Fe(d).forEach(f=>s.addColorStop(f.stop,f.color))}else if(e.type===5||e.type===6){const i=e,a=nt(i.stops,1),l=e.type===6;if(l&&!$t(a)){t.fillStyle=L(p(a,a.length-1).color),t.fillRect(r.left,r.top,n,o);return}s=t.createConicGradient(i.angle-Math.PI/2,r.left+n/2,r.top+o/2),((l?$t(a):null)??Fe(a)).forEach(c=>s.addColorStop(Math.min(1,Math.max(0,c.stop)),c.color))}s&&(t.fillStyle=s,t.fillRect(r.left,r.top,n,o))},Mn=async(t,e,r,n,o)=>{for(let s=0;s<e.length;s++){const i=p(e,s);if(i.type===0){const a=await o(i.url);a&&mu(t,a,r,s,n)}else xu(t,i,n)}},wu=(t,e,r,n,o)=>{let s=0,i=0,a=t,l=e,c=r.left,h=r.top,u=r.width,d=r.height;const f=u/d,g=a/l,m=o?S(o[0],1):.5,b=o?S(o[1],1):.5;if(n===2)g>f?(d=u/g,h+=(r.height-d)*b):(u=d*g,c+=(r.width-u)*m);else if(n===4)g>f?(a=l*f,s+=(t-a)*m):(l=a/f,i+=(e-l)*b);else if(n===8)a>u?(s+=(a-u)*m,a=u):(c+=(u-a)*m,u=a),l>d?(i+=(l-d)*b,l=d):(h+=(d-l)*b,d=l);else if(n===16){const x=g>f?u:d*g,C=g>f?u/g:d,w=Math.min(a,u),y=Math.min(l,d);x*C<w*y?g>f?(d=u/g,h+=(r.height-d)*b):(u=d*g,c+=(r.width-u)*m):(a>u?(s+=(a-u)*m,a=u):(c+=(u-a)*m,u=a),l>d?(i+=(l-d)*b,l=d):(h+=(d-l)*b,d=l))}return{sx:s,sy:i,sw:a,sh:l,dx:c,dy:h,dw:u,dh:d}};async function yu(t,e,r,n,o,s,i,a){if(o instanceof Io)try{const l=await e.cache.match(o.src),c=t.imageSmoothingEnabled;i.imageRendering===2||i.imageRendering===1?t.imageSmoothingEnabled=!1:i.imageRendering===3&&(t.imageSmoothingEnabled=!0),a(o,s,l),t.imageSmoothingEnabled=c}catch{e.logger.error(`Error loading image ${o.src}`)}if(o instanceof Bo&&a(o,s,o.canvas),o instanceof Oo)try{a(o,s,await e.cache.match(o.svg))}catch{e.logger.error(`Error loading svg ${o.svg.substring(0,255)}`)}if(o instanceof No&&o.tree){const l=await n(e,{scale:r.scale,backgroundColor:o.backgroundColor,x:0,y:0,width:o.width,height:o.height}).render(o.tree);o.width&&o.height&&t.drawImage(l,0,0,o.width,o.height,o.bounds.left,o.bounds.top,o.bounds.width,o.bounds.height)}}function Cu(t,e,r,n,o){if(n instanceof zt){const s=Math.min(n.bounds.width,n.bounds.height);n.type==="checkbox"&&n.checked?(t.save(),r([new E(n.bounds.left+s*.39363,n.bounds.top+s*.79),new E(n.bounds.left+s*.16,n.bounds.top+s*.5549),new E(n.bounds.left+s*.27347,n.bounds.top+s*.44071),new E(n.bounds.left+s*.39694,n.bounds.top+s*.5649),new E(n.bounds.left+s*.72983,n.bounds.top+s*.23),new E(n.bounds.left+s*.84,n.bounds.top+s*.34085),new E(n.bounds.left+s*.39363,n.bounds.top+s*.79)]),t.fillStyle=L(n.styles.accentColor??7733247),t.fill(),t.restore()):n.type==="radio"&&n.checked&&(t.save(),t.beginPath(),t.arc(n.bounds.left+s/2,n.bounds.top+s/2,s/4,0,Math.PI*2,!0),t.fillStyle=L(n.styles.accentColor??7733247),t.fill(),t.restore())}if(Ru(n)&&n.value.length){const[s]=e.createFontStyle(o);t.font=s??"";const i=S(o.fontSize,0),{baseline:a,height:l}=Yo(t,i);t.fillStyle=n instanceof zt&&n.isPlaceholder?L(Ch):L(o.color),t.textBaseline="alphabetic",t.textAlign=Tu(n.styles.textAlign);const c=de(n),h=n instanceof zt?Su(c,Zt(n),l):c;let u=0;switch(n.styles.textAlign){case 1:u+=c.width/2;break;case 2:u+=c.width}let d=0;n instanceof zt&&(d=(c.height-l)/2);const f=c.add(u,d,0,0);t.save(),r([new E(h.left,h.top),new E(h.left+h.width,h.top),new E(h.left+h.width,h.top+h.height),new E(h.left,h.top+h.height)]),t.clip();const g=Eu(t,n.value,c.width,o.whiteSpace==="pre"||o.whiteSpace==="nowrap"),m=Mt(o.lineHeight,i);g.forEach((b,x)=>{let C=f.left;const w=t.measureText(b).width;switch(o.textAlign){case 1:C+=(c.width-w)/2;break;case 2:C+=c.width-w}const y=new W(C,f.top+x*m,0,0);e.renderTextWithLetterSpacing(new mt(b,y),o.letterSpacing,a,o.writingMode)}),t.restore(),t.textBaseline="alphabetic",t.textAlign="left"}}const Su=(t,e,r)=>t.height<r?new W(t.left,e.top,t.width,e.height):t,Eu=(t,e,r,n)=>{const o=[],s=e.split(`
12
+ `);for(const i of s){if(n){o.push(i);continue}const a=i.split(/(\s+)/);let l="";for(const c of a){const h=l+c;t.measureText(h).width<=r||l===""?l=h:(o.push(l),l=c)}o.push(l)}return o};async function vu(t,e,r,n,o,s){if(V(o.styles.display,2048)){if(o.styles.listStyleImage!==null){const i=o.styles.listStyleImage;if(i.type===0){const a=i.url;try{const l=await e.cache.match(a),c=S(s.fontSize,0),h=l?.naturalWidth||l.width,u=l?.naturalHeight||l.height;if(h<=0||u<=0)return;const d=Math.min(c/h,c/u),f=h*d,g=u*d,m=o.bounds.top+S(o.styles.paddingTop,o.bounds.width)+Mt(s.lineHeight,s.fontSize.number)/2;t.drawImage(l,o.bounds.left-(f+10),m-g/2,f,g)}catch{e.logger.error(`Error loading list-style-image ${a}`)}}}else if(n.listValue&&o.styles.listStyleType!==-1){const i=o.styles.listStyleType;if(i===0||i===1||i===2){const a=s.fontSize.number*.45,l=o.bounds.left-a*.9,c=o.bounds.top+S(o.styles.paddingTop,o.bounds.width)+Mt(s.lineHeight,s.fontSize.number)/2;t.save(),t.fillStyle=L(s.color),t.beginPath(),i===2?t.rect(l-a/2,c-a/2,a,a):(t.arc(l,c,a/2,0,Math.PI*2),i===1&&(t.strokeStyle=L(s.color),t.lineWidth=a*.18)),i===1?t.stroke():t.fill(),t.restore()}else{const[a]=r.createFontStyle(s);t.font=a??"",t.fillStyle=L(s.color),t.textBaseline="middle",t.textAlign="right";const l=new W(o.bounds.left,o.bounds.top+S(o.styles.paddingTop,o.bounds.width),o.bounds.width,Mt(s.lineHeight,s.fontSize.number)/2+1);r.renderTextWithLetterSpacing(new mt(n.listValue,l),s.letterSpacing,Mt(s.lineHeight,s.fontSize.number)/2+2,s.writingMode),t.textBaseline="bottom",t.textAlign="left"}}}}const Ru=t=>t instanceof Do||t instanceof Po?!0:t instanceof zt&&t.type!=="radio"&&t.type!=="checkbox",Tu=t=>{switch(t){case 1:return"center";case 2:return"right";default:return"left"}},Ln=(t,e)=>{const r=e>t?e*(1+Math.pow(t/e-1,3)):e;return Math.max(0,t+r)},Fr=(t,e)=>{if(e===0)return t;const r=t.map((l,c)=>X(l)?{x:c%2===0?l.start.x:l.end.x,y:c%2===0?l.end.y:l.start.y,rx:Math.abs(l.end.x-l.start.x),ry:Math.abs(l.end.y-l.start.y)}:{x:l.x,y:l.y,rx:0,ry:0}),n=p(r,1).x-p(r,0).x+2*e,o=p(r,3).y-p(r,0).y+2*e;if(n<=0||o<=0)return[];const s=r.map(l=>({x:Ln(l.rx,e),y:Ln(l.ry,e)})),i=(l,c)=>c>0?l/c:1,a=Math.min(1,i(n,p(s,0).x+p(s,1).x),i(n,p(s,3).x+p(s,2).x),i(o,p(s,0).y+p(s,3).y),i(o,p(s,1).y+p(s,2).y));return t.map((l,c)=>{const h=p(r,c),u=h.x+(c===1||c===2?e:-e),d=h.y+(c>=2?e:-e);if(!X(l))return new E(u,d);const f=p(s,c).x*a,g=p(s,c).y*a;if(!f||!g)return new E(u,d);const m=f/h.rx,b=g/h.ry,x=C=>new E(u+(C.x-h.x)*m,d+(C.y-h.y)*b);return new re(x(l.start),x(l.startControl),x(l.endControl),x(l.end))})},Mu=(t,e,r)=>{const{a:n,b:o,c:s,d:i,e:a,f:l}=t;if(![n,o,s,i,a,l,e,r].every(Number.isFinite))return null;const c=n*i-o*s;if(!Number.isFinite(c)||c===0)return null;const h=(R,M)=>({x:(i*(R-a)-s*(M-l))/c,y:(-o*(R-a)+n*(M-l))/c}),u=[h(0,0),h(e,0),h(e,r),h(0,r)];if(!u.every(R=>Number.isFinite(R.x)&&Number.isFinite(R.y)))return null;const d=Math.min(...u.map(R=>R.x)),f=Math.min(...u.map(R=>R.y)),g=Math.max(...u.map(R=>R.x)),m=Math.max(...u.map(R=>R.y)),b=n*n+o*o,x=s*s+i*i,C=n*s+o*i,w=Math.sqrt((b+x+Math.hypot(b-x,2*C))/2);if(!Number.isFinite(w)||w<=0)return null;const y=1e-10*Math.max(b,x);return{matrix:t,viewport:new W(d,f,g-d,m-f),scale:w,uniform:Math.abs(b-x)<=y&&Math.abs(C)<=y}},ae=(t,e,r)=>{t.beginPath(),t.rect(e.left,e.top,e.width,e.height),r.length&&(ze(t,r),t.closePath())},Lr=(t,e)=>{const r=e.spread.number,n=Zt(t.container);return n.width-2*r<=0||n.height-2*r<=0?[]:Fr(wt(t.curves),-r)},Lu=async(t,e,r,n,o,s)=>{const i=Zt(e.container),a=r.blur.number/2,l=Math.ceil(3*a)+2,c=r.spread.number,h=Mr((r.inset?i:e.container.bounds.add(r.offsetX.number-c,r.offsetY.number-c,2*c,2*c)).add(-l,-l,2*l,2*l),s.viewport,l,s.scale);if(!h.width||!h.height)return!0;const u=Math.ceil(h.width*s.scale),d=Math.ceil(h.height*s.scale),f=oe(o,u,d);if(!f)return!1;let g,m;try{g=t.canvas.ownerDocument.createElement("canvas"),g.width=u,g.height=d;const b=g.getContext("2d");if(!b)return!1;b.scale(s.scale,s.scale),b.translate(-h.left,-h.top);const x=r.inset?Lr(e,r):Fr(at(e.curves),c),C=_e(x,r.offsetX.number,r.offsetY.number,0,0);r.inset?ae(b,h,C):bt(b,C),b.fillStyle=L(r.color),b.fill(r.inset?"evenodd":"nonzero"),m=await Ie(g,{functions:[{kind:"blur",value:a}]},1,s.scale,n.signal),t.save();try{r.inset?(bt(t,wt(e.curves)),t.clip()):(ae(t,s.viewport,at(e.curves)),t.clip("evenodd")),t.drawImage(m,h.left,h.top,m.width/s.scale,m.height/s.scale)}finally{t.restore()}return!0}catch(b){if(!(b instanceof H))throw b;return!1}finally{m&&m!==g&&P(m),g&&P(g),o.pixels-=f}},Iu=async(t,e,r,n,o)=>{if(n.signal?.aborted)throw new DOMException("The operation was aborted.","AbortError");if(ot(r.color))return;const s=r.spread.number;if(!r.inset&&(e.container.bounds.width+2*s<=0||e.container.bounds.height+2*s<=0))return;const i=typeof t.getTransform=="function",a=i?t.getTransform():{a:n.scale,b:0,c:0,d:n.scale,e:-n.x*n.scale,f:-n.y*n.scale},l=Mu(a,t.canvas.width,t.canvas.height);if(!l)return;const{viewport:c}=l;if(r.blur.number>0&&(r.inset||!l.uniform)&&await Lu(t,e,r,n,o,l))return;const h=Zt(e.container);t.save();try{if(r.inset&&r.blur.number===0){bt(t,wt(e.curves)),t.clip(),ae(t,h,_e(Lr(e,r),r.offsetX.number,r.offsetY.number,0,0)),t.fillStyle=L(r.color),t.fill("evenodd");return}const u=Math.ceil(r.blur.number*2+Math.abs(s)+Math.abs(r.offsetX.number)+Math.abs(r.offsetY.number))+2,d=r.inset?h.add(-u,-u,2*u,2*u):e.container.bounds.add(-s,-s,2*s,2*s),{a:f,b:g,c:m,d:b,e:x,f:C}=a,w=d.left+d.width,y=d.top+d.height,R=Math.max(f*d.left+m*d.top+x,f*w+m*d.top+x,f*w+m*y+x,f*d.left+m*y+x),M=Math.max(vc,R+u*l.scale+2);r.inset?(bt(t,wt(e.curves)),t.clip()):(ae(t,c,at(e.curves)),t.clip("evenodd")),i?t.setTransform(f,g,m,b,x-M,C):t.translate(-M/f,0),r.inset?ae(t,d,Lr(e,r)):bt(t,Fr(at(e.curves),s)),i?t.setTransform(f,g,m,b,x,C):t.translate(M/f,0),t.shadowOffsetX=M+f*r.offsetX.number+m*r.offsetY.number,t.shadowOffsetY=g*r.offsetX.number+b*r.offsetY.number,t.shadowBlur=r.blur.number*l.scale,t.shadowColor=L(r.color),t.fillStyle="rgb(0, 0, 0)",t.fill(r.inset?"evenodd":"nonzero")}finally{t.restore()}};var Bu=class{ctx;context;scale;createFontStyle;constructor(t){this.ctx=t.ctx,this.context=t.context,this.scale=t.scale,this.createFontStyle=t.createFontStyle}async render(t){const e=t.container,r=e.styles,n=e.bounds,o=this.scale;if(n.width<=0||n.height<=0)return;const s=this.ctx.canvas.ownerDocument??document,i=Math.ceil(n.width),a=Math.ceil(n.height),l=Math.ceil(n.width*o),c=Math.ceil(n.height*o),h=this.createLayer(s,l,c);if(!h)return;let u=null,d=null,f=null;try{h.ctx.scale(o,o);const[g]=this.createFontStyle(r);h.ctx.font=g??"",h.ctx.textBaseline="alphabetic",h.ctx.textAlign="left",h.ctx.direction=r.direction===1?"rtl":"ltr";const m=Xo(h.ctx,r.fontSize.number),b=new jo({ctx:h.ctx,context:this.context,canvas:h.canvas,options:{width:i,height:a,scale:1}});ot(r.backgroundColor)||(h.ctx.fillStyle=L(r.backgroundColor),h.ctx.fillRect(0,0,i,a)),h.ctx.save(),h.ctx.translate(-n.left,-n.top),await b.renderBackgroundImage(e),h.ctx.restore();const x={bounds:n,baseline:m,letterSpacing:r.letterSpacing,writingMode:r.writingMode};if(u=this.createGlyphLayer(s,l,c,h.ctx),!u)return;const C=!!r.webkitTextStrokeWidth;C&&(u.ctx.strokeStyle=L(r.webkitTextStrokeColor),u.ctx.lineWidth=r.webkitTextStrokeWidth,u.ctx.lineJoin=Ko());for(const w of e.textNodes)for(const y of w.textBounds)this.drawGlyphs(u,y,x,(R,M,B,T)=>{R.fillText(M,B,T),C&&R.strokeText(M,B,T)});if(h.ctx.globalCompositeOperation="destination-in",h.ctx.drawImage(u.canvas,0,0,i,a),f=this.renderShadowSilhouettes(t,s,l,c,h.ctx,r,x),f){if(d=this.createLayer(s,l,c),!d)return;for(const w of f)d.ctx.drawImage(w,0,0);d.ctx.drawImage(h.canvas,0,0),this.ctx.drawImage(d.canvas,n.left,n.top,n.width,n.height)}else this.ctx.drawImage(h.canvas,n.left,n.top,n.width,n.height)}finally{P(h.canvas),u&&P(u.canvas),d&&P(d.canvas),f&&f.forEach(P)}}createLayer(t,e,r){const n=t.createElement("canvas");n.width=e,n.height=r;const o=n.getContext("2d");return o?{canvas:n,ctx:o}:null}createGlyphLayer(t,e,r,n){const o=this.createLayer(t,e,r);return o?(o.ctx.scale(this.scale,this.scale),o.ctx.font=n.font,o.ctx.textBaseline=n.textBaseline,o.ctx.textAlign=n.textAlign,o.ctx.direction=n.direction,o.ctx.fillStyle="#000",o):null}drawGlyphs(t,e,r,n){const o=e.bounds.left-r.bounds.left,s=e.bounds.top-r.bounds.top+r.baseline,{letterSpacing:i,writingMode:a}=r;if(i<=0){n(t.ctx,e.text,o,s);return}if(ie(a)){n(t.ctx,e.text,o,s);return}let l=o;for(const c of gt(e.text))n(t.ctx,c,l,s),l+=t.ctx.measureText(c).width+i}renderShadowSilhouettes(t,e,r,n,o,s,i){const a=s.textShadow;if(!a.length)return null;const l=[];for(let c=a.length-1;c>=0;c--){const h=p(a,c),u=this.createGlyphLayer(e,r,n,o);if(u){u.ctx.shadowColor=L(h.color),u.ctx.shadowOffsetX=h.offsetX.number*this.scale,u.ctx.shadowOffsetY=h.offsetY.number*this.scale,u.ctx.shadowBlur=h.blur.number*this.scale,u.ctx.fillStyle=L(h.color);for(const d of t.container.textNodes)for(const f of d.textBounds)this.drawGlyphs(u,f,i,(g,m,b,x)=>{g.fillText(m,b,x)});l.push(u.canvas)}}return l.length?l:null}},Ou=class Ir{surfaceRoot;surfaceBudget;canvas;ctx;context;options;backgroundRenderer;borderRenderer;borderImageRenderer;effectsRenderer;textRenderer;textClipRenderer;legacySubtree=!1;constructor(e,r,n,o={pixels:0}){this.surfaceRoot=n,this.surfaceBudget=o,this.context=e,this.options=r,this.canvas=r.canvas?r.canvas:e.resourceDocument.createElement("canvas");const s=this.canvas.getContext("2d");if(!s)throw r.canvas||P(this.canvas),n?new H("Filter surface canvas is unavailable"):new Error("Failed to get 2D rendering context from canvas");this.ctx=s,r.canvas||(this.canvas.width=Math.floor(r.width*r.scale),this.canvas.height=Math.floor(r.height*r.scale),this.canvas.style.width=`${r.width}px`,this.canvas.style.height=`${r.height}px`),this.ctx.scale(this.options.scale,this.options.scale),this.ctx.translate(-r.x,-r.y),this.ctx.textBaseline="bottom",r.imageSmoothing!==void 0&&(this.ctx.imageSmoothingEnabled=r.imageSmoothing),r.imageSmoothingQuality&&(this.ctx.imageSmoothingQuality=r.imageSmoothingQuality),this.backgroundRenderer=new jo({ctx:this.ctx,context:this.context,canvas:this.canvas,options:{width:r.width,height:r.height,scale:r.scale}}),this.borderRenderer=new lu({ctx:this.ctx},{path:i=>this.path(i),formatPath:i=>this.formatPath(i)}),this.borderImageRenderer=new uu(this.ctx),this.effectsRenderer=new pu({ctx:this.ctx,scale:r.scale},{path:i=>this.path(i)}),this.textRenderer=new nu({ctx:this.ctx,options:{scale:r.scale}}),this.textClipRenderer=new Bu({ctx:this.ctx,context:this.context,scale:r.scale,createFontStyle:i=>this.textRenderer.createFontStyle(i)}),this.context.logger.debug(`Canvas renderer initialized (${r.width}x${r.height}) with scale ${r.scale}`)}async renderStack(e){const r=e.element.container.styles;if(r.isVisible()){const n=Le(r.filter),o=n!==null&&n.functions.length>0,s=r.maskImage.length>0,i=r.webkitBoxReflect,a=r.mixBlendMode!==A.NORMAL;if(e.element!==this.surfaceRoot&&!this.legacySubtree&&(s||i||a||n!==null&&(o||r.opacity<1))&&this.canComposite(e.element)){if(!await this.renderCompositedStack(e,n,s,i,a)){this.legacySubtree=!0;try{await this.renderStackContent(e)}finally{this.legacySubtree=!1}}return}await this.renderStackContent(e)}}canComposite(e){const r=s=>{const i=s.styles;return!i.isTransformed()&&i.zoom===1&&i.clipPath.type===0&&!V(i.display,2048)&&Le(i.filter)!==null},n=s=>r(s)&&s.elements.every(n);let o=e.parent;for(;o&&o!==this.surfaceRoot;){if(!r(o.container))return!1;o=o.parent}return n(e.container)}async renderCompositedStack(e,r,n,o,s=!1){const i=this.options.signal;if(i?.aborted)throw new DOMException("The operation was aborted.","AbortError");const a=Mr(Ho(e.element.container),new W(this.options.x,this.options.y,this.options.width,this.options.height),r?Go(r):0,this.options.scale);if(!a.width||!a.height)return!0;const l=oe(this.surfaceBudget,Math.ceil(a.width*this.options.scale),Math.ceil(a.height*this.options.scale));if(!l)return this.context.logger.info("Filter surface budget exceeded; using the existing renderer"),!1;const c={...this.options,canvas:void 0,backgroundColor:null,x:a.left,y:a.top,width:a.width,height:a.height};let h,u;try{h=new Ir(this.context,c,e.element,this.surfaceBudget),await h.renderStackContent(e),h.effectsRenderer.applyEffects([]),r&&(u=await Ie(h.canvas,r,e.element.container.styles.opacity,c.scale,i));const d=u??h.canvas;if(n&&await this.applyMask(d,e.element.container.styles,a),i?.aborted)throw new DOMException("The operation was aborted.","AbortError");const f=e.element.effects,g=e.element.getEffects(4,this.surfaceRoot).filter(m=>!f.includes(m)||!Ar(m)&&!Nr(m)&&!_r(m)&&!Ae(m));return this.effectsRenderer.applyEffects(g),s?(this.ctx.save(),this.ctx.globalCompositeOperation=e.element.container.styles.mixBlendMode,this.ctx.drawImage(d,c.x,c.y,d.width/c.scale,d.height/c.scale),this.ctx.restore()):this.ctx.drawImage(d,c.x,c.y,d.width/c.scale,d.height/c.scale),o&&await this.drawReflection(d,e.element.container.bounds,a,o),!0}catch(d){if(!(d instanceof H))throw d;return this.context.logger.info(`${d.message}; using the existing renderer`),!1}finally{h&&P(h.canvas),u&&P(u),this.surfaceBudget.pixels-=l}}async applyMask(e,r,n){const o=e.getContext("2d");if(!o)return;const s=this.context.resourceDocument.createElement("canvas");s.width=e.width,s.height=e.height;const i=s.getContext("2d");if(i){i.scale(this.options.scale,this.options.scale),i.translate(-n.left,-n.top);try{await Mn(i,r.maskImage,r,{left:n.left,top:n.top,width:n.width,height:n.height},async a=>await this.context.cache.match(a))}catch(a){this.context.logger.error(`Error rendering mask-image: ${a instanceof Error?a.message:a}`);return}o.save();try{o.setTransform(1,0,0,1,0,0),o.globalCompositeOperation="destination-in",o.drawImage(s,0,0)}finally{o.restore()}}}async drawReflection(e,r,n,o){const s=this.options.scale,i=Math.ceil(r.width*s),a=Math.ceil(r.height*s);if(i<=0||a<=0)return;const l=oe(this.surfaceBudget,i,a);if(!l)return;let c,h;try{c=this.context.resourceDocument.createElement("canvas"),c.width=i,c.height=a;const u=c.getContext("2d");if(!u)return;const d=Math.round((r.left-n.left)*s),f=Math.round((r.top-n.top)*s),g=o.direction==="left"||o.direction==="right";u.save();try{g?(u.translate(i,0),u.scale(-1,1)):(u.translate(0,a),u.scale(1,-1)),u.drawImage(e,-d,-f)}finally{u.restore()}if(o.mask){h=this.context.resourceDocument.createElement("canvas"),h.width=i,h.height=a;const C=h.getContext("2d");if(C){C.scale(s,s),await Mn(C,[o.mask],{maskPosition:[],maskRepeat:[],maskSize:[]},{left:0,top:0,width:r.width,height:r.height},async w=>await this.context.cache.match(w)),u.save();try{g?(u.translate(i,0),u.scale(-1,1)):(u.translate(0,a),u.scale(1,-1)),u.globalCompositeOperation="destination-in",u.drawImage(h,0,0,i,a)}finally{u.restore()}}}const m=o.offset;let b=r.left,x=r.top;o.direction==="below"?x=r.top+r.height+m:o.direction==="above"?x=r.top-r.height-m:o.direction==="right"?b=r.left+r.width+m:b=r.left-r.width-m,this.ctx.save();try{this.ctx.filter="none",this.ctx.drawImage(c,b,x,r.width,r.height)}finally{this.ctx.restore()}}finally{c&&P(c),h&&P(h),this.surfaceBudget.pixels-=l}}async renderNode(e){if(e.container.debugRender)debugger;e.container.styles.isVisible()&&(await this.renderNodeBackgroundAndBorders(e),await this.renderNodeContent(e))}renderReplacedElement(e,r,n){const o=n.naturalWidth||e.intrinsicWidth,s=n.naturalHeight||e.intrinsicHeight;if(n&&o>0&&s>0){const i=de(e),a=wt(r);this.path(a),this.ctx.save(),this.ctx.clip();const{sx:l,sy:c,sw:h,sh:u,dx:d,dy:f,dw:g,dh:m}=wu(o,s,i,e.styles.objectFit,e.styles.objectPosition);this.ctx.drawImage(n,l,c,h,u,d,f,g,m),this.ctx.restore()}}async renderNodeContent(e){this.effectsRenderer.applyEffects(e.getEffects(4,this.surfaceRoot));const r=e.container,n=e.curves,o=r.styles,s=de(r);for(const i of r.textNodes)await this.textRenderer.renderTextNode(i,o,s);await yu(this.ctx,this.context,{scale:this.options.scale,backgroundColor:this.options.backgroundColor,x:this.options.x,y:this.options.y,width:this.options.width,height:this.options.height},(i,a)=>new Ir(i,a),r,n,o,(i,a,l)=>this.renderReplacedElement(i,a,l)),Cu(this.ctx,this.textRenderer,this.path.bind(this),r,o),await vu(this.ctx,this.context,this.textRenderer,e,r,o)}async renderStackContent(e){if(e.element.container.debugRender)debugger;const r=this.options.signal;await this.renderNodeBackgroundAndBorders(e.element);for(const n of e.negativeZIndex){if(r?.aborted)throw new DOMException("The operation was aborted.","AbortError");await this.renderStack(n)}if(r?.aborted)throw new DOMException("The operation was aborted.","AbortError");await this.renderNodeContent(e.element);for(const n of e.nonInlineLevel)await this.renderNode(n);for(const n of e.nonPositionedFloats){if(r?.aborted)throw new DOMException("The operation was aborted.","AbortError");await this.renderStack(n)}for(const n of e.nonPositionedInlineLevel){if(r?.aborted)throw new DOMException("The operation was aborted.","AbortError");await this.renderStack(n)}for(const n of e.inlineLevel)await this.renderNode(n);for(const n of e.zeroOrAutoZIndexOrTransformedOrOpacity){if(r?.aborted)throw new DOMException("The operation was aborted.","AbortError");await this.renderStack(n)}for(const n of e.positiveZIndex){if(r?.aborted)throw new DOMException("The operation was aborted.","AbortError");await this.renderStack(n)}}path(e){bt(this.ctx,e)}formatPath(e){ze(this.ctx,e)}async renderSurfaceBoxShadow(e,r){const n=r.spread.number,o=r.blur.number/2,s=Math.ceil(3*o)+1,i=e.container.bounds.add(-n,-n,2*n,2*n);if(i.width<=0||i.height<=0)return;const a=this.options.scale,l=Mr(i.add(-s,-s,2*s,2*s),new W(this.options.x-r.offsetX.number,this.options.y-r.offsetY.number,this.options.width,this.options.height),s,a);if(!l.width||!l.height)return;const c=Math.ceil(l.width*a),h=Math.ceil(l.height*a),u=oe(this.surfaceBudget,c,h);if(!u)throw new H("Box shadow surface budget exceeded");let d,f;try{d=this.context.resourceDocument.createElement("canvas"),d.width=c,d.height=h;const g=d.getContext("2d");if(!g)throw new H("Box shadow surface canvas is unavailable");g.scale(a,a),g.translate(-l.left,-l.top),bt(g,_e(at(e.curves),-n,-n,2*n,2*n)),g.fillStyle=L(r.color),g.fill(),f=await Ie(d,{functions:[{kind:"blur",value:o}]},1,a,this.options.signal),this.ctx.save();try{this.ctx.beginPath(),this.ctx.rect(this.options.x,this.options.y,this.options.width,this.options.height),ze(this.ctx,at(e.curves)),this.ctx.closePath(),this.ctx.clip("evenodd"),this.ctx.drawImage(f,l.left+r.offsetX.number,l.top+r.offsetY.number,f.width/a,f.height/a)}finally{this.ctx.restore()}}finally{d&&P(d),f&&P(f),this.surfaceBudget.pixels-=u}}async renderNodeBackgroundAndBorders(e){this.effectsRenderer.applyEffects(e.getEffects(2,this.surfaceRoot)),!this.surfaceRoot&&e.container.styles.backdropFilter&&await this.renderBackdropFilter(e);const r=e.container.styles,n=!ot(r.backgroundColor)||r.backgroundImage.length,o=Pu(r),s=[{style:r.borderTopStyle,color:r.borderTopColor,width:r.borderTopWidth},{style:r.borderRightStyle,color:r.borderRightColor,width:r.borderRightWidth},{style:r.borderBottomStyle,color:r.borderBottomColor,width:r.borderBottomWidth},{style:r.borderLeftStyle,color:r.borderLeftColor,width:r.borderLeftWidth}],i=Rt(r.backgroundClip,0),a=ku(i,e.curves);if(n||r.boxShadow.length){o&&e.container.textNodes.length>0?await this.textClipRenderer.render(e):(this.ctx.save(),this.path(a),this.ctx.clip(),ot(r.backgroundColor)||(this.ctx.fillStyle=L(r.backgroundColor),this.ctx.fill()),await this.backgroundRenderer.renderBackgroundImage(e.container),this.ctx.restore());for(const c of r.boxShadow.slice(0).reverse()){if(this.surfaceRoot&&!c.inset){await this.renderSurfaceBoxShadow(e,c);continue}await Iu(this.ctx,e,c,this.options,this.surfaceBudget)}}if(r.borderImageSource){const c=r.borderImageSource,h=e.container.bounds,u=[Math.max(0,r.borderTopWidth),Math.max(0,r.borderRightWidth),Math.max(0,r.borderBottomWidth),Math.max(0,r.borderLeftWidth)];let d=null;if(c.type===0){const f=c.url;try{d=await this.context.cache.match(f)??null}catch{this.context.logger.error(`Error loading border-image ${f}`)}}else d=this.rasterizeGradientSource(c,h);if(d){const f=hu(r.borderImageOutset,u),g=h.add(-f.left,-f.top,f.left+f.right,f.top+f.bottom),m=cu(r.borderImageWidth,u,g);this.borderImageRenderer.renderBorderImage(h,d,r.borderImageSlice,r.borderImageRepeat,m[0],m[1],m[2],m[3],f)}return}let l=0;for(const c of s){if(c.style!==0&&!ot(c.color)&&c.width>0){const h=async()=>{c.style===2?await this.borderRenderer.renderDashedDottedBorder(c.color,c.width,l,e.curves,2):c.style===3?await this.borderRenderer.renderDashedDottedBorder(c.color,c.width,l,e.curves,3):c.style===4?await this.borderRenderer.renderDoubleBorder(c.color,c.width,l,e.curves):await this.borderRenderer.renderSolidBorder(c.color,l,e.curves)},u=e.container.legendBounds;if(l===0&&u){const d=e.container.bounds,f=u.left-d.left,g=u.left+u.width-d.left;f>0&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(d.left,d.top,f,d.height),this.ctx.clip(),await h(),this.ctx.restore());const m=d.left+g,b=d.width-g;b>0&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(m,d.top,b,d.height),this.ctx.clip(),await h(),this.ctx.restore())}else await h()}l++}this.renderOutline(e)}renderOutline(e){const r=e.container.styles;if(r.outlineStyle===0||r.outlineStyle===1)return;const n=Math.max(0,r.outlineWidth);if(n<=0)return;const o=r.outlineColor??r.color;if(ot(o))return;const s=Math.max(0,r.outlineOffset)+n/2,i=_e(at(e.curves),-s,-s,2*s,2*s);this.ctx.save();try{this.ctx.strokeStyle=L(o),this.ctx.lineWidth=n,r.outlineStyle===3?this.ctx.setLineDash([n*3,n*3]):r.outlineStyle===4&&this.ctx.setLineDash([n,n*2]),this.path(i),this.ctx.stroke()}finally{this.ctx.restore()}}rasterizeGradientSource(e,r){const n=Math.max(1,Math.ceil(r.width)),o=Math.max(1,Math.ceil(r.height)),s=(this.ctx.canvas.ownerDocument??document).createElement("canvas");s.width=n,s.height=o;const i=s.getContext("2d");if(!i)return null;if(e.type===1||e.type===3){const a=e,[l,c,h,u,d]=De(a.angle,n,o),f=nt(a.stops,l||n),g=e.type===3,m=g?$t(f):null,b=i.createLinearGradient(c,h,u,d);if(m)m.forEach(x=>{b.addColorStop(Math.min(1,Math.max(0,x.stop)),x.color)});else if(g){const x=L(p(f,f.length-1).color);b.addColorStop(0,x),b.addColorStop(1,x)}else Fe(f).forEach(x=>{b.addColorStop(x.stop,x.color)});return i.fillStyle=b,i.fillRect(0,0,n,o),s}if(e.type===2||e.type===4){const a=e,l=a.position.length===0?[Y]:a.position,c=S(p(l,0),n),h=S(p(l,l.length-1),o),[u,d]=Ne(a,c,h,n,o);if(u<=0||d<=0)return null;const f=this.ctx.canvas.ownerDocument??document,g=We(f,u,d,a.stops,e.type===4);return g?(i.fillStyle=g.lastColor,i.fillRect(0,0,n,o),i.drawImage(g.canvas,c-u,h-d,u*2,d*2),s):null}if(e.type===5||e.type===6){const a=e,l=S(p(a.position,0),n),c=S(p(a.position,1),o),h=i.createConicGradient(a.angle-Math.PI/2,l,c);let u;if(e.type===6){const d=nt(a.stops,1),f=p(d,0),g=p(d,d.length-1),m=Math.max(g.stop-f.stop,.01);u=[];const b=Math.ceil(1/m);for(let C=0;C<b;C++)for(const w of d){const y=C*m+(w.stop-f.stop);if(y>1)break;u.push({stop:y,color:L(w.color)})}const x=p(u,u.length-1);x&&x.stop<1&&u.push({stop:1,color:x.color})}else u=nt(a.stops,Math.max(n,o)).map(d=>({stop:d.stop,color:L(d.color)}));return u.forEach(d=>{h.addColorStop(Math.min(1,Math.max(0,d.stop)),d.color)}),i.fillStyle=h,i.fillRect(0,0,n,o),s}return this.context.logger.warn("Unsupported border-image source; only URL and gradient images are supported"),null}async renderBackdropFilter(e){const r=Le(e.container.styles.backdropFilter);if(!r||r.functions.length===0)return;const n=e.container.bounds;if(n.width<=0||n.height<=0)return;const o=this.options.scale,s=Math.ceil(n.width*o),i=Math.ceil(n.height*o);if(s<=0||i<=0)return;const a=oe(this.surfaceBudget,s,i);if(!a)return;let l,c;try{l=this.context.resourceDocument.createElement("canvas"),l.width=s,l.height=i;const h=l.getContext("2d");if(!h)return;const u=Math.round((n.left-this.options.x)*o),d=Math.round((n.top-this.options.y)*o);h.drawImage(this.canvas,u,d,s,i,0,0,s,i);try{c=await Ie(l,r,1,o,this.options.signal)}catch(f){if(f instanceof H){this.context.logger.info(`${f.message}; rendering without the backdrop effect`);return}throw f}if(this.options.signal?.aborted)throw new DOMException("The operation was aborted.","AbortError");this.ctx.save();try{this.ctx.filter="none",this.ctx.drawImage(c,n.left,n.top,n.width,n.height)}finally{this.ctx.restore()}}finally{l&&P(l),c&&P(c),this.surfaceBudget.pixels-=a}}async render(e){try{this.options.backgroundColor&&(this.ctx.fillStyle=L(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height));const r=kh(e);return await this.renderStack(r),this.effectsRenderer.applyEffects([]),this.canvas}catch(r){throw this.options.canvas||P(this.canvas),r}}};const ku=(t,e)=>{switch(t){case 0:return at(e);case 2:return Th(e);default:return wt(e)}},Pu=t=>t.backgroundClip.some(e=>e===3);var Du=class{canvas;ctx;options;context;constructor(t,e){this.context=t,this.options=e,this.canvas=e.canvas?e.canvas:t.resourceDocument.createElement("canvas");const r=this.canvas.getContext("2d");if(!r)throw new Error("Failed to get 2D rendering context from canvas");this.ctx=r,this.canvas.width=Math.floor(e.width*e.scale),this.canvas.height=Math.floor(e.height*e.scale),this.canvas.style.width=`${e.width}px`,this.canvas.style.height=`${e.height}px`,this.ctx.scale(this.options.scale,this.options.scale),this.ctx.translate(-e.x,-e.y),this.context.logger.debug(`EXPERIMENTAL ForeignObject renderer initialized (${e.width}x${e.height} at ${e.x},${e.y}) with scale ${e.scale}`)}async render(t){if(this.options.signal?.aborted)throw new DOMException("The operation was aborted.","AbortError");const e=Nu(t),r=rh(this.options.width,this.options.height,0,0,t),n=nh(r);e();const o=await n;if(this.options.signal?.aborted)throw new DOMException("The operation was aborted.","AbortError");return this.options.backgroundColor&&(this.ctx.fillStyle=L(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height)),this.ctx.drawImage(o,this.options.x,this.options.y,this.options.width,this.options.height),this.canvas}};const In=["marginTop","marginRight","marginBottom","marginLeft","top","right","bottom","left"],Nu=t=>{const e=t.style,r=In.map(n=>[n,e[n]]);for(const n of In)e[n]=n.startsWith("margin")?"0px":"auto";return()=>{for(const[n,o]of r)e[n]=o}};var _u=class{id;enabled;start;constructor({id:t,enabled:e}){this.id=t,this.enabled=e,this.start=Date.now()}debug(...t){this.enabled&&(typeof window<"u"&&window.console&&typeof console.debug=="function"?console.debug(this.id,`${this.getTime()}ms`,...t):this.info(...t))}getTime(){return Date.now()-this.start}info(...t){this.enabled&&typeof window<"u"&&window.console&&typeof console.info=="function"&&console.info(this.id,`${this.getTime()}ms`,...t)}warn(...t){this.enabled&&(typeof window<"u"&&window.console&&typeof console.warn=="function"?console.warn(this.id,`${this.getTime()}ms`,...t):this.info(...t))}error(...t){this.enabled&&(typeof window<"u"&&window.console&&typeof console.error=="function"?console.error(this.id,`${this.getTime()}ms`,...t):this.info(...t))}},Au=class{context;_options;_cache=new Map;maxSize;_pendingOperations=new Map;_deferMode=!1;_collectedUrls=new Set;_evictionSuspendCount=0;get _evictionEnabled(){return this._evictionSuspendCount===0}constructor(t,e){if(this.context=t,this._options=e,this.maxSize=e.maxCacheSize??100,this.maxSize<1)throw new Error("Cache maxSize must be at least 1");this.maxSize>1e4&&this.context.logger.warn(`Cache maxSize ${this.maxSize} is very large and may cause memory issues. Consider using a smaller value (recommended: 100-1000).`)}startDefer(){this._deferMode=!0,this._evictionSuspendCount++}async preloadAll(t=10,e,r){this._deferMode=!1;const n=Array.from(this._collectedUrls);this._collectedUrls.clear();try{if(n.length===0)return;const o=Math.max(1,Math.min(t,100));this.context.logger.debug(`Preloading ${n.length} image(s) with concurrency ${o}`);let s=0;const i=r?new Promise((a,l)=>{const c=()=>l(new DOMException("The operation was aborted.","AbortError"));r.aborted?c():r.addEventListener("abort",c,{once:!0})}):null;i?.catch(()=>{}),e?.(0,n.length);for(let a=0;a<n.length;a+=o){$(r);const l=n.slice(a,a+o);l.map(h=>this._addImageWithPending(h));const c=Promise.allSettled(l.map(h=>this._cache.get(h)?.value??Promise.resolve()));await(i?Promise.race([c,i]):c),s+=l.length,e?.(s,n.length)}}finally{this._evictionSuspendCount=Math.max(0,this._evictionSuspendCount-1)}}addImage(t){if(this._deferMode)return!this.has(t)&&(Jt(t)||Bn(t))&&this._collectedUrls.add(t),Promise.resolve();const e=this._pendingOperations.get(t);if(e)return e;if(this.has(t)){const r=this._cache.get(t);return this._cache.delete(t),this._cache.set(t,r),Promise.resolve()}return Jt(t)||Bn(t)?this._addImageWithPending(t):Promise.resolve()}_addImageWithPending(t){const e=this._pendingOperations.get(t);if(e)return e;const r=this._addImageInternal(t);return this._pendingOperations.set(t,r),r.finally(()=>{this._pendingOperations.delete(t)}),r}async _addImageInternal(t){const e=this._options.imageTimeout??15e3,r=this.withTimeout(this.loadImage(t),e,`Timed out (${e}ms) loading image`);r.catch(n=>{const o=n instanceof Error?n.message:String(n),s=`Failed to load image ${t.substring(0,256)}: ${o}`;this.context.logger.error(s),this.context.onError?.(new Error(s))}),this.set(t,r)}withTimeout(t,e,r){if(e<=0)return t;let n;const o=new Promise((s,i)=>{n=setTimeout(()=>i(new Error(r)),e)});return Promise.race([t,o]).finally(()=>{n!==void 0&&clearTimeout(n)})}match(t){const e=this._cache.get(t);if(e)return this._cache.delete(t),this._cache.set(t,e),e.value}set(t,e){if(this._cache.has(t))this._cache.delete(t);else if(this._evictionEnabled&&this._cache.size>=this.maxSize){const r=this._cache.keys().next().value;r!==void 0&&(this._cache.delete(r),this.context.logger.debug(`Cache: Evicted LRU entry: ${r}`))}this._cache.set(t,{value:e})}size(){return this._cache.size}getMaxSize(){return this.maxSize}clear(){this._cache.clear()}async loadImage(t){const e=this.context.originChecker,r=c=>e.isSameOrigin(c),n=typeof this._options.customIsSameOrigin=="function"?await this._options.customIsSameOrigin(t,r):r(t),o=!n&&this._options.allowTaint===!1&&!Re(t)&&!Jt(t)&&typeof this._options.proxy!="string",s=!Re(t)&&(this._options.useCORS===!0||o)&&Lt.SUPPORT_CORS_IMAGES&&!n,i=!Re(t)&&!n&&!Jt(t)&&typeof this._options.proxy=="string"&&!s;if(!n&&this._options.allowTaint===!1&&!Re(t)&&!Jt(t)&&!i&&!s)return;let a=t;i&&(a=await this.proxy(a)),this.context.logger.debug(`Added image ${t.substring(0,256)}`);const l=this.context.config.window.Image??Image;return await new Promise((c,h)=>{const u=new l;u.onload=()=>c(u),u.onerror=h,(zu(a)||s)&&(u.crossOrigin="anonymous"),u.src=a,u.complete===!0&&(typeof u.decode=="function"?u.decode().then(()=>c(u),()=>h(new Error(`Failed to decode image ${a.substring(0,256)}`))):setTimeout(()=>c(u),500))})}has(t){return this._cache.has(t)}keys(){return Promise.resolve(Array.from(this._cache.keys()))}proxy(t){const e=this._options.proxy;if(!e)throw new Error("No proxy defined");const r=t.substring(0,256);return new Promise((n,o)=>{const s=new XMLHttpRequest;s.onload=()=>{if(s.status===200){const a=new FileReader;a.addEventListener("load",()=>n(a.result),!1),a.addEventListener("error",l=>o(l),!1),a.readAsDataURL(s.response)}else o(`Failed to proxy resource ${r} with status code ${s.status}`)},s.onerror=o;const i=e.indexOf("?")>-1?"&":"?";if(s.open("GET",`${e}${i}url=${encodeURIComponent(t)}&responseType=blob`),s.responseType="blob",this._options.imageTimeout){const a=this._options.imageTimeout;s.timeout=a,s.ontimeout=()=>o(`Timed out (${a}ms) proxying ${r}`)}s.send()})}};const Fu=/^data:image\/svg\+xml/i,Wu=/^data:image\/.*;base64,/i,Vu=/^data:image\/.*/i,Bn=t=>Lt.SUPPORT_SVG_DRAWING||!Uu(t),Re=t=>Vu.test(t),zu=t=>Wu.test(t),Jt=t=>t.substring(0,4)==="blob",Uu=t=>t.slice(-3).toLowerCase()==="svg"||Fu.test(t);var $u=class{baseUri;origin;constructor(t){if(!t||!t.document)throw new Error("Valid window object required for OriginChecker");if(!t.location||!t.location.href)throw new Error("Window object must have valid location");this.baseUri=t.location.href,this.origin=this.getOrigin(t.location.href)}getOrigin(t){try{return new URL(t,this.baseUri).origin}catch{return""}}isSameOrigin(t){return this.getOrigin(t)===this.origin}getContextOrigin(){return this.origin}},Gu=class Zo{static instanceCount=1;instanceName=`#${Zo.instanceCount++}`;logger;cache;originChecker;config;onError;_windowBounds;constructor(e,r,n){this.config=n,this.logger=new _u({id:this.instanceName,enabled:e.logging}),this.originChecker=new $u(n.window),this.cache=e.cache??n.cache??new Au(this,e),this.onError=e.onError,this._windowBounds=r}get windowBounds(){return this._windowBounds}get resourceDocument(){const e=this.config.window.document;return e||(typeof document<"u"?document:void 0)}adjustWindowBounds(e,r){this._windowBounds=this._windowBounds.add(e,r,0,0)}};const Hu=t=>{["scale","width","height","imageTimeout","x","y","windowWidth","windowHeight","scrollX","scrollY"].forEach(e=>{const r=t[e];if(r!=null&&typeof r!="number"){const n=Number(r);Number.isNaN(n)||(t[e]=n)}})},Yu=t=>({allowTaint:t.allowTaint??!1,imageTimeout:t.imageTimeout??15e3,proxy:t.proxy,useCORS:t.useCORS??!1,customIsSameOrigin:t.customIsSameOrigin,maxCacheSize:t.maxCacheSize}),Xu=(t,e,r)=>({logging:t.logging??!0,cache:t.cache??e.cache,...r}),Ku=800,ju=600,On=0,Zu=(t,e)=>{const r=e;return{windowWidth:t.windowWidth??r.innerWidth??Ku,windowHeight:t.windowHeight??r.innerHeight??ju,scrollX:t.scrollX??r.pageXOffset??On,scrollY:t.scrollY??r.pageYOffset??On}},qu=(t,e,r)=>({allowTaint:t.allowTaint??!1,onclone:t.onclone,ignoreElements:t.ignoreElements,iframeContainer:t.iframeContainer,inlineImages:r,copyStyles:r,cspNonce:t.cspNonce??e.cspNonce,signal:t.signal}),Qu=(t,e,r,n,o,s,i)=>({canvas:t.canvas,backgroundColor:e,signal:t.signal,scale:t.scale??i??1,x:(t.x??0)+r,y:(t.y??0)+n,width:t.width??Math.ceil(o),height:t.height??Math.ceil(s),imageSmoothing:t.imageSmoothing,imageSmoothingQuality:t.imageSmoothingQuality}),Ju=(t,e,r)=>{const n=e.ownerDocument,o=n.documentElement?Ut(t,getComputedStyle(n.documentElement).backgroundColor):0,s=n.body?Ut(t,getComputedStyle(n.body).backgroundColor):0,i=typeof r=="string"?Ut(t,r):r===null?0:4294967295;return e===n.documentElement?ot(o)?ot(s)?i:s:o:i},vt=(t,e,r,n)=>{if(t)try{t(r,n)}catch(o){e.logger.error(`onProgress callback failed: ${o instanceof Error?o.message:String(o)}`)}},td=async(t,e,r)=>{if(Hu(e),!e.skipValidation){const dt=e.validator||Jo(),ft=dt.validateElement(t);if(!ft.valid)throw new Error(ft.error);const et=dt.validateOptions(e);if(!et.valid)throw new Error(`Invalid options: ${et.error}`)}if(!t||typeof t!="object")throw new Error("Invalid element provided as first argument");const n=t.ownerDocument;if(!n)throw new Error("Element is not attached to a Document");const o=n.defaultView;if(!o)throw new Error("Document is not attached to a Window");const s=Yu(e),i=Xu(e,r,s),a=Zu(e,o),l=new W(a.scrollX,a.scrollY,a.windowWidth,a.windowHeight),c=new Gu(i,l,r),h=e.enablePerformanceMonitoring??e.logging??!1,u=new ts(c,h);u.start("total",{width:a.windowWidth,height:a.windowHeight});const d=e.signal;$(d);const f=e.foreignObjectRendering??!1,g=qu(e,r,f);c.logger.debug(`Starting document clone with size ${l.width}x${l.height} scrolled to ${-l.left},${-l.top}`),vt(e.onProgress,c,"clone",10),u.start("clone");const m=new hr(c,t,g),b=m.clonedReferenceElement;if(!b)throw new Error("Unable to find element in cloned iframe");const x=await m.toIFrame(n,l);u.end("clone"),vt(e.onProgress,c,"clone",30),d?.aborted&&((e.removeContainer??!0)&&hr.destroy(x),$(d));const{width:C,height:w,left:y,top:R}=Pr(b)||zi(b)?es(b.ownerDocument):le(c,b),M=Ju(c,b,e.backgroundColor),B=Qu(e,M,y,R,C,w,o.devicePixelRatio??1);let T,z;try{f?(c.logger.debug("Document cloned, using foreign object rendering"),u.start("render-foreignobject"),T=await new Du(c,B).render(b),u.end("render-foreignobject")):(c.logger.debug(`Document cloned, element located at ${y},${R} with size ${C}x${w} using computed rendering`),c.logger.debug("Starting DOM parsing"),u.start("parse"),$(d),c.cache.startDefer(),z=Fo(c,b,{normalizeDom:e.normalizeDom}),u.end("parse"),vt(e.onProgress,c,"parse",50),u.start("preload"),await c.cache.preloadAll(10,(dt,ft)=>{vt(e.onProgress,c,"preload",50+Math.round(dt/ft*10))},d),u.end("preload"),vt(e.onProgress,c,"layout",60),M===z.styles.backgroundColor&&(z.styles.backgroundColor=0),c.logger.debug(`Starting renderer for element at ${B.x},${B.y} with size ${B.width}x${B.height}`),u.start("render"),$(d),T=await new Ou(c,B).render(z),u.end("render")),vt(e.onProgress,c,"render",90)}finally{u.start("cleanup");try{z&&z.restoreTree()}finally{(e.removeContainer??!0)&&hr.destroy(x),u.end("cleanup")}}return u.end("total"),c.logger.debug("Finished rendering"),h&&u.logSummary(),vt(e.onProgress,c,"render",100),T},ed=(t,e={},r)=>{const n=r||qo.fromElement(t,{cspNonce:e.cspNonce,cache:e.cache});return td(t,e,n)};export{qo as Html2CanvasConfig,ts as PerformanceMonitor,Qo as Validator,Jo as createDefaultValidator,ed as default,ed as html2canvas};